|
Boost Users : |
From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2007-05-01 14:26:58
Hi Jeffrey
----- Mensaje original -----
De: Jeffrey Chang <jeffrey8chang_at_[hidden]>
Fecha: Martes, Mayo 1, 2007 7:03 pm
Asunto: [Boost-users] [boost-users] [multi_index] print object data
member in gdb
Para: boost-users_at_[hidden]
CC: jeffrey8chang_at_[hidden]
> Hi,
>
> I've been compiling & using multi_index without problem for a
> while; but when I use gdb to print multi_index_container objects,
> I couldn't find a way to easily traverse through its internal
> data structure.
>
> Here' s my multi_index_container object declaration:
[...]
> The program is running fine without problem; and I wanna use gdb
> to check its runtime status by printing out the object. Here's
> the gdb output when I print the object (I've manully indexed the
> gdb output & add '//' commentafter closing-bracket '{' s.t. it's
> easier for the eyes):
>
>
> (gdb) p pMyClassObj->mTLVs
> $5 =
[...]
> According to the 'node_count', there're 3 objects stored in the
> multi_index_container of '*pMyClassObj'. But I couldn't find a
> way to traverse all 3 objects in gdb: I see there're two
> 'member' data fieldsinside MyClass container, the first one
> doesn't contain any data, while the second one (at address
> 0x85cf7a8 inside the header_holder class???) seems to be the
> right place to start traversing... but I don't know if there's
> any convenient way to traverse it at the symbolic level via
> container's data members. Any hint?
As you correctly guess, the member at header_holder_class is
where you have to look at in order to reach for the elements.
This member is of type (in your particular case)
boost::base_from_member<
boost::multi_index::detail::sequenced_index_node<
boost::multi_index::detail::ordered_index_node<
boost::multi_index::detail::index_node_base<
HtvValueBasePtr
>
>
>*,
0
>
The base_from_member base class in turn contains a member of
type pointer to
boost::multi_index::detail::sequenced_index_node<
boost::multi_index::detail::ordered_index_node<
boost::multi_index::detail::index_node_base<
HtvValueBasePtr
>
>
>
which is a pointer to the "header" of the container, from
where you can jump to the elements. This class contains
the element values proper (inside index_node_base<...>) as
well as linking stuff for each of the indices the multi-index
container is comprised of. sequenced_index_node<...>
multiply inherits from ordered_index_node<...> and
from a class sequenced_index_node_trampoline<...>,
which in turn inherits from sequenced_index_node_impl,
which has members called prior_ and next_. Since the
header is conceptually the end node of the container, just
follow the prior_ pointers to traverse all the elements.
You could also do the traversal following the pointers
in ordered_index_node<...>, but this is a little more
complicated since the data structure implemented by this is
an rb tree.
Hope this helps,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net