2009-07-27 97 views
1

我試圖strace一個Java小程序,strace似乎並沒有工作。我正在調用以下函數。strace java小程序

public static void testSTrace(){ 
    long c = 0; 
    for (int i = 0; i < 1000; i++){ 
     long start = System.nanoTime(); 

     try{Thread.sleep(0, 100);}catch(Exception e){/*cry*/} 

     long stop = System.nanoTime(); 

     log.info("start : " +start+" stop : "+stop); 
    } 
} 

我得到以下從strace的輸出稱爲上述消息之前再沒有什麼從strace的:

clone(child_stack=0xb7c9f4c4, 
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM| 
CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED, 
parent_tidptr=0xb7c9fbf8, {entry_number:6, base_addr:0xb7c9fbb0, 
limit:1048575, seg_32bit:1, 
contents:0, read_exec_only:0, 
limit_in_pages:1, seg_not_present:0, useable:1}, child_tidptr=0xb7c9fbf8) = 8351 futex(0xb7c9fbf8, FUTEX_WAIT, 8351, NULL 

一旦我開始越來越從方法日誌輸出,我從strace的僅此而已。我非常喜歡strace。任何有關正在發生的事情的線索?小程序可以被整理嗎?手冊頁

回答

1

你可能只strace'ing單線。 用-f標誌運行strace。

+1

是的,我發現在發佈我的問題後30秒=) – 2009-07-27 13:14:06

0

歡呼三聲,我想後續叉標誌,-f和-F

-f -- follow forks, -ff -- with output into separate files 
-F -- attempt to follow vforks, -h -- print help message 

strace -fF /bin/appletviewer test.html 

現在我得到:

[pid 8401] gettimeofday({1248700317, 550296}, NULL) = 0 
[pid 8401] gettimeofday({1248700317, 550401}, NULL) = 0 
[pid 8401] gettimeofday({1248700317, 550500}, NULL) = 0 
[pid 8401] gettimeofday({1248700317, 550626}, NULL) = 0 
[pid 8401] gettimeofday({1248700317, 550883}, NULL) = 0 
[pid 8401] gettimeofday({1248700317, 550993}, NULL) = 0 
[pid 8401] gettimeofday({1248700317, 551093}, NULL) = 0