Pause process to allow time for debugger to attach

后端 未结 1 960
臣服心动
臣服心动 2020-12-04 00:24

I\'d like to attach gdb to a process where I can\'t easily control the startup of the process because it is run from inetd and where the process completes too fast to be abl

相关标签:
1条回答
  • 2020-12-04 00:44

    What I'd like to do is insert a bit of code at the particular point that I want to start debugging.

    I usually do it like this:

    volatile int done = 0;
    while (!done) sleep(1);
    

    Attach GDB (you'll be inside sleep). Do finish, then set var done = 1, and enjoy the rest of your debugging session ;-)

    0 讨论(0)
提交回复
热议问题