Vim
, gdb
, C
, Go
VIM REFERENCE MANUAL - Debugging terminal-debug
C source:
Makefile:
make
vim main.c
Vim's command mode :packadd termdebug
to load debug plugin, which has been included in Vim.
Start debug test application with commad :Termdebug test
. It will split the terminal into 3 parts:
The gdb window is the gdb. So, just use gdb as usual in the window.
Ctrl + w
twice can jump between the windows.
Jump to the source window. Then, can go to the line and add a break point at the line by :Break
. Finally, jump back to the gdb window to run the program. It will stop at the line.
Go application can be debugged with GDB as well.
https://go.dev/doc/gdb
I try to make it go with debug symbols directly.
To have better debug information, add -N -l
into build's C flags, which disables optimizations and inlining.
Go source:
Makefile: