From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 05/33] gdb: add compunit_symtab::set_primary_filetab method
Date: Fri, 28 Jan 2022 07:45:03 -0500 [thread overview]
Message-ID: <20220128124531.2302941-6-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20220128124531.2302941-1-simon.marchi@polymtl.ca>
From: Simon Marchi <simon.marchi@efficios.com>
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
---
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 1754f5ffe6ed..914834f8e51f 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 2028e837f0f1..f4f5f09f215a 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 3fa4d5f5d0eb..23a348a381ce 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;
--
2.34.1
next prev parent reply other threads:[~2022-01-28 12:45 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi
2022-01-28 12:44 ` [PATCH 01/33] gdb: add getter/setter for compunit_symtab::objfile Simon Marchi
2022-01-28 12:45 ` [PATCH 02/33] gdb: remove COMPUNIT_OBJFILE macro Simon Marchi
2022-01-28 12:45 ` [PATCH 03/33] gdb: rename compunit_primary_filetab to compunit_symtab::primary_filetab Simon Marchi
2022-01-28 12:45 ` [PATCH 04/33] gdb: add compunit_symtab::add_filetab method Simon Marchi
2022-01-28 12:45 ` Simon Marchi [this message]
2022-01-28 12:45 ` [PATCH 06/33] gdb: move compunit_filetabs to compunit_symtab::filetabs Simon Marchi
2022-01-28 12:45 ` [PATCH 07/33] gdb: remove COMPUNIT_FILETABS macro Simon Marchi
2022-01-28 12:45 ` [PATCH 08/33] gdb: remove COMPUNIT_DEBUGFORMAT macro, add getter/setter Simon Marchi
2022-01-28 12:45 ` [PATCH 09/33] gdb: remove COMPUNIT_PRODUCER " Simon Marchi
2022-01-28 12:45 ` [PATCH 10/33] gdb: remove COMPUNIT_DIRNAME " Simon Marchi
2022-01-28 12:45 ` [PATCH 11/33] gdb: remove COMPUNIT_BLOCKVECTOR " Simon Marchi
2022-01-28 12:45 ` [PATCH 12/33] gdb: remove COMPUNIT_BLOCK_LINE_SECTION " Simon Marchi
2022-01-28 12:45 ` [PATCH 13/33] gdb: remove COMPUNIT_LOCATIONS_VALID " Simon Marchi
2022-01-28 12:45 ` [PATCH 14/33] gdb: remove COMPUNIT_EPILOGUE_UNWIND_VALID " Simon Marchi
2022-01-28 12:45 ` [PATCH 15/33] gdb: remove COMPUNIT_MACRO_TABLE " Simon Marchi
2022-01-28 12:45 ` [PATCH 16/33] gdb: remove SYMTAB_COMPUNIT " Simon Marchi
2022-01-28 12:45 ` [PATCH 17/33] gdb: remove SYMTAB_LINETABLE " Simon Marchi
2022-01-28 12:45 ` [PATCH 18/33] gdb: remove SYMTAB_LANGUAGE " Simon Marchi
2022-01-28 12:45 ` [PATCH 19/33] gdb: remove SYMTAB_BLOCKVECTOR macro Simon Marchi
2022-01-28 12:45 ` [PATCH 20/33] gdb: remove SYMTAB_OBJFILE macro Simon Marchi
2022-01-28 12:45 ` [PATCH 21/33] gdb: remove SYMTAB_PSPACE macro Simon Marchi
2022-01-28 12:45 ` [PATCH 22/33] gdb: remove SYMTAB_DIRNAME macro Simon Marchi
2022-01-28 12:45 ` [PATCH 23/33] gdb: remove SYMBOL_MATCHES_SEARCH_NAME Simon Marchi
2022-01-28 12:45 ` [PATCH 24/33] gdb: remove SYMBOL_ACLASS_INDEX macro, add getter/setter Simon Marchi
2022-01-28 12:45 ` [PATCH 25/33] gdb: remove SYMBOL_IMPL macro, add method Simon Marchi
2022-01-28 12:45 ` [PATCH 26/33] gdb: remove SYMBOL_CLASS macro, add getter Simon Marchi
2022-01-28 12:45 ` [PATCH 27/33] gdb: remove SYMBOL_DOMAIN macro Simon Marchi
2022-01-28 12:45 ` [PATCH 28/33] gdb: remove SYMBOL_OBJFILE_OWNED macro Simon Marchi
2022-01-28 12:45 ` [PATCH 29/33] gdb: remove SYMBOL_IS_ARGUMENT macro Simon Marchi
2022-01-28 12:45 ` [PATCH 30/33] gdb: remove SYMBOL_INLINED macro Simon Marchi
2022-01-28 12:45 ` [PATCH 31/33] gdb: remote SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION macro Simon Marchi
2022-01-28 12:45 ` [PATCH 32/33] gdb: remove SYMBOL_TYPE macro Simon Marchi
2022-01-28 12:45 ` [PATCH 33/33] gdb: remove SYMBOL_LINE macro Simon Marchi
2022-02-06 15:22 ` [PATCH 00/33] Remove some more accessor macros Joel Brobecker
2022-02-06 21:07 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220128124531.2302941-6-simon.marchi@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).