diff options
| author | Jonathan Wakely <jwakely@redhat.com> | 2026-02-04 22:57:34 +0000 |
|---|---|---|
| committer | Jonathan Wakely <redi@gcc.gnu.org> | 2026-02-05 11:52:36 +0000 |
| commit | 2e4e58bb43c5769827cd7c6dde46dd1060740e55 (patch) | |
| tree | 5b63c35ec0f10fa69fa6270161fbfff902bcb998 /libstdc++-v3/python | |
| parent | 1be41ad752945b0ed5c26aa134a30c145a29afd0 (diff) | |
| download | gcc-2e4e58bb43c5769827cd7c6dde46dd1060740e55.tar.gz gcc-2e4e58bb43c5769827cd7c6dde46dd1060740e55.tar.bz2 gcc-2e4e58bb43c5769827cd7c6dde46dd1060740e55.zip | |
libstdc++: Fix std::shared_ptr pretty printer for GDB 11
This pretty printer was updated for GCC 16 to match a change to
std::atomic<shared_ptr<T>>. But the gdb.Type.is_scalar property was
added in GDB 12.1, so we get an error for older GDB versions.
This adds a workaround for older GDB versions. The gdb.Type.tag property
is None for scalar types, and should always be defined for the
std::atomic class template. Another option would be to use the
is_specialization_of function defined in printers.py, but just checking
for the tag is simpler.
libstdc++-v3/ChangeLog:
* python/libstdcxx/v6/printers.py (SharedPointerPrinter): Only
use gdb.Type.is_scalar if supported.
* testsuite/libstdc++-prettyprinters/compat.cc: Test printer for
old implementation of std::atomic<std::shared_ptr<T>>.
Reviewed-by: Tomasz KamiĆski <tkaminsk@redhat.com>
Diffstat (limited to 'libstdc++-v3/python')
| -rw-r--r-- | libstdc++-v3/python/libstdcxx/v6/printers.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 8bb7dd2ad60..be7e7a25606 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -292,9 +292,15 @@ class SharedPointerPrinter(printer_base): if self._typename == 'std::atomic': # A tagged pointer is stored as uintptr_t. val = self._val['_M_refcount']['_M_val'] - if val.type.is_scalar: # GCC 16 stores uintptr_t + # GCC 16 stores it directly as uintptr_t + # GCC 12-15 stores std::atomic<uintptr_t> + if hasattr(val.type, 'is_scalar'): # Added in GDB 12.1 + val_is_uintptr = val.type.is_scalar + else: + val_is_uintptr = val.type.tag is None + if val_is_uintptr: ptr_val = val - else: # GCC 12-15 stores std::atomic<uintptr_t> + else: ptr_val = val['_M_i'] ptr_val = ptr_val - (ptr_val % 2) # clear lock bit ptr_type = find_type(self._val['_M_refcount'].type, 'pointer') |
