New issue
Advanced search Search tips

Issue 680654 link

Starred by 6 users

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 3
Type: Bug
gdb



Sign in to add a comment

clang and -gsplit-dwarf confuse GDB's namespace detection

Project Member Reported by raphael....@intel.com, Jan 12 2017

Issue description

Originally 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.
 

Comment 1 by thakis@chromium.org, Jan 12 2017

Cc: r...@chromium.org
rnk, you're clang sheriff this week, right? Since it's also about debug info, can you maybe opine on this bug?

Comment 2 by r...@chromium.org, 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.

Comment 3 by thakis@chromium.org, Jan 13 2017

Thanks, Reid. Raphael: Can you file with gdb with this additional information?
Status: ExternalDependency (was: Untriaged)
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
I'm that someone else, I'll go through the proper steps of submitting a patch next week.
leszeks: any progress?

Comment 7 by thakis@chromium.org, Mar 28 2017

Labels: gdb
Owner: leszeks@chromium.org
Ah, not yet, it's been on my backlog and far at the back of my mind.
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
Thank you!
Status: ExternalDependency (was: Fixed)
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?
I guess so, yes.
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.

Comment 16 by carl...@google.com, Oct 24 2017

Cc: carlosk@chromium.org
And the gLinux bug: http://b/68038248
Can we close this now that the gLinux bug is closed?
Status: Fixed (was: ExternalDependency)
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.
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