Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Patch: DWARF2 location lists vs. shared libraries
@ 2004-05-05  0:45 Bryce McKinlay
  2004-05-05  4:03 ` Daniel Jacobowitz
  0 siblings, 1 reply; 9+ messages in thread
From: Bryce McKinlay @ 2004-05-05  0:45 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1288 bytes --]

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



[-- Attachment #2: gdb-loclist.patch --]
[-- Type: text/x-patch, Size: 1363 bytes --]

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.");

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Patch: DWARF2 location lists vs. shared libraries
  2004-05-05  0:45 Patch: DWARF2 location lists vs. shared libraries Bryce McKinlay
@ 2004-05-05  4:03 ` Daniel Jacobowitz
  2004-05-05  5:59   ` Jim Blandy
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2004-05-05  4:03 UTC (permalink / raw)
  To: Bryce McKinlay; +Cc: gdb-patches

On Tue, May 04, 2004 at 08:45:52PM -0400, Bryce McKinlay wrote:
> 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.

I spoke briefly to Bryce about this (on IRC).

I think the right thing to do would be to add the offset when
searching, rather than when saving.  This will help us with relocating
objfiles, which I think would be good to support - that way we can
cache debug info for unchanged shared libraries across runs.

Does this make sense to others?  I'll try to write the patch tomorrow
or Thursday.

> 
> 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.");


-- 
Daniel Jacobowitz


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Patch: DWARF2 location lists vs. shared libraries
  2004-05-05  4:03 ` Daniel Jacobowitz
@ 2004-05-05  5:59   ` Jim Blandy
  2004-05-07 23:31     ` Bryce McKinlay
  0 siblings, 1 reply; 9+ messages in thread
From: Jim Blandy @ 2004-05-05  5:59 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Bryce McKinlay, gdb-patches

Daniel Jacobowitz <drow@false.org> writes:

> On Tue, May 04, 2004 at 08:45:52PM -0400, Bryce McKinlay wrote:
> > 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.
> 
> I spoke briefly to Bryce about this (on IRC).
> 
> I think the right thing to do would be to add the offset when
> searching, rather than when saving.  This will help us with relocating
> objfiles, which I think would be good to support - that way we can
> cache debug info for unchanged shared libraries across runs.
> 
> Does this make sense to others?  I'll try to write the patch tomorrow
> or Thursday.

Yes, that's the approach I'd prefer, too.  I wish we could apply it to
symbols as well, but I don't see how to pull that off.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Patch: DWARF2 location lists vs. shared libraries
  2004-05-05  5:59   ` Jim Blandy
@ 2004-05-07 23:31     ` Bryce McKinlay
  2004-05-12  1:34       ` Daniel Jacobowitz
  0 siblings, 1 reply; 9+ messages in thread
From: Bryce McKinlay @ 2004-05-07 23:31 UTC (permalink / raw)
  To: Jim Blandy; +Cc: Daniel Jacobowitz, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 466 bytes --]

How about this?

Regards

Bryce

Jim Blandy wrote:

>>I think the right thing to do would be to add the offset when
>>searching, rather than when saving.  This will help us with relocating
>>objfiles, which I think would be good to support - that way we can
>>cache debug info for unchanged shared libraries across runs.
>>    
>>
>Yes, that's the approach I'd prefer, too.  I wish we could apply it to
>symbols as well, but I don't see how to pull that off.
>  
>


[-- Attachment #2: gdb-loclist-2.patch --]
[-- Type: text/x-patch, Size: 1090 bytes --]

2004-05-07  Bryce McKinlay  <mckinlay@redhat.com>

	* dwarf2loc.c (find_location_expression): Use ANOFFSET to adjust
	base_address for shared libraries.

Index: dwarf2loc.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2loc.c,v
retrieving revision 1.14
diff -u -r1.14 dwarf2loc.c
--- dwarf2loc.c	26 Jan 2004 20:36:31 -0000	1.14
+++ dwarf2loc.c	7 May 2004 23:22:16 -0000
@@ -53,11 +53,14 @@
 find_location_expression (struct dwarf2_loclist_baton *baton,
 			  size_t *locexpr_length, CORE_ADDR pc)
 {
-  CORE_ADDR base_address = baton->base_address;
   CORE_ADDR low, high;
   char *loc_ptr, *buf_end;
   unsigned int addr_size = TARGET_ADDR_BIT / TARGET_CHAR_BIT, length;
   CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
+  /* Adjust base_address for relocatable objects.  */
+  CORE_ADDR base_offset = ANOFFSET (baton->objfile->section_offsets,
+				    SECT_OFF_TEXT (baton->objfile));
+  CORE_ADDR base_address = baton->base_address + base_offset;
 
   loc_ptr = baton->data;
   buf_end = baton->data + baton->size;

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Patch: DWARF2 location lists vs. shared libraries
  2004-05-07 23:31     ` Bryce McKinlay
@ 2004-05-12  1:34       ` Daniel Jacobowitz
  2004-05-12 22:03         ` Jim Blandy
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2004-05-12  1:34 UTC (permalink / raw)
  To: Bryce McKinlay; +Cc: Jim Blandy, gdb-patches

On Fri, May 07, 2004 at 07:31:14PM -0400, Bryce McKinlay wrote:
> How about this?

> 2004-05-07  Bryce McKinlay  <mckinlay@redhat.com>
> 
> 	* dwarf2loc.c (find_location_expression): Use ANOFFSET to adjust
> 	base_address for shared libraries.

It looks right to me.  Jim?

