Skip to content

Debug visualizers: std::any natvis extensions #929

@JVApen

Description

@JVApen

Describe the bug
The visualizer for std::any ain't that useful. Except knowing how something is stored into it, and the type info for the stored class, it is almost impossible to inspect what's into it.

I've already managed to extend the natvis with the following

<Item Name="[castable_ptr]" Condition="_Is_trivial()">(void*)(&amp;_Storage._TrivialData)</Item>
          <Item Name="[castable_ptr]" Condition="_Is_small()">(void*)(&amp;_Storage._SmallStorage._Data)</Item>
          <Item Name="[castable_ptr]" Condition="_Is_big()">(void*)(_Storage._BigStorage._Ptr)</Item>

This improved the usability a lot and has a lot of sense to add to the upstream project. Ideally, one would cast this to the actual type, however, I'm not sure that's even possible.

All details can be found in my stackoverflow post, see https://stackoverflow.com/questions/59285956/using-stdtype-info-for-casting-in-natvis

Command-line test case

C:\Temp>type repro.cpp
#include <any>

int main() {
    std::any a = 0;
}

C:\Temp>cl /EHsc /W4 /WX .\repro.cpp

Expected behavior
Be able to inspect the content of std::any in an easy way

STL version
Microsoft Visual Studio 2019, exact version not relevant

Additional context
https://stackoverflow.com/questions/59285956/using-stdtype-info-for-casting-in-natvis

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedSomething works now, yay!visualizerHow the VS debugger displays STL types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions