Esempio n. 1
0
    def process_commands(self):
        """Handle debugger commands."""
        if self.core.execution_status != "No program":
            self.setup()
            Mlocation.print_location(self, self.event)
            pass
        leave_loop = run_hooks(self, self.preloop_hooks)
        self.continue_running = False

        while not leave_loop:
            try:
                run_hooks(self, self.precmd_hooks)
                # bdb had a True return to leave loop.
                # A more straight-forward way is to set
                # instance variable self.continue_running.
                leave_loop = self.process_command()
                if leave_loop or self.continue_running:
                    break
            except EOFError:
                # If we have stacked interfaces, pop to the next
                # one.  If this is the last one however, we'll
                # just stick with that.  FIXME: Possibly we should
                # check to see if we are interactive.  and not
                # leave if that's the case. Is this the right
                # thing?  investigate and fix.
                if len(self.debugger.intf) > 1:
                    del self.debugger.intf[-1]
                    self.last_command = ""
                else:
                    if self.debugger.intf[-1].output:
                        self.debugger.intf[-1].output.writeline("Leaving")
                        raise Mexcept.DebuggerQuit
                        pass
                    break
                pass
            pass
        return run_hooks(self, self.postcmd_hooks)
Esempio n. 2
0
    def process_commands(self):
        """Handle debugger commands."""
        if self.core.execution_status != 'No program':
            self.setup()
            Mlocation.print_location(self, self.event)
            pass
        leave_loop = run_hooks(self, self.preloop_hooks)
        self.continue_running = False

        while not leave_loop:
            try:
                run_hooks(self, self.precmd_hooks)
                # bdb had a True return to leave loop.
                # A more straight-forward way is to set
                # instance variable self.continue_running.
                leave_loop = self.process_command()
                if leave_loop or self.continue_running: break
            except EOFError:
                # If we have stacked interfaces, pop to the next
                # one.  If this is the last one however, we'll
                # just stick with that.  FIXME: Possibly we should
                # check to see if we are interactive.  and not
                # leave if that's the case. Is this the right
                # thing?  investigate and fix.
                if len(self.debugger.intf) > 1:
                    del self.debugger.intf[-1]
                    self.last_command = ''
                else:
                    if self.debugger.intf[-1].output:
                        self.debugger.intf[-1].output.writeline('Leaving')
                        raise Mexcept.DebuggerQuit
                        pass
                    break
                pass
            pass
        return run_hooks(self, self.postcmd_hooks)
Esempio n. 3
0
        def canonic_filename(self, frame):
            return frame.f_code.co_filename

        def __init__(self):
            self.debugger = Debugger()
            return

        pass

    core = MockCore()
    bwproc = BWProcessor(core)
    print("commands:")
    commands = list(bwproc.commands.keys())
    commands.sort()
    print(commands)
    print(resolve_name(bwproc, "quit"))
    # print('-' * 10)
    # print_source_line(sys.stdout.write, 100, 'source_line_test.py')
    # print('-' * 10)
    bwproc.frame = sys._getframe()
    bwproc.setup()
    # print()
    # print('-' * 10)
    Mlocation.print_location(bwproc)

    # print 'Removing non-existing quit hook: ', bwproc.remove_preloop_hook(fn)
    # bwproc.add_preloop_hook(fn)
    # print bwproc.preloop_hooks
    # print 'Removed existing quit hook: ', bwproc.remove_preloop_hook(fn)
    pass
Esempio n. 4
0
    class MockCore:
        def filename(self, fn): return fn

        def canonic_filename(self, frame): return frame.f_code.co_filename

        def __init__(self):
            self.debugger = Debugger()
            return
        pass
    core = MockCore()
    bwproc = BWProcessor(core)
    print 'commands:'
    commands = bwproc.commands.keys()
    commands.sort()
    print commands
    print resolve_name(bwproc, 'quit')
    # print '-' * 10
    # print_source_line(sys.stdout.write, 100, 'source_line_test.py')
    # print '-' * 10
    bwproc.frame = sys._getframe()
    bwproc.setup()
    # print
    # print '-' * 10
    Mlocation.print_location(bwproc)

    # print 'Removing non-existing quit hook: ', bwproc.remove_preloop_hook(fn)
    # bwproc.add_preloop_hook(fn)
    # print bwproc.preloop_hooks
    # print 'Removed existing quit hook: ', bwproc.remove_preloop_hook(fn)
    pass