microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

Natvis format specifier `,s` doesn't work #7750

Open yh-sb opened 3 years ago

yh-sb commented 3 years ago

Issue Type: Bug

Format specifier ,s doesn't work.

How to reproduce

  1. Compile and debug the following code: (Mingw gcc 11 is used)
    
    #include <string>

int main() { std::string string("test");

return 0;

}


2. Use the following natvis entity:
```xml
    <Type Name="std::string">
        <AlternativeType Name="std::__cxx11::basic_string&lt;*&gt;"/>
        <DisplayString>{_M_dataplus._M_p,s}</DisplayString>
        <Expand>
            <Item Name="size">_M_string_length</Item>
            <Item Name="capacity" Condition="_M_dataplus._M_p == _M_local_buf">sizeof(_M_local_buf)</Item>
            <Item Name="capacity" Condition="_M_dataplus._M_p != _M_local_buf">_M_allocated_capacity</Item>
            <Item Name="string">_M_dataplus._M_p,s</Item>
        </Expand>
    </Type>
  1. See that ,s format specifier in <DisplayString> and <Item Name="string"> doesn't change anything in debug view, hover and showDisplayString.

Actual result: image

Expected result: string = "test" (without leading address)

Extension version: 1.5.0-insiders2 VS Code version: Code 1.57.1 (507ce72a4466fbb27b715c3722558bb15afa9f48, 2021-06-17T13:28:07.755Z) OS version: Windows_NT x64 10.0.17763 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz (8 x 1992)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.85GB (8.96GB free)| |Process Argv|--locale=en --crash-reporter-id c8510ba5-736a-4465-9c29-9471122a68c5| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383:30185418 pythonvspyt602:30300191 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythonvspyt639:30300192 pythontb:30283811 pythonvspyt551cf:30311713 vspre833:30321513 pythonptprofiler:30281270 vshan820:30294714 pythondataviewer:30285071 vscus158:30321503 pythonvsuse255cf:30323309 vscorehov:30309549 vscod805cf:30301675 pythonvspyt200:30324779 binariesv615:30325510 ```
sean-mcmanus commented 3 years ago

@WardenGnaw Any comment on this?

yh-sb commented 2 years ago

Still reproducible on v1.8.3.

WardenGnaw commented 2 years ago

Must be an issue in https://github.com/microsoft/MIEngine/blob/main/src/MIDebugEngine/Natvis.Impl/Natvis.cs

yh-sb commented 1 year ago

Issues is still present in vscode 1.76.0 with cpptools v1.14.1.