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

Implementation of evaluate request #47

Closed
simark opened this issue Dec 7, 2018 · 7 comments
Closed

Implementation of evaluate request #47

simark opened this issue Dec 7, 2018 · 7 comments

Comments

@simark
Copy link
Contributor

simark commented Dec 7, 2018

I looked at the implementation of the evaluate request (specifically the repl context), and have some concerns. My understanding is that the goal of this request is to evaluate an expression in the language you are debugging, and not executing debugger commands. In a REPL such as the browser console, you input expressions that can be evaluated as javascript (such as 1 + 2), and the debugger returns the result.

The current implementation executes the expression as a debugger command, which is not the same thing. My understanding is that this allows to get a really basic gdb console in VSCode, leveraging the debugger console.

I think it would be very useful to let clients evaluate expressions in the language being debugged (e.g. &myArray) and return the result. This would map pretty much directly to -data-evaluate-expression in GDB.

If it's still needed to run arbitrary GDB commands, we could add another context, but keep repl for evaluating C/C++ expressions. In the long run, it will be much better to have an actual GDB console (#30) anyway.

Comments?

@dschaefer
Copy link
Contributor

Yeah, I'm cheating. With vscode, there is no interactive console available to the debug session out of the box. So I hooked the expression evaluator up to do straight gdb commands. Great for testing in the beginning :). But yes, the help text in the text box does say expression, not debugger command.

Will need to figure out what to do on the vscode side if we want to change it. I think it's probably safe to do it now since we don't really have users yet other than @jcrwilliams and myself.

@simark
Copy link
Contributor Author

simark commented Dec 7, 2018

Have you started to look into how to create custom views in VSCode? Would it be possible to instantiate a separate console view/widget (like the repl), and customize it to send the request with a different context?

@dschaefer
Copy link
Contributor

Yeah, we've done a bunch of custom webviews and such. And we'll do custom views for Registers and something with memory. I want to check out the Terminal API to see if we can do it there.

I also want to check out how the PlatformIO IDE does this stuff. Love to get those guys to switch to our extensions. We can at least learn from them. It's a pretty rich environment on VS code.

simark pushed a commit to simark/cdt-gdb-adapter that referenced this issue Jan 17, 2019
As discussed in eclipse-cdt-cloud#47, this patch changes how evaluate requests are
handled.  Currently, they are handled as GDB commands.  The intent of
the request is more to evaluate expressions in the target language.

This is already what we do when context is 'watch'.  This patch makes it
so we handle it the same way regardless of the context.

A simple test for the evaluate request is added.

Signed-off-by: Simon Marchi <[email protected]>
dschaefer pushed a commit that referenced this issue Jan 29, 2019
* Change behavior of evaluate request handling

As discussed in #47, this patch changes how evaluate requests are
handled.  Currently, they are handled as GDB commands.  The intent of
the request is more to evaluate expressions in the target language.

This is already what we do when context is 'watch'.  This patch makes it
so we handle it the same way regardless of the context.

A simple test for the evaluate request is added.

Signed-off-by: Simon Marchi <[email protected]>

* Quote expressions passed to -var-create

Creating variable objects from expressions containing spaces (such as
"2 + 2") does not work currently.

Quote the expression passed to -var-create to handle this use case.

Signed-off-by: Simon Marchi <[email protected]>

* Send error message if evaluate is missing frameId

We currently don't support evaluating requests that lack a frameId
(normally, we should evaluate them in the global scope).

Instead of sending back that the request has succeeded with an error
message as the value, return an error.  Otherwise, the client doesn't
really have a way to notice the failure, since what it receives looks
like a regular value.

Signed-off-by: Simon Marchi <[email protected]>

* Send error when evaluate fails

When processing an evaluate request with an invalid expression (such as
"2 + "), we send back a "success" with an error message in the body.
This doesn't let the client handle the failure correctly.  Instead, send
back an error.

Signed-off-by: Simon Marchi <[email protected]>
@dwjbosman
Copy link

dwjbosman commented Jul 7, 2019

I am trying to use the cdt-gdb-adapter as part of theia's cdt-gdb-vscode plugin. I can open Theia's debug console and interact with GDB. I think evaluateRequest in GDBDebugSession.js is called when a command is typed in the debug console.

Unfortunately all commands send to evaluateRequest seem to be handled as evaluation of variable expressions. So it is not possible to execute arbitrary GDB commands. In the following issue microsoft/vscode-cpptools#106 they solved this by implementing a special prefix command (use "-exec") when executing GDB commands.

Is there any way of executing GDB commands directly?

@paul-marechal
Copy link
Member

If you are working on Linux, you can set the openGdbConsole configuration option to true in order to open a proper GDB prompt in a terminal. From there you should be able to use regular commands.

@dwjbosman
Copy link

The worked great!

@jonahgraham
Copy link
Contributor

This was resolved in #69 - if there is follow-on work, new issues that explain what is left should be raised.

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

No branches or pull requests

5 participants