This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA 34/42] Add many methods to buildsym_compunit
- From: Tom Tromey <tom at tromey dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>
- Date: Tue, 22 May 2018 22:58:43 -0600
- Subject: [RFA 34/42] Add many methods to buildsym_compunit
- References: <20180523045851.11660-1-tom@tromey.com>
This adds many methods to buildsym_compunit and makes the data members
private. Essentially the entire buildsym API is now available as a
method on buildsym_compunit. However, standalone functions are still
provided, as this is what the sybmol readers actually use.
gdb/ChangeLog
2018-05-22 Tom Tromey <tom@tromey.com>
* buildsym.c (buildsym_compunit::buildsym_compunit): Do more
initialization.
(buildsym_compunit): Add new constructor.
(struct buildsym_compunit) <get_last_source_file, finish_block,
record_block_range, start_subfile, patch_subfile_names,
push_subfile, pop_subfile, record_line, get_compunit_symtab,
set_last_source_start_addr, get_last_source_start_addr,
get_local_using_directives, set_local_using_directives,
get_global_using_directives, outermost_context_p,
get_current_context_stack, get_context_stack_depth,
get_current_subfile, get_local_symbols, get_file_symbols,
get_global_symbols, record_debugformat, record_producer,
push_context, pop_context, end_symtab_get_static_block,
end_symtab_from_static_block, end_symtab, end_expandable_symtab>:
New public methods.
<record_pending_block, finish_block_internal, make_blockvector,
watch_main_source_file_lossage, end_symtab_with_blockvector>: New
private methods.
Update all users.
---
gdb/ChangeLog | 22 +++
gdb/buildsym.c | 610 +++++++++++++++++++++++++++++++++++++++------------------
2 files changed, 444 insertions(+), 188 deletions(-)
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index c965776d82..b9be6dd61a 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -103,6 +103,32 @@ struct buildsym_compunit
language (language_),
m_last_source_start_addr (last_addr)
{
+ /* Allocate the compunit symtab now. The caller needs it to allocate
+ non-primary symtabs. It is also needed by get_macro_table. */
+ compunit_symtab = allocate_compunit_symtab (objfile, name);
+
+ /* Build the subfile for NAME (the main source file) so that we can record
+ a pointer to it for later.
+ IMPORTANT: Do not allocate a struct symtab for NAME here.
+ It can happen that the debug info provides a different path to NAME than
+ DIRNAME,NAME. We cope with this in watch_main_source_file_lossage but
+ that only works if the main_subfile doesn't have a symtab yet. */
+ start_subfile (name);
+ /* Save this so that we don't have to go looking for it at the end
+ of the subfiles list. */
+ main_subfile = m_current_subfile;
+ }
+
+ buildsym_compunit (struct objfile *objfile_, const char *name,
+ const char *comp_dir_, enum language language_,
+ CORE_ADDR last_addr, struct compunit_symtab *cust)
+ : objfile (objfile_),
+ m_last_source_file (name == nullptr ? nullptr : xstrdup (name)),
+ comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
+ compunit_symtab (cust),
+ language (language_),
+ m_last_source_start_addr (last_addr)
+ {
}
~buildsym_compunit ()
@@ -143,6 +169,11 @@ struct buildsym_compunit
m_last_source_file.reset (new_name);
}
+ const char *get_last_source_file ()
+ {
+ return m_last_source_file.get ();
+ }
+
struct macro_table *get_macro_table ()
{
if (m_pending_macros == nullptr)
@@ -167,6 +198,136 @@ struct buildsym_compunit
m_pending_blocks = nullptr;
}
+ struct block *finish_block (struct symbol *symbol,
+ struct pending_block *old_blocks,
+ const struct dynamic_prop *static_link,
+ CORE_ADDR start, CORE_ADDR end);
+
+ void record_block_range (struct block *block,
+ CORE_ADDR start, CORE_ADDR end_inclusive);
+
+ void start_subfile (const char *name);
+
+ void patch_subfile_names (struct subfile *subfile, const char *name);
+
+ void push_subfile ();
+
+ const char *pop_subfile ();
+
+ void record_line (struct subfile *subfile, int line, CORE_ADDR pc);
+
+ struct compunit_symtab *get_compunit_symtab ()
+ {
+ return compunit_symtab;
+ }
+
+ void set_last_source_start_addr (CORE_ADDR addr)
+ {
+ m_last_source_start_addr = addr;
+ }
+
+ CORE_ADDR get_last_source_start_addr ()
+ {
+ return m_last_source_start_addr;
+ }
+
+ struct using_direct **get_local_using_directives ()
+ {
+ return &m_local_using_directives;
+ }
+
+ void set_local_using_directives (struct using_direct *new_local)
+ {
+ m_local_using_directives = new_local;
+ }
+
+ struct using_direct **get_global_using_directives ()
+ {
+ return &m_global_using_directives;
+ }
+
+ bool outermost_context_p () const
+ {
+ return m_context_stack.empty ();
+ }
+
+ struct context_stack *get_current_context_stack ()
+ {
+ if (m_context_stack.empty ())
+ return nullptr;
+ return &m_context_stack.back ();
+ }
+
+ int get_context_stack_depth () const
+ {
+ return m_context_stack.size ();
+ }
+
+ struct subfile *get_current_subfile ()
+ {
+ return m_current_subfile;
+ }
+
+ struct pending **get_local_symbols ()
+ {
+ return &m_local_symbols;
+ }
+
+ struct pending **get_file_symbols ()
+ {
+ return &m_file_symbols;
+ }
+
+ struct pending **get_global_symbols ()
+ {
+ return &m_global_symbols;
+ }
+
+ void record_debugformat (const char *format)
+ {
+ debugformat = format;
+ }
+
+ void record_producer (const char *producer)
+ {
+ this->producer = producer;
+ }
+
+ struct context_stack *push_context (int desc, CORE_ADDR valu);
+
+ struct context_stack *pop_context ();
+
+ struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
+ int expandable, int required);
+
+ struct compunit_symtab *end_symtab_from_static_block
+ (struct block *static_block, int section, int expandable);
+
+ struct compunit_symtab *end_symtab (CORE_ADDR end_addr, int section);
+
+ struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
+ int section);
+
+ void augment_type_symtab ();
+
+private:
+
+ void record_pending_block (struct block *block, struct pending_block *opblock);
+
+ struct block *finish_block_internal (struct symbol *symbol,
+ struct pending **listhead,
+ struct pending_block *old_blocks,
+ const struct dynamic_prop *static_link,
+ CORE_ADDR start, CORE_ADDR end,
+ int is_global, int expandable);
+
+ struct blockvector *make_blockvector ();
+
+ void watch_main_source_file_lossage ();
+
+ struct compunit_symtab *end_symtab_with_blockvector
+ (struct block *static_block, int section, int expandable);
+
/* The objfile we're reading debug info from. */
struct objfile *objfile;
@@ -366,13 +527,13 @@ scoped_free_pendings::~scoped_free_pendings ()
OPBLOCK, or at the beginning if opblock is NULL. This puts the
block in the list after all its subblocks. */
-static void
-record_pending_block (struct block *block, struct pending_block *opblock)
+void
+buildsym_compunit::record_pending_block (struct block *block,
+ struct pending_block *opblock)
{
struct pending_block *pblock;
- pblock = XOBNEW (&buildsym_compunit->m_pending_block_obstack,
- struct pending_block);
+ pblock = XOBNEW (&m_pending_block_obstack, struct pending_block);
pblock->block = block;
if (opblock)
{
@@ -381,8 +542,8 @@ record_pending_block (struct block *block, struct pending_block *opblock)
}
else
{
- pblock->next = buildsym_compunit->m_pending_blocks;
- buildsym_compunit->m_pending_blocks = pblock;
+ pblock->next = m_pending_blocks;
+ m_pending_blocks = pblock;
}
}
@@ -390,15 +551,15 @@ record_pending_block (struct block *block, struct pending_block *opblock)
the order the symbols have in the list (reversed from the input
file). Put the block on the list of pending blocks. */
-static struct block *
-finish_block_internal (struct symbol *symbol,
- struct pending **listhead,
- struct pending_block *old_blocks,
- const struct dynamic_prop *static_link,
- CORE_ADDR start, CORE_ADDR end,
- int is_global, int expandable)
+struct block *
+buildsym_compunit::finish_block_internal
+ (struct symbol *symbol,
+ struct pending **listhead,
+ struct pending_block *old_blocks,
+ const struct dynamic_prop *static_link,
+ CORE_ADDR start, CORE_ADDR end,
+ int is_global, int expandable)
{
- struct objfile *objfile = buildsym_compunit->objfile;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct pending *next, *next1;
struct block *block;
@@ -413,21 +574,20 @@ finish_block_internal (struct symbol *symbol,
{
BLOCK_DICT (block)
= dict_create_linear (&objfile->objfile_obstack,
- buildsym_compunit->language, *listhead);
+ language, *listhead);
}
else
{
if (expandable)
{
- BLOCK_DICT (block)
- = dict_create_hashed_expandable (buildsym_compunit->language);
+ BLOCK_DICT (block) = dict_create_hashed_expandable (language);
dict_add_pending (BLOCK_DICT (block), *listhead);
}
else
{
BLOCK_DICT (block) =
dict_create_hashed (&objfile->objfile_obstack,
- buildsym_compunit->language, *listhead);
+ language, *listhead);
}
}
@@ -527,7 +687,7 @@ finish_block_internal (struct symbol *symbol,
start of this scope that don't have superblocks yet. */
opblock = NULL;
- for (pblock = buildsym_compunit->m_pending_blocks;
+ for (pblock = m_pending_blocks;
pblock && pblock != old_blocks;
pblock = pblock->next)
{
@@ -572,13 +732,13 @@ finish_block_internal (struct symbol *symbol,
block_set_using (block,
(is_global
- ? buildsym_compunit->m_global_using_directives
- : buildsym_compunit->m_local_using_directives),
+ ? m_global_using_directives
+ : m_local_using_directives),
&objfile->objfile_obstack);
if (is_global)
- buildsym_compunit->m_global_using_directives = NULL;
+ m_global_using_directives = NULL;
else
- buildsym_compunit->m_local_using_directives = NULL;
+ m_local_using_directives = NULL;
record_pending_block (block, opblock);
@@ -586,14 +746,13 @@ finish_block_internal (struct symbol *symbol,
}
struct block *
-finish_block (struct symbol *symbol,
- struct pending_block *old_blocks,
- const struct dynamic_prop *static_link,
- CORE_ADDR start, CORE_ADDR end)
+buildsym_compunit::finish_block (struct symbol *symbol,
+ struct pending_block *old_blocks,
+ const struct dynamic_prop *static_link,
+ CORE_ADDR start, CORE_ADDR end)
{
- return finish_block_internal (symbol, &buildsym_compunit->m_local_symbols,
- old_blocks, static_link,
- start, end, 0, 0);
+ return finish_block_internal (symbol, &m_local_symbols,
+ old_blocks, static_link, start, end, 0, 0);
}
/* Record that the range of addresses from START to END_INCLUSIVE
@@ -605,8 +764,9 @@ finish_block (struct symbol *symbol,
already provided by BLOCK_START and BLOCK_END, then we create an
address map for the block. */
void
-record_block_range (struct block *block,
- CORE_ADDR start, CORE_ADDR end_inclusive)
+buildsym_compunit::record_block_range (struct block *block,
+ CORE_ADDR start,
+ CORE_ADDR end_inclusive)
{
/* If this is any different from the range recorded in the block's
own BLOCK_START and BLOCK_END, then note that the address map has
@@ -615,29 +775,24 @@ record_block_range (struct block *block,
need to record this block in the addrmap. */
if (start != BLOCK_START (block)
|| end_inclusive + 1 != BLOCK_END (block))
- buildsym_compunit->m_pending_addrmap_interesting = true;
+ m_pending_addrmap_interesting = true;
- if (! buildsym_compunit->m_pending_addrmap)
- buildsym_compunit->m_pending_addrmap
- = addrmap_create_mutable (&buildsym_compunit->m_pending_addrmap_obstack);
+ if (! m_pending_addrmap)
+ m_pending_addrmap = addrmap_create_mutable (&m_pending_addrmap_obstack);
- addrmap_set_empty (buildsym_compunit->m_pending_addrmap,
- start, end_inclusive, block);
+ addrmap_set_empty (m_pending_addrmap, start, end_inclusive, block);
}
-static struct blockvector *
-make_blockvector (void)
+struct blockvector *
+buildsym_compunit::make_blockvector ()
{
- struct objfile *objfile = buildsym_compunit->objfile;
struct pending_block *next;
struct blockvector *blockvector;
int i;
/* Count the length of the list of blocks. */
- for (next = buildsym_compunit->m_pending_blocks, i = 0;
- next;
- next = next->next, i++)
+ for (next = m_pending_blocks, i = 0; next; next = next->next, i++)
{
}
@@ -653,20 +808,18 @@ make_blockvector (void)
sure this is true. */
BLOCKVECTOR_NBLOCKS (blockvector) = i;
- for (next = buildsym_compunit->m_pending_blocks; next; next = next->next)
+ for (next = m_pending_blocks; next; next = next->next)
{
BLOCKVECTOR_BLOCK (blockvector, --i) = next->block;
}
- buildsym_compunit->free_pending_blocks ();
+ free_pending_blocks ();
/* If we needed an address map for this symtab, record it in the
blockvector. */
- if (buildsym_compunit->m_pending_addrmap
- && buildsym_compunit->m_pending_addrmap_interesting)
+ if (m_pending_addrmap && m_pending_addrmap_interesting)
BLOCKVECTOR_MAP (blockvector)
- = addrmap_create_fixed (buildsym_compunit->m_pending_addrmap,
- &objfile->objfile_obstack);
+ = addrmap_create_fixed (m_pending_addrmap, &objfile->objfile_obstack);
else
BLOCKVECTOR_MAP (blockvector) = 0;
@@ -700,18 +853,16 @@ make_blockvector (void)
name. NAME is the name of the file (cannot be NULL). */
void
-start_subfile (const char *name)
+buildsym_compunit::start_subfile (const char *name)
{
const char *subfile_dirname;
struct subfile *subfile;
- gdb_assert (buildsym_compunit != NULL);
-
- subfile_dirname = buildsym_compunit->comp_dir.get ();
+ subfile_dirname = comp_dir.get ();
/* See if this subfile is already registered. */
- for (subfile = buildsym_compunit->subfiles; subfile; subfile = subfile->next)
+ for (subfile = subfiles; subfile; subfile = subfile->next)
{
char *subfile_name;
@@ -727,7 +878,7 @@ start_subfile (const char *name)
if (FILENAME_CMP (subfile_name, name) == 0)
{
- buildsym_compunit->m_current_subfile = subfile;
+ m_current_subfile = subfile;
if (subfile_name != subfile->name)
xfree (subfile_name);
return;
@@ -740,12 +891,12 @@ start_subfile (const char *name)
subfile = XNEW (struct subfile);
memset (subfile, 0, sizeof (struct subfile));
- subfile->buildsym_compunit = buildsym_compunit;
+ subfile->buildsym_compunit = this;
- subfile->next = buildsym_compunit->subfiles;
- buildsym_compunit->subfiles = subfile;
+ subfile->next = subfiles;
+ subfiles = subfile;
- buildsym_compunit->m_current_subfile = subfile;
+ m_current_subfile = subfile;
subfile->name = xstrdup (name);
@@ -781,7 +932,7 @@ start_subfile (const char *name)
enum language sublang = deduce_language_from_filename (subfile->name);
if (sublang == language_cplus || sublang == language_fortran)
- for (s = buildsym_compunit->subfiles; s != NULL; s = s->next)
+ for (s = subfiles; s != NULL; s = s->next)
if (s->language == language_c)
s->language = sublang;
}
@@ -820,14 +971,15 @@ free_buildsym_compunit (void)
directory name actually is (by checking for a trailing '/'). */
void
-patch_subfile_names (struct subfile *subfile, const char *name)
+buildsym_compunit::patch_subfile_names (struct subfile *subfile,
+ const char *name)
{
if (subfile != NULL
- && buildsym_compunit->comp_dir == NULL
+ && comp_dir == NULL
&& subfile->name != NULL
&& IS_DIR_SEPARATOR (subfile->name[strlen (subfile->name) - 1]))
{
- buildsym_compunit->comp_dir.reset (subfile->name);
+ comp_dir.reset (subfile->name);
subfile->name = xstrdup (name);
set_last_source_file (name);
@@ -857,22 +1009,19 @@ patch_subfile_names (struct subfile *subfile, const char *name)
order. */
void
-push_subfile ()
+buildsym_compunit::push_subfile ()
{
- gdb_assert (buildsym_compunit != nullptr);
- gdb_assert (! (buildsym_compunit->m_current_subfile == NULL
- || buildsym_compunit->m_current_subfile->name == NULL));
- buildsym_compunit->m_subfile_stack.push_back
- (buildsym_compunit->m_current_subfile->name);
+ gdb_assert (! (m_current_subfile == NULL
+ || m_current_subfile->name == NULL));
+ m_subfile_stack.push_back (m_current_subfile->name);
}
const char *
-pop_subfile ()
+buildsym_compunit::pop_subfile ()
{
- gdb_assert (buildsym_compunit != nullptr);
- gdb_assert (!buildsym_compunit->m_subfile_stack.empty ());
- const char *name = buildsym_compunit->m_subfile_stack.back ();
- buildsym_compunit->m_subfile_stack.pop_back ();
+ gdb_assert (!m_subfile_stack.empty ());
+ const char *name = m_subfile_stack.back ();
+ m_subfile_stack.pop_back ();
return name;
}
@@ -880,7 +1029,8 @@ pop_subfile ()
line vector for SUBFILE. */
void
-record_line (struct subfile *subfile, int line, CORE_ADDR pc)
+buildsym_compunit::record_line (struct subfile *subfile, int line,
+ CORE_ADDR pc)
{
struct linetable_entry *e;
@@ -898,7 +1048,7 @@ record_line (struct subfile *subfile, int line, CORE_ADDR pc)
xmalloc (sizeof (struct linetable)
+ subfile->line_vector_length * sizeof (struct linetable_entry));
subfile->line_vector->nitems = 0;
- buildsym_compunit->m_have_line_numbers = true;
+ m_have_line_numbers = true;
}
if (subfile->line_vector->nitems + 1 >= subfile->line_vector_length)
@@ -967,7 +1117,7 @@ buildsym_compunit_symtab (void)
{
gdb_assert (buildsym_compunit != NULL);
- return buildsym_compunit->compunit_symtab;
+ return buildsym_compunit->get_compunit_symtab ();
}
/* See buildsym.h. */
@@ -1004,23 +1154,7 @@ start_symtab (struct objfile *objfile, const char *name, const char *comp_dir,
buildsym_compunit = new struct buildsym_compunit (objfile, name, comp_dir,
language, start_addr);
- /* Allocate the compunit symtab now. The caller needs it to allocate
- non-primary symtabs. It is also needed by get_macro_table. */
- buildsym_compunit->compunit_symtab = allocate_compunit_symtab (objfile,
- name);
-
- /* Build the subfile for NAME (the main source file) so that we can record
- a pointer to it for later.
- IMPORTANT: Do not allocate a struct symtab for NAME here.
- It can happen that the debug info provides a different path to NAME than
- DIRNAME,NAME. We cope with this in watch_main_source_file_lossage but
- that only works if the main_subfile doesn't have a symtab yet. */
- start_subfile (name);
- /* Save this so that we don't have to go looking for it at the end
- of the subfiles list. */
- buildsym_compunit->main_subfile = buildsym_compunit->m_current_subfile;
-
- return buildsym_compunit->compunit_symtab;
+ return buildsym_compunit->get_compunit_symtab ();
}
/* Restart compilation for a symtab.
@@ -1045,8 +1179,8 @@ restart_symtab (struct compunit_symtab *cust,
name,
COMPUNIT_DIRNAME (cust),
compunit_language (cust),
- start_addr);
- buildsym_compunit->compunit_symtab = cust;
+ start_addr,
+ cust);
}
/* Subroutine of end_symtab to simplify it. Look for a subfile that
@@ -1059,18 +1193,13 @@ restart_symtab (struct compunit_symtab *cust,
manipulates the debug info. This can also happen from an innocent
symlink in the paths, we don't canonicalize paths here. */
-static void
-watch_main_source_file_lossage (void)
+void
+buildsym_compunit::watch_main_source_file_lossage ()
{
struct subfile *mainsub, *subfile;
- /* We have to watch for buildsym_compunit == NULL here. It's a quirk of
- end_symtab, it can return NULL so there may not be a main subfile. */
- if (buildsym_compunit == NULL)
- return;
-
/* Get the main source file. */
- mainsub = buildsym_compunit->main_subfile;
+ mainsub = main_subfile;
/* If the main source file doesn't have any line number or symbol
info, look for an alias in another subfile. */
@@ -1085,7 +1214,7 @@ watch_main_source_file_lossage (void)
struct subfile *prev_mainsub_alias = NULL;
prevsub = NULL;
- for (subfile = buildsym_compunit->subfiles;
+ for (subfile = subfiles;
subfile != NULL;
subfile = subfile->next)
{
@@ -1113,7 +1242,7 @@ watch_main_source_file_lossage (void)
mainsub->symtab = mainsub_alias->symtab;
if (prev_mainsub_alias == NULL)
- buildsym_compunit->subfiles = mainsub_alias->next;
+ subfiles = mainsub_alias->next;
else
prev_mainsub_alias->next = mainsub_alias->next;
xfree (mainsub_alias->name);
@@ -1145,14 +1274,13 @@ reset_symtab_globals (void)
not contain any symbols. */
struct block *
-end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
+buildsym_compunit::end_symtab_get_static_block (CORE_ADDR end_addr,
+ int expandable, int required)
{
- struct objfile *objfile = buildsym_compunit->objfile;
-
/* Finish the lexical context of the last function in the file; pop
the context stack. */
- if (!buildsym_compunit->m_context_stack.empty ())
+ if (!m_context_stack.empty ())
{
struct context_stack *cstk = pop_context ();
@@ -1160,7 +1288,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
finish_block (cstk->name, cstk->old_blocks, NULL,
cstk->start_addr, end_addr);
- if (!buildsym_compunit->m_context_stack.empty ())
+ if (!m_context_stack.empty ())
{
/* This is said to happen with SCO. The old coffread.c
code simply emptied the context stack, so we do the
@@ -1169,20 +1297,20 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
it used to be an abort(). */
complaint (&symfile_complaints,
_("Context stack not empty in end_symtab"));
- buildsym_compunit->m_context_stack.clear ();
+ m_context_stack.clear ();
}
}
/* Reordered executables may have out of order pending blocks; if
OBJF_REORDERED is true, then sort the pending blocks. */
- if ((objfile->flags & OBJF_REORDERED) && buildsym_compunit->m_pending_blocks)
+ if ((objfile->flags & OBJF_REORDERED) && m_pending_blocks)
{
struct pending_block *pb;
std::vector<block *> barray;
- for (pb = buildsym_compunit->m_pending_blocks; pb != NULL; pb = pb->next)
+ for (pb = m_pending_blocks; pb != NULL; pb = pb->next)
barray.push_back (pb->block);
/* Sort blocks by start address in descending order. Blocks with the
@@ -1195,7 +1323,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
});
int i = 0;
- for (pb = buildsym_compunit->m_pending_blocks; pb != NULL; pb = pb->next)
+ for (pb = m_pending_blocks; pb != NULL; pb = pb->next)
pb->block = barray[i++];
}
@@ -1213,12 +1341,12 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
finish_global_stabs (objfile);
if (!required
- && buildsym_compunit->m_pending_blocks == NULL
- && buildsym_compunit->m_file_symbols == NULL
- && buildsym_compunit->m_global_symbols == NULL
- && buildsym_compunit->m_have_line_numbers == 0
- && buildsym_compunit->m_pending_macros == NULL
- && buildsym_compunit->m_global_using_directives == NULL)
+ && m_pending_blocks == NULL
+ && m_file_symbols == NULL
+ && m_global_symbols == NULL
+ && m_have_line_numbers == 0
+ && m_pending_macros == NULL
+ && m_global_using_directives == NULL)
{
/* Ignore symtabs that have no functions with real debugging info. */
return NULL;
@@ -1227,7 +1355,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
{
/* Define the STATIC_BLOCK. */
return finish_block_internal (NULL, get_file_symbols (), NULL, NULL,
- buildsym_compunit->m_last_source_start_addr,
+ m_last_source_start_addr,
end_addr, 0, expandable);
}
}
@@ -1236,26 +1364,24 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
Handle the "have blockvector" case.
See end_symtab_from_static_block for a description of the arguments. */
-static struct compunit_symtab *
-end_symtab_with_blockvector (struct block *static_block,
- int section, int expandable)
+struct compunit_symtab *
+buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
+ int section, int expandable)
{
- struct objfile *objfile = buildsym_compunit->objfile;
- struct compunit_symtab *cu = buildsym_compunit->compunit_symtab;
+ struct compunit_symtab *cu = compunit_symtab;
struct symtab *symtab;
struct blockvector *blockvector;
struct subfile *subfile;
CORE_ADDR end_addr;
gdb_assert (static_block != NULL);
- gdb_assert (buildsym_compunit != NULL);
- gdb_assert (buildsym_compunit->subfiles != NULL);
+ gdb_assert (subfiles != NULL);
end_addr = BLOCK_END (static_block);
/* Create the GLOBAL_BLOCK and build the blockvector. */
finish_block_internal (NULL, get_global_symbols (), NULL, NULL,
- buildsym_compunit->m_last_source_start_addr, end_addr,
+ m_last_source_start_addr, end_addr,
1, expandable);
blockvector = make_blockvector ();
@@ -1272,7 +1398,7 @@ end_symtab_with_blockvector (struct block *static_block,
/* Now create the symtab objects proper, if not already done,
one for each subfile. */
- for (subfile = buildsym_compunit->subfiles;
+ for (subfile = subfiles;
subfile != NULL;
subfile = subfile->next)
{
@@ -1325,7 +1451,7 @@ end_symtab_with_blockvector (struct block *static_block,
{
struct symtab *main_symtab, *prev_symtab;
- main_symtab = buildsym_compunit->main_subfile->symtab;
+ main_symtab = main_subfile->symtab;
prev_symtab = NULL;
ALL_COMPUNIT_FILETABS (cu, symtab)
{
@@ -1346,20 +1472,20 @@ end_symtab_with_blockvector (struct block *static_block,
/* Fill out the compunit symtab. */
- if (buildsym_compunit->comp_dir != NULL)
+ if (comp_dir != NULL)
{
/* Reallocate the dirname on the symbol obstack. */
- const char *comp_dir = buildsym_compunit->comp_dir.get ();
+ const char *comp_dir = this->comp_dir.get ();
COMPUNIT_DIRNAME (cu)
= (const char *) obstack_copy0 (&objfile->objfile_obstack,
comp_dir, strlen (comp_dir));
}
/* Save the debug format string (if any) in the symtab. */
- COMPUNIT_DEBUGFORMAT (cu) = buildsym_compunit->debugformat;
+ COMPUNIT_DEBUGFORMAT (cu) = debugformat;
/* Similarly for the producer. */
- COMPUNIT_PRODUCER (cu) = buildsym_compunit->producer;
+ COMPUNIT_PRODUCER (cu) = producer;
COMPUNIT_BLOCKVECTOR (cu) = blockvector;
{
@@ -1370,7 +1496,7 @@ end_symtab_with_blockvector (struct block *static_block,
COMPUNIT_BLOCK_LINE_SECTION (cu) = section;
- COMPUNIT_MACRO_TABLE (cu) = buildsym_compunit->release_macros ();
+ COMPUNIT_MACRO_TABLE (cu) = release_macros ();
/* Default any symbols without a specified symtab to the primary symtab. */
{
@@ -1415,8 +1541,8 @@ end_symtab_with_blockvector (struct block *static_block,
expandable. */
struct compunit_symtab *
-end_symtab_from_static_block (struct block *static_block,
- int section, int expandable)
+buildsym_compunit::end_symtab_from_static_block (struct block *static_block,
+ int section, int expandable)
{
struct compunit_symtab *cu;
@@ -1463,7 +1589,7 @@ end_symtab_from_static_block (struct block *static_block,
yourself. */
struct compunit_symtab *
-end_symtab (CORE_ADDR end_addr, int section)
+buildsym_compunit::end_symtab (CORE_ADDR end_addr, int section)
{
struct block *static_block;
@@ -1474,7 +1600,7 @@ end_symtab (CORE_ADDR end_addr, int section)
/* Same as end_symtab except create a symtab that can be later added to. */
struct compunit_symtab *
-end_expandable_symtab (CORE_ADDR end_addr, int section)
+buildsym_compunit::end_expandable_symtab (CORE_ADDR end_addr, int section)
{
struct block *static_block;
@@ -1508,19 +1634,19 @@ set_missing_symtab (struct pending *pending_list,
This is the case for DWARF4 Type Units. */
void
-augment_type_symtab (void)
+buildsym_compunit::augment_type_symtab ()
{
- struct compunit_symtab *cust = buildsym_compunit->compunit_symtab;
+ struct compunit_symtab *cust = compunit_symtab;
const struct blockvector *blockvector = COMPUNIT_BLOCKVECTOR (cust);
- if (!buildsym_compunit->m_context_stack.empty ())
+ if (!m_context_stack.empty ())
complaint (&symfile_complaints,
_("Context stack not empty in augment_type_symtab"));
- if (buildsym_compunit->m_pending_blocks != NULL)
+ if (m_pending_blocks != NULL)
complaint (&symfile_complaints, _("Blocks in a type symtab"));
- if (buildsym_compunit->m_pending_macros != NULL)
+ if (m_pending_macros != NULL)
complaint (&symfile_complaints, _("Macro in a type symtab"));
- if (buildsym_compunit->m_have_line_numbers)
+ if (m_have_line_numbers)
complaint (&symfile_complaints,
_("Line numbers recorded in a type symtab"));
@@ -1530,9 +1656,9 @@ augment_type_symtab (void)
/* First mark any symbols without a specified symtab as belonging
to the primary symtab. */
- set_missing_symtab (buildsym_compunit->m_file_symbols, cust);
+ set_missing_symtab (m_file_symbols, cust);
- dict_add_pending (BLOCK_DICT (block), buildsym_compunit->m_file_symbols);
+ dict_add_pending (BLOCK_DICT (block), m_file_symbols);
}
if (*get_global_symbols () != NULL)
@@ -1541,10 +1667,10 @@ augment_type_symtab (void)
/* First mark any symbols without a specified symtab as belonging
to the primary symtab. */
- set_missing_symtab (buildsym_compunit->m_global_symbols, cust);
+ set_missing_symtab (m_global_symbols, cust);
dict_add_pending (BLOCK_DICT (block),
- buildsym_compunit->m_global_symbols);
+ m_global_symbols);
}
reset_symtab_globals ();
@@ -1555,23 +1681,20 @@ augment_type_symtab (void)
context. */
struct context_stack *
-push_context (int desc, CORE_ADDR valu)
+buildsym_compunit::push_context (int desc, CORE_ADDR valu)
{
- gdb_assert (buildsym_compunit != nullptr);
-
- buildsym_compunit->m_context_stack.emplace_back ();
- struct context_stack *newobj = &buildsym_compunit->m_context_stack.back ();
+ m_context_stack.emplace_back ();
+ struct context_stack *newobj = &m_context_stack.back ();
newobj->depth = desc;
- newobj->locals = buildsym_compunit->m_local_symbols;
- newobj->old_blocks = buildsym_compunit->m_pending_blocks;
+ newobj->locals = m_local_symbols;
+ newobj->old_blocks = m_pending_blocks;
newobj->start_addr = valu;
- newobj->local_using_directives
- = buildsym_compunit->m_local_using_directives;
+ newobj->local_using_directives = m_local_using_directives;
newobj->name = NULL;
- buildsym_compunit->m_local_symbols = NULL;
- buildsym_compunit->m_local_using_directives = NULL;
+ m_local_symbols = NULL;
+ m_local_using_directives = NULL;
return newobj;
}
@@ -1580,14 +1703,12 @@ push_context (int desc, CORE_ADDR valu)
popped. */
struct context_stack *
-pop_context (void)
+buildsym_compunit::pop_context ()
{
- gdb_assert (buildsym_compunit != nullptr);
- gdb_assert (!buildsym_compunit->m_context_stack.empty ());
- buildsym_compunit->m_popped_context
- = buildsym_compunit->m_context_stack.back ();
- buildsym_compunit->m_context_stack.pop_back ();
- return &buildsym_compunit->m_popped_context;
+ gdb_assert (!m_context_stack.empty ());
+ m_popped_context = m_context_stack.back ();
+ m_context_stack.pop_back ();
+ return &m_popped_context;
}
@@ -1595,13 +1716,13 @@ pop_context (void)
void
record_debugformat (const char *format)
{
- buildsym_compunit->debugformat = format;
+ buildsym_compunit->record_debugformat (format);
}
void
record_producer (const char *producer)
{
- buildsym_compunit->producer = producer;
+ buildsym_compunit->record_producer (producer);
}
@@ -1619,11 +1740,11 @@ set_last_source_file (const char *name)
/* See buildsym.h. */
const char *
-get_last_source_file (void)
+get_last_source_file ()
{
if (buildsym_compunit == nullptr)
return nullptr;
- return buildsym_compunit->m_last_source_file.get ();
+ return buildsym_compunit->get_last_source_file ();
}
/* See buildsym.h. */
@@ -1632,7 +1753,7 @@ void
set_last_source_start_addr (CORE_ADDR addr)
{
gdb_assert (buildsym_compunit != nullptr);
- buildsym_compunit->m_last_source_start_addr = addr;
+ buildsym_compunit->set_last_source_start_addr (addr);
}
/* See buildsym.h. */
@@ -1641,7 +1762,7 @@ CORE_ADDR
get_last_source_start_addr ()
{
gdb_assert (buildsym_compunit != nullptr);
- return buildsym_compunit->m_last_source_start_addr;
+ return buildsym_compunit->get_last_source_start_addr ();
}
/* See buildsym.h. */
@@ -1650,7 +1771,7 @@ struct using_direct **
get_local_using_directives ()
{
gdb_assert (buildsym_compunit != nullptr);
- return &buildsym_compunit->m_local_using_directives;
+ return buildsym_compunit->get_local_using_directives ();
}
/* See buildsym.h. */
@@ -1659,7 +1780,7 @@ void
set_local_using_directives (struct using_direct *new_local)
{
gdb_assert (buildsym_compunit != nullptr);
- buildsym_compunit->m_local_using_directives = new_local;
+ buildsym_compunit->set_local_using_directives (new_local);
}
/* See buildsym.h. */
@@ -1668,7 +1789,7 @@ struct using_direct **
get_global_using_directives ()
{
gdb_assert (buildsym_compunit != nullptr);
- return &buildsym_compunit->m_global_using_directives;
+ return buildsym_compunit->get_global_using_directives ();
}
/* See buildsym.h. */
@@ -1677,7 +1798,7 @@ bool
outermost_context_p ()
{
gdb_assert (buildsym_compunit != nullptr);
- return buildsym_compunit->m_context_stack.empty ();
+ return buildsym_compunit->outermost_context_p ();
}
/* See buildsym.h. */
@@ -1686,9 +1807,7 @@ struct context_stack *
get_current_context_stack ()
{
gdb_assert (buildsym_compunit != nullptr);
- if (buildsym_compunit->m_context_stack.empty ())
- return nullptr;
- return &buildsym_compunit->m_context_stack.back ();
+ return buildsym_compunit->get_current_context_stack ();
}
/* See buildsym.h. */
@@ -1697,7 +1816,7 @@ int
get_context_stack_depth ()
{
gdb_assert (buildsym_compunit != nullptr);
- return buildsym_compunit->m_context_stack.size ();
+ return buildsym_compunit->get_context_stack_depth ();
}
/* See buildsym.h. */
@@ -1706,7 +1825,7 @@ struct subfile *
get_current_subfile ()
{
gdb_assert (buildsym_compunit != nullptr);
- return buildsym_compunit->m_current_subfile;
+ return buildsym_compunit->get_current_subfile ();
}
/* See buildsym.h. */
@@ -1715,7 +1834,7 @@ struct pending **
get_local_symbols ()
{
gdb_assert (buildsym_compunit != nullptr);
- return &buildsym_compunit->m_local_symbols;
+ return buildsym_compunit->get_local_symbols ();
}
/* See buildsym.h. */
@@ -1724,7 +1843,7 @@ struct pending **
get_file_symbols ()
{
gdb_assert (buildsym_compunit != nullptr);
- return &buildsym_compunit->m_file_symbols;
+ return buildsym_compunit->get_file_symbols ();
}
/* See buildsym.h. */
@@ -1733,5 +1852,120 @@ struct pending **
get_global_symbols ()
{
gdb_assert (buildsym_compunit != nullptr);
- return &buildsym_compunit->m_global_symbols;
+ return buildsym_compunit->get_global_symbols ();
+}
+
+void
+start_subfile (const char *name)
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ buildsym_compunit->start_subfile (name);
+}
+
+void
+patch_subfile_names (struct subfile *subfile, const char *name)
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ buildsym_compunit->patch_subfile_names (subfile, name);
+}
+
+void
+push_subfile ()
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ buildsym_compunit->push_subfile ();
+}
+
+const char *
+pop_subfile ()
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ return buildsym_compunit->pop_subfile ();
+}
+
+struct block *
+end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ return buildsym_compunit->end_symtab_get_static_block (end_addr, expandable,
+ required);
+}
+
+struct compunit_symtab *
+end_symtab_from_static_block (struct block *static_block,
+ int section, int expandable)
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ struct compunit_symtab *result
+ = buildsym_compunit->end_symtab_from_static_block (static_block,
+ section, expandable);
+ reset_symtab_globals ();
+ return result;
+}
+
+struct compunit_symtab *
+end_symtab (CORE_ADDR end_addr, int section)
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ struct compunit_symtab *result
+ = buildsym_compunit->end_symtab (end_addr, section);
+ reset_symtab_globals ();
+ return result;
+}
+
+struct compunit_symtab *
+end_expandable_symtab (CORE_ADDR end_addr, int section)
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ struct compunit_symtab *result
+ = buildsym_compunit->end_expandable_symtab (end_addr, section);
+ reset_symtab_globals ();
+ return result;
+}
+
+void
+augment_type_symtab ()
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ buildsym_compunit->augment_type_symtab ();
+ reset_symtab_globals ();
+}
+
+struct context_stack *
+push_context (int desc, CORE_ADDR valu)
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ return buildsym_compunit->push_context (desc, valu);
+}
+
+struct context_stack *
+pop_context ()
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ return buildsym_compunit->pop_context ();
+}
+
+struct block *
+finish_block (struct symbol *symbol, struct pending_block *old_blocks,
+ const struct dynamic_prop *static_link,
+ CORE_ADDR start, CORE_ADDR end)
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ return buildsym_compunit->finish_block (symbol, old_blocks, static_link,
+ start, end);
+}
+
+void
+record_block_range (struct block *block, CORE_ADDR start,
+ CORE_ADDR end_inclusive)
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ buildsym_compunit->record_block_range (block, start, end_inclusive);
+}
+
+void
+record_line (struct subfile *subfile, int line, CORE_ADDR pc)
+{
+ gdb_assert (buildsym_compunit != nullptr);
+ buildsym_compunit->record_line (subfile, line, pc);
}
--
2.13.6