[PATCH] Fix gdb FilteringTypePrinter (again)

François Dumont frs.dumont@gmail.com
Thu Oct 6 17:38:09 GMT 2022


Hi

Looks like the previous patch was not enough. When using it in the 
context of a build without dual abi and versioned namespace I started 
having failures again. I guess I hadn't rebuild everything properly.

This time I think the problem was in those lines:

             if self.type_obj == type_obj:
                 return strip_inline_namespaces(self.name)

I've added a call to gdb.types.get_basic_type so that we do not compare 
a type with its typedef.

Thanks for the pointer to the doc !

Doing so I eventually use your code Jonathan to make FilteringTypeFilter 
more specific to a given instantiation.

     libstdc++: Fix gdb FilteringTypePrinter

     Once we found a matching FilteringTypePrinter instance we look for 
the associated
     typedef and check that the returned Python Type is equal to the 
Type to recognize.
     But gdb Python Type includes properties to distinguish a typedef 
from the actual
     type. So use gdb.types.get_basic_type to check if we are indeed on 
the same type.

     Additionnaly enhance FilteringTypePrinter matching mecanism by 
introducing targ1 that,
     if not None, will be used as the 1st template parameter.

     libstdc++-v3/ChangeLog:

             * python/libstdcxx/v6/printers.py (FilteringTypePrinter): 
Rename 'match' field
             'template'. Add self.targ1 to specify the first template 
parameter of the instantiation
             to match.
             (add_one_type_printer): Add targ1 optional parameter, 
default to None.
             Use gdb.types.get_basic_type to compare the type to 
recognize and the type
             returned from the typedef lookup.
             (register_type_printers): Adapt calls to add_one_type_printers.

Tested under Linux x86_64 normal, version namespace with or without dual 
abi.

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdb_printers.patch
Type: text/x-patch
Size: 8406 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20221006/490f837e/attachment.bin>


More information about the Libstdc++ mailing list