RFC strace via gdbserver
Stan Cox
scox at redhat.com
Wed Nov 2 18:54:41 UTC 2016
> Additionally, support for qualifying expressions (-e expr) and following
> children (-f) will be pushed soon.
-f and -e support has been added to the gdbserver remote protocol backend in the strace branch at https://github.com:stanfordcox/strace
Here is an interleaved example with two threads. gdb starts and runs the example with strace being attached to it.
GDB begin and set breaks
(gdb) b thread_worker_1
Breakpoint 2 at 0x4009ef: file tstthreads1.c, line 47.
(gdb) b thread_worker_2
Breakpoint 3 at 0x400a65: file tstthreads1.c, line 76.
STRACE begin
strace -G localhost:65432 -f -e '!futex,restart_syscall' -p 10508
Process 10508 attached in non-stop mode
GDB continue and do nexting
(gdb) c
Continuing.
[New Thread 11051.11063]
Thread 2 "tstthreads1.x" hit Breakpoint 2, thread_worker_1 () at tstthreads1.c:47
47 int unknown_syscall = 123456789;
(gdb) thr 2
[Switching to thread 2 (Thread 11051.11063)]
#0 thread_worker_1 () at tstthreads1.c:47
47 int unknown_syscall = 123456789;
(gdb) n
49 char buf1[2] = "a";
(gdb)
54 close (-1);
(gdb)
56 chroot (".");
(gdb)
STRACE reflects this
....
clone( <unfinished ...>
....
[pid 11051] <... clone resumed> child_stack=0x7ffff77fbff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7ffff77fc9d0, tls=0x7ffff77fc700, child_tidptr=0x7ffff77fc9d0) = 11063
[pid 11063] close(-1 <unfinished ...>
[pid 11051] mprotect(0xffffffff, 0, PROT_READ|PROT_GROWSUP|0x2083a620 <unfinished ...>
[pid 11063] <... close resumed> ) = -1 EBADF (Bad file descriptor)
[pid 11051] <... mprotect resumed> ) = -1 EPERM (Operation not permitted)
GDB nexting
(gdb) n
[New Thread 11051.11067]
58 pipe (fd);
(gdb)
60 write (fd[1], buf1, sizeof (buf1));
(gdb)
STRACE reflects this
[pid 11063] chroot(0x400b70 <unfinished ...>
[pid 11051] clone( <unfinished ...>
[pid 11063] <... chroot resumed> ) = -1 EPERM (Operation not permitted)
[pid 11051] <... clone resumed> child_stack=0, flags=CLONE_VM|CLONE_FS|CLONE_SIGHAND|0x400000|112) = -1 EPERM (Operation not permitted)
[pid 11067] set_robust_list(0x400b70, 0 <unfinished ...>
[pid 11063] pipe( <unfinished ...>
[pid 11067] <... set_robust_list resumed> ) = 0
[pid 11063] <... pipe resumed> [3, 4]) = 0
GDB switch threads and nexting
(gdb) thr 3
[Switching to thread 3 (Thread 11051.11067)]
#0 thread_worker_2 () at tstthreads1.c:76
76 int unknown_syscall = 123456789;
(gdb) n
78 char buf1[2] = "a";
(gdb)
83 close (-1);
(gdb)
70 syscall (unknown_syscall);
(gdb) 85 chroot (".");
n
87 pipe (fd);
STRACE
[pid 11063] pipe( <unfinished ...>
[pid 11067] <... set_robust_list resumed> ) = 0
[pid 11063] <... pipe resumed> [3, 4]) = 0
[pid 11063] write(4, "a\0", 2 <unfinished ...>
[pid 11063] read(3, "a\0", 2) = 2
[pid 11067] close(-1 <unfinished ...>
[pid 11067] chroot(0x400b70) = -1 EPERM (Operation not permitted)
More information about the Strace-devel
mailing list