aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2021-11-19 21:18:05 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2022-02-06 15:48:18 -0500
commit102cc23543fc37b42c4814f594f130f862397178 (patch)
tree641e7dce863b6e1aa80b58aafeb5bc2ae862fa49 /gdb
parent36664835fa3f81503633024e0e834be4d84276e1 (diff)
downloadgdb-102cc23543fc37b42c4814f594f130f862397178.zip
gdb-102cc23543fc37b42c4814f594f130f862397178.tar.gz
gdb-102cc23543fc37b42c4814f594f130f862397178.tar.bz2
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
Diffstat (limited to 'gdb')
-rw-r--r--gdb/coffread.c2
-rw-r--r--gdb/maint.c4
-rw-r--r--gdb/objfiles.c2
-rw-r--r--gdb/source.c4
-rw-r--r--gdb/symmisc.c10
-rw-r--r--gdb/symtab.c22
-rw-r--r--gdb/symtab.h36
7 files changed, 39 insertions, 41 deletions
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 921cfce..f6bf973 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 189b146..f7e1828 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 219dd01..d0c7ac8 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 73c1c1d..2160619 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 8b57434..b4b58f6 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 f4f5f09..6626ee8 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 23a348a..670826d 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<symtab>;
+
#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<compunit_symtab>;
-#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<compunit_symtab>;
#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<symtab>;
-
-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);