strace Java 小程序

发布于 2024-07-27 22:12:59 字数 976 浏览 3 评论 0原文

我正在尝试 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 还很陌生。 关于发生什么事的任何线索吗? 小程序可以追踪吗?

I'm trying to strace a java applet, and strace doesn't seem to be working. I'm calling the following function.

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);
    }
}

I get the following output from strace just before the above message is called and then nothing from 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

Once I start getting log output from the method, I get nothing more from strace. I'm pretty new to strace. Any clues on what is going on? Can applets be straced?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

箜明 2024-08-03 22:12:59

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

You're probably only strace'ing a single thread.
run strace with the -f flag.

想你只要分分秒秒 2024-08-03 22:12:59

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

Three cheers for man pages, I want the follow forks flag, -f and -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 

now I get:

[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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文