Commit Graph

105549 Commits

Author SHA1 Message Date
Tom Tromey
de909f0b76 Remove objfile::psymtabs
The method objfile::psymtabs is no longer used and can be removed.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* objfiles.h (struct objfile) <psymtabs>: Remove method.
2021-03-20 17:23:45 -06:00
Tom Tromey
caf8c1e507 Change count_psyms to be a method on psymbol_functions
This removes a use of objfile->psymtabs by changing count_psyms to be
a method on psymbol_functions.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* psymtab.c (psymbol_functions::count_psyms): Rename.
	(psymbol_functions::print_stats): Update.
	* psympriv.h (struct psymbol_functions) <count_psyms>: Declare
	method.
2021-03-20 17:23:45 -06:00
Tom Tromey
3aa31ce788 Remove last objfile partial_symtab references from psymtab.c
This removes the last references to the partial_symtab via the objfile
from psymtab.c.  require_partial_symbols is now a method on
psymbol_functions, and maintenance_print_psymbols is changed to use
dynamic_cast to verify that it is examining partial symbols.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* psymtab.c (psymbol_functions::require_partial_symbols): Rename.
	(psymbol_functions::find_pc_sect_psymtab): Rename.
	(psymbol_functions::find_pc_sect_compunit_symtab)
	(maintenance_print_psymbols, maintenance_check_psymtabs): Update.
	* psympriv.h (struct psymbol_functions) <require_partial_symbols>:
	Declare new method.
	<get_partial_symtabs, find_pc_sect_psymtab>: Likewise.
2021-03-20 17:23:45 -06:00
Tom Tromey
7b249e470a Add partial_symtabs parameter to psymtab construction functions
This adds a partial_symtabs parameter to the psymtab constructors and
to add_psymbol.  This helps with the overall project of removing the
partial symtabs from the objfile.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_start_psymtab): Add partial_symtabs parameter.
	(xcoff_end_psymtab, scan_xcoff_symtab): Update.
	* psymtab.c (partial_symtab::partial_symtab): Add partial_symtabs
	parameter.
	(add_psymbol_to_bcache): Remove.
	(partial_symtab::add_psymbol): Add partial_symtabs parameter.
	(partial_symtab::add_psymbol, partial_symtab::partial_symtab):
	Likewise.
	* psympriv.h (partial_symtab): Add partial_symtabs parameter.
	<add_psymbol>: Likewise.
	(standard_psymtab, legacy_psymtab): Likewise.
	* mdebugread.c (parse_partial_symbols): Update.
	(handle_psymbol_enumerators): Add partial_symtabs parameter.
	(handle_psymbol_enumerators): Update.
	(new_psymtab): Add partial_symtabs parameter.
	* dwarf2/read.h (dwarf2_psymtab): Add partial_symtabs parameter.
	* dwarf2/read.c (dwarf2_include_psymtab): Add partial_symtabs
	parameter.
	(dwarf2_create_include_psymtab): Add partial_symtabs parameter.
	(create_partial_symtab, add_partial_symbol, dwarf_decode_lines):
	Update.
	* dbxread.c (read_dbx_symtab): Update.
	(start_psymtab): Add partial_symtabs parameter.
	(dbx_end_psymtab): Update.
	* ctfread.c (struct ctf_context) <partial_symtabs>: New member.
	(ctf_psymtab): Add partial_symtabs parameter.
	(create_partial_symtab, ctf_psymtab_type_cb, ctf_psymtab_var_cb):
	Update.
	(scan_partial_symbols): Add partial_symtabs parameter.
	(scan_partial_symbols, elfctf_build_psymtabs)
	(ctf_psymtab_add_enums): Update.
2021-03-20 17:23:45 -06:00
Tom Tromey
d1eef86d12 Introduce objfile::require_partial_symbols
This adds a new method, objfile::require_partial_symbols.  This reuses
most of the code from the old function in psymtab.c.  That function is
now made static, and simplified.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* symfile.c (read_symbols): Use objfile method.
	* symfile-debug.c (objfile::require_partial_symbols): New method.
	* psymtab.h (require_partial_symbols): Don't declare.
	* psymtab.c (require_partial_symbols): Use objfile method.  Now
	static.
	(psymbol_functions::map_symtabs_matching_filename, OBJFILE)
	(psymbol_functions::lookup_symbol)
	(psymbol_functions::lookup_global_symbol_language)
	(psymbol_functions::find_last_source_symtab)
	(psymbol_functions::forget_cached_source_info)
	(psymbol_functions::print_stats)
	(psymbol_functions::expand_symtabs_for_function)
	(psymbol_functions::expand_all_symtabs)
	(psymbol_functions::expand_symtabs_with_fullname)
	(psymbol_functions::map_symbol_filenames)
	(psymbol_functions::map_matching_symbols)
	(psymbol_functions::expand_symtabs_matching)
	(psymbol_functions::find_compunit_symtab_by_address)
	(maintenance_print_psymbols, maintenance_info_psymtabs)
	(maintenance_check_psymtabs): Update.
	* objfiles.h (struct objfile) <require_partial_symbols>: Declare
	new method.
2021-03-20 17:23:44 -06:00
Tom Tromey
eb00e4686d Remove sym_fns::sym_read_psymbols
Partial symbols are read via the sym_fns::sym_read_psymbols function
pointer.  In order to separate the partial symbols from the objfile,
this must instead be done via a virtual method on
quick_symbol_functions.  This patch implements this change.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_sym_fns): Update.
	* symfile.h (struct sym_fns) <sym_read_psymbols>: Remove.
	* symfile-debug.c (objfile::has_partial_symbols): Use
	can_lazily_read_symbols.
	(debug_sym_read_psymbols): Remove.
	(debug_sym_fns, install_symfile_debug_logging): Update.
	* quick-symbol.h (struct quick_symbol_functions)
	<can_lazily_read_symbols, read_partial_symbols>: New methods.
	* psymtab.c (require_partial_symbols): Use new 'qf' methods.
	* mipsread.c (ecoff_sym_fns): Update.
	* machoread.c (macho_sym_fns): Update.
	* elfread.c (struct lazy_dwarf_reader): New.
	(elf_symfile_read): Update.
	(read_psyms): Now a method of lazy_dwarf_reader.
	(elf_sym_fns): Update.
	(elf_sym_fns_lazy_psyms): Remove.
	* dbxread.c (aout_sym_fns): Update.
	* coffread.c (coff_sym_fns): Update.
