-
Notifications
You must be signed in to change notification settings - Fork 159
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
Support debug protocol. #160
Conversation
debugEvent.shouldResume = false; | ||
// Have to send to events to keep the UI sync with the step in operations: | ||
context.getProtocolServer().sendEvent(new Events.StoppedEvent("step", thread.uniqueID())); | ||
context.getProtocolServer().sendEvent(new Events.ContinuedEvent(thread.uniqueID())); |
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.
why to send continued event to vscode
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.
After the stack operation (pop/stepin), the UI is out of sync with the underlying JVM debugger status. Thus, send continue event to update the VSCode UI to let the VSCode populate the threading information. The continue event will stop at the first line of the stepin method.
private boolean canRestartFrame(IDebugAdapterContext context, StackFrameReference frameReference) { | ||
ThreadReference reference = frameReference.getThread(); | ||
StackFrame[] frames = context.getStackFrameManager().reloadStackFrames(reference); | ||
// Current stack frame cannot be the top frame of the thread: |
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.
// Cannot restart top stack frame.
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.
top stack frame is misleading.
StepRequest request = DebugUtility.createStepIntoRequest(thread, context.getStepFilters().classNameFilters); | ||
context.getDebugSession().getEventHub().stepEvents().filter(debugEvent -> request.equals(debugEvent.event.request())).take(1).subscribe(debugEvent -> { | ||
debugEvent.shouldResume = false; | ||
// Have to send to events to keep the UI sync with the step in operations: |
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.
typos to
-> two
.
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.
with the step in operations
is a little confusing at the quick glance, how about changing it to with the latest stepIn status
.
} | ||
} | ||
|
||
private void stepin(IDebugAdapterContext context, ThreadReference thread) { |
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.
rename to stepIn
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.
Fixed.
|
||
if (stackFrameReference == null) { | ||
return AdapterUtils.createAsyncErrorResponse(response, ErrorCode.RESTARTFRAME_FAILURE, | ||
String.format("RestartFarme: cannot find the stack frame with frameID %s", restartFrameArgs.frameId)); |
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.
typos RestartFarme
-> RestartFrame
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.
Fixed.
} | ||
|
||
private void popStackFrames(IDebugAdapterContext context, ThreadReference thread, int depth) throws DebugException { | ||
while (depth >= 0) { |
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.
It seems all stack frames up to the specified depth can be popped by the one invoke. See the doc https://docs.oracle.com/javase/7/docs/jdk/api/jpda/jdi/
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.
Updated.
b01414b
to
2d5556c
Compare
ThreadReference reference = frameReference.getThread(); | ||
StackFrame[] frames = context.getStackFrameManager().reloadStackFrames(reference); | ||
// The frame cannot be the first one of the stack: | ||
if (frames.length <= frameReference.getDepth() + 1) { |
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.
From the implementation, it looks the last one
, not the first one
.
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.
The callstack first one, not the top(last) after pop
@andxu @akaroml @testforstephen