This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to view content in stl vector

Am Montag, 18. Juni 2007 13:27:21 schrieb Daniel Jacobowitz:
> > define dump_vector_simple
> FYI: I'm planning for a future version of GDB to be able to do this
> automatically in the "print" command.  No promises on when it will be
> ready, though.  Might be another two years.

Hello Daniel,

First of all, I'm new to gdb (don't ask me why I didn't used a debugger until 
last weok, there is no rational reason).

Native c++/stl support for gdb would be nice. Until then using user defined
gdb-functions is a good workarround.
Regarding user defined functions, doing this for std::vector is easy. 
It took only one day to write the scripts I posted (enforced by google and 
But there are others like std::map where one has to cast to get the content of 
a node

i.e. for std::map<int, char> you have to do
set $h = $map_instance_name._M_t._M_impl._M_header
p (('std::_Rb_tree_node<std::pair<const int, char> >' *) $h)->_M_value_field 

I tried to do this more generic:

set $h = $map_instance_name._M_t._M_impl._M_header

set $key_type = 'int'
set $mapped_type = 'char'
set $node_type = 'std::_Rb_tree_node<std::pair<const $key_type, $mapped_type> 

p (( $node_type *) $h)->_M_value_field 

which would make things like

dump_std_map mymap int char

possible. But it didn't work :(

Is storing of typenames possible at all?
set $type = int // syntax error!
set $type = 'int' // syntax error!

A workaround for this would be a native c++ map-dump function, which naturally 
would be implemented as function template, but I didn't find out how to call 
an instantiated function template  :(

It would be nice if you could give me a hint towards function templates and 
the typename storing issue.

MfG, Maik Beckmann

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]