gdb: remove COMPUNIT_BLOCK_LINE_SECTION macro, add getter/setter
authorSimon Marchi <simon.marchi@efficios.com>
Sat, 20 Nov 2021 03:31:55 +0000 (22:31 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Sun, 6 Feb 2022 20:48:19 +0000 (15:48 -0500)
Add a getter and a setter for a compunit_symtab's block line section.  Remove
the corresponding macro and adjust all callers.

Change-Id: I3eb1a323388ad55eae8bfa45f5bc4a08dc3df455

gdb/buildsym.c
gdb/dwarf2/loc.c
gdb/gdbtypes.c
gdb/objfiles.c
gdb/symtab.c
gdb/symtab.h

index 847414968af4e54c319acbb1a49aea3e38ba73bd..1b162dac9e07e87039b22649936ade969cbd84b5 100644 (file)
@@ -1022,7 +1022,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
     set_block_compunit_symtab (b, cu);
   }
 
-  COMPUNIT_BLOCK_LINE_SECTION (cu) = section;
+  cu->set_block_line_section (section);
 
   COMPUNIT_MACRO_TABLE (cu) = release_macros ();
 
index 69b480e6e8692c57deac3f24e06ebbd634429ce5..bf3cadba87eefc6c47258d193b8b5206d9d9d4b9 100644 (file)
@@ -717,7 +717,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
       {
        dwarf2_per_objfile *per_objfile = call_site->per_objfile;
        compunit_symtab *cust = per_objfile->get_symtab (call_site->per_cu);
-       int sect_idx = COMPUNIT_BLOCK_LINE_SECTION (cust);
+       int sect_idx = cust->block_line_section ();
        CORE_ADDR delta = per_objfile->objfile->section_offsets[sect_idx];
 
        return call_site->target.loc_physaddr () + delta;
index 8af96c79e6ca62cb51415e15e146b877a25bcc19..7958447331055be51d56626fbb3a31547fe14916 100644 (file)
@@ -6285,7 +6285,7 @@ call_site::pc () const
 {
   compunit_symtab *cust = this->per_objfile->get_symtab (this->per_cu);
   CORE_ADDR delta
-       = this->per_objfile->objfile->section_offsets[COMPUNIT_BLOCK_LINE_SECTION (cust)];
+       = this->per_objfile->objfile->section_offsets[cust->block_line_section ()];
   return m_unrelocated_pc + delta;
 }
 
index f363cb453f3a274893db39b8e0a4222d11bc4ffd..7e1ec6ca92dddbfe94ee9c6f7981c1b3b938a74f 100644 (file)
@@ -660,7 +660,7 @@ objfile_relocate1 (struct objfile *objfile,
            if (l)
              {
                for (int i = 0; i < l->nitems; ++i)
-                 l->item[i].pc += delta[COMPUNIT_BLOCK_LINE_SECTION (cust)];
+                 l->item[i].pc += delta[cust->block_line_section ()];
              }
          }
       }
@@ -668,7 +668,7 @@ objfile_relocate1 (struct objfile *objfile,
     for (compunit_symtab *cust : objfile->compunits ())
       {
        const struct blockvector *bv = cust->blockvector ();
-       int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
+       int block_line_section = cust->block_line_section ();
 
        if (BLOCKVECTOR_MAP (bv))
          addrmap_relocate (BLOCKVECTOR_MAP (bv), delta[block_line_section]);
index a0bc1dfea52e73f8b65a343230420c628ae332b9..70a9f10ea4b6b4133bd878908745d261fc78e323 100644 (file)
@@ -338,7 +338,7 @@ compunit_symtab::find_call_site (CORE_ADDR pc) const
     return nullptr;
 
   CORE_ADDR delta
-    = this->objfile ()->section_offsets[COMPUNIT_BLOCK_LINE_SECTION (this)];
+    = this->objfile ()->section_offsets[this->block_line_section ()];
   CORE_ADDR unrelocated_pc = pc - delta;
 
   struct call_site call_site_local (unrelocated_pc, nullptr, nullptr);
index f9318ffdcb46312b3b3ae8813d4d300307ea0698..c59e3c3457c7d7879bbd61d1f6e75cdb0cf36f74 100644 (file)
@@ -1521,6 +1521,16 @@ struct compunit_symtab
     m_blockvector = blockvector;
   }
 
+  int block_line_section () const
+  {
+    return m_block_line_section;
+  }
+
+  void set_block_line_section (int block_line_section)
+  {
+    m_block_line_section = block_line_section;
+  }
+
   /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
 
      PRIMARY_FILETAB must already be a filetab of this compunit symtab.  */
@@ -1578,7 +1588,7 @@ struct compunit_symtab
 
   /* Section in objfile->section_offsets for the blockvector and
      the linetable.  Probably always SECT_OFF_TEXT.  */
-  int block_line_section;
+  int m_block_line_section;
 
   /* Symtab has been compiled with both optimizations and debug info so that
      GDB may stop skipping prologues as variables locations are valid already
@@ -1616,7 +1626,6 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_BLOCK_LINE_SECTION(cust) ((cust)->block_line_section)
 #define COMPUNIT_LOCATIONS_VALID(cust) ((cust)->locations_valid)
 #define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid)
 #define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table)