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

Debug API #28500

Closed
isidorn opened this issue Jun 12, 2017 · 20 comments
Closed

Debug API #28500

isidorn opened this issue Jun 12, 2017 · 20 comments
Assignees
Labels
api debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality

Comments

@isidorn
Copy link
Contributor

isidorn commented Jun 12, 2017

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 @weinand and me. If name and type should be a part of DebugSession is very coraleted to the question @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>;
}
@isidorn isidorn added debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality under-discussion Issue is under discussion for relevance, priority, approach labels Jun 12, 2017
@weinand weinand added the api label Jun 12, 2017
@weinand
Copy link
Contributor

weinand commented Jun 12, 2017

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?

@DanTup
Copy link
Contributor

DanTup commented Jun 12, 2017

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).

@isidorn
Copy link
Contributor Author

isidorn commented Jun 13, 2017

@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

@isidorn isidorn added this to the June 2017 milestone Jun 13, 2017
@DanTup
Copy link
Contributor

DanTup commented Jun 13, 2017

@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.

@isidorn
Copy link
Contributor Author

isidorn commented Jun 23, 2017

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

@weinand
Copy link
Contributor

weinand commented Jun 23, 2017

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

@weinand weinand modified the milestones: On Deck, June 2017 Jun 23, 2017
@vadimcn
Copy link
Contributor

vadimcn commented Jul 28, 2017

I just want to highlight this comment here.

Say, my extension wants to send a custom command in response to a UI action. How does it know which debug session to send it to?
Should I still use workbench.customDebugRequest command in this scenario? But what if the active debug session was contributed by another extension?

@weinand
Copy link
Contributor

weinand commented Jul 28, 2017

In the July release there will be API to track the active debug session and to find out the type of the debug session. This makes it possible to send custom command only to those sessions, that are "owned" by your extension.

@hediet
Copy link
Member

hediet commented Nov 21, 2017

Is it possible somehow for an extension to ask the debug adapter to evaluate a given expression? It would be great if such an API method was available.

@hediet
Copy link
Member

hediet commented Nov 21, 2017

@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.

@weinand
Copy link
Contributor

weinand commented Nov 21, 2017

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").

@hediet
Copy link
Member

hediet commented Nov 21, 2017

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?

@weinand
Copy link
Contributor

weinand commented Nov 21, 2017

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?

@hediet
Copy link
Member

hediet commented Nov 21, 2017

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.

@hediet
Copy link
Member

hediet commented Feb 5, 2018

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.

@isidorn
Copy link
Contributor Author

isidorn commented Feb 5, 2018

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

@isidorn isidorn closed this as completed Feb 5, 2018
@hediet
Copy link
Member

hediet commented Feb 5, 2018

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

@isidorn
Copy link
Contributor Author

isidorn commented Feb 5, 2018

@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.

@weinand
Copy link
Contributor

weinand commented Feb 6, 2018

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

@weinand weinand removed the under-discussion Issue is under discussion for relevance, priority, approach label Feb 6, 2018
@weinand weinand removed this from the On Deck milestone Feb 6, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

5 participants