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=,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=,suspend=n

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

最新文章

  1. PHP_01之PHP概述、数据、语法
  2. python(四)函数
  3. LA 4064 Magnetic Train Tracks
  4. 第三百五十二天 how can I 坚持
  5. VNC-Server installation on CentOS 7
  6. LR性能测试应用
  7. 使用Webbrowser的一点心得体会
  8. Hexo搭建静态个人博客
  9. C#使用FFmpeg 将视频格式转换成Gif图片示例
  10. Maven启动Java Web工程,8081和8086端口号被占用
  11. 「NOI2017」泳池
  12. [心得] 如何利用liquibase進行資料庫版本控制 - 基礎觀念
  13. D. GukiZ and Binary Operations(矩阵+二进制)
  14. Linux 系统安全检查(shell)
  15. LeetCode之位操作题java
  16. MySQL建表时,日期时间类型选择
  17. Environment类包含的几个有用的方法
  18. 一个BUG?Visual Studio 2017 C++编写交换两个整数
  19. Prim求MST最小生成树
  20. java跨服务器请求url获得数据

热门文章

  1. Orchard模块开发全接触2:新建 ProductPart
  2. information_schema系列七
  3. window.name实现的跨域数据传输 JavaScript跨域总结与解决办法
  4. maven配置sqlServer的依赖
  5. poj 2348 Euclid's Game 题解
  6. Oracle简单的备份和恢复-导入和导出-目录
  7. 关掉Windows Firewall的PowerShell
  8. MFC中页面设置对话框CPageSetupDialog
  9. 大数据开发实战:Hive优化实战2-大表join小表优化
  10. jdbc操作数据库并自动获取字段类型