-
Notifications
You must be signed in to change notification settings - Fork 40
Debugging rock
Amos Wenger edited this page Jul 13, 2015
·
1 revision
Here's a workflow to debug rock. First, compile a debug build:
(cd $OOC_LIBS/rock && OOC_FLAGS="-O0 --nolines" make clean safe)
(Assuming you've made backup at some point in the past, i.e. after upgrading to a new stable release, which you should always do)
Then, you can run rock through gdb, assuming you're debugging a test, for example, run:
gdb --args rock -x --nolines -vv test/compiler/folder/sometest.ooc
To learn how to use gdb, read its documentation!
Here's a bunch of GDB functions that help:
- run
ooc_breaksto set up break points on compilation error & exception throw. It also tells GDB to unwind on exceptions thrown by eval'd code -
show_nodedoes anode token printMessage(node toString()) -
show_typedoesnode getType() toString() println()-- crashes if type is nil -
show_resolvedshows what an AST node returns forisResolved()
I (amos) mostly use the gdb commands:
-
r- runs program. You can keep gdb open, recompile rock, runragain, answeryto the prompt, it'll run with the new binary and keep all your breakpoints & settings -
bt- show back trace -
frame <number>switch to framenumber -
print <C expression>print the result of a C expression -
c- continues, or resume execution after a breakpoint