GithubHelp home page GithubHelp logo

microsoft / java-debug Goto Github PK

View Code? Open in Web Editor NEW
308.0 30.0 133.0 1.41 MB

The debug server implementation for Java. It conforms to the debug protocol of Visual Studio Code (DAP, Debugger Adapter Protocol).

License: Other

Java 98.60% Shell 0.17% JavaScript 1.23%

java-debug's People

Contributors

adpi2 avatar akaroml avatar andxu avatar ansyral avatar bhoppeadoy avatar crissnb avatar cscherryy avatar dependabot[bot] avatar eskibear avatar gayanper avatar jdneo avatar karlvr avatar mfussenegger avatar microsoft-github-policy-service[bot] avatar mozhuanzuojing avatar olsonjohn avatar p10q avatar rgrunber avatar sbj42 avatar snjeza avatar testforstephen avatar tom-shan avatar vladimirmakaev avatar yaohaizh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-debug's Issues

Log improvement

  1. jdi event
    2.vscode request/timestamp when uncaught error happens.

Implement our own launching connector

The jdi connector implementation in org.eclipse.jdt.debug-4.8, the connector arguments names are not compatible with the arguments in org.eclipse.jdt.debug-3.11.

In order to avoid future feature break, we need implement our own launching connector.

How tu debug this plugin?

You said

"It works with Eclipse JDT Language Server as an add-on to provide debug functionalities."

could you tell me how to run this plugin in terminal ?

step1

java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044 -Declipse.application=org.eclipse.jdt.ls.core.id1 -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.protocol=true -Dlog.level=ALL -noverify -Xmx1G -jar ./plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar -configuration ./config_linux -data /path/to/data

And then ? how do I add-on debug-plugin to OSGI Process ?

Watchs Expression

image

What caused this exception "Cannot evalution expression because of java.lang.RuntimeException: Evaluations must contain either an expression or a block of well-formed statements." ?

Error: "Failed to evaluate. Reason: Cannot evaluate because the thread is resumed"

`package com.demo.test.helloworld;
import java.util.Scanner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication implements CommandLineRunner {

public static void main(String[] args) {
	SpringApplication.run(DemoApplication.class, args);
}

@Override
public void run(String... args) throws Exception {
	System.out.println("Please enter name");
	Scanner scanner = new Scanner(System.in);
	String name = scanner.nextLine();
	System.out.println("Hello: " + name);
	scanner.close();
}

}`

{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "java", "name": "Debug (Launch)-DemoApplication<helloworld>", "request": "launch", "cwd": "${workspaceFolder}", "console": "internalConsole", "stopOnEntry": false, "mainClass": "com.demo.test.helloworld.DemoApplication", "projectName": "helloworld", "args": "" }, { "type": "java", "name": "Debug (Attach)", "request": "attach", "hostName": "localhost", "port": 0 } ] }

vscode: 1.21.1

When run from maven custom goal: spring-boot:run it runs fine. When run via F5 debug it fails after input. "Failed to evaluate. Reason: Cannot evaluate because the thread is resumed." There are no breakpoints placed anywhere in the code.

https://stackoverflow.com/questions/48642367/visual-studio-code-failed-to-evaluate-reason-cannot-evaluate-because-the-thre

error on continue request: Got IOException from Virtual Machine

The overall log is :

{"type":"request","seq":1,"command":"launch","arguments":{"cwd":"/var/lib/jenkins/workspace/vscode-java-debug-vsix-test/ci/testcase/7.variableperformance","mainClass":"VariablePerfTest","classPaths":["/var/lib/jenkins/workspace/vscode-java-debug-vsix-test/ci/testcase/7.variableperformance/bin"],"sourcePaths":["/var/lib/jenkins/workspace/vscode-java-debug-vsix-test/ci/testcase/7.variableperformance/src/main/java"]}}
Sep 19, 2017 8:38:46 AM Trying to launch Java Program with options "-Dfile.encoding=UTF-8 -cp [Ljava.lang.String;@429d3448 VariablePerfTest " .
Sep 19, 2017 8:38:46 AM Launching debuggee VM succeeded.
Sep 19, 2017 8:38:46 AM
[[RESPONSE]]
Content-Length: 77

{"success":true,"request_seq":1,"command":"launch","seq":1,"type":"response"}
Sep 19, 2017 8:38:46 AM
[REQUEST]
{"type":"request","seq":2,"command":"setBreakpoints","arguments":{"lines":[4],"breakpoints":[{"line":4}],"source":{"path":"/var/lib/jenkins/workspace/vscode-java-debug-vsix-test/ci/testcase/7.variableperformance/src/main/java/TooManyVariables.java"}}}
Sep 19, 2017 8:38:46 AM
[[RESPONSE]]
Content-Length: 157

{"success":true,"request_seq":2,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"verified":true,"line":4,"message":""}]},"seq":2,"type":"response"}
Sep 19, 2017 8:38:46 AM
[REQUEST]
{"type":"request","seq":3,"command":"configurationDone"}
Sep 19, 2017 8:38:46 AM
[[RESPONSE]]
Content-Length: 88

{"success":true,"request_seq":3,"command":"configurationDone","seq":3,"type":"response"}
Sep 19, 2017 8:38:46 AM
JDI Event: VMStartEvent: 0

Sep 19, 2017 8:38:46 AM
JDI Event: ThreadStartEvent: 5

Sep 19, 2017 8:38:46 AM
[[RESPONSE]]
Content-Length: 98

{"event":"thread","body":{"reason":"started","threadId":1,"type":"thread"},"seq":4,"type":"event"}
Sep 19, 2017 8:38:46 AM
JDI Event: ClassPrepareEvent: 3

Sep 19, 2017 8:38:46 AM
[[RESPONSE]]
Content-Length: 149

{"event":"breakpoint","body":{"reason":"new","breakpoint":{"id":1,"verified":true,"line":4,"message":""},"type":"breakpoint"},"seq":5,"type":"event"}
Sep 19, 2017 8:38:46 AM
JDI Event: BreakpointEvent: 7

Sep 19, 2017 8:38:46 AM
[[RESPONSE]]
Content-Length: 129

{"event":"stopped","body":{"threadId":1,"reason":"breakpoint","allThreadsStopped":false,"type":"stopped"},"seq":6,"type":"event"}
Sep 19, 2017 8:38:46 AM
[REQUEST]
{"type":"request","seq":4,"command":"stackTrace","arguments":{"threadId":1}}
Sep 19, 2017 8:38:46 AM
[[RESPONSE]]
Content-Length: 600

{"success":true,"request_seq":4,"command":"stackTrace","body":{"stackFrames":[{"id":1,"source":{"name":"TooManyVariables.java","path":"/var/lib/jenkins/workspace/vscode-java-debug-vsix-test/ci/testcase/7.variableperformance/src/main/java/TooManyVariables.java","sourceReference":0},"line":4,"column":0,"name":"test"},{"id":2,"source":{"name":"VariablePerfTest.java","path":"/var/lib/jenkins/workspace/vscode-java-debug-vsix-test/ci/testcase/7.variableperformance/src/main/java/VariablePerfTest.java","sourceReference":0},"line":3,"column":0,"name":"main"}],"totalFrames":2},"seq":7,"type":"response"}
Sep 19, 2017 8:38:46 AM
[REQUEST]
{"type":"request","seq":5,"command":"threads"}
Sep 19, 2017 8:38:46 AM
[[RESPONSE]]
Content-Length: 258

{"success":true,"request_seq":5,"command":"threads","body":{"threads":[{"id":2,"name":"Thread [Signal Dispatcher]"},{"id":3,"name":"Thread [Finalizer]"},{"id":4,"name":"Thread [Reference Handler]"},{"id":1,"name":"Thread [main]"}]},"seq":8,"type":"response"}
***threads { threads:
[ { id: 2, name: 'Thread [Signal Dispatcher]' },
{ id: 3, name: 'Thread [Finalizer]' },
{ id: 4, name: 'Thread [Reference Handler]' },
{ id: 1, name: 'Thread [main]' } ] }
Sep 19, 2017 8:38:46 AM
[REQUEST]
{"type":"request","seq":6,"command":"scopes","arguments":{"frameId":1}}
Sep 19, 2017 8:38:46 AM
[[RESPONSE]]
Content-Length: 155

{"success":true,"request_seq":6,"command":"scopes","body":{"scopes":[{"name":"Local","variablesReference":3,"expensive":false}]},"seq":9,"type":"response"}
***scopes { scopes: [ { name: 'Local', variablesReference: 3, expensive: false } ] }
Sep 19, 2017 8:38:46 AM
[REQUEST]
{"type":"request","seq":7,"command":"variables","arguments":{"variablesReference":3}}
Sep 19, 2017 8:38:46 AM
[[RESPONSE]]
Content-Length: 231

{"success":true,"request_seq":7,"command":"variables","body":{"variables":[{"name":"this","value":"TooManyVariables (id\u003d409)","type":"TooManyVariables","variablesReference":4,"indexedVariables":0}]},"seq":10,"type":"response"}
Sep 19, 2017 8:38:46 AM
[REQUEST]
{"type":"request","seq":8,"command":"continue","arguments":{"threadId":1}}
Sep 19, 2017 8:38:46 AM
JDI Event: ThreadDeathEvent: 6

Sep 19, 2017 8:38:46 AM
[[RESPONSE]]
Content-Length: 120

{"event":"output","body":{"category":"stdout","output":"variable perf test.\n","type":"output"},"seq":11,"type":"event"}
Sep 19, 2017 8:38:46 AM
JDI Event: ThreadStartEvent: 5

**** variable perf test.

Sep 19, 2017 8:38:46 AM
JDI Event: ThreadDeathEvent: 6

Sep 19, 2017 8:38:46 AM
JDI Event: VMDeathEvent: 0

Sep 19, 2017 8:38:46 AM
JDI Event: VMDisconnectEvent: 0

Sep 19, 2017 8:38:46 AM DebugSession dispatch exception:com.sun.jdi.VMDisconnectedException: Got IOException from Virtual Machine
Sep 19, 2017 8:38:46 AM
[[RESPONSE]]
Content-Length: 207

{"success":false,"message":"Got IOException from Virtual Machine","request_seq":8,"command":"continue","body":{"error":{"id":1000,"format":"Got IOException from Virtual Machine"}},"seq":12,"type":"response"}
Error: Got IOException from Virtual Machine
at /var/lib/jenkins/workspace/vscode-java-debug-vsix-test/ci/node_modules/vscode-debugadapter-testsupport/lib/protocolClient.js:36:35
at DebugClient.ProtocolClient.dispatch (/var/lib/jenkins/workspace/vscode-java-debug-vsix-test/ci/node_modules/vscode-debugadapter-testsupport/lib/protocolClient.js:98:17)
at DebugClient.ProtocolClient.handleData (/var/lib/jenkins/workspace/vscode-java-debug-vsix-test/ci/node_modules/vscode-debugadapter-testsupport/lib/protocolClient.js:64:30)
at Socket. (/var/lib/jenkins/workspace/vscode-java-debug-vsix-test/ci/node_modules/vscode-debugadapter-testsupport/lib/protocolClient.js:25:19)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)
1) should pass variable performance test.
(node:48804) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Got IOException from Virtual Machine
Sep 19, 2017 8:38:46 AM
[[RESPONSE]]
Content-Length: 98

.project .classpath files everywhere

Once I open a java project, the VSCode extensions start to produce a HUGE number of .project and .classpath files everywhere. They really mess my project folder up. Can you just stop generating them or at least put them aside?

How to Set a Object veriable?

RT

as I see, this project can only set double/int/boolean... veriable

when will you support Double/Integer/Boolean etc ?

"continue" response sent after the following "stopped" event - should be opposite

  1. Put 2 breakpoints (e.g lines: 28, 38) in Java method
  2. Stopped a the first breakpoint - OK as expected
  3. Sent "resume" command
  4. Sometimes the "continue" response sent after the following "stopped" event - so our debugger client doesn't stopped at second breakpoint.

Following is the log:
2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR {"command":"continue","type":"request","seq":"17","arguments":{"threadId":13}}

2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR 18/12/2017 11:38:53.398 - [com.microsoft.java.debug.core.EventHub.lambda$start$28] - [FINE] -

2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR JDI Event: [email protected]:38 in thread http-nio-0.0.0.0-3000-exec-3
2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR 18/12/2017 11:38:53.399 - [com.microsoft.java.debug.
2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR 2017/12/18 11:38:53 core.protocol.AbstractProtocolServer.sendMessage] - [FINE] -
2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR [[EVENT]]
2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR Content-Length: 131
2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR {"event":"stopped","body":{"threadId":13,"reason":"breakpoint","allThreadsStopped":false,"type":"stopped"},"seq":25,"type":"event"}

2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR 18/12/2017 11:38:53.403 - [com.microsoft.java.debug.core.protocol.AbstractProtocolServer.sendMessage] - [FINE] -
2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR [[RESPONSE]]
2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR Content-Length: 118
2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR {"success":true,"request_seq":17,"command":"continue","body":{"allThreadsContinued":false},"seq":26,"type":"response"}

2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR 18/12/2017 11:38:53.476 - [com.microsoft.java.debug.core.protocol.AbstractProtocolServer.processData] - [FINE] -
2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR [request]
2017-12-18T13:38:53.48+0200 [APP/PROC/WEB/0]ERR

Another comment - standard logs are being printed to the stderr instead of stdout even though they are not errors.

Ask a question.

In VsCode,I open a Java SpringBoot Project,
I am modifying and saving a piece of code at any time will cause the class file to be replaced.

image

I just want to know how it works ?Is it caused by lsp4j textDocument/didSave?

[VMDisconnectedException]Got IOException from Virtual Machine on setting breakpoint.

image

com.sun.jdi.VMDisconnectedException: Got IOException from Virtual Machine at org.eclipse.jdi.internal.connect.PacketReceiveManager.getReply(PacketReceiveManager.java:186) at org.eclipse.jdi.internal.connect.PacketReceiveManager.getReply(PacketReceiveManager.java:204) at org.eclipse.jdi.internal.MirrorImpl.requestVM(MirrorImpl.java:192) at org.eclipse.jdi.internal.MirrorImpl.requestVM(MirrorImpl.java:268) at org.eclipse.jdi.internal.VirtualMachineImpl.allClasses(VirtualMachineImpl.java:373) at org.eclipse.jdi.internal.VirtualMachineImpl.allRefTypes(VirtualMachineImpl.java:402) at org.eclipse.jdi.internal.ReferenceTypeImpl.nestedTypes(ReferenceTypeImpl.java:1229) at com.microsoft.java.debug.core.Breakpoint.lambda$collectLocations$5(Breakpoint.java:173) at java.util.ArrayList.forEach(ArrayList.java:1251) at com.microsoft.java.debug.core.Breakpoint.collectLocations(Breakpoint.java:171) at com.microsoft.java.debug.core.Breakpoint.createBreakpointRequests(Breakpoint.java:188) at com.microsoft.java.debug.core.Breakpoint.install(Breakpoint.java:146) at com.microsoft.java.debug.core.adapter.handler.SetBreakpointsRequestHandler.handle(SetBreakpointsRequestHandler.java:81) at com.microsoft.java.debug.core.adapter.DebugAdapter.dispatchRequest(DebugAdapter.java:73) at com.microsoft.java.debug.core.adapter.ProtocolServer.dispatchRequest(ProtocolServer.java:208) at com.microsoft.java.debug.core.adapter.ProtocolServer.processData(ProtocolServer.java:177) at com.microsoft.java.debug.core.adapter.ProtocolServer.start(ProtocolServer.java:99) at com.microsoft.java.debug.plugin.internal.JavaDebugServer$2.run(JavaDebugServer.java:139) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

Use client agnostic command names

From eclipse-jdtls/eclipse.jdt.ls#424 (comment), I noticed the debugger exposes vscode* commands on the server side.

[Trace - 21:52:28] Received request 'client/registerCapability - (5)'.
Params: {
    "registrations": [
        {
            "id": "18163e21-97e7-4ae8-b51c-5cdb20e639b1",
            "method": "workspace/executeCommand",
            "registerOptions": {
                "commands": [
                    "java.edit.organizeImports",
                    "vscode.java.fetchUsageData",
                    "vscode.java.resolveClasspath",
                    "vscode.java.resolveMainClass",
                    "vscode.java.updateDebugSettings",
                    "vscode.java.buildWorkspace",
                    "vscode.java.startDebugSession"
                ]
            }
        }
    ]

It'd be better if the names were client agnostic.

Main class 'Test' doesn't exist in the workspace.

Stack trace.

[{"declaringClass":"com.microsoft.java.debug.plugin.internal.ResolveClasspathsHandler","methodName":"computeClassPath","fileName":"ResolveClasspathsHandler.java","lineNumber":132},{"declaringClass":"com.microsoft.java.debug.plugin.internal.ResolveClasspathsHandler","methodName":"resolveClasspaths","fileName":"ResolveClasspathsHandler.java","lineNumber":50},{"declaringClass":"com.microsoft.java.debug.plugin.internal.JavaDebugDelegateCommandHandler","methodName":"executeCommand","fileName":"JavaDebugDelegateCommandHandler.java","lineNumber":42},{"declaringClass":"org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1","methodName":"run","fileName":"WorkspaceExecuteCommandHandler.java","lineNumber":133},{"declaringClass":"org.eclipse.core.runtime.SafeRunner","methodName":"run","fileName":"SafeRunner.java","lineNumber":42},{"declaringClass":"org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler","methodName":"executeCommand","fileName":"WorkspaceExecuteCommandHandler.java","lineNumber":128},{"declaringClass":"org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer","methodName":"lambda$2","fileName":"JDTLanguageServer.java","lineNumber":251},{"declaringClass":"java.util.concurrent.CompletableFuture","methodName":"uniApply","fileName":"CompletableFuture.java","lineNumber":602},{"declaringClass":"java.util.concurrent.CompletableFuture$UniApply","methodName":"tryFire","fileName":"CompletableFuture.java","lineNumber":577},{"declaringClass":"java.util.concurrent.CompletableFuture$Completion","methodName":"exec","fileName":"CompletableFuture.java","lineNumber":443},{"declaringClass":"java.util.concurrent.ForkJoinTask","methodName":"doExec","fileName":"ForkJoinTask.java","lineNumber":289},{"declaringClass":"java.util.concurrent.ForkJoinPool$WorkQueue","methodName":"runTask","fileName":"ForkJoinPool.java","lineNumber":1056},{"declaringClass":"java.util.concurrent.ForkJoinPool","methodName":"runWorker","fileName":"ForkJoinPool.java","lineNumber":1692},{"declaringClass":"java.util.concurrent.ForkJoinWorkerThread","methodName":"run","fileName":"ForkJoinWorkerThread.java","lineNumber":157}]

cannot setExceptionBreakpoints

It can reproduce in the bugbash version.

Steps:

  1. Open your java project, write a piece of code with uncaught exceptions.
  2. Check Uncaught exceptions on the bottom-left part in debug panel.
  3. Make sure there's NO any other breakpoint.

Error: "Failed to evaluate. Reason: Cannot evaluate because the thread is resumed"

Get error message "Failed to evaluate. Reason: Cannot evaluate because the thread is resumed" after getting input from vscode debug console using BufferedReader in Java.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class demo {
    public static void main(String args[]) throws IOException {
        int input;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
           input = br.read();
        }
        catch(IOException e) {
            e.printStackTrace();
        }
        if(br != null) br.close();
        System.out.println("123"); // would not execute using debug console in vscode.
    }
}

Here is the launch.json, which is basically a default one.

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
        "type": "java",
        "name": "compile",
        "mainClass": "demo",
        "request": "launch",
        "args": ""
    }

]
}

error

Environment
  • Operating System: Elementary OS 0.4.1 Loki Built on "Ubuntu 16.04.3 LTS"
  • JDK version: java 9.0.1
  • Visual Studio Code version: 1.18.0
  • Java extension version: 0.14.0
Steps To Reproduce
  1. A console Java program getting user input with BufferedReader.
  2. start debugging on debug console
Current Result
Expected Result
Additional Informations

cannot debug nashorn scripts

IntelliJ and Netbeans (as an example) can debug javascript scripts running on the JVM as the Nashorn engine seems to generate the proper debug information at runtime when the scripts are compiled.

An example project can be seen in the netbeans project:

http://services.netbeans.org/synergy/server/api/attachment.php?id=197

I've tried to see if this plugin would also allow it, but sadly the breakpoint is not recognized and the code never stops. Also adding the special keyword debugger; will not be recognized and the IDE reports Unverified Breakpoint

Only one step request allowed per thread error

When putting a breakpoint in some java file calling a constructor, and also putting a breakpoint inside the constructor (which is in another java file):
first step over - succeeded and we get 'stopped' event of reason 'breakpoint' as expected as it hit the breakpoint before completing the step operation (stack trace points to the breakpoint location inside the constructor).

With that, a second step over (to the second line in the constructor...) fails and the 'Only one step request allowed per thread' error message is returned.

Reference code:
[Main.java]
Person myPerson = new Person(12,"name1"); [ --> first breakpoint]

[Person.java]
public Person(int age,String name) {
this.name = name; [ --> second breakpoint]
this.age = age;
this.detail = new Detail();
}

Our setup:
We are using the debug.core code (without the plugin wrapping) and providing our own source provider and IDE (not VS Code).
The debugee application is a servlet, if it matters...

Request - Response communication (removed content length for readability):

[stopped at breakpoint - Main.java]

{"event":"stopped","body":{"threadId":15,"reason":"breakpoint","allThreadsStopped":false,"type":"stopped"},"seq":11,"type":"event"}

... [get stack trace, scopes, variables]

[step over request / response]

{"command":"next","type":"request","seq":"48","arguments":{"threadId":15}}

{"success":true,"request_seq":48,"command":"next","seq":53,"type":"response"}

[stopped at breakpoint - Person.java inside constructor]

{"event":"stopped","body":{"threadId":15,"reason":"breakpoint","allThreadsStopped":false,"type":"stopped"},"seq":55,"type":"event"}

... [get stack trace, scopes, variables]

[step over request / response]

{"command":"next","type":"request","seq":"90","arguments":{"threadId":15}}

{"success":false,"message":"Only one step request allowed per thread","request_seq":90,"command":"next","body":{"error":{"id":1000,"format":"Only one step request allowed per thread"}},"seq":97,"type":"response"}

(expected - success 'true' and get stopped event from 'step' reason at Person.java - in second line of constructor)

Exception:
com.sun.jdi.request.DuplicateRequestException: Only one step request allowed per thread
at com.sun.tools.jdi.EventRequestManagerImpl$StepRequestImpl.(EventRequestManagerImpl.java:591)
at com.sun.tools.jdi.EventRequestManagerImpl.createStepRequest(EventRequestManagerImpl.java:759)
at com.microsoft.java.debug.core.DebugUtility.step(DebugUtility.java:236)
at com.microsoft.java.debug.core.DebugUtility.stepOver(DebugUtility.java:201)
at com.microsoft.java.debug.core.adapter.handler.ThreadsRequestHandler.next(ThreadsRequestHandler.java:113)
at com.microsoft.java.debug.core.adapter.handler.ThreadsRequestHandler.handle(ThreadsRequestHandler.java:64)
at com.microsoft.java.debug.core.adapter.DebugAdapter.dispatchRequest(DebugAdapter.java:80)
at com.microsoft.java.debug.core.adapter.ProtocolServer.dispatchRequest(ProtocolServer.java:66)
at com.microsoft.java.debug.core.protocol.AbstractProtocolServer.processData(AbstractProtocolServer.java:166)
at com.microsoft.java.debug.core.protocol.AbstractProtocolServer.start(AbstractProtocolServer.java:80)
at com.microsoft.java.debug.core.adapter.ProtocolServer.start(ProtocolServer.java:53)

Failed to resolve classpath: Main class 'Main' isn't unique in the workspace

Open a java folder, see the screenshot below.
screen shot 2017-09-14 at 10 30 31 am

And click F5 to launch, it popup a message box saying that Failed to resolve classpath: Main class 'Main' isn't unique in the workspace, please pass in specified projectname..

Apparently it's not a normal eclipse/maven/gradle project, but just a simple java file. In such case, these java files will be linked to a fake project. It seems the main class isn't unique in the fake project. But in such case, user doesn't know how to specify project name. We need figure out how to handle such kind of case.

NPE exception for CompletionsProvider

