hi, on the recent 4.5 branch i have a problems with dwarf4 and pretty printers. here's steps to reproduce: $ make /local/devel/toolchain45/x86_64-gnu-linux.mt_alloc/bin/x86_64-gnu-linux-g++ t.cpp -gdwarf-3 -g2 -o t-dw3 /local/devel/toolchain45/x86_64-gnu-linux.mt_alloc/bin/x86_64-gnu-linux-g++ t.cpp -gdwarf-4 -g2 -o t-dw4 $ gdb ./t-dw3 (gdb) r Breakpoint 1, main () at t.cpp:4 4 std::string s( "foo" ); (gdb) n 5 s.size(); (gdb) p s $1 = "foo" $ gdb ./t-dw4 (gdb) r Breakpoint 1, main () at t.cpp:4 4 std::string s( "foo" ); (gdb) n 5 s.size(); (gdb) p s $1 = Traceback (most recent call last): File "/local/devel/toolchain45/x86_64-gnu-linux.mt_alloc/share/gcc-4.5.2/python/libstdcxx/v6/printers.py", line 547, in to_string reptype = gdb.lookup_type (str (realtype) + '::_Rep').pointer () RuntimeError: No type named std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep. $ readelf --debug-dump=pubtypes t-dw3 Contents of the .debug_pubtypes section: Length: 443 Version: 2 Offset into .debug_info section: 0x0 Size of area in .debug_info section: 13545 Offset Name 2d ptrdiff_t 3f size_t 6bf __FILE 6ca __va_list_tag 709 wint_t 770 mbstate_t fa4 char_traits 121c __pthread_internal_list 1243 __pthread_list_t 12ed __compar_fn_t b99 tm 161c __gthread_mutex_t 1627 _Atomic_word 163a __pool_base 17c5 __pool 1998 __mt_alloc_base 1a8e __common_pool 1adb __common_pool_base 1b2f __common_pool_policy 1b57 __mt_alloc 1c62 allocator 1cf0 lconv 1e5c __numeric_traits_integer 1ecc basic_string 3293 _Rep_base 32c4 _Rep $ readelf --debug-dump=pubtypes t-dw4 Contents of the .debug_pubtypes section: Length: 394 Version: 2 Offset into .debug_info section: 0x0 Size of area in .debug_info section: 3926 Offset Name 2d ptrdiff_t 3f size_t 41e __FILE 25 __va_list_tag 42b wint_t 43e mbstate_t 34 char_traits 25 __pthread_internal_list b7f __compar_fn_t 25 tm 34 __pool_base 34 __pool 34 __mt_alloc_base 34 __common_pool 34 __common_pool_base 34 __common_pool_policy 34 __mt_alloc 34 allocator 25 lconv 34 __numeric_traits_integer 25 rebind 34 basic_string 34 _Rep_base 34 _Rep as you can see few types have the same "offset 34". looks like a bug.
Created attachment 21811 [details] source, makefile and precompiled binaries.
ha, my gcc was built with: export CXXFLAGS="-O2"; ./configure --disable-shared..." and this CXXFLAGS afaics affects libstdc++.a debuginfo level. with CXXFLAGS="-O2 -g2" the python pretty printer works fine. testcase compiled with -gdwarf-4 -g2 and linked with stripped libstdc++.a ends with undebugable std::string. of course with -gdwarf-3 everything works fine.
Created attachment 22036 [details] my gcc build script.
attached gcc build script builds libstdc++.a with dwarf3 debuginfo which works with testcase compiled with dwarf3 or dwarf4. if you change CUSTOM_FLAGS in build script to emit dwarf4 for libstdc++.a then you'll get runtime error in python gdb printer.
Maybe Tom can have a look, see if something (still) makes sense here.
The problem is that the DWARF4 standard says that .debug_pubtypes resp. .debug_pubnames refer to .debug_info section offsets and this hasn't been updated for the (optional) .debug_types section addition. If a type (resp. name) DIE is instead in .debug_types section, it is unclear what should be done. Either such a type shouldn't be added into .debug_pubtypes at all, or we'd need to refer to something. I don't see anything to refer to in .debug_info section though, usually it just contains DW_AT_type with DW_FORM_sig8 containing the .debug_types hash with the type. And it isn't possible to refer to .debug_types section offsets, because the consumers would need a way to differentiate between what is a .debug_info offset in the header (relative to start of .debug_info) and what is a .debug_types offset (relative to start of .debug_types). I think currently what you see is gcc emitting offsets within containing .debug_types section in .debug_pubtypes chunks corresponding to .debug_info.
gdb doesn't read .debug_pubtypes. So the problem must be something else.