This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] libstdc++:: improve how pretty printers find node types (PR 91997)


This fixes two related problems.

The iterators for node-based containers use nested typedefs such as
std::list<T>::iterator::_Node to denote their node types. As reported in
https://bugzilla.redhat.com/show_bug.cgi?id=1053438 those typedefs are
not always present in the debug info. That means the pretty printers
cannot find them using gdb.lookup_type (via the find_type helper).
Instead of looking up the nested typedefs this patch makes the printers
look up the actual class templates directly.

A related problem (and the original topic of PR 91997) is that GDB fails
to find types via gdb.lookup_type when printing a backtrace from a
non-C++ functiion: https://sourceware.org/bugzilla/show_bug.cgi?id=25234
That is also solved by not looking up the nested typedef.

	PR libstdc++/91997
	* python/libstdcxx/v6/printers.py (find_type): Fail more gracefully
	if we run out of base classes to look at.
	(llokup_templ_spec, lookup_node_type): New utilities to find node
	types for node-based containers.
	(StdListPrinter.children, NodeIteratorPrinter.__init__)
	(NodeIteratorPrinter.to_string, StdSlistPrinter.children)
	(StdSlistIteratorPrinter.to_string, StdRbtreeIteratorPrinter.__init__)
	(StdMapPrinter.children, StdSetPrinter.children)
	(StdForwardListPrinter.children): Use lookup_node_type instead of
	find_type.
	(StdListIteratorPrinter.__init__, StdFwdListIteratorPrinter.__init__):
	Pass name of node type to NodeIteratorPrinter constructor.
	(Tr1HashtableIterator.__init__): Rename argument.
	(StdHashtableIterator.__init__): Likewise. Use lookup_templ_spec
	instead of find_type.
	* testsuite/libstdc++-prettyprinters/59161.cc: Remove workaround for
	_Node typedef not being present in debuginfo.
	* testsuite/libstdc++-prettyprinters/91997.cc: New test.

Tested powerpc64le-linux, committed to trunk.

I plan to backport this to the release branches too.

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]