Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

debug: fix updating breakpoints while debuggee is running #2128

Merged
merged 7 commits into from
Jan 24, 2019

Conversation

xiphon
Copy link
Contributor

@xiphon xiphon commented Nov 15, 2018

Issue
Can't set/remove breakpoints while debuggee is running

Details
Implemented stop-breakpoint-start approach to resolve the issue as described in #978 (comment).
Take a look at #978 for details, @muravjov's comments contain detailed description what's going wrong in that case.

Fixes #2002

@xiphon xiphon force-pushed the fix-breakpoints branch 5 times, most recently from 9edd5b0 to 003a3e5 Compare November 16, 2018 11:26
@jhendrixMSFT
Copy link
Member

@xiphon can you please rebase on top of master?

@xiphon xiphon force-pushed the fix-breakpoints branch 2 times, most recently from a5c534e to 504b8cd Compare January 12, 2019 00:22
@xiphon
Copy link
Contributor Author

xiphon commented Jan 12, 2019

Rebased

src/debugAdapter/goDebug.ts Outdated Show resolved Hide resolved
src/debugAdapter/goDebug.ts Outdated Show resolved Hide resolved
@@ -1073,17 +1091,22 @@ class GoDebugSession extends LoggingDebugSession {
this.threads.delete(id);
});

if (this.skipStopEventOnce) {
this.skipStopEventOnce = false;
return;
Copy link
Contributor

@ramya-rao-a ramya-rao-a Jan 14, 2019

Choose a reason for hiding this comment

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

Its not clear to me as to why we need to do this...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To silently skip the pause that we introduce just to set the breakpoint and continue right after.

src/debugAdapter/goDebug.ts Outdated Show resolved Hide resolved
return this.continue();
}, err => {
logError(err);
return this.sendErrorResponse(response, 2009, 'Failed to continue delve after setting the breakpoint: "{e}"', { e: err.toString() });
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this error handler is for the continue operation, I would move it up like so:

this.delve.callPromise('Command', [{ name: 'halt' }]).then(() => {
   return this.setBreakPoints(response, args).then(() => {
     return this.continue().then(null, err => {
          logError(err);
          this.sendErrorResponse(response, 2009, 'Failed to continue delve after setting the breakpoint: "{e}"', { e: err.toString() });
        })
    }, null);
}, err => {
     logError(err)
     this.sendErrorResponse(response, 2008, 'Failed to halt delve before attempting to set breakpoint: "{e}"', { e: err.toString() });
  });

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, on second thought, this.continue() doesnt return a promise.
Also, inside this.continue(), if the call to delve failed, it is logged and the error doesnt bubble up here.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jan 18, 2019

@xiphon I have pushed a commit to handle the error from continue().

Please see 45e6b64 and 4226264

In the normal scenario where continueRequest is called, one thing I am not clear about is whether delve returns the state when it fails the "continue" request...
I believe it doesnt. And if it does, whether we should update the debugState or not. @jhendrixMSFT, @xiphon Have seen anything otherwise?

@OneOfOne
Copy link
Contributor

OneOfOne commented Jan 18, 2019

this needs to be rebased against pull/2126

@jhendrixMSFT
Copy link
Member

Fixes #2002

@xiphon
Copy link
Contributor Author

xiphon commented Jan 18, 2019

@ramya-rao-a

whether delve returns the state when it fails the "continue" request...
I believe it doesnt

Right

@jhendrixMSFT

Fixes #2002

Updated the description


Will update the PR to finally fix all the edge cases:

  1. If continue fails, a user will end up with non-recoverable debug session state. Internally it will be paused, but VS Code UI will display it as running. Already fixed in @ramya-rao-a's commits
  2. setBreakPoints sends response in both cases: on success and on error. But we also invoke sendErrorResponse if continue fails (https://github.com/Microsoft/vscode-go/pull/2128/files#diff-16e876ed2a6ddf6a530a935e37dddfdbR765).
    If both setBreakPoints and continue fail, we send error response twice.
  3. If halt fails, we have to revert skipStopEventOnce to false

@xiphon
Copy link
Contributor Author

xiphon commented Jan 19, 2019

Updated

@ramya-rao-a
Copy link
Contributor

@xiphon If the continue after the halting of delve fails, right now we are just logging the error. Shouldnt we send the error response too?

@xiphon
Copy link
Contributor Author

xiphon commented Jan 19, 2019

@ramya-rao-a ramya-rao-a merged commit 4249d0c into microsoft:master Jan 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Breakpoints added when debug session is not in a paused state, results in debug process not ending
4 participants