Skip to content

Debug API #28500

Closed
Closed

Description

We are looking into adding debug API to our vscode.d.ts. In order to design this as best as possible let's first look at the use cases and the current use of commands.

Use Cases

Commands

Extension --> VS Code

  • vscode.startDebug - extension can start a debug session by calling this command
  • customDebugRequest - extension can send any DAP request to the currently active debug adapter
  • debug.logToDebugConsole - extension can log a string to the debug console

VS Code --> Extension

  • startSessionCommand - if contributed vscode calls this command instead of starting a debug session on its own
  • initialConfigurations - if contributed vscode calls this command to get the initial content of the launch.json

Proposal

Minimal API proposal by Andre Weinand (@weinand) and me. If name and type should be a part of DebugSession is very coraleted to the question Andre Weinand (@weinand) raises below.

export namespace debug {
  export const onDidEndDebugSession: Event<DebugSession>;
}

export interface DebugSession {
   readonly name: string;
   readonly type: string;
   customRequest(requestName: string, args: any): Thenable<DebugRequestResult>;
}

Activity

  1. added
    debug
    feature-request
    under-discussion
    on Jun 12, 2017
  2. weinand commented on Jun 12, 2017

    @weinand
    Contributor

    One interesting question is: can a debugger extension only see the debug sessions that have the type introduced by the debugger extension or can it see all debug sessions of all types?

  3. DanTup commented on Jun 12, 2017

    @DanTup
    Contributor

    I'd like to be able to report status messages from the debug adapter back to the extension so that I can show text in the status bar. There are some things that would be really spammy to log to the debug output window (for example, I think in full-VS it shows in the status bar every DLL symbols are being loaded for during debugging?).

    If status messages is a common requirement, maybe something like an additional channel for OutputEvent (eg. status) would work, though being able to send complete custom messages (similar to customDebugRequest but in the opposite direction) would be ideal, since an extension/debugger than have complete two-way communication (something some debug adapters have apparently implemented themselves by hosting endpoints and connecting back).

  4. isidorn commented on Jun 13, 2017

    @isidorn
    Author

    Danny Tuppeny (@DanTup) thanks for the suggestion however we are taking this one step at a time, currently we are looking into what is the minimal set of APIs to make this good.
    We will probably be focusing more on feature requests from next milestone onward

  5. DanTup commented on Jun 13, 2017

    @DanTup
    Contributor

    Isidor Nikolic (@isidorn) No worries; I figured it was worth you having the info even if you don't do anything with it for now (never hurts to have an idea of what people might want). My request is pretty minor tbh, the debugger just provides this info so I thought I'd look whether I could surface it anywhere.

  6. isidorn commented on Jun 23, 2017

    @isidorn
    Author

    We have introduced an initial API, more details #28234 (comment)
    Andre Weinand (@weinand) should we close this issue, or leave it open as an umbrella item for future discussion regarding the debug API?

  7. weinand commented on Jun 23, 2017

    @weinand
    Contributor

    We leave this open as the umbrella item for future discussions.

  8. 4 remaining items

  9. hediet commented on Nov 21, 2017

    @hediet
    Member

    Andre Weinand (@weinand) thanks for your quick reply. However, running this code:

    const result = await vscode.debug.activeDebugSession.customRequest(
          "evaluate", { expression: "myexpression" });

    throws an exception with the message "not available" (I get the German error message "Nicht verfügbar").
    I set enableProposedApi to true in package.json and made sure that there is an active debug session.

    Is there an event that fires when the debugger switches between running and pause mode?
    I want to code an extension that can visualize expressions while debugging - if you want, a more graphical watch window.

  10. weinand commented on Nov 21, 2017

    @weinand
    Contributor

    Yes, some debuggers can only "evaluate" if they are stopped.

    Currently there is no API to track the debug status. Here is the corresponding feature request: #30810

    BTW, It is no longer necessary to set "enableProposedApi" to true, since the API already lives in "vscode.d.ts" (and not vscode.proposed.d.ts").

  11. hediet commented on Nov 21, 2017

    @hediet
    Member

    I always get this error (even if the debugger is stopped). In order to access the debug namespace, I had to copy the content from vscode.d.ts of the github repository into the vscode.d.ts file of the most recent (1.1.7) vscode package. I am using the most recent version of vs code (1.18.1). Maybe a bug?

  12. weinand commented on Nov 21, 2017

    @weinand
    Contributor

    Please update your vscode dependency in your package.json, e.g.:

    	"engines": {
    		"vscode": "^1.18.0",
    		"node": "^7.4.0"
    	},
    

    and then delete node_modules folder and run npm install again.

    Or just run the postinstallscript:

    	"scripts": {
    		"postinstall": "node ./node_modules/vscode/bin/install",
                    /// ....
    	},
    

    What debugger extension are you using?

  13. hediet commented on Nov 21, 2017

    @hediet
    Member

    I am using this launch.json:

    {
    	"version": "0.2.0",
    	"configurations": [	
    		{
    			"type": "node",
    			"request": "launch",
    			"name": "Launch Program",
    			"program": "${workspaceFolder}/index.js"
    		}
    	]
    }

    (the default nodejs debugger)
    After deleting the node_modules folder and reinstalling all packages, it found the debug namespace - just changing the version in package.json and running npm install didn't do it. However, the error is still being thrown.

  14. hediet commented on Feb 5, 2018

    @hediet
    Member

    Are there any updates? I never managed to get it working (i.e. asking the debugging adapter to evaluate expressions). I am waiting for this feature for an awesome extension I want to prototype.

  15. isidorn commented on Feb 5, 2018

    @isidorn
    Author

    Henning Dieterichs (@hediet) we now support many new things in the debug api. You can find it here
    Andre Weinand (@weinand) I see no use of keeping this issue open, thus closing it.

  16. hediet commented on Feb 5, 2018

    @hediet
    Member

    Isidor Nikolic (@isidorn) I still don't see how to ask the debugger to evaluate a given expression. Did I miss something in the documentation?

  17. isidorn commented on Feb 5, 2018

    @isidorn
    Author

    Henning Dieterichs (@hediet) appologies, I misunderstood what you are exactly meaning to do. The evaluate request is still not a part of the API. For that one please create a brand new feature request so we have this on our radar. Thank you.

  18. weinand commented on Feb 6, 2018

    @weinand
    Contributor

    The "Evaluate Debug API" discussion continues here: #42989

  19. removed
    under-discussion
    on Feb 6, 2018
  20. removed this from the On Deck milestone on Feb 6, 2018
  21. locked and limited conversation to collaborators on Mar 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apidebugfeature-request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions