Commit Graph

197 Commits

Author SHA1 Message Date
Tom Tromey c3693a1d94 Turn start_psymtab_common into a constructor
This turns start_psymtab_common into a constructor, and then changes
the callers to use "new" directly.  This completes the psymtab
allocation transition -- now it is possible for symbol readers to
subclass struct partial_symtab.

gdb/ChangeLog
2020-01-26  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_start_psymtab): Use new.
	* psymtab.c (partial_symtab::partial_symtab): New constructor,
	renamed from start_psymtab_common.
	* psympriv.h (struct partial_symtab): Add new constructor.
	(start_psymtab_common): Don't declare.
	* mdebugread.c (parse_partial_symbols): Use new.
	* dwarf2read.c (create_partial_symtab): Use new.
	* dbxread.c (start_psymtab): Use new.
	* ctfread.c (create_partial_symtab): Use new.

Change-Id: I5a0217bcb52bcfa442559771954bb66bd9ccbf02
2020-01-26 16:40:21 -07:00
Tom Tromey 32caafd02b Change allocate_psymtab to be a constructor
This is the next step in getting the symbol readers to allocate
psymtabs themselves: change allocate_psymtab to be an ordinary
constructor, and then use "new" at the previous call sites.  Note that
this doesn't get us all the way -- start_psymtab_common is still
allocating a partial symtab.

gdb/ChangeLog
2020-01-26  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_end_psymtab): Use new.
	* psymtab.c (start_psymtab_common): Use new.
	(partial_symtab::partial_symtab): Rename from allocate_psymtab.
	Update.
	* psympriv.h (struct partial_symtab): Add parameters to
	constructor.  Don't inline.
	(allocate_psymtab): Don't declare.
	* mdebugread.c (new_psymtab): Use new.
	* dwarf2read.c (dwarf2_create_include_psymtab): Use new.
	* dbxread.c (dbx_end_psymtab): Use new.

Change-Id: Iffeae64c925050b90b9916cbc36e15b26ff42226
2020-01-26 16:40:21 -07:00
Tom Tromey abaa2f2340 Do not allocate psymtabs via psymtab_storage
Currently, partial symbol tables are allocated by a method in
psymtab_storage.  However, eventually we want to subclass partial
symtabs in the symbol readers, so the calls to "new" will have to
happen there.  This patch is a first step, moving the allocation from
psymtab_storage and into allocate_psymtab.

gdb/ChangeLog
2020-01-26  Tom Tromey  <tom@tromey.com>

	* psymtab.h (class psymtab_storage) <install_psymtab>: Rename from
	allocate_psymtab.  Update documentation.
	* psymtab.c (psymtab_storage::install_psymtab): Rename from
	allocate_psymtab.  Do not use new.
	(allocate_psymtab): Use new.  Update.

Change-Id: Iba6a9bf3ee1e78062fdb9f007c3010f826f64bc8
2020-01-26 16:40:21 -07:00
Tom Tromey 6d94535fc6 Change some psymtab fields to bool
This changes a few fields in partial_symtab to have type bool.

gdb/ChangeLog
2020-01-26  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_psymtab_to_symtab_1): Update.
	* psymtab.c (psym_print_stats): Update.
	* psympriv.h (struct partial_symtab) <readin,
	psymtabs_addrmap_supported, anonymous>: Now bool.
	* mdebugread.c (psymtab_to_symtab_1): Update.
	* dwarf2read.c (create_type_unit_group, create_partial_symtab)
	(build_type_psymtabs_reader, psymtab_to_symtab_1)
	(process_full_comp_unit, process_full_type_unit): Update.
	* dbxread.c (dbx_psymtab_to_symtab_1): Update.
	* ctfread.c (psymtab_to_symtab): Update.

Change-Id: I206761d083493589049ea0bc785ed6542339234d
2020-01-26 16:40:21 -07:00
Tom Tromey 6f17252b76 Use new and delete for psymtabs
This changes psymtabs to be allocated with new and destroyed with
delete.  As a consequence, the psymtab free-list is also removed.

The motivation for this is to let symbol readers subclass
partial_symtab.

gdb/ChangeLog
2020-01-26  Tom Tromey  <tom@tromey.com>

	* mdebugread.c (parse_partial_symbols): Use discard_psymtab.
	* psymtab.h (class psymtab_storage) <free_psymtabs>: Remove.
	* psymtab.c (psymtab_storage): Delete psymtabs.
	(psymtab_storage::allocate_psymtab): Use new.
	(psymtab_storage::discard_psymtab): Use delete.
	* psympriv.h (struct partial_symtab): Add constructor and
	initializers.

Change-Id: I4e78ac538fc0ea52b57489c1afb8f935a30941ef
2020-01-26 16:40:20 -07:00
Simon Marchi b3b3bada0d gdb: introduce objfile text_section_offset and data_section_offset methods
The pattern

  objfile->section_offsets[SECT_OFF_TEXT (objfile)]

... appears very often, to get the offset of the text section of an
objfile.  I thought it would be more readable to write it as:

  objfile->text_section_offset ()

... so I added this method and used it where possible.  I also added
data_section_offset, although it is not used as much.

gdb/ChangeLog:

	* objfiles.h (ALL_OBJFILE_OSECTIONS): Move up.
	(SECT_OFF_DATA): Likewise.
	(SECT_OFF_RODATA): Likewise.
	(SECT_OFF_TEXT): Likewise.
	(SECT_OFF_BSS): Likewise.
	(struct objfile) <text_section_offset, data_section_offset>: New
	methods.
	* amd64-windows-tdep.c (amd64_windows_find_unwind_info): Use
	objfile::text_section_offset.
	* coff-pe-read.c (add_pe_forwarded_sym): Likewise.
	* coffread.c (coff_symtab_read): Likewise.
	(enter_linenos): Likewise.
	(process_coff_symbol): Likewise.
	* ctfread.c (get_objfile_text_range): Likewise.
	* dtrace-probe.c (dtrace_probe::get_relocated_address):
	Use objfile::data_section_offset.
	* dwarf2-frame.c (execute_cfa_program): Use
	objfile::text_section_offset.
	(dwarf2_frame_find_fde): Likewise.
	* dwarf2read.c (create_addrmap_from_index): Likewise.
	(create_addrmap_from_aranges): Likewise.
	(dw2_find_pc_sect_compunit_symtab): Likewise.
	(process_psymtab_comp_unit_reader): Likewise.
	(add_partial_symbol): Likewise.
	(add_partial_subprogram): Likewise.
	(process_full_comp_unit): Likewise.
	(read_file_scope): Likewise.
	(read_func_scope): Likewise.
	(read_lexical_block_scope): Likewise.
	(read_call_site_scope): Likewise.
	(dwarf2_rnglists_process): Likewise.
	(dwarf2_ranges_process): Likewise.
	(dwarf2_ranges_read): Likewise.
	(dwarf_decode_lines_1): Likewise.
	(new_symbol): Likewise.
	(dwarf2_fetch_die_loc_sect_off): Likewise.
	(dwarf2_per_cu_text_offset): Likewise.
	* hppa-bsd-tdep.c (hppabsd_find_global_pointer): Likewise.
	* hppa-tdep.c (read_unwind_info): Likewise.
	* ia64-tdep.c (ia64_find_unwind_table): Likewise.
	* psympriv.h (struct partial_symtab): Likewise.
	* psymtab.c (find_pc_sect_psymtab): Likewise.
	* solib-svr4.c (enable_break): Likewise.
	* stap-probe.c (relocate_address): Use
	objfile::data_section_offset.
	* xcoffread.c (enter_line_range): Use
	objfile::text_section_offset.
	(read_xcoff_symtab): Likewise.
2020-01-23 17:55:35 -05:00
Simon Marchi 6c2659886f gdb: add back declarations for _initialize functions
I'd like to enable the -Wmissing-declarations warning.  However, it
warns for every _initialize function, for example:

      CXX    dcache.o
    /home/smarchi/src/binutils-gdb/gdb/dcache.c: In function ‘void _initialize_dcache()’:
    /home/smarchi/src/binutils-gdb/gdb/dcache.c:688:1: error: no previous declaration for ‘void _initialize_dcache()’ [-Werror=missing-declarations]
     _initialize_dcache (void)
     ^~~~~~~~~~~~~~~~~~

The only practical way forward I found is to add back the declarations,
which were removed by this commit:

    commit 481695ed5f
    Author: John Baldwin <jhb@FreeBSD.org>
    Date:   Sat Sep 9 11:02:37 2017 -0700

        Remove unnecessary function prototypes.

I don't think it's a big problem to have the declarations for these
functions, but if anybody has a better solution for this, I'll be happy
to use it.

