This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 34/42] Add many methods to buildsym_compunit
- From: Simon Marchi <simark at simark dot ca>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Tue, 10 Jul 2018 00:08:40 -0400
- Subject: Re: [RFA 34/42] Add many methods to buildsym_compunit
- References: <20180523045851.11660-1-tom@tromey.com> <20180523045851.11660-35-tom@tromey.com>
On 2018-05-23 12:58 AM, Tom Tromey wrote:
> 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)
> + {
> }
Oh, and could you provide a comment for the second constructor?
Thanks,
Simon