Skip to content
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

Merged
merged 1 commit into from
Mar 28, 2018
Merged

Support debug protocol. #160

merged 1 commit into from
Mar 28, 2018

Conversation

yaohaizh
Copy link
Contributor

@yaohaizh
Copy link
Contributor Author

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()));
Copy link
Contributor

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

Copy link
Contributor Author

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.

andxu
andxu previously approved these changes Mar 22, 2018
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:
Copy link
Contributor

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.

Copy link
Contributor Author

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typos to -> two.

Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to stepIn

Copy link
Contributor Author

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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typos RestartFarme -> RestartFrame

Copy link
Contributor Author

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) {
Copy link
Contributor

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/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@yaohaizh yaohaizh force-pushed the yaohai_dev branch 2 times, most recently from b01414b to 2d5556c Compare March 26, 2018 07:05
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) {
Copy link
Contributor

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.

Copy link
Contributor Author

@yaohaizh yaohaizh Mar 26, 2018

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

@yaohaizh yaohaizh merged commit c7a2ba9 into master Mar 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants