Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFC: fix bug when debugging prelink'd library
Date: Mon, 12 Jul 2010 21:06:00 -0000	[thread overview]
Message-ID: <m3zkxwv29e.fsf@fleche.redhat.com> (raw)
In-Reply-To: <m34og4wir4.fsf@fleche.redhat.com> (Tom Tromey's message of "Mon,	12 Jul 2010 14:24:47 -0600")

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> It does mean we need 3 new accessors, which is ugly.  OTOH, I found
Tom> that we use the objfile's name in locexpr_describe_location_piece,
Tom> and there I think we also want the master objfile.

We only need 1 new accessor -- using the master objfile is ok for the
other uses.

So, this is what I am going to commit.

Built & regtested on x86-64 (compile farm).
I also tried it on my test case.

Tom

2010-07-12  Tom Tromey  <tromey@redhat.com>

	* dwarf2loc.h (dwarf2_per_cu_text_offset): Declare.
	* dwarf2loc.c (find_location_expression): Use
	dwarf2_per_cu_text_offset.
	(dwarf2_evaluate_loc_desc): Likewise.
	(dwarf2_loc_desc_needs_frame): Likewise.
	(compile_dwarf_to_ax): Likewise.
	(loclist_describe_location): Likewise.
	* dwarf2read.c (dwarf2_per_cu_text_offset): New function.

diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 4106b7f..2a8e557 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -70,8 +70,7 @@ find_location_expression (struct dwarf2_loclist_baton *baton,
   int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd);
   CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
   /* Adjust base_address for relocatable objects.  */
-  CORE_ADDR base_offset = ANOFFSET (objfile->section_offsets,
-				    SECT_OFF_TEXT (objfile));
+  CORE_ADDR base_offset = dwarf2_per_cu_text_offset (baton->per_cu);
   CORE_ADDR base_address = baton->base_address + base_offset;
 
   loc_ptr = baton->data;
@@ -909,7 +908,7 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
 
   ctx->gdbarch = get_objfile_arch (objfile);
   ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
-  ctx->offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  ctx->offset = dwarf2_per_cu_text_offset (per_cu);
   ctx->baton = &baton;
   ctx->read_reg = dwarf_expr_read_reg;
   ctx->read_mem = dwarf_expr_read_mem;
@@ -1095,7 +1094,7 @@ dwarf2_loc_desc_needs_frame (const gdb_byte *data, unsigned short size,
 
   ctx->gdbarch = get_objfile_arch (objfile);
   ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
-  ctx->offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+  ctx->offset = dwarf2_per_cu_text_offset (per_cu);
   ctx->baton = &baton;
   ctx->read_reg = needs_frame_read_reg;
   ctx->read_mem = needs_frame_read_mem;
@@ -1304,12 +1303,7 @@ compile_dwarf_to_ax (struct agent_expr *expr, struct axs_value *loc,
 	     index, not an address.  We don't support things like
 	     branching between the address and the TLS op.  */
 	  if (op_ptr >= op_end || *op_ptr != DW_OP_GNU_push_tls_address)
-	    {
-	      struct objfile *objfile = dwarf2_per_cu_objfile (per_cu);
-
-	      uoffset += ANOFFSET (objfile->section_offsets,
-				   SECT_OFF_TEXT (objfile));
-	    }
+	    uoffset += dwarf2_per_cu_text_offset (per_cu);
 	  ax_const_l (expr, uoffset);
 	  break;
 
@@ -2511,8 +2505,7 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
   int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd);
   CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
   /* Adjust base_address for relocatable objects.  */
-  CORE_ADDR base_offset = ANOFFSET (objfile->section_offsets,
-				    SECT_OFF_TEXT (objfile));
+  CORE_ADDR base_offset = dwarf2_per_cu_text_offset (dlbaton->per_cu);
   CORE_ADDR base_address = dlbaton->base_address + base_offset;
 
   loc_ptr = dlbaton->data;
diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h
index 3ff595e..540e1d6 100644
--- a/gdb/dwarf2loc.h
+++ b/gdb/dwarf2loc.h
@@ -28,7 +28,9 @@ struct dwarf2_per_cu_data;
 /* This header is private to the DWARF-2 reader.  It is shared between
    dwarf2read.c and dwarf2loc.c.  */
 
-/* Return the OBJFILE associated with the compilation unit CU.  */
+/* Return the OBJFILE associated with the compilation unit CU.  If CU
+   came from a separate debuginfo file, then the master objfile is
+   returned.  */
 struct objfile *dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *cu);
 
 /* Return the address size given in the compilation unit header for CU.  */
@@ -37,6 +39,9 @@ CORE_ADDR dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *cu);
 /* Return the offset size given in the compilation unit header for CU.  */
 int dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *cu);
 
+/* Return the text offset for CU.  */
+CORE_ADDR dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *cu);
+
 struct dwarf2_locexpr_baton dwarf2_fetch_die_location_block
   (unsigned int offset, struct dwarf2_per_cu_data *per_cu);
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index e4ab034..653866c 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -12106,6 +12106,16 @@ dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *per_cu)
     }
 }
 
+/* Return the text offset of the CU.  */
+
+CORE_ADDR
+dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *per_cu)
+{
+  struct objfile *objfile = per_cu->psymtab->objfile;
+
+  return ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+}
+
 /* Locate the .debug_info compilation unit from CU's objfile which contains
    the DIE at OFFSET.  Raises an error on failure.  */
 


  reply	other threads:[~2010-07-12 21:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-12 19:34 Tom Tromey
2010-07-12 19:47 ` Jan Kratochvil
2010-07-12 20:24   ` Tom Tromey
2010-07-12 21:06     ` Tom Tromey [this message]
2010-07-12 21:22       ` Jan Kratochvil
2010-07-13 15:08         ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3zkxwv29e.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox