Author: Armin Rigo <ar...@tunes.org> Branch: reverse-debugger Changeset: r85320:a80b43cb9d22 Date: 2016-06-22 10:05 +0200 http://bitbucket.org/pypy/pypy/changeset/a80b43cb9d22/
Log: Interface tweaks diff --git a/rpython/translator/revdb/interact.py b/rpython/translator/revdb/interact.py --- a/rpython/translator/revdb/interact.py +++ b/rpython/translator/revdb/interact.py @@ -25,8 +25,13 @@ def interact(self): last_command = 'help' + previous_time = None while True: last_time = self.pgroup.get_current_time() + if last_time != previous_time: + print + self.pgroup.show_backtrace(complete=0) + previous_time = last_time prompt = '(%d)$ ' % last_time sys.stdout.write(prompt) sys.stdout.flush() @@ -55,11 +60,19 @@ def command_help(self, argument): """Display commands summary""" print 'Available commands:' - for name in dir(self): - if name.startswith('command_'): - command = name[len('command_'):] - docstring = getattr(self, name).__doc__ or 'undocumented' - print '\t%-12s %s' % (command, docstring) + lst = dir(self) + commands = [(name[len('command_'):], getattr(self, name)) + for name in lst + if name.startswith('command_')] + seen = {} + for name, func in commands: + seen.setdefault(func, []).append(name) + for _, func in commands: + if func in seen: + names = seen.pop(func) + names.sort(key=len, reverse=True) + docstring = func.__doc__ or 'undocumented' + print '\t%-16s %s' % (', '.join(names), docstring) def command_quit(self, argument): """Exit the debugger""" @@ -92,6 +105,7 @@ print ', '.join(lst) def move_forward(self, steps): + self.remove_tainting() try: self.pgroup.go_forward(steps) return True @@ -123,7 +137,6 @@ def command_step(self, argument): """Run forward ARG steps (default 1)""" arg = int(argument or '1') - self.remove_tainting() self.move_forward(arg) command_s = command_step @@ -145,7 +158,6 @@ def command_next(self, argument): """Run forward for one step, skipping calls""" - self.remove_tainting() depth1 = self.pgroup.get_stack_depth() if self.move_forward(1): depth2 = self.pgroup.get_stack_depth() @@ -173,11 +185,12 @@ command_bn = command_bnext def command_finish(self, argument): - self.remove_tainting() + """Run forward until the current function finishes""" with self._stack_depth_break(self.pgroup.get_stack_depth()): self.command_continue('') def command_bfinish(self, argument): + """Run backward until the current function is called""" with self._stack_depth_break(self.pgroup.get_stack_depth()): self.command_bcontinue('') @@ -201,7 +214,7 @@ def command_backtrace(self, argument): """Show the backtrace""" - self.pgroup.show_backtrace() + self.pgroup.show_backtrace(complete=1) command_bt = command_backtrace def command_locals(self, argument): diff --git a/rpython/translator/revdb/process.py b/rpython/translator/revdb/process.py --- a/rpython/translator/revdb/process.py +++ b/rpython/translator/revdb/process.py @@ -412,10 +412,10 @@ self.active.send(Message(CMD_PRINT, extra=expression)) self.active.print_text_answer(pgroup=self) - def show_backtrace(self): + def show_backtrace(self, complete=1): """Show the backtrace. """ - self.active.send(Message(CMD_BACKTRACE)) + self.active.send(Message(CMD_BACKTRACE, complete)) self.active.print_text_answer() def show_locals(self): diff --git a/rpython/translator/revdb/test/test_process.py b/rpython/translator/revdb/test/test_process.py --- a/rpython/translator/revdb/test/test_process.py +++ b/rpython/translator/revdb/test/test_process.py @@ -28,7 +28,7 @@ lambda_blip = lambda: blip def main(argv): - revdb.register_debug_command(1, lambda_blip) + revdb.register_debug_command(100, lambda_blip) for i, op in enumerate(argv[1:]): dbstate.stuff = Stuff() dbstate.stuff.x = i + 1000 @@ -63,8 +63,8 @@ def test_breakpoint_b(self): group = ReplayProcessGroup(str(self.exename), self.rdbname) - group.active.send(Message(1, 6, extra='set-breakpoint')) - group.active.expect(42, 1, -43, -44, 'set-breakpoint') + group.active.send(Message(100, 6, extra='set-breakpoint')) + group.active.expect(42, 100, -43, -44, 'set-breakpoint') group.active.expect(ANSWER_READY, 1, Ellipsis) e = py.test.raises(Breakpoint, group.go_forward, 10, 'b') assert e.value.time == 7 @@ -73,8 +73,8 @@ def test_breakpoint_r(self): group = ReplayProcessGroup(str(self.exename), self.rdbname) - group.active.send(Message(1, 6, extra='set-breakpoint')) - group.active.expect(42, 1, -43, -44, 'set-breakpoint') + group.active.send(Message(100, 6, extra='set-breakpoint')) + group.active.expect(42, 100, -43, -44, 'set-breakpoint') group.active.expect(ANSWER_READY, 1, Ellipsis) e = py.test.raises(Breakpoint, group.go_forward, 10, 'r') assert e.value.time == 8 @@ -83,7 +83,7 @@ def test_breakpoint_i(self): group = ReplayProcessGroup(str(self.exename), self.rdbname) - group.active.send(Message(1, 6, extra='set-breakpoint')) - group.active.expect(42, 1, -43, -44, 'set-breakpoint') + group.active.send(Message(100, 6, extra='set-breakpoint')) + group.active.expect(42, 100, -43, -44, 'set-breakpoint') group.active.expect(ANSWER_READY, 1, Ellipsis) group.go_forward(10, 'i') # does not raise Breakpoint _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit