Samsung / netcoredbg

NetCoreDbg is a managed code debugger with GDB/MI, VSCode DAP and CLI interfaces for CoreCLR.
MIT License
836 stars 103 forks source link

Unable to list variables #177

Closed EvgeniiPotanin closed 1 month ago

EvgeniiPotanin commented 1 month ago

Version: NET Core debugger 3.1.1-1 (227be44, Release)

OS: Linux 12cf9bba1619 6.1.0-22-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.94-1 (2024-06-21) x86_64 GNU/Linux

After analyzing documentation and source codes, I found no possibility to list local (and/or global) variables when debugee is stopped at breakpoint. Is there any way to achieve the above ? Or maybe itwas made intentionally and there's some reason about it?

viewizard commented 1 month ago

info locals and info args commands not implemented for now in CLI protocol. For now, implemented only variables in VSCode protocol and stack-list-variables in MI/GDB protocol.

Is there any way to achieve the above ? Or maybe itwas made intentionally and there's some reason about it?

You can use stack-list-variables code from MI/GDB protocol as a prototype and make your own info locals and/or info args implementation for CLI protocol. Not sure about "global" variables (info variables) for C#, this sound like all classes for all loaded assemblies should be parsed and all static members printed, we don't have such code in debugger for sure.

EvgeniiPotanin commented 1 month ago

Thanks for quick answer, just for the record, I managed to get locals. Using MI interpreter:

-stack-list-variables

^done,variables=[{name="myNum",value="5"},{name="myDoubleNum",value="5.99"},{name="myLetter",value="68 'D'"},{name="myBool",value="true"},{name="myText",value="\"Hello\""}]

And using VSCODE interpreter:

Content-Length: 87

{"seq":123,"type":"request","command":"variables","arguments":{"variablesReference":1}}

{"body":{"variables":[
    {"evaluateName":"myNum","name":"myNum","type":"int","value":"5","variablesReference":0},
    {"evaluateName":"myDoubleNum","name":"myDoubleNum","type":"double","value":"5.99","variablesReference":0},
    {"evaluateName":"myLetter","name":"myLetter","type":"char","value":"68 'D'","variablesReference":0},
    {"evaluateName":"myBool","name":"myBool","type":"bool","value":"true","variablesReference":0},
    {"evaluateName":"myText","name":"myText","type":"string","value":"\"Hello\"","variablesReference":0}
    ]},"command":"variables","request_seq":123,"seq":"118","success":true,"type":"response"}