This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RFC: fix bug when debugging prelink'd library
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 12 Jul 2010 13:34:20 -0600
- Subject: RFC: fix bug when debugging prelink'd library
I plan to check this in, but I wanted to ask for comments first, because
I think at least Jan disagrees with this direction. Once the discussion
is over I plan to commit this, or its replacement, to both the trunk and
the 7.2 branch.
When debugging a program linked with -lpthread I found that I couldn't
print a variable in one of the pthread functions. However, I have full
debuginfo installed, and the debuginfo is correct for this particular
variable.
Jan pointed out a Fedora patch that showed the problem --
dwarf2_per_cu_objfile was returning the master objfile, not the
debuginfo objfile. But, at least in the prelink case, the master
objfile does not have the same section offsets as the debuginfo objfile.
This fixes the problem by changing dwarf2_per_cu_objfile to return the
debuginfo objfile. This appears to be correct for all callers except
one, which I also updated.
Built and regtested on x86-64 (compile farm).
I also tried it locally on my prelink test case.
Tom
2010-07-12 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (dwarf2_per_cu_objfile): Return the objfile, not
the master objfile.
* dwarf2loc.c (dwarf_expr_tls_address): Use the master objfile.
Index: dwarf2loc.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2loc.c,v
retrieving revision 1.94
diff -u -r1.94 dwarf2loc.c
--- dwarf2loc.c 7 Jul 2010 17:26:38 -0000 1.94
+++ dwarf2loc.c 12 Jul 2010 19:25:11 -0000
@@ -234,6 +234,10 @@
struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
struct objfile *objfile = dwarf2_per_cu_objfile (debaton->per_cu);
+ /* Use the master objfile. */
+ if (objfile->separate_debug_objfile_backlink)
+ objfile = objfile->separate_debug_objfile_backlink;
+
return target_translate_tls_address (objfile, offset);
}
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.411
diff -u -r1.411 dwarf2read.c
--- dwarf2read.c 12 Jul 2010 17:07:11 -0000 1.411
+++ dwarf2read.c 12 Jul 2010 19:25:12 -0000
@@ -12054,14 +12054,7 @@
struct objfile *
dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *per_cu)
{
- struct objfile *objfile = per_cu->psymtab->objfile;
-
- /* Return 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;
-
- return objfile;
+ return per_cu->psymtab->objfile;
}
/* Return the address size given in the compilation unit header for CU. */