[pypy-commit] pypy reverse-debugger: More next/bnext tweaks

arigo pypy.commits at gmail.com
Fri Aug 5 11:40:41 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: reverse-debugger
Changeset: r86033:6b40ed980320
Date: 2016-08-05 17:42 +0200
http://bitbucket.org/pypy/pypy/changeset/6b40ed980320/

Log:	More next/bnext tweaks

diff --git a/pypy/interpreter/reverse_debugging.py b/pypy/interpreter/reverse_debugging.py
--- a/pypy/interpreter/reverse_debugging.py
+++ b/pypy/interpreter/reverse_debugging.py
@@ -512,7 +512,11 @@
         uid = 0
     else:
         uid = revdb.get_unique_id(frame)
-    revdb.send_answer(revdb.ANSWER_STACKID, uid)
+    if revdb.current_place() == -2:
+        hidden_level = 1      # hide the "<<" events from next/bnext commands
+    else:
+        hidden_level = 0
+    revdb.send_answer(revdb.ANSWER_STACKID, uid, hidden_level)
 lambda_stackid = lambda: command_stackid
 
 
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
@@ -237,47 +237,61 @@
 
     def command_next(self, argument):
         """Run forward for one step, skipping calls"""
-        stack_id = self.pgroup.get_stack_id(is_parent=False)
-        with self._stack_id_break(stack_id):
-            b = self.move_forward(1)
-        while b is not None:
-            # if we hit a regular breakpoint, stop
-            if any(b.regular_breakpoint_nums()):
-                return
-            # we hit only calls and returns inside stack_id.  If the
-            # last one of these is a "return", then we're now back inside
-            # stack_id, so stop
-            if b.nums[-1] == -2:
-                return
-            # else, the last one is a "call", so we entered another frame.
-            # Continue running until the next call/return event occurs
-            # inside stack_id
+        while True:
+            stack_id = self.pgroup.get_stack_id(is_parent=False)
             with self._stack_id_break(stack_id):
-                b = self.move_forward(self.pgroup.get_max_time() -
-                                      self.pgroup.get_current_time())
-            # and then look at that 'b' again (closes the loop)
+                b = self.move_forward(1)
+            while b is not None:
+                # if we hit a regular breakpoint, stop
+                if any(b.regular_breakpoint_nums()):
+                    return
+                # we hit only calls and returns inside stack_id.  If the
+                # last one of these is a "return", then we're now back inside
+                # stack_id, so stop
+                if b.nums[-1] == -2:
+                    break
+                # else, the last one is a "call", so we entered another frame.
+                # Continue running until the next call/return event occurs
+                # inside stack_id
+                with self._stack_id_break(stack_id):
+                    b = self.move_forward(self.pgroup.get_max_time() -
+                                          self.pgroup.get_current_time())
+                # and then look at that 'b' again (closes the loop)
+
+            # we might be at a "<<" position on the same line as before,
+            # which returns a get_hiddenpos_level() value of 1.  Continue
+            # until we reach a get_hiddenpos_level() value of 0.
+            if b is None or self.pgroup.get_hiddenpos_level() == 0:
+                break
     command_n = command_next
 
     def command_bnext(self, argument):
         """Run backward for one step, skipping calls"""
-        stack_id = self.pgroup.get_stack_id(is_parent=False)
-        with self._stack_id_break(stack_id):
-            b = self.move_backward(1)
-        while b is not None:
-            # if we hit a regular breakpoint, stop
-            if any(b.regular_breakpoint_nums()):
-                return
-            # we hit only calls and returns inside stack_id.  If the
-            # first one of these is a "call", then we're now back inside
-            # stack_id, so stop
-            if b.nums[0] == -1:
-                return
-            # else, the first one is a "return", so before, we were
-            # inside a different frame.  Continue running until the next
-            # call/return event occurs inside stack_id
+        while True:
+            stack_id = self.pgroup.get_stack_id(is_parent=False)
             with self._stack_id_break(stack_id):
-                b = self.move_backward(self.pgroup.get_current_time() - 1)
-            # and then look at that 'b' again (closes the loop)
+                b = self.move_backward(1)
+            while b is not None:
+                # if we hit a regular breakpoint, stop
+                if any(b.regular_breakpoint_nums()):
+                    return
+                # we hit only calls and returns inside stack_id.  If the
+                # first one of these is a "call", then we're now back inside
+                # stack_id, so stop
+                if b.nums[0] == -1:
+                    break
+                # else, the first one is a "return", so before, we were
+                # inside a different frame.  Continue running until the next
+                # call/return event occurs inside stack_id
+                with self._stack_id_break(stack_id):
+                    b = self.move_backward(self.pgroup.get_current_time() - 1)
+                # and then look at that 'b' again (closes the loop)
+
+            # we might be at a "<<" position on the same line as before,
+            # which returns a get_hiddenpos_level() value of 1.  Continue
+            # until we reach a get_hiddenpos_level() value of 0.
+            if self.pgroup.get_hiddenpos_level() == 0:
+                break
     command_bn = command_bnext
 
     def command_finish(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
@@ -587,8 +587,14 @@
     def edit_breakpoints(self):
         return self.all_breakpoints
 
+    def _stack_id(self, is_parent=0):
+        self.active.send(Message(CMD_STACKID, is_parent))
+        msg = self.active.expect(ANSWER_STACKID, Ellipsis, Ellipsis)
+        self.active.expect_ready()
+        return msg
+
     def get_stack_id(self, is_parent):
-        self.active.send(Message(CMD_STACKID, is_parent))
-        msg = self.active.expect(ANSWER_STACKID, Ellipsis)
-        self.active.expect_ready()
-        return msg.arg1
+        return self._stack_id(is_parent).arg1
+
+    def get_hiddenpos_level(self):
+        return self._stack_id().arg2


More information about the pypy-commit mailing list