> 
> Index: dwarf2loc.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dwarf2loc.c,v
> retrieving revision 1.14
> diff -u -r1.14 dwarf2loc.c
> --- dwarf2loc.c	26 Jan 2004 20:36:31 -0000	1.14
> +++ dwarf2loc.c	7 May 2004 23:22:16 -0000
> @@ -53,11 +53,14 @@
>  find_location_expression (struct dwarf2_loclist_baton *baton,
>  			  size_t *locexpr_length, CORE_ADDR pc)
>  {
> -  CORE_ADDR base_address = baton->base_address;
>    CORE_ADDR low, high;
>    char *loc_ptr, *buf_end;
>    unsigned int addr_size = TARGET_ADDR_BIT / TARGET_CHAR_BIT, length;
>    CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
> +  /* Adjust base_address for relocatable objects.  */
> +  CORE_ADDR base_offset = ANOFFSET (baton->objfile->section_offsets,
> +				    SECT_OFF_TEXT (baton->objfile));
> +  CORE_ADDR base_address = baton->base_address + base_offset;
>  
>    loc_ptr = baton->data;
>    buf_end = baton->data + baton->size;


-- 
Daniel Jacobowitz


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Patch: DWARF2 location lists vs. shared libraries
  2004-05-12  1:34       ` Daniel Jacobowitz
@ 2004-05-12 22:03         ` Jim Blandy
  2004-05-12 23:35           ` Bryce McKinlay
       [not found]           ` <40A3B128.5040309@redhat.com>
  0 siblings, 2 replies; 9+ messages in thread
From: Jim Blandy @ 2004-05-12 22:03 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Bryce McKinlay, gdb-patches

Daniel Jacobowitz <drow@false.org> writes:

> On Fri, May 07, 2004 at 07:31:14PM -0400, Bryce McKinlay wrote:
> > How about this?
> 
> > 2004-05-07  Bryce McKinlay  <mckinlay@redhat.com>
> > 
> > 	* dwarf2loc.c (find_location_expression): Use ANOFFSET to adjust
> > 	base_address for shared libraries.
> 
> It looks right to me.  Jim?

Yes, looks good.  Bryce, do you have commit access to GDB?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Patch: DWARF2 location lists vs. shared libraries
  2004-05-12 22:03         ` Jim Blandy
@ 2004-05-12 23:35           ` Bryce McKinlay
       [not found]           ` <40A3B128.5040309@redhat.com>
  1 sibling, 0 replies; 9+ messages in thread
From: Bryce McKinlay @ 2004-05-12 23:35 UTC (permalink / raw)
  To: Jim Blandy; +Cc: Daniel Jacobowitz, gdb-patches

Jim Blandy wrote:

2004-05-07  Bryce McKinlay  <mckinlay@redhat.com>

	* dwarf2loc.c (find_location_expression): Use ANOFFSET to adjust
	base_address for shared libraries.
     

It looks right to me.  Jim?
   

Yes, looks good.  Bryce, do you have commit access to GDB?
 

Not yet - perhaps someone can hook me up? My account on 
sources.redhat.com is "bryce".

Cheers

Bryce



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Patch: [commited] DWARF2 location lists vs. shared libraries
       [not found]           ` <40A3B128.5040309@redhat.com>
@ 2004-05-13 17:37             ` Daniel Jacobowitz
  2004-05-14  1:42               ` Bryce McKinlay
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2004-05-13 17:37 UTC (permalink / raw)
  To: Bryce McKinlay; +Cc: Jim Blandy, gdb-patches

I think this patch should be checked in on gdb_6_1-branch also.  Bryce,
would you mind taking care of that?

On Thu, May 13, 2004 at 01:32:24PM -0400, Bryce McKinlay wrote:
> FYI: I've checked this in.
> 
> Thanks
> 
> Bryce
> 
> 
> Jim Blandy wrote:
> 
> >2004-05-07 Bryce McKinlay <mckinlay@redhat.com>
> >
> >>>	* dwarf2loc.c (find_location_expression): Use ANOFFSET to adjust
> >>>	base_address for shared libraries.
> >>>     
> >>>
> >>It looks right to me.  Jim?
> >>   
> >>
> >
> >Yes, looks good.  Bryce, do you have commit access to GDB?
> >
> > 
> >
> 
> 

-- 
Daniel Jacobowitz


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Patch: [commited] DWARF2 location lists vs. shared libraries
  2004-05-13 17:37             ` Patch: [commited] " Daniel Jacobowitz
@ 2004-05-14  1:42               ` Bryce McKinlay
  0 siblings, 0 replies; 9+ messages in thread
From: Bryce McKinlay @ 2004-05-14  1:42 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Jim Blandy, gdb-patches

Sure. I've now checked the patch into the 6.1 branch as well.

Regards

Bryce

Daniel Jacobowitz wrote:

I think this patch should be checked in on gdb_6_1-branch also.  Bryce,
would you mind taking care of that?
 




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-05-14  1:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-05  0:45 Patch: DWARF2 location lists vs. shared libraries Bryce McKinlay
2004-05-05  4:03 ` Daniel Jacobowitz
2004-05-05  5:59   ` Jim Blandy
2004-05-07 23:31     ` Bryce McKinlay
2004-05-12  1:34       ` Daniel Jacobowitz
2004-05-12 22:03         ` Jim Blandy
2004-05-12 23:35           ` Bryce McKinlay
     [not found]           ` <40A3B128.5040309@redhat.com>
2004-05-13 17:37             ` Patch: [commited] " Daniel Jacobowitz
2004-05-14  1:42               ` Bryce McKinlay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox