I am debugging a program using gdb. First I load
my executable, then I continue
to run the program. I sometimes want to interrupt execution of my program, so I do Ctrl + C
.
My problem is that this closes both my program and gdb. How can I exit my program without exiting gdb?
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.
The QUIT command ends a z/OS® Debugger session and, if an expression is specified, sets the return code. In full-screen mode, it also displays a prompt panel that asks if you really want to quit the debug session. In line, batch, and remote debug mode, the QUIT command ends the session without prompting.
Like you can cancel a program on the command line, GDB lets you use ctrl-c to stop a program wherever it currently is. Hit ctrl-c now to break the infinite loop.
According to GDB documentation : Batch mode disables pagination, sets unlimited terminal width and height see Screen Size, and acts as if set confirm off were in effect (see Messages/Warnings).
Have you tried to use kill
from inside gdb?
Use ctrl-c to interrupt the application. Then run "signal SIGINT" from the GDB prompt, which will send this signal to your application, causing it to do the same things it would normally have done when you do ctrl-c from the command line.
Looks like under Windows, you have to use Ctrl-Break
not Ctrl-C
. See this page.
Excerpt:
MS-Windows programs that call SetConsoleMode to switch off the special meaning of the `Ctrl-C' keystroke cannot be interrupted by typing C-c. For this reason, gdb on MS-Windows supports C- as an alternative interrupt key sequence, which can be used to interrupt the debuggee even if it ignores C-c.
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