Pause process to allow time for debugger to attach

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 😉

Leave a Comment