java.lang.NullPointerException:
com.microsoft.java.debug.plugin.internal.CompletionsProvider#codeComplete (CompletionsProvider.java:53)
com.microsoft.java.debug.core.adapter.handler.CompletionsHandler#lambda$handle$0 (CompletionsHandler.java:59)
java.util.concurrent.CompletableFuture$AsyncSupply#run (CompletableFuture.java:1590)
java.util.concurrent.CompletableFuture$AsyncSupply#exec (CompletableFuture.java:1582)
java.util.concurrent.ForkJoinTask#doExec (ForkJoinTask.java:289)
java.util.concurrent.ForkJoinPool$WorkQueue#runTask (ForkJoinPool.java:1056)
java.util.concurrent.ForkJoinPool#runWorker (ForkJoinPool.java:1692)
java.util.concurrent.ForkJoinWorkerThread#run (ForkJoinWorkerThread.java:157)

[Perf] Perf issue of program which has constant output.

package test;
public class App {
    public void test() {
       System.out.println("xx");
    }
    public static void main(String args[]) throws Exception {

        while(true) {
            new App().test();
            Thread.yield();
        }
    }
}

When it is running, it is very slow to be able to set a breakpoint at "System.out.println("xx");"

SourceLookup fails for dependencies

Setting a breakpoint to a file from a dependency fails on source lookup.

In my gradle project I have dependency to compile group: 'xerces', name: 'xercesImpl', version:'2.11.0 and I am trying to set a breakpoint on 'org.apache.xerces.parsers.DomParser.parse()' which is located on this dependency. I can browse to the file through vscode and see the code but when I try to set the breakpoint it fails with the below stacktrace.

[Error - 12:12:00] 13-Nov-2017 12:10:58 PM DebugSession dispatch exception: java.lang.IllegalStateException: Java Model Exception: Java Model Status [/Users/gercan/.m2/repository/xerces/xercesImpl/2.11.0/xercesImpl-2.11.0.jar is not on its project's build path]
	at org.eclipse.jdt.internal.core.JavaElement.newJavaModelException(JavaElement.java:570)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:247)
	at org.eclipse.jdt.internal.core.Openable.openAncestors(Openable.java:505)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:241)
	at org.eclipse.jdt.internal.core.Openable.openAncestors(Openable.java:505)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:241)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:583)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:320)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:306)
	at org.eclipse.jdt.internal.core.Openable.getBuffer(Openable.java:285)
	at org.eclipse.jdt.internal.core.AbstractClassFile.getBuffer(AbstractClassFile.java:212)
	at org.eclipse.jdt.internal.core.AbstractClassFile.getSource(AbstractClassFile.java:324)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1131)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:815)
	at com.microsoft.java.debug.plugin.internal.JdtSourceLookUpProvider.getFullyQualifiedName(JdtSourceLookUpProvider.java:140)
	at com.microsoft.java.debug.core.adapter.handler.SetBreakpointsRequestHandler.convertClientBreakpointsToDebugger(SetBreakpointsRequestHandler.java:119)
	at com.microsoft.java.debug.core.adapter.handler.SetBreakpointsRequestHandler.handle(SetBreakpointsRequestHandler.java:83)
	at com.microsoft.java.debug.core.adapter.DebugAdapter.dispatchRequest(DebugAdapter.java:80)
	at com.microsoft.java.debug.core.adapter.ProtocolServer.dispatchRequest(ProtocolServer.java:66)
	at com.microsoft.java.debug.core.protocol.AbstractProtocolServer.processData(AbstractProtocolServer.java:166)
	at com.microsoft.java.debug.core.protocol.AbstractProtocolServer.start(AbstractProtocolServer.java:80)
	at com.microsoft.java.debug.core.adapter.ProtocolServer.start(ProtocolServer.java:53)
	at com.microsoft.java.debug.plugin.internal.JavaDebugServer$2.run(JavaDebugServer.java:136)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745

[VMDisconnectedException]Got IOException from Virtual Machine on ConfigurationDone request

image

com.sun.jdi.VMDisconnectedException: Got IOException from Virtual Machine at org.eclipse.jdi.internal.connect.PacketSendManager.sendPacket(PacketSendManager.java:90) at org.eclipse.jdi.internal.MirrorImpl.requestVM(MirrorImpl.java:187) at org.eclipse.jdi.internal.MirrorImpl.requestVM(MirrorImpl.java:227) at org.eclipse.jdi.internal.request.EventRequestImpl.enable(EventRequestImpl.java:258) at com.microsoft.java.debug.core.DebugSession.start(DebugSession.java:36) at com.microsoft.java.debug.core.adapter.handler.ConfigurationDoneRequestHandler.handle(ConfigurationDoneRequestHandler.java:54) at com.microsoft.java.debug.core.adapter.DebugAdapter.dispatchRequest(DebugAdapter.java:73) at com.microsoft.java.debug.core.adapter.ProtocolServer.dispatchRequest(ProtocolServer.java:208) at com.microsoft.java.debug.core.adapter.ProtocolServer.processData(ProtocolServer.java:177) at com.microsoft.java.debug.core.adapter.ProtocolServer.start(ProtocolServer.java:99) at com.microsoft.java.debug.plugin.internal.JavaDebugServer$2.run(JavaDebugServer.java:139) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

Question on StepEvent in multi-thread app

It's not an issue but a question.

