From: Maik Beckmann <maikbeckmann@gmx.de>
To: gdb@sourceware.org
Subject: Re: how to view content in stl vector
Date: Mon, 18 Jun 2007 12:27:00 -0000 [thread overview]
Message-ID: <200706181426.36383.maikbeckmann@gmx.de> (raw)
In-Reply-To: <20070618112721.GA2559@caradoc.them.org>
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
gmane).
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
<gdb>
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
</gdb>
I tried to do this more generic:
<gdb>
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
</gdb>
which would make things like
<gdb>
dump_std_map mymap int char
</gdb>
possible. But it didn't work :(
Is storing of typenames possible at all?
i.e.
<gdb>
set $type = int // syntax error!
set $type = 'int' // syntax error!
</gdb>
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
next prev parent reply other threads:[~2007-06-18 12:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-12 15:05 kdsfinger
2007-06-15 19:52 ` Mark Kettenis
2007-06-18 8:53 ` Alpár Jüttner
2007-06-18 11:15 ` Maik Beckmann
2007-06-18 11:27 ` Daniel Jacobowitz
2007-06-18 12:27 ` Maik Beckmann [this message]
2007-06-18 12:36 ` Daniel Jacobowitz
2007-06-18 12:54 ` Maik Beckmann
2007-06-18 13:06 ` Daniel Jacobowitz
2007-06-18 14:35 ` Maik Beckmann
2007-06-18 14:44 ` Daniel Jacobowitz
2007-06-18 14:57 ` Maik Beckmann
2007-06-18 15:03 ` Maik Beckmann
2007-06-18 15:28 ` Andreas Schwab
2007-06-18 15:49 ` Maik Beckmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200706181426.36383.maikbeckmann@gmx.de \
--to=maikbeckmann@gmx.de \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox