Example of source-location support
David Malcolm
dmalcolm@redhat.com
Tue Jan 1 00:00:00 GMT 2013
I've added support for source-locations to my jittest toy interpreter
[1] (as commit 4f50dee08dd92a0006b6d53d52c137adbb9932ea). In my test
example I do it in a rather contrived way by associating the stackvm
bytecodes with the locations in main.cc containing the table
initializing them, but in a real interpreter you'd get this data from
the parser.
This allows stepping through JIT-compiled bytecodes within gdb:
(gdb) break fibonacci
(gdb) run
Breakpoint 1, fibonacci (input=8) at main.cc:43
43 DUP,
(gdb) next
47 PUSH_INT_CONST, 2,
(gdb) next
51 BINARY_INT_COMPARE_LT,
(gdb) next
55 JUMP_ABS_IF_TRUE, 17,
(gdb) next
59 DUP,
(gdb) next
63 PUSH_INT_CONST, 1,
(gdb) next
67 BINARY_INT_SUBTRACT,
(gdb) next
71 CALL_INT,
(gdb) next
Breakpoint 1, fibonacci (input=7) at main.cc:43
43 DUP,
(...etc)
So hopefully this aspect of the library should now be usable for real
interpreters, giving users the ability to step through JIT-compiled
functions from in the debugger at the level of lines of script files.
Dave
[1] https://github.com/davidmalcolm/jittest
More information about the Jit
mailing list