2008-12-16  Denys Vlasenko  <dvlas...@redhat.com>

        * defs.h: Add new field "sigtrap80" to struct tcb.
        * strace.c (alloc_tcb): Initialize it.
        (detach, trace): Use it in place of constant SIGTRAP.
        (trace): Set PTRACE_O_TRACESYSGOOD and PTRACE_O_TRACEEXEC
        options on newly traced threads; detect these
        options if they are inherited across clone(); detect
        and handle execve's ptrace stop; add paranoia checks
        if real SIGTRAP is seen.


Run tested on vanilla and utrace-based kernels.
Tested with "kill -TRAP $pid":

strace sleep N

strace sh -c "trap 'echo Oi' TRAP; sleep 1; sleep 1; sleep 1; sleep 1"

strace -f -oLOG firefox

None of the above works correctly with unpatched strace,
with patch SIGTRAP is visible in strace and acts
as any other signal.


Testing how we strace trapping instruction:

# cat z.S

_start: .globl _start
        int3
        movl $42,%ebx
        movl $1,%eax
        int $0x80

# gcc -nostartfiles -nostdlib -oz z.S

# ./strace ./z
execve("./z", ["./z"], [/* 55 vars */]) = 0
--- SIGTRAP (Trace/breakpoint trap) @ 0 (0) ---
+++ killed by SIGTRAP +++


Unpatched strace:

# strace ./z
execve("./z", ["./z"], [/* 55 vars */]) = 0
write(0, NULL, 0 <unfinished ... exit status 42>


--
vda


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to