Author: Carl Friedrich Bolz <cfb...@gmx.de>
Branch: reverse-debugger
Changeset: r85958:fa384c882956
Date: 2016-07-14 10:44 +0200
http://bitbucket.org/pypy/pypy/changeset/fa384c882956/

Log:    a nicer get_printable_location

diff --git a/rpython/jit/tl/tla/tla.py b/rpython/jit/tl/tla/tla.py
--- a/rpython/jit/tl/tla/tla.py
+++ b/rpython/jit/tl/tla/tla.py
@@ -60,19 +60,34 @@
 
 # ____________________________________________________________
 
-CONST_INT = 1
-POP       = 2
-ADD       = 3
-RETURN    = 4
-JUMP_IF   = 5
-DUP       = 6
-SUB       = 7
-NEWSTR    = 8
+OPNAMES = []
+HASARG = []
+
+def define_op(name, has_arg=False):
+    globals()[name] = len(OPNAMES)
+    OPNAMES.append(name)
+    HASARG.append(has_arg)
+
+define_op("CONST_INT", True)
+define_op("POP")
+define_op("ADD")
+define_op("RETURN")
+define_op("JUMP_IF", True)
+define_op("DUP")
+define_op("SUB")
+define_op("NEWSTR", True)
+
 
 # ____________________________________________________________
 
 def get_printable_location(pc, bytecode):
-    return str(pc)
+    op = ord(bytecode[pc])
+    name = OPNAMES[op]
+    if HASARG[op]:
+        arg = str(ord(bytecode[pc + 1]))
+    else:
+        arg = ''
+    return "%s: %s %s" % (pc, name, arg)
 
 jitdriver = JitDriver(greens=['pc', 'bytecode'],
                       reds=['self'],
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to