Boost logo

Boost Users :

From: Jeffrey Chang (jeffrey8chang_at_[hidden])
Date: 2007-05-01 13:02:14


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:

class MyClass {
    ....
    //define a multi_index_container with a list-like index and an ordered
index
    struct SEQ {}; // Sequence
    struct TID {}; // TypeID
    typedef boost::multi_index::multi_index_container<
        HtvValueBasePtr, // element type
        boost::multi_index::indexed_by<
            boost::multi_index::sequenced< // list-like index
                boost::multi_index::tag<SEQ>
>, // sequenced<>
            boost::multi_index::ordered_unique< // map-lik index
                boost::multi_index::tag<TID>,
                boost::multi_index::const_mem_fun< // key extractor
                    HtvValueBase, // class name
                    const HtvTypeBase::TypeID, // return type
                    &HtvValueBase::getTypeId // const mem fun name
> // const_mem_fun<>
> // ordered_unique<>
> // indexed_by<>
> TLVListMapType;
    typedef TLVListMapType::index<SEQ>::type TLV_by_SEQ;
    typedef TLVListMapType::index<TID>::type TLV_by_TID;

    TLVListMapType mTLVs; //< indexed on both physical layout & TypeID.
    ....
}; // class MyClass

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 '//' comment
after closing-bracket '{' s.t. it's easier for the eyes):

