Incorrect Memory address return by Cppvsdbg debugger for memory inspection
Environment
Environment: Windows Debugger : Cppvsdbg Language: C/C++
Bug Summary and Steps to Reproduce
Bug Summary: While debugging C/C++ application using cppvsdbg, If you click the little memory icon when you hover mouse in variable (like integer type) in VARIABLES window, then VSCode will open hex code editor and show memory binary representation in the hex editor window. Cppvsdbg is sending wrong memory address in the hex editor.
Steps to reproduce:
- In Windows, Create a simple hello world application with some int / float/ double variable.
- Create a launch.json file for debugging C/C++ application using "cppvsdbg" type.
- Click Run & Debug icon the side panel then click Run with your launch.json profile.
- After launching the debugger, hover your mouse in an variable in "VARIABLE" window.
- Hex editor will open and show incorrect memory address for the variable.
Debugger Configurations
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++: cl.exe build and debug active file",
"type": "cppvsdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"logging": {
"trace": true,
"traceResponse": true,
"engineLogging": true
}
},
],
}
Debugger Logs
### Take a look value2 memoryReference value in "Scope" mode vs "presentationHint"
#################### DAP message for getting address of an integer variable (e.g: &value2) int watch window ######
-> (C) {"command":"evaluate","arguments":{"expression":"&value2","frameId":1000,"context":"watch"},"type":"request","seq":22}
-> (C) {"command":"scopes","arguments":{"frameId":1000},"type":"request","seq":23}
<- (R) {"seq":159,"type":"response","request_seq":23,"success":true,"command":"scopes","body":{"scopes":[{"name":"Locals","variablesReference":1022,"expensive":false},{"name":"Registers","presentationHint":"registers","variablesReference":1023,"expensive":true}]}}
<- (R) {"seq":161,"type":"response","request_seq":22,"success":true,"command":"evaluate","body":{"result":"0x000000a7d4bcfb50 {1065353215}","type":"int *","presentationHint":{"attributes":["readOnly"]},"variablesReference":1024,"memoryReference":"0x000000A7D4BCFB50","evaluateResponseReference":1024}}
################## variable window DAP message ########################
(C) {"command":"variables","arguments":{"variablesReference":1010},"type":"request","seq":16}
<- (R) {"seq":140,"type":"response","request_seq":16,"success":true,"command":"variables","body":{"variables":[{"name":"byteArray","value":"{ size=4 }","type":"std::vector<unsigned char,std::allocator<unsigned char>>","presentationHint":{"kind":"data","attributes":["readOnly"]},"evaluateName":"byteArray","variablesReference":1012},{"name":"cstr","value":"0x0000022cff493b00 \"˜9¸{ö\"","type":"const char *","presentationHint":{"kind":"data","attributes":["rawString"]},"evaluateName":"cstr","variablesReference":1013,"memoryReference":"0x0000022CFF493B00"},{"name":"doubleAsFloat","value":"3.61283159","type":"float","presentationHint":{"kind":"data"},"evaluateName":"doubleAsFloat","variablesReference":0},{"name":"doubleNumber","value":"3.6128315516282616","type":"double","presentationHint":{"kind":"data"},"evaluateName":"doubleNumber","variablesReference":0},{"name":"f","value":"0x000000a7d4bcfb50 {0.999999940}","type":"float *","presentationHint":{"kind":"data"},"evaluateName":"f","variablesReference":1014,"memoryReference":"0x000000A7D4BCFB50"},{"name":"f2","value":"0.999999940","type":"float","presentationHint":{"kind":"data"},"evaluateName":"f2","variablesReference":0},{"name":"floatNum","value":"0x0000022cff496760 {0.999999940}","type":"float *","presentationHint":{"kind":"data"},"evaluateName":"floatNum","variablesReference":1015,"memoryReference":"0x0000022CFF496760"},{"name":"magicNumber","value":"126","type":"int","presentationHint":{"kind":"data"},"evaluateName":"magicNumber","variablesReference":0,"memoryReference":"0x000000000000007E"},{"name":"message","value":"{ size=6 }","type":"std::vector<std::string,std::allocator<std::string>>","presentationHint":{"kind":"data","attributes":["readOnly"]},"evaluateName":"message","variablesReference":1016},{"name":"mg","value":"100","type":"int","presentationHint":{"kind":"data"},"evaluateName":"mg","variablesReference":0,"memoryReference":"0x0000000000000064"},{"name":"str","value":"\"\\x1\"","type":"std::string","presentationHint":{"kind":"data","attributes":["readOnly","rawString"]},"evaluateName":"str","variablesReference":1017},{"name":"text","value":"\"hello Meta !! nice to meet you. I am from Bangladesh and went to BUET and Starting Microsoft\"","type":"std::string","presentationHint":{"kind":"data","attributes":["readOnly","rawString"]},"evaluateName":"text","variablesReference":1018},{"name":"value2","value":"1065353215","type":"int","presentationHint":{"kind":"data"},"evaluateName":"value2","variablesReference":0,"memoryReference":"0x000000003F7FFFFF"}]}}
#################################### end #########################
Other Extensions
No response
Additional Information
No response
Thank you for reporting this issue. We’ll let you know if we need more information to investigate it. Additionally, if you're working with GDB/LLDB, please note that the code is open source at https://github.com/microsoft/MIEngine/wiki/Contributing-Code . Your contributions are always welcome and appreciated.
any update on this issue ? @sean-mcmanus
@SiamAbdullah Cppvsdbg is the VS debugger. Someone might need to file a bug at https://developercommunity.visualstudio.com/home against VS. We don't currently have any VS debugger developers working this VS Code extension and they don't monitor the debugger issues so they're probably not aware of this bug. If the bug is particular to VS Code, it might not be fixed.