线程转储编程/ JDI(Java调试器接口) [英] Thread dump programmatically /JDI (Java Debugger Interface)

查看:159
本文介绍了线程转储编程/ JDI(Java调试器接口)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢以编程方式生成线程转储。我了解到基本上有两种方法:


  1. 使用Java虚拟机工具界面JVM-TI

    li>
  2. 使用更高级的Java调试器接口JDI

对于JVM-TI,找到一些有用的信息,但我必须写一个JNI-DLL,至少在这一刻,我想避免。使用JDI,我可以使用Java,似乎我可以在应用程序中使用它。但是我无法找到某种教程或HOWTO。我可以找到的唯一文档是Java文档 http: //java.sun.com/j2se/1.5.0/docs/guide/jpda/jdi/ 这不是很有帮助,因为它不会告诉我如何使用这个类。



所以,有没有人知道我可以阅读的好教程/书?



Thx为任何帮助!

解决方案

您是否考虑过远程选择?即 VisualVM



thead dump with visualVM http://java.sun.com/javase/6/docs/technotes/guides/visualvm/images/applications-window-menu.png



jps和jstack 也是JDK 5中包含的有用工具,提供快速命令用于获取所有当前线程的堆栈跟踪的线方法。



这篇文章建议JDI也被用作一个远程工具



所以我不知道你可以在你自己的程序中触发一个线程转储,相反,您可以在Unix平台上找到一个SIGQUIT信号(kill -3),或者在Windows平台上按Unix或Ctrl-Break上的Ctrl-\键。



另外, JDI不用于调试JDI客户端正在运行的过程相同。仍然这个线程我刚刚链接到最接近我发现在同一个程序中实际使用JDI。


I like to generate a thread dump programmatically. I've learned that there a basically two ways to do it:

  1. Use the "Java Virtual Machine Tool Interface" JVM-TI
  2. Use the higher abstracted "Java Debugger Interface" JDI

For the JVM-TI I was able to find some useful information, but I would have to write a JNI-DLL which, at least for the moment, I would like to avoid. With the JDI I can use Java and it seems I'm able to use it from within the application. But I wasn't able to find some kind of tutorial or HOWTO for it. The only documentation I could find, were the Java-Docs http://java.sun.com/j2se/1.5.0/docs/guide/jpda/jdi/ which isn't very helpful, because it doesn't show me how to use this classes.

So, does anybody know of a good tutorial/book I could read?

Thx for any help!

解决方案

Did you consider the remote alternative ? I.e. VisualVM

thead dump with visualVM http://java.sun.com/javase/6/docs/technotes/guides/visualvm/images/applications-window-menu.png

jps and jstack are also useful tools included in JDK 5, providing a quick command line method for obtaining stack traces of all current threads.

This article suggest JDI is also used as a remote tool.

So I am not sure you can triggers a thread dump within your own program, instead you find a way to send to yourself a SIGQUIT signal (kill -3) on Unix platforms, or press the Ctrl-\ key on Unix or Ctrl-Break on Windows platforms.

Plus, JDI wasn't intended to be used to debug the same process in which the JDI client is running. Still this thread I just linked to is the closest I have found to actually use JDI within the same program.

这篇关于线程转储编程/ JDI(Java调试器接口)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