Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stop execution in GDB without a breakpoint?

Tags:

gdb

How do I stop a GDB execution without a breakpoint?

like image 288
anand Avatar asked Jan 07 '09 19:01

anand


People also ask

How do I stop a program from running in gdb?

To exit GDB, use the quit command (abbreviated q ), or type an end-of-file character (usually C-d ). If you do not supply expression , GDB will terminate normally; otherwise it will terminate using the result of expression as the error code.

How do I skip a breakpoint in gdb?

To skip a breakpoint a certain number of times, we use the ignore command. The ignore command takes two arguments: the breakpoint number to skip, and the number of times to skip it. (gdb) ignore 2 5 Will ignore next 5 crossings of breakpoint 2.

How do you stop an infinite loop in gdb?

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.


1 Answers

Just use a regular interrupt Ctrl-c will work just fine. GDB just forwards the SIGINT to the debugging process which then dies. GDB will catch the non-standard exit and break the process there, so you can still examine all the threads, their stacks and current values of variables. This works fine, though you would be better off using break points. The only time I find myself doing this is, if I think I've gotten into some sort of infinite loop.

like image 85
luke Avatar answered Oct 03 '22 11:10

luke