I\'m trying to debug a custom thread pool implementation that has rarely deadlocks. So I cannot use a debugger like gdb because I have click like 100 times \"launch\"
There are 2 basic ways:
gdb program -ex 'run ' -ex 'quit'
should run the program under debugger and then quit. If the program is still alive in one form or another (segfault, or you broke it manually) you will be asked for confirmation.gdb
to attach to running program - just wait for deadlock and attach then. This is especially useful when attached debugger causes timing to be changed and you can no longer repro the bug.In this way you can just run it in loop and wait for result while you drink coffee. BTW - I find the second option easier.