[RFC,09/10] Use local "text offset" variable in dwarf2_frame_cache

Message ID 20230424162211.682763-10-tromey@adacore.com
State New
Headers
Series More use of unrelocated_addr |

Commit Message

Tom Tromey April 24, 2023, 4:22 p.m. UTC
  A few spots in dwarf2_frame_cache use:

    cache->per_objfile->objfile->text_section_offset ()

... and a subsequent patch will add more, so move this into a local
variable.
---
 gdb/dwarf2/frame.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
  

Patch

diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 8f8add201f4..705e2a7eeb9 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -922,6 +922,8 @@  dwarf2_frame_cache (frame_info_ptr this_frame, void **this_cache)
   gdb_assert (fde != NULL);
   gdb_assert (cache->per_objfile != nullptr);
 
+  CORE_ADDR text_offset = cache->per_objfile->objfile->text_section_offset ();
+
   /* Allocate and initialize the frame state.  */
   struct dwarf2_frame_state fs (pc1, fde->cie);
 
@@ -934,7 +936,7 @@  dwarf2_frame_cache (frame_info_ptr this_frame, void **this_cache)
   execute_cfa_program (fde, fde->cie->initial_instructions,
 		       fde->cie->end, gdbarch,
 		       get_frame_address_in_block (this_frame), &fs,
-		       cache->per_objfile->objfile->text_section_offset ());
+		       text_offset);
 
   /* Save the initialized register set.  */
   fs.initial = fs.regs;
@@ -950,9 +952,8 @@  dwarf2_frame_cache (frame_info_ptr this_frame, void **this_cache)
       && entry_pc < fde->initial_location + fde->address_range)
     {
       /* Decode the insns in the FDE up to the entry PC.  */
-      instr = execute_cfa_program
-	(fde, fde->instructions, fde->end, gdbarch, entry_pc, &fs,
-	 cache->per_objfile->objfile->text_section_offset ());
+      instr = execute_cfa_program (fde, fde->instructions, fde->end, gdbarch,
+				   entry_pc, &fs, text_offset);
 
       if (fs.regs.cfa_how == CFA_REG_OFFSET
 	  && (dwarf_reg_to_regnum (gdbarch, fs.regs.cfa_reg)
@@ -968,7 +969,7 @@  dwarf2_frame_cache (frame_info_ptr 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,
-		       cache->per_objfile->objfile->text_section_offset ());
+		       text_offset);
 
   try
     {