Commits

Carl Friedrich Bolz committed 7373380

a somewhat hacky Pdb+ command "findv" to find variables of certain names
(default is "graph")

  • Participants
  • Parent commits b059fb4

Comments (0)

Files changed (1)

File rpython/translator/tool/pdbplus.py

             return
         self._show(page)
 
+    def do_findv(self, varname):
+        """ findv [varname]
+find a stack frame that has a certain variable (the default is "graph")
+"""
+        if not varname:
+            varname = "graph"
+        printfr = self.print_stack_entry
+        self.print_stack_entry = lambda *args: None
+        try:
+            num = 0
+            while self.curindex:
+                frame = self.curframe
+                if varname in frame.f_locals:
+                    printfr(self.stack[self.curindex])
+                    print "%s = %s" % (varname, frame.f_locals[varname])
+                    return
+                num += 1
+                self.do_up(None)
+            print "no %s found" % (varname, )
+            for i in range(num):
+                self.do_down(None)
+        finally:
+            del self.print_stack_entry
+
     def _attrs(self, arg, pr):
         arg, expr = self._parse_modif(arg, 'match')
         if expr == '_':