2011-12-23 33 views
2

我在Word處理器上運行ltrace並打開了一個示例文件,但出人意料地只有兩個調用。ltrace僅打印兩個調用

__libc_start_main(0x8048820, 1, 0xbfe08844, 0x8048850, 0x80488b0 <unfinished ...> 
_ZN10AP_UnixApp4mainEPKciPPc(0x8048910, 1, 0xbfe08844, 0xb61feff4, 0x8048850) = 0 
+++ exited (status 0) +++ 

不應該ltrace打印所有庫調用?

回答

2

問題是ltrace只攔截來自主可執行文件(此處爲abiword)的調用到其他共享庫,但不攔截從一個共享庫到另一個共享庫的調用。

abiword,則main功能實際上並沒有做太多:

(gdb) disas main 
Dump of assembler code for function main: 
    0x0000000000400a70 <+0>: mov %rsi,%rdx 
    0x0000000000400a73 <+3>: mov %edi,%esi 
    0x0000000000400a75 <+5>: mov $0x400b6c,%edi 
    0x0000000000400a7a <+10>: jmpq 0x400950 <[email protected]> 
End of assembler dump. 

正如你所看到的,它只是做了return AP_UnixApp::main(argc, "abiword", argv);,和所有的實際活動中實現AP_UnixApp::main庫發生(在我情況,在/usr/lib/libabiword-2.8.so)。

在Fedora系統上,您可以嘗試使用frysk來代替。特別是這樣的:

ftrace -sym '*' abiword 

產生(超長)跟蹤,開頭:

528.528 attached /usr/bin/abiword 
528.528 call #libpthread.so.0#_init(0x1, 0x7fffa8ba5bd8, 0x7fffa8ba5be8, 0x7fffa8ba5be8, 0x1f25bc2, 0x7) 
528.528 call #libpthread.so.0#__pthread_initialize_minimal(0x1, 0x7fffa8ba5bd8, 0x7fffa8ba5be8, 0x7fffa8ba5be8, 0x1f25bc2, 0x7) 
528.528 call #libpthread.so.0#__libc_sigaction(0x20, 0x7fffa8ba5a70, 0x0, 0x0, 0x1f25bc2, 0x7) 
528.528 call #libpthread.so.0#__libc_sigaction(0x21, 0x7fffa8ba5a70, 0x0, 0x7f32501f27b0, 0x0, 0x7) 
528.528 call #libc.so.6#getrlimit(0x3, 0x7fffa8ba5b10, 0x3f, 0x40, 0x0, 0x7) = 0 
528.528 call #libc.so.6#sysconf(0x1e, 0x7fffa8ba5b10, 0x3f, 0x30220e7b17, 0x0, 0x7) 
528.528 call #libc.so.6#getpagesize(0x1e, 0x7fffa8ba5b10, 0xfffffffffff51435, 0x30220e7b17, 0x0, 0x7) = 4096 
528.528 leave #libc.so.6#sysconf = 4096 
528.528 call #libc.so.6#__libc_dl_error_tsd(0x1e, 0x7fffa8ba5b10, 0x800000, 0x2a40, 0x0, 0x7) = 139854069229848 
... 

Ftrace文檔here