public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Remove the objfile backlink from comp_unit
@ 2020-02-12 22:54 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2020-02-12 22:54 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=219823045622bd111d68b984e31aa7b1712d5e10

commit 219823045622bd111d68b984e31aa7b1712d5e10
Author: Tom Tromey <tom@tromey.com>
Date:   Wed Feb 12 15:45:08 2020 -0700

    Remove the objfile backlink from comp_unit
    
    This removes the objfile backlink from comp_unit.  The only remaining
    uses involved fetching the text offset from the objfile.  However,
    this is already conveniently computed at all the sites that call
    execute_cfa_program, and so it can simply be passed in.
    
    gdb/ChangeLog
    2020-02-12  Tom Tromey  <tom@tromey.com>
    
    	* dwarf2/frame.c (struct comp_unit) <objfile>: Remove.
    	(comp_unit): Don't initialize objfile.
    	(execute_cfa_program): Add text_offset parameter.
    	(execute_cfa_program_test, dwarf2_fetch_cfa_info)
    	(dwarf2_frame_cache): Update.
    	(dwarf2_build_frame_info): Don't set "objfile" member.

Diff:
---
 gdb/ChangeLog      |  9 +++++++++
 gdb/dwarf2/frame.c | 27 ++++++++++++++-------------
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9bc686b..27166b4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
 2020-02-12  Tom Tromey  <tom@tromey.com>
 
+	* dwarf2/frame.c (struct comp_unit) <objfile>: Remove.
+	(comp_unit): Don't initialize objfile.
+	(execute_cfa_program): Add text_offset parameter.
+	(execute_cfa_program_test, dwarf2_fetch_cfa_info)
+	(dwarf2_frame_cache): Update.
+	(dwarf2_build_frame_info): Don't set "objfile" member.
+
+2020-02-12  Tom Tromey  <tom@tromey.com>
+
 	* dwarf2/frame.c (decode_frame_entry_1): Add gdbarch parameter.
 	(decode_frame_entry): Likewise.
 	(dwarf2_build_frame_info): Update.
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 7397a7f..ff33f4d 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -137,16 +137,13 @@ typedef std::vector<dwarf2_fde *> dwarf2_fde_table;
 struct comp_unit
 {
   comp_unit (struct objfile *objf)
-    : abfd (objf->obfd),
-      objfile (objf)
+    : abfd (objf->obfd)
   {
   }
 
   /* Keep the bfd convenient.  */
   bfd *abfd;
 
-  struct objfile *objfile;
-
   /* Pointer to the .debug_frame section loaded into memory.  */
   const gdb_byte *dwarf_frame_buffer = nullptr;
 
@@ -355,7 +352,8 @@ Not implemented: computing unwound register using explicit value operator"));
 static const gdb_byte *
 execute_cfa_program (struct dwarf2_fde *fde, const gdb_byte *insn_ptr,
 		     const gdb_byte *insn_end, struct gdbarch *gdbarch,
-		     CORE_ADDR pc, struct dwarf2_frame_state *fs)
+		     CORE_ADDR pc, struct dwarf2_frame_state *fs,
+		     CORE_ADDR text_offset)
 {
   int eh_frame_p = fde->eh_frame_p;
   unsigned int bytes_read;
@@ -392,8 +390,8 @@ execute_cfa_program (struct dwarf2_fde *fde, const gdb_byte *insn_ptr,
 	      fs->pc = read_encoded_value (fde->cie->unit, fde->cie->encoding,
 					   fde->cie->ptr_size, insn_ptr,
 					   &bytes_read, fde->initial_location);
-	      /* Apply the objfile offset for relocatable objects.  */
-	      fs->pc += fde->cie->unit->objfile->text_section_offset ();
+	      /* Apply the text offset for relocatable objects.  */
+	      fs->pc += text_offset;
 	      insn_ptr += bytes_read;
 	      break;
 
@@ -652,7 +650,7 @@ execute_cfa_program_test (struct gdbarch *gdbarch)
 
   const gdb_byte *insn_end = insns + sizeof (insns);
   const gdb_byte *out = execute_cfa_program (&fde, insns, insn_end, gdbarch,
-					     0, &fs);
+					     0, &fs, 0);
 
   SELF_CHECK (out == insn_end);
   SELF_CHECK (fs.pc == 0);
@@ -900,13 +898,14 @@ dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
 
   /* First decode all the insns in the CIE.  */
   execute_cfa_program (fde, fde->cie->initial_instructions,
-		       fde->cie->end, gdbarch, pc, &fs);
+		       fde->cie->end, gdbarch, pc, &fs, text_offset);
 
   /* Save the initialized register set.  */
   fs.initial = fs.regs;
 
   /* Then decode the insns in the FDE up to our target PC.  */
-  execute_cfa_program (fde, fde->instructions, fde->end, gdbarch, pc, &fs);
+  execute_cfa_program (fde, fde->instructions, fde->end, gdbarch, pc, &fs,
+		       text_offset);
 
   /* Calculate the CFA.  */
   switch (fs.regs.cfa_how)
@@ -1028,7 +1027,8 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
   /* First decode all the insns in the CIE.  */
   execute_cfa_program (fde, fde->cie->initial_instructions,
 		       fde->cie->end, gdbarch,
-		       get_frame_address_in_block (this_frame), &fs);
+		       get_frame_address_in_block (this_frame), &fs,
+		       cache->text_offset);
 
   /* Save the initialized register set.  */
   fs.initial = fs.regs;
@@ -1043,7 +1043,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
     {
       /* Decode the insns in the FDE up to the entry PC.  */
       instr = execute_cfa_program (fde, fde->instructions, fde->end, gdbarch,
-				   entry_pc, &fs);
+				   entry_pc, &fs, cache->text_offset);
 
       if (fs.regs.cfa_how == CFA_REG_OFFSET
 	  && (dwarf_reg_to_regnum (gdbarch, fs.regs.cfa_reg)
@@ -1058,7 +1058,8 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
 
   /* Then decode the insns in the FDE up to our target PC.  */
   execute_cfa_program (fde, instr, fde->end, gdbarch,
-		       get_frame_address_in_block (this_frame), &fs);
+		       get_frame_address_in_block (this_frame), &fs,
+		       cache->text_offset);
 
   try
     {


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-12 22:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-12 22:54 [binutils-gdb] Remove the objfile backlink from comp_unit Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).