eclipse-cdt-cloud / vscode-memory-inspector

vscode memory inspector
https://open-vsx.org/extension/eclipse-cdt/memory-inspector
Eclipse Public License 2.0
6 stars 10 forks source link

Variable tracker should use 'evaluateName' when evaluating variables #120

Closed HampusAdolfsson closed 5 months ago

HampusAdolfsson commented 5 months ago

Description When the CTracker variable tracker evaluates special expressions to get the address and size of a variable, it uses the name field to construct the expressions: https://github.com/eclipse-cdt-cloud/vscode-memory-inspector/blob/2bb5658b2a50a2ead3113cfcf63a9b0fb748a70f/src/plugin/adapter-registry/c-tracker.ts#L48-L49

It would be more correct to use the evaluateName if present, and fall back to name otherwise. From the DAP specification:

/**
* The evaluatable name of this variable which can be passed to the `evaluate`
* request to fetch the variable's value.
*/
evaluateName?: string;

This lets debug adapters treat the name as more of a "display name" while providing an evaluateName to use for watch and eval operations. As an example, the IAR debug adapter appends a module name to the name; a variable called myVar defined in MyFile.c would have the name myVar <MyFile\\myVar> and evaluateName myVar.

How to reproduce: Start a session with the IAR debug extension and enable the variables column. Observe that variable sizes have not been resolved, since the sizeof expressions have not been evaluated correctly.

Any other C debug adapter which distinguishes between name and evaluateName in the same way would work too, but I don't know of any offhand.

Environment

Additional information I'd be happy to provide a pull request if you'd like!

jreineckearm commented 5 months ago

@HampusAdolfsson , thanks for raising this issue!

I think the suggested change would make a lot of sense and use this field for what it was designed for. We don't make use of evaluateName in our debug adapters (yet). Hence, didn't consider it's use so far. @colin-grant-work , would this agree with the GDB debug adapter that you use?

@HampusAdolfsson , could you please open a PR for this? Happy to test on our end and continue discussion there if need be.