My program is determined to stop its execution by hitting CTRL+C in command window. By now, I have a critical error right in this stopping phase, so i want to debug with gdb.
Problem is, gdb redefines CTRL+C as its own interrupt and pauses the execution when hitted. How can I handle it that CTRL+C powers my programm off and gdb can catch the stack trace?
To stop your program while it is running, type "(ctrl) + c" (hold down the ctrl key and press c). gdb will stop your program at whatever line it has just executed. From here you can examine variables and move through your program.
Normally when you run a program through GDB you can press Ctrl+C to interrupt it, e.g. if it gets stuck in an infinite loop and you want to get a backtrace.
From the (gdb) prompt, type signal SIGINT . This will send (surprize) SIGINT to the program being debugged. Alternatively, handle SIGINT nostop print pass will make GDB pass the signal straight to the inferior (being debugged) process. Ctrl-Z works in GDB: it suspends the process and gets you to that (gdb) prompt.
When you're doing a usual gdb session on an executable file on the same computer, you can give the run command and it will start the program over again.
From the (gdb)
prompt, type signal SIGINT
. This will send (surprize) SIGINT
to the program being debugged.
Alternatively, handle SIGINT nostop print pass
will make GDB pass the signal straight to the inferior (being debugged) process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With