在网上看了一些个文章,自己还是没有弄懂,假定我现在在用myeclipse调试java程序,程序可能处于调试状态,设置断点后,我们就可以一步步单步调试程序,现在我想知道java虚拟机怎么知道程序在调试状态,程序怎么实现,
boolean  isdebug = func();//判断程序在调试状态
if (isdebug){
  
  System.out.println("程序在debug状态!");}求大虾帮助,小弟不甚感激......

解决方案 »

  1.   

    这个和JVM貌似没有关系吧
    是eclipse在跟踪内存堆栈这个没这么简单的,不是写几个变量的事情
      

  2.   

    这个本人不会,但是绝对有实现的方法。你用myeclipse可以debug模式启动,也可以一般模式启动,这个插件本身就是别人写出来的,所以要实现你的需求是绝对可以实现的,你可以查找一下eclipse插件的相关资料,比如server,它有这2个模式,之间的区别必定有一个参数,总之,你可以朝这个方向找找资料,但是应该没你想象的那么简单
      

  3.   

    在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的源码,最后肯定能实现的。只是这个比较费时间,害的靠自己努力,本人时间不多,就说这么多了