BlogJava-Jeffrey's Sky-随笔分类-Web服务器http://www.blogjava.net/Jeffery001/category/35663.htmlGo with windzh-cnFri, 12 Dec 2008 20:53:29 GMTFri, 12 Dec 2008 20:53:29 GMT60有关在eclipse上远程debug的问题。http://www.blogjava.net/Jeffery001/archive/2008/12/12/246001.htmlJeffrey FengJeffrey FengFri, 12 Dec 2008 09:34:00 GMThttp://www.blogjava.net/Jeffery001/archive/2008/12/12/246001.htmlhttp://www.blogjava.net/Jeffery001/comments/246001.htmlhttp://www.blogjava.net/Jeffery001/archive/2008/12/12/246001.html#Feedback0http://www.blogjava.net/Jeffery001/comments/commentRss/246001.htmlhttp://www.blogjava.net/Jeffery001/services/trackbacks/246001.html
   1.建立Remote debug的准备工作。
    a.可以将这些在java命令行中的设置放到一个script中去。例子如下所示:
 
    java -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y  -classpath
    其中,“-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y”是必须的。suspend=y---表明是在程序启动后hang在那个端口处并监听(如果设为n,则不会hang);address=8787---表明是在远端机器上的端口号。除此之外,在java后也可以添加java的系统环境变量,如-D等等。   
    b.在eclipse中可以通过设立一个remote debug的方式来建立这种连接。  
   2.远程调试时,局部变量的值无法Watch/Inspect问题的解决
    这实际上是由eclipse在build的时候,没有将javac后的option -g加上去。只有当加上 -g这个参数时,所有的调试信息才会被build到class文件中去。
    但ecipse没有提供这样在build时设置参数的user interface。所以,最好的方式就是写一个Ant脚本。
    例子如下,

     <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <project basedir="." default="build" name="ssdv">
    <property name="build.location" value="../ssdv_build"/>
    <property name="debuglevel" value="source,lines,vars"/><!--必须的-->
    <property name="target" value="1.5"/>
    <property name="source" value="1.5"/>
    
    <target name="init">
        <mkdir dir="bin"/>
    </target>
    
    
    <target name="clean">
        <delete dir="bin"/>
    </target>
   
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>

        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">  <!--必须的-->
            <src path="."/>
            <classpath refid="ssdv.classpath"/>
        </javac>

    </target>
    
</project>
   
     这样,将生成的build工程拷贝到要测试的远程OS。启动脚本,然后就可以看到local variables了。


Jeffrey Feng 2008-12-12 17:34 发表评论
]]>