From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 07/33] gdb: remove COMPUNIT_FILETABS macro
Date: Fri, 28 Jan 2022 07:45:05 -0500 [thread overview]
Message-ID: <20220128124531.2302941-8-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20220128124531.2302941-1-simon.marchi@polymtl.ca>
From: Simon Marchi <simon.marchi@efficios.com>
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
---
gdb/buildsym.c | 4 ++--
gdb/dwarf2/read.c | 8 ++++----
gdb/jit.c | 8 ++++----
gdb/linespec.c | 2 +-
gdb/mdebugread.c | 16 ++++++++--------
gdb/symmisc.c | 7 ++++---
gdb/symtab.h | 3 +--
7 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 914834f8e51f..855d84bd27a6 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 84877e6c7fe0..7e62d11aa2cc 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 42776b956832..007313d3b800 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -500,7 +500,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. */
@@ -512,9 +512,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);
}
@@ -553,7 +553,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 b24cf30dc712..f8b4b86a1e8e 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 1b327ad61153..836da8a3b8ca 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 b4b58f6e0f51..61e3eff562e5 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 670826dd1832..45d4bc4dc299 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1577,7 +1577,6 @@ struct compunit_symtab
using compunit_symtab_range = next_range<compunit_symtab>;
-#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 ();
}
\f
--
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 ` [PATCH 05/33] gdb: add compunit_symtab::set_primary_filetab method Simon Marchi
2022-01-28 12:45 ` [PATCH 06/33] gdb: move compunit_filetabs to compunit_symtab::filetabs Simon Marchi
2022-01-28 12:45 ` Simon Marchi [this message]
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-8-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).