This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Patch: DWARF2 location lists vs. shared libraries
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 04 May 2004 20:45:52 -0400
- Subject: Patch: DWARF2 location lists vs. shared libraries
GDB has been having problems debugging shared libraries built with CVS
gcc @ -O2. For example, libgcj backtraces look like this:
(gdb) bt
#0 _Jv_FindClass (name=0x83ebfe0, loader=Variable "loader" is not
available.
) at ../../../libjava/java/lang/natClassLoader.cc:375
#1 0x01442a99 in _Jv_FindClassFromSignature (sig=Variable "sig" is not
available.
) at ../../../libjava/prims.cc:753
#2 0x01442acb in _Jv_FindClassFromSignature (sig=Variable "sig" is not
available.
) at ../../../libjava/prims.cc:757
#3 0x01467d61 in _Jv_PrepareCompiledClass (klass=0x18f3500) at
../../../libjava/java/lang/natClassLoader.cc:107
#4 0x014670b8 in java::lang::Class::initializeClass (this=Variable
"this" is not available.
) at ../../../libjava/java/lang/natClass.cc:733
The problem seems to be that dwarf2read.c does not offset
dwarf2_loclist_baton's base_address for shared library load addresses.
This means that find_location_expression() fails, since the unrelocated
base_address in the baton does not match up with the PC being searched for.
Please review and commit. Since this bug means debugging of -O2 shared
libraries with cvs GCC is basically broken, perhaps the fix should go on
the stable branch as well?
Thanks to Daniel Berlin for helping to track this down!
Bryce
2004-05-04 Bryce McKinlay <mckinlay@redhat.com>
* dwarf2read.c (dwarf2_symbol_mark_computed): Use ANOFFSET to
adjust baton's base_address for shared libraries.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.150
diff -u -r1.150 dwarf2read.c
--- dwarf2read.c 4 May 2004 00:11:25 -0000 1.150
+++ dwarf2read.c 5 May 2004 00:41:00 -0000
@@ -8662,6 +8662,7 @@
if (attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8)
{
struct dwarf2_loclist_baton *baton;
+ CORE_ADDR base_offset;
baton = obstack_alloc (&cu->objfile->objfile_obstack,
sizeof (struct dwarf2_loclist_baton));
@@ -8671,7 +8672,10 @@
don't run off the edge of the section. */
baton->size = dwarf2_per_objfile->loc_size - DW_UNSND (attr);
baton->data = dwarf2_per_objfile->loc_buffer + DW_UNSND (attr);
- baton->base_address = cu->header.base_address;
+ /* Set base_address, adjusting for shared libraries. */
+ base_offset = ANOFFSET (cu->objfile->section_offsets,
+ SECT_OFF_TEXT (cu->objfile));
+ baton->base_address = cu->header.base_address + base_offset;
if (cu->header.base_known == 0)
complaint (&symfile_complaints,
"Location list used without specifying the CU base address.");