Re: Patch: DWARF2 location lists vs. shared libraries

Bryce McKinlay
2004-05-07T23:31:16Z

[-- 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;