-
Notifications
You must be signed in to change notification settings - Fork 163
customRequest 'processId' to get the debugging Java process id #399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
testforstephen
merged 5 commits into
microsoft:main
from
testforstephen:jinbo_processId
Mar 28, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fc76ef2
customRequest 'processId' to get Java process id
testforstephen d1f9328
Fix checkstyle
testforstephen e0e4465
support 'processId' request in Run action
testforstephen 05ba417
send a custom notification when processId/shellProcessId is ready
testforstephen d0e6163
Merge branch 'main' into jinbo_processId
testforstephen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/ProcessIdHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Microsoft Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Microsoft Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package com.microsoft.java.debug.core.adapter.handler; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import com.microsoft.java.debug.core.adapter.IDebugAdapterContext; | ||
import com.microsoft.java.debug.core.adapter.IDebugRequestHandler; | ||
import com.microsoft.java.debug.core.protocol.Messages.Response; | ||
import com.microsoft.java.debug.core.protocol.Requests.Arguments; | ||
import com.microsoft.java.debug.core.protocol.Requests.Command; | ||
import com.microsoft.java.debug.core.protocol.Responses.ProcessIdResponseBody; | ||
|
||
public class ProcessIdHandler implements IDebugRequestHandler { | ||
@Override | ||
public List<Command> getTargetCommands() { | ||
return Arrays.asList(Command.PROCESSID); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Response> handle(Command command, Arguments arguments, Response response, | ||
IDebugAdapterContext context) { | ||
long processId = context.getProcessId(); | ||
long shellProcessId = context.getShellProcessId(); | ||
if (context.getDebuggeeProcess() != null) { | ||
processId = context.getDebuggeeProcess().pid(); | ||
} | ||
|
||
response.body = new ProcessIdResponseBody(processId, shellProcessId); | ||
return CompletableFuture.completedFuture(response); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I debug Boot App via "Debug" action i get this back:
which is great.
However, when i run the app via the "Run" action i get an error back:
Is it possible to make it work with "Run" action?
I thought the change for this would be instead of
registerHandlerForDebug(...)
callregisterHandler(...)
but this didn't work for me and i hope also because i messed up the build...What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we can support it in "Run" as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added 'processId' request in Run action as well.
If the Run action is running with internalConsole, it works fine.
However, if the Run action is triggered on terminal shell, it may not work. In this case, Java debugger will terminate the DAP debug session early once the RunInTerminal request is responded. You may not have opportunity to call custom request to get processId.
We have a TODO task to not terminate DAP session when triggering a Run with integratedTerminal, which requires more work and may not be done right away.