Skip to content
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_breaks to set up break points on compilation error & exception throw. It also tells GDB to unwind on exceptions thrown by eval'd code
  • show_node does a node token printMessage(node toString())
  • show_type does node getType() toString() println() -- crashes if type is nil
  • show_resolved shows what an AST node returns for isResolved()

I (amos) mostly use the gdb commands:

  • r - runs program. You can keep gdb open, recompile rock, run r again, answer y to the prompt, it'll run with the new binary and keep all your breakpoints & settings
  • bt - show back trace
  • frame <number> switch to frame number
  • print <C expression> print the result of a C expression
  • c - continues, or resume execution after a breakpoint
Clone this wiki locally