2021-03-20 17:23:44 -06:00
Tom Tromey
b29b98cf84 Rearrange psymtab_storage construction
This changes objfile so that it doesn't construct a psymtab_storage
object until the psymtab functions are installed.  It also applies a
similar treatment to reread_symbols.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* symfile.c (syms_from_objfile_1): Call reset_psymtabs.
	(reread_symbols): Move reset_psymtabs call later.
	* objfiles.c (objfile::objfile): Don't initialize
	partial_symtabs.
2021-03-20 17:23:44 -06:00
Tom Tromey
17d66340eb Attach partial symtab storage to psymbol_functions
Currently, the storage for partial symtabs is attached to the objfile.
Ultimately, though, this direct assocation will be removed, and the
storage will be owned by the psymbol_functions object.

This patch is a step toward this goal.  The storage is already managed
as a shared_ptr, to enable cross-objfile sharing, so this adds a
reference from the psymbol_functions, and changes some code in
psymtab.c to use this reference instead.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (dwarf2_build_psymtabs): Call
	set_partial_symtabs.
	* symfile.c (syms_from_objfile_1, reread_symbols): Update.
	* psymtab.h (make_psymbol_functions): Add partial_symtabs
	parameter.
	* psymtab.c (find_pc_sect_psymtab): Add partial_symtabs
	parameter.
	(psymbol_functions::find_pc_sect_compunit_symtab)
	(psymbol_functions::print_stats, psymbol_functions::dump)
	(psymbol_functions::has_symbols): Update.
	(make_psymbol_functions, dump_psymtab_addrmap): Add
	partial_symtabs parameter.
	(maintenance_print_psymbols): Update.
	(psymbol_functions::expand_symtabs_matching): Update.
	* psympriv.h (struct psymbol_functions): Add constructor.
	<m_partial_symtabs>: New member.
	<set_partial_symtabs>: New method.
2021-03-20 17:23:44 -06:00
Tom Tromey
8468590493 Reference psymtabs via per_bfd in DWARF reader
This changes the DWARF reader to reference the psymtabs via the
per_bfd object, rather than via the objfile.  This helps isolate the
partial symtabs from the objfile.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (dwarf2_create_include_psymtab): Add per_bfd
	parameter.
	(process_psymtab_comp_unit_reader)
	(build_type_psymtab_dependencies, dwarf2_build_psymtabs_hard)
	(add_partial_subprogram, dwarf2_ranges_read, dwarf_decode_lines):
	Reference psymtabs via per_bfd.
2021-03-20 17:23:44 -06:00
Tom Tromey
79cc99f69b Change how DWARF index writer finds address map
This changes the DWARF index writer to find the psymtab address map in
the per_bfd object, rather than go via the objfile.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* dwarf2/index-write.c (struct addrmap_index_data) <objfile>:
	Remove.
	(add_address_entry): Remove objfile parameter.
	(add_address_entry_worker): Update.
	(write_address_map): Replace objfile parameter with per_bfd.
	(write_gdbindex, write_psymtabs_to_index): Update.
2021-03-20 17:23:43 -06:00
Tom Tromey
4829711b6b Move psymtab statistics printing to psymtab.c
This moves all the psymtab statistics printing code form symmisc.c to
psymtab.c.  This changes the formatting of the output a little, but
considering that it is a maint command (and, I assume, a rarely used
one), this seems fine to me.

This change helps further dissociate the psymtab from the objfile.  In
the end there will be no direct connect -- only via the
quick_symbol_functions interface.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (dwarf2_base_index_functions::print_stats): Add
	print_bcache parameter.
	* symfile-debug.c (objfile::print_stats): Add print_bcache
	parameter.
	* quick-symbol.h (struct quick_symbol_functions)
	<print_stats>: Add print_bcache parameter.
	* symmisc.c (print_symbol_bcache_statistics, count_psyms): Move
	code to psymtab.c.
	(print_objfile_statistics): Move psymtab code to psymtab.c.
	* psymtab.c (count_psyms): Move from symmisc.c.
	(psymbol_functions::print_stats): Print partial symbol and bcache
	statistics.  Add print_bcache parameter.
	* objfiles.h (print_symbol_bcache_statistics): Don't declare.
	(struct objfile) <print_stats>: Add print_bcache parameter.
	* maint.c (maintenance_print_statistics): Update.

gdb/testsuite/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* gdb.base/maint.exp: Update "maint print statistics" output.
2021-03-20 17:23:43 -06:00
Tom Tromey
efd7398ee2 Change how DWARF indices use addrmap
Currently the DWARF index readers reuse the objfile's partial symbol
table in order to store an addrmap.  We're going to be remove the
partial symbol object, so this patch changes the DWARF reader to store
this addrmap in the per_bfd object.  This object is chosen, rather
than the quick_symbol_functions subclass, because the addrmap can be
shared across objfiles.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.h (struct dwarf2_per_bfd) <psymtabs_addrmap>: New
	member.
	* dwarf2/read.c (create_addrmap_from_index)
	(create_addrmap_from_aranges): Set per_bfd addrmap.
	(dwarf2_read_gdb_index): Don't set partial_symtabs.
	(dwarf2_base_index_functions::find_pc_sect_compunit_symtab): Use
	per_bfd addrmap.
	(dwarf2_read_debug_names): Don't set partial_symtabs.
	(dwarf2_initialize_objfile): Likewise.
2021-03-20 17:23:43 -06:00
Tom Tromey
51962708bd Set per_bfd->partial_symtabs earlier
dwarf2_build_psymtabs sets per_bfd->partial_symtabs at its end, in
order to facilitate sharing.

However, in order to diassociate partial symtabs from the objfile, we
want to change the DWARF reader to reference partial symtabs via the
per_bfd.  So, we want to set this reference before reading psymtabs.
This is safe to do because the assignment is done unconditionally.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (dwarf2_build_psymtabs): Set partial_symtabs
	earlier.
2021-03-20 17:23:43 -06:00
Tom Tromey
484b109063 Do not pass objfile to psymtab_discarder
This changes the psymtab_discarder to not assume that partial symtabs
are attached to the objfile.  Instead, a psymtab_storage object is
passed directly to it.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* psympriv.h (psymtab_discarder): Take psymtab_storage parameter.
	(~psymtab_discarder, keep): Update.
	<m_objfile>: Remove.
	<m_partial_symtabs>: New member.
	* dwarf2/read.c (dwarf2_build_psymtabs): Update.
2021-03-20 17:23:42 -06:00
Tom Tromey
7e9c0476a7 Change how some psymbol readers access the psymtab storage
Currently, all psymbol readers access the psymtab storage via the
objfile.  This is done directly at any spot requiring the storage.

In order to move psymbols out of the objfile, the psymtab_storage must
be passed in explicitly.  This patch consolidates the access of the
storage in a single place in these readers, updating various functions
to pass the storage object around.  "Hidden" uses, like
"objfile->psymtabs ()", are also updated.

The DWARF reader is not yet touched.  That requires more complicated
changes.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_end_psymtab): Add partial_symtabs parameter.
	(xcoff_end_psymtab): Update.
	(scan_xcoff_symtab): Add partial_symtabs parameter.
	(xcoff_initial_scan): Update.
	* stabsread.h (dbx_end_psymtab): Add partial_symtabs parameter.
	* mdebugread.c (mdebug_build_psymtabs): Update.
	(parse_partial_symbols): Add partial_symtabs parameter.
	* dbxread.c (dbx_symfile_read): Update.
	(read_dbx_symtab): Add partial_symtabs parameter.
	(read_dbx_symtab): Update.
	(dbx_end_psymtab): Add partial_symtabs parameter.
2021-03-20 17:23:42 -06:00
Tom Tromey
75336a5a2a Move psymbol_map out of objfile
objfile::psymbol_map is used to implement a Rust feature.  It is
currently specific to partial symbols -- it isn't used by the DWARF
indices.

This patch moves it out of objfile and into psymbol_functions, adding
a new method to quick_symbol_functions to handle the clearing case.
This is needed because the map holds unrelocated addresses.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* quick-symbol.h (struct quick_symbol_functions)
	<relocated>: New method.
	* psymtab.h (struct psymbol_functions) <relocated>: New
	method.
	<fill_psymbol_map>: Declare method.
	<m_psymbol_map>: New member.
	* psymtab.c (psymbol_functions::fill_psymbol_map): Rename.
	(psymbol_functions::find_compunit_symtab_by_address): Update.
	* objfiles.h (reset_psymtabs): Don't clear psymbol_map.
	(struct objfile) <psymbol_map>: Remove.
	* objfiles.c (objfile_relocate1): Update.
2021-03-20 17:23:42 -06:00
Tom Tromey
39298a5d97 Convert quick_symbol_functions to use methods
This changes quick_symbol_functions to be a base class with pure
virtual methods, rather than a struct holding function pointers.
Then, objfile is changed to hold a unique_ptr to an instance of this
class.

struct psymbol_functions is put into psympriv.h, and not psymtab.c,
because that is convenient later in the series.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* psympriv.h (struct psymbol_functions): New.
	* symfile.c (syms_from_objfile_1, reread_symbols): Update.
	* symfile-debug.c (objfile::find_compunit_symtab_by_address)
	(objfile::lookup_global_symbol_language): Update.
	* quick-symbol.h (struct quick_symbol_functions): Convert function
	pointers to methods.  Add virtual destructor.
	(quick_symbol_functions_up): New typedef.
	* psymtab.h (psym_functions, dwarf2_gdb_index_functions)
	(dwarf2_debug_names_functions): Don't declare.
	(make_psymbol_functions): Declare.
	* psymtab.c (psymbol_functions::map_symtabs_matching_filename)
	(psymbol_functions::find_pc_sect_compunit_symtab)
	(psymbol_functions::lookup_symbol)
	(psymbol_functions::lookup_global_symbol_language)
	(psymbol_functions::find_last_source_symtab)
	(psymbol_functions::forget_cached_source_info)
	(psymbol_functions::print_stats, psymbol_functions::dump)
	(psymbol_functions::expand_symtabs_for_function)
	(psymbol_functions::expand_all_symtabs)
	(psymbol_functions::expand_symtabs_with_fullname)
	(psymbol_functions::map_symbol_filenames)
	(psymbol_functions::map_matching_symbols)
	(psymbol_functions::expand_symtabs_matching)
	(psymbol_functions::has_symbols)
	(psymbol_functions::find_compunit_symtab_by_address): Rename.
	(psym_functions): Remove.
	(make_psymbol_functions): New function.
	* objfiles.h (struct objfile) <qf>: Change type.
	* elfread.c (elf_symfile_read): Update.
	* dwarf2/read.c (struct dwarf2_base_index_functions)
	(struct dwarf2_gdb_index, struct dwarf2_debug_names_index): New.
	(make_dwarf_gdb_index, make_dwarf_debug_names): New functions.
	(dwarf2_base_index_functions::find_last_source_symtab)
	(dwarf2_base_index_functions::forget_cached_source_info)
	(dwarf2_base_index_functions::map_symtabs_matching_filename)
	(dwarf2_gdb_index::lookup_symbol)
	(dwarf2_base_index_functions::print_stats)
	(dwarf2_gdb_index::dump)
	(dwarf2_gdb_index::expand_symtabs_for_function)
	(dwarf2_base_index_functions::expand_all_symtabs)
	(dwarf2_base_index_functions::expand_symtabs_with_fullname):
	Rename.
	(dwarf2_gdb_index::map_matching_symbols): New method.
	(dwarf2_gdb_index::expand_symtabs_matching): New method.
	(dwarf2_base_index_functions::find_pc_sect_compunit_symtab)
	(dwarf2_base_index_functions::map_symbol_filenames)
	(dwarf2_base_index_functions::has_symbols): Rename.
	(dwarf2_gdb_index_functions): Remove.
	(dwarf2_debug_names_index::lookup_symbol)
	(dwarf2_debug_names_index::dump)
	(dwarf2_debug_names_index::expand_symtabs_for_function)
	(dwarf2_debug_names_index::map_matching_symbols)
	(dwarf2_debug_names_index::expand_symtabs_matching): Rename.
	(dwarf2_debug_names_functions): Remove.
	* dwarf2/public.h (make_dwarf_gdb_index, make_dwarf_debug_names):
	Declare.
