[RFC,05/10] Use unrelocated_addr in dwarf_decode_lines

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

Commit Message

Tom Tromey April 24, 2023, 4:22 p.m. UTC
  This changes dwarf_decode_lines to accept an unrelocated_addr and
fixes up the fallout.
---
 gdb/dwarf2/read.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
  

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 39e4f05b389..6b3018831d1 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -809,7 +809,7 @@  static line_header_up dwarf_decode_line_header (sect_offset sect_off,
 
 static void dwarf_decode_lines (struct line_header *,
 				struct dwarf2_cu *,
-				CORE_ADDR, int decode_mapping);
+				unrelocated_addr, int decode_mapping);
 
 static void dwarf2_start_subfile (dwarf2_cu *cu, const file_entry &fe,
 				  const line_header &lh);
@@ -7537,7 +7537,7 @@  find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu)
 
 static void
 handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu,
-			const file_and_directory &fnd, CORE_ADDR lowpc,
+			const file_and_directory &fnd, unrelocated_addr lowpc,
 			bool have_code) /* ARI: editCase function */
 {
   dwarf2_per_objfile *per_objfile = cu->per_objfile;
@@ -7666,7 +7666,7 @@  read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
   /* Decode line number information if present.  We do this before
      processing child DIEs, so that the line header table is available
      for DW_AT_decl_file.  */
-  handle_DW_AT_stmt_list (die, cu, fnd, lowpc, unrel_low != unrel_high);
+  handle_DW_AT_stmt_list (die, cu, fnd, unrel_low, unrel_low != unrel_high);
 
   /* Process all dies in compilation unit.  */
   if (die->child != NULL)
@@ -18455,19 +18455,16 @@  lnp_state_machine::check_line_address (struct dwarf2_cu *cu,
 
 static void
 dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
-		      CORE_ADDR lowpc)
+		      unrelocated_addr lowpc)
 {
   const gdb_byte *line_ptr, *extended_end;
   const gdb_byte *line_end;
   unsigned int bytes_read, extended_len;
   unsigned char op_code, extended_op;
-  CORE_ADDR baseaddr;
   struct objfile *objfile = cu->per_objfile->objfile;
   bfd *abfd = objfile->obfd.get ();
   struct gdbarch *gdbarch = objfile->arch ();
 
-  baseaddr = objfile->text_section_offset ();
-
   line_ptr = lh->statement_program_start;
   line_end = lh->statement_program_end;
 
@@ -18525,9 +18522,8 @@  dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 		      = cu->header.read_address (abfd, line_ptr, &bytes_read);
 		    line_ptr += bytes_read;
 
-		    state_machine.check_line_address
-		      (cu, line_ptr, (unrelocated_addr) (lowpc - baseaddr),
-		       address);
+		    state_machine.check_line_address (cu, line_ptr, lowpc,
+						      address);
 		    state_machine.handle_set_address (address);
 		  }
 		  break;
@@ -18684,7 +18680,7 @@  dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 
 static void
 dwarf_decode_lines (struct line_header *lh, struct dwarf2_cu *cu,
-		    CORE_ADDR lowpc, int decode_mapping)
+		    unrelocated_addr lowpc, int decode_mapping)
 {
   if (decode_mapping)
     dwarf_decode_lines_1 (lh, cu, lowpc);