Catching a signal and Debugging

11/22/2015 , 0 Comments

GDB로  디버깅 할 때, 여러가지 Signal때문에, 디버깅이 제대로 되지 않은 경우가 발생합니다.
간혹, 아래와 같은 식으로, Signal을 안티디버깅에 사용하는 경우도 있었습니다.

이때는 handle 명령으로 signal에 대한 제어가 가능합니다.
‘stop’, ‘nostop’, ‘print’, ‘noprint’, ‘pass’, ‘nopass’, ‘ignore’, ‘noignore’ 가 있습니다.


handle SIGUSR1 nostop

위의 명령과 같이 SIGUSR1 Signal에 대해 nostop 처리하면 효과적으로 디버깅이 가능합니다.


Reading symbols for shared libraries +. done
0x3a90aa50 in mach_msg_trap ()
(gdb) c
Continuing.

Program received signal SIGUSR1, User defined signal 1.
[Switching to process 1075 thread 0xcb23]
0x3a90e24c in poll ()
(gdb) c
Continuing.

Program received signal SIGUSR1, User defined signal 1.
0x3a90e24c in poll ()
(gdb) c
Continuing.

Program received signal SIGUSR1, User defined signal 1.
0x3a90e24c in poll ()
(gdb) c
Continuing.

Program received signal SIGUSR1, User defined signal 1.
0x3a90e24c in poll ()
(gdb) handle SIGUSR1 nostop
Signal        Stop  Print   Pass to program Description
SIGUSR1       No    Yes Yes     User defined signal 1
(gdb) c
Continuing.

Program received signal SIGUSR1, User defined signal 1.

Program received signal SIGUSR1, User defined signal 1.

Program received signal SIGUSR1, User defined signal 1.

Program received signal SIGUSR1, User defined signal 1.

Program received signal SIGUSR1, User defined signal 1.

If you need my help, tell me anytime. Facebook