I'm using your great project and DebugSession to debug my webapp powered by Tomcat.
Thanks to EventHub, i get a lot of StepEvent on the "main" thread where Tomcat runs.
But when I send an http request to my webapp / tomcat, i capture MethodEntryEvent for example but i do not capture any StepEvent on my code.
Is there anything I missed ?
Why i cannot capture StepEvent outside of the "main" thread ?
Do I have to perform a particular action on existing threads?

Whatever, thanks for all.

AttachRequestHandler should record error of attach failures.

AttachRequestHandler.java
try {
logger.info(String.format("Trying to attach to remote debuggee VM %s:%d .",
attachArguments.hostName, attachArguments.port));
IDebugSession debugSession = DebugUtility.attach(vmProvider.getVirtualMachineManager(),
attachArguments.hostName, attachArguments.port, attachArguments.timeout);
context.setDebugSession(debugSession);
logger.info("Attaching to debuggee VM succeeded.");
} catch (IOException | IllegalConnectorArgumentsException e) {
AdapterUtils.setErrorResponse(response, ErrorCode.ATTACH_FAILURE,
String.format("Failed to attach to remote debuggee VM. Reason: %s", e.toString()));
}

Publish java-debug as a p2 repo

... so it can easily be consumed by Eclipse based products.

Here's an example of a tycho based project to publish the java-debug plugin to a standalone p2 repo:
java-debug-repo.zip

If the p2 repo was built as part of the java-debug project. then the category.xml would declare
<bundle id="com.microsoft.java.debug.plugin" version="0.0.0.qualifier"/> IIRC. In that case, all the repositories, dependencies declaration in pom.xml could be removed.

As for publishing the p2 repo, bintray.org is an alternative to self-hosting. See this post describing bintray publishing.

cc @svor, @testforstephen

java.util.ConcurrentModificationException in toGson

!ENTRY java-debug 4 0 2017-11-10 09:31:50.091
!MESSAGE Dispatch debug protocol error: java.util.ConcurrentModificationException
!STACK 0
java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
at java.util.ArrayList$Itr.next(ArrayList.java:851)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:96)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:61)
at com.google.gson.Gson.toJson(Gson.java:669)
at com.google.gson.Gson.toJson(Gson.java:648)
at com.google.gson.Gson.toJson(Gson.java:603)
at com.google.gson.Gson.toJson(Gson.java:583)
at com.microsoft.java.debug.core.protocol.JsonUtils.toJson(JsonUtils.java:42)
at com.microsoft.java.debug.core.UsageDataSession.submitUsageData(UsageDataSession.java:140)
at com.microsoft.java.debug.core.adapter.ProtocolServer.stop(ProtocolServer.java:62)
at com.microsoft.java.debug.core.adapter.ProtocolServer.dispatchRequest(ProtocolServer.java:68)
at com.microsoft.java.debug.core.protocol.AbstractProtocolServer.processData(AbstractProtocolServer.java:166)
at com.microsoft.java.debug.core.protocol.AbstractProtocolServer.start(AbstractProtocolServer.java:80)
at com.microsoft.java.debug.core.adapter.ProtocolServer.start(ProtocolServer.java:53)
at com.microsoft.java.debug.plugin.internal.JavaDebugServer$2.run(JavaDebugServer.java:136)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

[NPE] on debug

| common.vscodeversion | 1.16.1
  | common.extversion | 0.1.0
  | common.osversion | 16.7.0
  | common.extname | vscode-java-debug
  | common.os | darwin
  | description | DebugSession dispatch exception: java.lang.NullPointerException
  | scope | exception
  | deubgSessionId | 7c0051c7-c171-4928-babb-461d27f88540

java.lang.NullPointerException at com.microsoft.java.debug.core.adapter.handler.SetBreakpointsRequestHandler.convertClientBreakpointsToDebugger(SetBreakpointsRequestHandler.java:119) at com.microsoft.java.debug.core.adapter.handler.SetBreakpointsRequestHandler.handle(SetBreakpointsRequestHandler.java:76) at com.microsoft.java.debug.core.adapter.DebugAdapter.dispatchRequest(DebugAdapter.java:73) at com.microsoft.java.debug.core.adapter.ProtocolServer.dispatchRequest(ProtocolServer.java:208) at com.microsoft.java.debug.core.adapter.ProtocolServer.processData(ProtocolServer.java:177) at com.microsoft.java.debug.core.adapter.ProtocolServer.start(ProtocolServer.java:99) at com.microsoft.java.debug.plugin.internal.JavaDebugServer$2.run(JavaDebugServer.java:139) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:748)

Main class 'main' isn't unique in the workspace, please pass in specified projectname.

image

