【问题标题】:strace java appletstrace java小程序
【发布时间】:2010-11-14 08:33:10
【问题描述】:

我正在尝试 strace 一个 java 小程序,但 strace 似乎没有工作。我正在调用以下函数。

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 很陌生。关于发生了什么的任何线索?可以跟踪小程序吗?

【问题讨论】:

    标签: java strace nanotime


    【解决方案1】:

    您可能只是在跟踪一个线程。 使用 -f 标志运行 strace。

    【讨论】:

    • 是的,我在发布问题 30 秒后发现了这一点 =)
    【解决方案2】:

    为手册页欢呼三声,我想要跟随分叉标志,-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
    

    【讨论】:

      猜你喜欢
      • 2012-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-09
      • 2014-09-25
      • 2011-03-14
      • 2017-11-17
      相关资源
      最近更新 更多