STLSupport-GDB Wiki

Source: Internet
Author: User
Tags perl script

STLSupport-GDB Wiki

Gd ## page was renamed from STL Support

 

STL Support Tools

When you try to use GDB's "print" command to display the contents of a vector, a stack, or any other GDB abstract data structure, you will get useless results. instead, download and install one of following tools to properly view the contents of STL containers from within GDB.

  • GDB 7.0 will include support for writing pretty-printers in Python. this feature, combined with the pretty-printers in the libstdc ++ svn repository, yields the best way to visualize C ++ containers. some distros (Fedora 11 +) ship all this code in a way that requires no configuration; in other cases, this email message explains how to set everything up. the main points have been redacted here:

    1. Check-out the latest Python libstdc ++ printers to a place on your machine. In a local directory, do:
      • Svn co svn: // gcc.gnu.org/svn/gcc/trunk/libstdc?#-v3/python

    2. Add the following to your ~ /. Gdbinit. the path needs to match where the python module abve was checked-out. so if checked out to:/home/maude/gdb_printers/, the path wocould be as written in the example:
      • pythonimport syssys.path.insert(0, '/home/maude/gdb_printers/python')from libstdcxx.v6.printers import register_libstdcxx_printersregister_libstdcxx_printers (None)end

    The path shoshould be the only element that needs to be adjusted in the example abve. once loaded, STL classes that the printers support shoshould printed in a more human-readable format. to print the classes in the old style, use/R(Raw) switch in the print command (I. e .,Print/r foo). This will print the classes as if the Python pretty-printers were not loaded.

  • Gdb-stl-viewsIs a set of GDB macros that can display the contents of many STL containers: list, vector, map, multimap, set, multiset, dequeue, stack, queue, priority_queue, bitset, string, and widestring. writen and currently maintained by Dan Marinescu-PhD. the author formally disclaims copyright to this source code. in place of a legal notice, here is a blessing: May you do good and not edevil. may you find f Orgiveness for yourself and forgive others. May you share freely, never taking more than you give!

    • You can download it here or here

    • Tutorials and an alternative download are hosted at yolinux.com.

  • Gdb ++Is a Perl script which extends gdb. it comes bundled as part of the Devel: GDB: Reflect Perl module. first use CPAN to install the module, then follow the gdb ++ usage instructions. developed by Stanford PhD student Antal Novak.

  • There are other options. tom Malnar wrote a set of GDB macros similar to Dan's (http://thread.gmane.org/gmane.comp.gcc.g++.general/4060/focus=4167) but it doesn't cover as wide a variety of containers. gilad Mishne wrote a different set of macros (http://www.stanford.edu /~ Afn/gdb_stl_utils/) but it is long unmaintained and it works only with SGI's STL implementation, which very few GCC users use.

  • Iterators: how to display the item the iterator points at (tested on gdb 6 with a list ):Print * (iter. _ M_current)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.