On Thu, Feb 5, 2026 at 12:32 PM Jonathan Wakely <[email protected]> wrote:
> On Thu, 5 Feb 2026 at 11:15, Tomasz Kaminski <[email protected]> wrote: > > > > > > > > On Thu, Feb 5, 2026 at 12:07 PM Jonathan Wakely <[email protected]> > wrote: > >> > >> On Thu, 5 Feb 2026 at 10:52, Tomasz Kaminski <[email protected]> > wrote: > >> > > >> > > >> > > >> > On Thu, Feb 5, 2026 at 11:41 AM Jonathan Wakely <[email protected]> > wrote: > >> >> > >> >> 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. > >> >> --- > >> >> > >> >> Tested x86_64-linux, using both GDB 8 and GDB 16, and also tested a > >> >> binary with the GCC 15 std::atomic<shared_ptr> can be printed by the > GCC > >> >> 16 printers.py. > >> > > >> > I am confused about the configuration that this is aiming to address? > Someone > >> > having a GCC 16 installation (so they pick up new pretty-printers), > but using > >> > GDB-8 to debug the produced binary? > >> > >> Right. > >> > >> > Why would we put effort into supporting > >> > this? > >> > >> Because RHEL 8 comes with GDB 8.2 > > > > I still do not follow up. RHEL 8 comes with GDB 8 and I assume GCC 8, > certainly not 16. > > We provide new versions of GCC via the RHEL GCC Toolset packages. > Users can also build GCC themselves. > > > So someone installed GCC 16, and built the program, and we cannot > require them to > > use and install and use GDB 16 to debug that? They already stepped out > of defaults. > > The person debugging it might not be the same person who compiled it. > They might only have the GCC 16 libstdc++.so and python printers, but > be using the system GDB. > > Less hypothetically, I'm seeing test failures when running the > testsuite on cfarm187, which has gdb-8.2. This change fixes those test > failures. > > In general there is no requirement to use a particular version of GDB > with a particular version of GCC. Any reasonable combination should > work, and we've always supported that. The alternative is for the > pretty printers to break very noisily when using an old GDB, and > there's simply no reason to give users that bad outcome. We can easily > support old versions of GDB. > OK, interesting. Up to this point, when I was uncertain about what I see from the dump, I was always making sure that GDB version is same or newer than GCC I used. I.e. assumed backward compatibility, but not forward. > > >> > >> > >> > > >> > Outside of that patch LGTM. > >> > > >> >> libstdc++-v3/python/libstdcxx/v6/printers.py | 10 ++++++++-- > >> >> 1 file changed, 8 insertions(+), 2 deletions(-) > >> >> > >> >> diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py > b/libstdc++-v3/python/libstdcxx/v6/printers.py > >> >> index 8bb7dd2ad600..be7e7a256065 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') > >> >> -- > >> >> 2.52.0 > >> >> > >> > >
