[PATCH] Add gdb remote protocol handling to strace

Stan Cox scox at redhat.com
Fri Nov 10 17:35:25 UTC 2017


Example usage:
gdbserver --once --multi :65432 & sleep 2 ; /work/scox/strace/mysrc/strace -G localhost:65432 ~/src/hello.x
[1] 4979
Listening on port 65432
/work/scox/strace/mysrc/strace: -G is always multithreaded, implies -f
Remote debugging from host 127.0.0.1
Process /home/scox/src/hello.x created; pid = 4988
brk(NULL)                               = 0x602000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffff7ff5000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/home/scox/lib/tls/x86_64/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/scox/lib/tls/x86_64", 0x7fffffffd490) = -1 ENOENT (No such file or directory)
open("/home/scox/lib/tls/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/scox/lib/tls", 0x7fffffffd490) = -1 ENOENT (No such file or directory)
open("/home/scox/lib/x86_64/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/scox/lib/x86_64", 0x7fffffffd490) = -1 ENOENT (No such file or directory)
open("/home/scox/lib/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/scox/lib", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
open("/usr/local/lib/tls/x86_64/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib/tls/x86_64", 0x7fffffffd490) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/tls/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib/tls", 0x7fffffffd490) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/x86_64/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib/x86_64", 0x7fffffffd490) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=146434, ...}) = 0
mmap(NULL, 146434, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffff7fd1000
close(3)                                = 0
open("/lib64/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\270\10\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1590720, ...}) = 0
mmap(NULL, 3699296, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff7a4f000
mprotect(0x7ffff7bc7000, 2097152, PROT_NONE) = 0
mmap(0x7ffff7dc7000, 49152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x178000) = 0x7ffff7dc7000
mmap(0x7ffff7dd3000, 12896, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ffff7dd3000
close(3)                                = 0
open("/home/scox/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib64/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0 W\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1169416, ...}) = 0
mmap(NULL, 3178728, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff7746000
mprotect(0x7ffff784e000, 2093056, PROT_NONE) = 0
mmap(0x7ffff7a4d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x107000) = 0x7ffff7a4d000
close(3)                                = 0
open("/home/scox/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open(0x7ffff7ff60a8, O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240*\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=92872, ...}) = 0
mmap(NULL, 2188336, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff752f000
mprotect(0x7ffff7545000, 2093056, PROT_NONE) = 0
mmap(0x7ffff7744000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x7ffff7744000
close(3)                                = 0
open("/home/scox/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open(0x7ffff7ff6578, O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\5\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2115656, ...}) = 0
mmap(NULL, 3954976, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffff7169000
mprotect(0x7ffff7326000, 2093056, PROT_NONE) = 0
mmap(0x7ffff7525000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bc000) = 0x7ffff7525000
mmap(0x7ffff752b000, 14624, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ffff752b000
close(3)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffff7fcf000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffff7fcd000
arch_prctl(ARCH_SET_FS, 0x7ffff7fd0600) = 0
mprotect(0x7ffff7525000, 16384, PROT_READ) = 0
mprotect(0x7ffff7744000, 4096, PROT_READ) = 0
mprotect(0x7ffff7a4d000, 4096, PROT_READ) = 0
mprotect(0x7ffff7dc7000, 40960, PROT_READ) = 0
mprotect(0x600000, 4096, PROT_READ)     = 0
mprotect(0x7ffff7ffc000, 4096, PROT_READ) = 0
munmap(0x7ffff7fd1000, 146434)          = 0
brk(NULL)                               = 0x602000
brk(0x634000)                           = 0x634000
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
write(1, "hello world\n", 12hello world
)           = 12
exit_group(0Killing process(es): 4988





More information about the Strace-devel mailing list