简体   繁体   English

Java调试器:进程间通信如何完成?

[英]Java debugger: how is the inter-process communication done?

I know that you can debug a remote JVM starting it in "debug mode" (the remote JVM opens a TCP port to communicate with the debugger). 我知道您可以调试以“调试模式”启动的远程JVM(远程JVM打开一个TCP端口以与调试器进行通信)。

My question is, how is this communication done when the debug is not remote but local ? 我的问题是,当调试不是远程而是本地时,该通信如何完成? for example, when you use an IDE to launch an application to debug it locally. 例如,当您使用IDE启动应用程序以在本地对其进行调试时。 The IDE launches the JVM in an independent process, and then how is this inter-process communication done (in the case of Windows, for example)? IDE在独立的进程中启动JVM,然后如何完成进程间通信(例如,对于Windows)? is it done throught a TCP port also? 是否也通过TCP端口完成?

That depends on the hosting OS. 这取决于托管操作系统。 On Windows the debugger will use shared memory and there is a whole bunch of alternative ways of connecting on various OS'es: http://download.oracle.com/javase/6/docs/technotes/guides/jpda/conninv.html 在Windows上,调试器将使用共享内存,并且有很多其他方法可以在各种OS上进行连接: http : //download.oracle.com/javase/6/docs/technotes/guides/jpda/conninv.html

In earlier versions, TCP would be quietly used unless on Windows... 在早期版本中,除非在Windows上,否则将默默使用TCP。

The details are, however, vendor specific and the Sun VM allows you to implement your own connector, if you want to implement one that works over another protocol: http://download.oracle.com/javase/1.5.0/docs/guide/jpda/jdi/com/sun/jdi/connect/spi/TransportService.html 但是,详细信息是特定于供应商的,并且如果您要实现可在另一种协议上使用的连接器,则Sun VM允许您实现自己的连接器: http : //download.oracle.com/javase/1.5.0/docs/指南/ JPDA / JDI / COM /阳光/ JDI /连接/ SPI / TransportService.html

According to the JDB Docs , you can specify a transport-argument. 根据JDB Docs ,您可以指定传输参数。

C:> java -agentlib:jdwp= transport=dt_shmem ,address=jdbconn,server=y,suspend=n C:> java -agentlib:jdwp = transport = dt_shmem ,address = jdbconn,server = y,suspend = n

Under Windows , you can specify dt_shmem for communication per shared memory Windows下 ,可以为每个共享内存的通讯指定dt_shmem

From the link below: 从下面的链接:

-Xrunjdwp: transport=dt_socket ,address=myhost:8000 -Xrunjdwp: transport = dt_socket ,address = myhost:8000

Under Unix/Linux (works under Win as well) the debugger and the VM communicate per Socket. 在Unix / Linux下(在Win下也可以使用),调试器和VM按套接字进行通信。

More Examples: http://download.oracle.com/javase/1.4.2/docs/guide/jpda/conninv.html 更多示例: http : //download.oracle.com/javase/1.4.2/docs/guide/jpda/conninv.html

In general, JDWP (JavaTM Debug Wire Protocol Transport Interface) does not define the transport mechanism (socket, serial line, shared memory, ...) but the format of information and requests transferred between the debuggee process and the debugger front-end. 通常,JDWP(Java™调试线协议传输接口)不定义传输机制(套接字,串行线,共享内存等),而是定义在调试对象进程和调试器前端之间传输的信息和请求的格式。 for a particular implementation you should look at its documentation. 对于特定的实现,您应该查看其文档。 For example, SUN VM supports two modes: TCP/IP and shared memeory. 例如,SUN VM支持两种模式:TCP / IP和共享内存。

For the Sun JVM, there are two modes : shared memory, and TCP/IP. 对于Sun JVM,有两种模式 :共享内存和TCP / IP。 You can list the options using 您可以使用列出选项

java -Xrunjdwp:help

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM