John Baldwin [Sat, 9 Sep 2017 18:02:37 +0000 (11:02 -0700)]
Remove unnecessary function prototypes.
These prototypes were required when compiling GDB as C but are not
required for C++.
gdb/ChangeLog:
* aarch64-linux-nat.c: Remove _initialize_aarch64_linux_nat
prototype.
* aarch64-linux-tdep.c: Remove _initialize_aarch64_linux_tdep
prototype.
* aarch64-newlib-tdep.c: Remove _initialize_aarch64_newlib_tdep
prototype.
* aarch64-tdep.c: Remove _initialize_aarch64_tdep prototype.
* ada-exp.y: Remove _initialize_ada_exp prototype.
* ada-lang.c: Remove _initialize_ada_language prototype.
* ada-tasks.c: Remove _initialize_tasks prototype.
* addrmap.c: Remove _initialize_addrmap prototype.
* agent.c: Remove _initialize_agent prototype.
* aix-thread.c: Remove _initialize_aix_thread prototype.
* alpha-bsd-nat.c: Remove _initialize_alphabsd_nat prototype.
* alpha-linux-nat.c: Remove _initialize_alpha_linux_nat prototype.
* alpha-linux-tdep.c: Remove _initialize_alpha_linux_tdep
prototype.
* alpha-nbsd-tdep.c: Remove _initialize_alphanbsd_tdep prototype.
* alpha-obsd-tdep.c: Remove _initialize_alphaobsd_tdep prototype.
* alpha-tdep.c: Remove _initialize_alpha_tdep prototype.
* amd64-darwin-tdep.c: Remove _initialize_amd64_darwin_tdep
prototype.
* amd64-dicos-tdep.c: Remove _initialize_amd64_dicos_tdep
prototype.
* amd64-fbsd-nat.c: Remove _initialize_amd64fbsd_nat prototype.
* amd64-fbsd-tdep.c: Remove _initialize_amd64fbsd_tdep prototype.
* amd64-linux-nat.c: Remove _initialize_amd64_linux_nat prototype.
* amd64-linux-tdep.c: Remove _initialize_amd64_linux_tdep
prototype.
* amd64-nbsd-nat.c: Remove _initialize_amd64nbsd_nat prototype.
* amd64-nbsd-tdep.c: Remove _initialize_amd64nbsd_tdep prototype.
* amd64-obsd-nat.c: Remove _initialize_amd64obsd_nat prototype.
* amd64-obsd-tdep.c: Remove _initialize_amd64obsd_tdep prototype.
* amd64-sol2-tdep.c: Remove _initialize_amd64_sol2_tdep prototype.
* amd64-tdep.c: Remove _initialize_amd64_tdep prototype.
* amd64-windows-nat.c: Remove _initialize_amd64_windows_nat
prototype.
* amd64-windows-tdep.c: Remove _initialize_amd64_windows_tdep
prototype.
* annotate.c: Remove _initialize_annotate prototype.
* arc-newlib-tdep.c: Remove _initialize_arc_newlib_tdep prototype.
* arc-tdep.c: Remove _initialize_arc_tdep prototype.
* arch-utils.c: Remove _initialize_gdbarch_utils prototype.
* arm-linux-nat.c: Remove _initialize_arm_linux_nat prototype.
* arm-linux-tdep.c: Remove _initialize_arm_linux_tdep prototype.
* arm-nbsd-tdep.c: Remove _initialize_arm_netbsd_tdep prototype.
* arm-obsd-tdep.c: Remove _initialize_armobsd_tdep prototype.
* arm-symbian-tdep.c: Remove _initialize_arm_symbian_tdep
prototype.
* arm-tdep.c: Remove _initialize_arm_tdep prototype.
* arm-wince-tdep.c: Remove _initialize_arm_wince_tdep prototype.
* auto-load.c: Remove _initialize_auto_load prototype.
* auxv.c: Remove _initialize_auxv prototype.
* avr-tdep.c: Remove _initialize_avr_tdep prototype.
* ax-gdb.c: Remove _initialize_ax_gdb prototype.
* bfin-linux-tdep.c: Remove _initialize_bfin_linux_tdep prototype.
* bfin-tdep.c: Remove _initialize_bfin_tdep prototype.
* break-catch-sig.c: Remove _initialize_break_catch_sig prototype.
* break-catch-syscall.c: Remove _initialize_break_catch_syscall
prototype.
* break-catch-throw.c: Remove _initialize_break_catch_throw
prototype.
* breakpoint.c: Remove _initialize_breakpoint prototype.
* bsd-uthread.c: Remove _initialize_bsd_uthread prototype.
* btrace.c: Remove _initialize_btrace prototype.
* charset.c: Remove _initialize_charset prototype.
* cli/cli-cmds.c: Remove _initialize_cli_cmds prototype.
* cli/cli-dump.c: Remove _initialize_cli_dump prototype.
* cli/cli-interp.c: Remove _initialize_cli_interp prototype.
* cli/cli-logging.c: Remove _initialize_cli_logging prototype.
* cli/cli-script.c: Remove _initialize_cli_script prototype.
* coff-pe-read.c: Remove _initialize_coff_pe_read prototype.
* coffread.c: Remove _initialize_coffread prototype.
* compile/compile.c: Remove _initialize_compile prototype.
* complaints.c: Remove _initialize_complaints prototype.
* completer.c: Remove _initialize_completer prototype.
* copying.awk: Remove _initialize_copying prototype.
* copying.c: Regenerate.
* core-regset.c: Remove _initialize_core_regset prototype.
* corefile.c: Remove _initialize_core prototype.
* corelow.c: Remove _initialize_corelow prototype.
* cp-abi.c: Remove _initialize_cp_abi prototype.
* cp-namespace.c: Remove _initialize_cp_namespace prototype.
* cp-support.c: Remove _initialize_cp_support prototype.
* cp-valprint.c: Remove _initialize_cp_valprint prototype.
* cris-linux-tdep.c: Remove _initialize_cris_linux_tdep prototype.
* cris-tdep.c: Remove _initialize_cris_tdep prototype.
* ctf.c: Remove _initialize_ctf prototype.
* d-lang.c: Remove _initialize_d_language prototype.
* darwin-nat-info.c: Remove _initialize_darwin_info_commands
prototype.
* darwin-nat.c: Remove _initialize_darwin_inferior prototype.
* dbxread.c: Remove _initialize_dbxread prototype.
* dcache.c: Remove _initialize_dcache prototype.
* demangle.c: Remove _initialize_demangler prototype.
* disasm-selftests.c: Remove _initialize_disasm_selftests
prototype.
* disasm.c: Remove _initialize_disasm prototype.
* dtrace-probe.c: Remove _initialize_dtrace_probe prototype.
* dummy-frame.c: Remove _initialize_dummy_frame prototype.
* dwarf2-frame-tailcall.c: Remove _initialize_tailcall_frame
prototype.
* dwarf2-frame.c: Remove _initialize_dwarf2_frame prototype.
* dwarf2expr.c: Remove _initialize_dwarf2expr prototype.
* dwarf2loc.c: Remove _initialize_dwarf2loc prototype.
* dwarf2read.c: Remove _initialize_dwarf2_read prototype.
* elfread.c: Remove _initialize_elfread prototype.
* exec.c: Remove _initialize_exec prototype.
* extension.c: Remove _initialize_extension prototype.
* f-lang.c: Remove _initialize_f_language prototype.
* f-valprint.c: Remove _initialize_f_valprint prototype.
* fbsd-nat.c: Remove _initialize_fbsd_nat prototype.
* fbsd-tdep.c: Remove _initialize_fbsd_tdep prototype.
* filesystem.c: Remove _initialize_filesystem prototype.
* findcmd.c: Remove _initialize_mem_search prototype.
* fork-child.c: Remove _initialize_fork_child prototype.
* frame-base.c: Remove _initialize_frame_base prototype.
* frame-unwind.c: Remove _initialize_frame_unwind prototype.
* frame.c: Remove _initialize_frame prototype.
* frv-linux-tdep.c: Remove _initialize_frv_linux_tdep prototype.
* frv-tdep.c: Remove _initialize_frv_tdep prototype.
* ft32-tdep.c: Remove _initialize_ft32_tdep prototype.
* gcore.c: Remove _initialize_gcore prototype.
* gdb_bfd.c: Remove _initialize_gdb_bfd prototype.
* gdbarch.c: Regenerate.
* gdbarch.sh: Remove _initialize_gdbarch prototype.
* gdbtypes.c: Remove _initialize_gdbtypes prototype.
* gnu-nat.c: Remove _initialize_gnu_nat prototype.
* gnu-v2-abi.c: Remove _initialize_gnu_v2_abi prototype.
* gnu-v3-abi.c: Remove _initialize_gnu_v3_abi prototype.
* go-lang.c: Remove _initialize_go_language prototype.
* go32-nat.c: Remove _initialize_go32_nat prototype.
* guile/guile.c: Remove _initialize_guile prototype.
* h8300-tdep.c: Remove _initialize_h8300_tdep prototype.
* hppa-linux-nat.c: Remove _initialize_hppa_linux_nat prototype.
* hppa-linux-tdep.c: Remove _initialize_hppa_linux_tdep prototype.
* hppa-nbsd-nat.c: Remove _initialize_hppanbsd_nat prototype.
* hppa-nbsd-tdep.c: Remove _initialize_hppanbsd_tdep prototype.
* hppa-obsd-nat.c: Remove _initialize_hppaobsd_nat prototype.
* hppa-obsd-tdep.c: Remove _initialize_hppaobsd_tdep prototype.
* hppa-tdep.c: Remove _initialize_hppa_tdep prototype.
* i386-bsd-nat.c: Remove _initialize_i386bsd_nat prototype.
* i386-cygwin-tdep.c: Remove _initialize_i386_cygwin_tdep
prototype.
* i386-darwin-tdep.c: Remove _initialize_i386_darwin_tdep
prototype.
* i386-dicos-tdep.c: Remove _initialize_i386_dicos_tdep prototype.
* i386-fbsd-nat.c: Remove _initialize_i386fbsd_nat prototype.
* i386-fbsd-tdep.c: Remove _initialize_i386fbsd_tdep prototype.
* i386-gnu-nat.c: Remove _initialize_i386gnu_nat prototype.
* i386-gnu-tdep.c: Remove _initialize_i386gnu_tdep prototype.
* i386-linux-nat.c: Remove _initialize_i386_linux_nat prototype.
* i386-linux-tdep.c: Remove _initialize_i386_linux_tdep prototype.
* i386-nbsd-nat.c: Remove _initialize_i386nbsd_nat prototype.
* i386-nbsd-tdep.c: Remove _initialize_i386nbsd_tdep prototype.
* i386-nto-tdep.c: Remove _initialize_i386nto_tdep prototype.
* i386-obsd-nat.c: Remove _initialize_i386obsd_nat prototype.
* i386-obsd-tdep.c: Remove _initialize_i386obsd_tdep prototype.
* i386-sol2-nat.c: Remove _initialize_amd64_sol2_nat prototype.
* i386-sol2-tdep.c: Remove _initialize_amd64_sol2_tdep prototype.
* i386-tdep.c: Remove _initialize_i386_tdep prototype.
* i386-windows-nat.c: Remove _initialize_i386_windows_nat
prototype.
* ia64-libunwind-tdep.c: Remove _initialize_libunwind_frame
prototype.
* ia64-linux-nat.c: Remove _initialize_ia64_linux_nat prototype.
* ia64-linux-tdep.c: Remove _initialize_ia64_linux_tdep prototype.
* ia64-tdep.c: Remove _initialize_ia64_tdep prototype.
* ia64-vms-tdep.c: Remove _initialize_ia64_vms_tdep prototype.
* infcall.c: Remove _initialize_infcall prototype.
* infcmd.c: Remove _initialize_infcmd prototype.
* inferior.c: Remove _initialize_inferiors prototype.
* inflow.c: Remove _initialize_inflow prototype.
* infrun.c: Remove _initialize_infrun prototype.
* interps.c: Remove _initialize_interpreter prototype.
* iq2000-tdep.c: Remove _initialize_iq2000_tdep prototype.
* jit.c: Remove _initialize_jit prototype.
* language.c: Remove _initialize_language prototype.
* linux-fork.c: Remove _initialize_linux_fork prototype.
* linux-nat.c: Remove _initialize_linux_nat prototype.
* linux-tdep.c: Remove _initialize_linux_tdep prototype.
* linux-thread-db.c: Remove _initialize_thread_db prototype.
* lm32-tdep.c: Remove _initialize_lm32_tdep prototype.
* m2-lang.c: Remove _initialize_m2_language prototype.
* m32c-tdep.c: Remove _initialize_m32c_tdep prototype.
* m32r-linux-nat.c: Remove _initialize_m32r_linux_nat prototype.
* m32r-linux-tdep.c: Remove _initialize_m32r_linux_tdep prototype.
* m32r-tdep.c: Remove _initialize_m32r_tdep prototype.
* m68hc11-tdep.c: Remove _initialize_m68hc11_tdep prototype.
* m68k-bsd-nat.c: Remove _initialize_m68kbsd_nat prototype.
* m68k-bsd-tdep.c: Remove _initialize_m68kbsd_tdep prototype.
* m68k-linux-nat.c: Remove _initialize_m68k_linux_tdep prototype.
* m68k-linux-tdep.c: Remove _initialize_m68k_linux_tdep prototype.
* m68k-tdep.c: Remove _initialize_m68k_tdep prototype.
* m88k-bsd-nat.c: Remove _initialize_m68kbsd_nat prototype.
* m88k-tdep.c: Remove _initialize_m68kbsd_tdep prototype.
* machoread.c: Remove _initialize_machoread prototype.
* macrocmd.c: Remove _initialize_macrocmd prototype.
* macroscope.c: Remove _initialize_macroscope prototype.
* maint.c: Remove _initialize_maint_cmds prototype.
* mdebugread.c: Remove _initialize_mdebugread prototype.
* memattr.c: Remove _initialize_mem prototype.
* mep-tdep.c: Remove _initialize_mep_tdep prototype.
* mi/mi-cmd-env.c: Remove _initialize_mi_cmd_env prototype.
* mi/mi-cmds.c: Remove _initialize_mi_cmds prototype.
* mi/mi-interp.c: Remove _initialize_mi_interp prototype.
* mi/mi-main.c: Remove _initialize_mi_main prototype.
* microblaze-linux-tdep.c: Remove
_initialize_microblaze_linux_tdep prototype.
* microblaze-tdep.c: Remove _initialize_microblaze_tdep prototype.
* mips-fbsd-nat.c: Remove _initialize_mips_fbsd_nat prototype.
* mips-fbsd-tdep.c: Remove _initialize_mips_fbsd_tdep prototype.
* mips-linux-nat.c: Remove _initialize_mips_linux_nat prototype.
* mips-linux-tdep.c: Remove _initialize_mips_linux_tdep prototype.
* mips-nbsd-nat.c: Remove _initialize_mipsnbsd_nat prototype.
* mips-nbsd-tdep.c: Remove _initialize_mipsnbsd_tdep prototype.
* mips-sde-tdep.c: Remove _initialize_mips_sde_tdep prototype.
* mips-tdep.c: Remove _initialize_mips_tdep prototype.
* mips64-obsd-nat.c: Remove _initialize_mips64obsd_nat prototype.
* mips64-obsd-tdep.c: Remove _initialize_mips64obsd_tdep
prototype.
* mipsread.c: Remove _initialize_mipsread prototype.
* mn10300-linux-tdep.c: Remove _initialize_mn10300_linux_tdep
prototype.
* mn10300-tdep.c: Remove _initialize_mn10300_tdep prototype.
* moxie-tdep.c: Remove _initialize_moxie_tdep prototype.
* msp430-tdep.c: Remove _initialize_msp430_tdep prototype.
* mt-tdep.c: Remove _initialize_mt_tdep prototype.
* nds32-tdep.c: Remove _initialize_nds32_tdep prototype.
* nios2-linux-tdep.c: Remove _initialize_nios2_linux_tdep
prototype.
* nios2-tdep.c: Remove _initialize_nios2_tdep prototype.
* nto-procfs.c: Remove _initialize_procfs prototype.
* nto-tdep.c: Remove _initialize_nto_tdep prototype.
* objc-lang.c: Remove _initialize_objc_language prototype.
* objfiles.c: Remove _initialize_objfiles prototype.
* observer.c: Remove observer_test_first_notification_function,
observer_test_second_notification_function,
observer_test_third_notification_function, and
_initialize_observer prototypes.
* opencl-lang.c: Remove _initialize_opencl_language prototypes.
* osabi.c: Remove _initialize_gdb_osabi prototype.
* osdata.c: Remove _initialize_osdata prototype.
* p-valprint.c: Remove _initialize_pascal_valprint prototype.
* parse.c: Remove _initialize_parse prototype.
* ppc-fbsd-nat.c: Remove _initialize_ppcfbsd_nat prototype.
* ppc-fbsd-tdep.c: Remove _initialize_ppcfbsd_tdep prototype.
* ppc-linux-nat.c: Remove _initialize_ppc_linux_nat prototype.
* ppc-linux-tdep.c: Remove _initialize_ppc_linux_tdep prototype.
* ppc-nbsd-nat.c: Remove _initialize_ppcnbsd_nat prototype.
* ppc-nbsd-tdep.c: Remove _initialize_ppcnbsd_tdep prototype.
* ppc-obsd-nat.c: Remove _initialize_ppcobsd_nat prototype.
* ppc-obsd-tdep.c: Remove _initialize_ppcobsd_tdep prototype.
* printcmd.c: Remove _initialize_printcmd prototype.
* probe.c: Remove _initialize_probe prototype.
* proc-api.c: Remove _initialize_proc_api prototype.
* proc-events.c: Remove _initialize_proc_events prototype.
* proc-service.c: Remove _initialize_proc_service prototype.
* procfs.c: Remove _initialize_procfs prototype.
* psymtab.c: Remove _initialize_psymtab prototype.
* python/python.c: Remove _initialize_python prototype.
* ravenscar-thread.c: Remove _initialize_ravenscar prototype.
* record-btrace.c: Remove _initialize_record_btrace prototype.
* record-full.c: Remove _initialize_record_full prototype.
* record.c: Remove _initialize_record prototype.
* regcache.c: Remove _initialize_regcache prototype.
* reggroups.c: Remove _initialize_reggroup prototype.
* remote-notif.c: Remove _initialize_notif prototype.
* remote-sim.c: Remove _initialize_remote_sim prototype.
* remote.c: Remove _initialize_remote prototype.
* reverse.c: Remove _initialize_reverse prototype.
* rl78-tdep.c: Remove _initialize_rl78_tdep prototype.
* rs6000-aix-tdep.c: Remove _initialize_rs6000_aix_tdep prototype.
* rs6000-lynx178-tdep.c: Remove _initialize_rs6000_lynx178_tdep
prototype.
* rs6000-nat.c: Remove _initialize_rs6000_nat prototype.
* rs6000-tdep.c: Remove _initialize_rs6000_tdep prototype.
* rust-exp.y: Remove _initialize_rust_exp prototype.
* rx-tdep.c: Remove _initialize_rx_tdep prototype.
* s390-linux-nat.c: Remove _initialize_s390_nat prototype.
* s390-linux-tdep.c: Remove _initialize_s390_tdep prototype.
* score-tdep.c: Remove _initialize_score_tdep prototype.
* selftest-arch.c: Remove _initialize_selftests_foreach_arch
prototype.
* ser-go32.c: Remove _initialize_ser_dos prototype.
* ser-mingw.c: Remove _initialize_ser_windows prototype.
* ser-pipe.c: Remove _initialize_ser_pipe prototype.
* ser-tcp.c: Remove _initialize_ser_tcp prototype.
* ser-unix.c: Remove _initialize_ser_hardwire prototype.
* serial.c: Remove _initialize_serial prototype.
* sh-linux-tdep.c: Remove _initialize_sh_linux_tdep prototype.
* sh-nbsd-nat.c: Remove _initialize_shnbsd_nat prototype.
* sh-nbsd-tdep.c: Remove _initialize_shnbsd_tdep prototype.
* sh-tdep.c: Remove _initialize_sh_tdep prototype.
* skip.c: Remove _initialize_step_skip prototype.
* sol-thread.c: Remove _initialize_sol_thread prototype.
* solib-aix.c: Remove _initialize_solib_aix prototype.
* solib-darwin.c: Remove _initialize_darwin_solib prototype.
* solib-dsbt.c: Remove _initialize_dsbt_solib prototype.
* solib-frv.c: Remove _initialize_frv_solib prototype.
* solib-spu.c: Remove _initialize_spu_solib prototype.
* solib-svr4.c: Remove _initialize_svr4_solib prototype.
* solib-target.c: Remove _initialize_solib_target prototype.
* solib.c: Remove _initialize_solib prototype.
* source.c: Remove _initialize_source prototype.
* sparc-linux-nat.c: Remove _initialize_sparc_linux_nat prototype.
* sparc-linux-tdep.c: Remove _initialize_sparc_linux_tdep
prototype.
* sparc-nat.c: Remove _initialize_sparc_nat prototype.
* sparc-nbsd-nat.c: Remove _initialize_sparcnbsd_nat prototype.
* sparc-nbsd-tdep.c: Remove _initialize_sparcnbsd_tdep prototype.
* sparc-obsd-tdep.c: Remove _initialize_sparc32obsd_tdep
prototype.
* sparc-sol2-nat.c: Remove _initialize_sparc_sol2_nat prototype.
* sparc-sol2-tdep.c: Remove _initialize_sparc_sol2_tdep prototype.
* sparc-tdep.c: Remove _initialize_sparc_tdep prototype.
* sparc64-fbsd-nat.c: Remove _initialize_sparc64fbsd_nat
prototype.
* sparc64-fbsd-tdep.c: Remove _initialize_sparc64fbsd_tdep
prototype.
* sparc64-linux-nat.c: Remove _initialize_sparc64_linux_nat
prototype.
* sparc64-linux-tdep.c: Remove _initialize_sparc64_linux_tdep
prototype.
* sparc64-nat.c: Remove _initialize_sparc64_nat prototype.
* sparc64-nbsd-nat.c: Remove _initialize_sparc64nbsd_nat
prototype.
* sparc64-nbsd-tdep.c: Remove _initialize_sparc64nbsd_tdep
prototype.
* sparc64-obsd-nat.c: Remove _initialize_sparc64obsd_nat
prototype.
* sparc64-obsd-tdep.c: Remove _initialize_sparc64obsd_tdep
prototype.
* sparc64-sol2-tdep.c: Remove _initialize_sparc64_sol2_tdep
prototype.
* spu-linux-nat.c: Remove _initialize_spu_nat prototype.
* spu-multiarch.c: Remove _initialize_spu_multiarch prototype.
* spu-tdep.c: Remove _initialize_spu_tdep prototype.
* stabsread.c: Remove _initialize_stabsread prototype.
* stack.c: Remove _initialize_stack prototype.
* stap-probe.c: Remove _initialize_stap_probe prototype.
* std-regs.c: Remove _initialize_frame_reg prototype.
* symfile-debug.c: Remove _initialize_symfile_debug prototype.
* symfile-mem.c: Remove _initialize_symfile_mem prototype.
* symfile.c: Remove _initialize_symfile prototype.
* symmisc.c: Remove _initialize_symmisc prototype.
* symtab.c: Remove _initialize_symtab prototype.
* target-dcache.c: Remove _initialize_target_dcache prototype.
* target-descriptions.c: Remove _initialize_target_descriptions
prototype.
* thread.c: Remove _initialize_thread prototype.
* tic6x-linux-tdep.c: Remove _initialize_tic6x_linux_tdep
prototype.
* tic6x-tdep.c: Remove _initialize_tic6x_tdep prototype.
* tilegx-linux-nat.c: Remove _initialize_tile_linux_nat prototype.
* tilegx-linux-tdep.c: Remove _initialize_tilegx_linux_tdep
prototype.
* tilegx-tdep.c: Remove _initialize_tilegx_tdep prototype.
* tracefile-tfile.c: Remove _initialize_tracefile_tfile prototype.
* tracefile.c: Remove _initialize_tracefile prototype.
* tracepoint.c: Remove _initialize_tracepoint prototype.
* tui/tui-hooks.c: Remove _initialize_tui_hooks prototype.
* tui/tui-interp.c: Remove _initialize_tui_interp prototype.
* tui/tui-layout.c: Remove _initialize_tui_layout prototype.
* tui/tui-regs.c: Remove _initialize_tui_regs prototype.
* tui/tui-stack.c: Remove _initialize_tui_stack prototype.
* tui/tui-win.c: Remove _initialize_tui_win prototype.
* tui/tui.c: Remove _initialize_tui prototype.
* typeprint.c: Remove _initialize_typeprint prototype.
* user-regs.c: Remove _initialize_user_regs prototype.
* utils.c: Remove _initialize_utils prototype.
* v850-tdep.c: Remove _initialize_v850_tdep prototype.
* valarith.c: Remove _initialize_valarith prototype.
* valops.c: Remove _initialize_valops prototype.
* valprint.c: Remove _initialize_valprint prototype.
* value.c: Remove _initialize_values prototype.
* varobj.c: Remove _initialize_varobj prototype.
* vax-bsd-nat.c: Remove _initialize_vaxbsd_nat prototype.
* vax-nbsd-tdep.c: Remove _initialize_vaxnbsd_tdep prototype.
* vax-tdep.c: Remove _initialize_vax_tdep prototype.
* windows-nat.c: Remove _initialize_windows_nat,
_initialize_check_for_gdb_ini, and _initialize_loadable
prototypes.
* windows-tdep.c: Remove _initialize_windows_tdep prototype.
* xcoffread.c: Remove _initialize_xcoffread prototype.
* xml-support.c: Remove _initialize_xml_support prototype.
* xstormy16-tdep.c: Remove _initialize_xstormy16_tdep prototype.
* xtensa-linux-nat.c: Remove _initialize_xtensa_linux_nat
prototype.
* xtensa-linux-tdep.c: Remove _initialize_xtensa_linux_tdep
prototype.
* xtensa-tdep.c: Remove _initialize_xtensa_tdep prototype.
Alan Modra [Sat, 9 Sep 2017 12:25:22 +0000 (21:55 +0930)]
PowerPC64 --plt-align
This changes the PowerPC64 --plt-align option to perform the usual
alignment of code as suggested by its name, as well as the previous
behaviour of padding so as to reduce boundary crossing. The old
behaviour is had by using a negative parameter.
The default is also changed to align plt stub code by default to 32
byte boundaries, the point being to get better bctr branch prediction
on power8 and power9 hardware.
bfd/
* elf64-ppp.c (plt_stub_pad): Handle positive and negative
plt_stub_align.
ld/
* ld.texinfo (--plt-align): Describe new behaviour of option.
* emultempl/ppc64elf.em (params): Default plt_stub_align to 5.
* testsuite/ld-powerpc/powerpc.exp: Pass --no-plt-align for
selected tests.
* testsuite/ld-powerpc/relbrlt.d: Pass --no-plt-align.
* testsuite/ld-powerpc/elfv2so.d: Adjust expected output.
H.J. Lu [Sat, 9 Sep 2017 14:29:15 +0000 (07:29 -0700)]
x86: Update UNDEFINED_WEAK_RESOLVED_TO_ZERO
Since the only information which SYMBOL_REFERENCES_LOCAL_P doesn't check
is relocations, UNDEFINED_WEAK_RESOLVED_TO_ZERO only needs to check for
relocations with SYMBOL_REFERENCES_LOCAL_P.
* elf32-i386.c (elf_i386_relocate_section): Update usage of
UNDEFINED_WEAK_RESOLVED_TO_ZERO.
(elf_i386_finish_dynamic_symbol): Likewise.
* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
(elf_x86_64_finish_dynamic_symbol): Likewise.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Likewise.
(_bfd_x86_elf_fixup_symbol): Likewise.
H.J. Lu [Sat, 9 Sep 2017 14:19:36 +0000 (07:19 -0700)]
x86: Don't check has_non_got_reloc
_bfd_x86_elf_link_symbol_references_local should depend only on symbol
references, not relocations, to work in check_relocs.
* elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't
check has_non_got_reloc.
H.J. Lu [Sat, 9 Sep 2017 12:31:30 +0000 (05:31 -0700)]
x86: Remove restriction on NOTRACK prefix position
Since the NOTRACK prefix is no longer required to be the last prefix
before the REX prefix, restriction on the NOTRACK prefix position is
removed from assembler as well as disassembler. Assembler encodes the
NOTRACK prefix the same way as the DS segment register, which places
it before other prefixes. Disassembler displays prefixes in the order
they appear.
gas/
* config/tc-i386.c (NOTRACK_PREFIX): Removed.
(REX_PREFIX): Updated.
(MAX_PREFIXES): Likewise.
(parse_insn): Remove restriction on NOTRACK prefix position.
* testsuite/gas/i386/notrack.s: Add tests with NOTRACK prefix
before other prefixes.
* testsuite/gas/i386/x86-64-notrack.s: Likewise.
* testsuite/gas/i386/notrackbad.s: Remove tests with NOTRACK
prefix before other prefixes.
* testsuite/gas/i386/x86-64-notrackbad.s: Likewise.
* testsuite/gas/i386/notrack-intel.d: Updated.
* testsuite/gas/i386/notrack.d: Likewise.
* testsuite/gas/i386/notrackbad.l: Likewise.
* testsuite/gas/i386/x86-64-notrack-intel.d: Likewise.
* testsuite/gas/i386/x86-64-notrack.d: Likewise.
* testsuite/gas/i386/x86-64-notrackbad.l: Likewise.
opcodes/
* i386-dis.c (last_active_prefix): Removed.
(ckprefix): Don't set last_active_prefix.
(NOTRACK_Fixup): Don't check last_active_prefix.
H.J. Lu [Sat, 9 Sep 2017 12:05:16 +0000 (05:05 -0700)]
x86: Properly handle __ehdr_start
After _bfd_i386_elf_convert_load and _bfd_x86_64_elf_convert_load are
removed, elf_i386_convert_load_reloc and elf_x86_64_convert_load_reloc
see __ehdr_start as an undefined symbol when they are called from
check_relocs to convert GOT relocations against local symbols. But
__ehdr_start will be defined as a hidden symbol by linker at the later
stage if it is referenced. This patch marks __ehdr_start as a defined
local symbol at the start of check_relocs if it is referenced and not
defined.
bfd/
PR ld/22115
* elf32-i386.c (elf_i386_convert_load_reloc): Check linker_def.
Don't use UNDEFINED_WEAK_RESOLVED_TO_ZERO.
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Check
linker_def. Don't use UNDEFINED_WEAK_RESOLVED_TO_ZERO.
* elfxx-x86.c (_bfd_x86_elf_link_check_relocs): Set local_ref
and linker_def on __ehdr_start if it is referenced and not
defined.
(_bfd_x86_elf_link_symbol_references_local): Also set local_ref
and return TRUE when building executable, if a symbol has
non-GOT/non-PLT relocations in text section or there is no
dynamic linker.
* elfxx-x86.h (elf_x86_link_hash_entry): Add linker_def.
ld/
PR ld/22115
* ld-i386/i386.exp: Run PR ld/22115 tests,
* ld/testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr22115-1.s: New file.
* testsuite/ld-i386/pr22115-1a.d: Likewise.
* testsuite/ld-i386/pr22115-1b.d: Likewise.
* testsuite/ld-i386/pr22115-1c.d: Likewise.
* testsuite/ld-i386/pr22115-1d.d: Likewise.
* testsuite/ld-x86-64/pr22115-1.s: Likewise.
* testsuite/ld-x86-64/pr22115-1a-x32.d: Likewise.
* testsuite/ld-x86-64/pr22115-1a.d: Likewise.
* testsuite/ld-x86-64/pr22115-1b-x32.d: Likewise.
* testsuite/ld-x86-64/pr22115-1b.d: Likewise.
* testsuite/ld-x86-64/pr22115-1c-x32.d: Likewise.
* testsuite/ld-x86-64/pr22115-1c.d: Likewise.
* testsuite/ld-x86-64/pr22115-1d-x32.d: Likewise.
* testsuite/ld-x86-64/pr22115-1d.d: Likewise.
GDB Administrator [Sat, 9 Sep 2017 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in
Keith Seitz [Fri, 8 Sep 2017 23:44:30 +0000 (16:44 -0700)]
Remove unused field field_info.fnfields
Since at least 7.3 the "fnfields" field in struct field_info has been
unused. This patch simply removes it.
gdb/ChangeLog:
* dwarf2read.c (struct field_info) <fnfields>: Remove unused
field.
H.J. Lu [Fri, 8 Sep 2017 16:15:25 +0000 (09:15 -0700)]
x86: Update comments in elfxx-x86.h
* elfxx-x86.h: Update comments.
Christoph Weinmann [Fri, 8 Sep 2017 13:11:47 +0000 (15:11 +0200)]
Remove C/C++ relevant code in Fortran specific file.
Remove code relevant for printing C/C++ Integer values in a
Fortran specific file to unify printing of Fortran values.
This does not change the output.
Bernhard Heckel [Fri, 8 Sep 2017 13:11:47 +0000 (15:11 +0200)]
fortran: Testsuite, fix typos in vla-value.
Bernhard Heckel [Fri, 8 Sep 2017 13:11:47 +0000 (15:11 +0200)]
Fortran: Testsuite, fix differences in type naming.
Frank Penczek [Fri, 8 Sep 2017 13:11:47 +0000 (15:11 +0200)]
Fix indentation for printing Fortran types with pointers
Printing the prefix "PTR TO -> (" resp. "REF TO ->(" ignored the active
indentation level. This caused inconsistent appearance of user-defined
Fortran types containing pointers. Fix by using "fprintfi_filtered" with the
current indentation level for outputting the prefix string. Add test case
ptr-indentation.
Example using 'ptype' on object of type:
type TypeWithPointer
integer i
integer, pointer:: p
end type TypeWithPointer
Before:
type = Type typewithpointer
integer(kind=4) :: i
PTR TO -> ( integer(kind=4) :: p)
End Type typewithpointer
After:
type = Type typewithpointer
integer(kind=4) :: i
PTR TO -> ( integer(kind=4) :: p)
End Type typewithpointer
H.J. Lu [Fri, 8 Sep 2017 11:10:34 +0000 (04:10 -0700)]
x86: Replace elf_x86_plt_layout_table with elf_x86_init_table
* elf32-i386.c (elf_i386_link_setup_gnu_properties): Replace
elf_x86_plt_layout_table with elf_x86_init_table.
* elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties):
Likewise.
* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties):
Likewise.
* elfxx-x86.h (elf_x86_plt_layout_table): Renamed to ...
(elf_x86_init_table): This.
(_bfd_x86_elf_link_setup_gnu_properties): Replace
elf_x86_plt_layout_table with elf_x86_init_table.
H.J. Lu [Fri, 8 Sep 2017 00:19:10 +0000 (17:19 -0700)]
x86; Don't add elf64-x86-64.lo nor elf64.lo together with elfxx-x86.lo
Don't set r_info and r_sym fields in _bfd_x86_elf_link_hash_table_create.
Instead, set them in _bfd_x86_elf_link_setup_gnu_properties. We can
avoid adding elf64-x86-64.lo and elf64.lo together with elfxx-x86.lo to
bfd_backends.
* configure.ac (bfd_backends): Don't add elf64-x86-64.lo nor
elf64.lo together with elfxx-x86.lo for 64-bit BFD.
* configure: Regenerated.
* elf32-i386.c (elf_i386_link_setup_gnu_properties): Set r_info
and r_sym fields of plt_layout.
* elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties):
Likewise.
* elfxx-x86.c (elf_x86_64_is_reloc_section): Remove BFD64 check.
(_bfd_x86_elf_link_hash_table_create): Likewise. Don't set
r_info nor r_sym fields.
(_bfd_x86_elf_link_setup_gnu_properties): Set r_info and r_sym
fields of htab.
* elfxx-x86.h (elf_x86_plt_layout_table): Add r_info and r_sym.
GDB Administrator [Fri, 8 Sep 2017 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
Palmer Dabbelt [Fri, 16 Jun 2017 21:33:16 +0000 (14:33 -0700)]
RISC-V: Avoid emitting invalid instructions in mixed RVC/no-RVC code
When linking the following code
.global _prog_start
_prog_start:
mv x1, x1
mv x2, x2
.align 2
rvc_boundry:
.option norvc
.align 3
mv x3, x3
we currently emit an invalid two-byte 0 instruction. The actual output
code looks like
0000000080000000 <_prog_start>:
80000000: 8086 mv ra,ra
80000002: 810a mv sp,sp
0000000080000004 <rvc_boundry>:
80000004: 0000 unimp
80000006: 0001 nop
80000008:
00018193 mv gp,gp
This ends up manifesting due to the two-byte compressed NOP that's
pessimisticly emitted by the ".align 2", which results in "rvc_boundry"
being 2-byte aligned. frag_align_code() then goes and outputs a 2-byte
NOP (which is invalid in no-RVC mode) to align the code back to a 4-byte
boundry, which can't be relaxed away by the linker as it's not part of
the R_RISCV_RELAX relocation.
The fix is to just always emit the worst case possible alignment into
the output as a single R_RISCV_RELAX, which the linker will then fix up.
With this patch I get the expected code generation
0000000080000000 <_prog_start>:
80000000: 8086 mv ra,ra
80000002: 810a mv sp,sp
0000000080000004 <rvc_boundry>:
80000004:
00000013 nop
80000008:
00018193 mv gp,gp
gas/ChangeLog
2017-09-07 Palmer Dabbelt <palmer@dabbelt.com>
* config/tc-riscv.c (riscv_frag_align_code): Emit the entire
alignment sequence inside R_RISCV_ALIGN.
Palmer Dabbelt [Fri, 16 Jun 2017 21:19:55 +0000 (14:19 -0700)]
RISC-V: Print an error when unable to align a section
This used to just print "can't relax section: Success", which is a silly
error message.
bfd/ChangeLog
2017-09-07 Palmer Dabbelt <palmer@dabbelt.com>
* elfnn-riscv.c (_bfd_riscv_relax_align): Call bfd_set_error and
print an error message when unable to relax a .align directive.
Palmer Dabbelt [Wed, 16 Aug 2017 17:41:56 +0000 (10:41 -0700)]
RISC-V: Support PCREL_* relocations agaist weak undefined symbols
I recently modified our Linux port's base address such the absolute
address 0 is no longer addressable as a 32-bit PC-relative offset.
Since Linux links a weak undefined symbol in an intermediate binary, it
needs to be able to reference absolute address 0.
This patch changes R_RISCV_PCREL_* relocations to absolute relocations
while resolving them in order to allow these symbols to be referenced in
PC-relative programs linked at high addresses. Note that this doesn't
apply to PIC, which also uses PC-relative relocations, just to
position-dependent objects, which we use to allow programs to be linked
at high addresses.
In case some of our embedded users are using R_RISCV_PCREL_* as a hacked
up method of getting position-independent binaries (which can work if
you have very simple programs), we only convert the relocations when the
PC-relative version would overflow.
bfd/ChangeLog:
2017-09-07 Palmer Dabbelt <palmer@dabbelt.com>
* elfnn-riscv.c (riscv_zero_pcrel_hi_reloc): New function.
(riscv_record_pcrel_hi_reloc): Add absolute argument.
(riscv_elf_relocate_section): Call riscv_zero_pcrel_hi_reloc for
R_RISCV_PCREL_HI20 relocs, and pass the result to
riscv_record_pcrel_hi_reloc.
Joel Brobecker [Thu, 7 Sep 2017 14:40:10 +0000 (07:40 -0700)]
Document the GDB 8.0.1 release in gdb/ChangeLog
gdb/ChangeLog:
GDB 8.0.1 released.
Joel Brobecker [Thu, 7 Sep 2017 14:24:33 +0000 (07:24 -0700)]
remove QStartupWithShell entry from NEWS::Changes in GDB 7.11
This entry was added twice within the same commit, back in Dec 2017
by the following change:
commit
aefd8b33d97bded58e51d75271f99e1eaec9fb28
Date: Thu Dec 22 22:14:02 2016 -0500
Subject: Implement proper "startup-with-shell" support on gdbserver
I think the second entry is just a rebase/merge oversight, and it wasn't
meant to be added there, particularly since the 7.11 branch was no longer
active at that time anymore.
This patch just removes the entry.
gdb/ChangeLog:
* NEWS (Changes in GDB 7.11): Remove entry for QStartupWithShell.
H.J. Lu [Thu, 7 Sep 2017 11:03:15 +0000 (04:03 -0700)]
x86: Remove _bfd_{i386,x86_64}_elf_convert_load
Instead of converting GOT relocations when sizing dynamic sections, we
convert GOT relocations during relocation check. Add a field, local_ref,
to elf_x86_link_hash_entry to indicate if symbol references are always
local with a new function to check if symbol references are always local,
which works in check_relocs.
* elf32-i386.c (elf_i386_convert_load_reloc): Add an argument,
r_type_p. Remove the converted argument. Replace
SYMBOL_REFERENCES_LOCAL with SYMBOL_REFERENCES_LOCAL_P. Return
the new relocation type via r_type_p.
(elf_i386_relocate_section): Likewise.
(elf_i386_finish_dynamic_symbol): Likewise.
(need_convert_load): Removed.
(check_relocs_failed): Updated.
(elf_i386_check_relocs): Call elf_i386_convert_load_reloc,
instead of setting need_convert_load.
(_bfd_i386_elf_convert_load): Removed.
* elf64-x86-64.c (need_convert_load): Removed.
(check_relocs_failed): Updated.
(elf_x86_64_convert_load_reloc): Add an argument, r_type_p.
Replace SYMBOL_REFERENCES_LOCAL with SYMBOL_REFERENCES_LOCAL_P.
Return the new relocation type via r_type_p.
(elf_x86_64_check_relocs): Call elf_x86_64_convert_load_reloc,
instead of setting need_convert_load.
(elf_x86_64_check_relocs): Don't check PIC if relocation has
been converted.
(_bfd_x86_64_elf_convert_load): Removed.
(elf_x86_64_relocate_section): Replace SYMBOL_REFERENCES_LOCAL
with SYMBOL_REFERENCES_LOCAL_P.
(elf_x86_64_finish_dynamic_symbol): Likewise.
* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Don't
set convert_load.
(_bfd_x86_elf_size_dynamic_sections): Don't call convert_load.
(_bfd_x86_elf_link_symbol_references_local): New function.
* elfxx-x86.h (SYMBOL_REFERENCES_LOCAL_P): New.
(UNDEFINED_WEAK_RESOLVED_TO_ZERO): Replace elf.forced_local with
SYMBOL_REFERENCES_LOCAL_P.
(elf_x86_link_hash_entry): Add local_ref.
(elf_x86_link_hash_table): Remove convert_load.
(_bfd_i386_elf_convert_load): Removed.
(_bfd_x86_64_elf_convert_load): Likewise.
(_bfd_x86_elf_link_symbol_references_local): New.
GDB Administrator [Thu, 7 Sep 2017 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Mon, 4 Sep 2017 03:50:47 +0000 (21:50 -0600)]
Change funcall_chain to be a std::vector
This simplifies the handling of funcall_chain, by changing it to be a
std::vector<int> and then fixing the users. This allows the removal
of a cleanup.
It would be even cleaner to replace this with better logic in the
parsers; but a baby step seemed ok.
gdb/ChangeLog
2017-09-05 Tom Tromey <tom@tromey.com>
* parse.c (funcall_chain): Now a std::vector.
(start_arglist, end_arglist): Simplify.
(free_funcalls): Remove.
(parse_exp_in_context_1): Remove cleanup.
Tom Tromey [Sun, 13 Aug 2017 16:40:35 +0000 (10:40 -0600)]
Remove last cleanups from go-exp.y
This removes the last remaining cleanups from go-exp.y.
2017-09-05 Tom Tromey <tom@tromey.com>
* go-exp.y (go_parse): Don't create a cleanup.
Tom Tromey [Sun, 13 Aug 2017 16:38:53 +0000 (10:38 -0600)]
Remove last cleanups from d-exp.y
This removes the last remaining cleanups from d-exp.y.
2017-09-05 Tom Tromey <tom@tromey.com>
* d-exp.y (PrimaryExpression): Use std::string.
(d_parse): Don't create a cleanup.
Tom Tromey [Sun, 13 Aug 2017 16:37:13 +0000 (10:37 -0600)]
Remove make_cleanup_clear_parser_state
This removes make_cleanup_clear_parser_state in favor of
scoped_restore.
2017-09-05 Tom Tromey <tom@tromey.com>
* utils.c (do_clear_parser_state): Remove.
(make_cleanup_clear_parser_state): Remove.
* p-exp.y (pascal_parse): Use scoped_restore.
* m2-exp.y (m2_parse): Use scoped_restore.
* f-exp.y (f_parse): Use scoped_restore.
* d-exp.y (d_parse): Use scoped_restore.
* c-exp.y (c_parse): Use scoped_restore.
* ada-exp.y (ada_parse): Use scoped_restore.
* utils.h (make_cleanup_clear_parser_state): Remove.
Keith Seitz [Wed, 6 Sep 2017 19:50:52 +0000 (12:50 -0700)]
Introduce dw2_linkage_name and dw2_linkage_name_attr.
The DWARF reader is littered with the following idiom to read a linkage name
from the debug info:
mangled = dwarf2_string_attr (die, DW_AT_linkage_name, cu);
if (mangled == NULL)
mangled = dwarf2_string_attr (die, DW_AT_MIPS_linkage_name, cu);
This patch introduces functions to simplify this to:
mangled = dw2_linkage_name (die, cu);
or
attr = dw2_linkage_name_attr (die, cu);
gdb/ChangeLog:
* dwarf2read.c (dw2_linkage_name_attr): New function.
(dw2_linkage_name): New function.
(dwarf2_compute_name, dwarf2_physname, read_call_site_scope)
(guess_full_die_structure_name, dwarf2_name): Use dw2_linkage_name.
(anonymous_struct_prefix, dwarf2_name): Use dw2_linkage_name_attr.
John Baldwin [Wed, 6 Sep 2017 17:16:12 +0000 (10:16 -0700)]
Honor an existing CC_FOR_BUILD in the environment for sim.
This matches the equivalent bits in bfd/acinclude.m4
sim/ChangeLog:
* configure.ac: Honor existing CC_FOR_BUILD in environment.
* configure: Regenerate.
sim/aarch64/ChangeLog:
* configure: Regenerate.
sim/arm/ChangeLog:
* configure: Regenerate.
sim/avr/ChangeLog:
* configure: Regenerate.
sim/bfin/ChangeLog:
* configure: Regenerate.
sim/common/ChangeLog:
* acinclude.m4 (SIM_AC_COMMON) Honor existing CC_FOR_BUILD in
environment.
sim/cr16/ChangeLog:
* configure: Regenerate.
sim/cris/ChangeLog:
* configure: Regenerate.
sim/d10v/ChangeLog:
* configure: Regenerate.
sim/erc32/ChangeLog:
* configure: Regenerate.
sim/frv/ChangeLog:
* configure: Regenerate.
sim/ft32/ChangeLog:
* configure: Regenerate.
sim/h8300/ChangeLog:
* configure: Regenerate.
sim/iq2000/ChangeLog:
* configure: Regenerate.
sim/lm32/ChangeLog:
* configure: Regenerate.
sim/m32c/ChangeLog:
* configure: Regenerate.
sim/m32r/ChangeLog:
* configure: Regenerate.
sim/m68hc11/ChangeLog:
* configure: Regenerate.
sim/mcore/ChangeLog:
* configure: Regenerate.
sim/microblaze/ChangeLog:
* configure: Regenerate.
sim/mips/ChangeLog:
* configure: Regenerate.
sim/mn10300/ChangeLog:
* configure: Regenerate.
sim/moxie/ChangeLog:
* configure: Regenerate.
sim/msp430/ChangeLog:
* configure: Regenerate.
sim/rl78/ChangeLog:
* configure: Regenerate.
sim/rx/ChangeLog:
* configure: Regenerate.
sim/sh/ChangeLog:
* configure: Regenerate.
sim/sh64/ChangeLog:
* configure: Regenerate.
sim/v850/ChangeLog:
* configure: Regenerate.
Tom Tromey [Wed, 30 Aug 2017 22:12:56 +0000 (16:12 -0600)]
Cast char constant to int in sizeof.exp
PR gdb/22010 concerns a regression I introduced with the scalar
printing changes. The bug is that this code in sizeof.exp:
set signof_byte [get_integer_valueof "'\\377'" -1]
can incorrectly compute sizeof_byte. One underlying problem here is
that gdb's C parser doesn't treat a char constant as an int (this is
PR 19973).
However, it seems good to have an immediate fix for the regression.
The simplest is to cast to an int here.
testsuite/ChangeLog
2017-09-05 Tom Tromey <tom@tromey.com>
PR gdb/22010:
* gdb.base/sizeof.exp (check_valueof): Cast char constant to int.
Kamil Rytarowski [Wed, 6 Sep 2017 16:48:49 +0000 (18:48 +0200)]
Correct shell compatibility issue detected with pkgsrc.
String comparison of in a POSIX bourne shell must be done
with '=', not '=='. For example the NetBSD sh(1) does not
support it.
gdb/ChangeLog
2017-09-06 Kamil Rytarowski <n54@gmx.com>
* config/djgpp/djconfig.sh: Correct shell portability issue.
Thomas Preud'homme [Wed, 6 Sep 2017 16:54:26 +0000 (17:54 +0100)]
Fix calls in gdb.arch/thumb2-it.exp
Tests in gdb.arch/thumb2-it.exp call functions defined in assembly
without type debugging information. Since
7022349d5c86bae74b49225515f42d2e221bd368 ("Stop assuming no-debug-info
functions return int") this triggers an error which leads to many tests
to FAIL. This patch cast the call to indicate the return type of the
functions when calling them.
2017-09-06 Thomas Preud'homme <thomas.preudhomme@arm.com>
gdb/testsuite/
* gdb.arch/thumb2-it.exp: Cast call to assembly defined function.
Kamil Rytarowski [Wed, 6 Sep 2017 16:33:46 +0000 (18:33 +0200)]
Define HAVE_NATIVE_GCORE_HOST on NetBSD
NetBSD ships with gcore(1) againg since the version 2.0.
This tool is functional and actively maintained.
gdb/ChangeLog
2017-09-06 Kamil Rytarowski <n54@gmx.com>
* configure.nat: Define HAVE_NATIVE_GCORE_HOST on NetBSD.
John Baldwin [Thu, 10 Aug 2017 18:00:42 +0000 (11:00 -0700)]
Add native target for FreeBSD/aarch64.
gdb/ChangeLog:
* Makefile.in (ALLDEPFILES): Add mips-fbsd-nat.c.
* NEWS: Mention new FreeBSD/mips native configuration.
* configure.host: Add aarch64*-*-freebsd*.
* configure.nat: Likewise.
* aarch64-fbsd-nat.c: New file.
John Baldwin [Wed, 9 Aug 2017 06:25:42 +0000 (23:25 -0700)]
Add FreeBSD/aarch64 architecture.
Support for collecting and supplying general purpose and floating point
register sets is provided along with signal frame unwinding.
gdb/ChangeLog:
* Makefile.in (ALL_64_TARGET_OBS): Add aarch64-fbsd-tdep.o.
(ALLDEPFILES): Add aarch64-fbsd-tdep.c.
* NEWS: Mention new FreeBSD/aarch64 target.
* configure.tgt: Add aarch64*-*-freebsd*.
* aarch64-fbsd-tdep.c: New file.
* aarch64-fbsd-tdep.h: New file.
Kamil Rytarowski [Wed, 6 Sep 2017 15:57:39 +0000 (17:57 +0200)]
Add myself as a write-after-approval GDB maintainer.
gdb/ChangeLog:
2017-09-06 Kamil Rytarowski <n54@gmx.com>
* MAINTAINERS (Write After Approval): Add Kamil Rytarowski.
H.J. Lu [Wed, 6 Sep 2017 12:06:35 +0000 (05:06 -0700)]
x86-64: Add R_X86_64_converted_reloc_bit
Add R_X86_64_converted_reloc_bit to relocation type to indicate if a
relocation is converted from a GOTPCREL relocation. Linker now generates
failed to convert GOTPCREL relocation; relink with --no-relax
for all cases, including relocations against local symbols.
bfd/
* elf64-x86-64.c (R_X86_64_converted_reloc_bit): New.
(elf_x86_64_info_to_howto): Get the real relocation type by
masking out R_X86_64_converted_reloc_bit.
(elf_x86_64_check_tls_transition): Get the real relocation type
by masking out R_X86_64_converted_reloc_bit.
(elf_x86_64_convert_load_reloc): Set R_X86_64_converted_reloc_bit
instead of setting converted_reloc.
(elf_x86_64_relocate_section): Check R_X86_64_converted_reloc_bit
instead of converted_reloc. Get the real relocation type by
masking out R_X86_64_converted_reloc_bit.
(elf_x86_64_link_setup_gnu_properties): Verify that the value of
R_X86_64_converted_reloc_bit is valid.
* elfxx-x86.h (converted_reloc): Removed.
ld/
* testsuite/ld-x86-64/pr19609-2a.d: Updated.
* testsuite/ld-x86-64/pr19609-2b.d: Likewise.
* testsuite/ld-x86-64/pr19609-4a.d: Likewise.
* testsuite/ld-x86-64/pr19609-4c.d: Likewise.
H.J. Lu [Wed, 6 Sep 2017 11:49:47 +0000 (04:49 -0700)]
x86: Don't change r_type when performing TLS transitions
Don't change r_type when performing TLS transitions to avoid getting
the relocation type with ELF32_R_TYPE again.
* elf32-i386.c (elf_i386_relocate_section): Don't change r_type
when calling elf_i386_tls_transition. Don't use ELF32_R_TYPE
to get the relocation type again.
* elf64-x86-64.c (elf_x86_64_relocate_section): Don't change
r_type when calling elf_x86_64_tls_transition. Don't use
ELF32_R_TYPE to get the relocation type again.
Jan Kratochvil [Wed, 6 Sep 2017 11:32:46 +0000 (12:32 +0100)]
Fix accessing TLS variables with no debug info
Since
2273f0ac95a7 ("change minsyms not to be relocated at
read-time"), printing TLS symbols of objfiles with a non-zero base
address, without debug info, fails.
E.g., with:
$ mv /usr/lib/debug /usr/lib/debug-x
to get debug info out of the way, we get:
$ echo 'int main(){}' | gcc -pthread -x c -
$ ./gdb -q -ex start -ex 'p (int) errno' ./a.out
Cannot access memory at address 0xffffef7c0698
instead of the expected:
$1 = 0
The regression is not visible with glibc debuginfo installed.
The problem is that we compute the address of TLS minsyms incorrectly.
To trigger the problem, it is important that the variable is in an
objfile with a non-zero base address. While glibc is a shared library
for 'errno', it's easier for the testcase to use PIE instead of a
shlib. For TLS variables in PT_EXEC the regression obviously does not
happen.
gdb/ChangeLog
2017-09-06 Jan Kratochvil <jan.kratochvil@redhat.com>
* parse.c (find_minsym_type_and_address): Don't relocate addresses
of TLS symbols.
gdb/testsuite/ChangeLog
2017-09-06 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.threads/tls-nodebug-pie.c: New file.
* gdb.threads/tls-nodebug-pie.exp: New file.
GDB Administrator [Wed, 6 Sep 2017 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Tue, 5 Sep 2017 20:41:18 +0000 (13:41 -0700)]
x86-64: Properly set converted_reloc
Linker now generates
failed to convert GOTPCREL relocation; relink with --no-relax
for more cases.
bfd/
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Properly set
converted_reloc.
ld/
* testsuite/ld-x86-64/pr19609-5d.d: Updated.
* testsuite/ld-x86-64/pr19609-7a.d: Likewise.
* testsuite/ld-x86-64/pr19609-7c.d: Likewise.
Philippe Waroquiers [Tue, 5 Sep 2017 18:51:23 +0000 (20:51 +0200)]
Fix leak of auto_obstack objfile_per_bfd_storage->storage_obstack;
commit
23732b1e32dd58f7c731d9aee56ff0b22a645d53
Author: Pedro Alves <palves@redhat.com>
Date: Tue Jun 27 16:22:08 2017 +0100
changed objfile_per_bfd_storage->storage_obstack
from 'struct obstack storage_obstack;'
to 'auto_obstack storage_obstack;'
So the obstack is auto allocated when the objfile_per_bfd_storage ctor is
manually called by get_objfile_bfd_data).
However, the ctor call was still followed by a manual call to
obstack_init (&storage->storage_obstack);
This results in a bunch of leaks detected by valgrind, such as:
==24665== 4,064 bytes in 1 blocks are definitely lost in loss record 11,469 of 11,590
==24665== at 0x4C27BF5: malloc (vg_replace_malloc.c:299)
==24665== by 0x5437B7: xmalloc (common-utils.c:44)
==24665== by 0x77CAA7: _obstack_begin_worker (obstack.c:141)
==24665== by 0x60168F: auto_obstack (gdb_obstack.h:70)
==24665== by 0x60168F: get_objfile_bfd_data(objfile*, bfd*) (objfiles.h:188)
==24665== by 0x601DB6: allocate_objfile(bfd*, char const*, enum_flags<objfile_flag>) (objfiles.c:423)
==24665== by 0x647753: symbol_file_add_with_addrs(bfd*, char const*, enum_flags<symfile_add_flag>, section_addr_info*, enum_flags<objfile_flag>, objfile*) (symfile.c:1158)
==24665== by 0x647C7B: symbol_file_add_separate(bfd*, char const*, enum_flags<symfile_add_flag>, objfile*) (symfile.c:1252)
==24665== by 0x4C7D79: elf_symfile_read(objfile*, enum_flags<symfile_add_flag>) (elfread.c:1270)
==24665== by 0x647CB4: read_symbols(objfile*, enum_flags<symfile_add_flag>) (symfile.c:861)
==24665== by 0x647809: syms_from_objfile_1 (symfile.c:1062)
-> remove the manual call to obstack_init.
Reg-tested on Debian 8/amd64, tests results are the same before/after the patch.
valgrind still show some leaks, but less.
gdb/ChangeLog
2017-09-05 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* objfiles.c (get_objfile_bfd_data): Remove useless obstack_init
call.
H.J. Lu [Tue, 5 Sep 2017 18:24:01 +0000 (11:24 -0700)]
x86-64: Improve GOTPCREL relocation conversion
When GOTPCREL relocation conversion leads to relocation overflow, we
may get a mysterious linker message, like
relocation truncated to fit: R_X86_64_32S against symbol `foo'
This patch changes the linker message to
failed to convert GOTPCREL relocation; relink with --no-relax
bfd/
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Remove the sec
argument. Don't check relocation overflow. Avoid relocation
overflow if --no-relax is used. Set converted_reloc on symbol
if a GOTPCREL relocation is converted.
(elf_x86_64_relocate_section): Issue a fatal error and suggest
--no-relax if GOTPCREL relocation conversion leads to relocation
overflow.
* elfxx-x86.h (elf_x86_link_hash_entry): Add converted_reloc.
ld/
* testsuite/ld-x86-64/pr19609-4e.d: Updated.
* testsuite/ld-x86-64/pr19609-6a.d: Likewise.
Tom Tromey [Mon, 4 Sep 2017 05:15:03 +0000 (23:15 -0600)]
Don't use -fdiagnostics-color=never for rustc
I noticed that the gdb.rust tests fail because the test suite passes
-fdiagnostics-color=never to rustc. This is not a recognized rustc
option, and the test suite already handles passing the appropriate
option to the Rust compiler.
This patch fixes the problem.
testsuite/ChangeLog
2017-09-05 Tom Tromey <tom@tromey.com>
* lib/gdb.exp (gdb_compile): Don't use universal_compile_options
for rust.
Simon Marchi [Tue, 5 Sep 2017 15:40:44 +0000 (17:40 +0200)]
Test different follow-exec-mode settings in gdb.multi/multi-arch-exec.exp
Using follow-exec-mode "new" takes a different code path than "same", so
it's interesting to test this path in combination with a change in
architecture of the inferior. This test fails if you remove the
previous patch.
gdb/testsuite/ChangeLog:
* gdb.multi/multi-arch-exec.exp: Test with different
"follow-exec-mode" settings.
(do_test): New procedure.
Simon Marchi [Tue, 5 Sep 2017 15:30:27 +0000 (17:30 +0200)]
Add thread after updating gdbarch when exec'ing
As mentioned in the previous patch, we should avoid doing register reads
after a process does an exec and before we've updated that inferior's
gdbarch. Otherwise, we may interpret the registers using the wrong
architecture. When a process does an exec with "follow-exec-mode new",
a new inferior is added by follow_exec. The gdbarch of that new
inferior is at first set to some default value, probably specific to the
gdb build (I get "i386" here), which may not be the right one. It is
updated later by the call to target_find_description. Before that
point, if we try to read the inferior's registers, we may not interpret
them correctly. This has been exposed by a failure in
gdb.base/foll-exec-mode.exp after the previous patch, with:
Remote 'g' packet reply is too long (expected 312 bytes, got 816 bytes)
The call to "add_thread" done just after adding the inferior is
problematic, because it ends up reading the registers (because the ptid
is re-used, we end up doing a switch_to_thread to it, which tries to
update stop_pc). The registers returned by gdbserver are the x86-64
ones, while we try to interpret them using the "i386" gdbarch.
Postponing the call to add_thread to until the target
description/gdbarch has been updated seems to fix the issue.
As to why this issue was uncovered by the previous patch: what I think
happened before that patch is that since we were updating stop_pc before
switching to the new inferior, we were filling the regcache associated
to the ptid (this worked fine as long as the architectures of the
previous and new process images were the same). The call to
switch_to_thread then worked, because the register read hit the
regcache. Now, it triggers a register read, while the gdbarch is not
set correctly, leading to the "reply is too long" error. If this is
right, it sounds wrong that we delete and re-add a thread with the same
ptid, and are able to access the registers from the deleted thread.
When we delete a thread, should we clear the regcache associated to that
ptid, so that the new thread starts with a fresh/empty regcache?
gdb/ChangeLog:
* infrun.c (follow_exec): Call add_thread after
target_find_description.
Simon Marchi [Tue, 5 Sep 2017 14:45:10 +0000 (16:45 +0200)]
Read stop_pc after updating the gdbarch when exec'ing
When an inferior execs and changes architecture (e.g. 64 bits to 32
bits), the gdbarch associated to the inferior is updated by the
follow_exec call in handle_inferior_event_1. We should avoid doing any
register read before that point, because the registers sent by the
remote side will be those of the new architecture, but we would
interpret them using the old architecture. We do just that by setting
stop_pc during this window, which obviously requires reading the
registers. This results in gdb.multi/multi-arch-exec.exp failing, GDB
outputting the following error:
Truncated register 50 in remote 'g' packet
This patch fixes that by postponing the setting of stop_pc to after
we've updated the inferior gdbarch.
This bug was hiding another problem, and as such introduces some
failures in gdb.base/foll-exec-mode.exp. The following patch takes care
of that.
gdb/ChangeLog:
* infrun.c (handle_inferior_event_1): When exec'ing, read
stop_pc after follow_exec.
Simon Marchi [Tue, 5 Sep 2017 14:43:07 +0000 (16:43 +0200)]
Improve "'g' reply is is to long" error message
... by adding the expected size, and the received size. I found this
useful when debugging gdbarch/remote issues, since it gives a hint of
what gdb expects and what the remote sent.
gdb/ChangeLog:
* remote.c (process_g_packet): Update error message.
Yao Qi [Tue, 5 Sep 2017 13:46:47 +0000 (14:46 +0100)]
Add i386.o to gdb_target_obs for x86_64-* targets
This patch fixes the build failure caused by
22916b0
(Convert the rest x86 target descriptions).
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* configure.tgt (gdb_target_obs): Add i386.o for x86_64-*
targets.
Pedro Alves [Tue, 5 Sep 2017 11:13:57 +0000 (12:13 +0100)]
eval.c:evaluate_subexp_standard: Factor out function call handling
While working on the no-debug-info debugging improvements, I found
evaluate_subexp_standard's function call code unnecessarily long and
hard to navigate and debug. The use of goto doesn't help either.
This commit tries to improve things by factoring out the
function-call-related code to separate helper functions.
gdb/ChangeLog:
2017-09-05 Pedro Alves <palves@redhat.com>
* eval.c (eval_call, evaluate_funcall): New functions, factored
out from ...
(evaluate_subexp_standard): ... this.
Nick Clifton [Tue, 5 Sep 2017 11:09:14 +0000 (12:09 +0100)]
Fix a buffer overrun when parsing a corrupt MIPS ELF binary.
PR 21995
* readelf.c (process_mips_specific): Add checks for a NULL data
pointer.
Yao Qi [Tue, 5 Sep 2017 08:54:54 +0000 (09:54 +0100)]
Convert the rest x86 target descriptions
This patch changes the rest of x86 target descriptions in GDB and
GDBserver.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* amd64-tdep.c (amd64_target_description): Create target
descriptions.
(_initialize_amd64_tdep): Don't call functions
initialize_tdesc_amd64_*. Add self tests.
* arch/amd64.c (amd64_create_target_description): Add parameter
is_linux. Call set_tdesc_osabi if is_linux is true.
* arch/amd64.h (amd64_create_target_description): Update the
declaration.
* arch/i386.c (i386_create_target_description): Add parameter
is_linux. Call set_tdesc_osabi if is_linux is true.
* arch/i386.h (i386_create_target_description): Update
declaration.
* configure.tgt: Add i386.o to gdb_target_obs.
* features/Makefile (XMLTOC): Remove i386/*.xml.
* features/i386/amd64-avx-avx512.c: Remove.
* features/i386/amd64-avx-mpx-avx512-pku.c: Remove.
* features/i386/amd64-avx-mpx.c: Remove.
* features/i386/amd64-avx.c: Remove.
* features/i386/amd64-mpx.c: Remove.
* features/i386/amd64.c: Remove.
* features/i386/i386-avx-avx512.c: Remove.
* features/i386/i386-avx-mpx-avx512-pku.c: Remove.
* features/i386/i386-avx-mpx.c: Remove.
* features/i386/i386-avx.c: Remove.
* features/i386/i386-mmx.c: Remove.
* features/i386/i386-mpx.c: Remove.
* features/i386/i386.c: Remove.
* i386-tdep.c: Don't include features/i386/i386*.c., include
target-descriptions.h and arch/i386.h.
(i386_target_description): Create target descriptions.
(i386_gdbarch_init): Don't call initialize_tdesc_i386_*
functions. Do self tests.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* configure.srv (srv_i386_regobj): Remove.
(srv_amd64_regobj): Remove.
(srv_regobj): Set it to "" for x86 non-linux targets.
* linux-x86-tdesc.c (i386_linux_read_description):
* lynx-i386-low.c: Include x86-xstate.h and arch/i386.h.
(init_registers_i386): Remove the declaration.
(tdesc_i386): Remove the declaration.
(lynx_i386_arch_setup): Call i386_create_target_description.
* nto-x86-low.c: Likewise.
* win32-i386-low.c [__x86_64__]: include arch/amd64.h.
[!__x86_64__]: include arch/i386.h.
(i386_arch_setup) [__x86_64__]: Call amd64_create_target_description.
Yao Qi [Tue, 5 Sep 2017 08:54:54 +0000 (09:54 +0100)]
Remove features/i386/amd64-*linux.c and features/i386/x32-*linux.c
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* features/Makefile (XMLTOC): Remove i386/amd64XXX-linux.xml.
* features/i386/amd64-avx-avx512-linux.c: Removed.
* features/i386/amd64-avx-linux.c: Removed.
* features/i386/amd64-avx-mpx-avx512-pku-linux.c: Removed.
* features/i386/amd64-avx-mpx-linux.c: Removed.
* features/i386/amd64-linux.c: Removed.
* features/i386/amd64-mpx-linux.c: Removed.
* features/i386/x32-avx-avx512-linux.c: Removed.
* features/i386/x32-avx-linux.c: Removed.
* features/i386/x32-linux.c: Removed.
Yao Qi [Tue, 5 Sep 2017 08:54:54 +0000 (09:54 +0100)]
[GDBserver] Shorten srv_amd64_linux_xmlfiles
GDBserver now is able to generate target descriptions from features, so
don't need to remember these target description files.
Note that it should be i386/amd64-avx-avx512-linux.xml instead of
i386/amd64-avx-avx512.xml in $srv_amd64_linux_xmlfiles. This patch
removes it anyway.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* configure.srv (srv_amd64_linux_xmlfiles): Remove
i386/amd64-XXX-linux from it.
Yao Qi [Tue, 5 Sep 2017 08:54:54 +0000 (09:54 +0100)]
[GDBserver] Use pre-generated amd64-linux tdesc as test
Now, all these amd64-linux pre-generated tdesc can be used as test, so
don't need to build them if $development is false.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* configure.srv: Empty srv_amd64_linux_regobj if $development is
false.
(ipa_amd64_linux_regobj): Remove.
(ipa_x32_linux_regobj): Remove.
Yao Qi [Tue, 5 Sep 2017 08:54:54 +0000 (09:54 +0100)]
Convert amd64-linux target descriptions
This patch changes amd64-linux target descriptions so that they can be
dynamically generated in both GDB and GDBserver.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* Makefile.in (arch-amd64.o): New rule.
* configure.srv: Append arch-amd64.o.
* linux-amd64-ipa.c: Include common/x86-xstate.h.
(get_ipa_tdesc): Call amd64_linux_read_description.
(initialize_low_tracepoint): Don't call init_registers_x32_XXX
and init_registers_amd64_XXX.
* linux-x86-low.c (x86_linux_read_description): Call
amd64_linux_read_description.
(x86_get_ipa_tdesc_idx): Call amd64_get_ipa_tdesc_idx.
(initialize_low_arch): Don't call init_registers_x32_XXX and
init_registers_amd64_XXX.
* linux-x86-tdesc-selftest.c: Declare init_registers_amd64_XXX
and tdesc_amd64_XXX.
[__x86_64__] (amd64_tdesc_test): New function.
(initialize_low_tdesc) [__x86_64__]: Call init_registers_x32_XXX
and init_registers_amd64_XXX.
* linux-x86-tdesc.c: Include arch/amd64.h.
(xcr0_to_tdesc_idx): New function.
(i386_linux_read_description): New function.
(amd64_get_ipa_tdesc_idx): New function.
* linux-x86-tdesc.h (amd64_get_ipa_tdesc_idx): Declare.
(amd64_get_ipa_tdesc): Declare.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* amd64-linux-tdep.c: Include arch/amd64.h. Don't include
features/i386/*.c.
(amd64_linux_read_description): Call
amd64_create_target_description.
* arch/amd64.c: New file.
* arch/amd64.h: New file.
* configure.tgt (x86_64-*-linux*): Append amd64.o.
* Makefile.in (ALL_64_TARGET_OBS): Append amd64.o.
Yao Qi [Tue, 5 Sep 2017 08:54:54 +0000 (09:54 +0100)]
Lazily and dynamically create amd64-linux target descriptions
This patch starts to use the generate c feature files to dynamically
create amd64-linux target descriptions.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* amd64-linux-tdep.c: Don't include amd64-XXX-linux and
x32-XXX-linux.c. Include 64bit-XX.c and x32-XX.c.
(amd64_linux_read_description): Create target descriptions.
(_initialize_amd64_linux_tdep): Don't call initialize_tdesc_XXX
functions. Add unit tests.
* features/Makefile (FEATURE_XMLFILES): Append 64bit-XXX.xml and
x32-core.xml.
* features/i386/64bit-avx.c: Generated.
* features/i386/64bit-avx512.c: Generated.
* features/i386/64bit-core.c: Generated.
* features/i386/64bit-linux.c: Generated.
* features/i386/64bit-mpx.c: Generated.
* features/i386/64bit-pkeys.c: Generated.
* features/i386/64bit-segments.c: Generated.
* features/i386/64bit-sse.c: Generated.
* features/i386/x32-core.c: Generated.
* target-descriptions.c (maint_print_c_tdesc_cmd): Print feature
c files for amd64-linux and x32-linux.
Yao Qi [Tue, 5 Sep 2017 08:54:53 +0000 (09:54 +0100)]
Centralize amd64-linux target descriptions
This patch adds a new function amd64_linux_read_description, which
creates amd64-linux target descriptions according to its two
arguments, xcr0 and is_x32.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* amd64-linux-tdep.c (amd64_linux_read_description): New
function.
(amd64_linux_core_read_description): Call
amd64_linux_read_description.
(amd64_linux_init_abi): Likewise.
(amd64_x32_linux_init_abi): Likewise.
* amd64-linux-tdep.h (amd64_linux_read_description): Declare.
* x86-linux-nat.c (x86_linux_read_description): Call
amd64_linux_read_description.
Yao Qi [Tue, 5 Sep 2017 08:54:53 +0000 (09:54 +0100)]
Update comments in amd64_linux_core_read_description
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* amd64-linux-tdep.c (amd64_linux_core_read_description): Update
comments.
Yao Qi [Tue, 5 Sep 2017 08:54:53 +0000 (09:54 +0100)]
[GDBserver] Shorten srv_i386_linux_xmlfiles
GDBserver now is able to generate target descriptions from features, so
don't need to remember these target description files.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* configure.srv (srv_i386_linux_xmlfiles): Remove
i386/i386-XXX-linux.xml from it.
Yao Qi [Tue, 5 Sep 2017 08:54:53 +0000 (09:54 +0100)]
[GDBserver] Use pre-generated tdesc as test
Now, these *-generate.c files are only used in GDBserver for unit test.
If $development is false (in release), these *-generate.c files won't be
used at all.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* configure.srv: Set srv_i386_linux_regobj empty if $development
is false.
* linux-i386-ipa.c (initialize_low_tracepoint): Don't call
initialize_low_tdesc.
* linux-x86-low.c (initialize_low_arch): Wrap initialize_low_tdesc
with #if initialize_low_tdesc.
* linux-x86-tdesc-selftest.c: New file.
* linux-x86-tdesc.c: Move code to linux-x86-tdesc-selftest.c.
Yao Qi [Tue, 5 Sep 2017 08:54:53 +0000 (09:54 +0100)]
Remove features/i386/i386-*linux.c
Now, features/i386/i386-XXX-linux.c are not used, remove them.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* features/Makefile (XMLTOC): Remove i386/i386-XX-linux.xml.
* features/i386/i386-avx-avx512-linux.c: Remove.
* features/i386/i386-avx-linux.c: Remove.
* features/i386/i386-avx-mpx-avx512-pku-linux.c: Remove.
* features/i386/i386-avx-mpx-linux.c: Remove.
* features/i386/i386-linux.c: Remove.
* features/i386/i386-mmx-linux.c: Remove.
* features/i386/i386-mpx-linux.c: Remove.
Yao Qi [Tue, 5 Sep 2017 08:54:53 +0000 (09:54 +0100)]
Share i386-linux target description between GDB and GDBserver
The code on creating i386-linux target descriptions are quite similar
between GDB and GDBserver, so this patch moves them into a shared file
arch/i386.c. I didn't name it as i386-linux.c, because I want to reuse it
to create other i386 non-linux target descriptions later.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* Makefile.in (ALL_TARGET_OBS): Add i386.o.
(SFILES): Add arch/i386.c.
(HFILES_NO_SRCDIR): Add arch/i386.h.
* arch/i386.c: New file.
* arch/i386.h: New file.
* arch/tdesc.h (allocate_target_description): Declare.
(set_tdesc_architecture): Declare.
(set_tdesc_osabi): Declare.
* configure.tgt (i[34567]86-*-linux*): Add i386.o.
* i386-linux-tdep.c: Don't include ../features/i386/32bit-XXX.c.
include arch/i386.h.
(i386_linux_read_description): Remove code and call
i386_create_target_description.
(set_tdesc_architecture): New function.
(set_tdesc_osabi): New function.
* target-descriptions.h (allocate_target_description): Remove.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* Makefile.in (arch-i386.o): New rule.
* configure.srv (i[34567]86-*-linux*): Add arch-i386.o.
(x86_64-*-linux*): Likewise.
* linux-x86-tdesc.c: Don't include ../features/i386/32bit-XXX.c,
include arch/i386.h.
(i386_linux_read_description): Remove code and call
i386_create_target_description.
* tdesc.c (allocate_target_description): New function.
* tdesc.h (set_tdesc_architecture): Remove declaration.
(set_tdesc_osabi): Likewise.
Yao Qi [Tue, 5 Sep 2017 08:54:53 +0000 (09:54 +0100)]
Dynamically composite xml in reply to GDB
GDBserver still uses pre-generated target descriptions in order to
reply to GDB's query on target description (see xml-builtin-generated.c
in GDBserver build directory). This patch teaches GDBserver to
create XML contents according to the target descriptions rather than
using pre-generated ones.
First, change target feature c files to pass the feature xml file
name to tdesc_create_feature, so that target description in GDBserver
can record them, and create XML contents from these features in
buffer, like
...
<xi:include href="$FEATURE1_XML_NAME"/>
<xi:include href="$FEATURE2_XML_NAME"/>
...
and send this buffer back to GDB.
Note that this patch reuses target_desc.xmltarget a little bit, which is
to hold the XML contents dynamically generated in tdesc_get_features_xml.
However, it is not xfree'ed in ~target_desc, because we can't tell it is
from xstrdup or a literal string. Since we don't delete target_desc,
there is no memory leak yet. After we change all target descriptions to
the new style, target_desc.xmltarget is from xstrdup, then, we can safely
xfree it in ~target_desc.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* arch/tdesc.h (tdesc_create_feature): Add an argument xml.
* target-descriptions.c (tdesc_create_feature): Likewise, and
adjust code.
* features/i386/32bit-avx.c: Re-generated.
* features/i386/32bit-avx512.c: Re-generated.
* features/i386/32bit-core.c: Re-generated.
* features/i386/32bit-linux.c: Re-generated.
* features/i386/32bit-mpx.c: Re-generated.
* features/i386/32bit-pkeys.c: Re-generated.
* features/i386/32bit-sse.c: Re-generated.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* linux-x86-tdesc.c: Don't include <inttypes.h>.
(i386_linux_read_description) [!IN_PROCESS_AGENT]: Call
set_tdesc_architecture and set_tdesc_osabi. Remove code setting
.xmltarget.
* server.c (get_features_xml): Call tdesc_get_features_xml.
* tdesc.c (set_tdesc_architecture): New function.
(set_tdesc_osabi): New function.
(tdesc_get_features_xml): New function.
(tdesc_create_feature): Add an argument.
* tdesc.h (struct target_desc) <features>: New field.
<arch, osabi>: New field.
(~target_desc): xfree features, arch, and osabi.
(target_desc::oerator==): Don't compare .xmltarget.
[!IN_PROCESS_AGENT] (set_tdesc_architecture): Declare.
(set_tdesc_osabi): Likewise.
(tdesc_get_features_xml): Likewise.
Yao Qi [Tue, 5 Sep 2017 08:54:53 +0000 (09:54 +0100)]
[GDBserver] unit test to i386_tdesc
This patch adds a unit test in GDBserver to test dynamically created
target descriptions equal these pre-generated ones.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* linux-x86-tdesc.c: Include selftest.h.
(i386_tdesc_test): New function.
(initialize_low_tdesc): Call selftests::register_test.
* tdesc.h: Include regdef.h.
(target_desc): Override operator == and !=.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* regformats/regdef.h (struct reg): Override operator == and !=.
Yao Qi [Tue, 5 Sep 2017 08:54:53 +0000 (09:54 +0100)]
[GDBserver] Centralize tdesc for i386-linux
tdesc_i386_XXX_linux is used in many places in linux-x86-low.c and this
patch adds a new function i386_linux_read_description to return the right
tdesc according to xcr0. i386_linux_read_description is quite similar to
the counterpart in GDB, and the following patch will share the duplicated
code, so this patch adds arch/tdesc.h includes the declarations of various
tdesc apis which are used by the shared code. The generated c feature
files can include arch/tdesc.h only.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* configure.srv (srv_tgtobj): Append linux-x86-tdesc.o.
(ipa_obj): Likewise.
* linux-i386-ipa.c: Include common/x86-xstate.h
(get_ipa_tdesc): Call i386_linux_read_description.
(initialize_low_tracepoint): Don't call init_registers_XXX
functions, call initialize_low_tdesc instead.
* linux-x86-low.c (x86_linux_read_description): Call
i386_linux_read_description.
(initialize_low_arch): Don't call init_registers_i386_XXX
functions, call initialize_low_tdesc.
* linux-x86-tdesc.c: New file.
* linux-x86-tdesc.h (x86_linux_tdesc): New X86_TDESC_LAST.
(i386_get_ipa_tdesc_idx): Declare.
(i386_get_ipa_tdesc): Declare.
(initialize_low_tdesc): Declare.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* arch/tdesc.h: New file.
* regformats/regdat.sh: Generate code using tdesc_create_reg.
* target-descriptions.c: Update comments.
* target-descriptions.h: Include "arch/tdesc.h". Remove the
declarations.
* features/i386/32bit-avx.c: Re-generated.
* features/i386/32bit-avx512.c: Re-generated.
* features/i386/32bit-core.c: Re-generated.
* features/i386/32bit-linux.c: Re-generated.
* features/i386/32bit-mpx.c: Re-generated.
* features/i386/32bit-pkeys.c: Re-generated.
* features/i386/32bit-sse.c: Re-generated.
Yao Qi [Tue, 5 Sep 2017 08:54:52 +0000 (09:54 +0100)]
Return X86_TDESC_MMX in x86_get_ipa_tdesc_idx
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* linux-x86-low.c (x86_get_ipa_tdesc_idx): Use X86_TDESC_MMX
instead of 0.
Yao Qi [Tue, 5 Sep 2017 08:54:52 +0000 (09:54 +0100)]
Use VEC for target_desc.reg_defs
Nowadays, target_desc.reg_defs is a pointer points to a pre-generated
array, which is not flexible. This patch changes it from an array
to a VEC so that GDBserver can create target descriptions dynamically
later. Instead of using pre-generated array, the -generated.c calls
VEC_safe_push to add each register to vector.
Since target_desc.reg_defs is used in IPA, we need to build common/vec.c
for IPA too.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* Makefile.in (IPA_OBJS): Add vec-ipa.o
* regcache.c (get_thread_regcache): Use VEC_length.
(init_register_cache): Likewise.
(regcache_cpy): Likewise.
(registers_to_string): Iterate reg_defs via VEC_iterate.
(find_regno): Likewise.
(find_register_by_number): Use VEC_index.
(register_size): Call find_register_by_number.
(register_data): Call find_register_by_number.
(supply_regblock): Use VEC_length.
(regcache_raw_read_unsigned): Likewise.
* tdesc.c (init_target_desc): Iterate reg_defs via
VEC_iterate.
(default_description): Update initializer.
(copy_target_description): Don't update field num_registers.
* tdesc.h (struct target_desc) <reg_defs>: Change it to VEC.
<num_registers>: Remove.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* regformats/regdat.sh: Update generated code.
Yao Qi [Tue, 5 Sep 2017 08:54:52 +0000 (09:54 +0100)]
Adjust code generated by regformats/regdat.sh
regformats/regdat.sh generate some *-generated.c files when GDBserver
is built. Each .c file has some static variables, which are only used
within function init_registers_XXX, like this,
static struct reg regs_i386_linux[] = {
{ "eax", 0, 32 },
{ "ecx", 32, 32 },
...
};
static const char *expedite_regs_i386_linux[] = { "ebp", "esp", "eip", 0 };
static const char *xmltarget_i386_linux = "i386-linux.xml";
void
init_registers_i386_linux (void)
{
...
}
This patch moves these static variables' definitions to function
init_registers_XXX, so the generated files look like this,
void
init_registers_i386_linux (void)
{
static struct target_desc tdesc_i386_linux_s;
struct target_desc *result = &tdesc_i386_linux_s;
static struct reg regs_i386_linux[] = {
...
};
static const char *expedite_regs_i386_linux[] = { "ebp", "esp", "eip", 0 };
static const char *xmltarget_i386_linux = "i386-linux.xml";
...
}
We want GDBserver create target descriptions dynamically in each
init_registers_XXXX functions, so this patch moves all the related code
into function init_registers_XXXX, so that the following patch can easily
change function init_registers_XXXX to create target description
dynamically, rather than using current pre-generated array.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* regformats/regdat.sh: Adjust code order.
Simon Marchi [Tue, 5 Sep 2017 07:00:42 +0000 (09:00 +0200)]
expprint: Fix format string warning
My compiler (gcc 5.4.0, clang 3.8) gives this warning:
/home/emaisin/src/binutils-gdb/gdb/expprint.c: In lambda function:
/home/emaisin/src/binutils-gdb/gdb/expprint.c:1055:35: error: format not a string literal and no format arguments [-Werror=format-security]
fprintf_filtered (stream, mod);
^
Fix it by not using the passed string as the format string.
gdb/ChangeLog:
* expprint.c (dump_subexp_body_standard): Use constant format
string in fprintf_filtered call.
John Baldwin [Tue, 5 Sep 2017 02:53:50 +0000 (19:53 -0700)]
Define an error function in the PPC simulator library.
Previously this used the error function from GDB directly when linked
against GDB instead of the error method in the host callbacks
structure. This was exposed via a link error when GDB was converted
to C++. The error function invokes the error callback similar to
sim_io_error.
Note that there are also error functions in sim/ppc/main.c and
sim/ppc/misc.c. The ppc libsim.a expects each consumer to provide
several symbols used by the library including "error". sim-calls.c
provides these symbols when the library is linked into gdb. The dgen,
igen, tmp-filter, tmp-ld-decode, tmp-ld-cache, and tmp-ld-insn programs
use the functions from misc.c. psim uses the functions from main.c.
sim/ppc/ChangeLog:
PR sim/20863
* sim_calls.c (error): New function.
John Baldwin [Tue, 5 Sep 2017 02:34:48 +0000 (19:34 -0700)]
Enable support for x86 debug registers on NetBSD.
NetBSD recently added PT_GETDBREGS and PT_SETDBREGS ptrace operations
that match the existing ones supported by x86-bsd-nat.c. NetBSD's
headers do not provide the DBREG_DRX helper macro, so define a local
version in x86-bsd-nat.c. In addition, add the x86-nat.o and x86-dregs.o
object files to the native NetBSD x86 build targets.
gdb/ChangeLog:
* configure.nat: Add "x86-nat.o x86-dregs.o" for NetBSD/amd64 and
NetBSD/i386.
* x86-bsd-nat.c [!DBREG_DRX && __NetBSD__]: Define DBREG_DRX.
John Baldwin [Tue, 5 Sep 2017 02:34:48 +0000 (19:34 -0700)]
Make <sys/user.h> include in bsd-kvm.c conditional on HAVE_SYS_USER_H.
NetBSD has recently removed <sys/user.h>.
gdb/ChangeLog:
* bsd-kvm.c: Make <sys/user.h> conditional on HAVE_SYS_USER_H.
John Baldwin [Tue, 5 Sep 2017 02:34:48 +0000 (19:34 -0700)]
Define _KMEMUSER before including BSD kernel headers.
Recent versions of NetBSD hide certain kernel structures needed by the
KVM target from userland unless this macro is defined.
gdb/ChangeLog:
* bsd-kvm.o: Define _KMEMUSER.
* configure.ac: Define _KMEMUSER when checking for "struct lwp".
* configure: Regenerate.
John Baldwin [Tue, 5 Sep 2017 02:31:33 +0000 (19:31 -0700)]
Include "x86-xstate.h" for X86_XSTATE_* constants.
gdb/ChangeLog:
* amd64-fbsd-nat.c: Add include of "x86-xstate.h".
* i386-fbsd-nat.c: Likewise.
GDB Administrator [Tue, 5 Sep 2017 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Alexander Fedotov-B55613 [Mon, 4 Sep 2017 22:52:17 +0000 (08:22 +0930)]
Missing relocation R_PPC_VLE_ADDR20 and add VLE flag to details in readelf
include/
* elf/ppc.h (R_PPC_VLE_ADDR20): New relocation.
bfd/
* elf32-ppc.c (ppc_elf_howto_raw): Add R_PPC_VLE_ADDR20.
(ppc_elf_check_relocs): Handle it.
(ppc_elf_vle_split20): New function.
(ppc_elf_relocate_section): Handle R_PPC_VLE_ADDR20.
binutils/
* readelf.c (get_elf_section_flags): Add VLE.
(process_section_headers): Add VLE key to details.
gas/
* config/tc-ppc.c (md_parse_option): Handle "mno-vle" flag.
(ppc_elf_section_letter): New function.
* config/tc-ppc.h (md_elf_section_letter): New.
* testsuite/gas/elf/section10.d: Adjust for VLE.
John Baldwin [Mon, 4 Sep 2017 22:58:38 +0000 (15:58 -0700)]
Explicitly include <array> for std::array<>.
gdb/ChangeLog:
* unittests/array-view-selftests.c: Add include of <array>.
John Baldwin [Mon, 4 Sep 2017 22:57:02 +0000 (15:57 -0700)]
Catch up to recent changes to call_function_by_hand().
gdb/ChangeLog:
* spu-tdep.c (flush_ea_cache): Add missing argument to
call_function_by_hand.
Pedro Alves [Mon, 4 Sep 2017 19:21:16 +0000 (20:21 +0100)]
Document "no debug info debugging" improvements
Here's the documentation bits for all the improvements done in
previous commits.
Note that the original "weak alias functions" paragraph ends up
disappearing, because this patch, which I'm considering kind of part
of this series, makes the alias case Just Work:
https://sourceware.org/ml/gdb-patches/2017-07/msg00018.html
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* NEWS (Safer support for debugging with no debug info): New.
gdb/doc/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Variables) <Program Variables>: Document inspecting
no-debug-info variables.
(Symbols) <Examining the Symbol Table>: Document inspecting
no-debug-info types.
(Calling) <Calling functions with no debug info>: New subsection,
documenting calling no-debug-info functions.
(Non-debug DLL Symbols) <Working with Minimal Symbols>: Update.
Pedro Alves [Mon, 4 Sep 2017 19:21:16 +0000 (20:21 +0100)]
Make "p S::method() const::static_var" work too
Trying to print a function local static variable of a const-qualified
method still doesn't work after the previous fixes:
(gdb) p 'S::method() const'::static_var
$1 = {i1 = 1, i2 = 2, i3 = 3}
(gdb) p S::method() const::static_var
No symbol "static_var" in specified context.
The reason is that the expression parser/evaluator loses the "const",
and the above unquoted case is just like trying to print a variable of
the non-const overload, if it exists, even. As if the above unquoted
case had been written as:
(gdb) p S::method()::static_var
No symbol "static_var" in specified context.
We can see the problem without static vars in the picture. With:
struct S
{
void method ();
void method () const;
};
Compare:
(gdb) print 'S::method(void) const'
$1 = {void (const S * const)} 0x400606 <S::method() const>
(gdb) print S::method(void) const
$2 = {void (S * const)} 0x4005d8 <S::method()> # wrong method!
That's what we need to fix. If we fix that, the function local static
case starts working.
The grammar production for function/method types is this one:
exp: exp '(' parameter_typelist ')' const_or_volatile
This results in a TYPE_INSTANCE expression evaluator operator. For
the example above, we get something like this ("set debug expression 1"):
...
0 TYPE_INSTANCE 1 TypeInstance: Type @0x560fda958be0 (void)
5 OP_SCOPE Type @0x560fdaa544d8 (S) Field name: `method'
...
While evaluating TYPE_INSTANCE, we end up in
value_struct_elt_for_reference, trying to find the method named
"method" that has the prototype recorded in TYPE_INSTANCE. In this
case, TYPE_INSTANCE says that we're looking for a method that has
"(void)" as parameters (that's what "1 TypeInstance: Type
@0x560fda958be0 (void)" above means. The trouble is that nowhere in
this mechanism do we communicate to value_struct_elt_for_reference
that we're looking for the _const_ overload.
value_struct_elt_for_reference only compared parameters, and the
non-const "method()" overload has matching parameters, so it's
considered the right match...
Conveniently, the "const_or_volatile" production in the grammar
already records "const" and "volatile" info in the type stack. The
type stack is not used in this code path, but we can borrow the
information. The patch converts the info in the type stack to an
"instance flags" enum, and adds that as another element in
TYPE_INSTANCE operators. This type instance flags is then applied to
the temporary type that is passed to value_struct_elt_for_reference
for matching.
The other side of the problem is that methods in the debug info aren't
marked const/volatile, so with that in place, the matching never finds
const/volatile-qualified methods.
The problem is that in the DWARF, there's no indication at all whether
a method is const/volatile qualified... For example (c++filt applied
to the linkage name for convenience):
<2><d3>: Abbrev Number: 6 (DW_TAG_subprogram)
<d4> DW_AT_external : 1
<d4> DW_AT_name : (indirect string, offset: 0x3df): method
<d8> DW_AT_decl_file : 1
<d9> DW_AT_decl_line : 58
<da> DW_AT_linkage_name: (indirect string, offset: 0x5b2): S::method() const
<de> DW_AT_declaration : 1
<de> DW_AT_object_pointer: <0xe6>
<e2> DW_AT_sibling : <0xec>
I see the same with both GCC and Clang. The patch works around this
by extracting the cv qualification from the "const" and "volatile" in
the demangled name. This will need further tweaking for "&" and
"const &" overloads, but we don't support them in the parser yet,
anyway.
The TYPE_CONST changes were necessary otherwise the comparisons in valops.c:
if (TYPE_CONST (intype) != TYPE_FN_FIELD_CONST (f, j))
continue;
would fail, because when both TYPE_CONST() TYPE_FN_FIELD_CONST() were
true, their values were different.
BTW, I'm recording the const/volatile-ness of methods in the
TYPE_FN_FIELD info because #1 - I'm not sure it's kosher to change the
method's type directly (vs having to call make_cv_type to create a new
type), and #2 it's what stabsread.c does:
...
case 'A': /* Normal functions. */
new_sublist->fn_field.is_const = 0;
new_sublist->fn_field.is_volatile = 0;
(*pp)++;
break;
case 'B': /* `const' member functions. */
new_sublist->fn_field.is_const = 1;
new_sublist->fn_field.is_volatile = 0;
...
After all this, this finally all works:
print S::method(void) const
$1 = {void (const S * const)} 0x400606 <S::method() const>
(gdb) p S::method() const::static_var
$2 = {i1 = 1, i2 = 2, i3 = 3}
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* c-exp.y (function_method, function_method_void): Add current
instance flags to TYPE_INSTANCE.
* dwarf2read.c (check_modifier): New.
(compute_delayed_physnames): Assert that only C++ adds delayed
physnames. Mark fn_fields as const/volatile depending on
physname.
* eval.c (make_params): New type_instance_flags parameter. Use
it as the new type's instance flags.
(evaluate_subexp_standard) <TYPE_INSTANCE>: Extract the instance
flags element and pass it to make_params.
* expprint.c (print_subexp_standard) <TYPE_INSTANCE>: Handle
instance flags element.
(dump_subexp_body_standard) <TYPE_INSTANCE>: Likewise.
* gdbtypes.h: Include "enum-flags.h".
(type_instance_flags): New enum-flags type.
(TYPE_CONST, TYPE_VOLATILE, TYPE_RESTRICT, TYPE_ATOMIC)
(TYPE_CODE_SPACE, TYPE_DATA_SPACE): Return boolean.
* parse.c (operator_length_standard) <TYPE_INSTANCE>: Adjust.
(follow_type_instance_flags): New function.
(operator_check_standard) <TYPE_INSTANCE>: Adjust.
* parser-defs.h (follow_type_instance_flags): Declare.
* valops.c (value_struct_elt_for_reference): const/volatile must
match too.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.base/func-static.c (S::method const, S::method volatile)
(S::method volatile const): New methods.
(c_s, v_s, cv_s): New instances.
(main): Call method() on them.
* gdb.base/func-static.exp (syntax_re, cannot_resolve_re): New variables.
(cannot_resolve): New procedure.
(cxx_scopes_list): Test cv methods. Add print-scope-quote and
print-quote-unquoted columns.
(do_test): Test printing each scope too.
Pedro Alves [Mon, 4 Sep 2017 19:21:16 +0000 (20:21 +0100)]
Handle "p 'S::method()::static_var'" (quoted) in symbol lookup
While the previous commit made "p method()::static_var" (no
single-quotes) Just Work, if users (or frontends) try wrapping the
expression with quotes, they'll get:
(gdb) p 'S::method()::static_var'
'S::method()::static_var' has unknown type; cast it to its declared type
even if we _do_ have debug info for that variable. That's better than
the bogus/confusing value what GDB would print before the
stop-assuming-int patch:
(gdb) p 'S::method()::static_var'
$1 = 1
but I think it'd still be nice to make this case Just Work too.
In this case, due to the quoting, the C/C++ parser (c-exp.y)
interprets the whole expression/string as a single symbol name, and we
end up calling lookup_symbol on that name. There's no debug symbol
with that fully-qualified name, but since the compiler gives the
static variable a mangled linkage name exactly like the above, it
appears in the mininal symbols:
$ nm -A local-static | c++filt | grep static_var
local-static:
0000000000601040 d S::method()::static_var
... and that's what GDB happens to find/print. This only happens in
C++, note, since for C the compiler uses different linkage names:
local-static-c:
0000000000601040 d static_var.1848
So while (in C++, not C) function local static variables are given a
mangled name that demangles to the same syntax that GDB
documents/expects as the way to access function local statics, there's
no global symbol in the debug info with that name at all. The debug
info for a static local variable for a non-inline function looks like
this:
<1><2a1>: Abbrev Number: 19 (DW_TAG_subprogram)
...
<2><2f7>: Abbrev Number: 20 (DW_TAG_variable)
<2f8> DW_AT_name : (indirect string, offset: 0x4e9): static_var
<2fc> DW_AT_decl_file : 1
<2fd> DW_AT_decl_line : 64
<2fe> DW_AT_type : <0x25>
<302> DW_AT_location : 9 byte block: 3 40 10 60 0 0 0 0 0 (DW_OP_addr: 601040)
and for an inline function, it looks like this (linkage name run
through c++filt for convenience):
<2><21b>: Abbrev Number: 16 (DW_TAG_variable)
<21c> DW_AT_name : (indirect string, offset: 0x21a): static_var
<220> DW_AT_decl_file : 1
<221> DW_AT_decl_line : 48
<222> DW_AT_linkage_name: (indirect string, offset: 0x200): S::inline_method()::static_var
<226> DW_AT_type : <0x25>
<22a> DW_AT_external : 1
<22a> DW_AT_location : 9 byte block: 3 a0 10 60 0 0 0 0 0 (DW_OP_addr: 6010a0)
(The inline case makes the variable external so that the linker can
merge the different inlined copies. It seems like GCC never outputs
the linkage name for non-extern globals.)
When we read the DWARF, we record the static_var variable as a regular
variable of the containing function's block. This makes stopping in
the function and printing the variable as usual. The variable just so
happens to have a memory address as location.
So one way to make "p 'S::method()::static_var'" work would be to
record _two_ copies of the symbols for these variables. One in the
function's scope/block, with "static_var" as name, as we currently do,
and another in the static or global blocks (depending on whether the
symbol is external), with a fully-qualified name. I wrote a prototype
patch for that, and it works. For the non-inline case above, since
the debug info doesn't point to the linkage same, that patch built the
physname of the static local variable as the concat of the physname of
the containing function, plus "::", plus the variable's name. We
could make that approach work for C too, though it kind of feels
awkward to record fake symbol names like that in C.
The other approach I tried is to change the C++ symbol lookup routines
instead. This is the approach this commit takes. We can already
lookup up symbol in namespaces and classes, so this feels like a good
fit, and was easy enough. The advantage is that this doesn't require
recording extra symbols.
The test in gdb.cp/m-static.exp that exposed the need for this is
removed, since the same functionality is now covered by
gdb.cp/local-static.exp.
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* cp-namespace.c (cp_search_static_and_baseclasses): Handle
function/method scopes; lookup the nested name as a function local
static variable.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.base/local-static.exp: Also test with
class::method::variable wholly quoted.
* gdb.cp/m-static.exp (class::method::variable): Remove test.
Pedro Alves [Mon, 4 Sep 2017 19:21:15 +0000 (20:21 +0100)]
Handle "p S::method()::static_var" in the C++ parser
This commit makes "print S::method()::static_var" actually find the
debug symbol for static_var. Currently, you get:
(gdb) print S::method()::static_var
A syntax error in expression, near `'.
Quoting the whole string would seemingly work before the previous
patch that made GDB stop assuming int for no-debug-info variables:
(gdb) p 'S::method()::static_var'
$1 = 1
... except that's incorrect output, because:
(gdb) ptype 'S::method()::static_var'
type = <data variable, no debug info>
The way to make it work correctly currently is by quoting the
function/method part, like this:
(gdb) print 'S::method()'::static_var
$1 = {i1 = 1, i2 = 2, i3 = 3}
(gdb) ptype 'S::method()'::static_var
type = struct aggregate {
int i1;
int i2;
int i3;
}
At least after the "stop assuming int" patch, this is what we
now get:
(gdb) p 'S::method()::static_var'
'S::method()::static_var' has unknown type; cast it to its declared type
(gdb) p (struct aggregate) 'S::method()::static_var'
$1 = {i1 = 1, i2 = 2, i3 = 3}
However, IMO, users shouldn't really have to care about any of this.
GDB should Just Work, without quoting, IMO.
So here's a patch that implements support for that in the C++ parser.
With this patch, you now get:
(gdb) p S::method()::S_M_s_var_aggregate
$1 = {i1 = 1, i2 = 2, i3 = 3}
(gdb) ptype S::method()::S_M_s_var_aggregate
type = struct aggregate {
int i1;
int i2;
int i3;
}
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
(%type <voidval>): Add function_method.
* c-exp.y (exp): New production for calls with no arguments.
(function_method, function_method_void_or_typelist): New
productions.
(exp): New production for "method()::static_var".
* eval.c (evaluate_subexp_standard): Handle OP_FUNC_STATIC_VAR.
* expprint.c (print_subexp_standard, dump_subexp_body_standard):
Handle OP_FUNC_STATIC_VAR.
* parse.c (operator_length_standard):
Handle OP_FUNC_STATIC_VAR.
* std-operator.def (OP_FUNC_STATIC_VAR): New.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.base/local-static.c: New.
* gdb.base/local-static.cc: New.
* gdb.base/local-static.exp: New.
Pedro Alves [Mon, 4 Sep 2017 19:21:15 +0000 (20:21 +0100)]
Eliminate UNOP_MEMVAL_TLS
Since minsym references now go via OP_VAR_MSYM_VALUE, UNOP_MEMVAL_TLS
is no longer used anywhere.
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard): Remove UNOP_MEMVAL_TLS
handling.
* expprint.c (print_subexp_standard, dump_subexp_body_standard):
Ditto.
* parse.c (operator_length_standard, operator_check_standard):
Ditto.
* std-operator.def (UNOP_MEMVAL_TLS): Delete.
Pedro Alves [Mon, 4 Sep 2017 19:21:15 +0000 (20:21 +0100)]
Stop assuming no-debug-info variables have type int
An earlier commit made GDB no longer assume no-debug-info functions
return int. This commit gives the same treatment to variables.
Currently, you can end misled by GDB over output like this:
(gdb) p var
$1 = -1
(gdb) p /x var
$2 = 0xffffffff
until you realize that GDB is assuming that the variable is an "int",
because:
(gdb) ptype var
type = <data variable, no debug info>
You may try to fix it by casting, but that doesn't really help:
(gdb) p /x (unsigned long long) var
$3 = 0xffffffffffffffff # incorrect
^^
That's incorrect output, because the variable was defined like this:
uint64_t var = 0x7fffffffffffffff;
^^
What happened is that with the cast, GDB did an int -> 'unsigned long
long' conversion instead of reinterpreting the variable as the cast-to
type. To get at the variable properly you have to reinterpret the
variable's address manually instead, with either:
(gdb) p /x *(unsigned long long *) &var
$4 = 0x7fffffffffffffff
(gdb) p /x {unsigned long long} &var
$5 = 0x7fffffffffffffff
After this commit GDB does it for you. This is what you'll get
instead:
(gdb) p var
'var' has unknown type; cast it to its declared type
(gdb) p /x (unsigned long long) var
$1 = 0x7fffffffffffffff
As in the functions patch, the "compile" machinery doesn't currently
have the cast-to type handy, so it continues assuming no-debug
variables have int type, though now at least it warns.
The change to gdb.cp/m-static.exp deserves an explanation:
- gdb_test "print 'gnu_obj_1::method()::sintvar'" "\\$\[0-9\]+ = 4" \
+ gdb_test "print (int) 'gnu_obj_1::method()::sintvar'" "\\$\[0-9\]+ = 4" \
That's printing the "sintvar" function local static of the
"gnu_obj_1::method()" method.
The problem with that test is that that "'S::method()::static_var'"
syntax doesn't really work in C++ as you'd expect. The way to make it
work correctly currently is to quote the method part, not the whole
expression, like:
(gdb) print 'gnu_obj_1::method()'::sintvar
If you wrap the whole expression in quotes, like in m-static.exp, what
really happens is that the parser considers the whole string as a
symbol name, but there's no debug symbol with that name. However,
local statics have linkage and are given a mangled name that demangles
to the same string as the full expression, so that's what GDB prints.
After this commit, and without the cast, the print in m-static.exp
would error out saying that the variable has unknown type:
(gdb) p 'gnu_obj_1::method()::sintvar'
'gnu_obj_1::method()::sintvar' has unknown type; cast it to its declared type
TBC, if currently (even before this series) you try to print any
function local static variable of type other than int, you'll get
bogus results. You can see that with m-static.cc as is, even.
Printing the "svar" local, which is a boolean (1 byte) still prints as
"int" (4 bytes):
(gdb) p 'gnu_obj_1::method()::svar'
$1 = 1
(gdb) ptype 'gnu_obj_1::method()::svar'
type = <data variable, no debug info>
This probably prints some random bogus value on big endian machines.
If 'svar' was of some aggregate type (etc.) we'd still print it as
int, so the problem would have been more obvious... After this
commit, you'll get instead:
(gdb) p 'gnu_obj_1::method()::svar'
'gnu_obj_1::method()::svar' has unknown type; cast it to its declared type
... so at least GDB is no longer misleading. Making GDB find the real
local static debug symbol is the subject of the following patches. In
the end, it'll all "Just Work".
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* ax-gdb.c: Include "typeprint.h".
(gen_expr_for_cast): New function.
(gen_expr) <OP_CAST, OP_CAST_TYPE>: Use it.
<OP_VAR_VALUE, OP_MSYM_VAR_VALUE>: Error out if the variable's
type is unknown.
* dwarf2read.c (new_symbol_full): Fallback to int instead of
nodebug_data_symbol.
* eval.c: Include "typeprint.h".
(evaluate_subexp_standard) <OP_VAR_VALUE, OP_VAR_MSYM_VALUE>:
Error out if symbol has unknown type.
<UNOP_CAST, UNOP_CAST_TYPE>: Common bits factored out to
evaluate_subexp_for_cast.
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof): Handle
OP_VAR_MSYM_VALUE.
(evaluate_subexp_for_cast): New function.
* gdbtypes.c (init_nodebug_var_type): New function.
(objfile_type): Use it to initialize types of variables with no
debug info.
* typeprint.c (error_unknown_type): New.
* typeprint.h (error_unknown_type): New declaration.
* compile/compile-c-types.c (convert_type_basic): Handle
TYPE_CODE_ERROR; warn and fallback to int for variables with
unknown type.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.asm/asm-source.exp: Add casts to int.
* gdb.base/nodebug.c (dataglobal8, dataglobal32_1, dataglobal32_2)
(dataglobal64_1, dataglobal64_2): New globals.
* gdb.base/nodebug.exp: Test different expressions involving the
new globals, with print, whatis and ptype. Add casts to int.
* gdb.base/solib-display.exp: Add casts to int.
* gdb.compile/compile-ifunc.exp: Expect warning. Add cast to int.
* gdb.cp/m-static.exp: Add cast to int.
* gdb.dwarf2/dw2-skip-prologue.exp: Add cast to int.
* gdb.threads/tls-nodebug.exp: Check that gdb errors out printing
tls variable with no debug info without a cast. Test with a cast
to int too.
* gdb.trace/entry-values.exp: Add casts.
Pedro Alves [Mon, 4 Sep 2017 19:21:14 +0000 (20:21 +0100)]
evaluate_subexp_standard: Factor out OP_VAR_VALUE handling.
A following patch will want to call the new evaluate_var_value
function in another spot.
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_var_value): New function, factored out from ...
(evaluate_subexp_standard): ... here.
Pedro Alves [Mon, 4 Sep 2017 19:21:14 +0000 (20:21 +0100)]
evaluate_subexp_standard: Remove useless assignments
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <UNOP_COMPLEMENT, UNOP_ADDR>:
Remove useless assignments to 'op'.
Pedro Alves [Mon, 4 Sep 2017 19:21:14 +0000 (20:21 +0100)]
evaluate_subexp_standard: Eliminate one goto
A following patch will want to factor out a bit of
evaluate_subexp_standard, and it'd be handy to reuse the code under the
"nosideret:" label there too. This commits moves it to a separate
function as preparation for that.
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* eval.c (eval_skip_value): New function.
(evaluate_subexp_standard): Use it.
Pedro Alves [Mon, 4 Sep 2017 19:21:14 +0000 (20:21 +0100)]
Make ptype/whatis print function name of functions with no debug info too
The patch to make GDB stop assuming functions return int left GDB with
an inconsistency. While with normal expression evaluation the
"unknown return type" error shows the name of the function that misses
debug info:
(gdb) p getenv ("PATH")
'getenv' has unknown return type; cast the call to its declared return type
^^^^^^
which is handy in more complicated expressions, "ptype" does not:
(gdb) ptype getenv ("PATH")
function has unknown return type; cast the call to its declared return type
^^^^^^^^
This commit builds on the new OP_VAR_MSYM_VALUE to fix it, by making
OP_FUNCALL extract the function name from the symbol stored in
OP_VAR_VALUE/OP_VAR_MSYM_VALUE. We now get the same error in "print"
vs "ptype":
(gdb) ptype getenv()
'getenv' has unknown return type; cast the call to its declared return type
(gdb) p getenv()
'getenv' has unknown return type; cast the call to its declared return type
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard): <OP_FUNCALL>: Extract
function name from symbol/minsym and pass it to
error_call_unknown_return_type.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.base/nodebug.exp: Test that ptype's error about functions
with unknown return type includes the function name too.
Pedro Alves [Mon, 4 Sep 2017 19:21:13 +0000 (20:21 +0100)]
Introduce OP_VAR_MSYM_VALUE
The previous patch left GDB with an inconsistency. While with normal
expression evaluation the "unknown return type" error shows the name
of the function that misses debug info:
(gdb) p getenv ("PATH")
'getenv' has unknown return type; cast the call to its declared return type
^^^^^^
which can by handy in more complicated expressions, "ptype" does not:
(gdb) ptype getenv ("PATH")
function has unknown return type; cast the call to its declared return type
^^^^^^^^
This commit is a step toward fixing it.
The problem is that while evaluating the expression above, we have no
reference to the minimal symbol where we could extract the name from.
This is because the resulting expression tree has no reference to the
minsym at all. During parsing, the type and address of the minsym are
extracted and an UNOP_MEMVAL / UNOP_MEMVAL_TLS operator is generated
(see write_exp_elt_msym). With "set debug expression", here's what
you see:
0 OP_FUNCALL Number of args: 0
3 UNOP_MEMVAL Type @0x565334a51930 (<text variable, no debug info>)
6 OP_LONG Type @0x565334a51c60 (__CORE_ADDR), value
140737345035648 (0x7ffff7751d80)
The "print" case finds the function name, because
call_function_by_hand looks up the function by address again.
However, for "ptype", we don't reach that code, because obviously we
don't really call the function.
Unlike minsym references, references to variables with debug info have
a pointer to the variable's symbol in the expression tree, with
OP_VAR_VALUE:
(gdb) ptype main()
...
0 OP_FUNCALL Number of args: 0
3 OP_VAR_VALUE Block @0x0, symbol @0x559bbbd9b358 (main(int, char**))
...
so I don't see why do minsyms need to be different. So to prepare for
fixing the missing function name issue, this commit adds a new
OP_VAR_MSYM_VALUE operator that mimics OP_VAR_VALUE, except that it's
for minsyms instead of debug symbols. For infcalls, we now get
expressions like these:
0 OP_FUNCALL Number of args: 0
3 OP_VAR_MSYM_VALUE Objfile @0x1e41bf0, msymbol @0x7fffe599b000 (getenv)
In the following patch, we'll make OP_FUNCALL extract the function
name from the symbol stored in OP_VAR_VALUE/OP_VAR_MSYM_VALUE.
OP_VAR_MSYM_VALUE will be used more in a later patch in the series
too.
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* ada-lang.c (resolve_subexp): Handle OP_VAR_MSYM_VALUE.
* ax-gdb.c (gen_msym_var_ref): New function.
(gen_expr): Handle OP_VAR_MSYM_VALUE.
* eval.c (evaluate_var_msym_value): New function.
* eval.c (evaluate_subexp_standard): Handle OP_VAR_MSYM_VALUE.
<OP_FUNCALL>: Extract function name from symbol/minsym and pass it
to call_function_by_hand.
* expprint.c (print_subexp_standard, dump_subexp_body_standard):
Handle OP_VAR_MSYM_VALUE.
(union exp_element) <msymbol>: New field.
* minsyms.h (struct type): Forward declare.
(find_minsym_type_and_address): Declare.
* parse.c (write_exp_elt_msym): New function.
(write_exp_msymbol): Delete, refactored as ...
(find_minsym_type_and_address): ... this new function.
(write_exp_msymbol): Reimplement using OP_VAR_MSYM_VALUE.
(operator_length_standard, operator_check_standard): Handle
OP_VAR_MSYM_VALUE.
* std-operator.def (OP_VAR_MSYM_VALUE): New.
Pedro Alves [Mon, 4 Sep 2017 19:21:13 +0000 (20:21 +0100)]
Stop assuming no-debug-info functions return int
The fact that GDB defaults to assuming that functions return int, when
it has no debug info for the function has been a recurring source of
user confusion. Recently this came up on the errno pretty printer
discussions. Shortly after, it came up again on IRC, with someone
wondering why does getenv() in GDB return a negative int:
(gdb) p getenv("PATH")
$1 = -6185
This question (with s/getenv/random-other-C-runtime-function) is a FAQ
on IRC.
The reason for the above is:
(gdb) p getenv
$2 = {<text variable, no debug info>} 0x7ffff7751d80 <getenv>
(gdb) ptype getenv
type = int ()
... which means that GDB truncated the 64-bit pointer that is actually
returned from getent to 32-bit, and then sign-extended it:
(gdb) p /x -6185
$6 = 0xffffe7d7
The workaround is to cast the function to the right type, like:
(gdb) p ((char *(*) (const char *)) getenv) ("PATH")
$3 = 0x7fffffffe7d7 "/usr/local/bin:/"...
IMO, we should do better than this.
I see the "assume-int" issue the same way I see printing bogus values
for optimized-out variables instead of "<optimized out>" -- I'd much
rather that the debugger tells me "I don't know" and tells me how to
fix it than showing me bogus misleading results, making me go around
tilting at windmills.
If GDB prints a signed integer when you're expecting a pointer or
aggregate, you at least have some sense that something is off, but
consider the case of the function actually returning a 64-bit integer.
For example, compile this without debug info:
unsigned long long
function ()
{
return 0x7fffffffffffffff;
}
Currently, with pristine GDB, you get:
(gdb) p function ()
$1 = -1 # incorrect
(gdb) p /x function ()
$2 = 0xffffffff # incorrect
maybe after spending a few hours debugging you suspect something is
wrong with that -1, and do:
(gdb) ptype function
type = int ()
and maybe, just maybe, you realize that the function actually returns
unsigned long long. And you try to fix it with:
(gdb) p /x (unsigned long long) function ()
$3 = 0xffffffffffffffff # incorrect
... which still produces the wrong result, because GDB simply applied
int to unsigned long long conversion. Meaning, it sign-extended the
integer that it extracted from the return of the function, to 64-bits.
and then maybe, after asking around on IRC, you realize you have to
cast the function to a pointer of the right type, and call that. It
won't be easy, but after a few missteps, you'll get to it:
..... (gdb) p /x ((unsigned long long(*) ()) function) ()
$666 = 0x7fffffffffffffff # finally! :-)
So to improve on the user experience, this patch does the following
(interrelated) things:
- makes no-debug-info functions no longer default to "int" as return
type. Instead, they're left with NULL/"<unknown return type>"
return type.
(gdb) ptype getenv
type = <unknown return type> ()
- makes calling a function with unknown return type an error.
(gdb) p getenv ("PATH")
'getenv' has unknown return type; cast the call to its declared return type
- and then to make it easier to call the function, makes it possible
to _only_ cast the return of the function to the right type,
instead of having to cast the function to a function pointer:
(gdb) p (char *) getenv ("PATH") # now Just Works
$3 = 0x7fffffffe7d7 "/usr/local/bin:/"...
(gdb) p ((char *(*) (const char *)) getenv) ("PATH") # continues working
$4 = 0x7fffffffe7d7 "/usr/local/bin:/"...
I.e., it makes GDB default the function's return type to the type
of the cast, and the function's parameters to the type of the
arguments passed down.
After this patch, here's what you'll get for the "unsigned long long"
example above:
(gdb) p function ()
'function' has unknown return type; cast the call to its declared return type
(gdb) p /x (unsigned long long) function ()
$4 = 0x7fffffffffffffff # correct!
Note that while with "print" GDB shows the name of the function that
has the problem:
(gdb) p getenv ("PATH")
'getenv' has unknown return type; cast the call to its declared return type
which can by handy in more complicated expressions, "ptype" does not:
(gdb) ptype getenv ("PATH")
function has unknown return type; cast the call to its declared return type
This will be fixed in the next patch.
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_evaluate_subexp) <TYPE_CODE_FUNC>: Don't handle
TYPE_GNU_IFUNC specially here. Throw error if return type is
unknown.
* ada-typeprint.c (print_func_type): Handle functions with unknown
return type.
* c-typeprint.c (c_type_print_base): Handle functions and methods
with unknown return type.
* compile/compile-c-symbols.c (convert_symbol_bmsym)
<mst_text_gnu_ifunc>: Use nodebug_text_gnu_ifunc_symbol.
* compile/compile-c-types.c: Include "objfiles.h".
(convert_func): For functions with unknown return type, warn and
default to int.
* compile/compile-object-run.c (compile_object_run): Adjust call
to call_function_by_hand_dummy.
* elfread.c (elf_gnu_ifunc_resolve_addr): Adjust call to
call_function_by_hand.
* eval.c (evaluate_subexp_standard): Adjust calls to
call_function_by_hand. Handle functions and methods with unknown
return type. Pass expect_type to call_function_by_hand.
* f-typeprint.c (f_type_print_base): Handle functions with unknown
return type.
* gcore.c (call_target_sbrk): Adjust call to
call_function_by_hand.
* gdbtypes.c (objfile_type): Leave nodebug text symbol with NULL
return type instead of int. Make nodebug_text_gnu_ifunc_symbol be
an integer address type instead of nodebug.
* guile/scm-value.c (gdbscm_value_call): Adjust call to
call_function_by_hand.
* infcall.c (error_call_unknown_return_type): New function.
(call_function_by_hand): New "default_return_type" parameter.
Pass it down.
(call_function_by_hand_dummy): New "default_return_type"
parameter. Use it instead of defaulting to int. If there's no
default and the return type is unknown, throw an error. If
there's a default return type, and the called function has no
debug info, then assume the function is prototyped.
* infcall.h (call_function_by_hand, call_function_by_hand_dummy):
New "default_return_type" parameter.
(error_call_unknown_return_type): New declaration.
* linux-fork.c (call_lseek): Cast return type of lseek.
(inferior_call_waitpid, checkpoint_command): Adjust calls to
call_function_by_hand.
* linux-tdep.c (linux_infcall_mmap, linux_infcall_munmap): Adjust
calls to call_function_by_hand.
* m2-typeprint.c (m2_procedure): Handle functions with unknown
return type.
* objc-lang.c (lookup_objc_class, lookup_child_selector)
(value_nsstring, print_object_command): Adjust calls to
call_function_by_hand.
* p-typeprint.c (pascal_type_print_varspec_prefix): Handle
functions with unknown return type.
(pascal_type_print_func_varspec_suffix): New function.
(pascal_type_print_varspec_suffix) <TYPE_CODE_FUNC,
TYPE_CODE_METHOD>: Use it.
* python/py-value.c (valpy_call): Adjust call to
call_function_by_hand.
* rust-lang.c (rust_evaluate_funcall): Adjust call to
call_function_by_hand.
* valarith.c (value_x_binop, value_x_unop): Adjust calls to
call_function_by_hand.
* valops.c (value_allocate_space_in_inferior): Adjust call to
call_function_by_hand.
* typeprint.c (type_print_unknown_return_type): New function.
* typeprint.h (type_print_unknown_return_type): New declaration.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.base/break-main-file-remove-fail.exp (test_remove_bp): Cast
return type of munmap in infcall.
* gdb.base/break-probes.exp: Cast return type of foo in infcall.
* gdb.base/checkpoint.exp: Simplify using for loop. Cast return
type of ftell in infcall.
* gdb.base/dprintf-detach.exp (dprintf_detach_test): Cast return
type of getpid in infcall.
* gdb.base/infcall-exec.exp: Cast return type of execlp in
infcall.
* gdb.base/info-os.exp: Cast return type of getpid in infcall.
Bail on failure to extract the pid.
* gdb.base/nodebug.c: #include <stdint.h>.
(multf, multf_noproto, mult, mult_noproto, add8, add8_noproto):
New functions.
* gdb.base/nodebug.exp (test_call_promotion): New procedure.
Change expected output of print/whatis/ptype with functions with
no debug info. Test all supported languages. Call
test_call_promotion.
* gdb.compile/compile.exp: Adjust expected output to expect
warning.
* gdb.threads/siginfo-threads.exp: Likewise.
Pedro Alves [Mon, 4 Sep 2017 19:21:13 +0000 (20:21 +0100)]
Fix calling prototyped functions via function pointers
Calling a prototyped function via a function pointer with the right
prototype doesn't work correctly, if the called function requires
argument coercion... Like, e.g., with:
float mult (float f1, float f2) { return f1 * f2; }
(gdb) p mult (2, 3.5)
$1 = 7
(gdb) p ((float (*) (float, float)) mult) (2, 3.5)
$2 = 0
both calls should have returned the same, of course. The problem is
that GDB misses marking the type of the function pointer target as
prototyped...
Without the fix, the new test fails like this:
(gdb) p ((int (*) (float, float)) t_float_values2)(3.14159,float_val2)
$30 = 0
(gdb) FAIL: gdb.base/callfuncs.exp: p ((int (*) (float, float)) t_float_values2)(3.14159,float_val2)
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdbtypes.c (lookup_function_type_with_arguments): Mark function
types with more than one parameter as prototyped.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.base/callfuncs.exp (do_function_calls): New parameter
"prototypes". Test calling float functions via prototyped and
unprototyped function pointers.
(perform_all_tests): New parameter "prototypes". Pass it down.
(top level): Pass down "prototypes" parameter to
perform_all_tests.
Simon Marchi [Mon, 4 Sep 2017 19:19:17 +0000 (21:19 +0200)]
gdb.base/commands.exp: Test loop_break and loop_continue in nested loops
This patch improves the loop_break and loop_continue tests to verify
that they work as expected when multiple loops are nested (they affect
the inner loop).
gdb/testsuite/ChangeLog:
* gdb.base/commands.exp (loop_break_test, loop_continue_test):
Test with nested loops.
Pedro Alves [Mon, 4 Sep 2017 17:23:22 +0000 (18:23 +0100)]
Introduce gdb_disassembly_flags
For some reason I ended up staring at some of the "int flags" in
btrace-related code, and I got confused because I had no clue what the
flags where supposed to indicate.
Fix that by using enum_flags, so that:
#1 - it's clear from the type what the flags are about, and
#2 - the compiler can catch mismatching mistakes
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* cli/cli-cmds.c (print_disassembly, disassemble_current_function)
(disassemble_command): Use gdb_disassembly_flags instead of bare
int.
* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn)
(dump_insns, do_mixed_source_and_assembly_deprecated)
(do_mixed_source_and_assembly, do_assembly_only, gdb_disassembly):
Use gdb_disassembly_flags instead of bare int.
* disasm.h (DISASSEMBLY_SOURCE_DEPRECATED, DISASSEMBLY_RAW_INSN)
(DISASSEMBLY_OMIT_FNAME, DISASSEMBLY_FILENAME)
(DISASSEMBLY_OMIT_PC, DISASSEMBLY_SOURCE)
(DISASSEMBLY_SPECULATIVE): No longer macros. Instead they're...
(enum gdb_disassembly_flag): ... values of this new enumeration.
(gdb_disassembly_flags): Define.
(gdb_disassembly)
(gdb_pretty_print_disassembler::pretty_print_insn): Use it.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Use
gdb_disassembly_flags instead of bare int.
* record-btrace.c (btrace_insn_history)
(record_btrace_insn_history, record_btrace_insn_history_range)
(record_btrace_insn_history_from): Use gdb_disassembly_flags
instead of bare int.
* record.c (get_insn_history_modifiers, cmd_record_insn_history):
Use gdb_disassembly_flags instead of bare int.
* target-debug.h (target_debug_print_gdb_disassembly_flags):
Define.
* target-delegates.c: Regenerate.
* target.c (target_insn_history, target_insn_history_from)
(target_insn_history_range): Use gdb_disassembly_flags instead of
bare int.
* target.h: Include "disasm.h".
(struct target_ops) <to_insn_history, to_insn_history_from,
to_insn_history_range>: Use gdb_disassembly_flags instead of bare
int.
(target_insn_history, target_insn_history_from)
(target_insn_history_range): Use gdb_disassembly_flags instead of
bare int.
Simon Marchi [Mon, 4 Sep 2017 17:15:59 +0000 (19:15 +0200)]
Add tests for loop_break and loop_continue commands
I grepped the testsuite for loop_break and loop_continue and didn't find
anything, so I wrote some simple tests for those.
gdb/testsuite/ChangeLog:
* gdb.base/commands.exp: Call the new procedures.
(loop_break_test, loop_continue_test): New procedures.
Simon Marchi [Mon, 4 Sep 2017 17:13:08 +0000 (19:13 +0200)]
Error out immediatly when using if command without args in command list
When using "if" (or while) without args directly on gdb's command line,
you get this:
(gdb) if
if/while commands require arguments
When doing the same when entering a command list, you only get an error
when the command is executed, when parse_exp_in_context_1 fails to
evaluate the expression.
(gdb) define foo
Type commands for definition of "foo".
End with a line saying just "end".
>if
>end
>end
(gdb) foo
Argument required (expression to compute).
I think it would make more sense to error out when inputting the command
list directly:
(gdb) define foo
Type commands for definition of "foo".
End with a line saying just "end".
>if
if/while commands require arguments.
The only required change is to check whether args is an empty string in
build_command_line.
gdb/ChangeLog:
* cli/cli-script.c (build_command_line): For if/while commands,
check whether args is empty.
gdb/testsuite/ChangeLog:
* gdb.base/commands.exp: Call new procedure.
(define_if_without_arg_test): New procedure.
Simon Marchi [Mon, 4 Sep 2017 17:09:12 +0000 (19:09 +0200)]
Move command lines types/declarations to cli-script.h
I think it would make more sense if the types and function declarations
related to command lines were in cli-script.h rather than defs.h, since
the related function definitions are in cli-script.c.
I had to add a few includes here and there. I also had to rename the
"lines" parameter of command_lines_deleter::operator(), because ncurses
has a "#define lines ..." that was interfering when cli-script.h is
included by some TUI source files that also include ncurses header files.
gdb/ChangeLog:
* cli/cli-script.h (enum misc_command_type): Move from defs.h.
(enum command_control_type): Likewise.
(struct command_line): Likewise.
(free_command_lines): Likewise.
(struct command_lines_deleter): Likewise.
(command_line_up): Likewise.
(read_command_lines): Likewise.
(read_command_lines_1): Likewise.
* defs.h (enum misc_command_type): Move to cli/cli-script.h.
(enum command_control_type): Likewise.
(struct command_line): Likewise.
(free_command_lines): Likewise.
(struct command_lines_deleter): Likewise.
(command_line_up): Likewise.
(read_command_lines): Likewise.
(read_command_lines_1): Likewise.
* breakpoint.h: Include cli/cli-script.h.
* extension-priv.h: Likewise.
* gdbcmd.h: Likewise.
Simon Marchi [Mon, 4 Sep 2017 17:02:56 +0000 (19:02 +0200)]
gdbserver Makefile: don't delete intermediary files
If you "make" from scratch in gdbserver/, you'll notice that make
deletes the files it considers as intermediary at the end:
$ make clean && make
...
rm i386-mmx-linux-generated.c x32-avx-avx512-linux-generated.c ...
Then, if you type make again, make will rebuild these files and rebuild
gdbserver. To avoid this, we can add the .SECONDARY special target. If
it has no pre-requisites, all intermediary files will be kept.
gdb/gdbserver/ChangeLog:
* Makefile.in (.SECONDARY): Define target.
Pedro Alves [Mon, 4 Sep 2017 16:10:13 +0000 (17:10 +0100)]
Kill init_sal
Instead, make symtab_and_line initialize its members itself. Many
symtab_and_line declarations are moved to where the object is
initialized at the same time both for clarity and to avoid double
initialization. A few functions, like e.g., find_frame_sal are
adjusted to return the sal using normal function return instead of an
output parameter likewise to avoid having to default-construct a sal
and then immediately have the object overwritten.
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* ada-lang.c (is_known_support_routine): Move sal declaration to
where it is initialized.
* breakpoint.c (create_internal_breakpoint, init_catchpoint)
(parse_breakpoint_sals, decode_static_tracepoint_spec)
(clear_command, update_static_tracepoint): Remove init_sal
references. Move declarations closer to initializations.
* cli/cli-cmds.c (list_command): Move sal declarations closer to
initializations.
* elfread.c (elf_gnu_ifunc_resolver_stop): Remove init_sal
references. Move sal declarations closer to initializations.
* frame.c (find_frame_sal): Return a symtab_and_line via function
return instead of output parameter. Remove init_sal references.
* frame.h (find_frame_sal): Return a symtab_and_line via function
return instead of output parameter.
* guile/scm-frame.c (gdbscm_frame_sal): Adjust.
* guile/scm-symtab.c (stscm_make_sal_smob): Use in-place new
instead of memset.
(gdbscm_find_pc_line): Remove init_sal reference.
* infcall.c (call_function_by_hand_dummy): Remove init_sal
references. Move declarations closer to initializations.
* infcmd.c (set_step_frame): Update. Move declarations closer to
initializations.
(finish_backward): Remove init_sal references. Move declarations
closer to initializations.
* infrun.c (process_event_stop_test, handle_step_into_function)
(insert_hp_step_resume_breakpoint_at_frame)
(insert_step_resume_breakpoint_at_caller): Likewise.
* linespec.c (create_sals_line_offset, decode_digits_ordinary)
(symbol_to_sal): Likewise.
* probe.c (parse_probes_in_pspace): Remove init_sal reference.
* python/py-frame.c (frapy_find_sal): Move sal declaration closer
to its initialization.
* reverse.c (save_bookmark_command): Use new/delete. Remove
init_sal references. Move declarations closer to initializations.
* source.c (get_current_source_symtab_and_line): Remove brace
initialization.
(set_current_source_symtab_and_line): Now takes the sal by const
reference. Remove brace initialization.
(line_info): Remove init_sal reference.
* source.h (set_current_source_symtab_and_line): Now takes a
symtab_and_line via const reference.
* stack.c (set_current_sal_from_frame): Adjust.
(print_frame_info): Adjust.
(get_last_displayed_sal): Return the sal via function return
instead of via output parameter. Simplify.
(frame_info): Adjust.
* stack.h (get_last_displayed_sal): Return the sal via function
return instead of via output parameter.
* symtab.c (init_sal): Delete.
(find_pc_sect_line): Remove init_sal references. Move
declarations closer to initializations.
(find_function_start_sal): Remove init_sal references. Move
declarations closer to initializations.
* symtab.h (struct symtab_and_line): In-class initialize all
fields.
* tracepoint.c (set_traceframe_context)
(print_one_static_tracepoint_marker): Remove init_sal references.
Move declarations closer to initializations.
* tui/tui-disasm.c (tui_show_disassem_and_update_source): Adjust.
* tui/tui-stack.c (tui_show_frame_info): Adjust. Move
declarations closer to initializations.
* tui/tui-winsource.c (tui_update_source_window_as_is): Remove
init_sal references. Adjust.
Pedro Alves [Mon, 4 Sep 2017 16:10:13 +0000 (17:10 +0100)]
struct symtabs_and_lines -> std::vector<symtab_and_line>
This replaces "struct symtabs_and_lines" with
std::vector<symtab_and_line> in most cases. This removes a number of
cleanups.
In some cases, the sals objects do not own the sals they point at.
Instead they point at some sal that lives on the stack. Typically
something like this:
struct symtab_and_line sal;
struct symtabs_and_lines sals;
// fill in sal
sals.nelts = 1;
sals.sals = &sal;
// use sals
Instead of switching those cases to std::vector too, such usages are
replaced by gdb::array_view<symtab_and_line> instead. This avoids
introducing heap allocations.
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* ax-gdb.c (agent_command_1): Use range-for.
* break-catch-throw.c (re_set_exception_catchpoint): Update.
* breakpoint.c: Include "common/array-view.h".
(init_breakpoint_sal, create_breakpoint_sal): Change sals
parameter from struct symtabs_and_lines to
array_view<symtab_and_line>. Adjust. Use range-for. Update.
(breakpoint_sals_to_pc): Change sals parameter from struct
symtabs_and_lines to std::vector reference.
(check_fast_tracepoint_sals): Change sals parameter from struct
symtabs_and_lines to std::array_view. Use range-for.
(decode_static_tracepoint_spec): Return a std::vector instead of
symtabs_and_lines. Update.
(create_breakpoint): Update.
(break_range_command, until_break_command, clear_command): Update.
(base_breakpoint_decode_location, bkpt_decode_location)
(bkpt_probe_create_sals_from_location)
(bkpt_probe_decode_location, tracepoint_decode_location)
(tracepoint_probe_decode_location)
(strace_marker_create_sals_from_location): Return a std::vector
instead of symtabs_and_lines.
(strace_marker_create_breakpoints_sal): Update.
(strace_marker_decode_location): Return a std::vector instead of
symtabs_and_lines. Update.
(update_breakpoint_locations): Change struct symtabs_and_lines
parameters to gdb::array_view. Adjust.
(location_to_sals): Return a std::vector instead of
symtabs_and_lines. Update.
(breakpoint_re_set_default): Use std::vector instead of struct
symtabs_and_lines.
(decode_location_default): Return a std::vector instead of
symtabs_and_lines. Update.
* breakpoint.h: Include "common/array-view.h".
(struct breakpoint_ops) <decode_location>: Now returns a
std::vector instead of returning a symtabs_and_lines via output
parameter.
(update_breakpoint_locations): Change sals parameters to use
gdb::array_view.
* cli/cli-cmds.c (edit_command, list_command): Update to use
std::vector and gdb::array_view.
(ambiguous_line_spec): Adjust to use gdb::array_view and
range-for.
(compare_symtabs): Rename to ...
(cmp_symtabs): ... this. Change parameters to symtab_and_line
const reference and adjust.
(filter_sals): Rewrite using std::vector and standard algorithms.
* elfread.c (elf_gnu_ifunc_resolver_return_stop): Simplify.
(jump_command): Update to use std::vector.
* linespec.c (struct linespec_state) <canonical_names>: Update
comment.
(add_sal_to_sals_basic): Delete.
(add_sal_to_sals, filter_results, convert_results_to_lsals)
(decode_line_2, create_sals_line_offset)
(convert_address_location_to_sals, convert_linespec_to_sals)
(convert_explicit_location_to_sals, parse_linespec)
(event_location_to_sals, decode_line_full, decode_line_1)
(decode_line_with_current_source)
(decode_line_with_last_displayed, decode_objc)
(decode_digits_list_mode, decode_digits_ordinary, minsym_found)
(linespec_result::~linespec_result): Adjust to use std::vector
instead of symtabs_and_lines.
* linespec.h (linespec_sals::sals): Now a std::vector.
(struct linespec_result): Use std::vector, bool, and in-class
initialization.
(decode_line_1, decode_line_with_current_source)
(decode_line_with_last_displayed): Return std::vector.
* macrocmd.c (info_macros_command): Use std::vector.
* mi/mi-main.c (mi_cmd_trace_find): Use std::vector.
* probe.c (parse_probes_in_pspace, parse_probes): Adjust to use
std::vector.
* probe.h (parse_probes): Return a std::vector.
* python/python.c (gdbpy_decode_line): Use std::vector and
gdb::array_view.
* source.c (select_source_symtab, line_info): Use std::vector.
* stack.c (func_command): Use std::vector.
* symtab.h (struct symtabs_and_lines): Delete.
* tracepoint.c (tfind_line_command, scope_info): Use std::vector.