gdb/ChangeLog:

	* aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Add declaration.
	* aarch64-fbsd-tdep.c (_initialize_aarch64_fbsd_tdep): Add declaration.
	* aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Add declaration.
	* aarch64-linux-tdep.c (_initialize_aarch64_linux_tdep): Add declaration.
	* aarch64-newlib-tdep.c (_initialize_aarch64_newlib_tdep): Add declaration.
	* aarch64-tdep.c (_initialize_aarch64_tdep): Add declaration.
	* ada-exp.y (_initialize_ada_exp): Add declaration.
	* ada-lang.c (_initialize_ada_language): Add declaration.
	* ada-tasks.c (_initialize_tasks): Add declaration.
	* agent.c (_initialize_agent): Add declaration.
	* aix-thread.c (_initialize_aix_thread): Add declaration.
	* alpha-bsd-nat.c (_initialize_alphabsd_nat): Add declaration.
	* alpha-linux-nat.c (_initialize_alpha_linux_nat): Add declaration.
	* alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add declaration.
	* alpha-nbsd-tdep.c (_initialize_alphanbsd_tdep): Add declaration.
	* alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Add declaration.
	* alpha-tdep.c (_initialize_alpha_tdep): Add declaration.
	* amd64-darwin-tdep.c (_initialize_amd64_darwin_tdep): Add declaration.
	* amd64-dicos-tdep.c (_initialize_amd64_dicos_tdep): Add declaration.
	* amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Add declaration.
	* amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Add declaration.
	* amd64-linux-nat.c (_initialize_amd64_linux_nat): Add declaration.
	* amd64-linux-tdep.c (_initialize_amd64_linux_tdep): Add declaration.
	* amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Add declaration.
	* amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Add declaration.
	* amd64-obsd-nat.c (_initialize_amd64obsd_nat): Add declaration.
	* amd64-obsd-tdep.c (_initialize_amd64obsd_tdep): Add declaration.
	* amd64-sol2-tdep.c (_initialize_amd64_sol2_tdep): Add declaration.
	* amd64-tdep.c (_initialize_amd64_tdep): Add declaration.
	* amd64-windows-nat.c (_initialize_amd64_windows_nat): Add declaration.
	* amd64-windows-tdep.c (_initialize_amd64_windows_tdep): Add declaration.
	* annotate.c (_initialize_annotate): Add declaration.
	* arc-newlib-tdep.c (_initialize_arc_newlib_tdep): Add declaration.
	* arc-tdep.c (_initialize_arc_tdep): Add declaration.
	* arch-utils.c (_initialize_gdbarch_utils): Add declaration.
	* arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Add declaration.
	* arm-fbsd-tdep.c (_initialize_arm_fbsd_tdep): Add declaration.
	* arm-linux-nat.c (_initialize_arm_linux_nat): Add declaration.
	* arm-linux-tdep.c (_initialize_arm_linux_tdep): Add declaration.
	* arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Add declaration.
	* arm-nbsd-tdep.c (_initialize_arm_netbsd_tdep): Add declaration.
	* arm-obsd-tdep.c (_initialize_armobsd_tdep): Add declaration.
	* arm-pikeos-tdep.c (_initialize_arm_pikeos_tdep): Add declaration.
	* arm-symbian-tdep.c (_initialize_arm_symbian_tdep): Add declaration.
	* arm-tdep.c (_initialize_arm_tdep): Add declaration.
	* arm-wince-tdep.c (_initialize_arm_wince_tdep): Add declaration.
	* auto-load.c (_initialize_auto_load): Add declaration.
	* auxv.c (_initialize_auxv): Add declaration.
	* avr-tdep.c (_initialize_avr_tdep): Add declaration.
	* ax-gdb.c (_initialize_ax_gdb): Add declaration.
	* bfin-linux-tdep.c (_initialize_bfin_linux_tdep): Add declaration.
	* bfin-tdep.c (_initialize_bfin_tdep): Add declaration.
	* break-catch-sig.c (_initialize_break_catch_sig): Add declaration.
	* break-catch-syscall.c (_initialize_break_catch_syscall): Add declaration.
	* break-catch-throw.c (_initialize_break_catch_throw): Add declaration.
	* breakpoint.c (_initialize_breakpoint): Add declaration.
	* bsd-uthread.c (_initialize_bsd_uthread): Add declaration.
	* btrace.c (_initialize_btrace): Add declaration.
	* charset.c (_initialize_charset): Add declaration.
	* cli/cli-cmds.c (_initialize_cli_cmds): Add declaration.
	* cli/cli-dump.c (_initialize_cli_dump): Add declaration.
	* cli/cli-interp.c (_initialize_cli_interp): Add declaration.
	* cli/cli-logging.c (_initialize_cli_logging): Add declaration.
	* cli/cli-script.c (_initialize_cli_script): Add declaration.
	* cli/cli-style.c (_initialize_cli_style): Add declaration.
	* coff-pe-read.c (_initialize_coff_pe_read): Add declaration.
	* coffread.c (_initialize_coffread): Add declaration.
	* compile/compile-cplus-types.c (_initialize_compile_cplus_types): Add declaration.
	* compile/compile.c (_initialize_compile): Add declaration.
	* complaints.c (_initialize_complaints): Add declaration.
	* completer.c (_initialize_completer): Add declaration.
	* copying.c (_initialize_copying): Add declaration.
	* corefile.c (_initialize_core): Add declaration.
	* corelow.c (_initialize_corelow): Add declaration.
	* cp-abi.c (_initialize_cp_abi): Add declaration.
	* cp-namespace.c (_initialize_cp_namespace): Add declaration.
	* cp-support.c (_initialize_cp_support): Add declaration.
	* cp-valprint.c (_initialize_cp_valprint): Add declaration.
	* cris-linux-tdep.c (_initialize_cris_linux_tdep): Add declaration.
	* cris-tdep.c (_initialize_cris_tdep): Add declaration.
	* csky-linux-tdep.c (_initialize_csky_linux_tdep): Add declaration.
	* csky-tdep.c (_initialize_csky_tdep): Add declaration.
	* ctfread.c (_initialize_ctfread): Add declaration.
	* d-lang.c (_initialize_d_language): Add declaration.
	* darwin-nat-info.c (_initialize_darwin_info_commands): Add declaration.
	* darwin-nat.c (_initialize_darwin_nat): Add declaration.
	* dbxread.c (_initialize_dbxread): Add declaration.
	* dcache.c (_initialize_dcache): Add declaration.
	* disasm-selftests.c (_initialize_disasm_selftests): Add declaration.
	* disasm.c (_initialize_disasm): Add declaration.
	* dtrace-probe.c (_initialize_dtrace_probe): Add declaration.
	* dummy-frame.c (_initialize_dummy_frame): Add declaration.
	* dwarf-index-cache.c (_initialize_index_cache): Add declaration.
	* dwarf-index-write.c (_initialize_dwarf_index_write): Add declaration.
	* dwarf2-frame-tailcall.c (_initialize_tailcall_frame): Add declaration.
	* dwarf2-frame.c (_initialize_dwarf2_frame): Add declaration.
	* dwarf2expr.c (_initialize_dwarf2expr): Add declaration.
	* dwarf2loc.c (_initialize_dwarf2loc): Add declaration.
	* dwarf2read.c (_initialize_dwarf2_read): Add declaration.
	* elfread.c (_initialize_elfread): Add declaration.
	* exec.c (_initialize_exec): Add declaration.
	* extension.c (_initialize_extension): Add declaration.
	* f-lang.c (_initialize_f_language): Add declaration.
	* f-valprint.c (_initialize_f_valprint): Add declaration.
	* fbsd-nat.c (_initialize_fbsd_nat): Add declaration.
	* fbsd-tdep.c (_initialize_fbsd_tdep): Add declaration.
	* filesystem.c (_initialize_filesystem): Add declaration.
	* findcmd.c (_initialize_mem_search): Add declaration.
	* findvar.c (_initialize_findvar): Add declaration.
	* fork-child.c (_initialize_fork_child): Add declaration.
	* frame-base.c (_initialize_frame_base): Add declaration.
	* frame-unwind.c (_initialize_frame_unwind): Add declaration.
	* frame.c (_initialize_frame): Add declaration.
	* frv-linux-tdep.c (_initialize_frv_linux_tdep): Add declaration.
	* frv-tdep.c (_initialize_frv_tdep): Add declaration.
	* ft32-tdep.c (_initialize_ft32_tdep): Add declaration.
	* gcore.c (_initialize_gcore): Add declaration.
	* gdb-demangle.c (_initialize_gdb_demangle): Add declaration.
	* gdb_bfd.c (_initialize_gdb_bfd): Add declaration.
	* gdbarch-selftests.c (_initialize_gdbarch_selftests): Add declaration.
	* gdbarch.c (_initialize_gdbarch): Add declaration.
	* gdbtypes.c (_initialize_gdbtypes): Add declaration.
	* gnu-nat.c (_initialize_gnu_nat): Add declaration.
	* gnu-v2-abi.c (_initialize_gnu_v2_abi): Add declaration.
	* gnu-v3-abi.c (_initialize_gnu_v3_abi): Add declaration.
	* go-lang.c (_initialize_go_language): Add declaration.
	* go32-nat.c (_initialize_go32_nat): Add declaration.
	* guile/guile.c (_initialize_guile): Add declaration.
	* h8300-tdep.c (_initialize_h8300_tdep): Add declaration.
	* hppa-linux-nat.c (_initialize_hppa_linux_nat): Add declaration.
	* hppa-linux-tdep.c (_initialize_hppa_linux_tdep): Add declaration.
	* hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Add declaration.
	* hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Add declaration.
	* hppa-obsd-nat.c (_initialize_hppaobsd_nat): Add declaration.
	* hppa-obsd-tdep.c (_initialize_hppabsd_tdep): Add declaration.
	* hppa-tdep.c (_initialize_hppa_tdep): Add declaration.
	* i386-bsd-nat.c (_initialize_i386bsd_nat): Add declaration.
	* i386-cygwin-tdep.c (_initialize_i386_cygwin_tdep): Add declaration.
	* i386-darwin-nat.c (_initialize_i386_darwin_nat): Add declaration.
	* i386-darwin-tdep.c (_initialize_i386_darwin_tdep): Add declaration.
	* i386-dicos-tdep.c (_initialize_i386_dicos_tdep): Add declaration.
	* i386-fbsd-nat.c (_initialize_i386fbsd_nat): Add declaration.
	* i386-fbsd-tdep.c (_initialize_i386fbsd_tdep): Add declaration.
	* i386-gnu-nat.c (_initialize_i386gnu_nat): Add declaration.
	* i386-gnu-tdep.c (_initialize_i386gnu_tdep): Add declaration.
	* i386-go32-tdep.c (_initialize_i386_go32_tdep): Add declaration.
	* i386-linux-nat.c (_initialize_i386_linux_nat): Add declaration.
	* i386-linux-tdep.c (_initialize_i386_linux_tdep): Add declaration.
	* i386-nbsd-nat.c (_initialize_i386nbsd_nat): Add declaration.
	* i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Add declaration.
	* i386-nto-tdep.c (_initialize_i386nto_tdep): Add declaration.
	* i386-obsd-nat.c (_initialize_i386obsd_nat): Add declaration.
	* i386-obsd-tdep.c (_initialize_i386obsd_tdep): Add declaration.
	* i386-sol2-nat.c (_initialize_amd64_sol2_nat): Add declaration.
	* i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Add declaration.
	* i386-tdep.c (_initialize_i386_tdep): Add declaration.
	* i386-windows-nat.c (_initialize_i386_windows_nat): Add declaration.
	* ia64-libunwind-tdep.c (_initialize_libunwind_frame): Add declaration.
	* ia64-linux-nat.c (_initialize_ia64_linux_nat): Add declaration.
	* ia64-linux-tdep.c (_initialize_ia64_linux_tdep): Add declaration.
	* ia64-tdep.c (_initialize_ia64_tdep): Add declaration.
	* ia64-vms-tdep.c (_initialize_ia64_vms_tdep): Add declaration.
	* infcall.c (_initialize_infcall): Add declaration.
	* infcmd.c (_initialize_infcmd): Add declaration.
	* inflow.c (_initialize_inflow): Add declaration.
	* infrun.c (_initialize_infrun): Add declaration.
	* interps.c (_initialize_interpreter): Add declaration.
	* iq2000-tdep.c (_initialize_iq2000_tdep): Add declaration.
	* jit.c (_initialize_jit): Add declaration.
	* language.c (_initialize_language): Add declaration.
	* linux-fork.c (_initialize_linux_fork): Add declaration.
	* linux-nat.c (_initialize_linux_nat): Add declaration.
	* linux-tdep.c (_initialize_linux_tdep): Add declaration.
	* linux-thread-db.c (_initialize_thread_db): Add declaration.
	* lm32-tdep.c (_initialize_lm32_tdep): Add declaration.
	* m2-lang.c (_initialize_m2_language): Add declaration.
	* m32c-tdep.c (_initialize_m32c_tdep): Add declaration.
	* m32r-linux-nat.c (_initialize_m32r_linux_nat): Add declaration.
	* m32r-linux-tdep.c (_initialize_m32r_linux_tdep): Add declaration.
	* m32r-tdep.c (_initialize_m32r_tdep): Add declaration.
	* m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration.
	* m68k-bsd-nat.c (_initialize_m68kbsd_nat): Add declaration.
	* m68k-bsd-tdep.c (_initialize_m68kbsd_tdep): Add declaration.
	* m68k-linux-nat.c (_initialize_m68k_linux_nat): Add declaration.
	* m68k-linux-tdep.c (_initialize_m68k_linux_tdep): Add declaration.
	* m68k-tdep.c (_initialize_m68k_tdep): Add declaration.
	* machoread.c (_initialize_machoread): Add declaration.
	* macrocmd.c (_initialize_macrocmd): Add declaration.
	* macroscope.c (_initialize_macroscope): Add declaration.
	* maint-test-options.c (_initialize_maint_test_options): Add declaration.
	* maint-test-settings.c (_initialize_maint_test_settings): Add declaration.
	* maint.c (_initialize_maint_cmds): Add declaration.
	* mdebugread.c (_initialize_mdebugread): Add declaration.
	* memattr.c (_initialize_mem): Add declaration.
	* mep-tdep.c (_initialize_mep_tdep): Add declaration.
	* mi/mi-cmd-env.c (_initialize_mi_cmd_env): Add declaration.
	* mi/mi-cmds.c (_initialize_mi_cmds): Add declaration.
	* mi/mi-interp.c (_initialize_mi_interp): Add declaration.
	* mi/mi-main.c (_initialize_mi_main): Add declaration.
	* microblaze-linux-tdep.c (_initialize_microblaze_linux_tdep): Add declaration.
	* microblaze-tdep.c (_initialize_microblaze_tdep): Add declaration.
	* mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Add declaration.
	* mips-fbsd-tdep.c (_initialize_mips_fbsd_tdep): Add declaration.
	* mips-linux-nat.c (_initialize_mips_linux_nat): Add declaration.
	* mips-linux-tdep.c (_initialize_mips_linux_tdep): Add declaration.
	* mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Add declaration.
	* mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Add declaration.
	* mips-sde-tdep.c (_initialize_mips_sde_tdep): Add declaration.
	* mips-tdep.c (_initialize_mips_tdep): Add declaration.
	* mips64-obsd-nat.c (_initialize_mips64obsd_nat): Add declaration.
	* mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Add declaration.
	* mipsread.c (_initialize_mipsread): Add declaration.
	* mn10300-linux-tdep.c (_initialize_mn10300_linux_tdep): Add declaration.
	* mn10300-tdep.c (_initialize_mn10300_tdep): Add declaration.
	* moxie-tdep.c (_initialize_moxie_tdep): Add declaration.
	* msp430-tdep.c (_initialize_msp430_tdep): Add declaration.
	* nds32-tdep.c (_initialize_nds32_tdep): Add declaration.
	* nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Add declaration.
	* nios2-tdep.c (_initialize_nios2_tdep): Add declaration.
	* nto-procfs.c (_initialize_procfs): Add declaration.
	* objc-lang.c (_initialize_objc_language): Add declaration.
	* observable.c (_initialize_observer): Add declaration.
	* opencl-lang.c (_initialize_opencl_language): Add declaration.
	* or1k-linux-tdep.c (_initialize_or1k_linux_tdep): Add declaration.
	* or1k-tdep.c (_initialize_or1k_tdep): Add declaration.
	* osabi.c (_initialize_gdb_osabi): Add declaration.
	* osdata.c (_initialize_osdata): Add declaration.
	* p-valprint.c (_initialize_pascal_valprint): Add declaration.
	* parse.c (_initialize_parse): Add declaration.
	* ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Add declaration.
	* ppc-fbsd-tdep.c (_initialize_ppcfbsd_tdep): Add declaration.
	* ppc-linux-nat.c (_initialize_ppc_linux_nat): Add declaration.
	* ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Add declaration.
	* ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Add declaration.
	* ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Add declaration.
	* ppc-obsd-nat.c (_initialize_ppcobsd_nat): Add declaration.
	* ppc-obsd-tdep.c (_initialize_ppcobsd_tdep): Add declaration.
	* printcmd.c (_initialize_printcmd): Add declaration.
	* probe.c (_initialize_probe): Add declaration.
	* proc-api.c (_initialize_proc_api): Add declaration.
	* proc-events.c (_initialize_proc_events): Add declaration.
	* proc-service.c (_initialize_proc_service): Add declaration.
	* procfs.c (_initialize_procfs): Add declaration.
	* producer.c (_initialize_producer): Add declaration.
	* psymtab.c (_initialize_psymtab): Add declaration.
	* python/python.c (_initialize_python): Add declaration.
	* ravenscar-thread.c (_initialize_ravenscar): Add declaration.
	* record-btrace.c (_initialize_record_btrace): Add declaration.
	* record-full.c (_initialize_record_full): Add declaration.
	* record.c (_initialize_record): Add declaration.
	* regcache-dump.c (_initialize_regcache_dump): Add declaration.
	* regcache.c (_initialize_regcache): Add declaration.
	* reggroups.c (_initialize_reggroup): Add declaration.
	* remote-notif.c (_initialize_notif): Add declaration.
	* remote-sim.c (_initialize_remote_sim): Add declaration.
	* remote.c (_initialize_remote): Add declaration.
	* reverse.c (_initialize_reverse): Add declaration.
	* riscv-fbsd-nat.c (_initialize_riscv_fbsd_nat): Add declaration.
	* riscv-fbsd-tdep.c (_initialize_riscv_fbsd_tdep): Add declaration.
	* riscv-linux-nat.c (_initialize_riscv_linux_nat): Add declaration.
	* riscv-linux-tdep.c (_initialize_riscv_linux_tdep): Add declaration.
	* riscv-tdep.c (_initialize_riscv_tdep): Add declaration.
	* rl78-tdep.c (_initialize_rl78_tdep): Add declaration.
	* rs6000-aix-tdep.c (_initialize_rs6000_aix_tdep): Add declaration.
	* rs6000-lynx178-tdep.c (_initialize_rs6000_lynx178_tdep):
	Add declaration.
	* rs6000-nat.c (_initialize_rs6000_nat): Add declaration.
	* rs6000-tdep.c (_initialize_rs6000_tdep): Add declaration.
	* run-on-main-thread.c (_initialize_run_on_main_thread): Add declaration.
	* rust-exp.y (_initialize_rust_exp): Add declaration.
	* rx-tdep.c (_initialize_rx_tdep): Add declaration.
	* s12z-tdep.c (_initialize_s12z_tdep): Add declaration.
	* s390-linux-nat.c (_initialize_s390_nat): Add declaration.
	* s390-linux-tdep.c (_initialize_s390_linux_tdep): Add declaration.
	* s390-tdep.c (_initialize_s390_tdep): Add declaration.
	* score-tdep.c (_initialize_score_tdep): Add declaration.
	* ser-go32.c (_initialize_ser_dos): Add declaration.
	* ser-mingw.c (_initialize_ser_windows): Add declaration.
	* ser-pipe.c (_initialize_ser_pipe): Add declaration.
	* ser-tcp.c (_initialize_ser_tcp): Add declaration.
	* ser-uds.c (_initialize_ser_socket): Add declaration.
	* ser-unix.c (_initialize_ser_hardwire): Add declaration.
	* serial.c (_initialize_serial): Add declaration.
	* sh-linux-tdep.c (_initialize_sh_linux_tdep): Add declaration.
	* sh-nbsd-nat.c (_initialize_shnbsd_nat): Add declaration.
	* sh-nbsd-tdep.c (_initialize_shnbsd_tdep): Add declaration.
	* sh-tdep.c (_initialize_sh_tdep): Add declaration.
	* skip.c (_initialize_step_skip): Add declaration.
	* sol-thread.c (_initialize_sol_thread): Add declaration.
	* solib-aix.c (_initialize_solib_aix): Add declaration.
	* solib-darwin.c (_initialize_darwin_solib): Add declaration.
	* solib-dsbt.c (_initialize_dsbt_solib): Add declaration.
	* solib-frv.c (_initialize_frv_solib): Add declaration.
	* solib-svr4.c (_initialize_svr4_solib): Add declaration.
	* solib-target.c (_initialize_solib_target): Add declaration.
	* solib.c (_initialize_solib): Add declaration.
	* source-cache.c (_initialize_source_cache): Add declaration.
	* source.c (_initialize_source): Add declaration.
	* sparc-linux-nat.c (_initialize_sparc_linux_nat): Add declaration.
	* sparc-linux-tdep.c (_initialize_sparc_linux_tdep): Add declaration.
	* sparc-nat.c (_initialize_sparc_nat): Add declaration.
	* sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Add declaration.
	* sparc-nbsd-tdep.c (_initialize_sparcnbsd_tdep): Add declaration.
	* sparc-obsd-tdep.c (_initialize_sparc32obsd_tdep): Add declaration.
	* sparc-sol2-tdep.c (_initialize_sparc_sol2_tdep): Add declaration.
	* sparc-tdep.c (_initialize_sparc_tdep): Add declaration.
	* sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Add declaration.
	* sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Add declaration.
	* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Add declaration.
	* sparc64-linux-tdep.c (_initialize_sparc64_linux_tdep): Add declaration.
	* sparc64-nat.c (_initialize_sparc64_nat): Add declaration.
	* sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Add declaration.
	* sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Add declaration.
	* sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Add declaration.
	* sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Add declaration.
	* sparc64-sol2-tdep.c (_initialize_sparc64_sol2_tdep): Add declaration.
	* sparc64-tdep.c (_initialize_sparc64_adi_tdep): Add declaration.
	* stabsread.c (_initialize_stabsread): Add declaration.
	* stack.c (_initialize_stack): Add declaration.
	* stap-probe.c (_initialize_stap_probe): Add declaration.
	* std-regs.c (_initialize_frame_reg): Add declaration.
	* symfile-debug.c (_initialize_symfile_debug): Add declaration.
	* symfile-mem.c (_initialize_symfile_mem): Add declaration.
	* symfile.c (_initialize_symfile): Add declaration.
	* symmisc.c (_initialize_symmisc): Add declaration.
	* symtab.c (_initialize_symtab): Add declaration.
	* target.c (_initialize_target): Add declaration.
	* target-connection.c (_initialize_target_connection): Add
	declaration.
	* target-dcache.c (_initialize_target_dcache): Add declaration.
	* target-descriptions.c (_initialize_target_descriptions): Add declaration.
	* thread.c (_initialize_thread): Add declaration.
	* tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Add declaration.
	* tic6x-tdep.c (_initialize_tic6x_tdep): Add declaration.
	* tilegx-linux-nat.c (_initialize_tile_linux_nat): Add declaration.
	* tilegx-linux-tdep.c (_initialize_tilegx_linux_tdep): Add declaration.
	* tilegx-tdep.c (_initialize_tilegx_tdep): Add declaration.
	* tracectf.c (_initialize_ctf): Add declaration.
	* tracefile-tfile.c (_initialize_tracefile_tfile): Add declaration.
	* tracefile.c (_initialize_tracefile): Add declaration.
	* tracepoint.c (_initialize_tracepoint): Add declaration.
	* tui/tui-hooks.c (_initialize_tui_hooks): Add declaration.
	* tui/tui-interp.c (_initialize_tui_interp): Add declaration.
	* tui/tui-layout.c (_initialize_tui_layout): Add declaration.
	* tui/tui-regs.c (_initialize_tui_regs): Add declaration.
	* tui/tui-stack.c (_initialize_tui_stack): Add declaration.
	* tui/tui-win.c (_initialize_tui_win): Add declaration.
	* tui/tui.c (_initialize_tui): Add declaration.
	* typeprint.c (_initialize_typeprint): Add declaration.
	* ui-style.c (_initialize_ui_style): Add declaration.
	* unittests/array-view-selftests.c (_initialize_array_view_selftests): Add declaration.
	* unittests/child-path-selftests.c (_initialize_child_path_selftests): Add declaration.
	* unittests/cli-utils-selftests.c (_initialize_cli_utils_selftests): Add declaration.
	* unittests/common-utils-selftests.c (_initialize_common_utils_selftests): Add declaration.
	* unittests/copy_bitwise-selftests.c (_initialize_copy_bitwise_utils_selftests): Add declaration.
	* unittests/environ-selftests.c (_initialize_environ_selftests): Add declaration.
	* unittests/filtered_iterator-selftests.c
	(_initialize_filtered_iterator_selftests): Add declaration.
	* unittests/format_pieces-selftests.c (_initialize_format_pieces_selftests): Add declaration.
	* unittests/function-view-selftests.c (_initialize_function_view_selftests): Add declaration.
	* unittests/help-doc-selftests.c (_initialize_help_doc_selftests): Add declaration.
	* unittests/lookup_name_info-selftests.c (_initialize_lookup_name_info_selftests): Add declaration.
	* unittests/main-thread-selftests.c
	(_initialize_main_thread_selftests): Add declaration.
	* unittests/memory-map-selftests.c (_initialize_memory_map_selftests): Add declaration.
	* unittests/memrange-selftests.c (_initialize_memrange_selftests): Add declaration.
	* unittests/mkdir-recursive-selftests.c (_initialize_mkdir_recursive_selftests): Add declaration.
	* unittests/observable-selftests.c (_initialize_observer_selftest): Add declaration.
	* unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Add declaration.
	* unittests/optional-selftests.c (_initialize_optional_selftests): Add declaration.
	* unittests/parse-connection-spec-selftests.c (_initialize_parse_connection_spec_selftests): Add declaration.
	* unittests/rsp-low-selftests.c (_initialize_rsp_low_selftests): Add declaration.
	* unittests/scoped_fd-selftests.c (_initialize_scoped_fd_selftests): Add declaration.
	* unittests/scoped_mmap-selftests.c (_initialize_scoped_mmap_selftests): Add declaration.
	* unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Add declaration.
	* unittests/string_view-selftests.c (_initialize_string_view_selftests): Add declaration.
	* unittests/style-selftests.c (_initialize_style_selftest): Add declaration.
	* unittests/tracepoint-selftests.c (_initialize_tracepoint_selftests): Add declaration.
	* unittests/tui-selftests.c (_initialize_tui_selftest): Add
	declaration.
	* unittests/unpack-selftests.c (_initialize_unpack_selftests): Add declaration.
	* unittests/utils-selftests.c (_initialize_utils_selftests): Add declaration.
	* unittests/vec-utils-selftests.c (_initialize_vec_utils_selftests): Add declaration.
	* unittests/xml-utils-selftests.c (_initialize_xml_utils): Add declaration.
	* user-regs.c (_initialize_user_regs): Add declaration.
	* utils.c (_initialize_utils): Add declaration.
	* v850-tdep.c (_initialize_v850_tdep): Add declaration.
	* valops.c (_initialize_valops): Add declaration.
	* valprint.c (_initialize_valprint): Add declaration.
	* value.c (_initialize_values): Add declaration.
	* varobj.c (_initialize_varobj): Add declaration.
	* vax-bsd-nat.c (_initialize_vaxbsd_nat): Add declaration.
	* vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Add declaration.
	* vax-tdep.c (_initialize_vax_tdep): Add declaration.
	* windows-nat.c (_initialize_windows_nat): Add declaration.
	(_initialize_check_for_gdb_ini): Add declaration.
	(_initialize_loadable): Add declaration.
	* windows-tdep.c (_initialize_windows_tdep): Add declaration.
	* x86-bsd-nat.c (_initialize_x86_bsd_nat): Add declaration.
	* x86-linux-nat.c (_initialize_x86_linux_nat): Add declaration.
	* xcoffread.c (_initialize_xcoffread): Add declaration.
	* xml-support.c (_initialize_xml_support): Add declaration.
	* xstormy16-tdep.c (_initialize_xstormy16_tdep): Add declaration.
	* xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Add declaration.
	* xtensa-linux-tdep.c (_initialize_xtensa_linux_tdep): Add declaration.
	* xtensa-tdep.c (_initialize_xtensa_tdep): Add declaration.

