zoukankan      html  css  js  c++  java
  • Configuring the launch of the remote virtual machine to debug

    Options need to be added to the standard launch of a virtual machine (VM) to enable the debugging architecture, allowing us to attach (hook in) and collect data.

    -Xdebug 

    Enables remote debugging.

    -Xnoagent 

    On a Sun VM, disables the proprietary debugging interface thus letting JPDA work correctly.在Sun VM上,禁用专有调试接口,从而允许JPDA正确工作。

    -Djava.compiler=NONE 

    Disables Just-In-Time (JIT) compilation..

    我们一般debug程序的时候,只是关注其中的一部分代码,而且大部分情况下是设置断点,然后单步执行,而JIT的编译单位是class,只要我们执行了class里面的代码,JIT就会对整个class进行编译,而我们实际执行的代码一般都是其中的一部分代码,所以从整个时间效率上来看,采用JIT反而更费时间。也就是说在JVM远程调试这个事情上,禁用JIT(只使用转译器,解释一行执行一条)更合理,所以通过-Djava.compiler=NONE来禁止JIT。 

    -Xrunjdwp:

    transport=dt_socket,

    server=y,

    address=5000,

    suspend=y

    Loads JDWP (Java Debug Wire Protocol), the reference implementation of JPDA. Sub-options further specify the option. 

    transport=dt_socket 

    Sets the transport type for the connection with the debugging application; in this example, we will connect via a socket.

    server=y 

    Tells the VM whether it must be receptive to an attaching debugging application.

    address=5000 

    The port address for our connection; we will need 5000 for our example.

    suspend=y 

    This option can be set depending on whether we want to suspend the exectution of the VM until a debugging application connects. This is useful if we seek to understand what happens when a server starts.

    1、If we wish to make the VM wait for a connection before a full launch, we will need a command line such as this :

    java …. -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=5000,suspend=y

    2、If we want the VM to be fully executing and listening for a debugging application, we will require a command line such as this one :

    java …. -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=5000,suspend=n

     第2种模式是一种比较好的方式,VM采用侦听的方式等待调试程序的连接。

  • 相关阅读:
    APP与智能手表是如何通信的【本文摘抄自深圳尚锐科技】
    flash添加超链接的办法
    NPOI使用手册
    如何在 SQL Server 实例之间传输登录和密码
    CentOS 7 上部署Mono 4 和Jexus 5.6
    django models 中choices之用法举例
    django中的objects.get和objects.filter方法的区别
    Django中的Model.objects.create() 和 Model() 的区别?
    python爬虫练手项目快递单号查询
    根据现有的数据库自动生成Django model
  • 原文地址:https://www.cnblogs.com/frankyou/p/9525598.html
Copyright © 2011-2022 走看看