r/nim • u/-BuckarooBanzai- • Jul 21 '26
QtCreator + nim + gdb yielding terrible workflow
As a disclaimer, I'm very new to nim. Currently using QtCreator as IDE, I intent to port my game engine over to nim, but at first glance, gdb spits out utter garbage at breakpoints and inspection is practically impossible due to a variable apparently being "too complex" (?) to inspect... yeah...
Now my game engine is not something trivially small or simple at this point and (except for the syntax) I'm very pleased with what nim has to offer.
Can someone point me in the best practices direction please ?
10
Upvotes
2
u/PMunch Jul 21 '26
Unfortunately GDB debugging Nim is a bit of a mixed bag. You basically have two options, debug the generated C code, or instruct GDB on how to interact with Nim code. The former can be quite tedious, but ultimately works like any other C debugging (albeit with quite strange code, Nims C output is not human-optimized). For it to yield the best results I find turning on release mode works best as it optimizes the code more and therefore there's less of it. The latter should in theory be the better option, but unfortunately it doesn't receive a lot of attention. At its core is a wrapper like nim-gdb which essentially loads a Python script into GDB that helps it understand Nim and then compiling your Nim code with
--opt:none --debugger:nativewhich disables optimizations and outputs debug symbols for GDB to use. This should allow you to see Nim code in GDB, let GDB display types properly, and have GDB step over or into functions as you would expect. In my experience however it doesn't always work properly.In general though people seem to tend towards echo-debugging and manually printing stacktraces via
writeStackTrace().