0

Knowing that the elements of a vector might be printed in debug mode using the command

p *(myVector._M_impl._M_start)@myVector.size()

I'm looking for a similar command to print the element of a set (the uniqueness of the elements in a set is pretty useful in my code)

Thanks in advance

Arno
  • 331
  • 2
  • 4
  • 8
  • http://stackoverflow.com/questions/2463198/printing-stl-containers-with-gdb-7-0 – dirkgently Jun 12 '12 at 07:43
  • http://stackoverflow.com/questions/427589/inspecting-standard-container-stdmap-contents-with-gdb – dirkgently Jun 12 '12 at 07:44
  • [De-Referencing STL Containers:](http://www.yolinux.com/TUTORIALS/GDB-Commands.html#STLDEREF). Did you even Google before posting? – dirkgently Jun 12 '12 at 07:44
  • Those answers are all completely out of date. Pretty printing is enabled by default with recent versions of GCC (4.5+) and GDB (7.0+) – Jonathan Wakely Jun 12 '12 at 09:12
  • @JonathanWakely: and it plays havoc with memory issues (say dangling references) :/ – Matthieu M. Jun 12 '12 at 09:17
  • @dirkgently yes, I've google it before, but did not find anything. from the answer you gave, you can tell that there is obviously no simple solution for this apparently – Arno Jun 12 '12 at 09:18
  • Maybe I misunderstood something and did not choose a question title according to what I want to do... I'm developing on Eclipse cdt Indigo and I want an easy way to print the values in a set in debug mode. Thx – Arno Jun 12 '12 at 09:20
  • @Mattheiu, so will any other pretty printing mechanism that dereferences the address. The answer is don't create dangling references! You can use `p/r` to print "raw" i.e. without pretty printers. – Jonathan Wakely Jun 12 '12 at 09:22
  • @Arno, do you mean "in the debugger" not "in debug mode"? GDB supports printing elements from any std containers, does eclipse use gdb or its own debugger? – Jonathan Wakely Jun 12 '12 at 09:24
  • don't know the difference between the 2, running debug with a break point somewhere: i would say "in debug mode" but not sure. And I don't know about the debugger in eclipse. I thought it was gdb but not sure – Arno Jun 12 '12 at 09:27

0 Answers0