Skip to content

Incorrect Memory address return by Cppvsdbg debugger for memory inspection #13589

Open
@SiamAbdullah

Description

@SiamAbdullah

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:

  1. In Windows, Create a simple hello world application with some int / float/ double variable.
  2. Create a launch.json file for debugging C/C++ application using "cppvsdbg" type.
  3. Click Run & Debug icon the side panel then click Run with your launch.json profile.
  4. After launching the debugger, hover your mouse in an variable in "VARIABLE" window.
  5. Hex editor will open and show incorrect memory address for the variable.

Image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Visual StudioInherited from Visual Studiobugdebuggerhelp wantedCan be fixed in the public (open source) repo.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions