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

Change-Id: I99484c6619dcbbea7c5d89c72aa660316ca62f64

15 files changed:
gdb/ada-lang.c
gdb/block.c
gdb/buildsym.c
gdb/cp-support.c
gdb/dwarf2/read.c
gdb/jit.c
gdb/maint.c
gdb/mdebugread.c
gdb/objfiles.c
gdb/psymtab.c
gdb/python/py-symbol.c
gdb/symfile-debug.c
gdb/symmisc.c
gdb/symtab.c
gdb/symtab.h

index 5a67853455da90ead60294480e87ae3fb6abae9c..2bb64ae03bde1395701c6deefac6669aef3e3eea 100644 (file)
@@ -5237,7 +5237,7 @@ map_matching_symbols (struct objfile *objfile,
   for (compunit_symtab *symtab : objfile->compunits ())
     {
       const struct block *block
-       = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (symtab), block_kind);
+       = BLOCKVECTOR_BLOCK (symtab->blockvector (), block_kind);
       if (!iterate_over_symbols_terminated (block, lookup_name,
                                            domain, data))
        break;
@@ -5266,7 +5266,7 @@ add_nonlocal_symbols (std::vector<struct block_symbol> &result,
       for (compunit_symtab *cu : objfile->compunits ())
        {
          const struct block *global_block
-           = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cu), GLOBAL_BLOCK);
+           = BLOCKVECTOR_BLOCK (cu->blockvector (), GLOBAL_BLOCK);
 
          if (ada_add_block_renamings (result, global_block, lookup_name,
                                       domain))
@@ -12617,7 +12617,7 @@ ada_add_global_exceptions (compiled_regex *preg,
     {
       for (compunit_symtab *s : objfile->compunits ())
        {
-         const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (s);
+         const struct blockvector *bv = s->blockvector ();
          int i;
 
          for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
@@ -13204,7 +13204,7 @@ public:
        for (compunit_symtab *s : objfile->compunits ())
          {
            QUIT;
-           b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK);
+           b = BLOCKVECTOR_BLOCK (s->blockvector (), GLOBAL_BLOCK);
            ALL_BLOCK_SYMBOLS (b, iter, sym)
              {
                if (completion_skip_symbol (mode, sym))
@@ -13223,7 +13223,7 @@ public:
        for (compunit_symtab *s : objfile->compunits ())
          {
            QUIT;
-           b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK);
+           b = BLOCKVECTOR_BLOCK (s->blockvector (), STATIC_BLOCK);
            /* Don't do this block twice.  */
            if (b == surrounding_static_block)
              continue;
index 617164584578c94310195c1386dad2f5928f8d08..c0e3e465a115e31bb5090978a6954b4b1b1b9ab5 100644 (file)
@@ -197,7 +197,7 @@ blockvector_for_pc_sect (CORE_ADDR pc, struct obj_section *section,
        return 0;
     }
 
-  bl = COMPUNIT_BLOCKVECTOR (cust);
+  bl = cust->blockvector ();
 
   /* Then search that symtab for the smallest block that wins.  */
   b = find_block_in_blockvector (bl, pc);
@@ -543,7 +543,7 @@ block_iterator_step (struct block_iterator *iterator, int first)
          if (cust == NULL)
            return  NULL;
 
-         block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
+         block = BLOCKVECTOR_BLOCK (cust->blockvector (),
                                     iterator->which);
          sym = mdict_iterator_first (BLOCK_MULTIDICT (block),
                                      &iterator->mdict_iter);
@@ -612,7 +612,7 @@ block_iter_match_step (struct block_iterator *iterator,
          if (cust == NULL)
            return  NULL;
 
-         block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
+         block = BLOCKVECTOR_BLOCK (cust->blockvector (),
                                     iterator->which);
          sym = mdict_iter_match_first (BLOCK_MULTIDICT (block), name,
                                        &iterator->mdict_iter);
index b96d154331a3dac5687850c09136ce33dfc28220..847414968af4e54c319acbb1a49aea3e38ba73bd 100644 (file)
@@ -1015,7 +1015,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
   /* Similarly for the producer.  */
   cu->set_producer (m_producer);
 
-  COMPUNIT_BLOCKVECTOR (cu) = blockvector;
+  cu->set_blockvector (blockvector);
   {
     struct block *b = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
 
@@ -1163,7 +1163,7 @@ void
 buildsym_compunit::augment_type_symtab ()
 {
   struct compunit_symtab *cust = m_compunit_symtab;
-  const struct blockvector *blockvector = COMPUNIT_BLOCKVECTOR (cust);
+  const struct blockvector *blockvector = cust->blockvector ();
 
   if (!m_context_stack.empty ())
     complaint (_("Context stack not empty in augment_type_symtab"));
index de83eb5d957021a3c677aced278b1aac83e2fa65..028ff0f475460c900a0b9a99127dafea18993619 100644 (file)
@@ -1464,7 +1464,7 @@ add_symbol_overload_list_qualified (const char *func_name,
       for (compunit_symtab *cust : objfile->compunits ())
        {
          QUIT;
-         b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), GLOBAL_BLOCK);
+         b = BLOCKVECTOR_BLOCK (cust->blockvector (), GLOBAL_BLOCK);
          add_symbol_overload_list_block (func_name, b, overload_list);
        }
     }
@@ -1474,7 +1474,7 @@ add_symbol_overload_list_qualified (const char *func_name,
       for (compunit_symtab *cust : objfile->compunits ())
        {
          QUIT;
-         b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
+         b = BLOCKVECTOR_BLOCK (cust->blockvector (), STATIC_BLOCK);
          /* Don't do this block twice.  */
          if (b == surrounding_static_block)
            continue;
index cd3e6afbe87f2e84d3baf2867144debac3eee4ba..0d78c242768ad4b4ab0ece97b8f334794a1de872 100644 (file)
@@ -4451,8 +4451,8 @@ recursively_find_pc_sect_compunit_symtab (struct compunit_symtab *cust,
 {
   int i;
 
-  if (COMPUNIT_BLOCKVECTOR (cust) != NULL
-      && blockvector_contains_pc (COMPUNIT_BLOCKVECTOR (cust), pc))
+  if (cust->blockvector () != nullptr
+      && blockvector_contains_pc (cust->blockvector (), pc))
     return cust;
 
   if (cust->includes == NULL)
index eda96b0003f1fb1f7fdefc036362e74a4120e863..c86124c9e1be661f2c64c42733f1fb53f94348b4 100644 (file)
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -531,7 +531,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
                      + (actual_nblocks - 1) * sizeof (struct block *));
   bv = (struct blockvector *) obstack_alloc (&objfile->objfile_obstack,
                                             blockvector_size);
-  COMPUNIT_BLOCKVECTOR (cust) = bv;
+  cust->set_blockvector (bv);
 
   /* At the end of this function, (begin, end) will contain the PC range this
      entire blockvector spans.  */
index f7e1828e2810fc0192d210550a0ab9d59ad57180..11dc2e466d6bee7a64f00feb6f66052cb487f040 100644 (file)
@@ -946,7 +946,7 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
          for (compunit_symtab *cu : o->compunits ())
            {
              ++nr_compunit_symtabs;
-             nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu));
+             nr_blocks += BLOCKVECTOR_NBLOCKS (cu->blockvector ());
              nr_symtabs += std::distance (cu->filetabs ().begin (),
                                           cu->filetabs ().end ());
            }
index 44c7bc306d073edf153148e4b867d40f8a39097e..59b70389531ab0a9b3b88f40e163ebe0e108a9c5 100644 (file)
@@ -1965,7 +1965,7 @@ parse_procedure (PDR *pr, struct compunit_symtab *search_symtab,
 #else
       s = mylookup_symbol
        (sh_name,
-        BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (search_symtab),
+        BLOCKVECTOR_BLOCK (search_symtab->blockvector (),
                            STATIC_BLOCK),
         VAR_DOMAIN,
         LOC_BLOCK);
@@ -4096,7 +4096,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
       push_parse_stack ();
       top_stack->cur_st = cust->primary_filetab ();
       top_stack->cur_block
-       = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
+       = BLOCKVECTOR_BLOCK (cust->blockvector (), STATIC_BLOCK);
       BLOCK_START (top_stack->cur_block) = pst->text_low (objfile);
       BLOCK_END (top_stack->cur_block) = 0;
       top_stack->blocktype = stFile;
@@ -4502,7 +4502,7 @@ add_block (struct block *b, struct symtab *s)
                                         + BLOCKVECTOR_NBLOCKS (bv)
                                         * sizeof (bv->block)));
   if (bv != SYMTAB_BLOCKVECTOR (s))
-    SYMTAB_BLOCKVECTOR (s) = bv;
+    SYMTAB_COMPUNIT (s)->set_blockvector (bv);
 
   BLOCKVECTOR_BLOCK (bv, BLOCKVECTOR_NBLOCKS (bv)++) = b;
 }
@@ -4632,7 +4632,7 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile)
   BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = new_block (NON_FUNCTION_BLOCK, lang);
   BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
     BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-  COMPUNIT_BLOCKVECTOR (cust) = bv;
+  cust->set_blockvector (bv);
 
   cust->set_debugformat ("ECOFF");
   return cust;
index d0c7ac83d379a5fdded22bd9cd6390fe8a79356b..f363cb453f3a274893db39b8e0a4222d11bc4ffd 100644 (file)
@@ -667,7 +667,7 @@ objfile_relocate1 (struct objfile *objfile,
 
     for (compunit_symtab *cust : objfile->compunits ())
       {
-       const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
+       const struct blockvector *bv = cust->blockvector ();
        int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
 
        if (BLOCKVECTOR_MAP (bv))
index fcbf54ab2bdd9afd48ed6b71f8176f824006b7ad..ac5009aec37f73bc172e5b3dd3c3f2bffd85dc5c 100644 (file)
@@ -1801,7 +1801,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
              /* Now do checks requiring the associated symtab.  */
              if (cust == NULL)
                continue;
-             bv = COMPUNIT_BLOCKVECTOR (cust);
+             bv = cust->blockvector ();
              b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
              for (partial_symbol *psym : ps->static_psymbols)
                {
index 508f445e100155dc7189de63df585d5f02fc0e33..f636f5119a13d29f82d2c41bbba1bcb3cbd3e817 100644 (file)
@@ -571,7 +571,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
              const struct blockvector *bv;
              const struct block *block;
 
-             bv = COMPUNIT_BLOCKVECTOR (cust);
+             bv = cust->blockvector ();
              block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
 
              if (block != nullptr)
index cd25789ba9b04532f26c568df83d5272586eb1c5..59dbaf16e62b53e89d042f53ea0d194085ebf780 100644 (file)
@@ -245,7 +245,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
   auto search_one_symtab = [&] (compunit_symtab *stab)
   {
     struct symbol *sym, *with_opaque = NULL;
-    const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (stab);
+    const struct blockvector *bv = stab->blockvector ();
     const struct block *block = BLOCKVECTOR_BLOCK (bv, kind);
 
     sym = block_find_symbol (block, name, domain,
index 9c882a468b278b486aab5a212ab472f2b0fc3b9e..6e1a4c2e8341152605467c835051fe442073b35d 100644 (file)
@@ -787,7 +787,7 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
                        printf_filtered ("    blockvector"
                                         " ((struct blockvector *) %s)\n",
                                         host_address_to_string
-                                        (COMPUNIT_BLOCKVECTOR (cust)));
+                                          (cust->blockvector ()));
                        printf_filtered ("    user"
                                         " ((struct compunit_symtab *) %s)\n",
                                         cust->user != nullptr
@@ -863,7 +863,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
 
            QUIT;
 
-           if (COMPUNIT_BLOCKVECTOR (cust) == NULL)
+           if (cust->blockvector () == NULL)
              found_something = 1;
            /* Add more checks here.  */
 
@@ -879,7 +879,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
                  }
                printf_filtered ("  { symtab %s\n",
                                 symtab_to_filename_for_display (symtab));
-               if (COMPUNIT_BLOCKVECTOR (cust) == NULL)
+               if (cust->blockvector () == NULL)
                  printf_filtered ("    NULL blockvector\n");
                printf_filtered ("  }\n");
              }
index 6626ee8d36cabb6d044e0f19baf1981cda7e7865..a0bc1dfea52e73f8b65a343230420c628ae332b9 100644 (file)
@@ -2309,7 +2309,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
       const struct block *block;
       struct block_symbol result;
 
-      bv = COMPUNIT_BLOCKVECTOR (cust);
+      bv = cust->blockvector ();
       block = BLOCKVECTOR_BLOCK (bv, block_index);
       result.symbol = block_lookup_symbol_primary (block, name, domain);
       result.block = block;
@@ -2442,7 +2442,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
       return {};
     }
 
-  bv = COMPUNIT_BLOCKVECTOR (cust);
+  bv = cust->blockvector ();
   block = BLOCKVECTOR_BLOCK (bv, block_index);
   result.symbol = block_lookup_symbol (block, name,
                                       symbol_name_match_type::FULL, domain);
@@ -2792,7 +2792,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
   if (cust == NULL)
     return NULL;
 
-  bv = COMPUNIT_BLOCKVECTOR (cust);
+  bv = cust->blockvector ();
   block = BLOCKVECTOR_BLOCK (bv, block_index);
   sym = block_find_symbol (block, name, STRUCT_DOMAIN,
                           block_find_non_opaque_type, NULL);
@@ -2817,7 +2817,7 @@ basic_lookup_transparent_type_1 (struct objfile *objfile,
 
   for (compunit_symtab *cust : objfile->compunits ())
     {
-      bv = COMPUNIT_BLOCKVECTOR (cust);
+      bv = cust->blockvector ();
       block = BLOCKVECTOR_BLOCK (bv, block_index);
       sym = block_find_symbol (block, name, STRUCT_DOMAIN,
                               block_find_non_opaque_type, NULL);
@@ -2962,7 +2962,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
     {
       for (compunit_symtab *cust : obj_file->compunits ())
        {
-         const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
+         const struct blockvector *bv = cust->blockvector ();
          const struct block *global_block
            = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
          CORE_ADDR start = BLOCK_START (global_block);
@@ -3068,7 +3068,7 @@ find_symbol_at_address (CORE_ADDR address)
      ADDR.  */
   auto search_symtab = [] (compunit_symtab *symtab, CORE_ADDR addr) -> symbol *
     {
-      const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (symtab);
+      const struct blockvector *bv = symtab->blockvector ();
 
       for (int i = GLOBAL_BLOCK; i <= STATIC_BLOCK; ++i)
        {
@@ -3276,7 +3276,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
       return val;
     }
 
-  bv = COMPUNIT_BLOCKVECTOR (cust);
+  bv = cust->blockvector ();
 
   /* Look at all the symtabs that share this blockvector.
      They all have the same apriori range, that we found was right;
@@ -4793,7 +4793,7 @@ global_symbol_searcher::add_matching_symbols
   /* Add matching symbols (if not already present).  */
   for (compunit_symtab *cust : objfile->compunits ())
     {
-      const struct blockvector *bv  = COMPUNIT_BLOCKVECTOR (cust);
+      const struct blockvector *bv  = cust->blockvector ();
 
       for (block_enum block : { GLOBAL_BLOCK, STATIC_BLOCK })
        {
@@ -5773,7 +5773,7 @@ add_symtab_completions (struct compunit_symtab *cust,
   for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
     {
       QUIT;
-      b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), i);
+      b = BLOCKVECTOR_BLOCK (cust->blockvector (), i);
       ALL_BLOCK_SYMBOLS (b, iter, sym)
        {
          if (completion_skip_symbol (mode, sym))
index b72abab2ab5a3c05fbd2cedbc0d7490271b858b7..f9318ffdcb46312b3b3ae8813d4d300307ea0698 100644 (file)
@@ -1409,7 +1409,7 @@ using symtab_range = next_range<symtab>;
 #define SYMTAB_LINETABLE(symtab) ((symtab)->linetable)
 #define SYMTAB_LANGUAGE(symtab) ((symtab)->language)
 #define SYMTAB_BLOCKVECTOR(symtab) \
-  COMPUNIT_BLOCKVECTOR (SYMTAB_COMPUNIT (symtab))
+  (SYMTAB_COMPUNIT (symtab)->blockvector ())
 #define SYMTAB_OBJFILE(symtab) \
   (SYMTAB_COMPUNIT (symtab)->objfile ())
 #define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace)
@@ -1511,6 +1511,16 @@ struct compunit_symtab
     m_dirname = dirname;
   }
 
+  const struct blockvector *blockvector () const
+  {
+    return m_blockvector;
+  }
+
+  void set_blockvector (const struct blockvector *blockvector)
+  {
+    m_blockvector = blockvector;
+  }
+
   /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
 
      PRIMARY_FILETAB must already be a filetab of this compunit symtab.  */
@@ -1564,7 +1574,7 @@ struct compunit_symtab
 
   /* List of all symbol scope blocks for this symtab.  It is shared among
      all symtabs in a given compilation unit.  */
-  const struct blockvector *blockvector;
+  const struct blockvector *m_blockvector;
 
   /* Section in objfile->section_offsets for the blockvector and
      the linetable.  Probably always SECT_OFF_TEXT.  */
@@ -1606,7 +1616,6 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_BLOCKVECTOR(cust) ((cust)->blockvector)
 #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)