offline
- E.L.I.T.E.
- Legendarni građanin
- Pridružio: 23 Maj 2012
- Poruke: 4575
|
strace je alatka za Linux koja prati interakciju između procesa i kernela i može biti vrlo korisna pri debagovanju programa (recimo u slučajevima kada je potrebno odrediti da li se neki sistemski poziv uopšte šalje određenom interfejsu kernela).
Primer:
#include <iostream>
int main() {
std::cout << "Testiranje" << std::endl;
return 0;
}
nikola@nikola:~$ strace -ttT ./main
10:27:23.016080 execve("./main", ["./main"], [/* 41 vars */]) = 0 <0.000616>
10:27:23.017154 brk(0) = 0xefc000 <0.000033>
10:27:23.017340 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) <0.000043>
10:27:23.017520 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa804639000 <0.000042>
10:27:23.017691 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) <0.000039>
10:27:23.017872 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 <0.000050>
10:27:23.018040 fstat(3, {st_mode=S_IFREG|0644, st_size=102768, ...}) = 0 <0.000031>
10:27:23.018188 mmap(NULL, 102768, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fa80461f000 <0.000038>
10:27:23.018327 close(3) = 0 <0.000031>
10:27:23.018469 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) <0.000037>
10:27:23.018631 open("/usr/lib/x86_64-linux-gnu/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3 <0.000047>
10:27:23.018785 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\270\5\0\0\0\0\0"..., 832) = 832 <0.000036>
10:27:23.018942 fstat(3, {st_mode=S_IFREG|0644, st_size=1008120, ...}) = 0 <0.000032>
10:27:23.019101 mmap(NULL, 3188384, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa804110000 <0.000040>
10:27:23.019246 mprotect(0x7fa8041fc000, 2097152, PROT_NONE) = 0 <0.000045>
10:27:23.019393 mmap(0x7fa8043fc000, 40960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xec000) = 0x7fa8043fc000 <0.000050>
10:27:23.019562 mmap(0x7fa804406000, 83616, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fa804406000 <0.000043>
10:27:23.019729 close(3) = 0 <0.000034>
10:27:23.019927 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) <0.000039>
10:27:23.020094 open("/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3 <0.000048>
10:27:23.020250 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200U\0\0\0\0\0\0"..., 832) = 832 <0.000035>
10:27:23.020400 fstat(3, {st_mode=S_IFREG|0644, st_size=1051056, ...}) = 0 <0.000032>
10:27:23.020549 mmap(NULL, 3146072, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa803e0f000 <0.000042>
10:27:23.020696 mprotect(0x7fa803f0f000, 2093056, PROT_NONE) = 0 <0.000047>
10:27:23.020842 mmap(0x7fa80410e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xff000) = 0x7fa80410e000 <0.000048>
10:27:23.021022 close(3) = 0 <0.000030>
10:27:23.021172 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) <0.000037>
10:27:23.021326 open("/lib/x86_64-linux-gnu/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3 <0.000042>
10:27:23.021470 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260*\0\0\0\0\0\0"..., 832) = 832 <0.000033>
10:27:23.021609 fstat(3, {st_mode=S_IFREG|0644, st_size=90096, ...}) = 0 <0.000031>
10:27:23.021754 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa80461e000 <0.000037>
10:27:23.021910 mmap(NULL, 2185952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa803bf9000 <0.000039>
10:27:23.022052 mprotect(0x7fa803c0f000, 2093056, PROT_NONE) = 0 <0.000043>
10:27:23.022188 mmap(0x7fa803e0e000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x7fa803e0e000 <0.000045>
10:27:23.022364 close(3) = 0 <0.000159>
10:27:23.022692 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) <0.000040>
10:27:23.022864 open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 <0.000050>
10:27:23.023019 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\34\2\0\0\0\0\0"..., 832) = 832 <0.000035>
10:27:23.023162 fstat(3, {st_mode=S_IFREG|0755, st_size=1738176, ...}) = 0 <0.000032>
10:27:23.023310 mmap(NULL, 3844640, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fa80384e000 <0.000043>
10:27:23.023454 mprotect(0x7fa8039f0000, 2093056, PROT_NONE) = 0 <0.000057>
10:27:23.023604 mmap(0x7fa803bef000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1a1000) = 0x7fa803bef000 <0.000053>
10:27:23.023805 mmap(0x7fa803bf5000, 14880, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fa803bf5000 <0.000045>
10:27:23.023977 close(3) = 0 <0.000030>
10:27:23.024159 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa80461d000 <0.000040>
10:27:23.024314 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa80461b000 <0.000035>
10:27:23.024461 arch_prctl(ARCH_SET_FS, 0x7fa80461b740) = 0 <0.000029>
10:27:23.024769 mprotect(0x7fa803bef000, 16384, PROT_READ) = 0 <0.000053>
10:27:23.025002 mprotect(0x7fa80410e000, 4096, PROT_READ) = 0 <0.000047>
10:27:23.026157 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa80461a000 <0.000052>
10:27:23.026439 mprotect(0x7fa8043fc000, 32768, PROT_READ) = 0 <0.000054>
10:27:23.026639 mprotect(0x7fa80463b000, 4096, PROT_READ) = 0 <0.000048>
10:27:23.026791 munmap(0x7fa80461f000, 102768) = 0 <0.000066>
10:27:23.027323 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0 <0.000036>
10:27:23.027519 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa804638000 <0.000043>
10:27:23.027705 write(1, "Testiranje\n", 11Testiranje
) = 11 <0.000068>
10:27:23.028002 exit_group(0) = ?
10:27:23.028340 +++ exited with 0 +++
|