Debugging Odin using gdb

TL;DR: To debug odin code using gdb, compile your code with -debug and -o:none
For example, odin build -debug -o:none . -debug might only give you the assembly, not the odin code.

I’m really only starting to use debuggers in a system programming language, but I thought I would document my journey learning that for Odin. For now, in some stream-of-consciouness way, to avoid procrastinating like if tried to write a blog post. :sweat_smile:

Let me know if I should have put it in another forum post category though.

For now, if you prefer staying in Emacs, I also really recommend Emacs’ gdb frontend, the recent gdb one, not the old `gdb-gud one. It better integrate with Emacs. You get to place and see breakpoint in the gutter/fringe and have a better experience than gdb’s TUI.

Next up, I’m going to try to attach a debugger to a odin test binary, to be able to inspect values in falling tests.

2 Likes