WebFreak001 / code-debug

Native debugging for VSCode
The Unlicense
401 stars 114 forks source link

Support evaluate on hover #10

Closed csholmq closed 8 years ago

csholmq commented 8 years ago

In order for this to work, it appears that the extension needs to support

/** The debug adapter supports a (side effect free) evaluate request for data hovers. */
supportsEvaluateForHovers?: boolean;

https://github.com/Microsoft/vscode/issues/2745#issuecomment-181765580 https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/debug/common/debugProtocol.d.ts#L489

WebFreak001 commented 8 years ago

:+1: gonna implement

WebFreak001 commented 8 years ago

Actually Im not quite sure if this would make sense, as it would only support global variables because variables in functions keep changing, for example children of a class. Im gonna try and do my best

csholmq commented 8 years ago

But it makes total sense for global variables! :) Especially for structural languages such as C.

Here's how I use your plugin with my remote target (GDB) and polling variables using Watch:

gdb_remote_debug

https://github.com/Microsoft/vscode/issues/2833

WebFreak001 commented 8 years ago

I dont think this will actually work for running symbols if not using gdbserver or something else.

For me it gives an error when trying to access a global variable while the program is running: Cannot access memory at address 0x6008f4

csholmq commented 8 years ago

@WebFreak001 I get that when I use the wrong offset. Does it work for you using a Watch?

WebFreak001 commented 8 years ago

I am currently testing it in the watch. It only works when the program is paused, otherwise it tells me "cannot access memory". Here is my used code:

#include <stdio.h>

int GlobalVariable = 0;

int main() {
    printf("Hello World\n");
    while(1) {
        GlobalVariable++;
    }
    return 0;
}
csholmq commented 8 years ago

Well I'm in a remote target debug; don't know if that makes a difference. I just press Start once and then a add-symbol-file My_Elf_File.elf 0x8020000 in the console.

If I press Continue or Step, everything stops working.

"name": "Debug GDB",
"type": "gdb",
"request": "attach",
"target": ":4444",
"remote": true,
WebFreak001 commented 8 years ago

In theory its implemented now. However vscode does not seem to call evaluate for me. Maybe its implemented in the february release?

csholmq commented 8 years ago

Great. According to https://github.com/Microsoft/vscode/issues/2745#issuecomment-181765580 they need to add support in VSCode to evaluate whilst not paused.

WebFreak001 commented 8 years ago

I mean it also doesn't get called when its paused (on a breakpoint)

csholmq commented 8 years ago

Hmm. Then I don't really know what's going on.

Is there a difference to "Paused" and "Stopped"?

WebFreak001 commented 8 years ago

There is only a StopEvent that I need to send when the program pauses. If it completely quits I need to send a TerminatedEvent. I think this is a vscode bug or they only have it in the current development version. I only have the January release

csholmq commented 8 years ago

Not really sure of the current status atm. But now when I start my remote debug it seems to stop at inside an arbitrary function (same every time, with no breakpoint set) and spoofs a call stack.

I can also hover variables (call stack only) so that part seems to work (as long as it thinks it's paused).

image

As soon as I change view or reload symbols however, the call stack disappears, together with the ability to hover variables. So with https://github.com/Microsoft/vscode/issues/2833 we can hopefully alter that behavior to have hover polling on at all stages of debug.

WebFreak001 commented 8 years ago

now working in latest release!