2010-05-25

Debugging an already-running process

I was getting a segfault in pms, an ncurses application I contribute to, so I restarted the program within gdb. But since the bug seems to be something to do with resizing the console window the segfault never appeared again -- gdb doesn't pass the resize signal (or perhaps the new dimensions) on to the program running within it.

I Googled around for a way to run gdb in a separate console window from the ncurses application. It's rather simple: change to the directory containing the binary so it can find the right one to debug against and run gdb -p $(pidof pms).

That'll attach gdb to the already running process and pause it. Type continue in the gdb window and await the crash.

No comments:

Post a Comment