4 ms·
In VSCode and Neovim there's a visual debugger but in general you can compile with `--debugger:native` and use GDB, for example: A guide to debugging and profi
by arc619 6y ago
In VSCode and Neovim there's a visual debugger but in general you can compile with `--debugger:native` and use GDB, for example:
A guide to debugging and profiling: https://nim-lang.org/blog/2017/10/02/documenting-profiling-and-debugging-nim-code.html https://nim-lang.org/blog/2017/10/02/documenting-profiling-a...
Guide for working directly with GDB-Nim: https://internet-of-tomohiro.netlify.app/nim/gdb.en.html https://internet-of-tomohiro.netlify.app/nim/gdb.en.html
A walk through and extra info with the language devs: https://www.youtube.com/watch?v=DmYOPkI_LzU https://www.youtube.com/watch?v=DmYOPkI_LzU
- FartyMcFarter 6y agoBut would you then be debugging the automatically-generated C++ code, which is presumably harder to read than the original Nim source code?
- arc619 6y agoTechnically yes, but directives are inserted so GDB reports the line number, source code, and parameters of the Nim file. However GDB shows the name mangling suffix in generated code, and types are their native types. There's a script called nim-gdb to add pretty printers for types to the GDB output to show the Nim source types. Perhaps surprisingly though, the C and C++ generated output itself is fairly straightforward, even with name mangling suffixes. The inserted directives tell you the Nim source line so you can navigate it fairly well if you want to, and the suffix means the variable is unique referenced in the code. As far as I know you can use any debugger that supports the target language, though I've not tried anything but GDB myself. It's very rare for me to dig into the generated code but sometimes I'm curious about the data structure analog in the target language. In the case of Nim's object variants, last time I looked when compiling to C they were ultimately reduced to simple checked union types.
- FpUser 6y agoLooks more or less workable but I guess not as good as what you get in Visual Studio
- arc619 6y agoNot yet, no. I hope with companies like JetBrains working on their Nim plugin https://plugins.jetbrains.com/plugin/15128-nim https://plugins.jetbrains.com/plugin/15128-nim we'll see more focus put on a smooth IDE based debugging experience in particular.