watch std::unordered_map

Sysprogs forums Forums VisualGDB watch std::unordered_map

Viewing 15 posts - 1 through 15 (of 26 total)
  • Author
    Posts
  • #30401
    elikfir
    Participant

    Hi,

    I tried to watch std::unordered_map on visualGDB and I can see only hashtable members without any pretty printing for that.

    do you have any quick solution? (any natvis file that I can use to fix that?)

    code:

    #include <iostream>
    #include <string>
    #include <unordered_map>

    int main(int argc, char *argv[])
    {
    std::unordered_map<int32_t, std::string> tmp;
    tmp[0] = “str0”;
    tmp[1] = “str1”;

    return 0;
    }

    thanks

     

    #30402
    support
    Keymaster

    Hi,

    Sorry, we don’t have a ready-to-use visualizer of unordered_map yet. It is on the roadmap, however it’s hard to give any time estimates now. As a workaround, please consider creating one manually as shown in this tutorial.

    #30405
    elikfir
    Participant

    thanks.

    Once you have any solution for that It will be great to get it even a temporary/walkaround solution (like a working visualizer that just need to plug and play)

    #31195
    elikfir
    Participant

    Hi,

    any updates with  ready-to-use visualizer of unordered_map/set?

    thanks

    #31196
    support
    Keymaster

    Hi,

    We generally prioritize feature requests based on the number of affected users. As this is a very specific request affecting a very small number of users, and can be achieved by implementing a custom visualizer, it has a very low priority and will likely not be added anytime soon.

    If your company holds multiple VisualGDB licenses, please let us know the email associated with your key, and we will assign a higher priority to this.

    #31533
    elikfir
    Participant

    hi,

    first of all it’s not a weird question, it’s a STD container that VisualGDB cannot show. I don’t know about other users, but I guess I’m not the only one who need that, I just the first one to report about that.

    second, I don’t know how to read the this container and how to write a custom visualizer for it. if it simple you’re welcome to share it, if it’s not so simple it doesn’t make any sense to ask users to do it.

    About the company I worked on, I don’t know which one uses VisualGDB, and even I knew it’s not something I can share here.

    I guess I will need to wait for Visual-Studio 2022 or other extension which will help me to build/debug a custom Linux/WSL2 and get rid of VisualGDB.

    #31534
    support
    Keymaster

    Please note that VisualGDB focuses on improving the typical development scenarios that would otherwise take a lot of our customers’ time. E.g. we provide a powerful Clang-based IntellISense engine that allows exploring large code bases, more reliable debugger integration, convenient GUI for configuring common settings, deep integration with Valgrind, CMake and numerous other tools, etc. You can find more about VisualGDB features for Linux here.

    If none of these features made VisualGDB worthwhile for you in 6 months, adding support for visualizing a very specific container will not make much of a difference. So instead, we have to focus on features that would make a difference in the context of common tasks (e.g. the newly added Code Explorer is a huge help when dealing with large projects).

    #31744
    elikfir
    Participant

    I just found a way to get it print correctly when using VS2022 (by using libstdcxx pretty printing). it works fine when using native VS2022 Linux debugger.

    It doesn’t work on VisualGDB, I can see the values on GDB Session window but not on the Watch.

    Is there any way to enable it on the watch as it’s done on native Linux debugger on VS2022?

    #31745
    support
    Keymaster

    Hi,

    No problem, you can use the GDB session window to send commands directly to GDB, including the ones to evaluate variables via libstdcxx.

    #31749
    elikfir
    Participant

    Hi,

    yes, that’s what I did (or a better way to put it on additional gdb commands part).

    But I want to see it on the watch window. I don’t want to go back to use command line GDB, that’s why I purchased VisualGDB

    #31750
    support
    Keymaster

    We are sorry, as we have explained before, we do not have any plans for supporting it in the watch window and will not be able to change it.

    As a workaround, please use the GDB session window. All other functionality provided by VisualGDB will work as expected.

    #31751
    elikfir
    Participant

    but here my question is different – the data is already there when using pretty-printer, is there any simple step that I can do to see it on the watch? (VS2022 native Linux debugger has it)

    #31752
    support
    Keymaster

    If GDB recognizes and reports the data via the MI interface, both Visual Studio and VisualGDB will show it out-of-the-box. If the data appears when using the regular VS debugger, but not with VisualGDB, most likely you are using different GDB settings.

    If you could capture a GDB log from both VisualGDB and the regular VS debugger, and let us know the variable name in question, we can help you configure VisualGDB to show it the same way the VS debugger does.

    #31753
    elikfir
    Participant

    here is the summary:
    the code is:

    #include <iostream>
    #include <unordered_map>

    int main()
    {
    std::unordered_map<int32_t, float> m;
    m[5] = 5.1f;
    int c = getchar();
    return 0;
    }

    Visual Studio debugging without any change to the configuration – works fine and I can see the data on the watch.

    Visual Studio debugging with adding verbose log to the launch.vs.json – same behavior as Visual GDB – I can see the data on the GDB command line only but not in the watch.

    VisualGDB – as mentioned – I can see the data on command line after manually loading pretty-printing for libgcc but not on the watch.

     

    this is the way I added verbose to the configuration:

    “setupCommands”: [
    {
    “description”: “verbose”,
    “text”: “set verbose on”,
    “ignoreFailures”: true
    }
    ]

     

    Attachments:
    You must be logged in to view attached files.
    #31758
    support
    Keymaster

    Hi,

    No problem, if the verbose mode is interfering with the unordered_map visualization, you can turn it off via VisualGDB Project Properties -> Advanced GDB Settings -> Request verbose output from GDB.

    If it doesn’t help, please make sure the native VS log does include the used GDB command line and the full output from gdb (including commands like -var-create –frame 0 –thread 1 – * “m”). Any differences in the watch window contents come from different output from -var-list-children and the only way to troubleshoot them is to understand what is causing this difference.

Viewing 15 posts - 1 through 15 (of 26 total)
  • You must be logged in to reply to this topic.