Ejemplo n.º 1
0
def parse_breakpoints(lines):
    # b [ (filename:lineno | function) [, "condition"] ]

    breakpoints = []
    for arg in lines:
        if not arg:
            continue
        arg = arg[1:]

        filename = None
        lineno = None
        cond = None
        comma = arg.find(',')

        if comma > 0:
            # parse stuff after comma: "condition"
            cond = arg[comma + 1:].lstrip()
            arg = arg[:comma].rstrip()

        colon = arg.rfind(':')
        funcname = None

        if colon > 0:
            filename = arg[:colon].strip()

            from pudb.lowlevel import lookup_module
            f = lookup_module(filename)

            if not f:
                continue
            else:
                filename = f

            arg = arg[colon + 1:].lstrip()
            try:
                lineno = int(arg)
            except ValueError:
                continue
        else:
            continue

        from pudb.lowlevel import get_breakpoint_invalid_reason
        if get_breakpoint_invalid_reason(filename, lineno) is None:
            breakpoints.append((filename, lineno, False, cond, funcname))

    return breakpoints
Ejemplo n.º 2
0
def parse_breakpoints(lines):
    # b [ (filename:lineno | function) [, "condition"] ]

    breakpoints = []
    for arg in lines:
        if not arg:
            continue
        arg = arg[1:]

        filename = None
        lineno = None
        cond = None
        comma = arg.find(",")

        if comma > 0:
            # parse stuff after comma: "condition"
            cond = arg[comma + 1 :].lstrip()
            arg = arg[:comma].rstrip()

        colon = arg.rfind(":")
        funcname = None

        if colon > 0:
            filename = arg[:colon].strip()

            from pudb.lowlevel import lookup_module

            f = lookup_module(filename)

            if not f:
                continue
            else:
                filename = f

            arg = arg[colon + 1 :].lstrip()
            try:
                lineno = int(arg)
            except ValueError, msg:
                continue
        else:
            continue

        from pudb.lowlevel import get_breakpoint_invalid_reason

        if get_breakpoint_invalid_reason(filename, lineno) is None:
            breakpoints.append((filename, lineno, False, cond, funcname))
Ejemplo n.º 3
0
        def toggle_breakpoint(w, size, key):
            if self.shown_file:
                sline, pos = self.source.get_focus()
                lineno = pos+1

                existing_breaks = self.debugger.get_breaks(
                        self.shown_file, lineno)
                if existing_breaks:
                    err = self.debugger.clear_break(self.shown_file, lineno)
                    sline.set_breakpoint(False)
                else:
                    from pudb.lowlevel import get_breakpoint_invalid_reason
                    invalid_reason = get_breakpoint_invalid_reason(
                            self.shown_file, pos+1)

                    if invalid_reason is not None:
                        do_set = not self.dialog(urwid.ListBox([
                            urwid.Text("The breakpoint you just set may be "
                                "invalid, for the following reason:\n\n"
                                + invalid_reason),
                            ]), [
                            ("Cancel", True),
                            ("Set Anyway", False),
                            ], title="Possibly Invalid Breakpoint",
                            focus_buttons=True)
                    else:
                        do_set = True

                    if do_set:
                        err = self.debugger.set_break(self.shown_file, pos+1)
                        sline.set_breakpoint(True)
                    else:
                        err = None

                if err:
                    self.message("Error dealing with breakpoint:\n"+ err)

                self.update_breakpoints()
            else:
                raise RuntimeError, "no valid current file"
Ejemplo n.º 4
0
        def run_to_cursor(w, size, key):
            if self.debugger.post_mortem:
                self.message("Post-mortem mode: Can't modify state.")
            else:
                sline, pos = self.source.get_focus()
                lineno = pos+1

                from pudb.lowlevel import get_breakpoint_invalid_reason
                invalid_reason = get_breakpoint_invalid_reason(
                        self.shown_file, lineno)

                if invalid_reason is not None:
                    self.message(
                        "Cannot run to the line you indicated, "
                        "for the following reason:\n\n"
                        + invalid_reason)
                else:
                    err = self.debugger.set_break(self.shown_file, pos+1, temporary=True)
                    if err:
                        self.message("Error dealing with breakpoint:\n"+ err)

                    self.debugger.set_continue()
                    end()