]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix pretty printer lookup for class templates [PR122812]
authorVladimir Bespalov <vlad.bespalov@jetstreamsoft.com>
Sun, 23 Nov 2025 03:58:08 +0000 (19:58 -0800)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 3 Dec 2025 18:02:04 +0000 (18:02 +0000)
Under some circumstances the type.name of a pair<> type starts with
"struct". This confuses GDB when we use gdb.lookup_type for the name of
template specialization using "struct pair<...>" in its template
argument list.

Using type.tag avoids this problem.

libstdc++-v3/ChangeLog:

PR libstdc++/122812
* python/libstdcxx/v6/printers.py (lookup_templ_spec): Use
gdb.Type.tag if present.

libstdc++-v3/python/libstdcxx/v6/printers.py

index f7f0489abf9afec9c6bd704c02de48041b1c8198..abb072f8a2ba448c739341c22ac9183c1779167f 100644 (file)
@@ -133,7 +133,11 @@ def lookup_templ_spec(templ, *args):
     """
     Lookup template specialization templ<args...>.
     """
-    t = '{}<{}>'.format(templ, ', '.join([str(a) for a in args]))
+    # Similar to PR67440, str(a) might contain unexpected type qualifiers.
+    t = '{}<{}>'.format(templ, ', '.join([ \
+            a.tag if isinstance(a, gdb.Type) and a.tag \
+            else str(a) \
+        for a in args]))
     try:
         return gdb.lookup_type(t)
     except gdb.error as e: