clang and -gsplit-dwarf confuse GDB's namespace detection |
||||||||
Issue descriptionOriginally reported here: https://groups.google.com/a/chromium.org/d/msg/chromium-dev/Vz5TxSLixU4/2lPXmRaMAAAJ clang (verified with my system's clang 3.8.0 as well as Chromium's 4.0.0 trunk 289944) with -gsplit-dwarf generates code that GDB >= 7.11 has trouble parsing correctly for namespaces. Most namespaces are recognized as "(anonymous namespace)" instead, which makes debugging quite annoying and breaks all the Python pretty printers. Sample code: namespace N { int func() { return 42; } } $ ./third_party/llvm-build/Release+Asserts/bin/clang++ -gsplit-dwarf -g2 -c func.cc && ./third_party/llvm-build/Release+Asserts/bin/clang++ -shared -o libfunc.so func.o $ gdb -q ./libfunc.so Reading symbols from ./libfoo.so...done. (gdb) info func func All functions matching regular expression "func": File bla.cc: int (anonymous namespace)::func(); When GCC is used, or when clang is invoked without -gsplit-dwarf, everything works as expected and "info func func" shows "int N::func();". Bisecting shows the change in GDB that causes this behavior is http://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=7d45c7c3f692d93c3a33a043c347f1386681deb4 (dwarf2read.c: Check type of string valued attributes prior to decoding), which is present since GDB 7.11. Since GCC is working fine, it is not clear to me if this is a bug in clang or GDB. I haven't looked for differences in the .dwo files generated by clang and GCC yet.
,
Jan 12 2017
The new function in gdb doesn't appear to handle DW_FORM_GNU_str_index, which clang uses during fission. This is the difference between gcc and clang's DW_TAG_namespace abbreviation:
[2] DW_TAG_namespace DW_CHILDREN_yes
- DW_AT_name DW_FORM_string
+ DW_AT_name DW_FORM_GNU_str_index
DW_AT_decl_file DW_FORM_data1
DW_AT_decl_line DW_FORM_data1
- DW_AT_sibling DW_FORM_ref4
I think this is a bug in GDB.
,
Jan 13 2017
Thanks, Reid. Raphael: Can you file with gdb with this additional information?
,
Jan 13 2017
Thanks, guys. I was going to file a new bug in GDB's bug tracker, but apparently someone else had already stumbled upon the same issue with V8, so I've commented on the existing bug instead: https://sourceware.org/bugzilla/show_bug.cgi?id=20899
,
Jan 13 2017
I'm that someone else, I'll go through the proper steps of submitting a patch next week.
,
Feb 5 2017
leszeks: any progress?
,
Mar 28 2017
,
Mar 29 2017
Ah, not yet, it's been on my backlog and far at the back of my mind.
,
Jul 27 2017
Thanks for the efforts, But I am still experiencing the issue, and the patch (manually applied on gdb master branch) does not fix the issue. So I have to disable use_debug_fission to fix it. Hoang
,
Aug 1 2017
Patch submitted: https://sourceware.org/ml/gdb-patches/2017-08/msg00003.html
,
Aug 7 2017
And merged: http://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=16eb6b2db49e6cf2fdca56efd37689fcc170cd37
,
Aug 7 2017
Thank you!
,
Aug 7 2017
Thanks much! Now we need a gdb release with that fix, and then we need everyone affected by this bug to use the new gdb, right?
,
Aug 7 2017
I guess so, yes.
,
Aug 24 2017
In case anyone else is using Fedora: I recently filed https://bugzilla.redhat.com/show_bug.cgi?id=1482892 and leszeks' fix was added to gdb-8.0-22 in Fedora 26.
,
Oct 24 2017
,
Oct 25 2017
And the gLinux bug: http://b/68038248
,
Mar 15 2018
Can we close this now that the gLinux bug is closed?
,
Mar 15 2018
I think so. Your commit is part of GDB 8.1 (and at least Fedora was already shipping it in earlier releases), and gLinux seems to be OK as well, so I don't see anything else that still needs to be fixed.
,
Aug 15
FYI: I've been running into this exact issue lately - namespaces like "blink" are being marked as "(anonymous namespace)" and pretty printing and function calling was broken as a result. I'm running on gLinux and installed the latest version of gdb I can (7.12-6). I've worked around the issue by installing the patched version posted at http://b/68038248#comment12. It was working for me since March so perhaps something broke in the mean time? Is anyone else seeing this? My gn args in case I'm missing something: is_debug = true is_component_build = true symbol_level = 2 use_goma = true goma_dir = "/home/bokan/tools/goma" |
||||||||
►
Sign in to add a comment |
||||||||
Comment 1 by thakis@chromium.org
, Jan 12 2017