2021-03-20 17:23:42 -06:00
Tom Tromey
5c3f1e5bfc Move sym_fns::qf to objfile
Currently the "partial" symbol reader is attached to the objfile's
symbol functions.  However, in order to allow multiple separate
partial symbol readers, this association must be changed.  This patch
moves the "qf" member out of sym_fns as a step toward that goal.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* psymtab.c (require_partial_symbols): Check that 'sf' is not
	null.
	* xcoffread.c (xcoff_sym_fns): Update.
	* symfile.h (struct sym_fns) <qf>: Remove.
	* symfile.c (syms_from_objfile_1, reread_symbols): Update.
	* symfile-debug.c (objfile::has_partial_symbols)
	(objfile::find_last_source_symtab)
	(objfile::forget_cached_source_info)
	(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
	(objfile::print_stats, objfile::dump)
	(objfile::expand_symtabs_for_function)
	(objfile::expand_all_symtabs)
	(objfile::expand_symtabs_with_fullname)
	(objfile::map_matching_symbols)
	(objfile::expand_symtabs_matching)
	(objfile::find_pc_sect_compunit_symtab)
	(objfile::map_symbol_filenames)
	(objfile::find_compunit_symtab_by_address)
	(objfile::lookup_global_symbol_language, debug_sym_fns)
	(install_symfile_debug_logging): Update.
	* objfiles.h (struct objfile) <qf>: New member.
	* mipsread.c (ecoff_sym_fns): Update.
	* machoread.c (macho_sym_fns): Update.
	* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_debug_names):
	Don't declare.
	(elf_symfile_read, elf_sym_fns, elf_sym_fns_lazy_psyms): Update.
	* dbxread.c (aout_sym_fns): Update.
	* coffread.c (coff_sym_fns): Update.
2021-03-20 17:23:41 -06:00
Tom Tromey
9b99dcc8db Move quick_symbol_functions to a new header
This introduces a new header, quick-symbol.h, and moves
quick_symbol_functions and related typedefs into it.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* symfile.h (symbol_compare_ftype, symbol_filename_ftype)
	(expand_symtabs_file_matcher_ftype)
	(expand_symtabs_symbol_matcher_ftype)
	(expand_symtabs_exp_notify_ftype, struct quick_symbol_functions):
	Move to quick-symbol.h.
	* quick-symbol.h: New file.
2021-03-20 17:23:41 -06:00
Tom Tromey
4d080b4687 Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
	(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
	(basic_lookup_transparent_type_quick)
	(find_pc_sect_compunit_symtab, find_symbol_at_address)
	(find_line_symtab, global_symbol_searcher::expand_symtabs):
	Update.
	* symmisc.c (print_objfile_statistics, dump_objfile)
	(maintenance_expand_symtabs): Update.
	* symfile.c (symbol_file_add_with_addrs)
	(expand_symtabs_matching, map_symbol_filenames): Update.
	* symfile-debug.c (objfile::has_partial_symbols)
	(objfile::find_last_source_symtab)
	(objfile::forget_cached_source_info)
	(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
	(objfile::print_stats, objfile::dump)
	(objfile::expand_symtabs_for_function)
	(objfile::expand_all_symtabs)
	(objfile::expand_symtabs_with_fullname)
	(objfile::map_matching_symbols)
	(objfile::expand_symtabs_matching)
	(objfile::find_pc_sect_compunit_symtab)
	(objfile::map_symbol_filenames)
	(objfile::find_compunit_symtab_by_address)
	(objfile::lookup_global_symbol_language): New methods.
	(debug_sym_quick_functions): Remove.
	(debug_sym_fns, install_symfile_debug_logging): Update.
	* source.c (forget_cached_source_info_for_objfile)
	(select_source_symtab): Update.
	* objfiles.h (struct objfile): Add methods corresponding to
	quick_symbol_functions.
	* objfiles.c (objfile::has_partial_symbols): Move to
	symfile-debug.c.
	* linespec.c (iterate_over_all_matching_symtabs): Update.
	* cp-support.c (add_symbol_overload_list_qualified): Update.
	* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-20 17:23:41 -06:00
Tom Tromey
fae2120ba0 Change objfile::has_partial_symbols to return bool
This changes objfile::has_partial_symbols and
quick_symbol_functions::has_symbols to return bool.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* objfiles.h (struct objfile) <has_partial_symbols>: Return bool.
	* symfile.h (struct quick_symbol_functions) <has_symbols>: Return
	bool.
	* symfile-debug.c (debug_qf_has_symbols): Return bool.
	* psymtab.c (psym_has_symbols): Return bool.
	* objfiles.c (objfile::has_partial_symbols): Return bool.
	* dwarf2/read.c (dw2_has_symbols): Return bool.
2021-03-20 17:23:41 -06:00
Tom Tromey
a8ad4f3c17 Change objfile_has_partial_symbols to a method
This changes objfile_has_partial_symbols to be a method on objfile.

There are some other functions that could benefit from this sort of
change, but this was the only one that was relevant to this series.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* symfile.c (read_symbols): Update.
	* objfiles.h (struct objfile) <has_partial_symbols>: New method.
	(objfile_has_partial_symbols): Don't declare.
	* objfiles.c (objfile::has_partial_symbols): Rename from
	objfile_has_partial_symbols.
	(objfile_has_symbols, have_partial_symbols): Update.
	* elfread.c (elf_symfile_read): Update.
	* dwarf2/read.c (dwarf2_has_info): Update.
	* coffread.c (coff_symfile_read): Update.
2021-03-20 17:23:41 -06:00
Tom Tromey
701823751b Introduce dwarf2/public.h
This moves some more DWARF code out of symfile.h and into a new
header, dwarf2/public.h.  This header is intended to describe the
public API of the DWARF reader.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* coffread.c: Include dwarf2/public.h.
	* dwarf2/frame.c: Include dwarf2/public.h.
	* dwarf2/index-write.h: Include dwarf2/public.h, not symfile.h.
	* dwarf2/public.h: New file.
	* dwarf2/read.c: Include dwarf2/public.h.
	* elfread.c: Include dwarf2/public.h.
	* machoread.c: Include dwarf2/public.h.
	* symfile.h (dwarf2_has_info, enum dw_index_kind)
	(dwarf2_initialize_objfile, dwarf2_build_psymtabs)
	(dwarf2_build_frame_info): Move to dwarf2/public.h.
	* xcoffread.c: Include dwarf2/public.h.
2021-03-20 17:23:40 -06:00
Tom Tromey
18038e6363 Move some DWARF code out of symfile.h
This moves a bit of the DWARF-specific code out of symfile.h and into
dwarf2/read.h.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* symfile.h (enum dwarf2_section_enum)
	(dwarf2_get_section_info): Move to dwarf2/read.h.
	* dwarf2/read.h (enum dwarf2_section_enum)
	(dwarf2_get_section_info): Move from symfile.h.
2021-03-20 17:23:40 -06:00
Cary Coutant
35891b4775 Use stdout when printing object file names for -t option.
gold/
	PR gold/27615
	* errors.cc (Errors::trace): New method.
	(gold_trace): New function.
	* errors.h (Errors::trace): New method.
	* gold.h (gold_trace): New function.
	* object.cc (Input_objects::add_object): Use gold_trace to print
	object file names.
2021-03-19 18:41:12 -07:00
Cary Coutant
b218a83935 Fix failing test for PR 23870.
gold/
	PR gold/pr23870
	* testsuite/aarch64_pr23870_bar.c: Return a magic value.
	* testsuite/aarch64_pr23870_foo.c: Check the magic value and return
	success or failure.
2021-03-19 17:58:32 -07:00
H.J. Lu
1de96e5de9 x86-64: Add a testcase for PR ld/27590
PR ld/27590
	* testsuite/ld-x86-64/pr27590.rd: New file.
	* testsuite/ld-x86-64/pr27590a.obj.bz2: Likewise.
	* testsuite/ld-x86-64/pr27590b.obj.bz2: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run ld/27590 test.
2021-03-19 17:23:47 -07:00
Alan Modra
15407e7e0d DWARF LTO debug sections vs. .stabstr
The exception for debug sections in clearing SEC_EXCLUDE when
relocatable was really for one specific debug section, so let's make
it do just that.

bfd/
	PR 27590
	* elf.c (_bfd_elf_make_section_from_shdr): Remove SHF_EXCLUDE
	test for .gnu.debuglto*.
ld/
	PR 27590
	* ldlang.c (lang_gc_sections): Clear SEC_EXCLUDE when relocatable
	for all sections except .stabstr.
2021-03-20 10:35:18 +10:30
GDB Administrator
6536577167 Automatic date update in version.in 2021-03-20 00:00:06 +00:00
Holger Berger
07b1c3dbd9 Fix call to system fallocate to handle errno correctly.
2021-03-19  Holger Berger  <holger.berger@googlemail.com>

gold/
	PR gold/26541
	* output.cc (gold_fallocate): Use errno when calling system fallocate.
2021-03-19 16:18:53 -07:00
Cary Coutant
cc1849716f Fix typo in previous patch: should use struct mallinfo2.
PR gold/26585
	* main.cc (main): Fix typo in previous patch.
2021-03-19 15:29:49 -07:00
Cary Coutant
9331846e44 Regenerate config.in, missing from previous commit.
PR gold/26585
	* config.in: Regenerate from previous commit.
2021-03-19 15:23:49 -07:00
Duncan Simpson
4ee6049505 Fix gold to use mallinfo2 if available instead of deprecated mallinfo.
gold/
	PR gold/26585
	* configure.ac: Add check for mallinfo2.
	* configure: Regenerate.
	* main.cc (main): Use mallinfo2 if available.
2021-03-19 14:22:08 -07:00
Cary Coutant
5cde809b7b Add DWARF 5 support in gold.
elfcpp/
	PR gold/27246
	* dwarf.h (enum DW_LNCT): Add line number table content type codes.
	(enum DW_LINE_OPS): Reformat.
	(enum DW_LINE_EXTENDED_OPS): Reformat.
	(enum DW_CHILDREN): Reformat.
	(enum DW_RLE): Add range list entry types.
	(enum DW_SECT): Update values for DWARF 5.

gold/
	PR gold/27246
	* dwarf_reader.cc (Dwarf_abbrev_table::do_get_abbrev): Handle
	DW_FORM_implicit_const.
	(Dwarf_ranges_table::read_ranges_table): Add version parameter;
	Adjust all callers.  Look for .debug_rnglists section if DWARF 5.
	(Dwarf_ranges_table::read_range_list_v5): New method.
	(Dwarf_die::read_attributes): Handle new DWARF 5 DW_FORM codes.
	(Dwarf_die::skip_attributes): Likewise.
	(Dwarf_info_reader::do_parse): Support DWARF 5 unit header format.
	(Dwarf_info_reader::read_3bytes_from_pointer): New method.
	(Sized_dwarf_line_info::Sized_dwarf_line_info): Initialize
	str_buffer_, str_buffer_start, reloc_map_, line_number_map_.
	Look for .debug_line_str section.
	(Sized_dwarf_line_info::read_header_prolog): Support DWARF 5 prolog.
	(Sized_dwarf_line_info::read_header_tables): Rename to...
	(Sized_dwarf_line_info::read_header_tables_v2): ... this.
	(Sized_dwarf_line_info::read_header_tables_v5): New method.
	(Sized_dwarf_line_info::process_one_opcode): Insert missing "this->".
	Change advance_line to signed int64_t.
	(Sized_dwarf_line_info::read_lines): Add endptr parameter; adjust
	callers.  Insert missing "this->".
	(Sized_dwarf_line_info::read_line_mappings): Support DWARF 5.
	(Sized_dwarf_line_info::do_addr2line): Add debug code.
	* dwarf_reader.h (Dwarf_abbrev_table::Attribute): Add implicit_const
	field. Adjust constructor.
	(Dwarf_abbrev_table::add_sttribute): Add implicit_const parameter.
	(Dwarf_ranges_table::read_ranges_table): Add version parameter.
	(Dwarf_ranges_table::read_range_list_v5): New method.
	(Dwarf_die): Remove unused attr_off field.
	(Dwarf_info_reader::Dwarf_info_reader): Initialize unit_type_ field.
	(Dwarf_info_reader::is_type_unit): New method.
	(Dwarf_info_reader::read_3bytes_from_pointer): New method.
	(Dwarf_info_reader::read_range_list): Call read_range_list_v5 for
	DWARF 5 range lists.
	(Dwarf_info_reader::is_type_unit_): Remove.
	(Dwarf_info_reader::unit_type_): New field.
	(Sized_dwarf_line_info::~Sized_dwarf_line_info): Delete
	str_buffer_start_.
	(Sized_dwarf_line_info::read_header_tables): Rename to...
	(Sized_dwarf_line_info::read_header_tables_v2): ... this.
	(Sized_dwarf_line_info::read_header_tables_v5): New method.
	(Sized_dwarf_line_info::read_lines): Add endptr parameter.
	(Sized_dwarf_line_info::Dwarf_line_infoHeader): Add address_size field.
	(Sized_dwarf_line_info::str_buffer_): New field.
	(Sized_dwarf_line_info::str_buffer_end_): New field.
	(Sized_dwarf_line_info::str_buffer_start_): New field.
	(Sized_dwarf_line_info::end_of_header_length_): New field.
	(Sized_dwarf_line_info::end_of_unit_): New field.
2021-03-19 13:55:35 -07:00
Kevin Buettner
e0d6d27406 Fix potential hang during gdbserver testing
We're currently seeing testing of native-extended-gdbserver hang while
testing the x86_64 architecture on both Fedora 34 and Fedora Rawhide.
The test responsible for the hang is gdb.threads/fork-plus-threads.exp.

While there is clearly a problem/bug with this test on F34 and
Rawhide, it's also the case that testing should not hang.  This commit
prevents the hang by waiting with the "-nowait" flag in
close_gdbserver.

The -nowait flag is also used in the kill_wait_spawned_process proc in
gdb/testsuite/lib/gdb.exp, so there is precedent for doing this.

There are also 15 other uses of "wait -i" scattered throughout the
test suite.  While it's tempting to change these to also use the
-nowait flag, I think it might be safer to defer doing so until we
actually see a problem.

I've tested this patch on Fedora 32, 33, 34, and Rawhide.  Results are
comparable on Fedora 32 and 33.  On Fedora 34 and Rawhide, with this
commit in place, testing completes when the target_board is
native-extended-gdbserver.  On those OSes, when not using this commit,
testing usually hangs due to a problem with
gdb.threads/fork-plus-threads.exp.  I've also tested on all of the
mentioned OSes with target_board=native-gdbserver; for that testing,
I achieved comparable results over a number of runs.  (Unfortunately
results are rarely identical due to racy tests.)

gdb/testsuite/ChangeLog:

	* lib/gdbserver-support.exp (gdbserver_exit): Use the
	"-nowait" flag when waiting for gdbserver to exit.
2021-03-19 13:36:33 -07:00
Pedro Alves
219f56b484 Fix any_thread_of_inferior
Running gdb-term.exp against gdbserver with "maint set target-non-stop
on", runs into this:

  [infrun] fetch_inferior_event: exit
  [infrun] fetch_inferior_event: enter
  /home/pedro/gdb/binutils-gdb/src/gdb/thread.c:72: internal-error: thread_info* inferior_thread(): Assertion `current_thread_ != nullptr' failed.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.

  This is a bug, please report it.  For instructions, see:
  <https://www.gnu.org/software/gdb/bugs/>.

  FAIL: gdb.base/gdb-sigterm.exp: expect eof #2 (GDB internal error)
  Resyncing due to internal error.
  ERROR: : spawn id exp9 not open
      while executing
  "expect {
  -i exp9 -timeout 10
	      -re "Quit this debugging session\\? \\(y or n\\) $" {
		  send_gdb "n\n" answer
		  incr count
	      }
	      -re "Create ..."
      ("uplevel" body line 1)
      invoked from within
  "uplevel $body" NONE : spawn id exp9 not open
  ERROR: Could not resync from internal error (timeout)
  gdb.base/gdb-sigterm.exp: expect eof #2: stepped 0 times
  UNRESOLVED: gdb.base/gdb-sigterm.exp: 50 SIGTERM passes

The assertion fails here:

  ...
  #5  0x000055af4b4a7164 in internal_error (file=0x55af4b5e5de8 "/home/pedro/gdb/binutils-gdb/src/gdb/thread.c", line=72, fmt=0x55af4b5e5ce9 "%s: Assertion `%s' failed.") at /home/pedro/gdb/binutils-gdb/src/gdbsupport/errors.cc:55
  #6  0x000055af4b25fc43 in inferior_thread () at /home/pedro/gdb/binutils-gdb/src/gdb/thread.c:72
  #7  0x000055af4b26177e in any_thread_of_inferior (inf=0x55af4cf874f0) at /home/pedro/gdb/binutils-gdb/src/gdb/thread.c:638
  #8  0x000055af4b26eec8 in kill_or_detach (inf=0x55af4cf874f0, from_tty=0) at /home/pedro/gdb/binutils-gdb/src/gdb/top.c:1665
  #9  0x000055af4b26f37f in quit_force (exit_arg=0x0, from_tty=0) at /home/pedro/gdb/binutils-gdb/src/gdb/top.c:1767
  #10 0x000055af4b2f72a7 in quit () at /home/pedro/gdb/binutils-gdb/src/gdb/utils.c:633
  #11 0x000055af4b2f730b in maybe_quit () at /home/pedro/gdb/binutils-gdb/src/gdb/utils.c:657
  #12 0x000055af4b1adb74 in ser_base_wait_for (scb=0x55af4d02e460, timeout=0) at /home/pedro/gdb/binutils-gdb/src/gdb/ser-base.c:236
  #13 0x000055af4b1adf0f in do_ser_base_readchar (scb=0x55af4d02e460, timeout=0) at /home/pedro/gdb/binutils-gdb/src/gdb/ser-base.c:365
  #14 0x000055af4b1ae06d in generic_readchar (scb=0x55af4d02e460, timeout=0, do_readchar=0x55af4b1adeb1 <do_ser_base_readchar(serial*, int)>) at /home/pedro/gdb/binutils-gdb/src/gdb/ser-base.c:444
  ...

The bug is that any_thread_of_inferior incorrectly assumes that
there's always a selected thread.  This fixes it.

gdb/ChangeLog:

	* thread.c (any_thread_of_inferior): Check if there's a selected
	thread before calling inferior_thread().

Change-Id: Ica4b9ec746121a7a7c22bef09baea72103b3853d
2021-03-19 19:35:20 +00:00
H.J. Lu
7b9f985957 elf: Rename EM_INTEL205 to EM_INTELGT
Rename EM_INTEL205 to EM_INTELGT for Intel Graphics Technology.

binutils/

	* readelf.c (get_machine_name): Add EM_INTELGT.

include/

	* elf/common.h (EM_INTEL205): Renamed to ...
	(EM_INTELGT): This.
2021-03-19 05:58:46 -07:00
Alan Modra
826b97d42d gas/app.c don't throw away spaces before slash
I don't know really why we should lose a space before a '/'.  Possibly
it would make sense if '/' started a comment, but otherwise no.

	* app.c (do_scrub_chars): Don't lose spaces before a slash.
2021-03-19 20:12:30 +10:30
Alan Modra
fba7f7533c pr27590 testcase fixes
PR 27590
	* testsuite/ld-elf/pr27590a.d: Match relocs using label, and
	R_MIPS_NONE.
	* testsuite/ld-elf/pr27590b.d: Likewise.
2021-03-19 20:03:56 +10:30
Sourabh Singh Tomar
a088215ae3 Enable macro test for clang compiler
`clang` uses `-fdebug-macro` switch to enable debug-info
for macros.

gdb/testsuite/ChangeLog:

2021-03-19  Sourabh Singh Tomar  <SourabhSingh.Tomar@amd.com>

* gdb.base/info-macros.exp: Append -fdebug-macro to
  additional_flags for clang.
* gdb.base/macscp.exp: Likewise.
* gdb.base/style.exp: Likewise.
* gdb.linespec/macro-relative.exp: Likewise.
2021-03-19 10:44:56 +05:30
H.J. Lu
3818d4ab06 elf: Handle .gnu.debuglto_.debug_* sections
commit 994b251328
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Jan 17 20:01:16 2021 -0800

    ld/elf: Ignore section symbols when matching linkonce with comdat

ignored section symbols when comparing symbols in 2 sections.  Since all
references to debugging sections are done with section symbols, symbols
in debugging sections are ignored and we fail to match symbols in comdat
debugging sections.  Also .gnu.debuglto_.debug_* sections aren't treated
as debugging sections.

1. Treate .gnu.debuglto_.debug_ section as debugging section unless it
is marked with SHF_EXCLUDE.
2. Revert commit 994b251328 in elf_create_symbuf.
3. Ignore section symbols only when matching non-debugging sections or
linkonce section with comdat section.

bfd/

	PR ld/27590
	* elf.c (_bfd_elf_make_section_from_shdr): Treate
	.gnu.debuglto_.debug_ section as debugging section unless it is
	marked with SHF_EXCLUDE.
	* elflink.c (elf_create_symbuf): Revert commit 994b251328.
	(bfd_elf_match_symbols_in_sections): Ignore section symbols when
	matching non-debugging sections or linkonce section with comdat
	section.

ld/

	PR ld/27590
	* testsuite/ld-elf/pr27590.s: New file.
	* testsuite/ld-elf/pr27590a.d: Likewise.
	* testsuite/ld-elf/pr27590b.d: Likewise.
	* testsuite/ld-i386/i386.exp: Also run ld/27193 test with
	--reduce-memory-overheads.
2021-03-18 20:57:02 -07:00
H.J. Lu
51f6e7a9f4 DWARF: Check version >= 3 for DW_FORM_ref_addr
Check version >= 3, instead of version == 3 || version == 4, for
DW_FORM_ref_addr.

bfd/

	PR ld/27587
	* dwarf2.c (read_attribute_value): Check version >= 3 for
	DW_FORM_ref_addr.

ld/

	PR ld/27587
	* testsuite/ld-x86-64/pr27587.err: New file.
	* testsuite/ld-x86-64/pr27587a.obj.bz2: Likewise.
	* testsuite/ld-x86-64/pr27587b.obj.bz2: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run PR ld/27587 test.
2021-03-18 18:34:48 -07:00
GDB Administrator
fb099b8a51 Automatic date update in version.in 2021-03-19 00:00:07 +00:00
Christian Groessler
3273f9a19e 2021-03-18 Christian Groessler <chris@groessler.org>
* config/tc-z8k.c (apply_fix): Handle 7-bit relocations correctly.
       Problem found by Tadashi G. Takaoka <tadashi.g.takaoka@gmail.com>.
2021-03-18 21:33:51 +01:00
Tom Tromey
15310fd4eb Reimplement dwarf_unit_type_name
I noticed that dwarf_unit_type_name is nearly identical to
get_DW_UT_name from libiberty; but rather than simply replacing it, it
seemed better to have it work like the other DWARF constant
stringification functions -- return a string showing unrecognized
numeric forms rather than nullptr.  (The previous code did include
numeric values for the recognized constants, but this seems to be not
that useful to me.)

2021-03-18  Tom Tromey  <tromey@adacore.com>

	* dwarf2/stringify.c (dwarf_unit_type_name): New function.  Use
	get_DW_UT_name.
	* dwarf2/stringify.h (dwarf_unit_type_name): Declare.
	* dwarf2/comp-unit.c (dwarf_unit_type_name): Remove.
2021-03-18 12:08:41 -06:00
Andrew Burgess
763b8efdcc gdb/doc: fix the example for get_set_string in Python API docs
The small example for gdb.Parameter.get_set_string does not return a
string.  The documentation is very clear that this method must return
a string, and indeed, inspecting the code in gdb/python/py-param.c
shows that a string return value is required (if an exception is not
thrown).

While inspecting the code in gdb/python/py-param.c I noticed that the
comment for the C++ code that invokes the Python get_set_string method
is wrong, so I updated that too.

gdb/ChangeLog:

	* python/py-param.c (get_set_value): Update header comment.

gdb/doc/ChangeLog:

	* python.texinfo (Parameters In Python): Return empty string in
	small example code.
2021-03-18 16:55:37 +00:00
H.J. Lu
538c15fc2a GCC_CET_HOST_FLAGS: Check if host supports multi-byte NOPs
Check if host supports multi-byte NOPs before enabling CET on host.

config/

	PR binutils/27397
	* cet.m4 (GCC_CET_HOST_FLAGS): Check if host supports multi-byte
	NOPs.

libiberty/

	PR binutils/27397
	* configure: Regenerated.
2021-03-18 08:02:46 -07:00
Nick Clifton
835f2fae11 Fix section dumping so that warnings are not issued for missed sections in separate debuginfo files.
PR 27478
	* readelf.c (dump_section_as_strings): Mention separate filename.
	(dump_section_as_bytes): Likewise.
	(dump_section_as_ctf): Likewise.
	(initialise_dumkps_byname): Only issue a warning for missing
	sections if processing the main file.
	(process_section_contents): Only issue a warning for unsumped
	section numbers in the main file.
	(initialise_dump_sects): New function.  Contains code extracted
	from ...
	(process_object): ... here.  Also call initialise_dump_sects for
	separate files.
2021-03-18 14:01:25 +00:00
Nick Alcock
69a284867c libctf: support encodings for enums
The previous commit started to error-check the lookup of
ctf_type_encoding for the underlying type that is internally done when
carrying out a ctf_type_encoding on a slice.

Unfortunately, enums have no encoding, so this has historically been
returning an error (which is ignored) and then populating the cte_format
with uninitialized data.  Now the error is not ignored, this is
returning an error, which breaks linking of CTF containing bitfields of
enumerated type.

CTF format v3 does not record the actual underlying type of a enum, but
we can mock up something that is not *too* wrong, and that is at any
rate better than uninitialized data.

ld/ChangeLog
2021-03-18  Nick Alcock  <nick.alcock@oracle.com>

	* testsuite/ld-ctf/slice.c: Check slices of enums too.
	* testsuite/ld-ctf/slice.d: Results adjusted.

libctf/ChangeLog
2021-03-18  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-types.c (ctf_type_encoding): Support, after a fashion, for enums.
	* ctf-dump.c (ctf_dump_format_type): Do not report enums' degenerate
	encoding.
2021-03-18 12:40:41 +00:00
Nick Alcock
e4c78f303d libctf: a couple of small error-handling fixes
Out-of-memory errors initializing the string atoms table were
disregarded (though they would have caused a segfault very shortly
afterwards).  Errors hashing types during deduplication were only
reported if they happened on the output dict, which is almost never the
case (most errors are going to be on the dict we're working over, which
is going to be one of the inputs).  (The error was detected in both
cases, but the errno was extracted from the wrong dict.)

libctf/ChangeLog
2021-03-18  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-dedup.c (ctf_dedup_rhash_type): Report errors on the input
	dict properly.
	* ctf-open.c (ctf_bufopen_internal): Report errors initializing
	the atoms table.
2021-03-18 12:40:41 +00:00