From: Simon Marchi Date: Sat, 20 Nov 2021 02:18:05 +0000 (-0500) Subject: gdb: move compunit_filetabs to compunit_symtab::filetabs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=102cc23543fc37b42c4814f594f130f862397178;p=binutils-gdb.git gdb: move compunit_filetabs to compunit_symtab::filetabs Make compunit_filetabs, used to iterate a compunit_symtab's filetabs, a method of compunit_symtab. The name filetabs conflicts with the current name of the field. Rename the field to m_filetabs, since at this point nothing outside of compunit_symtab uses it, so we should treat it as private (even though it's not actually private). Rename the last_filetab field to m_last_filetab as well (it's only used on compunit_symtab::add_filetab). Adjust the COMPUNIT_FILETABS macro to keep its current behavior of returning the first filetab. Change-Id: I537b553a44451c52d24b18ee1bfa47e23747cfc3 --- diff --git a/gdb/coffread.c b/gdb/coffread.c index 921cfce1053..f6bf973e9f7 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1177,7 +1177,7 @@ coff_symtab_read (minimal_symbol_reader &reader, { for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) patch_opaque_types (s); } } diff --git a/gdb/maint.c b/gdb/maint.c index 189b14643a8..f7e1828e281 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -947,8 +947,8 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr, { ++nr_compunit_symtabs; nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu)); - nr_symtabs += std::distance (compunit_filetabs (cu).begin (), - compunit_filetabs (cu).end ()); + nr_symtabs += std::distance (cu->filetabs ().begin (), + cu->filetabs ().end ()); } } } diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 219dd0175cb..d0c7ac83d37 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -651,7 +651,7 @@ objfile_relocate1 (struct objfile *objfile, { for (compunit_symtab *cust : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cust)) + for (symtab *s : cust->filetabs ()) { struct linetable *l; diff --git a/gdb/source.c b/gdb/source.c index 73c1c1d5188..2160619b34f 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -344,7 +344,7 @@ select_source_symtab (struct symtab *s) { for (compunit_symtab *cu : ofp->compunits ()) { - for (symtab *symtab : compunit_filetabs (cu)) + for (symtab *symtab : cu->filetabs ()) { const char *name = symtab->filename; int len = strlen (name); @@ -424,7 +424,7 @@ forget_cached_source_info_for_objfile (struct objfile *objfile) { for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) { if (s->fullname != NULL) { diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 8b57434e84f..b4b58f6e0f5 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -74,7 +74,7 @@ print_objfile_statistics (void) i = linetables = 0; for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) { i++; if (SYMTAB_LINETABLE (s) != NULL) @@ -126,7 +126,7 @@ dump_objfile (struct objfile *objfile) printf_filtered ("Symtabs:\n"); for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *symtab : compunit_filetabs (cu)) + for (symtab *symtab : cu->filetabs ()) { printf_filtered ("%s at %s", symtab_to_filename_for_display (symtab), @@ -469,7 +469,7 @@ maintenance_print_symbols (const char *args, int from_tty) for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) { int print_for_source = 0; @@ -756,7 +756,7 @@ maintenance_info_symtabs (const char *regexp, int from_tty) { int printed_compunit_symtab_start = 0; - for (symtab *symtab : compunit_filetabs (cust)) + for (symtab *symtab : cust->filetabs ()) { QUIT; @@ -1025,7 +1025,7 @@ maintenance_info_line_tables (const char *regexp, int from_tty) { for (compunit_symtab *cust : objfile->compunits ()) { - for (symtab *symtab : compunit_filetabs (cust)) + for (symtab *symtab : cust->filetabs ()) { QUIT; diff --git a/gdb/symtab.c b/gdb/symtab.c index f4f5f09f215..6626ee8d36c 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -367,15 +367,15 @@ compunit_symtab::set_primary_filetab (symtab *primary_filetab) symtab *prev_filetab = nullptr; /* Move PRIMARY_FILETAB to the head of the filetab list. */ - for (symtab *filetab : compunit_filetabs (this)) + for (symtab *filetab : this->filetabs ()) { if (filetab == primary_filetab) { if (prev_filetab != nullptr) { prev_filetab->next = primary_filetab->next; - primary_filetab->next = this->filetabs; - this->filetabs = primary_filetab; + primary_filetab->next = m_filetabs; + m_filetabs = primary_filetab; } break; @@ -384,7 +384,7 @@ compunit_symtab::set_primary_filetab (symtab *primary_filetab) prev_filetab = filetab; } - gdb_assert (primary_filetab == this->filetabs); + gdb_assert (primary_filetab == m_filetabs); } /* See symtab.h. */ @@ -392,10 +392,10 @@ compunit_symtab::set_primary_filetab (symtab *primary_filetab) struct symtab * compunit_symtab::primary_filetab () const { - gdb_assert (this->filetabs != nullptr); + gdb_assert (m_filetabs != nullptr); /* The primary file symtab is the first one in the list. */ - return this->filetabs; + return m_filetabs; } /* See symtab.h. */ @@ -533,7 +533,7 @@ iterate_over_some_symtabs (const char *name, for (cust = first; cust != NULL && cust != after_last; cust = cust->next) { - for (symtab *s : compunit_filetabs (cust)) + for (symtab *s : cust->filetabs ()) { if (compare_filenames_for_search (s->filename, name)) { @@ -3282,7 +3282,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) They all have the same apriori range, that we found was right; but they have different line tables. */ - for (symtab *iter_s : compunit_filetabs (cust)) + for (symtab *iter_s : cust->filetabs ()) { /* Find the best line in this symtab. */ l = SYMTAB_LINETABLE (iter_s); @@ -3483,7 +3483,7 @@ find_line_symtab (struct symtab *sym_tab, int line, { for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) { struct linetable *l; int ind; @@ -4531,7 +4531,7 @@ info_sources_worker (struct ui_out *uiout, for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) { const char *file = symtab_to_filename_for_display (s); const char *fullname = symtab_to_fullname (s); @@ -6190,7 +6190,7 @@ make_source_files_completion_list (const char *text, const char *word) { for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) { if (not_interesting_fname (s->filename)) continue; diff --git a/gdb/symtab.h b/gdb/symtab.h index 23a348a381c..670826dd183 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1401,6 +1401,10 @@ struct symtab char *fullname; }; +/* A range adapter to allowing iterating over all the file tables in a list. */ + +using symtab_range = next_range; + #define SYMTAB_COMPUNIT(symtab) ((symtab)->compunit_symtab) #define SYMTAB_LINETABLE(symtab) ((symtab)->linetable) #define SYMTAB_LANGUAGE(symtab) ((symtab)->language) @@ -1459,17 +1463,22 @@ struct compunit_symtab m_objfile = objfile; } + symtab_range filetabs () const + { + return symtab_range (m_filetabs); + } + void add_filetab (symtab *filetab) { - if (this->filetabs == nullptr) + if (m_filetabs == nullptr) { - this->filetabs = filetab; - this->last_filetab = filetab; + m_filetabs = filetab; + m_last_filetab = filetab; } else { - this->last_filetab->next = filetab; - this->last_filetab = filetab; + m_last_filetab->next = filetab; + m_last_filetab = filetab; } } @@ -1503,14 +1512,14 @@ struct compunit_symtab source file (e.g., .c, .cc) is guaranteed to be first. Each symtab is a file, either the "main" source file (e.g., .c, .cc) or header (e.g., .h). */ - struct symtab *filetabs; + symtab *m_filetabs; /* Last entry in FILETABS list. Subfiles are added to the end of the list so they accumulate in order, with the main source subfile living at the front. The main reason is so that the main source file symtab is at the head of the list, and the rest appear in order for debugging convenience. */ - struct symtab *last_filetab; + symtab *m_last_filetab; /* Non-NULL string that identifies the format of the debugging information, such as "stabs", "dwarf 1", "dwarf 2", "coff", etc. This is mostly useful @@ -1568,7 +1577,7 @@ struct compunit_symtab using compunit_symtab_range = next_range; -#define COMPUNIT_FILETABS(cust) ((cust)->filetabs) +#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) @@ -1578,17 +1587,6 @@ using compunit_symtab_range = next_range; #define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid) #define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table) -/* A range adapter to allowing iterating over all the file tables - within a compunit. */ - -using symtab_range = next_range; - -static inline symtab_range -compunit_filetabs (compunit_symtab *cu) -{ - return symtab_range (cu->filetabs); -} - /* Return the language of CUST. */ extern enum language compunit_language (const struct compunit_symtab *cust);