The third parameter of sa_sigaction is a pointer which point to a machine-dependent struct ucontext
, I would like to know what I can dump from struct ucontext
.
void (*sa_sigaction)(int signum, siginfo_t *info, void *ucontext)
struct ucontext {
unsigned long uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
struct sigcontext uc_mcontext;
sigset_t uc_sigmask; /* mask last for extensibility */
};
Particularly through uc_mcontext (if you can show me where I can know more about other data members, that's would be great), as people usually use uc_mcontext
to dump host registers like this,
ucontext->uc_mcontext.gregs[REG_EIP]
Because uc_mcontext
type is struct sigcontext
, I look on struct sigcontext
in arch/x86/include/asm/sigcontext.h
.
struct sigcontext {
unsigned short gs, __gsh;
unsigned short fs, __fsh;
unsigned short es, __esh;
unsigned short ds, __dsh;
... snip ...
};
Is it the right one, beacuse I don't see gregs
in struct sigcontext
? Any suggestion is welcomed.
You are looking at the Linux kernel definition of sigcontext. You should be looking at the C library headers of struct ucontext. It is defined at /usr/include/sys/ucontext.h file
Note that it is architecture specific - e.g. the fields for x86 and PPC, for example, are totally different!