简体   繁体   中英

Need to change from local debug of eclipse plugin to remote debug in a vm

I'm currently debugging an eclipse plugin on a centos7 laptop. I need to change this so that the test instance runs in a VM (ubuntu14), and I remotely connect to that instance. I understand some/most of the required elements for this, but I'm unsure about at least one.

I first had to configure the network on the VM. I only had one adapter, using NAT. I guess with this I didn't have full connectivity, although I'm not sure exactly what issues this presents. I added a second adapter in "host-only" mode. Now my VM can get to the internet, and my host can get to the IP of the VM, and I believe the VM can get to the IP of the host (although I don't know that I need that).

I installed Eclipse on the VM and added the "-Xdebug" parameters to the eclipse.ini file in the Eclipse installation on the VM (with "suspend=n").

I then created a debug configuration on the host using "Remote Java Application", specifying the IP of the guest and the port number I specified in the "-Xdebug" parameters in the eclipse.ini on the guest, and also adding my several associated plugin projects to the "Source" references. I ran that configuration, and I saw that it connected and give me a set of threads showing in the Debug window.

I then terminated the Eclipse on the guest, and saw that the debug session on the host terminated. This shows that they were connected properly.

It's the next steps that I'm unsure of. My plugin code is on the host. The debug configuration specifies the source of the plugin project(s), but what exactly do I have to do on the guest now?

I managed to develop an implementation that works. I got a lot of help from the other person in this thread: https://www.eclipse.org/forums/index.php/t/1071968/ .

Basically, I have a VM running Eclipse, with a workspace of projects that reference the same files as the Eclipse on the host (through a shared folder). On the VM, I have a run configuration (not debug) of type "Eclipse Application" with the following VM args: "-Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000".

On the host Eclipse, I have a debug configuration of type "Remote Java Application", pointing to the IP of the VM and the same port.

One important detail outside of Eclipse is that the VM needs to have two adapters, not the one that is created by default. In addition to a NAT-based adapter, I have to have a "host-only adapter".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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