From af39c5c8749757724a0f62dcb51be59cf3ecc678 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 19 Nov 2021 22:25:23 -0500 Subject: [PATCH] gdb: remove COMPUNIT_BLOCKVECTOR macro, add getter/setter Add a getter and a setter for a compunit_symtab's blockvector. Remove the corresponding macro and adjust all callers. Change-Id: I99484c6619dcbbea7c5d89c72aa660316ca62f64 --- gdb/ada-lang.c | 10 +++++----- gdb/block.c | 6 +++--- gdb/buildsym.c | 4 ++-- gdb/cp-support.c | 4 ++-- gdb/dwarf2/read.c | 4 ++-- gdb/jit.c | 2 +- gdb/maint.c | 2 +- gdb/mdebugread.c | 8 ++++---- gdb/objfiles.c | 2 +- gdb/psymtab.c | 2 +- gdb/python/py-symbol.c | 2 +- gdb/symfile-debug.c | 2 +- gdb/symmisc.c | 6 +++--- gdb/symtab.c | 18 +++++++++--------- gdb/symtab.h | 15 ++++++++++++--- 15 files changed, 48 insertions(+), 39 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 5a67853455d..2bb64ae03bd 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -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 &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; diff --git a/gdb/block.c b/gdb/block.c index 61716458457..c0e3e465a11 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -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); diff --git a/gdb/buildsym.c b/gdb/buildsym.c index b96d154331a..847414968af 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -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")); diff --git a/gdb/cp-support.c b/gdb/cp-support.c index de83eb5d957..028ff0f4754 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -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; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index cd3e6afbe87..0d78c242768 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -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) diff --git a/gdb/jit.c b/gdb/jit.c index eda96b0003f..c86124c9e1b 100644 --- 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. */ diff --git a/gdb/maint.c b/gdb/maint.c index f7e1828e281..11dc2e466d6 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -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 ()); } diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 44c7bc306d0..59b70389531 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -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; diff --git a/gdb/objfiles.c b/gdb/objfiles.c index d0c7ac83d37..f363cb453f3 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -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)) diff --git a/gdb/psymtab.c b/gdb/psymtab.c index fcbf54ab2bd..ac5009aec37 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -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) { diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 508f445e100..f636f5119a1 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -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) diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index cd25789ba9b..59dbaf16e62 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -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, diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 9c882a468b2..6e1a4c2e834 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -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"); } diff --git a/gdb/symtab.c b/gdb/symtab.c index 6626ee8d36c..a0bc1dfea52 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -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)) diff --git a/gdb/symtab.h b/gdb/symtab.h index b72abab2ab5..f9318ffdcb4 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1409,7 +1409,7 @@ using symtab_range = next_range; #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; -#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) -- 2.30.2