Skip to content

Instantly share code, notes, and snippets.

@flaviut
Last active August 29, 2015 14:13
Show Gist options
  • Save flaviut/487be89b8abfae2612e8 to your computer and use it in GitHub Desktop.
Save flaviut/487be89b8abfae2612e8 to your computer and use it in GitHub Desktop.
How to debug Nim code

Nim Debugging

I use GDB to debug my Nim code, but by default Nim doesn't output enough information to be usable. I pass --debuginfo --linedir:on to the nim command to fix that.

There is some name mangling, but in most cases things are still understandable. procs have an integer appended to the name, so when setting a breakpoint is done like this: b foo_431313. It's also possible to just line number for breakpoints, which is exactly as you might expect: b mymodule.nim:321.

Inspecting strings is a bit of work, you have to do print str->data. Seqs are the same, the contents can be found at print myseq->data[n].

GDB shows you each line as it executes it, so it's easy to tell where in the code you are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment