Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print the last received signal in GDB?

when loading a core dump into GDB the reason why it crashed automatically is displayed. For example

Program terminated with signal 11, Segmentation fault.

Is there any way to get the information again? The thing is, that I'm writing a script which needs this information. But if the signal is only available after loading the core dump amd I can't access the information later on.

Is there really no command for such an important feature?

like image 248
Uhlo Avatar asked Jan 17 '12 16:01

Uhlo


People also ask

What does Ctrl C do in GDB?

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.

How does GDB use Ptrace?

The role of ptrace() in GDBIt lets GDB observe and control the execution of the inferior program. ptrace() can, for example, set the registers, peek and poke memory, continue or interrupt the inferior — all the good stuff we need for debugging. The inferior and GDB asynchronously communicate via signals.

How do I send Sigint in GDB?

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.

How do I stop GDB after continue?

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. To specify other places where gdb should stop, see the section on breakpoints below.


1 Answers

To print the information about the last signal execute

p $_siginfo
like image 138
steve Avatar answered Oct 01 '22 19:10

steve