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

Missing Variable Value Tooltips #121

Closed
chroberino opened this issue Nov 14, 2024 · 9 comments · Fixed by eclipse-cdt-cloud/cdt-gdb-adapter#347 or #129
Closed

Missing Variable Value Tooltips #121

chroberino opened this issue Nov 14, 2024 · 9 comments · Fixed by eclipse-cdt-cloud/cdt-gdb-adapter#347 or #129

Comments

@chroberino
Copy link

I am using the cdt-gdb-vscode extension (v0.0.108) with Eclipse Theia for remote debugging with gdb, and overall, the setup works well. However, a key feature appears to be missing: variable value tooltips. When I hover over a variable name in the editor window, I do not see a tooltip displaying the variable's current value.

This feature is available in another debug adapter I was using, and it would be very helpful for my workflow to have the same functionality here.

@chroberino
Copy link
Author

Well, having a further look at it I can now say that for some variables I do get hover values.

Tinkering around in the gdb console I found a major difference between a variable where I get a hover value and a variable where I don't get it.

In my program code there is a variable named result and it does show a hover value when debugging:

>info address result
Symbol "result" is a complex DWARF expression:
     0: DW_OP_fbreg -12

One of the variables not showing a hover tooltip is switch1:

>info address switch1
Symbol "switch1" is static storage at address 0xb554d87.

Maybe this difference (static vs. local) is relevant for your debug adapter?
Does this help you to identify the issue?

In fact, another debug adapter is giving me the tooltip also for the switch1 variable, so the debug infrormation is basically available and I can use the gdb console to read its value:

>print switch1
$1 = 0

@chroberino
Copy link
Author

Just collected some additional information: When using MS's C/C++ extension (ms-vscode.cpptools) I am getting these tooltips for both types of variables, local and static. The MS extension seems to retrieve values from gdb on demand (i.e. when hovering over a variable).

This is the log output from the extension when hovering over a local variable:

<--   C (evaluate-42): {"command":"evaluate","arguments":{"expression":"result","frameId":1000,"context":"hover","line":20,"column":7,"source":{"name":"Main.c","path":"d:\\DbgTest\\Main.c","sources":[],"checksums":[]}},"type":"request","seq":42}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (52551) <-1077-var-create  - * \"result\"\r\n"},"seq":2088}
1: (52551) <-1077-var-create  - * "result"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (52565) ->1077^done,name=\"var11\",numchild=\"0\",value=\"0\",type=\"long\",thread-id=\"8\",has_more=\"0\"\r\n"},"seq":2090}
1: (52565) ->1077^done,name="var11",numchild="0",value="0",type="long",thread-id="8",has_more="0"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (52565) ->(gdb)\r\n"},"seq":2092}
1: (52565) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (52565) 1077: elapsed time 14\r\n"},"seq":2094}
1: (52565) 1077: elapsed time 14
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (52566) ->&\"\\n\"\r\n"},"seq":2096}
1: (52566) ->&"\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (52566) ->^done\r\n"},"seq":2098}
1: (52566) ->^done
--> R (evaluate-42): {"type":"response","request_seq":42,"success":true,"command":"evaluate","body":{"result":"0","type":"long","variablesReference":0,"memoryReference":"0x00000000"},"seq":2099}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (52566) ->(gdb)\r\n"},"seq":2102}
1: (52566) ->(gdb)

And here's the output for hovering over a static variable:

<--   C (evaluate-44): {"command":"evaluate","arguments":{"expression":"counter1","frameId":1000,"context":"hover","line":23,"column":3,"source":{"name":"Main.c","path":"d:\\DbgTest\\Main.c","sources":[],"checksums":[]}},"type":"request","seq":44}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (237426) <-1079-var-create  - * \"counter1\"\r\n"},"seq":2122}
1: (237426) <-1079-var-create  - * "counter1"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (237441) ->1079^done,name=\"var13\",numchild=\"0\",value=\"0\",type=\"short\",has_more=\"0\"\r\n"},"seq":2124}
1: (237441) ->1079^done,name="var13",numchild="0",value="0",type="short",has_more="0"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (237441) ->(gdb)\r\n"},"seq":2126}
1: (237441) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (237441) 1079: elapsed time 14\r\n"},"seq":2128}
1: (237441) 1079: elapsed time 14
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (237441) ->&\"\\n\"\r\n"},"seq":2130}
1: (237441) ->&"\n"
--> R (evaluate-44): {"type":"response","request_seq":44,"success":true,"command":"evaluate","body":{"result":"0","type":"short","variablesReference":0,"memoryReference":"0x00000000"},"seq":2132}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (237441) ->^done\r\n"},"seq":2134}
1: (237441) ->^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (237441) ->(gdb)\r\n"},"seq":2136}
1: (237441) ->(gdb)

jonahgraham added a commit to jonahgraham/cdt-gdb-adapter that referenced this issue Dec 16, 2024
There is a slight concern of turning this on for GDB as it is documented
with this [requirement](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Capabilities):

> The debug adapter supports a (side effect free) `evaluate`
> request for data hovers.

Because of side-effects on read that is present in memory mapped
registers in embedded systems this can cause unexpected reads of the
target's registers.  For Eclipse CDT I don't think there is any
special code, so I think it is ok to do this here too. GDB also
has a number of settings that may be useful to prevent accidental
reads too.

Fixes eclipse-cdt-cloud/cdt-gdb-vscode#121
@jonahgraham
Copy link
Contributor

I don't know why it wasn't enabled when the adapter was first written, but supportsEvaluateForHovers is false for cdt-gdb-vscode. To set this to true we have to meet the requirement:

The debug adapter supports a (side effect free) evaluate request for data hovers.

Because of side-effects on read that is present in memory mapped registers in embedded systems this can cause unexpected reads of the target's registers. For Eclipse CDT I don't think there is any special code, so I think it is ok to do this here too. GDB also has a number of settings that may be useful to prevent accidental reads too.

Fix in progress in eclipse-cdt-cloud/cdt-gdb-adapter#347

@jonahgraham
Copy link
Contributor

Thanks @chroberino for taking the time to report this issue. When I next publish the adapter this change will appear. The version will probably be v1.0.5

@chroberino
Copy link
Author

chroberino commented Dec 17, 2024

Thanks @chroberino for taking the time to report this issue. When I next publish the adapter this change will appear. The version will probably be v1.0.5

Thank you so much, @jonahgraham!
I was actually starting to look into this by myself. But I didn't find a way to debug into cdt-gdb-adapter via cdt-gdb-vscode. I succeeded with yarn link cdt-gdb-adapter as suggested in the readme, but I did not find a way to step into the cdt-gdb-adapter code.

=> I would appreciate some hints on how to do this. Just in case I ever feel like analysing such issues again... ;)

@jonahgraham
Copy link
Contributor

=> I would appreciate some hints on how to do this. Just in case I ever feel like analysing such issues again... ;)

@chroberino I took this opportunity to update the README, see #129 and the updated https://github.com/eclipse-cdt-cloud/cdt-gdb-vscode?tab=readme-ov-file#co-developing-cdt-gdb-adapter

Please let me know if anything isn't clear there and I'll try to answer questions and update it.

@chroberino
Copy link
Author

@jonahgraham, does the latest 2.0.0 release contain this change in cdt-gdb-adapter. It still don't get tooltips with values when hovering over varibale names.

@jonahgraham
Copy link
Contributor

Doh! Not it doesn't, the adapter is now published to npm with the fix and I have started the (new) process of getting that into the extension here: #139

@jonahgraham
Copy link
Contributor

Version 2.0.1 has been published, I think it is working:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants