g++, gdb: debugging with STL containers

Hello,

I'm in the process of writing a C++ application using gcc, gdb, the STL and the netbeans IDE on Linux. If I watch the value of a template variable, I get something like this:
{_M_t = {_M_impl = {<std::allocator<std::_Rb_tree_node<std::pair<const int, int> > >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<const int, int> > >> = {<No data fields>}, <No data fields>}, _M_key_compare = {<> = {<No data fields>}, <No data fields>}, _M_header = {_M_color = std::_S_red, _M_parent = 0x8132870, _M_left = 0x8112870, _M_right = 0x8128740}, _M_node_count = 3}}}

This isn't very useful: in Visual Studio on windows, I can see the value of the containers members (even nested templates, I believe), which is very useful.

Is something similar possible with gdb?
Regards,
Sternocera
sternoceraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

evilrixSenior Software Engineer (Avast)Commented:
>> I can see the value of the containers members (even nested templates, I believe), which is very useful.
Isn't that what gdb is showing you though? Obviously, natively gdb is a text based debugger so it's presentation isn't going to be as nice as Visual Studio. Have you tried using ddd, which is a GUI wrapper for gdb?
http://www.gnu.org/software/ddd/

0
sternoceraAuthor Commented:
I'm using netbeans, which provides a graphical frontend to gdb in much the same manner as ddd - I actually have used ddd in the past. I realise that gdb is showing me the literal value of the template, which is memory addresses and such. however, it would be useful if I could see those values automagically, as I can in visual studio.

This would have to be a specific feature of gdb or its extensions, which doesn't seem to be provided by ddd or any other tool I'm aware of,
Regards,
Sternocera
0
evilrixSenior Software Engineer (Avast)Commented:
>> This would have to be a specific feature of gdb or its extensions, which doesn't seem to be provided by ddd or any other tool I'm aware of,
Try looking at this: http://staff.science.uva.nl/~gilad/stl/stl_gdb.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jkrCommented:
See also the script at http://help.lockergnome.com/linux/GDB-capabilities-exploring-STL-classes-ftopict279673.html
##########################################
# #
# STL GDB evaluators/views/utilities #
# #
##########################################
#
# The new GDB commands:
# are entirely non instrumental
# do not depend on any "inline"(s) - e.g. size(), [], etc
# are extremely tolerant to debugger settings
#
# This file should be "included" in .gdbinit as following:
# source stl-views.gdb or just paste it into your .gdbinit file
#
# The following STL containers are currently supported:
#
# std::vector<T> -- via pvector command
# std::list<T> -- via plist command
# std::map<T,T> -- via pmap command
# std::multimap<T,T> -- via pmap command
# std::set<T> -- via pset command
# std::multiset<T> -- via pset command
# std::deque<T> -- via pdequeue command
# std::stack<T> -- via pstack command
# std::queue<T> -- via pqueue command
# std::priority_queue<T> -- via ppqueue command
# std::bitset<n> -- via pbitset command
# std::string -- via pstring command
# std::widestring -- via pwstring command
#
# The end of this file contains (optional) C++ beautifiers
#
##########################################################################
# #
# CopyRight @ 2008 - Dan C Marinescu - All Rights Reserved under GPL V3. #
# #
# Email: dan_c_marinescu DeleteThis @yahoo.com #
# #
##########################################################################
 
// full script in the above link

Open in new window

0
SeanDurkinCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup Zone:
      Split: evilrix {http:#20873919} & jkr {http:#20875675}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Sean
EE Cleanup Volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.