microsoft / vscode-cpptools

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

How to view nested STL container in debugger - C++ #1835

Open cv40067 opened 6 years ago

cv40067 commented 6 years ago

vscode cannot display nested STL container in the debugger.

For example,say we have typedef set A typedef list G map<int, G > D;

IN the debugger, the only data I can inspect is A. G and D both would show stuff like: std::__cxx11::_List_base<std::set<int, std::less, std::allocator >, std::allocator<std::set<int, std::less, std::allocator > > >

I have

"setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ]

enabled.

If this intended, then how do we debug a complex data structure?

Advice is appreciated.

WardenGnaw commented 6 years ago

Which OS are you using?

cv40067 commented 6 years ago

Linux Ubuntu 16.04

On Mon, Apr 16, 2018 at 12:53 PM, Andrew Wang notifications@github.com wrote:

Which OS are you using?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode-cpptools/issues/1835#issuecomment-381728203, or mute the thread https://github.com/notifications/unsubscribe-auth/AkX038ZRizLc0YqJhUVoh194obJoJlbRks5tpPa_gaJpZM4TVSX3 .

WardenGnaw commented 6 years ago

The pretty-printers are provided by gdb itself and not our extension. I would verify that the version of gdb you are running has a pretty printer for that type.

Here is a reference for the gdb command: https://sourceware.org/gdb/onlinedocs/gdb/Pretty_002dPrinter-Commands.html#Pretty_002dPrinter-Commands

There looks to be an issue with the std::list pretty printer.

cv40067 commented 6 years ago

Understood.

Will this be mitigated if I ran this on Windows? It is troublesome if we cannot inspect data within containers.

In addition, is there a way to configure custom data types to be inspected?

On Mon, Apr 16, 2018 at 3:47 PM, Andrew Wang notifications@github.com wrote:

The pretty-printers are provided by gdb itself and not our extension. I would verify that the version of gdb you are running has a pretty printer for that type.

Here is a reference for the gdb command: https://sourceware.org/gdb/onlinedocs/gdb/Pretty_ 002dPrinter-Commands.html#Pretty_002dPrinter-Commands

There looks to be an issue with the std::list pretty printer.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode-cpptools/issues/1835#issuecomment-381773854, or mute the thread https://github.com/notifications/unsubscribe-auth/AkX03-y9Aubf3gyK9mO03GAsB7Oyw8RDks5tpR9ygaJpZM4TVSX3 .

WardenGnaw commented 6 years ago

It might work if you run it on Windows. It would depend on the pretty printers for GDB.

For std::list, you can try std::vector as a work around to inspect the contents.

For custom data types to be inspected you can look at creating your own GDB pretty printer or use natvis.