Vscode-java-debug: Java remote attach to debug not hitting breakpoints.

Created on 3 Feb 2020  路  23Comments  路  Source: microsoft/vscode-java-debug

[provide a description of the issue]

Environment
  • Operating System: MacOSX Mojave 10.14.6
  • JDK version: 1.8.0_121
  • Visual Studio Code version: 1.14.1
  • Java extension version: 0.8.1
  • Java Debugger extension version: 0.24.0
Steps To Reproduce
  1. [step 1] Set remote debug configuration
    { "type": "java", "name": "Debug (Attach) - Remote", "request": "attach", "hostName": "192.168.1.1", "timeout": 30000, "port": 8000, "projectName": "service" },
  2. [step 2] Run and Debug remote, and it shows that warning message, and not hitting the breakpoints set below.

    [Warn - 11:25:04 AM] 2020-2-3 11:25:04 [Warn] The debugger and the debuggee are running in different versions of JVMs. You could see wrong source mapping results.
    Debugger JVM version: 1.8.0_121
    Debuggee JVM version: 1.8.0_102

[attach a sample project reproducing the error]
[attach logs](https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting#enable-logging)

Current Result

Not hitting the breakpoints.

Expected Result

Hit the breakpoints and could view the variables.

Additional Informations

I used the IDEA remote attach through the commands, and it works without problem. I wonder if any differences between IDEA and VSCode-java-debug remote attach commands?

  • IDEA Remote debug options
    image

  • VSCode Java Debug remote attach configuration

image

question

Most helpful comment

this worked for me:
MacOS/VSCode Insiders/OpenJDK8/Skaffold: $ skaffold debug --port-forward
terminal reports back debug port:Picked up JAVA_TOOL_OPTIONS: -agentlib:jdwp=transport=dt_socket,server=y,address=5005,suspend=n,quiet=y
VSCode: Add debug Configuration: Java: Attach to Remote Program
image
image

All 23 comments

Anyone could help me out with this issue?

@jkryanchou, thanks for reaching out.

The remote capability of VS Code is different from remote debugging in IntelliJ. We would love to help but we are not able to reproduce the issue based on the materials provided in this thread.

Could you please share the project with us?

The repository was private. Is there any other data I could provide to help me out with this issue?

@jkryanchou, could you share the command line arguments to launch your remote service?

@testforstephen How could I print out the command line arguments which to launch the remote service In VSCode? Or you mean the launch.json configuration?

To debug a remote Java program, it has two steps:
Step 1: Start the application in debugging mode

java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=<debug-port> -cp <ClassPath> <ClassName>

Step 2: Configuration launch.json to attach to the application.

Currently if you're using attach debugging in VS Code, you must manually launch your service at first. Could you tell me the approach to launch your service?

@testforstephen Here are the agentlib commandline args:

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

In the args, suspend=n, this means your application is started not in suspend mode. The application will start execution immediately, and no need to wait for a debugger to connect it. This is why you don't see hitting breakpoints, because your program may have executed the breakpoint code before the debugger ready.

To solve your program, you need set suspend=y, then the JVM starts in suspended mode and stays suspended until a debugger attaches to it.

@testforstephen OK, Thanks a lot. I will try it later. If any other issue exists . I would reply on this issue.

@testforstephen I have changed the suspend=y args. while it works as before and still couldn't hit the breakpoint. I guess it was something wrong with my network to the remote java agent.

I'm also having a similar issue

@testforstephen can you reproduce this? if no, then we need some help from @jkryanchou or @lherman-cs to reproduce it.

@akaroml OK, I will post it later.

this worked for me:
MacOS/VSCode Insiders/OpenJDK8/Skaffold: $ skaffold debug --port-forward
terminal reports back debug port:Picked up JAVA_TOOL_OPTIONS: -agentlib:jdwp=transport=dt_socket,server=y,address=5005,suspend=n,quiet=y
VSCode: Add debug Configuration: Java: Attach to Remote Program
image
image

I'm having the same issue and would like to get the java debugger working for vs code. Currently, I am able to remote debug using IntelliJ.

The breakpoints are not hit and display as "Unverified Breakpoint" in source code.

Created launch.json at project name directory.
Program (Apache Tomcat) is running on a vagrant vm (VirtualBox). Successfully debugged using IntelliJ.

Operating System: MacOSX Catalina
JDK version: 1.8.0_252 (adoptopenjdk)
Visual Studio Code version: 1.46
Java extension version: 0.9.1
Java Debugger extension version: 0.26.0

Command line arguments:
-agentlib:jdwp=transport=dt_socket,address=192.168.100.112:8000,server=y,suspend=n

Running debugger attaches to remote process.

The breakpoints are not hit and display as "Unverified Breakpoint" in source code.

This explained the reason. Looks like your source code is not loaded correctly by vscode-java. @alturium Could you share a sample code for reproduce?

@alturium - What is the contents of your launch.json?

@omcfig launch.json configuration:
"configurations": [
{
"type": "java",
"name": "Debug (Attach) - Remote",
"request": "attach",
"hostName": "192.168.100.112",
"port": 8000
},
I have tried adding sourcePaths (relative or absolute? top-level directory or target directory?), and projectName. To no avail.

Since debugging works for intellij, I'm going to take a guess that the the issue is loading and mapping the source code. It would imply that the debuggee process has the instrumented debugging information.

Configuration: Build a maven project (pom.xml). Output to target directory. Project directory has:
pom.xml
src/main/java/org/...
target/...

Process is apache running JSP servlet engine. There is a .war file. When I do a binary dump of the classes, I notice that the source is 'org/...'.

Is there a use of sourcePaths to help the debugger map the source code to the debugged process?

@testforstephen It will take some time to put together an example project. Has the java debugger been tested with remote apache debugging environment?

Thank you for the help! Unless there is a an undocumented feature, or perhaps a way to use sourcePaths parameter, I'm afraid that this will take some effort to diagnose and may be a bug against the vscode-java-debug.

I have the same problem. It does not attach to the remote application. I'm running with docker. On IntelliJ works fine!
MacOX Catalina
VSCode 1.48.2
Application Java 1.8
Java Debugger: 0.28.0
Java extension version: 0.10.0

I wonder if is not the difference of Java versions between VSCode and the Application.

@raphaelluchini What error did you see when it does not attach to the remote application?

@testforstephen No Errors, just hanging, the timeout also seems it's not working, I set to 1000 ms and the debugger keeps trying to connect until I try many times to stop.

I have the same problem too, it's occurring after a fresh update of windows and vscode. Before that it was working fine.

I've resolved my issue with 'clean the Javalanguage server workspace' option on VsCode

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PG-practice picture PG-practice  路  3Comments

mojo2012 picture mojo2012  路  3Comments

dgileadi picture dgileadi  路  3Comments

mojo2012 picture mojo2012  路  5Comments

testforstephen picture testforstephen  路  4Comments