[binutils-gdb] gdb: add compunit_symtab::set_primary_filetab method
Simon Marchi
simark@sourceware.org
Sun Feb 6 21:08:57 GMT 2022
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=36664835fa3f81503633024e0e834be4d84276e1
commit 36664835fa3f81503633024e0e834be4d84276e1
Author: Simon Marchi <simon.marchi@efficios.com>
Date: Fri Nov 19 21:14:36 2021 -0500
gdb: add compunit_symtab::set_primary_filetab method
Add a method to set the primary filetab of the CU. This is currently
done in buildsym_compunit::end_symtab_with_blockvector.
Change-Id: I16c51a6b90a4cb4c0c5f183b0f2e12bc64b6fd74
Diff:
---
gdb/buildsym.c | 24 ++----------------------
gdb/symtab.c | 28 ++++++++++++++++++++++++++++
gdb/symtab.h | 6 ++++++
3 files changed, 36 insertions(+), 22 deletions(-)
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 1754f5ffe6e..914834f8e51 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -996,28 +996,8 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
symtab->language = subfile->language;
}
- /* Make sure the symtab of main_subfile is the first in its list. */
- {
- struct symtab *main_symtab, *prev_symtab;
-
- main_symtab = m_main_subfile->symtab;
- prev_symtab = NULL;
- for (symtab *symtab : compunit_filetabs (cu))
- {
- if (symtab == main_symtab)
- {
- if (prev_symtab != NULL)
- {
- prev_symtab->next = main_symtab->next;
- main_symtab->next = COMPUNIT_FILETABS (cu);
- COMPUNIT_FILETABS (cu) = main_symtab;
- }
- break;
- }
- prev_symtab = symtab;
- }
- gdb_assert (main_symtab == COMPUNIT_FILETABS (cu));
- }
+ /* Make sure the filetab of main_subfile is the primary filetab of the CU. */
+ cu->set_primary_filetab (m_main_subfile->symtab);
/* Fill out the compunit symtab. */
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 2028e837f0f..f4f5f09f215 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -361,6 +361,34 @@ compunit_symtab::set_call_site_htab (htab_t call_site_htab)
/* See symtab.h. */
+void
+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))
+ {
+ if (filetab == primary_filetab)
+ {
+ if (prev_filetab != nullptr)
+ {
+ prev_filetab->next = primary_filetab->next;
+ primary_filetab->next = this->filetabs;
+ this->filetabs = primary_filetab;
+ }
+
+ break;
+ }
+
+ prev_filetab = filetab;
+ }
+
+ gdb_assert (primary_filetab == this->filetabs);
+}
+
+/* See symtab.h. */
+
struct symtab *
compunit_symtab::primary_filetab () const
{
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 3fa4d5f5d0e..23a348a381c 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1473,6 +1473,12 @@ struct compunit_symtab
}
}
+ /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
+
+ PRIMARY_FILETAB must already be a filetab of this compunit symtab. */
+
+ void set_primary_filetab (symtab *primary_filetab);
+
/* Return the primary filetab of the compunit. */
symtab *primary_filetab () const;
More information about the Gdb-cvs
mailing list