(gdb) p pMyClassObj->mTLVs
$5 =
{

<boost::base_from_member<std::allocator<boost::multi_index::detail::sequenced_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::shared_ptr<hipeer::HtvValueBase>
> > > >,0>> =
    {
        member =
        {

<__gnu_cxx::new_allocator<boost::multi_index::detail::sequenced_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::shared_ptr<hipeer::HtvValueBase>
> > > >> =
            {
                <No data fields>
            },
            <No data fields>
        }
    },

<boost::multi_index::detail::header_holder<boost::multi_index::detail::sequenced_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::shared_ptr<hipeer::HtvValueBase>
> >
>,boost::multi_index::multi_index_container<boost::shared_ptr<hipeer::HtvValueBase>,
boost::multi_index::indexed_by<boost::multi_index::sequenced<boost::multi_index::tag<hipeer::HipPacket::SEQ,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >,
boost::multi_index::ordered_unique<boost::multi_index::tag<hipeer::HipPacket::TID,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>,
boost::multi_index::const_mem_fun<hipeer::HtvValueBase, const
hipeer::HtvTypeBase::TypeID, &hipeer::HtvValueBase::getTypeId>, mpl_::na>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na>,
std::allocator<boost::shared_ptr<hipeer::HtvValueBase> > > >> =
    {

<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<boost::shared_ptr<hipeer::HtvValueBase>
> > >*,0>> =
        {
            member = 0x85cf7a8
        },
        <boost::noncopyable_::noncopyable> =
        {
            <No data fields>
        },
        <No data fields>
    }, // header_holder

<boost::multi_index::detail::sequenced_index<boost::multi_index::detail::nth_layer<1,
boost::shared_ptr<hipeer::HtvValueBase>,
boost::multi_index::indexed_by<boost::multi_index::sequenced<boost::multi_index::tag<hipeer::HipPacket::SEQ,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >,
boost::multi_index::ordered_unique<boost::multi_index::tag<hipeer::HipPacket::TID,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>,
boost::multi_index::const_mem_fun<hipeer::HtvValueBase, const
hipeer::HtvTypeBase::TypeID, &hipeer::HtvValueBase::getTypeId>, mpl_::na>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na>,
std::allocator<boost::shared_ptr<hipeer::HtvValueBase> >
>,boost::mpl::v_item<hipeer::HipPacket::SEQ, boost::mpl::vector0<mpl_::na>,
0> >> =
    {

<boost::multi_index::detail::ordered_index<boost::multi_index::const_mem_fun<hipeer::HtvValueBase,
const hipeer::HtvTypeBase::TypeID,
&hipeer::HtvValueBase::getTypeId>,std::less<const
hipeer::HtvTypeBase::TypeID>,boost::multi_index::detail::nth_layer<2,
boost::shared_ptr<hipeer::HtvValueBase>,
boost::multi_index::indexed_by<boost::multi_index::sequenced<boost::multi_index::tag<hipeer::HipPacket::SEQ,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >,
boost::multi_index::ordered_unique<boost::multi_index::tag<hipeer::HipPacket::TID,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>,
boost::multi_index::const_mem_fun<hipeer::HtvValueBase, const
hipeer::HtvTypeBase::TypeID, &hipeer::HtvValueBase::getTypeId>, mpl_::na>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na>,
std::allocator<boost::shared_ptr<hipeer::HtvValueBase> >
>,boost::mpl::v_item<hipeer::HipPacket::TID, boost::mpl::vector0<mpl_::na>,
0>,boost::multi_index::detail::ordered_unique_tag>> =
        {

<boost::multi_index::detail::index_base<boost::shared_ptr<hipeer::HtvValueBase>,boost::multi_index::indexed_by<boost::multi_index::sequenced<boost::multi_index::tag<hipeer::HipPacket::SEQ,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >,
boost::multi_index::ordered_unique<boost::multi_index::tag<hipeer::HipPacket::TID,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>,
boost::multi_index::const_mem_fun<hipeer::HtvValueBase, const
hipeer::HtvTypeBase::TypeID, &hipeer::HtvValueBase::getTypeId>, mpl_::na>,
mpl_---Type <return> to continue, or q <return> to quit---
    ::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na,
mpl_::na>,std::allocator<boost::shared_ptr<hipeer::HtvValueBase> > >> =
            {
                <No data fields>
            }, // index_base

<boost::multi_index::detail::safe_container<boost::multi_index::detail::ordered_index<boost::multi_index::const_mem_fun<hipeer::HtvValueBase,
const hipeer::HtvTypeBase::TypeID, &hipeer::HtvValueBase::getTypeId>,
std::less<const hipeer::HtvTypeBase::TypeID>,
boost::multi_index::detail::nth_layer<2,
boost::shared_ptr<hipeer::HtvValueBase>,
boost::multi_index::indexed_by<boost::multi_index::sequenced<boost::multi_index::tag<hipeer::HipPacket::SEQ,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >,
boost::multi_index::ordered_unique<boost::multi_index::tag<hipeer::HipPacket::TID,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>,
boost::multi_index::const_mem_fun<hipeer::HtvValueBase, const
hipeer::HtvTypeBase::TypeID, &hipeer::HtvValueBase::getTypeId>, mpl_::na>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na>,
std::allocator<boost::shared_ptr<hipeer::HtvValueBase> > >,
boost::mpl::v_item<hipeer::HipPacket::TID, boost::mpl::vector0<mpl_::na>,
0>, boost::multi_index::detail::ordered_unique_tag> >> =
            {
                <boost::multi_index::detail::safe_container_base> =
                {
                    <boost::noncopyable_::noncopyable> =
                    {
                        <No data fields>
                    },
                    header =
                    {
                        cont = 0x0,
                        next = 0x0,
                        unchecked_ = false
                    },
                    mutex =
                    {
                        m_ =
                        {
                            __m_reserved = 0,
                            __m_count = 0,
                            __m_owner = 0x0,
                            __m_kind = 0,
                            __m_lock =
                            {
                                __status = 0,
                                __spinlock = 0
                            }
                        }
                    }
                },
                <No data fields>
            }, // safe_container (for ordered_index?)
            key =
            {
                <No data fields>
            },
            comp =
            {
                <> =
                {
                    <No data fields>
                },
                <No data fields>
            }
        }, // ordered_index

<boost::multi_index::detail::safe_container<boost::multi_index::detail::sequenced_index<boost::multi_index::detail::nth_layer<1,
boost::shared_ptr<hipeer::HtvValueBase>,
boost::multi_index::indexed_by<boost::multi_index::sequenced<boost::multi_index::tag<hipeer::HipPacket::SEQ,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >,
boost::multi_index::ordered_unique<boost::multi_index::tag<hipeer::HipPacket::TID,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>,
boost::multi_index::const_mem_fun<hipeer::HtvValueBase, const
hipeer::HtvTypeBase::TypeID, &hipeer::HtvValueBase::getTypeId>, mpl_::na>,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na>,
std::allocator<boost::shared_ptr<hipeer::HtvValueBase> > >,
boost::mpl::v_item<hipeer::HipPacket::SEQ, boost::mpl::vector0<mpl_::na>, 0>
> >> =
        {
            <boost::multi_index::detail::safe_container_base> =
            {
                <boost::noncopyable_::noncopyable> =
                {
                    <No data fields>
                },
                header =
                {
                    cont = 0x0,
                    next = 0x0,
                    unchecked_ = false
                },
                mutex =
                {
                    m_ =
                    {
                        __m_reserved = 0,
                        __m_count = 0,
                        __m_owner = 0x0,
                        __m_kind = 0,
                        __m_lock =
                        {
                            __status = 0,
                            __spinlock = 0
                        }
                    }
                }
            },
            <No data fields>
        }, // safe_container (for sequenced_index?)
        <No data fields>
    }, // sequenced_index

    node_count = 3

} // $5...

(gdb) p pMyClassObj->mTLVs.header
$12 = {cont = 0x0, next = 0x0, unchecked_ = false}
(gdb) p pMyClassObj->mTLVs.member
$13 =
{<__gnu_cxx::new_allocator<boost::multi_index::detail::sequenced_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::shared_ptr<hipeer::HtvValueBase>
> > > >> = {<No data fields>}, <No data fields>}
(gdb) p rqInbPkt.px->mTLVs.node_count
$14 = 3

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 fields
inside 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?

Thanks,

--- Jeffrey



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