日期:2014-05-20  浏览次数:21050 次

判断java程序的是否在调试状态
在网上看了一些个文章,自己还是没有弄懂,

假定我现在在用myeclipse调试java程序,程序可能处于调试状态,设置断点后,我们就可以一步步单步调试程序,

现在我想知道java虚拟机怎么知道程序在调试状态,程序怎么实现,


boolean isdebug = func();//判断程序在调试状态


if (isdebug){
  
  System.out.println("程序在debug状态!");



求大虾帮助,小弟不甚感激......

------解决方案--------------------
你学在我前面,帮你顶,让人来帮
------解决方案--------------------
这个和JVM貌似没有关系吧
是eclipse在跟踪内存堆栈

这个没这么简单的,不是写几个变量的事情
------解决方案--------------------
断点调试不是几个程序你就明白的,而是在出现了与你设计的程序的有出入但是不知道错在哪?你才断点调试,分析分析错误在那。
------解决方案--------------------
楼上说的好 跟踪堆栈
------解决方案--------------------
在eclipse插件plugins中找到了org.eclipse.wst.xsl.debug.ui_1.0.100.v201004290328.jar,解压后看到这个plugin.properties,内容如下:
#Properties file for org.eclipse.wst.xsl.debug.ui
Bundle-Name.0 = XSL Debugger UI
launchMode.description.0 = Create a configuration to debug an XSLT transformation
launchMode.description.1 = Create a configuration to run an XSLT transformation
context.description.0 = Context for debugging XSLT
context.name.0 = XSLT Debugging
shortcut.label.0 = XSL Transformation
shortcut.label.1 = XSLT Transformation
Bundle-Vendor.0 = Eclipse Web Tools Platform
description.description.0 = Run an XSLT transformation using the selected file(s)
description.description.1 = Debug an XSLT transformation using the selected file(s)
description.description.2 = Profile an XSLT transformation using the selected file(s)

看到红色的部分了吗?翻译过来就是启动模式的一个属性,这些知识猜测,呵呵,可见你要去研究debug的源码,最后肯定能实现的。只是这个比较费时间,害的靠自己努力,本人时间不多,就说这么多了