[commit] Fix TLS display for .gnu_debuglink

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[commit] Fix TLS display for .gnu_debuglink

Daniel Jacobowitz-2
If you have a stripped libc.so, and point GDB to a separate copy using
set debug-file-directory and objfile --only-keep-debug that has
symbols, GDB will fail to print errno.  It will say:

Cannot find shared library `/usr/lib/debug/lib/tls/libc-2.3.3.so.debug' link_map in dynamic linker's module list

The fix is to always record the master objfile;
/lib/tls/libc-2.3.3.so.debug is in the list.  I picked this solution
rather than changing the module list search, since it also fixes
"info addr errno" to report the correct library.

Tested on x86_64-linux and committed.

--
Daniel Jacobowitz
CodeSourcery

2007-06-05  Daniel Jacobowitz  <[hidden email]>

        * dwarf2read.c (dwarf2_symbol_mark_computed): Fix formatting.
        Use the original objfile if necessary.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.221
diff -u -p -r1.221 dwarf2read.c
--- dwarf2read.c 4 Jun 2007 12:34:11 -0000 1.221
+++ dwarf2read.c 5 Jun 2007 15:03:32 -0000
@@ -1046,9 +1046,9 @@ static void dwarf_decode_macros (struct
 
 static int attr_form_is_block (struct attribute *);
 
-static void
-dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
-     struct dwarf2_cu *cu);
+static void dwarf2_symbol_mark_computed (struct attribute *attr,
+ struct symbol *sym,
+ struct dwarf2_cu *cu);
 
 static gdb_byte *skip_one_die (gdb_byte *info_ptr, struct abbrev_info *abbrev,
                                struct dwarf2_cu *cu);
@@ -9698,6 +9698,13 @@ static void
 dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
      struct dwarf2_cu *cu)
 {
+  struct objfile *objfile = cu->objfile;
+
+  /* Save the master objfile, so that we can report and look up the
+     correct file containing this variable.  */
+  if (objfile->separate_debug_objfile_backlink)
+    objfile = objfile->separate_debug_objfile_backlink;
+
   if ((attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8)
       /* ".debug_loc" may not exist at all, or the offset may be outside
  the section.  If so, fall through to the complaint in the
@@ -9708,7 +9715,7 @@ dwarf2_symbol_mark_computed (struct attr
 
       baton = obstack_alloc (&cu->objfile->objfile_obstack,
      sizeof (struct dwarf2_loclist_baton));
-      baton->objfile = cu->objfile;
+      baton->objfile = objfile;
 
       /* We don't know how long the location list is, but make sure we
  don't run off the edge of the section.  */
@@ -9728,7 +9735,7 @@ dwarf2_symbol_mark_computed (struct attr
 
       baton = obstack_alloc (&cu->objfile->objfile_obstack,
      sizeof (struct dwarf2_locexpr_baton));
-      baton->objfile = cu->objfile;
+      baton->objfile = objfile;
 
       if (attr_form_is_block (attr))
  {