[{"declaringClass":"com.microsoft.java.debug.plugin.internal.ResolveClasspathsHandler","methodName":"computeClassPath","fileName":"ResolveClasspathsHandler.java","lineNumber":136},{"declaringClass":"com.microsoft.java.debug.plugin.internal.ResolveClasspathsHandler","methodName":"resolveClasspaths","fileName":"ResolveClasspathsHandler.java","lineNumber":50},{"declaringClass":"com.microsoft.java.debug.plugin.internal.JavaDebugDelegateCommandHandler","methodName":"executeCommand","fileName":"JavaDebugDelegateCommandHandler.java","lineNumber":42},{"declaringClass":"org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1","methodName":"run","fileName":"WorkspaceExecuteCommandHandler.java","lineNumber":133},{"declaringClass":"org.eclipse.core.runtime.SafeRunner","methodName":"run","fileName":"SafeRunner.java","lineNumber":42},{"declaringClass":"org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler","methodName":"executeCommand","fileName":"WorkspaceExecuteCommandHandler.java","lineNumber":128},{"declaringClass":"org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer","methodName":"lambda$2","fileName":"JDTLanguageServer.java","lineNumber":251},{"declaringClass":"java.util.concurrent.CompletableFuture","methodName":"uniApply","fileName":"CompletableFuture.java","lineNumber":602},{"declaringClass":"java.util.concurrent.CompletableFuture$UniApply","methodName":"tryFire","fileName":"CompletableFuture.java","lineNumber":577},{"declaringClass":"java.util.concurrent.CompletableFuture$Completion","methodName":"exec","fileName":"CompletableFuture.java","lineNumber":443},{"declaringClass":"java.util.concurrent.ForkJoinTask","methodName":"doExec","fileName":"ForkJoinTask.java","lineNumber":289},{"declaringClass":"java.util.concurrent.ForkJoinPool$WorkQueue","methodName":"runTask","fileName":"ForkJoinPool.java","lineNumber":1056},{"declaringClass":"java.util.concurrent.ForkJoinPool","methodName":"runWorker","fileName":"ForkJoinPool.java","lineNumber":1692},{"declaringClass":"java.util.concurrent.ForkJoinWorkerThread","methodName":"run","fileName":"ForkJoinWorkerThread.java","lineNumber":157}]

Bad log for startup scripts.

Trying to launch Java Program with options "-Dfile.encoding=UTF-8 -cp [Ljava.lang.String;@5090d8bb
LuceneTest " .

Cannot set the breakpoint for file from included path when restart debug session

Project: https://github.com/fbricon/vscode-java-demo
System: Ubuntu

  1. Git clone the project
  2. Open with VSCode and wait for the project initialized with language server
  3. Config launch.json
  4. Start debugging

Issue:

  1. Debug into SpringApplication which is not part of the workspace but in the included path
  2. Set a breakpoint on the SprintApplication
  3. Restart debug session.

Cannot set the breakpoint for SpringApplication

[Error - 11:22:49 PM] Sep 13, 2017 11:21:52 PM DebugSession dispatch exception:java.lang.IllegalStateException
[Error - 11:37:19 PM] Sep 13, 2017 11:21:52 PM File not found: '/vscode-java-demo/SpringApplication.java'
Resource '/vscode-java-demo/SpringApplication.java' does not exist.
org.eclipse.core.internal.resources.ResourceException: Resource '/vscode-java-demo/SpringApplication.java' does not exist.
	at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:335)
	at org.eclipse.core.internal.resources.Resource.checkAccessible(Resource.java:209)
	at org.eclipse.core.internal.resources.File.getContents(File.java:275)
	at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsCharArray(Util.java:1190)
	at org.eclipse.jdt.internal.core.CompilationUnit.getContents(CompilationUnit.java:652)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1125)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:813)
	at com.microsoft.java.debug.plugin.internal.JdtSourceLookUpProvider.getFullyQualifiedName(JdtSourceLookUpProvider.java:103)
	at com.microsoft.java.debug.core.adapter.handler.SetBreakpointsRequestHandler.convertClientBreakpointsToDebugger(SetBreakpointsRequestHandler.java:110)
	at com.microsoft.java.debug.core.adapter.handler.SetBreakpointsRequestHandler.handle(SetBreakpointsRequestHandler.java:76)
	at com.microsoft.java.debug.core.adapter.DebugAdapter.dispatchRequest(DebugAdapter.java:72)
	at com.microsoft.java.debug.core.adapter.ProtocolServer.dispatchRequest(ProtocolServer.java:201)
	at com.microsoft.java.debug.core.adapter.ProtocolServer.processData(ProtocolServer.java:171)
	at com.microsoft.java.debug.core.adapter.ProtocolServer.start(ProtocolServer.java:95)
	at com.microsoft.java.debug.plugin.internal.JavaDebugServer$2.run(JavaDebugServer.java:131)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "type": "java",
            "name": "Debug (Launch)",
            "request": "launch",
            "mainClass": "com.redhat.vscode.demo.DevoxxApplication",
            "args": "",
            "sourcePaths": [
                "${workspaceRoot}"
            ]
        },
        {
            "type": "java",
            "name": "Debug (Attach)",
            "request": "attach",
            "hostName": "localhost",
            "port": 0,
            "timeout": 30000,
            "sourcePaths": [
                "${workspaceRoot}"
            ]
        }
    ]
}

error

when use mvn clean ,then suffering thing appear、

当用 mvn clean 清空时,项目不会自动编译文件
经过测试发现,只有改动的文件才回再编译
这样在外部利用命令行 mvn clean,清空后,java源文件没改动,但是编译的class被清理了
是不是需要什么设置才能全部重新编译。。。。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.