From: Simon Marchi Date: Sat, 20 Nov 2021 02:35:17 +0000 (-0500) Subject: gdb: remove COMPUNIT_FILETABS macro X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=510860f2787f354d1c294958e4cc5e81256ece58;p=binutils-gdb.git gdb: remove COMPUNIT_FILETABS macro I think that most remaining uses of COMPUNIT_FILETABS intend to get the primary filetab of the compunit_symtab specifically (and not to iterate over all filetabs, for example, those cases would use compunit_filetabs, which has been converted to compunit_symtab::filetabs), so replace mosts uses with compunit_symtab::primary_filetab. In jit.c, function finalize_symtab, we can save the symtab object returned by allocate_symtab and use it, it makes things simpler. Change-Id: I4e51d6d4b40759de8768b61292e5e13c8eae2e38 --- diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 914834f8e51..855d84bd27a 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -1031,7 +1031,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block, int block_i; /* The main source file's symtab. */ - struct symtab *symtab = COMPUNIT_FILETABS (cu); + struct symtab *symtab = cu->primary_filetab (); for (block_i = 0; block_i < BLOCKVECTOR_NBLOCKS (blockvector); block_i++) { @@ -1150,7 +1150,7 @@ set_missing_symtab (struct pending *pending_list, for (i = 0; i < pending->nsyms; ++i) { if (symbol_symtab (pending->symbol[i]) == NULL) - symbol_set_symtab (pending->symbol[i], COMPUNIT_FILETABS (cu)); + symbol_set_symtab (pending->symbol[i], cu->primary_filetab ()); } } } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 84877e6c7fe..7e62d11aa2c 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9477,8 +9477,8 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language) compilation is from a C file generated by language preprocessors, do not set the language if it was already deduced by start_subfile. */ if (!(cu->per_cu->lang == language_c - && COMPUNIT_FILETABS (cust)->language != language_unknown)) - COMPUNIT_FILETABS (cust)->language = cu->per_cu->lang; + && cust->primary_filetab ()->language != language_unknown)) + cust->primary_filetab ()->language = cu->per_cu->lang; /* GCC-4.0 has started to support -fvar-tracking. GCC-3.x still can produce DW_AT_location with location lists but it can be possibly @@ -9562,8 +9562,8 @@ process_full_type_unit (dwarf2_cu *cu, do not set the language if it was already deduced by start_subfile. */ if (!(cu->per_cu->lang == language_c - && COMPUNIT_FILETABS (cust)->language != language_c)) - COMPUNIT_FILETABS (cust)->language = cu->per_cu->lang; + && cust->primary_filetab ()->language != language_c)) + cust->primary_filetab ()->language = cu->per_cu->lang; } } else diff --git a/gdb/jit.c b/gdb/jit.c index 356525443cb..6366c7511e6 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -509,7 +509,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) }); cust = allocate_compunit_symtab (objfile, stab->file_name.c_str ()); - allocate_symtab (cust, stab->file_name.c_str ()); + symtab *filetab = allocate_symtab (cust, stab->file_name.c_str ()); add_compunit_symtab_to_objfile (cust); /* JIT compilers compile in memory. */ @@ -521,9 +521,9 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) size_t size = ((stab->linetable->nitems - 1) * sizeof (struct linetable_entry) + sizeof (struct linetable)); - SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust)) + SYMTAB_LINETABLE (filetab) = (struct linetable *) obstack_alloc (&objfile->objfile_obstack, size); - memcpy (SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust)), + memcpy (SYMTAB_LINETABLE (filetab), stab->linetable.get (), size); } @@ -562,7 +562,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) /* The name. */ SYMBOL_DOMAIN (block_name) = VAR_DOMAIN; SYMBOL_ACLASS_INDEX (block_name) = LOC_BLOCK; - symbol_set_symtab (block_name, COMPUNIT_FILETABS (cust)); + symbol_set_symtab (block_name, filetab); SYMBOL_TYPE (block_name) = lookup_function_type (block_type); SYMBOL_BLOCK_VALUE (block_name) = new_block; diff --git a/gdb/linespec.c b/gdb/linespec.c index 27ceaa41adb..d5025157833 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1179,7 +1179,7 @@ iterate_over_all_matching_symtabs for (compunit_symtab *cu : objfile->compunits ()) { - struct symtab *symtab = COMPUNIT_FILETABS (cu); + struct symtab *symtab = cu->primary_filetab (); iterate_over_file_blocks (symtab, lookup_name, name_domain, callback); diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 1b327ad6115..836da8a3b8c 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4084,17 +4084,17 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) /* The proper language was already determined when building the psymtab, use it. */ - COMPUNIT_FILETABS (cust)->language = PST_PRIVATE (pst)->pst_language; + cust->primary_filetab ()->language = PST_PRIVATE (pst)->pst_language; } - psymtab_language = COMPUNIT_FILETABS (cust)->language; + psymtab_language = cust->primary_filetab ()->language; - lines = SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust)); + lines = SYMTAB_LINETABLE (cust->primary_filetab ()); /* Get a new lexical context. */ push_parse_stack (); - top_stack->cur_st = COMPUNIT_FILETABS (cust); + top_stack->cur_st = cust->primary_filetab (); top_stack->cur_block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK); BLOCK_START (top_stack->cur_block) = pst->text_low (objfile); @@ -4173,7 +4173,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) size = lines->nitems; if (size > 1) --size; - SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust)) + SYMTAB_LINETABLE (cust->primary_filetab ()) = ((struct linetable *) obstack_copy (&mdebugread_objfile->objfile_obstack, lines, (sizeof (struct linetable) @@ -4183,7 +4183,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) /* .. and our share of externals. XXX use the global list to speed up things here. How? FIXME, Maybe quit once we have found the right number of ext's? */ - top_stack->cur_st = COMPUNIT_FILETABS (cust); + top_stack->cur_st = cust->primary_filetab (); top_stack->cur_block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (top_stack->cur_st), GLOBAL_BLOCK); @@ -4201,7 +4201,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) { printf_filtered (_("File %s contains %d unresolved references:"), symtab_to_filename_for_display - (COMPUNIT_FILETABS (cust)), + (cust->primary_filetab ()), n_undef_symbols); printf_filtered ("\n\t%4d variables\n\t%4d " "procedures\n\t%4d labels\n", @@ -4211,7 +4211,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) } pop_parse_stack (); - sort_blocks (COMPUNIT_FILETABS (cust)); + sort_blocks (cust->primary_filetab ()); } /* Now link the psymtab and the symtab. */ diff --git a/gdb/symmisc.c b/gdb/symmisc.c index b4b58f6e0f5..61e3eff562e 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -329,8 +329,9 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) } else { + compunit_symtab *compunit = SYMTAB_COMPUNIT (symtab); const char *compunit_filename - = symtab_to_filename_for_display (COMPUNIT_FILETABS (SYMTAB_COMPUNIT (symtab))); + = symtab_to_filename_for_display (compunit->primary_filetab ()); fprintf_filtered (outfile, "\nBlockvector same as owning compunit: %s\n\n", @@ -346,7 +347,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) if (cust->user != nullptr) { const char *addr - = host_address_to_string (COMPUNIT_FILETABS (cust->user)); + = host_address_to_string (cust->user->primary_filetab ()); fprintf_filtered (outfile, "Compunit user: %s\n", addr); } if (cust->includes != nullptr) @@ -356,7 +357,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) if (include == nullptr) break; const char *addr - = host_address_to_string (COMPUNIT_FILETABS (include)); + = host_address_to_string (include->primary_filetab ()); fprintf_filtered (outfile, "Compunit include: %s\n", addr); } } diff --git a/gdb/symtab.h b/gdb/symtab.h index 670826dd183..45d4bc4dc29 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1577,7 +1577,6 @@ struct compunit_symtab using compunit_symtab_range = next_range; -#define COMPUNIT_FILETABS(cust) (*(cust)->filetabs ().begin ()) #define COMPUNIT_DEBUGFORMAT(cust) ((cust)->debugformat) #define COMPUNIT_PRODUCER(cust) ((cust)->producer) #define COMPUNIT_DIRNAME(cust) ((cust)->dirname) @@ -1596,7 +1595,7 @@ extern enum language compunit_language (const struct compunit_symtab *cust); static inline bool is_main_symtab_of_compunit_symtab (struct symtab *symtab) { - return symtab == COMPUNIT_FILETABS (SYMTAB_COMPUNIT (symtab)); + return symtab == SYMTAB_COMPUNIT (symtab)->primary_filetab (); }