Skip to contentSkip to conversation

the fault address of a traced process

DISCUSSION Bruce Janson 2 participants 2 messages Sep 30, 2001

lore
Share & tools
lore
#0 lore raw

One process traces another.
When the traced process tries to read, write or execute an unmapped address it is stopped with a SIGSEGV signal.
The tracer now wants to determine the traced process' faulted address. According to the (2.2.19) kernel source

.../arch/i386/mm/fault.c:do_page_fault()

such a fault in user mode causes the offending address and error code to be saved in

tsk->tss.cr2

and

tsk->tss.error_code

respectively. There do not appear to be ptrace() or /proc hooks to extract this data directly. In earlier unices extraction of this data would have required grubbing around in /dev/kmem using the kernel namelist as a guide.
How should a tracer extract this information under a current (2.2.*, 2.4.*) Linux?

#1 lore raw
Quoted 2 lines · [email protected] said:

The tracer now wants to determine the traced process' faulted address. According to the (2.2.19) kernel source

[snip]

Quoted 2 lines

How should a tracer extract this information under a current (2.2.*, 2.4.*) Linux?

Read some more UML source, specifically,

segv_handler() in arch/um/kernel/trap_user.c and also the i386 definitions in arch/um/include/sysdep-i386/sigcontext.h

Basically, you are passed the necessary information in a sigcontext struct.

Jeff