vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Add default Natvis for GCC STL

Open yh-sb opened this issue 2 years ago • 4 comments

Feature Request

As you know, cppvsdbg has default Natvis for STL unlike cppdbg GCC. I would like to suggest adding a default visualizer for GCC STL in case when "visualizerFile" isn't set in launch.json.

Here is my Natvis file for GCC STL (I tested it with GCC 12 and 13): https://gist.github.com/yhsb2k/5c56887cd6d8f06f54846fa11c613748

yh-sb avatar May 23 '23 08:05 yh-sb

Ideally, GDB's pretty printer would handle visualizing standard library objects. Are there objects that are not being properly handled by GDB's pretty printer?

WardenGnaw avatar May 30 '23 19:05 WardenGnaw

GDB's (GCC 12, 13) pretty printer is really printing its STL objects correctly. Source code:

std::vector<int> vect = {2, 1, 3, 20};

GDB terminal:

print vect
$1 = std::vector of length 4, capacity 4 = {2, 1, 3, 20}

But vscode doesn't use this.

yh-sb avatar May 31 '23 07:05 yh-sb

@yh-sb have you added -enable-pretty-printing to your launch config's setupCommands?

david-fong avatar Oct 15 '25 05:10 david-fong

@david-fong, yes, it doesn't help. Here is what I get with -enable-pretty-printing on std::vector<int>:

Image

debug_console.log

yh-sb avatar Oct 19 '25 12:10 yh-sb