Change-Id: I13eec7e0ed2b3c427377a7bdb055cf46da64def9
2020-01-13 14:01:38 -05:00
Tom Tromey 6a053cb1ff Change section_offsets to a std::vector
This changes section_offsets to be specialization of a std::vector and
updates all the users.  It also removes the ANOFFSET and
SIZEOF_N_SECTION_OFFSETS macros.

Most of this is just a generic sort of cleanup, that reduces the
number of lines of code.  However, a couple spots were doing weird
things.

objfile_relocate did:

-      std::vector<struct section_offsets>
-	new_debug_offsets (SIZEOF_N_SECTION_OFFSETS (debug_objfile->num_sections));

... which seems to greatly over-estimate the number of elements
needed.

This appeared in set_objfile_default_section_offset:

-  std::vector<struct section_offsets> offsets (objf->num_sections,
-					       { { offset } });

... which makes sense due to type safety, but is also actively
confusing given that section_offsets was previously also a kind of
vector type.

Tested on x86-64 Fedora 30.

gdb/ChangeLog
2020-01-08  Tom Tromey  <tromey@adacore.com>

	* xcoffread.c (enter_line_range, read_xcoff_symtab)
	(process_xcoff_symbol, xcoff_symfile_offsets): Update.
	* symtab.h (MSYMBOL_VALUE_ADDRESS): Update.
	(struct section_offsets, ANOFFSET, SIZEOF_N_SECTION_OFFSETS):
	Remove.
	(section_offsets): New typedef.
	* symtab.c (fixup_section, get_msymbol_address): Update.
	* symmisc.c (dump_msymbols): Update.
	* symfile.h (relative_addr_info_to_section_offsets)
	(symfile_map_offsets_to_segments): Update.
	* symfile.c (build_section_addr_info_from_objfile)
	(init_objfile_sect_indices): Update.
	(struct place_section_arg): Change type of "offsets".
	(place_section): Update.
	(relative_addr_info_to_section_offsets): Change type of
	"section_offsets".  Remove "num_sections" parameter.
	(default_symfile_offsets, syms_from_objfile_1)
	(set_objfile_default_section_offset): Update.
	(reread_symbols): No need to preserve section offsets by hand.
	(symfile_map_offsets_to_segments): Change type of "offsets".
	* stap-probe.c (relocate_address): Update.
	* stabsread.h (process_one_symbol): Update.
	* solib-target.c (struct lm_info_target) <offsets>: Change type.
	(solib_target_relocate_section_addresses): Update.
	* solib-svr4.c (enable_break, svr4_relocate_main_executable):
	Update.
	* solib-frv.c (frv_relocate_main_executable): Update.
	* solib-dsbt.c (dsbt_relocate_main_executable): Update.
	* solib-aix.c (solib_aix_get_section_offsets): Change return
	type.
	(solib_aix_solib_create_inferior_hook): Update.
	* remote.c (remote_target::get_offsets): Update.
	* psymtab.c (find_pc_sect_psymtab): Update.
	* psympriv.h (struct partial_symbol) <address, text_low,
	text_high>: Update.
	* objfiles.h (obj_section_offset): Update.
	(struct objfile) <section_offsets>: Change type.
	<num_sections>: Remove.
	(objfile_relocate): Update.
	* objfiles.c (entry_point_address_query): Update
	(relocate_one_symbol): Change type of "section_offsets".
	(objfile_relocate1, objfile_relocate1): Change type of
	"new_offsets".
	(objfile_rebase1): Update.
	* mipsread.c (mipscoff_symfile_read): Update.
	(read_alphacoff_dynamic_symtab): Remove "section_offsets"
	parameter.
	* mdebugread.c (parse_symbol): Change type of "section_offsets".
	(parse_external, psymtab_to_symtab_1): Update.
	* machoread.c (macho_symfile_offsets): Update.
	* ia64-tdep.c (ia64_find_unwind_table): Update.
	* hppa-tdep.c (read_unwind_info): Update.
	* hppa-bsd-tdep.c (hppabsd_find_global_pointer): Update.
	* dwarf2read.c (create_addrmap_from_index)
	(create_addrmap_from_aranges, dw2_find_pc_sect_compunit_symtab)
	(process_psymtab_comp_unit_reader, add_partial_symbol)
	(add_partial_subprogram, process_full_comp_unit)
	(read_file_scope, read_func_scope, read_lexical_block_scope)
	(read_call_site_scope, dwarf2_rnglists_process)
	(dwarf2_ranges_process, dwarf2_ranges_read)
	(dwarf_decode_lines_1, var_decode_location, new_symbol)
	(dwarf2_fetch_die_loc_sect_off, dwarf2_per_cu_text_offset):
	Update.
	* dwarf2-frame.c (execute_cfa_program, dwarf2_frame_find_fde):
	Update.
	* dtrace-probe.c (dtrace_probe::get_relocated_address): Update.
	* dbxread.c (read_dbx_symtab, read_ofile_symtab): Update.
	(process_one_symbol): Change type of "section_offsets".
	* ctfread.c (get_objfile_text_range): Update.
	* coffread.c (coff_symtab_read, enter_linenos)
	(process_coff_symbol): Update.
	* coff-pe-read.c (add_pe_forwarded_sym): Update.
	* amd64-windows-tdep.c (amd64_windows_find_unwind_info): Update.

Change-Id: I147eb967e9b44d82f4048039de7bb44b80cd72fb
2020-01-08 15:32:41 -07:00
Joel Brobecker b811d2c292 Update copyright year range in all GDB files.
gdb/ChangeLog:

        Update copyright year range in all GDB files.
2020-01-01 10:20:53 +04:00
Christian Biesinger 4d4eaa3005 Make symbol_set_names a member function
This also renames it to make it clearer that this is not a cheap
function (to compute_and_set_names).  Also renames name to m_name
to make the implementation of the renamed function more readable.

Most of the places that access sym->m_name directly were also changed
to call linkage_name () instead, to make it clearer which name they
are accessing.

gdb/ChangeLog:

2019-12-26  Christian Biesinger  <cbiesinger@google.com>

	* ada-lang.c (ada_decode_symbol): Update.
	* buildsym.c (add_symbol_to_list): Update.
	* coffread.c (process_coff_symbol): Update.
	* ctfread.c (ctf_add_enum_member_cb): Update.
	(new_symbol): Update.
	(ctf_add_var_cb): Update.
	* dwarf2read.c (fixup_go_packaging): Update.
	(dwarf2_compute_name): Update.
	(new_symbol): Update.
	* jit.c (finalize_symtab): Update.
	* language.c (language_alloc_type_symbol): Update.
	* mdebugread.c (new_symbol): Update.
	* minsyms.c (minimal_symbol_reader::record_full): Update.
	(minimal_symbol_reader::install): Update.
	* psymtab.c (print_partial_symbols): Update.
	(psymbol_hash): Update.
	(psymbol_compare): Update.
	(add_psymbol_to_bcache): Update.
	(maintenance_check_psymtabs): Update.
	* stabsread.c (define_symbol): Update.
	* symtab.c (symbol_set_names): Rename to...
	(general_symbol_info::compute_and_set_names): ...this.
	(general_symbol_info::natural_name): Update.
	(general_symbol_info::search_name): Update.
	(fixup_section): Update.
	* symtab.h (struct general_symbol_info) <name>: Rename to...
	<m_name>: ...this.
	<compute_and_set_names>: Rename from...
	(symbol_set_names): ...this.
	(SYMBOL_SET_NAMES): Remove.
	(struct symbol) <ctor>: Update.

Change-Id: I8da1f10cab4e0b89f19d5750fa4e6e2ac8d2b24f
2019-12-27 01:41:35 -03:00
Christian Biesinger d3ecddab5f Use a member function to set a symbol's language
This removes symbol_set_language and SYMBOL_SET_LANGUAGE in favor of
a new function general_symbol_info::set_language. symbol and minimal_symbol
already inherit from that struct so this works naturally.

gdb/ChangeLog:

2019-12-15  Christian Biesinger  <cbiesinger@google.com>

	* ada-exp.y (write_ambiguous_var): Update.
	* coffread.c (process_coff_symbol): Update.
	* ctfread.c (ctf_add_enum_member_cb): Update.
	(new_symbol): Update.
	* dwarf2read.c (fixup_go_packaging): Update.
	(new_symbol): Update.
	* language.c (language_alloc_type_symbol): Update.
	* mdebugread.c (new_symbol): Update.
	* minsyms.c (minimal_symbol_reader::record_full): Update.
	* psymtab.c (add_psymbol_to_bcache): Update.
	* stabsread.c (define_symbol): Update.
	(read_enum_type): Update.
	* symtab.c (symbol_set_language): Make this a member function...
	(general_symbol_info::set_language): ... here.
	* symtab.h (struct general_symbol_info) <set_language>: New function.
	(SYMBOL_SET_LANGUAGE): Remove.
	(symbol_set_language): Remove.

Change-Id: Ideafb6c384004b9adef793a1192735c501da41d5
2019-12-16 00:44:58 -06:00
Christian Biesinger c1b5c1ebc9 Use an accessor function for general_symbol_info::language
Also renames the member variable to m_language to make code easier to read
when more functions become member functions.

I was originally hoping to eventually make m_language private (after a few
more patches), but unfortunately then it no longer counts as a POD type,
which means gdbsupport/poison.h won't let us use memset to initialize
this type, which psymtabs rely on to clear padding bytes so that bcache
can work properly.

gdb/ChangeLog:

2019-12-15  Christian Biesinger  <cbiesinger@google.com>

	* ada-lang.c (ada_add_block_symbols): Update.
	(ada_collect_symbol_completion_matches): Update.
	* ax-gdb.c (gen_expr): Update.
	* block.c (block_lookup_symbol): Update.
	(block_lookup_symbol_primary): Update.
	(block_find_symbol): Update.
	* cp-namespace.c (cp_lookup_symbol_imports_or_template): Update.
	* dbxread.c (process_one_symbol): Update.
	* dictionary.c (insert_symbol_hashed): Update.
	(collate_pending_symbols_by_language): Update.
	(mdict_add_symbol): Update.
	* dwarf-index-write.c (write_psymbols): Update.
	* dwarf2read.c (fixup_go_packaging): Update.
	* findvar.c (read_var_value): Update.
	* ft32-tdep.c (ft32_skip_prologue): Update.
	* go-lang.c (go_symbol_package_name): Update.
	* language.h (scoped_switch_to_sym_language_if_auto::
	scoped_switch_to_sym_language_if_auto): Update.
	* linespec.c (find_method): Update.
	(find_label_symbols_in_block): Update.
	* mdebugread.c (parse_symbol): Update.
	* mi/mi-cmd-stack.c (list_arg_or_local): Update.
	* minsyms.c (add_minsym_to_demangled_hash_table): Update.
	(minimal_symbol_reader::install): Update.
	* moxie-tdep.c (moxie_skip_prologue): Update.
	* parse.c (parse_exp_in_context): Update.
	* psymtab.c (psymbol_name_matches): Update.
	(match_partial_symbol): Update.
	(lookup_partial_symbol): Update.
	(psymbol_hash): Update.
	(psymbol_compare): Update.
	* python/py-framefilter.c (extract_sym): Update.
	(py_print_single_arg): Update.
	* stabsread.c (define_symbol): Update.
	* stack.c (print_frame_arg): Update.
	(find_frame_funname): Update.
	(info_frame_command_core): Update.
	* symfile.c (set_initial_language): Update.
	* symtab.c (symbol_set_demangled_name): Update.
	(symbol_get_demangled_name): Update.
	(symbol_set_language): Update.
	(symbol_find_demangled_name): Update.
	(symbol_set_names): Update.
	(general_symbol_info::natural_name): Update.
	(general_symbol_info::demangled_name): Update.
	(general_symbol_info::search_name): Update.
	(symbol_matches_search_name): Update.
	(eq_symbol_entry): Update.
	(iterate_over_symbols): Update.
	(completion_list_add_symbol): Update.
	(completion_list_add_msymbol): Update.
	(completion_list_add_fields): Update.
	* symtab.h (struct general_symbol_info) <language>: New function.
	<language>: Rename to...
	<m_language>: ...this.
	(SYMBOL_LANGUAGE): Remove.
	(MSYMBOL_LANGUAGE): Remove.
	(struct symbol) <ctor>: Update.
	* xstormy16-tdep.c (xstormy16_skip_prologue): Update.

Change-Id: I6464d477457e61639c63ddf8b145e407a35c235a
2019-12-16 00:44:36 -06:00
Christian Biesinger 4cbd39b289 Replace hash function from bcache with fast_hash
This function is not just slower than xxhash, it is slower than
even libiberty's iterative_hash, so there does not seem to be
a reason for it to exist.

------------------------------------------------------------
Benchmark                     Time           CPU Iterations
------------------------------------------------------------
BM_xxh3                      11 ns         11 ns   66127192
BM_xxh32                     19 ns         19 ns   36792609
BM_xxh64                     16 ns         16 ns   42941328
BM_city32                    26 ns         26 ns   27028370
BM_city64                    17 ns         17 ns   40472793
BM_iterative_hash            77 ns         77 ns    9088854
BM_bcache_hash              125 ns        125 ns    5599232

gdb/ChangeLog:

2019-12-03  Christian Biesinger  <cbiesinger@google.com>

	* bcache.c (hash): Remove.
	(hash_continue): Remove.
	* bcache.h (hash): Remove.
	(hash_continue): Remove.
	(struct bcache) <ctor>: Update.
	* psymtab.c (psymbol_hash): Update.
	* stabsread.c (hashname): Update.
	* utils.h (fast_hash): Add an argument for a start value,
	defaulting to zero.

Change-Id: I107f013eda5fdd3293326b5a206be43155dae0f8
2019-12-03 15:27:15 -06:00
Tom Tromey 26abc753cd Use bool in require_partial_symbols
This changes require_partial_symbols to use bool as its parameter
type.

gdb/ChangeLog
2019-11-24  Tom Tromey  <tom@tromey.com>

	* symfile.c (read_symbols): Update.
	* psymtab.c (require_partial_symbols): Change type of "verbose" to
	bool.
	(psym_map_symtabs_matching_filename, find_pc_sect_psymtab)
	(psym_lookup_symbol, psym_find_last_source_symtab)
	(psym_forget_cached_source_info, psym_print_stats)
	(psym_expand_symtabs_for_function, psym_expand_all_symtabs)
	(psym_expand_symtabs_with_fullname, psym_map_symbol_filenames)
	(psym_map_matching_symbols, psym_expand_symtabs_matching)
	(psym_find_compunit_symtab_by_address)
	(maintenance_print_psymbols, maintenance_info_psymtabs)
	(maintenance_check_psymtabs): Update.
	* psymtab.h (require_partial_symbols): Change type of "verbose" to
	bool.

Change-Id: Iae87aa5e4590706bb9e90a33adb86f1fe0fbf3c7
2019-11-24 11:12:20 -07:00
Christian Biesinger c9d95fa3d0 Replace the MSYMBOL_*_NAME macros with member functions
Improves readability. In the future, it will also allow making the name
private, once the name setter functions become member functions.

gdb/ChangeLog:

2019-11-22  Christian Biesinger  <cbiesinger@google.com>

	* ada-lang.c (ada_lookup_simple_minsym): Update.
	(ada_collect_symbol_completion_matches): Update.
	* ada-tasks.c (read_atcb): Update.
	* amd64-windows-tdep.c (amd64_skip_main_prologue): Update.
	(amd64_windows_skip_trampoline_code): Update.
	* arm-tdep.c (skip_prologue_function): Update.
	(arm_skip_stack_protector): Update.
	* arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update.
	(arm_wince_skip_main_prologue): Update.
	* ax-gdb.c (gen_expr): Update.
	* block.c (call_site_for_pc): Update.
	* blockframe.c (find_pc_partial_function): Update.
	* breakpoint.c (set_breakpoint_location_function): Update.
	* btrace.c (ftrace_print_function_name): Update.
	(ftrace_function_switched): Update.
	* c-valprint.c (print_unpacked_pointer): Update.
	* coffread.c (coff_symfile_read): Update.
	* compile/compile-c-symbols.c (convert_symbol_bmsym): Update.
	* compile/compile-cplus-symbols.c (convert_symbol_bmsym): Update.
	* dwarf-index-write.c (write_psymbols): Update.
	* dwarf2loc.c (call_site_to_target_addr): Update.
	(func_verify_no_selftailcall): Update.
	(tailcall_dump): Update.
	(call_site_find_chain_1): Update.
	(dwarf_expr_reg_to_entry_parameter): Update.
	* elfread.c (elf_gnu_ifunc_record_cache): Update.
	* eval.c (evaluate_funcall): Update.
	(evaluate_subexp_standard): Update.
	(evaluate_subexp_for_sizeof): Update.
	* expprint.c (print_subexp_standard): Update.
	(dump_subexp_body_standard): Update.
	* frame.c (get_prev_frame_always_1): Update.
	* frv-tdep.c (frv_skip_main_prologue): Update.
	* gnu-v2-abi.c (gnuv2_value_rtti_type): Update.
	* gnu-v3-abi.c (gnuv3_rtti_type): Update.
	(gnuv3_get_typename_from_type_info): Update.
	(gnuv3_skip_trampoline): Update.
	* hppa-tdep.c (hppa_lookup_stub_minimal_symbol): Update.
	* i386-tdep.c (i386_skip_main_prologue): Update.
	(i386_pe_skip_trampoline_code): Update.
	* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Update.
	* infcall.c (get_function_name): Update.
	* linespec.c (minsym_found): Update.
	* linux-fork.c (info_checkpoints_command): Update.
	* m32c-tdep.c (m32c_m16c_address_to_pointer): Update.
	(m32c_m16c_pointer_to_address): Update.
	* maint.c (maintenance_translate_address): Update.
	* minsyms.c (add_minsym_to_hash_table): Update.
	(add_minsym_to_demangled_hash_table): Update.
	(lookup_minimal_symbol_mangled): Update.
	(lookup_minimal_symbol_demangled): Update.
	(lookup_minimal_symbol_linkage): Update.
	(lookup_minimal_symbol_text): Update.
	(lookup_minimal_symbol_by_pc_name): Update.
	(minimal_symbol_is_less_than): Update.
	(compact_minimal_symbols): Update.
	(build_minimal_symbol_hash_tables): Update.
	(find_solib_trampoline_target): Update.
	* mips-tdep.c (mips_stub_frame_sniffer): Update.
	(mips_skip_pic_trampoline_code): Update.
	* msp430-tdep.c (msp430_skip_trampoline_code): Update.
	* objc-lang.c (info_selectors_command): Update.
	(info_classes_command): Update.
	(find_methods): Update.
	(find_imps): Update.
	* p-valprint.c (pascal_val_print): Update.
	* ppc-linux-tdep.c (powerpc_linux_in_dynsym_resolve_code): Update.
	* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
	* printcmd.c (build_address_symbolic): Update.
	(info_symbol_command): Update.
	* psymtab.c (psymbol_name_matches): Update.
	(match_partial_symbol): Update.
	(lookup_partial_symbol): Update.
	(print_partial_symbols): Update.
	(sort_pst_symbols): Update.
	(maintenance_check_psymtabs): Update.
	* python/py-framefilter.c (py_print_frame): Update.
	* python/python.c (gdbpy_rbreak): Update.
	* record-btrace.c (btrace_get_bfun_name): Update.
	(btrace_call_history): Update.
	* rs6000-tdep.c (rs6000_skip_main_prologue): Update.
	(rs6000_skip_trampoline_code): Update.
	* sol-thread.c (info_cb): Update.
	* stabsread.c (scan_file_globals): Update.
	* stack.c (find_frame_funname): Update.
	(info_frame_command_core): Update.
	* symmisc.c (dump_msymbols): Update.
	* symtab.c (symbol_natural_name): Rename to..,
	(general_symbol_info::natural_name): ...this.
	(symbol_demangled_name): Rename to...
	(general_symbol_info::demangled_name): ...this.
	(symbol_search_name): Rename to...
	(general_symbol_info::search_name): ...this.
	(symbol_matches_search_name): Update.
	(find_pc_sect_line): Update.
	(skip_prologue_sal): Update.
	(search_symbols): Update.
	(print_msymbol_info): Update.
	(rbreak_command): Update.
	(completion_list_add_msymbol): Update.
	(completion_list_objc_symbol): Update.
	(get_msymbol_address): Update.
	* symtab.h (struct general_symbol_info): Add member functions
	natural_name (), linkage_name (), print_name (), demangled_name (),
	and search_name ().
	(SYMBOL_NATURAL_NAME): Update.
	(symbol_natural_name): Move to a member function on general_symbol_info.
	(SYMBOL_DEMANGLED_NAME): Update.
	(symbol_demangled_name): Move to a member function on
	general_symbol_info.
	(SYMBOL_SEARCH_NAME): Update.
	(symbol_search_name): Move to a member function on general_symbol_info.
	(MSYMBOL_NATURAL_NAME): Remove.
	(MSYMBOL_LINKAGE_NAME): Remove.
	(MSYMBOL_PRINT_NAME): Remove.
	(MSYMBOL_DEMANGLED_NAME): Remove.
	(MSYMBOL_SEARCH_NAME): Remove.
	* x86-tdep.c (x86_in_indirect_branch_thunk): Update.

Change-Id: I65aa529843a9903e174ce799037e41f954a9fcee
2019-11-22 12:05:14 -06:00
Tom Tromey e0eac551da Remove some includes of readline.h
I went through most of the spots that include readline.h and, when
appropriate, either removed the include or changed it to include
tilde.h.

Note that remote-sim.c and bsd-kvm.c could probably include tilde.h
instead, but I did not change these.  I think I can't build the
latter, and I didn't want to set up a sim build for the former.

Tested by rebuilding.

gdb/ChangeLog
2019-11-06  Tom Tromey  <tom@tromey.com>

	* tui/tui-interp.c: Don't include readline.h.
	* tui/tui-hooks.c: Don't include readline.h.
	* symmisc.c: Include tilde.h, not readline.h.
	* symfile.c: Include tilde.h, not readline.h.
	* source.c: Include tilde.h, not readline.h.
	* solib.c: Include tilde.h, not readline.h.
	* psymtab.c: Include tilde.h, not readline.h.
	* exec.c: Include tilde.h, not readline.h.
	* corelow.c: Include tilde.h, not readline.h.
	* cli/cli-dump.c: Include tilde.h, not readline.h.
	* cli/cli-cmds.c: Don't include readline.h.

Change-Id: I60487a190c43128b800ef77517d1ab42957571d7
2019-11-06 07:29:43 -07:00
Andrew Burgess 59c35742fb gdb/fortran: Add new 'info modules' command
Add a new command 'info modules' that lists all of the modules GDB
knows about from the debug information.

A module is a debugging entity in the DWARF defined with
DW_TAG_module, currently Fortran is known to use this tag for its
modules.  I'm not aware of any other language that currently makes use
of DW_TAG_module.

The output style is similar to the 'info type' output:

    (gdb) info modules
    All defined modules:

    File info-types.f90:
    16:     mod1
    24:     mod2
    (gdb)

Where the user is told the file the module is defined in and, on the
left hand side, the line number at which the module is defined along
with the name of the module.

This patch is a new implementation of an idea originally worked on by
Mark O'Connor, Chris January, David Lecomber, and Xavier Oro from ARM.

gdb/ChangeLog:

	* dwarf2read.c (dw2_symtab_iter_next): Handle MODULE_DOMAIN.
	(dw2_expand_marked_cus): Handle MODULES_DOMAIN.
	(dw2_debug_names_iterator::next): Handle MODULE_DOMAIN and
	MODULES_DOMAIN.
	(scan_partial_symbols): Only create partial module symbols for non
	declarations.
	* psymtab.c (recursively_search_psymtabs): Handle MODULE_DOMAIN
	and MODULES_DOMAIN.
	* symtab.c (search_domain_name): Likewise.
	(search_symbols): Likewise.
	(print_symbol_info): Likewise.
	(symtab_symbol_info): Likewise.
	(info_modules_command): New function.
	(_initialize_symtab): Register 'info modules' command.
	* symtab.h (enum search_domain): Add MODULES_DOMAIN.
	* NEWS: Mention new 'info modules' command.

gdb/doc/ChangeLog:

	* gdb.texinfo (Symbols): Document new 'info modules' command.

gdb/testsuite/ChangeLog:

	* gdb.fortran/info-modules.exp: New file.
	* gdb.fortran/info-types.exp: Build with new file.
	* gdb.fortran/info-types.f90: Include and use new module.
	* gdb.fortran/info-types-2.f90: New file.

Change-Id: I2b781dd5a06bcad04620ccdc45f01a0f711adfad
2019-10-31 23:02:59 +00:00
Christian Biesinger 31edb80295 Change some arguments to gdb::string_view instead of name+len
Just some code cleanup. This change has a few benefits:
- Shorter argument list in the functions
- If the caller needs to calculate the string, they no longer
  need to explicitly call strlen
- It is easy to pass std::string to this (done in one place
  currently)

This also updates a couple of places that were passing 0/1 to
a bool parameter.

gdb/ChangeLog:

2019-10-29  Christian Biesinger  <cbiesinger@google.com>

	* coffread.c (record_minimal_symbol): Update.
	(process_coff_symbol): Update.
	* dbxread.c (read_dbx_symtab): Update.
	* dwarf2read.c (add_partial_symbol): Update.
	(fixup_go_packaging): Update.
	(load_partial_dies): Update.
	(new_symbol): Update.
	* elfread.c (record_minimal_symbol): Change signature to use
	gdb::string_view instead of name+len.
	(elf_symtab_read): Update.
	(elf_rel_plt_read): Update.
	* mdebugread.c (parse_partial_symbols): Update.
	(handle_psymbol_enumerators): Update.
	(new_symbol): Update.
	* minsyms.c (minimal_symbol_reader::record_full): Change signature
	to use gdb::string_view instead of name+len.
	* minsyms.h (class minimal_symbol_reader) <record_full>: Likewise.
	* psympriv.h (add_psymbol_to_list): Likewise.
	* psymtab.c (add_psymbol_to_bcache): Likewise.
	(add_psymbol_to_list): Likewise.
	* stabsread.c (define_symbol): Update.
	* symtab.c (symbol_set_names): Change signature to use gdb::string_view.
	* symtab.h (SYMBOL_SET_NAMES): Likewise.
	(symbol_set_names): Likewise.
	* xcoffread.c (scan_xcoff_symtab): Update.

Change-Id: I2675c6865e0368f9c755a1081088a53aa54dda4c
2019-10-29 14:19:59 -05:00
Simon Marchi 703a86c2fa gdb: re-write add_psymbol_to_list doc, move it to header file
The comment above the add_psymbol_to_list function seems outdated and
misleading, here's an attempt at improving it.

gdb/ChangeLog:

	* psymtab.c (add_psymbol_to_list): Move comment to psympriv.h.
	* psympriv.h (add_psymbol_to_list): Move comment here and update
	it.
2019-09-30 11:49:57 -04:00
Andrew Burgess 3dd9bb4620 gdb: Don't fault for 'maint print psymbols' when using an index
I found that these tests:

  make check-gdb RUNTESTFLAGS="--target_board=cc-with-gdb-index gdb.base/maint.exp"
  make check-gdb RUNTESTFLAGS="--target_board=cc-with-debug-names gdb.base/maint.exp"

were causing GDB to segfault.  It turns out that this test runs this
command:

  maint print psymbols -pc main /path/to/some/file

which tries to lookup the partial_symtab for 'main'.  The problem is
that there is no partial_symtab for 'main' as we are using the
.gdb_index or .debug_names instead of partial_symtabs.

What happens is that maintenance_print_symbols calls
find_pc_sect_psymtab, which looks for the partial_symtab in the
objfile's objfile->partial_symtabs->psymtabs_addrmap.

This is a problem because when we are using the indexes
psymtabs_addrmap is reused to hold things other than partial_symtabs,
this can be seen in dwarf2read.c in create_addrmap_from_index and
create_addrmap_from_aranges.  If we then lookup in psymtabs_addrmap we
end up returning a pointer to something that isn't really a
partial_symtab, after which everything goes wrong.

Initially I simply added a check at the start of find_pc_sect_psymtab
that the objfile had some partial_symtabs, like:

  if (objfile->partial_symtabs->psymtabs == NULL)
    return NULL;

Figuring that if there were no partial_symtabs at all then this
function should always return NULL, however, this caused a failure in
the test gdb.python/py-event.exp which I didn't dig into too deeply,
but seems to be that in this tests there are initially no psymtabs,
but the second part of find_pc_sect_psymtab does manage to read some
in from somewhere, with the check I added the test fails as we
returned NULL here and this caused GDB to load in the full symtabs
earlier than was expected.

Instead I chose to guard only the access to psymtabs_addrmap with a
check that the function has some psymtabs.  This allows my original
tests to pass, and the py-event.exp test to pass too.

Now, a good argument can be made that we simply should never call
find_pc_sect_psymtab on an objfile that is using indexes instead of
partial_symtabs.  I did consider this approach, we could easily add an
assert into find_pc_sect_psymtab that if we find a partial_symtab in
psymtabs_addrmap then the psymtabs pointer must be non-null.  The
responsibility would then be on the user of find_pc_sect_psymtab to
ensure that the objfile being checked is suitable.  In the end I
didn't take this approach as the check in find_pc_sect_psymtab is
cheap and this ensures that any future miss-uses of the function will
not cause problems.

I also extended the comment on psymtabs_addrmap to indicate that it
holds more than just partial_symtabs as this was not at all clear from
the original comment, and caused me some confusion when I was
initially debugging this problem.

gdb/ChangeLog:

	* psymtab.c (find_pc_sect_psymtab): Move baseaddr local into more
	inner scope, add check that the objfile has psymtabs before
	checking psymtabs_addrmap.
	* psymtab.h (psymtab_storage) <psymtabs_addrmap>: Extend comment.
2019-09-12 20:31:29 -04:00
Christian Biesinger 67547d896b Change the type of copy_names from int to bool
This parameter is really a boolean, so change the type accordingly
and update the callers.

This is for symbol_set_names, add_psymbol_to_bcache, and
add_psymbol_to_list.

minimal_symbol_reader::record_full was already passing a bool
to symbol_set_names.

gdb/ChangeLog:

2019-09-11  Christian Biesinger  <cbiesinger@google.com>

	* dbxread.c (read_dbx_symtab): Update.
	* dwarf2read.c (load_partial_dies): Update.
	* mdebugread.c (parse_partial_symbols): Update.
	(handle_psymbol_enumerators): Update.
	* psympriv.h (add_psymbol_to_list): Change type of copy_names to bool.
	* psymtab.c (add_psymbol_to_bcache): Likewise.
	(add_psymbol_to_list): Likewise.
	* symtab.c (symbol_set_names): Likewise.
	* symtab.h (symbol_set_names): Likewise.
	* xcoffread.c (scan_xcoff_symtab): Update.
2019-09-11 12:43:45 -05:00
Tom Tromey b054970d54 Change map_matching_symbols to take a lookup_name_info
This patch further simplifies the map_matching_symbols callback, by
having it take a lookup_name_info rather than a plain string.

gdb/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (add_nonlocal_symbols): Combine calls to
	map_matching_symbols.  Update.
	* dwarf2read.c (dw2_map_matching_symbols): Update.
	* psymtab.c (match_partial_symbol): Change type; update.
	(psym_map_matching_symbols): Likewise.
	* symfile-debug.c (debug_qf_map_matching_symbols): Change
	type; update.
	* symfile.h (struct quick_symbol_functions)
	<map_matching_symbols>: Change "name" to be a lookup_name_info.
	Remove "match".
2019-09-10 08:30:45 -06:00
Tom Tromey 6a3dbf1bc6 Simplify psym_map_matching_symbols
This introduces a new helper function,
iterate_over_symbols_terminated, and changes psym_map_matching_symbols
to use it.  A subsequent patch will introduce a new user of this
function in the DWARF reader.

gdb/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

	* psymtab.c (map_block): Remove.
	(psym_map_matching_symbols): Use iterate_over_symbols_terminated.
	* symtab.c (iterate_over_symbols_terminated): New function.
	* symtab.c (iterate_over_symbols_terminated): Declare.
2019-09-10 08:30:45 -06:00
Tom Tromey 199b4314ef Change map_matching_symbols to take a symbol_found_callback_ftype
This changes map_matching_symbols to take a
symbol_found_callback_ftype, rather than separate callback and data
parameters.  This enables a future patch to clean up some existing
code so that it can more readily be shared.

gdb/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (aux_add_nonlocal_symbols): Change type.
	(add_nonlocal_symbols): Update.
	* dwarf2read.c (dw2_map_matching_symbols): Change type.
	* psymtab.c (map_block, psym_map_matching_symbols): Change type.
	* symfile-debug.c (debug_qf_map_matching_symbols): Change type.
	* symfile.h (struct quick_symbol_functions) <map_matching_symbols>:
	Change type of "callback".  Remove "data".
2019-09-10 08:30:45 -06:00
Simon Marchi c7f839cbf0 Change lookup_symbol's block_index parameter type to block_enum
The only two values valid to pass to the block_index parameter of
quick_symbol_functions::lookup_symbol are GLOBAL_BLOCK and STATIC_BLOCK,
part of enum block_enum.  Change the type of that parameter to
block_enum.

Change also the block_index field of dw2_symtab_iterator in the same
way..  This makes it consistent with dw2_debug_names_iterator, which
already uses block_enum for its block_index field.

This is a follow-up to this thread:

https://sourceware.org/ml/gdb-patches/2019-08/msg00097.html

gdb/ChangeLog:

	* dwarf2read.c (struct dw2_symtab_iterator) <block_index>:
	Change type to gdb::optional<block_enum>.
	(dw2_symtab_iter_init): Change block_index parameter type
	to gdb::optional<block_enum>.
	(dw2_lookup_symbol): Change block_index parameter
	type to block_enum.c
	(dw2_debug_names_lookup_symbol): Likewise.
	* psymtab.c (psym_lookup_symbol): Likewise.
	* symfile-debug.c (debug_qf_lookup_symbol): Likewise.
	* symfile.h (struct quick_symbol_functions) <lookup_symbol>:
	Likewise.
2019-09-07 12:06:01 -04:00
Andrew Burgess 06ff036ed2 gdb: Handle missing domain types in: maintenance print psymbols
Some domain_enum values were not handled in print_partial_symbols
which means that 'maintenance print psymbols' would print '<invalid
domain>' when it shouldn't have.

gdb/ChangeLog:

	* psymtab.c (print_partial_symbols): Handle missing domain_enum
	values MODULE_DOMAIN and COMMON_BLOCK_DOMAIN.
2019-09-03 22:29:07 +01:00
Pedro Alves b02f78f928 Introduce and use make_unique_xstrdup
Adds an utility function to make it shorter to write the common case
of wrapping an xstrdup with a unique_xmalloc_ptr, and uses it
throughout.

Note: I tried to put this in common/common-utils.h near skip_spaces,
etc. but that is included in common/common-defs.h before
common/gdb_unique_ptr.h is included, so it would fail to compile
because gdb::unique_xmalloc_ptr isn't defined at that point yet.  I
tried moving the gdb_unique_ptr.h inclusion before common-utils.h, but
that doesn't work because gdb_unique_ptr.h depends on common-utils.h
for xfree.

gdb/ChangeLog:
2019-06-04  Pedro Alves  <palves@redhat.com>

	* common/gdb_unique_ptr.h (make_unique_xstrdup): New.

	* ada-lang.c (catch_ada_completer): Use make_unique_xstrdup.
	* breakpoint.c (condition_completer): Likewise.
	* cli/cli-dump.c (scan_expression): Likewise.
	* common/filestuff.c (mkdir_recursive): Likewise.
	* common/gdb_tilde_expand.c (gdb_tilde_expand_up)
	* common/pathstuff.c (gdb_realpath, gdb_realpath_keepfile)
	(gdb_abspath): Likewise.
	* compile/compile-cplus-types.c
	(compile_cplus_instance::decl_name): Likewise.
	* completer.c (complete_explicit_location):
	(signal_completer, reg_or_group_completer_1): Likewise.
	* cp-support.c (cp_remove_params_if_any): Likewise.
	* fbsd-tdep.c (fbsd_core_vnode_path): Likewise.
	* guile/scm-safe-call.c (gdbscm_safe_eval_string): Likewise.
	* infcmd.c (strip_bg_char): Likewise.
	* linespec.c (copy_token_string): Likewise.
	* mi/mi-main.c (output_cores): Likewise.
	* psymtab.c (psymtab_search_name):
	* symfile.c (test_set_ext_lang_command): Likewise.
	* target.c (target_fileio_read_stralloc): Likewise.
	* tui/tui-regs.c (tui_reggroup_completer): Likewise.
	* value.c (complete_internalvar): Likewise.

gdb/gdbserver/ChangeLog:
2019-06-04  Pedro Alves  <palves@redhat.com>

	* server.c (captured_main): Use make_unique_xstrdup.
2019-06-04 22:48:32 +01:00
Tom Tromey af97b4161f Don't derive partial_symbol from general_symbol_info
This patch partly reverts commit 8a6d42345 ("Change representation of
psymbol to flush out accessors"); specifically, it changes
partial_symbol to no longer derive from general_symbol_info.

The basic problem here is that the bcache compares objects bitwise,
and this change made it less likely that the relevant fields in the
psymbol would be fully initialized.  This could be seen by running a
test under valgrind on the Fedora-i686 buildbot.

I considered a simpler patch, namely just zeroing the psymbol's
"value" field in add_psymbol_to_bcache.  However, it wasn't clear to
me that this memset could not then be optimized away by the compiler.

Regression tested by the buildbot.  I think this should go in 8.3 as
well.

gdb/ChangeLog
2019-05-04  Tom Tromey  <tom@tromey.com>

	* psymtab.c (psymbol_name_matches, match_partial_symbol)
	(lookup_partial_symbol, print_partial_symbols)
	(recursively_search_psymtabs, sort_pst_symbols, psymbol_hash)
	(psymbol_compare): Update.
	(add_psymbol_to_bcache): Clear the entire psymbol.
	(maintenance_check_psymtabs): Update.
	* psympriv.h (struct partial_symbol): Don't derive from
	general_symbol_info.
	<obj_section, unrelocated_address, address,
	set_unrelocated_address>: Update.
	<ginfo>: New member.
	* dwarf-index-write.c (write_psymbols, debug_names::insert)
	(debug_names::write_psymbols): Update.
2019-05-04 13:43:50 -06:00
Tom Tromey 582942f456 More block constification
I noticed that there are still many places referring to non-const
blocks.  This constifies all the remaining ones that I found that
could be constified.

In a few spots, this search found unused variables or fields.  I
removed these.  I've also removed some unnecessary casts to
"struct block *".

gdb/ChangeLog
2019-03-24  Tom Tromey  <tom@tromey.com>

	* c-exp.y (typebase): Remove casts.
	* gdbtypes.c (lookup_unsigned_typename, )
	(lookup_signed_typename): Remove cast.
	* eval.c (parse_to_comma_and_eval): Remove cast.
	* parse.c (write_dollar_variable): Remove cast.
	* block.h (struct block) <superblock>: Now const.
	* symfile-debug.c (debug_qf_map_matching_symbols): Update.
	* psymtab.c (psym_map_matching_symbols): Make "block" const.
	(map_block): Make "block" const.
	* symfile.h (struct quick_symbol_functions)
	<map_matching_symbols>: Constify block argument to "callback".
	* symtab.c (basic_lookup_transparent_type_quick): Make "block"
	const.
	(find_pc_sect_compunit_symtab): Make "b" const.
	(find_symbol_at_address): Likewise.
	(search_symbols): Likewise.
	* dwarf2read.c (dw2_lookup_symbol): Make "block" const.
	(dw2_debug_names_lookup_symbol): Likewise.
	(dw2_map_matching_symbols): Update.
	* p-valprint.c (pascal_val_print): Remove "block".
	* ada-lang.c (ada_add_global_exceptions): Make "b" const.
	(aux_add_nonlocal_symbols): Make "block" const.
	(resolve_subexp): Remove cast.
	* linespec.c (iterate_over_all_matching_symtabs): Make "block"
	const.
	(iterate_over_file_blocks): Likewise.
	* f-exp.y (%union) <bval>: Remove.
	* coffread.c (patch_opaque_types): Make "b" const.
	* spu-tdep.c (spu_catch_start): Make "block" const.
	* c-valprint.c (print_unpacked_pointer): Remove "block".
	* symmisc.c (dump_symtab_1): Make "b" const.
	(block_depth): Make "block" const.
	* d-exp.y (%union) <bval>: Remove.
	* cp-support.h (cp_lookup_rtti_type): Update.
	* cp-support.c (cp_lookup_rtti_type): Make "block" const.
	* psymtab.c (psym_lookup_symbol): Make "block" const.
	(maintenance_check_psymtabs): Make "b" const.
	* python/py-framefilter.c (extract_sym): Make "sym_block" const.
	(enumerate_locals, enumerate_args): Update.
	* python/py-symtab.c (stpy_global_block): Make "block" const.
	(stpy_static_block): Likewise.
	* inline-frame.c (block_starting_point_at): Make "new_block"
	const.
	* block.c (find_block_in_blockvector): Make return type const.
	(blockvector_for_pc_sect): Make "b" const.
	(find_block_in_blockvector): Make "b" const.
2019-03-24 23:32:08 -06:00
Tom Tromey 25629dfdb4 C++-ify bcache
This somewhat C++-ifies bcache.  It replaces bcache_xmalloc and
bcache_xfree with constructors; changes some functions into methods;
and changes various structures to include a bcache directly (as
opposed to a pointer to a bcache).

Tested by the buildbot.

gdb/ChangeLog
2019-03-07  Tom Tromey  <tom@tromey.com>

	* symmisc.c (print_symbol_bcache_statistics): Update.
	(print_objfile_statistics): Update.
	* symfile.c (allocate_symtab): Update.
	* stabsread.c: Don't include bcache.h.
	* psymtab.h (struct psymbol_bcache): Don't declare.
	(class psymtab_storage) <psymbol_cache>: Now a bcache.
	(psymbol_bcache_init, psymbol_bcache_free)
	(psymbol_bcache_get_bcache): Don't declare.
	* psymtab.c (struct psymbol_bcache): Remove.
	(psymtab_storage::psymtab_storage): Update.
	(psymtab_storage::~psymtab_storage): Update.
	(psymbol_bcache_init, psymbol_bcache_free)
	(psymbol_bcache_get_bcache, psymbol_bcache_full): Remove.
	(add_psymbol_to_bcache): Update.
	(allocate_psymtab): Update.
	* objfiles.h (struct objfile_per_bfd_storage) <filename_cache,
	macro_cache>: No longer pointers.
	* objfiles.c (get_objfile_bfd_data): Don't call bcache_xmalloc.
	(free_objfile_per_bfd_storage): Don't call bcache_xfree.
	* macrotab.c (macro_bcache): Update.
	* macroexp.c: Don't include bcache.h.
	* gdbtypes.c (check_types_worklist): Update.
	(types_deeply_equal): Remove TRY/CATCH.  Update.
	* elfread.c (elf_symtab_read): Update.
	* dwarf2read.c: Don't include bcache.h.
	* buildsym.c (buildsym_compunit::get_macro_table): Update.
	* bcache.h (bcache, bcache_full, bcache_xffree, bcache_xmalloc)
	(print_bcache_statistics, bcache_memory_used): Don't declare.
	(struct bcache): Move from bcache.c.  Add constructor, destructor,
	methods.  Rename all data members.
	* bcache.c (struct bcache): Move to bcache.h.
	(bcache::expand_hash_table): Rename from expand_hash_table.
	(bcache): Remove.
	(bcache::insert): Rename from bcache_full.
	(bcache::compare): Rename from bcache_compare.
	(bcache_xmalloc): Remove.
	(bcache::~bcache): Rename from bcache_xfree.
	(bcache::print_statistics): Rename from print_bcache_statistics.
	(bcache::memory_used): Rename from bcache_memory_used.
2019-03-07 10:48:02 -07:00
Tom Tromey f252c6d5dc Make psymtab range adapter a method on objfile
This removes the objfile_psymtabs class in favor of a method on
objfile and on psymtab_storage.

2019-01-16  Tom Tromey  <tom@tromey.com>

	* objfiles.h (struct objfile) <psymtabs>: New method.
	(class objfile_psymtabs): Remove.
	* psymtab.h (class psymtab_storage) <partial_symtab_range>: New
	typedef.
	<range>: New method.
	(require_partial_symbols): Change return type.
	* psymtab.c (require_partial_symbols)
	(psym_expand_symtabs_matching): Update.
	* mdebugread.c (parse_partial_symbols): Update.
	* dbxread.c (dbx_end_psymtab): Update.
2019-01-17 15:42:05 -07:00
Tom Tromey 2030c07971 Change all_objfiles adapter to be a method on program_space
This changes the all_objfiles range adapter to be a method on the
program space, and fixes up all the users.

gdb/ChangeLog
2019-01-17  Tom Tromey  <tom@tromey.com>

	* progspace.h (program_space) <objfiles_range>: New typedef.
	<objfiles>: New method.
	<objfiles_head>: Rename from objfiles.
	(object_files): Update.
	* guile/scm-progspace.c (gdbscm_progspace_objfiles): Update.
	* guile/scm-pretty-print.c
	(ppscm_find_pretty_printer_from_objfiles): Update.
	* guile/scm-objfile.c (gdbscm_objfiles): Update.
	* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers):
	Update.
	* python/py-progspace.c (pspy_get_objfiles): Update.
	* python/py-prettyprint.c (find_pretty_printer_from_objfiles):
	Update.
	* python/py-objfile.c (objfpy_lookup_objfile_by_name)
	(objfpy_lookup_objfile_by_build_id): Update.
	* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update.
	* windows-tdep.c (windows_iterate_over_objfiles_in_search_order):
	Update.
	* symtab.c (iterate_over_symtabs, matching_obj_sections)
	(expand_symtab_containing_pc, lookup_objfile_from_block)
	(lookup_static_symbol, basic_lookup_transparent_type)
	(find_pc_sect_compunit_symtab, find_symbol_at_address)
	(find_line_symtab, info_sources_command)
	(default_collect_symbol_completion_matches_break_on)
	(make_source_files_completion_list, find_main_name): Update.
	* symmisc.c (print_symbol_bcache_statistics)
	(print_objfile_statistics, maintenance_print_symbols)
	(maintenance_print_msymbols, maintenance_print_objfiles)
	(maintenance_info_symtabs, maintenance_check_symtabs)
	(maintenance_expand_symtabs, maintenance_info_line_tables):
	Update.
	* symfile.c (remove_symbol_file_command, overlay_invalidate_all)
	(find_pc_overlay, find_pc_mapped_section, list_overlays_command)
	(map_overlay_command, unmap_overlay_command)
	(simple_overlay_update, expand_symtabs_matching)
	(map_symbol_filenames): Update.
	* symfile-debug.c (set_debug_symfile): Update.
	* spu-tdep.c (spu_overlay_update, spu_objfile_from_frame):
	Update.
	* source.c (select_source_symtab, forget_cached_source_info):
	Update.
	* solib.c (solib_read_symbols): Update.
	* solib-spu.c (append_ocl_sos): Update.
	* psymtab.c (maintenance_print_psymbols)
	(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
	* probe.c (parse_probes_in_pspace, find_probe_by_pc): Update.
	* printcmd.c (info_symbol_command): Update.
	* ppc-linux-tdep.c (ppc_linux_spe_context_inferior_created):
	Update.
	* objfiles.h (class all_objfiles): Remove.
	* objfiles.c (have_partial_symbols, have_full_symbols)
	(have_minimal_symbols, qsort_cmp, update_section_map)
	(shared_objfile_contains_address_p)
	(default_iterate_over_objfiles_in_search_order): Update.
	* objc-lang.c (info_selectors_command, info_classes_command)
	(find_methods): Update.
	* minsyms.c (find_solib_trampoline_target): Update.
	* maint.c (maintenance_info_sections)
	(maintenance_translate_address, count_symtabs_and_blocks):
	Update.
	* main.c (captured_main_1): Update.
	* linux-thread-db.c (try_thread_db_load_from_pdir)
	(has_libpthread): Update.
	* linespec.c (iterate_over_all_matching_symtabs)
	(search_minsyms_for_name): Update.
	* jit.c (jit_find_objf_with_entry_addr): Update.
	* hppa-tdep.c (find_unwind_entry)
	(hppa_lookup_stub_minimal_symbol): Update.
	* gcore.c (gcore_create_callback, objfile_find_memory_regions):
	Update.
	* elfread.c (elf_gnu_ifunc_resolve_by_cache)
	(elf_gnu_ifunc_resolve_by_got): Update.
	* dwarf2-frame.c (dwarf2_frame_find_fde): Update.
	* dwarf-index-write.c (save_gdb_index_command): Update.
	* cp-support.c (add_symbol_overload_list_qualified): Update.
	* breakpoint.c (create_overlay_event_breakpoint)
	(create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint): Update.
	* blockframe.c (find_pc_partial_function): Update.
	* ada-lang.c (ada_lookup_simple_minsym, add_nonlocal_symbols)
	(ada_collect_symbol_completion_matches)
	(ada_add_global_exceptions): Update.
2019-01-17 15:34:37 -07:00
Tom Tromey 8d7bcccb82 Move psymtabs to their own obstack
Previously, the psymtab obstack was just a pointer to the objfile
obstack.  This patch changes psymtabs to use their own obstack,
instead.  A gdb::optional is used to avoid unnecessary allocation when
the obstack is not needed.

After this patch, the psymtab code lifetime model is that, in the core
psymtab code, objects allocated on the psymtab obstack may point to
other such objects, or to objects on the per-BFD obstack -- but never
to the objfile obstack.

Note however that this invariant is only obeyed the core psymtab code,
and even there not quite fully: there is still a link from the psymtab
to the full symtab.

Symbol readers are free to work however they like; and in particular,
even after this patch, in practice all symbol readers violate this
invariant via the read_symtab_private field.

gdb/ChangeLog
2019-01-10  Tom Tromey  <tom@tromey.com>

	* objfiles.h (objfile::reset_psymtabs): Update.
	* objfiles.c (objfile::objfile): Update.
	* psymtab.h (psymtab_storage::obstack): Update.
	(psymtab_storage::m_obstack): Use gdb::optional.
	(class psymtab_storage): Update comment.  Remove objfile
	parameter.
	* psymtab.c (psymtab_storage::psymtab_storage): Update.
2019-01-10 07:08:15 -07:00
Tom Tromey b596a3c77d Make psymtab_storage::free_psymtabs private
This adds a new psymtab allocation method to psymtab_storage and
changes the free_psymtabs member to be private.  While not strictly
necessary, this seems like a decent cleanup, and also makes it simpler
to move psymtabs off of obstacks entirely, should that prove
desirable.

gdb/ChangeLog
2019-01-10  Tom Tromey  <tom@tromey.com>

	* psymtab.h (psymtab_storage::allocate_psymtab): New method.
	<free_psymtabs>: Now private.
	* psymtab.c (psymtab_storage::allocate_psymtab): Implement.
	(allocate_psymtab): Use new method.
2019-01-10 07:08:14 -07:00
Tom Tromey 5af7096648 Move more allocations to psymtab obstack
This moves a couple more psymtab-related allocations to the psymtab
obstack.

gdb/ChangeLog
2019-01-10  Tom Tromey  <tom@tromey.com>

	* psymtab.c (add_psymbol_to_bcache): Pass psymtab obstack to
	PSYMBOL_SET_LANGUAGE.
	(allocate_psymtab): Allocate psymtab on the psymtab obstack.
2019-01-10 07:08:14 -07:00
Tom Tromey 5923a04c0c Allocate the address map on the psymtab obstack
After this patch, the psymtab address map will now be allocated on the
psymtab obstack rather than the objfile obstack.  This also changes
the psymtab storage object to make the obstack private; this will be
used later.

gdb/ChangeLog
2019-01-10  Tom Tromey  <tom@tromey.com>

	* psymtab.h (psymtab_storage::obstack): New method.
	<m_obstack>: Rename from obstack; now private.
	* psymtab.c (psymtab_storage): Update.
	* dwarf2read.c (create_addrmap_from_index)
	(create_addrmap_from_aranges, dwarf2_build_psymtabs_hard):
	Update.
2019-01-10 07:08:13 -07:00
Tom Tromey d320c2b5e1 Introduce class psymtab_storage
This introduces a new psymtab_storage class, which holds all
psymbol-related objects that are independent of the objfile.  (This
latter contraint explains why psymbol_map was not moved; though this
could still be done with some work.)

This patch does not yet change where psymtab allocation is done --
that comes later.  This just wraps everything in a single object to
make further transformations simpler.

Note that a shared_ptr is used to link from the objfile to the
psymtab_storage object.  The end goal here is to allow a given symbol
reader to simply attach to the psymtab_storage object to the BFD, then
reuse it in later invocations; shared_ptr makes this simple to reason
about.

gdb/ChangeLog
2019-01-10  Tom Tromey  <tom@tromey.com>

	* symmisc.c (print_symbol_bcache_statistics): Update.
	(print_objfile_statistics): Update.
	* symfile.c (reread_symbols): Update.
	* psymtab.h (class psymtab_storage): New.
	* psymtab.c (psymtab_storage): New constructor.
	(~psymtab_storage): New destructor.
	(require_partial_symbols): Update.
	(ALL_OBJFILE_PSYMTABS_REQUIRED): Rewrite.
	(find_pc_sect_psymtab, find_pc_sect_psymbol)
	(match_partial_symbol, lookup_partial_symbol, dump_psymtab)
	(psym_dump, recursively_search_psymtabs, psym_has_symbols)
	(psym_find_compunit_symtab_by_address, sort_pst_symbols)
	(start_psymtab_common, end_psymtab_common)
	(add_psymbol_to_bcache, add_psymbol_to_list, init_psymbol_list)
	(allocate_psymtab): Update.
	(psymtab_storage::discard_psymtab): Rename from discard_psymtab.
	Update.
	(dump_psymtab_addrmap, maintenance_print_psymbols)
	(maintenance_check_psymtabs): Update.
	(class objfile_psymtabs): Move to objfiles.h.
	* psympriv.h (discard_psymtab): Now inline.
	(psymtab_discarder::psymtab_discarder): Update.
	(psymtab_discarder::~psymtab_discarder): Update.
	(ALL_OBJFILE_PSYMTABS): Rewrite.
	* objfiles.h (struct objfile) <psymtabs, psymtabs_addrmap,
	free_psymtabs, psymbol_cache, global_psymbols, static_psymbols>:
	Remove fields.
	<partial_symtabs>: New field.
	(class objfile_psymtabs): Move from psymtab.h.  Update.
	* objfiles.c (objfile::objfile): Initialize partial_symtabs, not
	psymbol_cache.
	(objfile::~objfile): Don't destroy psymbol_cache.
	* mdebugread.c (parse_partial_symbols): Update.
	* dwarf2read.c (create_addrmap_from_index)
	(create_addrmap_from_aranges, dw2_find_pc_sect_compunit_symtab)
	(process_psymtab_comp_unit_reader, dwarf2_build_psymtabs_hard)
	(add_partial_subprogram, dwarf2_ranges_read): Update.
	* dwarf-index-write.c (write_address_map)
	(write_one_signatured_type, recursively_write_psymbols)
	(class debug_names, class debug_names, write_psymtabs_to_index):
	Update.
2019-01-10 07:08:12 -07:00
Tom Tromey 1d94a5a36a Change symbol_set_names to take an objfile_per_bfd_storage
This changes symbol_set_names to take an objfile_per_bfd_storage
argument, and updates the users.  It also changes PSYMBOL_SET_NAMES to
take this argument directly; I feel this clarifies the storage
location of objects created in psymtab.c.

gdb/ChangeLog
2019-01-10  Tom Tromey  <tom@tromey.com>

	* symtab.h (SYMBOL_SET_NAMES): Update.
	(symbol_set_names): Update.
	(MSYMBOL_SET_NAMES): Update.
	* symtab.c (symbol_set_names): Change argument to be an
	objfile_per_bfd_storage.
	* psymtab.c (add_psymbol_to_bcache): Update.
	* psympriv.h (PSYMBOL_SET_NAMES): Take per_bfd argument.
2019-01-10 07:08:12 -07:00
Tom Tromey 6eee24ce30 Simplify calls to init_psymbol_list
Existing callers to init_psymbol_list were checking to see if psymbols
had already been initialized.  It seemed better to me to do this check
directly in init_psymbol_list, simplifying the callers.

gdb/ChangeLog
2019-01-10  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_initial_scan): Unconditionally call
	init_psymbol_list.
	* psymtab.c (init_psymbol_list): Do nothing if already called.
	* psympriv.h (init_psymbol_list): Add comment.
	* dwarf2read.c (dwarf2_build_psymtabs): Unconditionally call
	init_psymbol_list.
	* dbxread.c (dbx_symfile_read): Unconditionally call
	init_psymbol_list.
2019-01-10 07:08:11 -07:00
Tom Tromey 75aedd27e6 Change add_psymbol_to_list to use an enum
This changes add_psymbol_to_list to use an enum, rather than a pointer
to a vector, to decide where to put the new symbol.  This reduces the
number of direct references to the static_psymbols and global_psymbols
members of the objfile, which is handy in a later patch.

gdb/ChangeLog
2019-01-10  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (scan_xcoff_symtab): Update.
	* psymtab.c (add_psymbol_to_list): Replace "list" parameter with
	"where".
	* mdebugread.c (parse_partial_symbols)
	(handle_psymbol_enumerators): Update.
	* dwarf2read.c (add_partial_symbol, load_partial_dies): Update.
	* dbxread.c (read_dbx_symtab): Update.
	* psympriv.h (psymbol_placement): New enum.
	(add_psymbol_to_list): Update.
2019-01-10 07:08:11 -07:00
Tom Tromey 939652a515 Remove parameters from start_psymtab_common
start_psymtab_common takes references to the global_psymbols and
static_psymbols vectors, but it also has an objfile parameter.  This
is redundant, so this patch simplifies the function by removing those
reference parameters.

gdb/ChangeLog
2019-01-10  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_start_psymtab): Remove global_psymbols and
	static_psymbols parameters.
	(scan_xcoff_symtab): Update.
	* psymtab.c (start_psymtab_common): Remove global_psymbols and
	static_psymbols parameters.
	* psympriv.h (start_psymtab_common): Update.
	* mdebugread.c (parse_partial_symbols): Update.
	* dwarf2read.c (create_partial_symtab): Update.
	* dbxread.c (read_dbx_symtab): Update.
	(start_psymtab): Remove global_psymbols and static_psymbols
	parameters.
2019-01-10 07:08:10 -07:00
Tom Tromey baa62830ed Remove some unneeded psymtab initializations
allocate_psymtab has long cleared the new psymtab that is returned.
This patch documents this behavior and then removes some redundant
initializations.

gdb/ChangeLog
2019-01-10  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_end_psymtab): Remove some initializations.
	* psymtab.c (allocate_psymtab): Add comment.
	* psympriv.h (allocate_psymtab): Add comment.
	* dwarf2read.c (dwarf2_create_include_psymtab): Remove some
	initializations.
	* dbxread.c (dbx_end_psymtab): Remove some initializations.
2019-01-10 07:08:10 -07:00
Tom Tromey b22a7c6ab6 Remove ALL_OBJFILE_PSYMTABS
This removes the ALL_OBJFILE_PSYMTABS macro, replacing its uses with
ranged for loops.

gdb/ChangeLog
2019-01-09  Tom Tromey  <tom@tromey.com>

	* dbxread.c (dbx_end_psymtab): Use objfile_psymtabs.
	* mdebugread.c (parse_partial_symbols): Use objfile_psymtabs.
	* psymtab.c (ALL_OBJFILE_PSYMTABS_REQUIRED): Remove.
	(psym_map_symtabs_matching_filename, find_pc_sect_psymtab)
	(psym_lookup_symbol, psym_find_last_source_symtab)
	(psym_forget_cached_source_info, psym_print_stats)
	(psym_expand_symtabs_for_function, psym_expand_all_symtabs)
	(psym_expand_symtabs_with_fullname, psym_map_symbol_filenames)
	(psym_map_matching_symbols, psym_expand_symtabs_matching)
	(psym_find_compunit_symtab_by_address)
	(maintenance_print_psymbols, maintenance_info_psymtabs)
	(maintenance_check_psymtabs): Use ranged for.
	* psymtab.h (class objfile_psymtabs): New.
	(require_partial_symbols): Return objfile_psymtabs.
	* psympriv.h (ALL_OBJFILE_PSYMTABS): Remove.
2019-01-09 18:28:15 -07:00
Tom Tromey aed57c5371 Remove most uses of ALL_OBJFILES
This removes most uses of ALL_OBJFILES, replacing them with ranged for
loops.  The remaining uses are all in macros, and will be removed in
subsequent patches.

gdb/ChangeLog
2019-01-09  Tom Tromey  <tom@tromey.com>

	* symtab.c (iterate_over_symtabs, matching_obj_sections)
	(expand_symtab_containing_pc, lookup_static_symbol)
	(basic_lookup_transparent_type, find_pc_sect_compunit_symtab)
	(find_symbol_at_address, find_line_symtab, find_main_name): Use
	all_objfiles.
	* probe.c (find_probe_by_pc, collect_probes): Use all_objfiles.
	* breakpoint.c (create_overlay_event_breakpoint)
	(create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint): Use all_objfiles.
	* linux-thread-db.c (try_thread_db_load_from_pdir)
	(has_libpthread): Use all_objfiles.
	* ada-lang.c (add_nonlocal_symbols): Use all_objfiles.
	* linespec.c (iterate_over_all_matching_symtabs)
	(search_minsyms_for_name): Use all_objfiles.
	* maint.c (maintenance_info_sections): Use all_objfiles.
	* main.c (captured_main_1): Use all_objfiles.
	* spu-tdep.c (spu_objfile_from_frame): Use all_objfiles.
	* guile/scm-objfile.c (gdbscm_objfiles): Use all_objfiles.
	* guile/scm-pretty-print.c
	(ppscm_find_pretty_printer_from_objfiles): Use all_objfiles.
	* solib-spu.c (append_ocl_sos): Use all_objfiles.
	* symmisc.c (maintenance_print_symbols): Use all_objfiles.
	(maintenance_print_msymbols): Use all_objfiles.
	* source.c (select_source_symtab): Use all_objfiles.
	* jit.c (jit_find_objf_with_entry_addr): Use all_objfiles.
	* symfile.c (remove_symbol_file_command)
	(expand_symtabs_matching, map_symbol_filenames): Use
	all_objfiles.
	* ppc-linux-tdep.c (ppc_linux_spe_context_inferior_created): Use
	all_objfiles.
	* dwarf2-frame.c (dwarf2_frame_find_fde): Use all_objfiles.
	* objc-lang.c (find_methods): Use all_objfiles.
	* objfiles.c (have_partial_symbols, have_full_symbols)
	(have_minimal_symbols, qsort_cmp)
	(default_iterate_over_objfiles_in_search_order): Use
	all_objfiles.
	* hppa-tdep.c (find_unwind_entry): Use all_objfiles.
	* psymtab.c (maintenance_print_psymbols): Use all_objfiles.
	(maintenance_check_psymtabs): Use all_objfiles.
	(ALL_PSYMTABS): Remove.
	* compile/compile-object-run.c (do_module_cleanup): Use
	all_objfiles.
	* blockframe.c (find_pc_partial_function): Use all_objfiles.
	* cp-support.c (add_symbol_overload_list_qualified): Use
	all_objfiles.
	* windows-tdep.c (windows_iterate_over_objfiles_in_search_order):
	Use all_objfiles.
	* dwarf-index-write.c (save_gdb_index_command): Use all_objfiles.
	* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers): Use
	all_objfiles.
	* python/py-objfile.c (objfpy_lookup_objfile_by_name)
	(objfpy_lookup_objfile_by_build_id): Use all_objfiles.
	* python/py-prettyprint.c (find_pretty_printer_from_objfiles):
	Uses all_objfiles.
	* solib.c (solib_read_symbols): Use all_objfiles
2019-01-09 18:28:14 -07:00
Tom Tromey 99d89cdea6 Remove ALL_PSPACE_OBJFILES
This removes the ALL_PSPACE_OBJFILES macro in favor of ranged for
loops.

gdb/ChangeLog
2019-01-09  Tom Tromey  <tom@tromey.com>

	* probe.c (parse_probes_in_pspace): Use all_objfiles.
	* guile/scm-progspace.c (gdbscm_progspace_objfiles): Use
	all_objfiles.
	* objfiles.h (ALL_PSPACE_OBJFILES): Remove.
	* symmisc.c (print_symbol_bcache_statistics)
	(print_objfile_statistics, maintenance_print_objfiles)
	(maintenance_info_symtabs, maintenance_check_symtabs)
	(maintenance_expand_symtabs, maintenance_info_line_tables): Use
	all_objfiles.
	* source.c (forget_cached_source_info): Use all_objfiles.
	* symfile-debug.c (set_debug_symfile): Use all_objfiles.
	* elfread.c (elf_gnu_ifunc_resolve_by_cache)
	(elf_gnu_ifunc_resolve_by_got): Use all_objfiles.
	* objfiles.c (update_section_map): Use all_objfiles.
	(shared_objfile_contains_address_p): Likewise.
	* psymtab.c (maintenance_info_psymtabs): Use all_objfiles.
	* python/py-progspace.c (pspy_get_objfiles): Use all_objfiles.
2019-01-09 18:28:14 -07:00
Tom Tromey 48c5e7e239 Use upper case for more metasyntactic variables in gdb
I noticed a few places where a Usage line in gdb did not use upper
case for metasyntactic variables.  This patch fixes all the instances
I found.

Tested on x86-64 Fedora 28.

gdb/ChangeLog
2019-01-04  Tom Tromey  <tom@tromey.com>

	* compile/compile.c (_initialize_compile): Use upper case for
	metasyntactic variables.
	* symmisc.c (_initialize_symmisc): Use upper case for
	metasyntactic variables.
	* psymtab.c (_initialize_psymtab): Use upper case for
	metasyntactic variables.
	* demangle.c (demangle_command): Use upper case for metasyntactic
	variables.
	(_initialize_demangler): Likewise.
	* ax-gdb.c (_initialize_ax_gdb): Use upper case for metasyntactic
	variables.
2019-01-04 11:08:02 -07:00
Joel Brobecker 42a4f53d2b Update copyright year range in all GDB files.
This commit applies all changes made after running the gdb/copyright.py
script.

Note that one file was flagged by the script, due to an invalid
copyright header
(gdb/unittests/basic_string_view/element_access/char/empty.cc).
As the file was copied from GCC's libstdc++-v3 testsuite, this commit
leaves this file untouched for the time being; a patch to fix the header
was sent to gcc-patches first.

gdb/ChangeLog:

	Update copyright year range in all GDB files.
2019-01-01 10:01:51 +04:00
Tom Tromey 2179fbc36d Return scoped_fd from open_source_file and find_and_open_source
This changes open_source_file and find_and_open_source to return
scoped_fd, then updates the callers as appropriate, including using
scoped_fd::to_file.

Tested by the buildbot.

gdb/ChangeLog
2018-11-09  Tom Tromey  <tom@tromey.com>

	* common/scoped_fd.h (class scoped_fd): Add move constructor and
	move assignment operator.
	* psymtab.c (psymtab_to_fullname): Update.
	* source.h (open_source_file): Return scoped_fd.
	(find_and_open_source): Likewise.
	* source.c (open_source_file): Return scoped_fd.
	(get_filename_and_charpos): Update.
	(print_source_lines_base): Update.  Use scoped_fd::to_file.
	(forward_search_command): Likewise.
	(reverse_search_command): Likewise.
	(find_and_open_source): Return scoped_fd.
	* tui/tui-source.c (tui_set_source_content): Update.  Use
	gdb_file_up.
2018-11-09 15:47:45 -07:00
Joel Brobecker d2f7dcb218 reformat parameters of gdb/psymtab.c::recursively_search_psymtabs
This is just to make sure one of the parameters doesn't end past
the 80 characters limit. And while at it, since all parameters were
on their own line except the first two that were listed on the same
line, it felf more consistent to just split them to have each and
every parameter on their own line.

gdb/ChangeLog:

        * psymtab.c (recursively_search_psymtabs): Reformat parameters
        to avoid exceeding 80 characters per line limit.

Tested by rebuilding GDB on x86_64-linux.
2018-10-04 18:04:13 -04:00
Tom Tromey 3453e7e409 Clean up "Reading symbols" output
This patch is another attempt to fix PR cli/19551.  Unlike my previous
attempt, it doesn't print progress.  Instead, it just changes some
messages and adds newlines to make the output a bit nicer.

It also removes the "done." text that was previously emitted.  The
idea here is that it is obvious when gdb is done reading debug info,
as it starts then doing something else; and that while this message
did not provide much benefit to users, it did make it harder to make
the output clean.

After this change the output from "./gdb -iex 'set complaint 1' -nx ./gdb"
reads:

    Reading symbols from ./gdb...
    .debug_ranges entry has start address of zero [in module /home/tromey/gdb/build/gdb/gdb]
    DW_AT_low_pc 0x0 is zero for DIE at 0x17116c1 [in module /home/tromey/gdb/build/gdb/gdb]
    .debug_line address at offset 0xa22f5 is 0 [in module /home/tromey/gdb/build/gdb/gdb]
    During symbol reading, unsupported tag: 'DW_TAG_unspecified_type'.
    During symbol reading, const value length mismatch for 'std::ratio<1, 1000000000>::num', got 8, expected 0.

gdb/ChangeLog
2018-10-04  Tom Tromey  <tom@tromey.com>

	PR cli/19551:
	* symfile.c (symbol_file_add_with_addrs): Update output.
	* psymtab.c (require_partial_symbols): Update output.

gdb/testsuite/ChangeLog
2018-10-04  Tom Tromey  <tom@tromey.com>

	PR cli/19551:
	* lib/mi-support.exp (mi_gdb_file_cmd): Update.
	* lib/gdb.exp (gdb_file_cmd): Update.
	* gdb.stabs/weird.exp (print_weird_var): Update.
	* gdb.server/solib-list.exp: Update.
	* gdb.multi/remove-inferiors.exp (test_remove_inferiors): Update.
	* gdb.mi/mi-cli.exp: Update.
	* gdb.linespec/linespec.exp: Update.
	* gdb.dwarf2/dw2-stack-boundary.exp: Update.
	* gdb.dwarf2/dw2-objfile-overlap.exp: Update.
	* gdb.cp/cp-relocate.exp: Update.
	* gdb.base/sym-file.exp: Update.
	* gdb.base/relocate.exp: Update.
	* gdb.base/readnever.exp: Update.
	* gdb.base/print-symbol-loading.exp (test_load_core): Update.
	* gdb.base/kill-detach-inferiors-cmd.exp: Update.
	* gdb.base/dbx.exp (gdb_file_cmd): Update.
	* gdb.base/code_elim.exp: Update.
	* gdb.base/break-unload-file.exp (test_break): Update.
	* gdb.base/break-interp.exp (test_attach_gdb): Update.
	* gdb.base/break-idempotent.exp (force_breakpoint_re_set):
	Update.
	* gdb.base/attach.exp (do_attach_tests): Update.
	* gdb.base/sepdebug.exp: Update.
	* gdb.python/py-section-script.exp: Update.
2018-10-04 13:40:10 -06:00