Lind-Project / native_client

native_client trusted code base
BSD 3-Clause "New" or "Revised" License
6 stars 4 forks source link

Lind Strace #149

Closed yizhuoliang closed 9 months ago

yizhuoliang commented 10 months ago

Description

Adding tracing feature at the interface between NaCl and the safeposix syscall implementations. Thanks Rupesh and Yash for filling in the tracing functions @yashaswi2000 @rupeshkoushik07

Usage

Type of change

Sample output with running socketselect.c

1 getuid() = -1
1 geteuid() = -1
1 getgid() = -1
1 getegid() = -1
1 open(./socketselect.nexe, 0, 0) = 3
1 read(3, 0x360ffffefa48, 832) = 832
1 lseek(3, 0x7f624a27ac58, 0) = 0
1 read(3, 0x360ffffef930, 36) = 36
1 fstat(3, 0x7f624a27ac00) = 0
1 getcwd(0x360f10040d38, 128) = 0
1 mmap(0x11000000, 196608, 0, 34, -1, 0x00000000) = 285212672
1 mmap(0x1000000, 65536, 5, 18, 3, 0x00010000) = -22
1 mmap((nil), 65536, 1, 2, 3, 0x00010000) = -16842752
1 munmap(0x360ffeff0000, 65536) = 0
1 mmap(0x11000000, 65536, 1, 2066, 3, 0x00020000) = 285212672
1 mmap(0x11010000, 65536, 3, 2066, 3, 0x00020000) = 285278208
1 mmap(0x11020000, 128, 3, 50, -1, 0x00000000) = 285343744
1 close(3) = 0
1 mutex_create() = 0
1 access(/etc/ld.so.preload, 4) = -2
1 open(/lib/glibc/libgcc_s.so.1, 0, 0) = 3
1 read(3, 0x360ffffef7d8, 832) = 832
1 lseek(3, 0x7f624a27ac58, 0) = 0
1 read(3, 0x360ffffef560, 36) = 36
1 fstat(3, 0x7f624a27ac00) = 0
1 mmap(0x11030000, 196608, 0, 34, -1, 0x00000000) = 285409280
1 mmap(0x1030000, 65536, 5, 18, 3, 0x00010000) = -22
1 mmap((nil), 65536, 1, 2, 3, 0x00010000) = -16842752
1 munmap(0x360ffeff0000, 65536) = 0
1 mmap(0x11030000, 65536, 1, 2066, 3, 0x00020000) = 285409280
1 mmap(0x11040000, 65536, 3, 2066, 3, 0x00020000) = 285474816
1 mmap(0x11050000, 212, 3, 50, -1, 0x00000000) = 285540352
1 close(3) = 0
1 open(/lib/glibc/libpthread.so.990e7c45, 0, 0) = 3
1 read(3, 0x360ffffef7b8, 832) = 832
1 lseek(3, 0x7f624a27ac58, 0) = 0
1 read(3, 0x360ffffef530, 36) = 36
1 fstat(3, 0x7f624a27ac00) = 0
1 mmap(0x11060000, 262144, 0, 34, -1, 0x00000000) = 285605888
1 mmap(0x1060000, 131072, 5, 18, 3, 0x00010000) = -22
1 mmap((nil), 131072, 1, 2, 3, 0x00010000) = -16908288
1 munmap(0x360ffefe0000, 131072) = 0
1 mmap(0x11060000, 65536, 1, 2066, 3, 0x00030000) = 285605888
1 mmap(0x11070000, 131072, 3, 2066, 3, 0x00030000) = 285671424
1 mmap(0x11090000, 8400, 3, 50, -1, 0x00000000) = 285802496
1 close(3) = 0
1 open(/lib/glibc/libc.so.990e7c45, 0, 0) = 3
1 read(3, 0x360ffffef798, 832) = 832
1 lseek(3, 0x7f624a27ac58, 0) = 0
1 read(3, 0x360ffffef520, 36) = 36
1 fstat(3, 0x7f624a27ac00) = 0
1 mmap(0x110a0000, 589824, 0, 34, -1, 0x00000000) = 285868032
1 mmap(0x10a0000, 1769472, 5, 18, 3, 0x00010000) = -22
1 mmap((nil), 1769472, 1, 2, 3, 0x00010000) = -18546688
1 munmap(0x360ffee50000, 1769472) = 0
1 mmap(0x110a0000, 393216, 1, 2066, 3, 0x001c0000) = 285868032
1 mmap(0x11100000, 131072, 3, 2066, 3, 0x00210000) = 286261248
1 mmap(0x11120000, 10128, 3, 50, -1, 0x00000000) = 286392320
1 close(3) = 0
1 mutex_lock(0) = 0
1 mutex_unlock(0) = 0
1 mmap((nil), 196608, 3, 131106, -1, 0x00000000) = -16973824
1 mmap((nil), 196608, 3, 131106, -1, 0x00000000) = -17170432
1 mutex_lock(0) = 0
1 cond_create() = 0
1 socket(2, 1, 0) = 3
1 setsockopt(3, 1, 2, 0x360ffefff310, 4) = 0
1 ioctl(3, 21537, 0x360ffefff310) = 0
1 socket(2, 1, 0) = 4
1 setsockopt(4, 1, 2, 0x360ffefcef1c, 4) = 0
1 mutex_lock(0) = 0
1 cond_create() = 1
1 bind(3, 0x360ffefff2b0, 16) = 0
1 listen(3, 1) = 0
1 mutex_lock(0) = 0
1 cond_signal(1) = 0
1 mutex_unlock(0) = 0
1 fstat(1, 0x7f624a269c00) = 0
1 mmap((nil), 8192, 3, 34, -1, 0x00000000) = -17235968
1 write(1, 0x360ffef90000, 23) = 23
1 cond_wait(1, 0) = 0
1 mutex_unlock(0) = 0
1 connect(4, 0x360ffefcf320, 16) = 0
1 send(4, 17, 0, 0x360f11000a70) = 17
1 select(4, 0x360ffefff1a0, 0x00000000, 0x00000000, 0x360ffefff2a0) = 1
1 write(1, 0x360ffef90000, 50) = 50
1 accept(3, 0x00000000, 0x00000000) = 5
1 write(1, 0x360ffef90000, 30) = 30
1 accept(3, 0x00000000, 0x00000000) = -11
1 write(1, 0x360ffef90000, 23) = 23
1 select(6, 0x360ffefff1a0, 0x00000000, 0x00000000, 0x360ffefff2a0) = 1
1 write(1, 0x360ffef90000, 27) = 27
1 recv(5, 80, 0, 0x360ffefff2c0) = 17
1 write(1, 0x360ffef90000, 20) = 20
1 send(5, 17, 0, 0x360ffefff2c0) = 17
1 mutex_lock(0) = 0
1 read(4, 0x360ffefcef20, 1024) = 17
1 cond_create() = 2
1 write(1, 0x360ffef90000, 18) = 18
1 close(4) = 0
1 mutex_lock(0) = 0
1 cond_signal(2) = 0
1 mutex_unlock(0) = 0
1 mutex_lock(0) = 0
1 cond_signal(0) = 0
1 mutex_unlock(0) = 0
1 cond_wait(0, 0) = 0
1 mutex_unlock(0) = 0
1 mutex_lock(0) = 0
1 cond_wait(2, 0) = 0
1 mutex_unlock(0) = 0
1 recv(5, 80, 0, 0x360ffefff2c0) = 0
1 close(5) = 0
1 write(1, 0x360ffef90000, 43) = 43
1 select(4, 0x360ffefff1a0, 0x00000000, 0x00000000, 0x360ffefff2a0) = 0
1 close(3) = 0
1 mutex_lock(0) = 0
1 cond_signal(0) = 0
1 mutex_unlock(0) = 0
1 cond_wait(0, 0) = 0
1 mutex_unlock(0) = 0
1 mutex_destroy(0) = 0
1 write(1, 0x360ffef90000, 36) = 36
JustinCappos commented 10 months ago

This is a great start! We likely also want an option where we resolve arguments that are pointers to strings, ENUMs, etc. to more readable values. However, that is a more complicated undertaking, so need not be in the first version of this.