I made small assembly code about registering signal handler.
.section .data
.set SIGSEGV, 11
.set SA_SIGINFO, 4
.section .bss
.lcomm my_sigaction, 140 # size of sigaction struction is 140
.section .text
.global main
myhandler:
nop
push %eax
pop %eax
main:
# Registring signal handler for SIGSEGV
movl $myhandler, my_sigaction # fill sa_handler field
movl $132, %edi # fill sa_flags field
movl $SA_SIGINFO, my_sigaction(,%edi,1) # SA_SIGINFO designate that whenever signal appears, run the signal handling function.
# Call sigaction(int, const struct sigaction *, struct sigaction *)
pushl $0 # 1st param : oact
pushl $my_sigaction # 2nd param : act
pushl $SIGSEGV # 3rd param : sig
call sigaction
addl $12, %esp
jmp 0x11223344 # Segmantation fault
When I execute compiled binary, myhandler
worked well.
However ... when I tried to debug this, gdb just stoped after SIGSEGV signal occurred.
So I could not reach to myhandler
with gdb..
Question.
How can I debug myhandler
function, which runs after SIGSEGV signal?
PS 1. I checked here, but setting follow-process-mode wasn't helpful in my case. ;(
PS 2. I checked here, but after asserting handle SIGSEGV nostop
, gdb infinitely emits the "Program received signal SIGSEGV, Segmentation fault" message when SIGSEGV occured...