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

Add postDebugTask to debugger launch.json #11522

Closed
WebFreak001 opened this issue Sep 4, 2016 · 30 comments
Closed

Add postDebugTask to debugger launch.json #11522

WebFreak001 opened this issue Sep 4, 2016 · 30 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality on-testplan release-notes Release notes issues
Milestone

Comments

@WebFreak001
Copy link

There is preLaunchTask already which runs a task right before debugging, it would be cool also having a postDebugTask which would run a task when finishing debugging.

Users could then provide a custom start server and stop server task for example.

@dbaeumer dbaeumer added the debug Debug viewlet, configurations, breakpoints, adapter issues label Sep 4, 2016
@isidorn isidorn added the feature-request Request for new features or functionality label Sep 5, 2016
@isidorn isidorn added this to the Backlog milestone Sep 5, 2016
@isidorn isidorn removed their assignment Sep 5, 2016
@weinand
Copy link
Contributor

weinand commented Sep 20, 2016

duplicate of #2405

@weinand weinand closed this as completed Sep 20, 2016
@weinand weinand added the *duplicate Issue identified as a duplicate of another issue(s) label Sep 20, 2016
@newbrain
Copy link

Hi,
are you sure it's a duplicate?
The postDebug task should not run once the debugger is started, but rather when it's ended (i.e. when the "Stop" red sqare icon is clicked).
The idea behind the proposal, that I originally sent to the native gdb extension, is to have a clean up task that can, e.g., stop debug servers.

@weinand
Copy link
Contributor

weinand commented Sep 20, 2016

@newbrain you are right.

@weinand weinand reopened this Sep 20, 2016
@weinand weinand removed the *duplicate Issue identified as a duplicate of another issue(s) label Sep 20, 2016
@MeirionHughes
Copy link

Something like this would make clean up after transpiling (for debugging) a bit easier.

@rei-vilo
Copy link

rei-vilo commented Mar 9, 2017

Any update on this postLaunchTask feature? Thank you!

@isidorn
Copy link
Contributor

isidorn commented Mar 10, 2017

To be honest I am not undestadning how this is not a duplicate of #2405

All in all, this is still on the backlog. And if demand increases we can consider introducing it in one of the coming releases.

@newbrain
Copy link

@isidorn:
#2405 request that a task be started after the launch, so AFAICU, when the debug session is still active.

This one, instead, is asking for a task to be started when the debugging session is terminated ("Stop" button clicked): quite the opposite.

My use case: cleanly stopping a local debug server process (OpenOCD) when debugging embedded code, so that the e.g. DUT is properly reset.

As for #2405, I used a workaround: start a background script with a "reasonable" delay.

@isidorn
Copy link
Contributor

isidorn commented Mar 10, 2017

@newbrain Got it. Thanks for the explanation,

@weinand
Copy link
Contributor

weinand commented Mar 10, 2017

@isidorn issue #2405 asks for a hook to launch something (e.g. a browser) after the debug session has started whereas this issue asks for a hook when the debug session has ended.

I believe that this request is actually more important than #2405 because that one can be emulated by using a delay.

@MeirionHughes
Copy link

Main problem at the moment is that there is no way to clean up after debugging ts-compiled code, which all needs to be on the file system in order for vscode to find it. We either need a way to clean up after debugging (this issue), or a way to have vscode debug without the js and map file on the fs.

@weinand
Copy link
Contributor

weinand commented Mar 10, 2017

@MeirionHughes any suggestions how VS Code could support debugging without js and map files on the filesystem?

@MeirionHughes
Copy link

MeirionHughes commented Mar 10, 2017

Well I'm currently using webpack-dev-server quite a lot, and it keeps everything in memory and serves up those files when requested by chrome.

In principle, all you'd really need is

  • a webpack plugin that calls
  • a vscode server API to supply and update the sourcemaps files (and paths).

whenever the in-memory source/sourcemap is compiled by webpack it could then continually update vscode via the API.

I would imagine the main innards of how vscode deals with the source-mapping would be unaffected - although perhaps it would need testing to make sure you can actually update the sourcemaps on the fly. For example: hot-module reloading where chrome/chrome-debugger won't actually be refreshing the whole page.

@xinyanmsft
Copy link

xinyanmsft commented May 23, 2017

Having a Post debug task is very help for us to clean up remote connections.
Scenario:
We automate some remote debugging scenario by having the prelaunch task establish a SSH connection (port forwarding) to the remote host. The problem now is, we don't have a good way to know when to safely clean up this connection after debugging stops. There is no way to get that event from an extension as well.
If there is a post debug task, we can use it to reliably clean up remote connections.
@isidorn @weinand

@G1itcher
Copy link

Would the team consider an external contribution for this?

@isidorn
Copy link
Contributor

isidorn commented Jul 17, 2017

@G1itcher yes PRs are welcome, however before writing code feel free to just create a PR with a proposed solution. Once we agree on the structure we can start coding.
If you prefer to code you can just start with that however be aware that we might reject it
Code pointer https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/debug/electron-browser/debugService.ts#L880

Also ping me on the pr. Thanks!

@weinand weinand modified the milestones: Backlog, On Deck Nov 13, 2017
@cleidigh
Copy link
Contributor

@G1itcher
Did you decide to work on this? If not let me know as I can do a PR also.

@G1itcher
Copy link

Hi @cleidigh. Unfortunately my situation has changed and I've had 0 free time to sit down and look at this.

@isidorn
Copy link
Contributor

isidorn commented Mar 7, 2018

I started looking into this "postDebugTask". This task will be launched when a debug process ends, which basically means when you stop debugging or when you restart your session.
preLaunchTask also gets run on restart so I think this is consistent.

How should we call this? Is "postDebugTask" a good name, how about "postLaunchTask"?
How to make it clear that users do not confuse it with #2405 since both @weinand and me confused it a couple of times.

An alternative to adding a new string field is adding a structured object, something like:

"task": {
  "name" : "foo",
  "whenToExecute": "preLaunch" | "postLaunch" | "onSessionEnd"
}

The upside of this is that it makes it a bit clearer when it will be executed and we can also cover #2405. Downside is that strucutred objects are more complex.

Let me know what you think @weinand

@newbrain
Copy link

newbrain commented Mar 7, 2018

@isidorn:
"onSessionEnd" is quite self-explicative, I prefer it to my original proposal of "postDebug(Task)".
If a structured object is not used, "onSessionEndTask" seems quite right.

Thanks for picking this up.

@weinand
Copy link
Contributor

weinand commented Mar 7, 2018

@isidorn since we already have a "preLaunchTask" I suggest that we continue to use this naming scheme (and avoid the structured object and the "on*" style). I still like the name "postDebugTask".
And "postLaunchTask" is already reserved for #2405.

Restart behaviour: we have two "restart" mechanisms:

  1. User presses "Restart" button
  2. launch config uses "restart" attribute and session is restarted automatically.

I'm pretty sure that "postDebugTask" must not be called in the second case.
But I'm not completely sold that it should be called in the first case.

@isidorn isidorn closed this as completed in 526c5c0 Mar 8, 2018
@isidorn
Copy link
Contributor

isidorn commented Mar 8, 2018

I have pushed the initial support for this. Try it out in tomorrow's vscode insiders and let us know what you think.

@weinand what you are saying makes sense, however I think the use case is that people want to deconstruct whatever they contructed in preLaunchTask. So I think this should run symetrical to preLaunchTask. As a seperate discussion we can figure out if preLaunchTask should be run on restart (currently it does)?

A seperate issue on my end is that I do not know what is the reason that a session stopped, or started so in both those I run preLaunch or postDebug task.

I am open to changing this but pushed a first version so we get some feedback.

@isidorn isidorn mentioned this issue Mar 8, 2018
2 tasks
@weinand
Copy link
Contributor

weinand commented Mar 8, 2018

@isidorn you said:

I do not know what is the reason that a session stopped, or started so in both those I run preLaunch or postDebug task.

This is not true for the "restart" case (2. from above). In this case you receive a "restart" attribute in the "terminate" event, so you could know that a "preLaunchTask" and "postDebugTask" is not needed for an automatic "restart".

I don't think that Docker users want to shutdown and relaunch a Docker session on every source code edit.

@chrisdias @WebFreak001 @newbrain what do you think?

@isidorn
Copy link
Contributor

isidorn commented Mar 8, 2018

@weinand I did not mean it is not possible, just my code is structured in such a way that I do not have that knowledge when I am reacting on seassion has ended event.
As I mentioned above I am open to changing this.

@isidorn
Copy link
Contributor

isidorn commented Mar 8, 2018

@weinand also it seems than for that scenario we should also not run the preLaunchTask again. So it still feels to me preLaunchTask and postDebugTask are "symetric".

@rei-vilo
Copy link

rei-vilo commented Mar 8, 2018

That's great news. I'll try the Insider version when it is released!

The use case I have is about debugging MCUs.

  • Launch the GDB server (OpenOCD, JLinkGDBServer or other) with preLaunchTask,
  • Perform the debugging session,
  • Once the debugging session is completed, close it and stop the GDB server with postDebugTask.

Some GDB clients allows to start the server from the GDB clients and to stop it when closing the debugging session, but not all. However, even in that case, I haven't figured out how to set all those parameters on the launch.json file, as the client tries to connect to the server before it starts.

@rei-vilo
Copy link

rei-vilo commented Mar 8, 2018

@isidorn

Could preLaunchTask be called preDebugTask, either as a new name or a synonym for preLaunchTask?

@isidorn
Copy link
Contributor

isidorn commented Mar 8, 2018

@rei-vilo no, since that would be a breaking change.

@weinand
Copy link
Contributor

weinand commented Mar 8, 2018

@rei-vilo let's talk about semantics first, and then discuss name changes.

@isidorn yes, preLaunchTask should not be called on automatic "restart" (case 2). In the Docker scenario (https://github.com/Microsoft/vscode-recipes/tree/master/Docker-TypeScript) we are lucky and survive multiple activations of the preLaunchTask because it is a background watcher task anyway.

@isidorn
Copy link
Contributor

isidorn commented Mar 8, 2018

@weinand I have pushed a change that both preLaunch and postDebug task are not being run on automatic restarts.
Let's try it out and then we can decide if they should be run for explitcit user restarts - currently they are being run.
Thanks

@weinand
Copy link
Contributor

weinand commented Mar 8, 2018

Great, thanks. I'll try my scenarios tomorrow.

@isidorn isidorn added the release-notes Release notes issues label Mar 26, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality on-testplan release-notes Release notes issues
Projects
None yet
Development

No branches or pull requests

10 participants