java idea如何线上debug

 

 

 

1 建立一个remote 项目

2 ip 填入远程的机器

 

3 端口进行查看 ,catalina.sh

 

4 选择自己的模块;

 

下面表示成功

 

 

 

参数解释

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8787

 

dt_socket:使用的通信方式

server:是主动连接调试器还是作为服务器等待调试器连接

suspend:是否在启动JVM时就暂停,并等待调试器连接

address:地址和端口,地址可以省略,两者用冒号分隔

 

调试器

 

Before Java 5.0, use -Xdebug and -Xrunjdwp arguments. These options will still work in later versions, but but it will run in interpreted mode instead of JIT, which will be slower.

From Java 5.0, it is better to use the -agentlib:jdwp single option:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044

Options on -Xrunjdwp or agentlib:jdwp arguments are :

  • transport=dt_socket : means the way used to connect to JVM (socket is a good choice, it can be used to debug a distant computer)

  • address=8000 : TCP/IP port exposed, to connect from the debugger,

  • suspend=y : if 'y', tell the JVM to wait until debugger is attached to begin execution, otherwise (if 'n'), starts execution right away.

该答案解释了,使用-Xdebug方式,主要是在交互模式下适用,它在性能上会弱于使用-agentlib方式。

同时,该答案还解释了相应的三个参数:

transport:有两种形式,分别是socket和shared memory,需要跨机器,只能用socket

address:端口号,这里采用的是tcp协议。我们可以使用

cat /etc/services | grep '8000'

来查看该端口是否开启

suspend:如果是y,则需要等B机器上的debugger开启后,程序才会开始运行。否则,程序启动时候不会挂起,直接运行。

 

 

java -Xrunjdwp:transport=dt_socket,server=y,address=8000 myApp

This command:

    •  Listens for a socket connection on port 8000.

    •  Suspends this VM before main class loads (suspend=y by default).

    •  Once the debugger application connects, it can send a JDWP command to resume the VM.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值