How to get process signal information in GDB?

Is there a way to get information about the signal (which signals are turned on, which are blocked, which handlers / parameters) for the process in gdb? There are info signals , but this gives me information about the processing of the gdb signal, and I need this information to debug the process - for example. to see if it blocks a particular signal or sees which handler it sets for that signal.

If relevant, my gdb is GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 15 08:33:48 UTC 2011) .

+6
source share
1 answer

Assuming you are connected to a running process and are not checking for a core dump, and assuming gdb can access characters, you should be able to call (via gdb) POSIX signal processing functions to determine information such as which signals are blocked and what signal handlers are registers.

For example, to determine whether a handler is registered for the SIGSEGV == 11 signal using the sigaction function, you can use the following:

 (gdb) call malloc(sizeof(struct sigaction)) $1 = (void *) 0x... (gdb) call malloc(sizeof(struct sigaction)) $2 = (void *) 0x... (gdb) call memset($2, 0, sizeof(struct sigaction)) ... (gdb) call sigaction(11, $2, $1) $... = 0 (gdb) print *((struct sigaction *)$1) <prints struct sigaction info> 

This information should allow you to determine the address of the handler, and then you can simply pass this to the info symbol command to determine which function is used as the handler.

Similar operations can be performed to determine which signals are blocked.

In addition, the special GDB variable $ _siginfo may be useful to you. See here for more information: http://sourceware.org/gdb/onlinedocs/gdb/Signals.html

Although I assumed $ _siginfo was not available for Apple / darwin purposes.

+9
source

Source: https://habr.com/ru/post/893997/


All Articles