[3/7] Hoist a call to frob_address

Message ID 20240217-dwarf-race-relocate-v1-3-d3d2d908c1e8@tromey.com
State New
Headers
Series Fix race in DWARF reader |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Tom Tromey Feb. 18, 2024, 1:10 a.m. UTC
  This hoists the call to frob_address in
lookup_minimal_symbol_by_pc_section, so that it now appears earlier in
the loop.  This is useful to help with a refactoring in the next
patch.  Making this change also made it clear that 'pc' is not used,
so this removes the local variable as well.
---
 gdb/minsyms.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Patch

diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index f63d0f4af61..36ca11a0b94 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -796,7 +796,9 @@  lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
 
   for (objfile *objfile : section->objfile->separate_debug_objfiles ())
     {
-      CORE_ADDR pc = pc_in;
+      unrelocated_addr unrel_pc;
+      if (!frob_address (objfile, pc_in, &unrel_pc))
+	continue;
 
       /* If this objfile has a minimal symbol table, go search it
 	 using a binary search.  */
@@ -827,9 +829,7 @@  lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
 
 	     Warning: this code is trickier than it would appear at first.  */
 
-	  unrelocated_addr unrel_pc;
-	  if (frob_address (objfile, pc, &unrel_pc)
-	      && unrel_pc >= msymbol[lo].unrelocated_address ())
+	  if (unrel_pc >= msymbol[lo].unrelocated_address ())
 	    {
 	      while (msymbol[hi].unrelocated_address () > unrel_pc)
 		{