1

I'm trying to view the contents on an std::map using Eclipse CDT, but all I seem to see is a(n infinite?) tree of red-and-black tree nodes.

  1. Where's the actual data?
  2. How come CDT doesn't offer some pretty-printed view of the contents of the map?
Glyphack
  • 876
  • 9
  • 20
einpoklum
  • 118,144
  • 57
  • 340
  • 684

2 Answers2

1

I'm not sure to what extent Eclipse CDT supports this by default right now, but recent versions of GDB can show you a human-friendly visualization of STL containers, including std::map. You need GCC version 7 or later and then you can say print the_map_name and it will show you something like this:

std::map with 2 elements = {[1] = 2, [2] = 4}

For more details on that, see here: https://stackoverflow.com/a/15329434/4323

And for some tips on making it work in Eclipse: How to enable gdb pretty printing for C++ STL objects in Eclipse CDT?

Community
  • 1
  • 1
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • I went there, saw the explanation, it didn't work on my system (which apparently already has some `.gdbinit` code for pretty-printing. – einpoklum Apr 28 '16 at 10:35
0

When you have a map iterator iter, just type in the Expressions dialog of Eclipse one of these:

iter->first
iter->second

When you just put iter in the watch window, this will not show the first and second... maybe a bug in Eclipse. (sorry for late reply)

Bart Mensfort
  • 995
  • 11
  • 21
  • That's not what I asked. I don't have an iterator, I have a map, and I want to see all of its data. Please remove this answer. – einpoklum May 20 '19 at 09:25