Commit Graph

358 Commits

Author SHA1 Message Date
Sergio Durigan Junior 935676c92f Convert generic probe interface to C++ (and perform some cleanups)
This patch converts the generic probe interface (gdb/probe.[ch]) to
C++, and also performs some cleanups that were on my TODO list for a
while.

The main changes were the conversion of 'struct probe' to 'class
probe', and 'struct probe_ops' to 'class static_probe_ops'.  The
former now contains all the "dynamic", generic methods that act on a
probe + the generic data related to it; the latter encapsulates a
bunch of "static" methods that relate to the probe type, but not to a
specific probe itself.

I've had to do a few renamings (e.g., on 'struct bound_probe' the
field is called 'probe *prob' now, instead of 'struct probe *probe')
because GCC was complaining about naming the field using the same name
as the class.  Nothing major, though.  Generally speaking, the logic
behind and the design behind the code are the same.

Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies.  But it
should be easier to review in separate logical units.

I've regtested this patch on BuildBot, no regressions found.

gdb/ChangeLog:
2017-11-22  Sergio Durigan Junior  <sergiodj@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Use
	'probe.prob' instead of 'probe.probe'.
	* breakpoint.c (create_longjmp_master_breakpoint): Call
	'can_evaluate_arguments' and 'get_relocated_address' methods
	from probe.
	(create_exception_master_breakpoint): Likewise.
	(add_location_to_breakpoint): Use 'sal->prob' instead of
	'sal->probe'.
	(bkpt_probe_insert_location): Call 'set_semaphore' method from
	probe.
	(bkpt_probe_remove_location): Likewise, for 'clear_semaphore'.
	* elfread.c (elf_get_probes): Use 'static_probe_ops' instead
	of 'probe_ops'.
	(probe_key_free): Call 'delete' on probe.
	(check_exception_resume): Use 'probe.prob' instead of
	'probe.probe'.
	* location.c (string_to_event_location_basic): Call
	'probe_linespec_to_static_ops'.
	* probe.c (class any_static_probe_ops): New class.
	(any_static_probe_ops any_static_probe_ops): New variable.
	(parse_probes_in_pspace): Receive 'static_probe_ops' as
	argument.  Adjust code to reflect change.
	(parse_probes): Use 'static_probe_ops' instead of
	'probe_ops'.  Adjust code to reflect change.
	(find_probes_in_objfile): Call methods to get name and
	provider from probe.
	(find_probe_by_pc): Use 'result.prob' instead of
	'result.probe'.  Call 'get_relocated_address' method from
	probe.
	(collect_probes): Adjust comment and argument list to receive
	'static_probe_ops' instead of 'probe_ops'.  Adjust code to
	reflect change.  Call necessary methods from probe.
	(compare_probes): Call methods to get name and provider from
	probes.
	(gen_ui_out_table_header_info): Receive 'static_probe_ops'
	instead of 'probe_ops'.  Use 'std::vector' instead of VEC,
	adjust code accordingly.
	(print_ui_out_not_applicables): Likewise.
	(info_probes_for_ops): Rename to...
	(info_probes_for_spops): ...this.  Receive 'static_probe_ops'
	as argument instead of 'probe_ops'.  Adjust code.  Call
	necessary methods from probe.
	(info_probes_command): Use 'info_probes_for_spops'.
	(enable_probes_command): Pass correct argument to
	'collect_probes'.  Call methods from probe.
	(disable_probes_command): Likewise.
	(get_probe_address): Move to 'any_static_probe_ops::get_address'.
	(get_probe_argument_count): Move to
	'any_static_probe_ops::get_argument_count'.
	(can_evaluate_probe_arguments): Move to
	'any_static_probe_ops::can_evaluate_arguments'.
	(evaluate_probe_argument): Move to
	'any_static_probe_ops::evaluate_argument'.
	(probe_safe_evaluate_at_pc): Use 'probe.prob' instead of
	'probe.probe'.
	(probe_linespec_to_ops): Rename to...
	(probe_linespec_to_static_ops): ...this.  Adjust code.
	(probe_any_is_linespec): Rename to...
	(any_static_probe_ops::is_linespec): ...this.
	(probe_any_get_probes): Rename to...
	(any_static_probe_ops::get_probes): ...this.
	(any_static_probe_ops::type_name): New method.
	(any_static_probe_ops::gen_info_probes_table_header): New
	method.
	(compute_probe_arg): Use 'pc_probe.prob' instead of
	'pc_probe.probe'.  Call methods from probe.
	(compile_probe_arg): Likewise.
	(std::vector<const probe_ops *> all_probe_ops): Delete.
	(std::vector<const static_probe_ops *> all_static_probe_ops):
	New variable.
	(_initialize_probe): Use 'all_static_probe_ops' instead of
	'all_probe_ops'.
	* probe.h (struct info_probe_column) <field_name>: Delete
	extraneous newline
	(info_probe_column_s): Delete type and VEC.
	(struct probe_ops): Delete.  Replace with...
	(class static_probe_ops): ...this and...
	(clas probe): ...this.
	(struct bound_probe) <bound_probe>: Delete extraneous
	newline.  Adjust constructor to receive 'probe' instead of
	'struct probe'.
	<probe>: Rename to...
	<prob>: ...this.  Delete extraneous newline.
	<objfile>: Delete extraneous newline.
	(register_probe_ops): Delete unused prototype.
	(info_probes_for_ops): Rename to...
	(info_probes_for_spops): ...this.  Adjust comment.
	(get_probe_address): Move to 'probe::get_address'.
	(get_probe_argument_count): Move to
	'probe::get_argument_count'.
	(can_evaluate_probe_arguments): Move to
	'probe::can_evaluate_arguments'.
	(evaluate_probe_argument): Move to 'probe::evaluate_argument'.
	* solib-svr4.c (struct svr4_info): Adjust comment.
	(struct probe_and_action) <probe>: Rename to...
	<prob>: ...this.
	(register_solib_event_probe): Receive 'probe' instead of
	'struct probe' as argument.  Use 'prob' instead of 'probe'
	when applicable.
	(solib_event_probe_action): Call 'get_argument_count' method
	from probe.  Adjust comment.
	(svr4_handle_solib_event): Adjust comment.  Call
	'evaluate_argument' method from probe.
	(svr4_create_probe_breakpoints): Call 'get_relocated_address'
	from probe.
	(svr4_create_solib_event_breakpoints): Use 'probe' instead of
	'struct probe'.  Call 'can_evaluate_arguments' from probe.
	* symfile.h: Forward declare 'class probe' instead of 'struct
	probe'.
	* symtab.h: Likewise.
	(struct symtab_and_line) <probe>: Rename to...
	<prob>: ...this.
	* tracepoint.c (start_tracing): Use 'prob' when applicable.
	Call probe methods.
	(stop_tracing): Likewise.
2017-11-22 19:13:44 -05:00
Tom Tromey 454dafbdf2 Introduce gdb_breakpoint_up
This introduces gdb_breakpoint_up, a unique_ptr typedef that owns a
breakpoint.  It then changes set_momentary_breakpoint to return a
gdb_breakpoint_up and fixes up the fallout.  This then allows the
removal of make_cleanup_delete_breakpoint.

Once breakpoints are fully C++-ified, this typedef can be removed in
favor of a plain std::unique_ptr.

gdb/ChangeLog
2017-11-04  Tom Tromey  <tom@tromey.com>

	* breakpoint.c (set_momentary_breakpoint): Return
	breakpoint_up.
	(until_break_command): Update.
	(new_until_break_fsm): Change argument types to
	breakpoint_up.
	(set_momentary_breakpoint_at_pc): Return breakpoint_up.
	(do_delete_breakpoint_cleanup, make_cleanup_delete_breakpoint):
	Remove.
	* infcmd.c (finish_forward): Update.
	* breakpoint.h (set_momentary_breakpoint)
	(set_momentary_breakpoint_at_pc): Return breakpoint_up.
	(make_cleanup_delete_breakpoint): Remove.
	(struct breakpoint_deleter): New.
	(breakpoint_up): New typedef.
	* infrun.c (insert_step_resume_breakpoint_at_sal_1): Update.
	(insert_exception_resume_breakpoint): Update.
	(insert_exception_resume_from_probe): Update.
	(insert_longjmp_resume_breakpoint): Update.
	* arm-linux-tdep.c (arm_linux_copy_svc): Update.
	* elfread.c (elf_gnu_ifunc_resolver_stop): Update.
	* infcall.c (call_function_by_hand_dummy): Update
2017-11-04 10:27:20 -06:00
Pedro Alves 63f0e930d4 Work around GCC 6.3.1 bug
This commit works around a GCC 6.3.1 bug several people are hitting:

  https://sourceware.org/ml/gdb-patches/2017-09/msg00270.html
  https://sourceware.org/ml/gdb-patches/2017-10/msg00418.html

It manifests like this:

  ../../../binutils-gdb/gdb/probe.c:68:12: error: types may not be defined in a for-range-declaration [-Werror]
	 for (struct probe *probe : probes)
	      ^~~~~~

Fix it by renaming the range-for named variables to something different
from their type's name.

gdb/ChangeLog:
2017-10-16  Pedro Alves  <palves@redhat.com>

	* elfread.c (probe_key_free): Rename range-for variable.
	* probe.c (parse_probes_in_pspace, find_probes_in_objfile)
	(find_probe_by_pc, collect_probes): Rename range-for variable.
2017-10-16 13:39:12 +01:00
Simon Marchi 0782db848b probe: Replace VEC(probe_ops_cp) with std::vector
This patch replaces the usage of VEC to store pointers to probe_ops with
an std::vector.  The sole usage of that vector type is one global
variable that holds the ops for the various kinds of probes, so this is
pretty straightforward (no allocation/deallocation issues).

gdb/ChangeLog:

	* probe.h (probe_ops_cp): Remove typedef.
	(DEF_VEC_P (probe_ops_cp)): Remove.
	(all_probe_ops): Change type to std::vector.
	* probe.c (info_probes_for_ops): Adjust to vector change.
	(probe_linespec_to_ops): Likewise.
	(all_probe_ops): Change type to std::vector.
	(_initialize_probe): Adjust to vector change.
	* dtrace-probe.c (_initialize_dtrace_probe): Likewise.
	* elfread.c (elf_get_probes): Likewise.
	* stap-probe.c (_initialize_stap_probe): Likewise.
2017-09-12 14:15:23 +02:00
Simon Marchi aaa63a3190 Make probe_ops::get_probes fill an std::vector
This patch changes one usage of VEC to std::vector.  It is a relatively
straightforward 1:1 change.  The implementations of
sym_probe_fns::sym_get_probes return a borrowed reference to their probe
vectors, meaning that the caller should not free it.  In the new code, I
made them return a const reference to the vector.

This patch and the following one were tested by the buildbot.  I didn't
see any failures that looked related to this one.

gdb/ChangeLog:

	* probe.h (struct probe_ops) <get_probes>: Change parameter from
	vec to std::vector.
	* probe.c (parse_probes_in_pspace): Update.
	(find_probes_in_objfile): Update.
	(find_probe_by_pc): Update.
	(collect_probes): Update.
	(probe_any_get_probes): Update.
	* symfile.h (struct sym_probe_fns) <sym_get_probes> Change
	return type to reference to std::vector.
	* dtrace-probe.c (dtrace_process_dof_probe): Change parameter to
	std::vector and update.
	(dtrace_process_dof): Likewise.
	(dtrace_get_probes): Likewise.
	* elfread.c (elf_get_probes): Change return type to std::vector,
	store an std::vector in bfd_data.
	(probe_key_free): Update to std::vector.
	* stap-probe.c (handle_stap_probe): Change parameter to
	std::vector and update.
	(stap_get_probes): Likewise.
	* symfile-debug.c (debug_sym_get_probes): Change return type to
	std::vector and update.
2017-09-12 13:37:00 +02:00
John Baldwin 481695ed5f 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.
2017-09-09 11:02:37 -07:00
Pedro Alves 7022349d5c 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.
2017-09-04 20:21:13 +01:00
Pedro Alves 51abb42130 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.
2017-09-04 17:11:45 +01:00
Pedro Alves 6c5b2ebeac 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.
2017-09-04 17:11:15 +01:00
Alex Lindsay ba7139188c Synthetic symbol leak in elf_read_minimal_symbols
Detected this leak with valgrind memcheck:

==30840== 194 bytes in 1 blocks are definitely lost in loss record 9,138 of 10,922
==30840==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==30840==    by 0x80DF82: bfd_malloc (libbfd.c:193)
==30840==    by 0x80E12D: bfd_zmalloc (libbfd.c:278)
==30840==    by 0x819E80: elf_x86_64_get_synthetic_symtab (elf64-x86-64.c:6835)
==30840==    by 0x4F7B01: elf_read_minimal_symbols(objfile*, int, elfinfo const*) (elfread.c:1124)
==30840==    by 0x4F7CE7: elf_symfile_read(objfile*, enum_flags<symfile_add_flag>) (elfread.c:1182)
==30840==    by 0x7557FC: read_symbols(objfile*, enum_flags<symfile_add_flag>) (symfile.c:861)
==30840==    by 0x755EE1: syms_from_objfile_1(objfile*, section_addr_info*, enum_flags<symfile_add_flag>) (symfile.c:1062)

We perform a dynamic allocation in
elf64-x86-64.c:elf_x86_64_get_synthetic_symtab

  s = *ret = (asymbol *) bfd_zmalloc (size);

that appear to never get freed.

gdb:

2017-08-17  Alex Lindsay  <alexlindsay239@gmail.com>

	* elfread.c (elf_read_minimal_symbols): xfree synthsyms.
2017-08-17 11:53:53 +01:00
Tom Tromey 26fcd5d757 Use containers to avoid cleanups
This patch introduces the use of various containers -- std::vector,
std::string, or gdb::byte_vector -- in several spots in gdb that were
using xmalloc and a cleanup.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

	* valops.c (search_struct_method): Use gdb::byte_vector.
	* valarith.c (value_concat): Use std::vector.
	* target.c (memory_xfer_partial): Use gdb::byte_vector.
	(simple_search_memory): Likewise.
	* printcmd.c (find_string_backward): Use gdb::byte_vector.
	* mi/mi-main.c (mi_cmd_data_write_memory): Use gdb::byte_vector.
	* gcore.c (gcore_copy_callback): Use gdb::byte_vector.
	* elfread.c (elf_rel_plt_read): Use std::string.
	* cp-valprint.c (cp_print_value): Use gdb::byte_vector.
	* cli/cli-dump.c (restore_section_callback): Use
	gdb::byte_vector.
2017-08-03 07:59:02 -06:00
Tom Tromey d28cd78ad8 Change breakpoint event locations to event_location_up
This is a follow-up to an earlier patch.  It changes breakpoint's
location and location_range_end members to be of type
event_location_up, then fixes up the users.

gdb/ChangeLog
2017-04-12  Tom Tromey  <tom@tromey.com>

	* remote.c (remote_download_tracepoint): Update.
	* python/py-breakpoint.c (bppy_get_location): Update.
	* guile/scm-breakpoint.c (bpscm_print_breakpoint_smob)
	(gdbscm_breakpoint_location): Update.
	* elfread.c (elf_gnu_ifunc_resolver_return_stop): Update.
	* breakpoint.h (struct breakpoint) <location, location_range_end>:
	Change type to event_location_up.
	* breakpoint.c (create_overlay_event_breakpoint)
	(create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint)
	(breakpoint_event_location_empty_p, print_breakpoint_location)
	(print_one_breakpoint_location, create_thread_event_breakpoint)
	(init_breakpoint_sal, create_breakpoint)
	(print_recreate_ranged_breakpoint, break_range_command)
	(init_ada_exception_breakpoint, say_where): Update.
	(base_breakpoint_dtor): Don't call delete_event_location.
	(bkpt_print_recreate, tracepoint_print_recreate)
	(dprintf_print_recreate, update_static_tracepoint)
	(breakpoint_re_set_default): Update.
2017-04-12 11:16:19 -06:00
Tom Tromey 192b62ce0b Use class to manage BFD reference counts
This introduces a new specialization of gdb::ref_ptr that can be used
to manage BFD reference counts.  Then it changes most places in gdb to
use this new class, rather than explicit reference-counting or
cleanups.  This patch removes make_cleanup_bfd_unref.

If you look you will see a couple of spots using "release" where a use
of gdb_bfd_ref_ptr would be cleaner.  These will be fixed in the next
patch.

I think this patch fixes some latent bugs.  For example, it seems to
me that previously objfpy_add_separate_debug_file leaked a BFD.

I'm not 100% certain that the macho_symfile_read_all_oso change is
correct.  The existing code here is hard for me to follow.  One goal
of this sort of automated reference counting, though, is to make it
more difficult to make logic errors; so hopefully the code is clear
now.

2017-01-10  Tom Tromey  <tom@tromey.com>

	* windows-tdep.c (windows_xfer_shared_library): Update.
	* windows-nat.c (windows_make_so): Update.
	* utils.h (make_cleanup_bfd_unref): Remove.
	* utils.c (do_bfd_close_cleanup, make_cleanup_bfd_unref): Remove.
	* symfile.h (symfile_bfd_open)
	(find_separate_debug_file_in_section): Return gdb_bfd_ref_ptr.
	* symfile.c (read_symbols, symbol_file_add)
	(separate_debug_file_exists): Update.
	(symfile_bfd_open): Return gdb_bfd_ref_ptr.
	(generic_load, reread_symbols): Update.
	* symfile-mem.c (symbol_file_add_from_memory): Update.
	* spu-linux-nat.c (spu_bfd_open): Return gdb_bfd_ref_ptr.
	(spu_symbol_file_add_from_memory): Update.
	* solist.h (struct target_so_ops) <bfd_open>: Return
	gdb_bfd_ref_ptr.
	(solib_bfd_fopen, solib_bfd_open): Return gdb_bfd_ref_ptr.
	* solib.c (solib_bfd_fopen, solib_bfd_open): Return
	gdb_bfd_ref_ptr.
	(solib_map_sections, reload_shared_libraries_1): Update.
	* solib-svr4.c (enable_break): Update.
	* solib-spu.c (spu_bfd_fopen): Return gdb_bfd_ref_ptr.
	* solib-frv.c (enable_break2): Update.
	* solib-dsbt.c (enable_break): Update.
	* solib-darwin.c (gdb_bfd_mach_o_fat_extract): Return
	gdb_bfd_ref_ptr.
	(darwin_solib_get_all_image_info_addr_at_init): Update.
	(darwin_bfd_open): Return gdb_bfd_ref_ptr.
	* solib-aix.c (solib_aix_bfd_open): Return gdb_bfd_ref_ptr.
	* record-full.c (record_full_save): Update.
	* python/py-objfile.c (objfpy_add_separate_debug_file): Update.
	* procfs.c (insert_dbx_link_bpt_in_file): Update.
	* minidebug.c (find_separate_debug_file_in_section): Return
	gdb_bfd_ref_ptr.
	* machoread.c (macho_add_oso_symfile): Change abfd to
	gdb_bfd_ref_ptr.
	(macho_symfile_read_all_oso): Update.
	(macho_check_dsym): Return gdb_bfd_ref_ptr.
	(macho_symfile_read): Update.
	* jit.c (bfd_open_from_target_memory): Return gdb_bfd_ref_ptr.
	(jit_bfd_try_read_symtab): Update.
	* gdb_bfd.h (gdb_bfd_open, gdb_bfd_fopen, gdb_bfd_openr)
	(gdb_bfd_openw, gdb_bfd_openr_iovec)
	(gdb_bfd_openr_next_archived_file, gdb_bfd_fdopenr): Return
	gdb_bfd_ref_ptr.
	(gdb_bfd_ref_policy): New struct.
	(gdb_bfd_ref_ptr): New typedef.
	* gdb_bfd.c (gdb_bfd_open, gdb_bfd_fopen, gdb_bfd_openr)
	(gdb_bfd_openw, gdb_bfd_openr_iovec)
	(gdb_bfd_openr_next_archived_file, gdb_bfd_fdopenr): Return
	gdb_bfd_ref_ptr.
	* gcore.h (create_gcore_bfd): Return gdb_bfd_ref_ptr.
	* gcore.c (create_gcore_bfd): Return gdb_bfd_ref_ptr.
	(gcore_command): Update.
	* exec.c (exec_file_attach): Update.
	* elfread.c (elf_symfile_read): Update.
	* dwarf2read.c (dwarf2_get_dwz_file): Update.
	(try_open_dwop_file, open_dwo_file): Return gdb_bfd_ref_ptr.
	(open_and_init_dwo_file): Update.
	(open_dwp_file): Return gdb_bfd_ref_ptr.
	(open_and_init_dwp_file): Update.
	* corelow.c (core_open): Update.
	* compile/compile-object-load.c (compile_object_load): Update.
	* common/gdb_ref_ptr.h (ref_ptr::operator->): New operator.
	* coffread.c (coff_symfile_read): Update.
	* cli/cli-dump.c (bfd_openr_or_error, bfd_openw_or_error): Return
	gdb_bfd_ref_ptr.  Rename.
	(dump_bfd_file, restore_command): Update.
	* build-id.h (build_id_to_debug_bfd): Return gdb_bfd_ref_ptr.
	* build-id.c (build_id_to_debug_bfd): Return gdb_bfd_ref_ptr.
	(find_separate_debug_file_by_buildid): Update.
2017-01-10 19:14:10 -07:00
Joel Brobecker 61baf725ec update copyright year range in GDB files
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.

gdb/ChangeLog:

        Update copyright year range in all GDB files.
2017-01-01 10:52:34 +04:00
Yao Qi 1a08844158 Restrict checking value.lval on using address
With the previous change, value.location.address is only valid for
lval_memory.  This patch restrict some checking on value.lval on
using address.  Since we have a check on VALUE_VAL in
set_value_address, we need to set VALUE_VAL properly before
set_value_address too.

gdb:

2016-11-25  Yao Qi  <yao.qi@linaro.org>

	* ada-lang.c (ensure_lval): Call set_value_address after setting
	VALUE_LVAL.
	* elfread.c (elf_gnu_ifunc_resolve_addr): Set VALUE_LVAL to
	lval_memory.
	(elf_gnu_ifunc_resolver_return_stop): Likewise.
	* value.c (value_fn_field): Likewise.
	(value_from_contents_and_address_unresolved): Likewise.
	(value_from_contents_and_address): Likewise.
	(value_address): Check value->lval isn't
	lval_memory.
	(value_raw_address): Likewise.
	(set_value_address): Assert value->lval is lval_memory.
2016-11-28 17:09:26 +00:00
Pedro Alves b22e99fdaf gdb::{unique_ptr,move} -> std::{unique_ptr,move}
Now that we require C++11, use std::unique_ptr and std::move directly.

gdb/ChangeLog:
2016-11-15  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (create_excep_cond_exprs): Use std::move instead of
	gdb::move.
	* break-catch-throw.c (handle_gnu_v3_exceptions): Use
	std::unique_ptr instead of gdb::unique_ptr.
	* breakpoint.c (watch_command_1): Use std::move instead of
	gdb::move.
	* cli/cli-dump.c (dump_memory_to_file, restore_binary_file): Use
	std::unique_ptr instead of gdb::unique_ptr.
	* dtrace-probe.c (dtrace_process_dof_probe): Use std::move instead
	of gdb::move.
	* elfread.c (elf_read_minimal_symbols): Use std::unique_ptr
	instead of gdb::unique_ptr.
	* mi/mi-main.c (mi_cmd_data_read_memory): Use std::unique_ptr
	instead of gdb::unique_ptr.
	* parse.c (parse_expression_for_completion): Use std::move instead
	of gdb::move.
	* printcmd.c (display_command): std::move instead of gdb::move.
2016-11-15 19:54:21 +00:00
Pedro Alves b15cc25cbe Make symfile_add_flags and objfile->flags strongly typed
This makes these flag types be "enum flag" types.  The benefit is
making use of C++'s stronger typing -- mixing the flags types by
mistake errors at compile time.

This caught one old bug in symbol_file_add_main_1 already, fixed by
this patch as well:

  @@ -1318,7 +1326,7 @@ symbol_file_add_main_1 (const char *args, int from_tty, int flags)
	what is frameless.  */
     reinit_frame_cache ();

  -  if ((flags & SYMFILE_NO_READ) == 0)
  +  if ((add_flags & SYMFILE_NO_READ) == 0)
       set_initial_language ();
   }

Above, "flags" are objfile flags, not symfile_add_flags.  So that was
actually checking for "flag & OBJF_PSYMTABS_READ", which has the same
value as SYMFILE_NO_READ...

I moved the flags definitions to separate files to break circular
dependencies.

Built with --enable-targets=all and tested on x86-64 Fedora 23.

gdb/ChangeLog:
2016-10-26  Pedro Alves  <palves@redhat.com>

	* coffread.c (coff_symfile_read): Use symfile_add_flags.
	* dbxread.c (dbx_symfile_read): Ditto.
	* elfread.c (elf_symfile_read): Ditto.
	* inferior.h: Include symfile-add-flags.h.
	(struct inferior) <symfile_flags>: Now symfile_add_flags.
	* machoread.c (macho_add_oso_symfile, macho_symfile_read_all_oso)
	(macho_symfile_read, mipscoff_symfile_read): Use
	symfile_add_flags.
	* objfile-flags.h: New file.
	* objfiles.c (allocate_objfile): Use objfile_flags.
	* objfiles.h: Include objfile-flags.h.
	(struct objfile) <flags>: Now an objfile_flags.
	(OBJF_REORDERED, OBJF_SHARED, OBJF_READNOW, OBJF_USERLOADED)
	(OBJF_PSYMTABS_READ, OBJF_MAINLINE, OBJF_NOT_FILENAME): Delete.
	Converted to an enum-flags in objfile-flags.h.
	(allocate_objfile): Use objfile_flags.
	* python/py-objfile.c (objfpy_add_separate_debug_file): Remove
	unnecessary local.
	* solib.c (solib_read_symbols, solib_add)
	(reload_shared_libraries_1): Use symfile_add_flags.
	* solib.h: Include "symfile-add-flags.h".
	(solib_read_symbols): Use symfile_add_flags.
	* symfile-add-flags.h: New file.
	* symfile-debug.c (debug_sym_read): Use symfile_add_flags.
	* symfile-mem.c (symbol_file_add_from_memory): Use
	symfile_add_flags.
	* symfile.c (read_symbols, syms_from_objfile_1)
	(syms_from_objfile, finish_new_objfile): Use symfile_add_flags.
	(symbol_file_add_with_addrs): Use symfile_add_flags and
	objfile_flags.
	(symbol_file_add_separate): Use symfile_add_flags.
	(symbol_file_add_from_bfd, symbol_file_add): Use symfile_add_flags
	and objfile_flags.
	(symbol_file_add_main_1): : Use objfile_flags.  Fix add_flags vs
	flags confusion.
	(symbol_file_command): Use objfile_flags.
	(add_symbol_file_command): Use symfile_add_flags and
	objfile_flags.
	(clear_symtab_users): Use symfile_add_flags.
	* symfile.h: Include "symfile-add-flags.h" and "objfile-flags.h".
	(struct sym_fns) <sym_read>: Use symfile_add_flags.
	(clear_symtab_users): Use symfile_add_flags.
	(enum symfile_add_flags): Delete, moved to symfile-add-flags.h and
	converted to enum-flags.
	(symbol_file_add, symbol_file_add_from_bfd)
	(symbol_file_add_separate): Use symfile_add_flags.
	* xcoffread.c (xcoff_initial_scan): Use symfile_add_flags.
2016-10-26 16:47:10 +01:00
Tom Tromey ce6c454e5a Change minimal_symbol_reader::record_full to take a bool
This changes an "int" to a "bool" in the signature for
minimal_symbol_reader::record_full, and then fixes the callers.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* minsyms.h (minimal_symbol_reader::record_full): "copy_name" now
	a bool.
	(record, record_with_info): Update.
	* minsyms.c (record): Fix indentation.
	(record_full): Fix indentation.  Update for type change.
	* elfread.c (record_minimal_symbol): "copy_name" now a bool.
	(elf_symtab_read): "copy_names" now a bool.
	(elf_rel_plt_read, elf_read_minimal_symbols): Update.
2016-10-21 14:17:39 -06:00
Tom Tromey d1e4a62469 Use gdb::unique_ptr in elf_read_minimal_symbols
This changes elf_read_minimal_symbols to use gdb::unique_ptr rather
than an explicit allocation.  This removes a cleanup.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* elfread.c (elf_read_minimal_symbols): Use gdb::unique_ptr.
2016-10-21 14:17:36 -06:00
Tom Tromey 8dddcb8f00 Record minimal symbols directly in reader.
This patch changes minimal symbol creation in two ways.  First, it
removes global variables in favor of members of minimal_symbol_reader.
Second, it changes functions like prim_record_minimal_symbol to be
member functions of minimal_symbol_reader.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add
	"reader" argument.  Update.
	(xcoff_initial_scan): Update.
	* symfile.h (mdebug_build_psymtabs): Add "reader" argument.
	* mipsread.c (mipscoff_symfile_read): Update.
	(read_alphacoff_dynamic_symtab): Add "reader" argument.  Update.
	* minsyms.h (minimal_symbol_reader) <record, record_full>:
	Declare.
	<m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members.
	<record_with_info>: New function, renamed from
	prim_record_minimal_symbol_and_info.
	* minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove
	globals.
	(minimal_symbol_reader): Initialize new members.
	(minimal_symbol_reader::record): Renamed from
	prim_record_minimal_symbol.
	(minimal_symbol_reader::record_full): Renamed from
	prim_record_minimal_symbol_full.
	(prim_record_minimal_symbol_and_info): Move to minsyms.h; rename.
	* mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols)
	(record_minimal_symbol): Add "reader" argument.  Update.
	(elfmdebug_build_psymtabs): Update.
	* machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add
	"reader" argument.  Update.
	(macho_symfile_read): Update.
	* elfread.c (record_minimal_symbol, elf_symtab_read)
	(elf_rel_plt_read): Add "reader" argument.  Update.
	(elf_read_minimal_symbols): Update.
	* dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab)
	(read_dbx_symtab): Add "reader" argument.  Update.
	(dbx_symfile_read): Update.
	* coffread.c (record_minimal_symbol, coff_symtab_read): Add
	"reader" argument.  Update.
	(coff_symfile_read): Update.
	* coff-pe-read.h (read_pe_exported_syms): Add "reader" argument.
	* coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym)
	(read_pe_exported_syms): Add "reader" argument.  Update.
2016-10-21 14:17:33 -06:00
Tom Tromey d25e871993 Change minimal_symbol_reader to store objfile
This changes minimal_symbol_reader to require the objfile to be
passed to the constructor.  The class now records the objfile and
automatically uses it later in "install".

This is a minor cleanup that will come in useful in the next patch.
It is separate from the first patch to keep that one a bit simpler to
understand.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_initial_scan): Update.
	* mipsread.c (mipscoff_symfile_read): Update.
	* minsyms.c (minimal_symbol_reader): Add obj argument.
	Initialize member.
	(install): Remove objfile argument.  Update.
	* mdebugread.c (elfmdebug_build_psymtabs): Update.
	* machoread.c (macho_symfile_read): Update.
	* elfread.c (elf_read_minimal_symbols): Update.
	* dbxread.c (dbx_symfile_read): Update.
	* coffread.c (coff_symfile_read): Update.
	* minsyms.h (minimal_symbol_reader): Add m_objfile member.
	(constructor): Add objfile argument.
	(minimal_symbol_reader::install): Remove objfile argument.
2016-10-21 14:17:33 -06:00
Tom Tromey 873a915e0a Introduce minimal_symbol_reader
This patch introduced minimal_symbol_reader, a RAII-based class which
replaces the current make_cleanup_discard_minimal_symbols.

2016-10-21  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_initial_scan): Use
	minimal_symbol_reader.
	* mipsread.c (mipscoff_symfile_read): Use
	minimal_symbol_reader.
	* minsyms.h (minimal_symbol_reader): New class.
	(init_minimal_symbol_collection)
	(make_cleanup_discard_minimal_symbols, install_minimal_symbols):
	Don't declare.
	* minsyms.c (minimal_symbol_reader): Renamed from
	init_minimal_symbol_collection, turned into constructor.
	(~minimal_symbol_reader): Renamed from
	do_discard_minimal_symbols_cleanup, turned into destructor.
	(make_cleanup_discard_minimal_symbols): Remove.
	(minimal_symbol_reader::install): Rename form
	install_minimal_symbols.
	* mdebugread.c (elfmdebug_build_psymtabs): Use
	minimal_symbol_reader.
	* machoread.c (macho_symfile_read): Use
	minimal_symbol_reader.
	* elfread.c (elf_read_minimal_symbols): Use
	minimal_symbol_reader.
	* dbxread.c (dbx_symfile_read): Use minimal_symbol_reader.
	* coffread.c (coff_symfile_read): Use
	minimal_symbol_reader.
2016-10-21 14:17:33 -06:00
Andreas Arnez e1b2624a08 Pass HWCAP to ifunc resolver
On various GNU Elf architectures, including AArch64, ARM, s390/s390x,
ppc32/64, and sparc32/64, the dynamic loader passes HWCAP as a parameter
to each ifunc resolver.  Currently there is an open glibc Bugzilla that
requests this to be generalized to all architectures:

  https://sourceware.org/bugzilla/show_bug.cgi?id=19766

And various ifunc resolvers already rely on receiving HWCAP.  Currently
GDB always calls an ifunc resolver without any arguments; thus the
resolver may receive garbage, and based on that, the resolver may decide
to return a function that is not suited for the given platform.

This patch always passes HWCAP to ifunc resolvers, even on systems where
the dynamic loader currently behaves otherwise.  The rationale is
that (1) the dynamic loader may get adjusted on those systems as well in
the future; (2) passing an unused argument should not cause a problem
with existing resolvers; and (3) the logic is much simpler without such
a distinction.

gdb/ChangeLog:

	* elfread.c (auxv.h): New include.
	(elf_gnu_ifunc_resolve_addr): Pass HWCAP to ifunc resolver.

gdb/testsuite/ChangeLog:

	* gdb.base/gnu-ifunc-lib.c (resolver_hwcap): New external
	variable declaration.
	(gnu_ifunc): Add parameter hwcap.  Store it in resolver_hwcap.
	* gdb.base/gnu-ifunc.c (resolver_hwcap): New global variable.
	* gdb.base/gnu-ifunc.exp: Add test to verify that the resolver
	received HWCAP as its argument.
2016-09-09 19:59:53 +02:00
Tom Tromey 78cc6c2d9a Remove unused variables
This patch removes set-but-unused variables.  This holds all the
removals I consider to be simple and relatively uncontroversial.

2016-07-14  Tom Tromey  <tom@tromey.com>

	* mips-tdep.c (micromips_scan_prologue): Remove "frame_addr".
	(mips_o32_push_dummy_call): Remove "stack_used_p".
	* aarch64-tdep.c (aarch64_record_data_proc_imm): Remove
	"insn_bit28".
	* rust-lang.c (rust_print_type): Remove "len".
	* rust-exp.y (super_name): Remove "current_len".
	* python/py-framefilter.c (py_print_type): Remove "type".
	* mdebugread.c (parse_partial_symbols): Remove
	"past_first_source_file".
	<N_SO>: Remove "valu", "first_so_symnum", "prev_textlow_not_set".
	* m2-valprint.c (m2_print_unbounded_array): Remove
	"content_type".
	(m2_val_print): Remove "i".
	* linespec.c (unexpected_linespec_error): Remove "cleanup".
	* f-valprint.c (f_val_print): Remove "i".
	* elfread.c (elf_symtab_read): Remove "offset".
	* dwarf2-frame.c (dwarf2_fetch_cfa_info): Remove "addr_size".
	* jit.c (jit_dealloc_cache): Remove "i" and "frame_arch".
2016-07-14 10:35:40 -06:00
Pedro Alves c2f4122d5c Limit breakpoint re-set to the current program space
Currently, we always re-set all locations of all breakpoints.  This
commit makes us re-set only locations of the current program space.

If we loaded symbols to a program space (e.g., "file" command or some
shared library was loaded), GDB must run through all breakpoints and
determine if any new locations need to be added to the breakpoint.
However, there's no reason to recreate locations for _other_ program
spaces, as those haven't changed.

Similarly, when we create a new inferior, through e.g., a fork, GDB
must run through all breakpoints and determine if any new locations
need to be added to the breakpoint.  There's no reason to destroy the
locations of the parent inferior and other inferiors.  We know those
won't change.

In addition to being inneficient, resetting breakpoints of inferiors
that are currently running is problematic, because:

 - some targets can't read memory while the inferior is running.

 - the inferior might exit while we're re-setting its breakpoints,
   which may confuse prologue skipping.

I went through all the places where we call breakpoint_re_set, and it
seems to me that all can be changed to only re-set locations of the
current program space.

The patch that reversed threads order in "info threads" etc. happened
to make gdb.threads/fork-plus-thread.exp expose this problem when
testing on x86/-m32.  The problem was latent and masked out by chance
by the code-cache:

 https://sourceware.org/ml/gdb-patches/2016-01/msg00213.html

Tested on x86-64 F20, native (-m64/-m32) and extended-remote
gdbserver.

Fixes the regression discussed in the url above with --target_board=unix/-m32:

 -FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: inferior 1 exited
 +PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: inferior 1 exited
 -FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: no threads left (timeout)
 -FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: only inferior 1 left (the program exited)
 +PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: no threads left
 +PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: only inferior 1 left

gdb/ChangeLog:
2016-01-19  Pedro Alves  <palves@redhat.com>

	* ax-gdb.c (agent_command_1): Adjust call to decode_line_full.
	* break-catch-throw.c (re_set_exception_catchpoint): Pass the
	current program space down to linespec decoding and breakpoint
	location updating.
	* breakpoint.c (parse_breakpoint_sals): Adjust calls to
	decode_line_full.
	(until_break_command): Adjust calls to decode_line_1.
	(base_breakpoint_decode_location, bkpt_decode_location): Add
	'search_pspace' parameter.  Pass it along.
	(bkpt_probe_create_sals_from_location): Adjust calls to
	parse_probes.
	(tracepoint_decode_location, tracepoint_probe_decode_location)
	(strace_marker_decode_location): Add 'search_pspace' parameter.
	Pass it along.
	(all_locations_are_pending): Rewrite to take a breakpoint and
	program space as arguments instead.
	(hoist_existing_locations): New function.
	(update_breakpoint_locations): Add 'filter_pspace' parameter.  Use
	hoist_existing_locations instead of always removing all locations,
	and adjust to all_locations_are_pending change.
	(location_to_sals): Add 'search_pspace' parameter.  Pass it along.
	Don't disable the breakpoint if there are other locations in
	another program space.
	(breakpoint_re_set_default): Adjust to pass down the current
	program space as filter program space.
	(decode_location_default): Add 'search_pspace' parameter and pass
	it along.
	(prepare_re_set_context): Don't switch program space here.
	(breakpoint_re_set): Use save_current_space_and_thread instead of
	save_current_program_space.
	* breakpoint.h (struct breakpoint_ops) <decode_location>: Add
	'search_pspace' parameter.
	(update_breakpoint_locations): Add 'filter_pspace' parameter.
	* cli/cli-cmds.c (edit_command, list_command): Adjust calls to
	decode_line_1.
	* elfread.c (elf_gnu_ifunc_resolver_return_stop): Pass the current
	program space as filter program space.
	* linespec.c (struct linespec_state) <search_pspace>: New field.
	(create_sals_line_offset, convert_explicit_location_to_sals)
	(parse_linespec): Pass the search program space down.
	(linespec_state_constructor): Add 'search_pspace' parameter.
	Store it.
	(linespec_parser_new): Add 'search_pspace' parameter and pass it
	along.
	(linespec_lex_to_end): Adjust.
	(decode_line_full, decode_line_1): Add 'search_pspace' parameter
	and pass it along.
	(decode_line_with_last_displayed): Adjust.
	(collect_symtabs_from_filename, symtabs_from_filename): New
	'search_pspace' parameter.  Use it.
	(find_function_symbols): Pass the search program space down.
	* linespec.h (decode_line_1, decode_line_full): Add
	'search_pspace' parameter.
	* probe.c (parse_probes_in_pspace): New function, factored out
	from ...
	(parse_probes): ... this.  Add 'search_pspace' parameter and use
	it.
	* probe.h (parse_probes): Add pspace' parameter.
	* python/python.c (gdbpy_decode_line): Adjust.
	* tracepoint.c (scope_info): Adjust.
2016-01-19 12:18:14 +00:00
Pedro Alves 5d5658a1d3 Per-inferior/Inferior-qualified thread IDs
This commit changes GDB to track thread numbers per-inferior.  Then,
if you're debugging multiple inferiors, GDB displays
"inferior-num.thread-num" instead of just "thread-num" whenever it
needs to display a thread:

 (gdb) info inferiors
   Num  Description       Executable
   1    process 6022     /home/pedro/gdb/tests/threads
 * 2    process 6037     /home/pedro/gdb/tests/threads
 (gdb) info threads
   Id   Target Id         Frame
   1.1  Thread 0x7ffff7fc2740 (LWP 6022) "threads" (running)
   1.2  Thread 0x7ffff77c0700 (LWP 6028) "threads" (running)
   1.3  Thread 0x7ffff7fc2740 (LWP 6032) "threads" (running)
   2.1  Thread 0x7ffff7fc1700 (LWP 6037) "threads" (running)
   2.2  Thread 0x7ffff77c0700 (LWP 6038) "threads" (running)
 * 2.3  Thread 0x7ffff7fc2740 (LWP 6039) "threads" (running)
 (gdb)
...
 (gdb) thread 1.1
 [Switching to thread 1.1 (Thread 0x7ffff7fc2740 (LWP 8155))]
 (gdb)
...

etc.

You can still use "thread NUM", in which case GDB infers you're
referring to thread NUM of the current inferior.

The $_thread convenience var and Python's InferiorThread.num attribute
are remapped to the new per-inferior thread number.  It's a backward
compatibility break, but since it only matters when debugging multiple
inferiors, I think it's worth doing.

Because MI thread IDs need to be a single integer, we keep giving
threads a global identifier, _in addition_ to the per-inferior number,
and make MI always refer to the global thread IDs.  IOW, nothing
changes from a MI frontend's perspective.

Similarly, since Python's Breakpoint.thread and Guile's
breakpoint-thread/set-breakpoint-thread breakpoint methods need to
work with integers, those are adjusted to work with global thread IDs
too.  Follow up patches will provide convenient means to access
threads' global IDs.

To avoid potencially confusing users (which also avoids updating much
of the testsuite), if there's only one inferior and its ID is "1",
IOW, the user hasn't done anything multi-process/inferior related,
then the "INF." part of thread IDs is not shown.  E.g,.:

 (gdb) info inferiors
   Num  Description       Executable
 * 1    process 15275     /home/pedro/gdb/tests/threads
 (gdb) info threads
   Id   Target Id         Frame
 * 1    Thread 0x7ffff7fc1740 (LWP 15275) "threads" main () at threads.c:40
 (gdb) add-inferior
 Added inferior 2
 (gdb) info threads
   Id   Target Id         Frame
 * 1.1  Thread 0x7ffff7fc1740 (LWP 15275) "threads" main () at threads.c:40
 (gdb)

No regressions on x86_64 Fedora 20.

gdb/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention that thread IDs are now per inferior and global
	thread IDs.
	* Makefile.in (SFILES): Add tid-parse.c.
	(COMMON_OBS): Add tid-parse.o.
	(HFILES_NO_SRCDIR): Add tid-parse.h.
	* ada-tasks.c: Adjust to use ptid_to_global_thread_id.
	* breakpoint.c (insert_breakpoint_locations)
	(remove_threaded_breakpoints, bpstat_check_breakpoint_conditions)
	(print_one_breakpoint_location, set_longjmp_breakpoint)
	(check_longjmp_breakpoint_for_call_dummy)
	(set_momentary_breakpoint): Adjust to use global IDs.
	(find_condition_and_thread, watch_command_1): Use parse_thread_id.
	(until_break_command, longjmp_bkpt_dtor)
	(breakpoint_re_set_thread, insert_single_step_breakpoint): Adjust
	to use global IDs.
	* dummy-frame.c (pop_dummy_frame_bpt): Adjust to use
	ptid_to_global_thread_id.
	* elfread.c (elf_gnu_ifunc_resolver_stop): Likewise.
	* gdbthread.h (struct thread_info): Rename field 'num' to
	'global_num.  Add new fields 'per_inf_num' and 'inf'.
	(thread_id_to_pid): Rename thread_id_to_pid to
	global_thread_id_to_ptid.
	(pid_to_thread_id): Rename to ...
	(ptid_to_global_thread_id): ... this.
	(valid_thread_id): Rename to ...
	(valid_global_thread_id): ... this.
	(find_thread_id): Rename to ...
	(find_thread_global_id): ... this.
	(ALL_THREADS, ALL_THREADS_BY_INFERIOR): Declare.
	(print_thread_info): Add comment.
	* tid-parse.h: New file.
	* tid-parse.c: New file.
	* infcmd.c (step_command_fsm_prepare)
	(step_command_fsm_should_stop): Adjust to use the global thread
	ID.
	(until_next_command, until_next_command)
	(finish_command_fsm_should_stop): Adjust to use the global thread
	ID.
	(attach_post_wait): Adjust to check the inferior number too.
	* inferior.h (struct inferior) <highest_thread_num>: New field.
	* infrun.c (handle_signal_stop)
	(insert_exception_resume_breakpoint)
	(insert_exception_resume_from_probe): Adjust to use the global
	thread ID.
	* record-btrace.c (record_btrace_open): Use global thread IDs.
	* remote.c (process_initial_stop_replies): Also consider the
	inferior number.
	* target.c (target_pre_inferior): Clear the inferior's highest
	thread num.
	* thread.c (clear_thread_inferior_resources): Adjust to use the
	global thread ID.
	(new_thread): New inferior parameter.  Adjust to use it.  Set both
	the thread's global ID and the thread's per-inferior ID.
	(add_thread_silent): Adjust.
	(find_thread_global_id): New.
	(find_thread_id): Make static.  Adjust to rename.
	(valid_thread_id): Rename to ...
	(valid_global_thread_id): ... this.
	(pid_to_thread_id): Rename to ...
	(ptid_to_global_thread_id): ... this.
	(thread_id_to_pid): Rename to ...
	(global_thread_id_to_ptid): ... this.  Adjust.
	(first_thread_of_process): Adjust.
	(do_captured_list_thread_ids): Adjust to use global thread IDs.
	(should_print_thread): New function.
	(print_thread_info): Rename to ...
	(print_thread_info_1): ... this, and add new show_global_ids
	parameter.  Handle it.  Iterate over inferiors.
	(print_thread_info): Reimplement as wrapper around
	print_thread_info_1.
	(show_inferior_qualified_tids): New function.
	(print_thread_id): Use it.
	(tp_array_compar): Compare inferior numbers too.
	(thread_apply_command): Use tid_range_parser.
	(do_captured_thread_select): Use parse_thread_id.
	(thread_id_make_value): Adjust.
	(_initialize_thread): Adjust "info threads" help string.
	* varobj.c (struct varobj_root): Update comment.
	(varobj_create): Adjust to use global thread IDs.
	(value_of_root_1): Adjust to use global_thread_id_to_ptid.
	* windows-tdep.c (display_tib): No longer accept an argument.
	* cli/cli-utils.c (get_number_trailer): Make extern.
	* cli/cli-utils.h (get_number_trailer): Declare.
	(get_number_const): Adjust documentation.
	* mi/mi-cmd-var.c (mi_cmd_var_update_iter): Adjust to use global
	thread IDs.
	* mi/mi-interp.c (mi_new_thread, mi_thread_exit)
	(mi_on_normal_stop, mi_output_running_pid, mi_on_resume):
	* mi/mi-main.c (mi_execute_command, mi_cmd_execute): Likewise.
	* guile/scm-breakpoint.c (gdbscm_set_breakpoint_thread_x):
	Likewise.
	* python/py-breakpoint.c (bppy_set_thread): Likewise.
	* python/py-finishbreakpoint.c (bpfinishpy_init): Likewise.
	* python/py-infthread.c (thpy_get_num): Add comment and return the
	per-inferior thread ID.
	(thread_object_getset): Update comment of "num".

gdb/testsuite/ChangeLog:
2016-01-07  Pedro Alves  <palves@redhat.com>

	* gdb.base/break.exp: Adjust to output changes.
	* gdb.base/hbreak2.exp: Likewise.
	* gdb.base/sepdebug.exp: Likewise.
	* gdb.base/watch_thread_num.exp: Likewise.
	* gdb.linespec/keywords.exp: Likewise.
	* gdb.multi/info-threads.exp: Likewise.
	* gdb.threads/thread-find.exp: Likewise.
	* gdb.multi/tids.c: New file.
	* gdb.multi/tids.exp: New file.

gdb/doc/ChangeLog:
2016-01-07  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Threads): Document per-inferior thread IDs,
	qualified thread IDs, global thread IDs and thread ID lists.
	(Set Watchpoints, Thread-Specific Breakpoints): Adjust to refer to
	thread IDs.
	(Convenience Vars): Document the $_thread convenience variable.
	(Ada Tasks): Adjust to refer to thread IDs.
	(GDB/MI Async Records, GDB/MI Thread Commands, GDB/MI Ada Tasking
	Commands, GDB/MI Variable Objects): Update to mention global
	thread IDs.
	* guile.texi (Breakpoints In Guile)
	<breakpoint-thread/set-breakpoint-thread breakpoint>: Mention
	global thread IDs instead of thread IDs.
	* python.texi (Threads In Python): Adjust documentation of
	InferiorThread.num.
	(Breakpoint.thread): Mention global thread IDs instead of thread
	IDs.
2016-01-13 10:59:43 +00:00
Joel Brobecker 618f726fcb GDB copyright headers update after running GDB's copyright.py script.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2016-01-01 08:43:22 +04:00
Simon Marchi 9a3c826307 Add some more casts (1/2)
Note: I needed to split this patch in two, otherwise it's too big for
the mailing list.

This patch adds explicit casts to situations where a void pointer is
assigned to a pointer to the "real" type.  Building in C++ mode requires
those assignments to use an explicit cast.  This includes, for example:

 - callback arguments (cleanups, comparison functions, ...)
 - data attached to some object (objfile, program space, etc) in the form
   of a void pointer
 - "user data" passed to some function

This patch comes from the commit "(mostly) auto-generated patch to insert
casts needed for C++", taken from Pedro's C++ branch.

Only files built on x86 with --enable-targets=all are modified, so the
native files for other arches will need to be dealt with separately.

I built-tested this with --enable-targets=all and reg-tested.  To my
surprise, a test case (selftest.exp) had to be adjusted.

Here's the ChangeLog entry.  Again, this was relatively quick to make
despite the length, thanks to David Malcom's script, although I don't
believe it's very useful information in that particular case...

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_make_prologue_cache): Add cast(s).
	(aarch64_make_stub_cache): Likewise.
	(value_of_aarch64_user_reg): Likewise.
	* ada-lang.c (ada_inferior_data_cleanup): Likewise.
	(get_ada_inferior_data): Likewise.
	(get_ada_pspace_data): Likewise.
	(ada_pspace_data_cleanup): Likewise.
	(ada_complete_symbol_matcher): Likewise.
	(ada_exc_search_name_matches): Likewise.
	* ada-tasks.c (get_ada_tasks_pspace_data): Likewise.
	(get_ada_tasks_inferior_data): Likewise.
	* addrmap.c (addrmap_mutable_foreach_worker): Likewise.
	(splay_obstack_alloc): Likewise.
	(splay_obstack_free): Likewise.
	* alpha-linux-tdep.c (alpha_linux_supply_gregset): Likewise.
	(alpha_linux_collect_gregset): Likewise.
	(alpha_linux_supply_fpregset): Likewise.
	(alpha_linux_collect_fpregset): Likewise.
	* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Likewise.
	* alpha-tdep.c (alpha_lds): Likewise.
	(alpha_sts): Likewise.
	(alpha_sigtramp_frame_unwind_cache): Likewise.
	(alpha_heuristic_frame_unwind_cache): Likewise.
	(alpha_supply_int_regs): Likewise.
	(alpha_fill_int_regs): Likewise.
	(alpha_supply_fp_regs): Likewise.
	(alpha_fill_fp_regs): Likewise.
	* alphanbsd-tdep.c (alphanbsd_supply_fpregset): Likewise.
	(alphanbsd_aout_supply_gregset): Likewise.
	(alphanbsd_supply_gregset): Likewise.
	* amd64-linux-tdep.c (amd64_linux_init_abi): Likewise.
	(amd64_x32_linux_init_abi): Likewise.
	* amd64-nat.c (amd64_supply_native_gregset): Likewise.
	(amd64_collect_native_gregset): Likewise.
	* amd64-tdep.c (amd64_frame_cache): Likewise.
	(amd64_sigtramp_frame_cache): Likewise.
	(amd64_epilogue_frame_cache): Likewise.
	(amd64_supply_fxsave): Likewise.
	(amd64_supply_xsave): Likewise.
	(amd64_collect_fxsave): Likewise.
	(amd64_collect_xsave): Likewise.
	* amd64-windows-tdep.c (amd64_windows_frame_cache): Likewise.
	* amd64obsd-tdep.c (amd64obsd_trapframe_cache): Likewise.
	* arm-linux-tdep.c (arm_linux_supply_gregset): Likewise.
	(arm_linux_collect_gregset): Likewise.
	(arm_linux_supply_nwfpe): Likewise.
	(arm_linux_collect_nwfpe): Likewise.
	(arm_linux_supply_vfp): Likewise.
	(arm_linux_collect_vfp): Likewise.
	* arm-tdep.c (arm_find_mapping_symbol): Likewise.
	(arm_prologue_unwind_stop_reason): Likewise.
	(arm_prologue_this_id): Likewise.
	(arm_prologue_prev_register): Likewise.
	(arm_exidx_data_free): Likewise.
	(arm_find_exidx_entry): Likewise.
	(arm_stub_this_id): Likewise.
	(arm_m_exception_this_id): Likewise.
	(arm_m_exception_prev_register): Likewise.
	(arm_normal_frame_base): Likewise.
	(gdb_print_insn_arm): Likewise.
	(arm_objfile_data_free): Likewise.
	(arm_record_special_symbol): Likewise.
	(value_of_arm_user_reg): Likewise.
	* armbsd-tdep.c (armbsd_supply_fpregset): Likewise.
	(armbsd_supply_gregset): Likewise.
	* auto-load.c (auto_load_pspace_data_cleanup): Likewise.
	(get_auto_load_pspace_data): Likewise.
	(hash_loaded_script_entry): Likewise.
	(eq_loaded_script_entry): Likewise.
	(clear_section_scripts): Likewise.
	(collect_matching_scripts): Likewise.
	* auxv.c (auxv_inferior_data_cleanup): Likewise.
	(get_auxv_inferior_data): Likewise.
	* avr-tdep.c (avr_frame_unwind_cache): Likewise.
	* ax-general.c (do_free_agent_expr_cleanup): Likewise.
	* bfd-target.c (target_bfd_xfer_partial): Likewise.
	(target_bfd_xclose): Likewise.
	(target_bfd_get_section_table): Likewise.
	* bfin-tdep.c (bfin_frame_cache): Likewise.
	* block.c (find_block_in_blockvector): Likewise.
	(call_site_for_pc): Likewise.
	(block_find_non_opaque_type_preferred): Likewise.
	* break-catch-sig.c (signal_catchpoint_insert_location): Likewise.
	(signal_catchpoint_remove_location): Likewise.
	(signal_catchpoint_breakpoint_hit): Likewise.
	(signal_catchpoint_print_one): Likewise.
	(signal_catchpoint_print_mention): Likewise.
	(signal_catchpoint_print_recreate): Likewise.
	* break-catch-syscall.c (get_catch_syscall_inferior_data): Likewise.
	* breakpoint.c (do_cleanup_counted_command_line): Likewise.
	(bp_location_compare_addrs): Likewise.
	(get_first_locp_gte_addr): Likewise.
	(check_tracepoint_command): Likewise.
	(do_map_commands_command): Likewise.
	(get_breakpoint_objfile_data): Likewise.
	(free_breakpoint_probes): Likewise.
	(do_captured_breakpoint_query): Likewise.
	(compare_breakpoints): Likewise.
	(bp_location_compare): Likewise.
	(bpstat_remove_breakpoint_callback): Likewise.
	(do_delete_breakpoint_cleanup): Likewise.
	* bsd-uthread.c (bsd_uthread_set_supply_uthread): Likewise.
	(bsd_uthread_set_collect_uthread): Likewise.
	(bsd_uthread_activate): Likewise.
	(bsd_uthread_fetch_registers): Likewise.
	(bsd_uthread_store_registers): Likewise.
	* btrace.c (check_xml_btrace_version): Likewise.
	(parse_xml_btrace_block): Likewise.
	(parse_xml_btrace_pt_config_cpu): Likewise.
	(parse_xml_btrace_pt_raw): Likewise.
	(parse_xml_btrace_pt): Likewise.
	(parse_xml_btrace_conf_bts): Likewise.
	(parse_xml_btrace_conf_pt): Likewise.
	(do_btrace_data_cleanup): Likewise.
	* c-typeprint.c (find_typedef_for_canonicalize): Likewise.
	* charset.c (cleanup_iconv): Likewise.
	(do_cleanup_iterator): Likewise.
	* cli-out.c (cli_uiout_dtor): Likewise.
	(cli_table_begin): Likewise.
	(cli_table_body): Likewise.
	(cli_table_end): Likewise.
	(cli_table_header): Likewise.
	(cli_begin): Likewise.
	(cli_end): Likewise.
	(cli_field_int): Likewise.
	(cli_field_skip): Likewise.
	(cli_field_string): Likewise.
	(cli_field_fmt): Likewise.
	(cli_spaces): Likewise.
	(cli_text): Likewise.
	(cli_message): Likewise.
	(cli_wrap_hint): Likewise.
	(cli_flush): Likewise.
	(cli_redirect): Likewise.
	(out_field_fmt): Likewise.
	(field_separator): Likewise.
	(cli_out_set_stream): Likewise.
	* cli/cli-cmds.c (compare_symtabs): Likewise.
	* cli/cli-dump.c (call_dump_func): Likewise.
	(restore_section_callback): Likewise.
	* cli/cli-script.c (clear_hook_in_cleanup): Likewise.
	(do_restore_user_call_depth): Likewise.
	(do_free_command_lines_cleanup): Likewise.
	* coff-pe-read.c (get_section_vmas): Likewise.
	(pe_as16): Likewise.
	(pe_as32): Likewise.
	* coffread.c (coff_symfile_read): Likewise.
	* common/agent.c (agent_look_up_symbols): Likewise.
	* common/filestuff.c (do_close_cleanup): Likewise.
	* common/format.c (free_format_pieces_cleanup): Likewise.
	* common/vec.c (vec_o_reserve): Likewise.
	* compile/compile-c-support.c (print_one_macro): Likewise.
	* compile/compile-c-symbols.c (hash_symbol_error): Likewise.
	(eq_symbol_error): Likewise.
	(del_symbol_error): Likewise.
	(error_symbol_once): Likewise.
	(gcc_convert_symbol): Likewise.
	(gcc_symbol_address): Likewise.
	(hash_symname): Likewise.
	(eq_symname): Likewise.
	* compile/compile-c-types.c (hash_type_map_instance): Likewise.
	(eq_type_map_instance): Likewise.
	(insert_type): Likewise.
	(convert_type): Likewise.
	* compile/compile-object-load.c (munmap_listp_free_cleanup): Likewise.
	(setup_sections): Likewise.
	(link_hash_table_free): Likewise.
	(copy_sections): Likewise.
	* compile/compile-object-run.c (do_module_cleanup): Likewise.
	* compile/compile.c (compile_print_value): Likewise.
	(do_rmdir): Likewise.
	(cleanup_compile_instance): Likewise.
	(cleanup_unlink_file): Likewise.
	* completer.c (free_completion_tracker): Likewise.
	* corelow.c (add_to_spuid_list): Likewise.
	* cp-namespace.c (reset_directive_searched): Likewise.
	* cp-support.c (reset_directive_searched): Likewise.
	* cris-tdep.c (cris_sigtramp_frame_unwind_cache): Likewise.
	(cris_frame_unwind_cache): Likewise.
	* d-lang.c (builtin_d_type): Likewise.
	* d-namespace.c (reset_directive_searched): Likewise.
	* dbxread.c (dbx_free_symfile_info): Likewise.
	(do_free_bincl_list_cleanup): Likewise.
	* disasm.c (hash_dis_line_entry): Likewise.
	(eq_dis_line_entry): Likewise.
	(dis_asm_print_address): Likewise.
	(fprintf_disasm): Likewise.
	(do_ui_file_delete): Likewise.
	* doublest.c (convert_floatformat_to_doublest): Likewise.
	* dummy-frame.c (pop_dummy_frame_bpt): Likewise.
	(dummy_frame_prev_register): Likewise.
	(dummy_frame_this_id): Likewise.
	* dwarf2-frame-tailcall.c (cache_hash): Likewise.
	(cache_eq): Likewise.
	(cache_find): Likewise.
	(tailcall_frame_this_id): Likewise.
	(dwarf2_tailcall_prev_register_first): Likewise.
	(tailcall_frame_prev_register): Likewise.
	(tailcall_frame_dealloc_cache): Likewise.
	(tailcall_frame_prev_arch): Likewise.
	* dwarf2-frame.c (dwarf2_frame_state_free): Likewise.
	(dwarf2_frame_set_init_reg): Likewise.
	(dwarf2_frame_init_reg): Likewise.
	(dwarf2_frame_set_signal_frame_p): Likewise.
	(dwarf2_frame_signal_frame_p): Likewise.
	(dwarf2_frame_set_adjust_regnum): Likewise.
	(dwarf2_frame_adjust_regnum): Likewise.
	(clear_pointer_cleanup): Likewise.
	(dwarf2_frame_cache): Likewise.
	(find_cie): Likewise.
	(dwarf2_frame_find_fde): Likewise.
	* dwarf2expr.c (dwarf_expr_address_type): Likewise.
	(free_dwarf_expr_context_cleanup): Likewise.
	* dwarf2loc.c (locexpr_find_frame_base_location): Likewise.
	(locexpr_get_frame_base): Likewise.
	(loclist_find_frame_base_location): Likewise.
	(loclist_get_frame_base): Likewise.
	(dwarf_expr_dwarf_call): Likewise.
	(dwarf_expr_get_base_type): Likewise.
	(dwarf_expr_push_dwarf_reg_entry_value): Likewise.
	(dwarf_expr_get_obj_addr): Likewise.
	(entry_data_value_coerce_ref): Likewise.
	(entry_data_value_copy_closure): Likewise.
	(entry_data_value_free_closure): Likewise.
	(get_frame_address_in_block_wrapper): Likewise.
	(dwarf2_evaluate_property): Likewise.
	(dwarf2_compile_property_to_c): Likewise.
	(needs_frame_read_addr_from_reg): Likewise.
	(needs_frame_get_reg_value): Likewise.
	(needs_frame_frame_base): Likewise.
	(needs_frame_frame_cfa): Likewise.
	(needs_frame_tls_address): Likewise.
	(needs_frame_dwarf_call): Likewise.
	(needs_dwarf_reg_entry_value): Likewise.
	(get_ax_pc): Likewise.
	(locexpr_read_variable): Likewise.
	(locexpr_read_variable_at_entry): Likewise.
	(locexpr_read_needs_frame): Likewise.
	(locexpr_describe_location): Likewise.
	(locexpr_tracepoint_var_ref): Likewise.
	(locexpr_generate_c_location): Likewise.
	(loclist_read_variable): Likewise.
	(loclist_read_variable_at_entry): Likewise.
	(loclist_describe_location): Likewise.
	(loclist_tracepoint_var_ref): Likewise.
	(loclist_generate_c_location): Likewise.
	* dwarf2read.c (line_header_hash_voidp): Likewise.
	(line_header_eq_voidp): Likewise.
	(dwarf2_has_info): Likewise.
	(dwarf2_get_section_info): Likewise.
	(locate_dwz_sections): Likewise.
	(hash_file_name_entry): Likewise.
	(eq_file_name_entry): Likewise.
	(delete_file_name_entry): Likewise.
	(dw2_setup): Likewise.
	(dw2_get_file_names_reader): Likewise.
	(dw2_find_pc_sect_compunit_symtab): Likewise.
	(hash_signatured_type): Likewise.
	(eq_signatured_type): Likewise.
	(add_signatured_type_cu_to_table): Likewise.
	(create_debug_types_hash_table): Likewise.
	(lookup_dwo_signatured_type): Likewise.
	(lookup_dwp_signatured_type): Likewise.
	(lookup_signatured_type): Likewise.
	(hash_type_unit_group): Likewise.
	(eq_type_unit_group): Likewise.
	(get_type_unit_group): Likewise.
	(process_psymtab_comp_unit_reader): Likewise.
	(sort_tu_by_abbrev_offset): Likewise.
	(process_skeletonless_type_unit): Likewise.
	(psymtabs_addrmap_cleanup): Likewise.
	(dwarf2_read_symtab): Likewise.
	(psymtab_to_symtab_1): Likewise.
	(die_hash): Likewise.
	(die_eq): Likewise.
	(load_full_comp_unit_reader): Likewise.
	(reset_die_in_process): Likewise.
	(free_cu_line_header): Likewise.
	(handle_DW_AT_stmt_list): Likewise.
	(hash_dwo_file): Likewise.
	(eq_dwo_file): Likewise.
	(hash_dwo_unit): Likewise.
	(eq_dwo_unit): Likewise.
	(create_dwo_cu_reader): Likewise.
	(create_dwo_unit_in_dwp_v1): Likewise.
	(create_dwo_unit_in_dwp_v2): Likewise.
	(lookup_dwo_unit_in_dwp): Likewise.
	(dwarf2_locate_dwo_sections): Likewise.
	(dwarf2_locate_common_dwp_sections): Likewise.
	(dwarf2_locate_v2_dwp_sections): Likewise.
	(hash_dwp_loaded_cutus): Likewise.
	(eq_dwp_loaded_cutus): Likewise.
	(lookup_dwo_cutu): Likewise.
	(abbrev_table_free_cleanup): Likewise.
	(dwarf2_free_abbrev_table): Likewise.
	(find_partial_die_in_comp_unit): Likewise.
	(free_line_header_voidp): Likewise.
	(follow_die_offset): Likewise.
	(follow_die_sig_1): Likewise.
	(free_heap_comp_unit): Likewise.
	(free_stack_comp_unit): Likewise.
	(dwarf2_free_objfile): Likewise.
	(per_cu_offset_and_type_hash): Likewise.
	(per_cu_offset_and_type_eq): Likewise.
	(get_die_type_at_offset): Likewise.
	(partial_die_hash): Likewise.
	(partial_die_eq): Likewise.
	(dwarf2_per_objfile_free): Likewise.
	(hash_strtab_entry): Likewise.
	(eq_strtab_entry): Likewise.
	(add_string): Likewise.
	(hash_symtab_entry): Likewise.
	(eq_symtab_entry): Likewise.
	(delete_symtab_entry): Likewise.
	(cleanup_mapped_symtab): Likewise.
	(add_indices_to_cpool): Likewise.
	(hash_psymtab_cu_index): Likewise.
	(eq_psymtab_cu_index): Likewise.
	(add_address_entry_worker): Likewise.
	(unlink_if_set): Likewise.
	(write_one_signatured_type): Likewise.
	(save_gdb_index_command): Likewise.
	* elfread.c (elf_symtab_read): Likewise.
	(elf_gnu_ifunc_cache_hash): Likewise.
	(elf_gnu_ifunc_cache_eq): Likewise.
	(elf_gnu_ifunc_record_cache): Likewise.
	(elf_gnu_ifunc_resolve_by_cache): Likewise.
	(elf_get_probes): Likewise.
	(probe_key_free): Likewise.
	* f-lang.c (builtin_f_type): Likewise.
	* frame-base.c (frame_base_append_sniffer): Likewise.
	(frame_base_set_default): Likewise.
	(frame_base_find_by_frame): Likewise.
	* frame-unwind.c (frame_unwind_prepend_unwinder): Likewise.
	(frame_unwind_append_unwinder): Likewise.
	(frame_unwind_find_by_frame): Likewise.
	* frame.c (frame_addr_hash): Likewise.
	(frame_addr_hash_eq): Likewise.
	(frame_stash_find): Likewise.
	(do_frame_register_read): Likewise.
	(unwind_to_current_frame): Likewise.
	(frame_cleanup_after_sniffer): Likewise.
	* frv-linux-tdep.c (frv_linux_sigtramp_frame_cache): Likewise.
	* frv-tdep.c (frv_frame_unwind_cache): Likewise.
	* ft32-tdep.c (ft32_frame_cache): Likewise.
	* gcore.c (do_bfd_delete_cleanup): Likewise.
	(gcore_create_callback): Likewise.
	* gdb_bfd.c (hash_bfd): Likewise.
	(eq_bfd): Likewise.
	(gdb_bfd_open): Likewise.
	(free_one_bfd_section): Likewise.
	(gdb_bfd_ref): Likewise.
	(gdb_bfd_unref): Likewise.
	(get_section_descriptor): Likewise.
	(gdb_bfd_map_section): Likewise.
	(gdb_bfd_crc): Likewise.
	(gdb_bfd_mark_parent): Likewise.
	(gdb_bfd_record_inclusion): Likewise.
	(gdb_bfd_requires_relocations): Likewise.
	(print_one_bfd): Likewise.
	* gdbtypes.c (type_pair_hash): Likewise.
	(type_pair_eq): Likewise.
	(builtin_type): Likewise.
	(objfile_type): Likewise.
	* gnu-v3-abi.c (vtable_ptrdiff_type): Likewise.
	(vtable_address_point_offset): Likewise.
	(gnuv3_get_vtable): Likewise.
	(hash_value_and_voffset): Likewise.
	(eq_value_and_voffset): Likewise.
	(compare_value_and_voffset): Likewise.
	(compute_vtable_size): Likewise.
	(gnuv3_get_typeid_type): Likewise.
	* go-lang.c (builtin_go_type): Likewise.
	* guile/scm-block.c (bkscm_hash_block_smob): Likewise.
	(bkscm_eq_block_smob): Likewise.
	(bkscm_objfile_block_map): Likewise.
	(bkscm_del_objfile_blocks): Likewise.
	* guile/scm-breakpoint.c (bpscm_build_bp_list): Likewise.
	* guile/scm-disasm.c (gdbscm_disasm_read_memory_worker): Likewise.
	(gdbscm_disasm_print_address): Likewise.
	* guile/scm-frame.c (frscm_hash_frame_smob): Likewise.
	(frscm_eq_frame_smob): Likewise.
	(frscm_inferior_frame_map): Likewise.
	(frscm_del_inferior_frames): Likewise.
	* guile/scm-gsmob.c (gdbscm_add_objfile_ref): Likewise.
	* guile/scm-objfile.c (ofscm_handle_objfile_deleted): Likewise.
	(ofscm_objfile_smob_from_objfile): Likewise.
	* guile/scm-ports.c (ioscm_write): Likewise.
	(ioscm_file_port_delete): Likewise.
	(ioscm_file_port_rewind): Likewise.
	(ioscm_file_port_put): Likewise.
	(ioscm_file_port_write): Likewise.
	* guile/scm-progspace.c (psscm_handle_pspace_deleted): Likewise.
	(psscm_pspace_smob_from_pspace): Likewise.
	* guile/scm-safe-call.c (scscm_recording_pre_unwind_handler): Likewise.
	(scscm_recording_unwind_handler): Likewise.
	(gdbscm_with_catch): Likewise.
	(scscm_call_0_body): Likewise.
	(scscm_call_1_body): Likewise.
	(scscm_call_2_body): Likewise.
	(scscm_call_3_body): Likewise.
	(scscm_call_4_body): Likewise.
	(scscm_apply_1_body): Likewise.
	(scscm_eval_scheme_string): Likewise.
	(gdbscm_safe_eval_string): Likewise.
	(scscm_source_scheme_script): Likewise.
	(gdbscm_safe_source_script): Likewise.
	* guile/scm-string.c (gdbscm_call_scm_to_stringn): Likewise.
	(gdbscm_call_scm_from_stringn): Likewise.
	* guile/scm-symbol.c (syscm_hash_symbol_smob): Likewise.
	(syscm_eq_symbol_smob): Likewise.
	(syscm_get_symbol_map): Likewise.
	(syscm_del_objfile_symbols): Likewise.
	* guile/scm-symtab.c (stscm_hash_symtab_smob): Likewise.
	(stscm_eq_symtab_smob): Likewise.
	(stscm_objfile_symtab_map): Likewise.
	(stscm_del_objfile_symtabs): Likewise.
	* guile/scm-type.c (tyscm_hash_type_smob): Likewise.
	(tyscm_eq_type_smob): Likewise.
	(tyscm_type_map): Likewise.
	(tyscm_copy_type_recursive): Likewise.
	(save_objfile_types): Likewise.
	* guile/scm-utils.c (extract_arg): Likewise.
	* h8300-tdep.c (h8300_frame_cache): Likewise.
	* hppa-linux-tdep.c (hppa_linux_sigtramp_frame_unwind_cache): Likewise.
	* hppa-tdep.c (compare_unwind_entries): Likewise.
	(find_unwind_entry): Likewise.
	(hppa_frame_cache): Likewise.
	(hppa_stub_frame_unwind_cache): Likewise.
	* hppanbsd-tdep.c (hppanbsd_supply_gregset): Likewise.
	* hppaobsd-tdep.c (hppaobsd_supply_gregset): Likewise.
	(hppaobsd_supply_fpregset): Likewise.
	* i386-cygwin-tdep.c (core_process_module_section): Likewise.
	* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
	* i386-tdep.c (i386_frame_cache): Likewise.
	(i386_epilogue_frame_cache): Likewise.
	(i386_sigtramp_frame_cache): Likewise.
	(i386_supply_gregset): Likewise.
	(i386_collect_gregset): Likewise.
	(i386_gdbarch_init): Likewise.
	* i386obsd-tdep.c (i386obsd_aout_supply_regset): Likewise.
	(i386obsd_trapframe_cache): Likewise.
	* i387-tdep.c (i387_supply_fsave): Likewise.
	(i387_collect_fsave): Likewise.
	(i387_supply_fxsave): Likewise.
	(i387_collect_fxsave): Likewise.
	(i387_supply_xsave): Likewise.
	(i387_collect_xsave): Likewise.
	* ia64-tdep.c (ia64_frame_cache): Likewise.
	(ia64_sigtramp_frame_cache): Likewise.
	* infcmd.c (attach_command_continuation): Likewise.
	(attach_command_continuation_free_args): Likewise.
	* inferior.c (restore_inferior): Likewise.
	(delete_thread_of_inferior): Likewise.
	* inflow.c (inflow_inferior_data_cleanup): Likewise.
	(get_inflow_inferior_data): Likewise.
	(inflow_inferior_exit): Likewise.
	* infrun.c (displaced_step_clear_cleanup): Likewise.
	(restore_current_uiout_cleanup): Likewise.
	(release_stop_context_cleanup): Likewise.
	(do_restore_infcall_suspend_state_cleanup): Likewise.
	(do_restore_infcall_control_state_cleanup): Likewise.
	(restore_inferior_ptid): Likewise.
	* inline-frame.c (block_starting_point_at): Likewise.
	* iq2000-tdep.c (iq2000_frame_cache): Likewise.
	* jit.c (get_jit_objfile_data): Likewise.
	(get_jit_program_space_data): Likewise.
	(jit_object_close_impl): Likewise.
	(jit_find_objf_with_entry_addr): Likewise.
	(jit_breakpoint_deleted): Likewise.
	(jit_unwind_reg_set_impl): Likewise.
	(jit_unwind_reg_get_impl): Likewise.
	(jit_dealloc_cache): Likewise.
	(jit_frame_sniffer): Likewise.
	(jit_frame_prev_register): Likewise.
	(jit_prepend_unwinder): Likewise.
	(jit_inferior_exit_hook): Likewise.
	(free_objfile_data): Likewise.
	* jv-lang.c (jv_per_objfile_free): Likewise.
	(get_dynamics_objfile): Likewise.
	(get_java_class_symtab): Likewise.
	(builtin_java_type): Likewise.
	* language.c (language_string_char_type): Likewise.
	(language_bool_type): Likewise.
	(language_lookup_primitive_type): Likewise.
	(language_lookup_primitive_type_as_symbol): Likewise.
	* linespec.c (hash_address_entry): Likewise.
	(eq_address_entry): Likewise.
	(iterate_inline_only): Likewise.
	(iterate_name_matcher): Likewise.
	(decode_line_2_compare_items): Likewise.
	(collect_one_symbol): Likewise.
	(compare_symbols): Likewise.
	(compare_msymbols): Likewise.
	(add_symtabs_to_list): Likewise.
	(collect_symbols): Likewise.
	(compare_msyms): Likewise.
	(add_minsym): Likewise.
	(cleanup_linespec_result): Likewise.
	* linux-fork.c (inferior_call_waitpid_cleanup): Likewise.
	* linux-nat.c (delete_lwp_cleanup): Likewise.
	(count_events_callback): Likewise.
	(select_event_lwp_callback): Likewise.
	(resume_stopped_resumed_lwps): Likewise.
	* linux-tdep.c (get_linux_gdbarch_data): Likewise.
	(invalidate_linux_cache_inf): Likewise.
	(get_linux_inferior_data): Likewise.
	(linux_find_memory_regions_thunk): Likewise.
	(linux_make_mappings_callback): Likewise.
	(linux_corefile_thread_callback): Likewise.
	(find_mapping_size): Likewise.
	* linux-thread-db.c (find_new_threads_callback): Likewise.
	* lm32-tdep.c (lm32_frame_cache): Likewise.
	* m2-lang.c (builtin_m2_type): Likewise.
	* m32c-tdep.c (m32c_analyze_frame_prologue): Likewise.
	* m32r-linux-tdep.c (m32r_linux_sigtramp_frame_cache): Likewise.
	(m32r_linux_supply_gregset): Likewise.
	(m32r_linux_collect_gregset): Likewise.
	* m32r-tdep.c (m32r_frame_unwind_cache): Likewise.
	* m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
	* m68k-tdep.c (m68k_frame_cache): Likewise.
	* m68kbsd-tdep.c (m68kbsd_supply_fpregset): Likewise.
	(m68kbsd_supply_gregset): Likewise.
	* m68klinux-tdep.c (m68k_linux_sigtramp_frame_cache): Likewise.
	* m88k-tdep.c (m88k_frame_cache): Likewise.
	(m88k_supply_gregset): Likewise.

gdb/gdbserver/ChangeLog:

	* dll.c (match_dll): Add cast(s).
	(unloaded_dll): Likewise.
	* linux-low.c (second_thread_of_pid_p): Likewise.
	(delete_lwp_callback): Likewise.
	(count_events_callback): Likewise.
	(select_event_lwp_callback): Likewise.
	(linux_set_resume_request): Likewise.
	* server.c (accumulate_file_name_length): Likewise.
	(emit_dll_description): Likewise.
	(handle_qxfer_threads_worker): Likewise.
	(visit_actioned_threads): Likewise.
	* thread-db.c (any_thread_of): Likewise.
	* tracepoint.c (same_process_p): Likewise.
	(match_blocktype): Likewise.
	(build_traceframe_info_xml): Likewise.

gdb/testsuite/ChangeLog:

	* gdb.gdb/selftest.exp (do_steps_and_nexts): Adjust expected
	source line.
2015-09-25 14:08:07 -04:00
Simon Marchi 224c3ddb89 Add casts to memory allocation related calls
Most allocation functions (if not all) return a void* pointing to the
allocated memory.  In C++, we need to add an explicit cast when
assigning the result to a pointer to another type (which is the case
more often than not).

The content of this patch is taken from Pedro's branch, from commit
"(mostly) auto-generated patch to insert casts needed for C++".  I
validated that the changes make sense and manually reflowed the code to
make it respect the coding style.  I also found multiple places where I
could use XNEW/XNEWVEC/XRESIZEVEC/etc.

Thanks a lot to whoever did that automated script to insert casts, doing
it completely by hand would have taken a ridiculous amount of time.

Only files built on x86 with --enable-targets=all are modified.  This
means that all other -nat.c files are untouched and will have to be
dealt with later by using appropiate compilers.  Or maybe we can try to
build them with a regular g++ just to know where to add casts, I don't
know.

I built-tested this with --enable-targets=all and reg-tested.

Here's the changelog entry, which was not too bad to make despite the
size, thanks to David Malcom's script.  I fixed some bits by hand, but
there might be some wrong parts left (hopefully not).

gdb/ChangeLog:

	* aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast
	to allocation result assignment.
	* ada-exp.y (write_object_renaming): Likewise.
	(write_ambiguous_var): Likewise.
	(ada_nget_field_index): Likewise.
	(write_var_or_type): Likewise.
	* ada-lang.c (ada_decode_symbol): Likewise.
	(ada_value_assign): Likewise.
	(value_pointer): Likewise.
	(cache_symbol): Likewise.
	(add_nonlocal_symbols): Likewise.
	(ada_name_for_lookup): Likewise.
	(symbol_completion_add): Likewise.
	(ada_to_fixed_type_1): Likewise.
	(ada_get_next_arg): Likewise.
	(defns_collected): Likewise.
	* ada-lex.l (processId): Likewise.
	(processString): Likewise.
	* ada-tasks.c (read_known_tasks_array): Likewise.
	(read_known_tasks_list): Likewise.
	* ada-typeprint.c (decoded_type_name): Likewise.
	* addrmap.c (addrmap_mutable_create_fixed): Likewise.
	* amd64-tdep.c (amd64_push_arguments): Likewise.
	(amd64_displaced_step_copy_insn): Likewise.
	(amd64_classify_insn_at): Likewise.
	(amd64_relocate_instruction): Likewise.
	* amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise.
	* arch-utils.c (simple_displaced_step_copy_insn): Likewise.
	(initialize_current_architecture): Likewise.
	* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
	* arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise.
	* arm-tdep.c (arm_exidx_new_objfile): Likewise.
	(arm_push_dummy_call): Likewise.
	(extend_buffer_earlier): Likewise.
	(arm_adjust_breakpoint_address): Likewise.
	(arm_skip_stub): Likewise.
	* auto-load.c (filename_is_in_pattern): Likewise.
	(maybe_add_script_file): Likewise.
	(maybe_add_script_text): Likewise.
	(auto_load_objfile_script_1): Likewise.
	* auxv.c (ld_so_xfer_auxv): Likewise.
	* ax-general.c (new_agent_expr): Likewise.
	(grow_expr): Likewise.
	(ax_reg_mask): Likewise.
	* bcache.c (bcache_full): Likewise.
	* breakpoint.c (program_breakpoint_here_p): Likewise.
	* btrace.c (parse_xml_raw): Likewise.
	* build-id.c (build_id_to_debug_bfd): Likewise.
	* buildsym.c (end_symtab_with_blockvector): Likewise.
	* c-exp.y (string_exp): Likewise.
	(qualified_name): Likewise.
	(write_destructor_name): Likewise.
	(operator_stoken): Likewise.
	(parse_number): Likewise.
	(scan_macro_expansion): Likewise.
	(yylex): Likewise.
	(c_print_token): Likewise.
	* c-lang.c (c_get_string): Likewise.
	(emit_numeric_character): Likewise.
	* charset.c (wchar_iterate): Likewise.
	* cli/cli-cmds.c (complete_command): Likewise.
	(make_command): Likewise.
	* cli/cli-dump.c (restore_section_callback): Likewise.
	(restore_binary_file): Likewise.
	* cli/cli-interp.c (cli_interpreter_exec): Likewise.
	* cli/cli-script.c (execute_control_command): Likewise.
	* cli/cli-setshow.c (do_set_command): Likewise.
	* coff-pe-read.c (add_pe_forwarded_sym): Likewise.
	(read_pe_exported_syms): Likewise.
	* coffread.c (coff_read_struct_type): Likewise.
	(coff_read_enum_type): Likewise.
	* common/btrace-common.c (btrace_data_append): Likewise.
	* common/buffer.c (buffer_grow): Likewise.
	* common/filestuff.c (gdb_fopen_cloexec): Likewise.
	* common/format.c (parse_format_string): Likewise.
	* common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise.
	* common/xml-utils.c (xml_escape_text): Likewise.
	* compile/compile-object-load.c (copy_sections): Likewise.
	(compile_object_load): Likewise.
	* compile/compile-object-run.c (compile_object_run): Likewise.
	* completer.c (filename_completer): Likewise.
	* corefile.c (read_memory_typed_address): Likewise.
	(write_memory_unsigned_integer): Likewise.
	(write_memory_signed_integer): Likewise.
	(complete_set_gnutarget): Likewise.
	* corelow.c (get_core_register_section): Likewise.
	* cp-name-parser.y (d_grab): Likewise.
	(allocate_info): Likewise.
	(cp_new_demangle_parse_info): Likewise.
	* cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise.
	(cp_lookup_symbol_in_namespace): Likewise.
	(lookup_namespace_scope): Likewise.
	(find_symbol_in_baseclass): Likewise.
	(cp_lookup_nested_symbol): Likewise.
	(cp_lookup_transparent_type_loop): Likewise.
	* cp-support.c (copy_string_to_obstack): Likewise.
	(make_symbol_overload_list): Likewise.
	(make_symbol_overload_list_namespace): Likewise.
	(make_symbol_overload_list_adl_namespace): Likewise.
	(first_component_command): Likewise.
	* cp-valprint.c (cp_print_value): Likewise.
	* ctf.c (ctf_xfer_partial): Likewise.
	* d-exp.y (StringExp): Likewise.
	* d-namespace.c (d_lookup_symbol_in_module): Likewise.
	(lookup_module_scope): Likewise.
	(find_symbol_in_baseclass): Likewise.
	(d_lookup_nested_symbol): Likewise.
	* dbxread.c (find_stab_function_addr): Likewise.
	(read_dbx_symtab): Likewise.
	(dbx_end_psymtab): Likewise.
	(cp_set_block_scope): Likewise.
	* dcache.c (dcache_alloc): Likewise.
	* demangle.c (_initialize_demangler): Likewise.
	* dicos-tdep.c (dicos_load_module_p): Likewise.
	* dictionary.c (dict_create_hashed_expandable): Likewise.
	(dict_create_linear_expandable): Likewise.
	(expand_hashtable): Likewise.
	(add_symbol_linear_expandable): Likewise.
	* dwarf2-frame.c (add_cie): Likewise.
	(add_fde): Likewise.
	(dwarf2_build_frame_info): Likewise.
	* dwarf2expr.c (dwarf_expr_grow_stack): Likewise.
	(dwarf_expr_fetch_address): Likewise.
	(add_piece): Likewise.
	(execute_stack_op): Likewise.
	* dwarf2loc.c (chain_candidate): Likewise.
	(dwarf_entry_parameter_to_value): Likewise.
	(read_pieced_value): Likewise.
	(write_pieced_value): Likewise.
	* dwarf2read.c (dwarf2_read_section): Likewise.
	(add_type_unit): Likewise.
	(read_comp_units_from_section): Likewise.
	(fixup_go_packaging): Likewise.
	(dwarf2_compute_name): Likewise.
	(dwarf2_physname): Likewise.
	(create_dwo_unit_in_dwp_v1): Likewise.
	(create_dwo_unit_in_dwp_v2): Likewise.
	(read_func_scope): Likewise.
	(read_call_site_scope): Likewise.
	(dwarf2_attach_fields_to_type): Likewise.
	(process_structure_scope): Likewise.
	(mark_common_block_symbol_computed): Likewise.
	(read_common_block): Likewise.
	(abbrev_table_read_table): Likewise.
	(guess_partial_die_structure_name): Likewise.
	(fixup_partial_die): Likewise.
	(add_file_name): Likewise.
	(dwarf2_const_value_data): Likewise.
	(dwarf2_const_value_attr): Likewise.
	(build_error_marker_type): Likewise.
	(guess_full_die_structure_name): Likewise.
	(anonymous_struct_prefix): Likewise.
	(typename_concat): Likewise.
	(dwarf2_canonicalize_name): Likewise.
	(dwarf2_name): Likewise.
	(write_constant_as_bytes): Likewise.
	(dwarf2_fetch_constant_bytes): Likewise.
	(copy_string): Likewise.
	(parse_macro_definition): Likewise.
	* elfread.c (elf_symfile_segments): Likewise.
	(elf_rel_plt_read): Likewise.
	(elf_gnu_ifunc_resolve_by_cache): Likewise.
	(elf_gnu_ifunc_resolve_by_got): Likewise.
	(elf_read_minimal_symbols): Likewise.
	(elf_gnu_ifunc_record_cache): Likewise.
	* event-top.c (top_level_prompt): Likewise.
	(command_line_handler): Likewise.
	* exec.c (resize_section_table): Likewise.
	* expprint.c (print_subexp_standard): Likewise.
	* fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise.
	* findcmd.c (parse_find_args): Likewise.
	* findvar.c (address_from_register): Likewise.
	* frame.c (get_prev_frame_always): Likewise.
	* gdb_bfd.c (gdb_bfd_ref): Likewise.
	(get_section_descriptor): Likewise.
	* gdb_obstack.c (obconcat): Likewise.
	(obstack_strdup): Likewise.
	* gdbtypes.c (lookup_function_type_with_arguments): Likewise.
	(create_set_type): Likewise.
	(lookup_unsigned_typename): Likewise.
	(lookup_signed_typename): Likewise.
	(resolve_dynamic_union): Likewise.
	(resolve_dynamic_struct): Likewise.
	(add_dyn_prop): Likewise.
	(copy_dynamic_prop_list): Likewise.
	(arch_flags_type): Likewise.
	(append_composite_type_field_raw): Likewise.
	* gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise.
	* gnu-v3-abi.c (gnuv3_rtti_type): Likewise.
	* go-exp.y (string_exp): Likewise.
	* go-lang.c (go_demangle): Likewise.
	* guile/guile.c (compute_scheme_string): Likewise.
	* guile/scm-cmd.c (gdbscm_parse_command_name): Likewise.
	(gdbscm_canonicalize_command_name): Likewise.
	* guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise.
	(ioscm_init_memory_port): Likewise.
	(ioscm_reinit_memory_port): Likewise.
	* guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise.
	(gdbscm_gc_dup_argv): Likewise.
	* h8300-tdep.c (h8300_push_dummy_call): Likewise.
	* hppa-tdep.c (internalize_unwinds): Likewise.
	(read_unwind_info): Likewise.
	* i386-cygwin-tdep.c (core_process_module_section): Likewise.
	(windows_core_xfer_shared_libraries): Likewise.
	* i386-tdep.c (i386_displaced_step_copy_insn): Likewise.
	(i386_stap_parse_special_token_triplet): Likewise.
	(i386_stap_parse_special_token_three_arg_disp): Likewise.
	* i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise.
	* inf-child.c (inf_child_fileio_readlink): Likewise.
	* inf-ptrace.c (inf_ptrace_fetch_register): Likewise.
	(inf_ptrace_store_register): Likewise.
	* infrun.c (follow_exec): Likewise.
	(displaced_step_prepare_throw): Likewise.
	(save_stop_context): Likewise.
	(save_infcall_suspend_state): Likewise.
	* jit.c (jit_read_descriptor): Likewise.
	(jit_read_code_entry): Likewise.
	(jit_symtab_line_mapping_add_impl): Likewise.
	(finalize_symtab): Likewise.
	(jit_unwind_reg_get_impl): Likewise.
	* jv-exp.y (QualifiedName): Likewise.
	* jv-lang.c (get_java_utf8_name): Likewise.
	(type_from_class): Likewise.
	(java_demangle_type_signature): Likewise.
	(java_class_name_from_physname): Likewise.
	* jv-typeprint.c (java_type_print_base): Likewise.
	* jv-valprint.c (java_value_print): Likewise.
	* language.c (add_language): Likewise.
	* linespec.c (add_sal_to_sals_basic): Likewise.
	(add_sal_to_sals): Likewise.
	(decode_objc): Likewise.
	(find_linespec_symbols): Likewise.
	* linux-fork.c (fork_save_infrun_state): Likewise.
	* linux-nat.c (linux_nat_detach): Likewise.
	(linux_nat_fileio_readlink): Likewise.
	* linux-record.c (record_linux_sockaddr): Likewise.
	(record_linux_msghdr): Likewise.
	(Do): Likewise.
	* linux-tdep.c (linux_core_info_proc_mappings): Likewise.
	(linux_collect_regset_section_cb): Likewise.
	(linux_get_siginfo_data): Likewise.
	* linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise.
	(try_thread_db_load_from_dir): Likewise.
	(thread_db_load_search): Likewise.
	(info_auto_load_libthread_db): Likewise.
	* m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise.
	(m32c_m16c_pointer_to_address): Likewise.
	* m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise.
	* m68k-tdep.c (m68k_get_longjmp_target): Likewise.
	* machoread.c (macho_check_dsym): Likewise.
	* macroexp.c (resize_buffer): Likewise.
	(gather_arguments): Likewise.
	(maybe_expand): Likewise.
	* macrotab.c (new_macro_key): Likewise.
	(new_source_file): Likewise.
	(new_macro_definition): Likewise.
	* mdebugread.c (parse_symbol): Likewise.
	(parse_type): Likewise.
	(parse_partial_symbols): Likewise.
	(psymtab_to_symtab_1): Likewise.
	* mem-break.c (default_memory_insert_breakpoint): Likewise.
	* mi/mi-cmd-break.c (mi_argv_to_format): Likewise.
	* mi/mi-main.c (mi_cmd_data_read_memory): Likewise.
	(mi_cmd_data_read_memory_bytes): Likewise.
	(mi_cmd_data_write_memory_bytes): Likewise.
	(mi_cmd_trace_frame_collected): Likewise.
	* mi/mi-parse.c (mi_parse_argv): Likewise.
	(mi_parse): Likewise.
	* minidebug.c (lzma_open): Likewise.
	(lzma_pread): Likewise.
	* mips-tdep.c (mips_read_fp_register_single): Likewise.
	(mips_print_fp_register): Likewise.
	* mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise.
	* mipsread.c (read_alphacoff_dynamic_symtab): Likewise.
	* mt-tdep.c (mt_register_name): Likewise.
	(mt_registers_info): Likewise.
	(mt_push_dummy_call): Likewise.
	* namespace.c (add_using_directive): Likewise.
	* nat/linux-btrace.c (perf_event_read): Likewise.
	(linux_enable_bts): Likewise.
	* nat/linux-osdata.c (linux_common_core_of_thread): Likewise.
	* nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise.
	* nto-tdep.c (nto_find_and_open_solib): Likewise.
	(nto_parse_redirection): Likewise.
	* objc-lang.c (objc_demangle): Likewise.
	(find_methods): Likewise.
	* objfiles.c (get_objfile_bfd_data): Likewise.
	(set_objfile_main_name): Likewise.
	(allocate_objfile): Likewise.
	(objfile_relocate): Likewise.
	(update_section_map): Likewise.
	* osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise.
	* p-exp.y (exp): Likewise.
	(yylex): Likewise.
	* p-valprint.c (pascal_object_print_value): Likewise.
	* parse.c (initialize_expout): Likewise.
	(mark_completion_tag): Likewise.
	(copy_name): Likewise.
	(parse_float): Likewise.
	(type_stack_reserve): Likewise.
	* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
	(ppu2spu_prev_register): Likewise.
	* ppc-ravenscar-thread.c (supply_register_at_address): Likewise.
	* printcmd.c (printf_wide_c_string): Likewise.
	(printf_pointer): Likewise.
	* probe.c (parse_probes): Likewise.
	* python/py-cmd.c (gdbpy_parse_command_name): Likewise.
	(cmdpy_init): Likewise.
	* python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise.
	* python/py-symtab.c (set_sal): Likewise.
	* python/py-unwind.c (pyuw_sniffer): Likewise.
	* python/python.c (python_interactive_command): Likewise.
	(compute_python_string): Likewise.
	* ravenscar-thread.c (get_running_thread_id): Likewise.
	* record-full.c (record_full_exec_insn): Likewise.
	(record_full_core_open_1): Likewise.
	* regcache.c (regcache_raw_read_signed): Likewise.
	(regcache_raw_read_unsigned): Likewise.
	(regcache_cooked_read_signed): Likewise.
	(regcache_cooked_read_unsigned): Likewise.
	* remote-fileio.c (remote_fileio_func_open): Likewise.
	(remote_fileio_func_rename): Likewise.
	(remote_fileio_func_unlink): Likewise.
	(remote_fileio_func_stat): Likewise.
	(remote_fileio_func_system): Likewise.
	* remote-mips.c (mips_xfer_memory): Likewise.
	(mips_load_srec): Likewise.
	(pmon_end_download): Likewise.
	* remote.c (new_remote_state): Likewise.
	(map_regcache_remote_table): Likewise.
	(remote_register_number_and_offset): Likewise.
	(init_remote_state): Likewise.
	(get_memory_packet_size): Likewise.
	(remote_pass_signals): Likewise.
	(remote_program_signals): Likewise.
	(remote_start_remote): Likewise.
	(remote_check_symbols): Likewise.
	(remote_query_supported): Likewise.
	(extended_remote_attach): Likewise.
	(process_g_packet): Likewise.
	(store_registers_using_G): Likewise.
	(putpkt_binary): Likewise.
	(read_frame): Likewise.
	(compare_sections_command): Likewise.
	(remote_hostio_pread): Likewise.
	(remote_hostio_readlink): Likewise.
	(remote_file_put): Likewise.
	(remote_file_get): Likewise.
	(remote_pid_to_exec_file): Likewise.
	(_initialize_remote): Likewise.
	* rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise.
	(rs6000_aix_core_xfer_shared_libraries_aix): Likewise.
	* rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise.
	(bfd_uses_spe_extensions): Likewise.
	* s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise.
	* score-tdep.c (score7_malloc_and_get_memblock): Likewise.
	* solib-dsbt.c (decode_loadmap): Likewise.
	(fetch_loadmap): Likewise.
	(scan_dyntag): Likewise.
	(enable_break): Likewise.
	(dsbt_relocate_main_executable): Likewise.
	* solib-frv.c (fetch_loadmap): Likewise.
	(enable_break2): Likewise.
	(frv_relocate_main_executable): Likewise.
	* solib-spu.c (spu_relocate_main_executable): Likewise.
	(spu_bfd_open): Likewise.
	* solib-svr4.c (lm_info_read): Likewise.
	(read_program_header): Likewise.
	(find_program_interpreter): Likewise.
	(scan_dyntag): Likewise.
	(elf_locate_base): Likewise.
	(open_symbol_file_object): Likewise.
	(read_program_headers_from_bfd): Likewise.
	(svr4_relocate_main_executable): Likewise.
	* solib-target.c (solib_target_relocate_section_addresses): Likewise.
	* solib.c (solib_find_1): Likewise.
	(exec_file_find): Likewise.
	(solib_find): Likewise.
	* source.c (openp): Likewise.
	(print_source_lines_base): Likewise.
	(forward_search_command): Likewise.
	* sparc-ravenscar-thread.c (supply_register_at_address): Likewise.
	* spu-tdep.c (spu2ppu_prev_register): Likewise.
	(spu_get_overlay_table): Likewise.
	* stabsread.c (patch_block_stabs): Likewise.
	(define_symbol): Likewise.
	(again:): Likewise.
	(read_member_functions): Likewise.
	(read_one_struct_field): Likewise.
	(read_enum_type): Likewise.
	(common_block_start): Likewise.
	* stack.c (read_frame_arg): Likewise.
	(backtrace_command): Likewise.
	* stap-probe.c (stap_parse_register_operand): Likewise.
	* symfile.c (syms_from_objfile_1): Likewise.
	(find_separate_debug_file): Likewise.
	(load_command): Likewise.
	(load_progress): Likewise.
	(load_section_callback): Likewise.
	(reread_symbols): Likewise.
	(add_filename_language): Likewise.
	(allocate_compunit_symtab): Likewise.
	(read_target_long_array): Likewise.
	(simple_read_overlay_table): Likewise.
	* symtab.c (symbol_set_names): Likewise.
	(resize_symbol_cache): Likewise.
	(rbreak_command): Likewise.
	(completion_list_add_name): Likewise.
	(completion_list_objc_symbol): Likewise.
	(add_filename_to_list): Likewise.
	* target-descriptions.c (maint_print_c_tdesc_cmd): Likewise.
	* target-memory.c (target_write_memory_blocks): Likewise.
	* target.c (target_read_string): Likewise.
	(read_whatever_is_readable): Likewise.
	(target_read_alloc_1): Likewise.
	(simple_search_memory): Likewise.
	(target_fileio_read_alloc_1): Likewise.
	* tilegx-tdep.c (tilegx_push_dummy_call): Likewise.
	* top.c (command_line_input): Likewise.
	* tracefile-tfile.c (tfile_fetch_registers): Likewise.
	* tracefile.c (tracefile_fetch_registers): Likewise.
	* tracepoint.c (add_memrange): Likewise.
	(init_collection_list): Likewise.
	(add_aexpr): Likewise.
	(trace_dump_actions): Likewise.
	(parse_trace_status): Likewise.
	(parse_tracepoint_definition): Likewise.
	(parse_tsv_definition): Likewise.
	(parse_static_tracepoint_marker_definition): Likewise.
	* tui/tui-file.c (tui_sfileopen): Likewise.
	(tui_file_adjust_strbuf): Likewise.
	* tui/tui-io.c (tui_expand_tabs): Likewise.
	* tui/tui-source.c (tui_set_source_content): Likewise.
	* typeprint.c (find_global_typedef): Likewise.
	* ui-file.c (do_ui_file_xstrdup): Likewise.
	(ui_file_obsavestring): Likewise.
	(mem_file_write): Likewise.
	* utils.c (make_hex_string): Likewise.
	(get_regcomp_error): Likewise.
	(puts_filtered_tabular): Likewise.
	(gdb_realpath_keepfile): Likewise.
	(ldirname): Likewise.
	(gdb_bfd_errmsg): Likewise.
	(substitute_path_component): Likewise.
	* valops.c (search_struct_method): Likewise.
	(find_oload_champ_namespace_loop): Likewise.
	* valprint.c (print_decimal_chars): Likewise.
	(read_string): Likewise.
	(generic_emit_char): Likewise.
	* varobj.c (varobj_delete): Likewise.
	(varobj_value_get_print_value): Likewise.
	* vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise.
	* windows-tdep.c (display_one_tib): Likewise.
	* xcoffread.c (read_xcoff_symtab): Likewise.
	(process_xcoff_symbol): Likewise.
	(swap_sym): Likewise.
	(scan_xcoff_symtab): Likewise.
	(xcoff_initial_scan): Likewise.
	* xml-support.c (gdb_xml_end_element): Likewise.
	(xml_process_xincludes): Likewise.
	(xml_fetch_content_from_file): Likewise.
	* xml-syscall.c (xml_list_of_syscalls): Likewise.
	* xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise.

gdb/gdbserver/ChangeLog:

	* ax.c (gdb_parse_agent_expr): Add cast to allocation result
	assignment.
	(gdb_unparse_agent_expr): Likewise.
	* hostio.c (require_data): Likewise.
	(handle_pread): Likewise.
	* linux-low.c (disable_regset): Likewise.
	(fetch_register): Likewise.
	(store_register): Likewise.
	(get_dynamic): Likewise.
	(linux_qxfer_libraries_svr4): Likewise.
	* mem-break.c (delete_fast_tracepoint_jump): Likewise.
	(set_fast_tracepoint_jump): Likewise.
	(uninsert_fast_tracepoint_jumps_at): Likewise.
	(reinsert_fast_tracepoint_jumps_at): Likewise.
	(validate_inserted_breakpoint): Likewise.
	(clone_agent_expr): Likewise.
	* regcache.c (init_register_cache): Likewise.
	* remote-utils.c (putpkt_binary_1): Likewise.
	(decode_M_packet): Likewise.
	(decode_X_packet): Likewise.
	(look_up_one_symbol): Likewise.
	(relocate_instruction): Likewise.
	(monitor_output): Likewise.
	* server.c (handle_search_memory): Likewise.
	(handle_qxfer_exec_file): Likewise.
	(handle_qxfer_libraries): Likewise.
	(handle_qxfer): Likewise.
	(handle_query): Likewise.
	(handle_v_cont): Likewise.
	(handle_v_run): Likewise.
	(captured_main): Likewise.
	* target.c (write_inferior_memory): Likewise.
	* thread-db.c (try_thread_db_load_from_dir): Likewise.
	* tracepoint.c (init_trace_buffer): Likewise.
	(add_tracepoint_action): Likewise.
	(add_traceframe): Likewise.
	(add_traceframe_block): Likewise.
	(cmd_qtdpsrc): Likewise.
	(cmd_qtdv): Likewise.
	(cmd_qtstatus): Likewise.
	(response_source): Likewise.
	(response_tsv): Likewise.
	(cmd_qtnotes): Likewise.
	(gdb_collect): Likewise.
	(initialize_tracepoint): Likewise.
2015-09-25 14:08:06 -04:00
Simon Marchi 8d7493201c Replace some xmalloc-family functions with XNEW-family ones
This patch is part of the make-gdb-buildable-in-C++ effort.  The idea is
to change some calls to the xmalloc family of functions to calls to the
equivalents in the XNEW family.  This avoids adding an explicit cast, so
it keeps the code a bit more readable.  Some of them also map relatively
well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be
possible to do scripted replacements if needed.

I only changed calls that were obviously allocating memory for one or
multiple "objects".  Allocation of variable sizes (such as strings or
buffer handling) will be for later (and won't use XNEW).

  - xmalloc (sizeof (struct foo)) -> XNEW (struct foo)
  - xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num)
  - xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo)
  - xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num)
  - xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num)
  - obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo)
  - obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num)
  - alloca (sizeof (struct foo)) -> XALLOCA (struct foo)
  - alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num)

Some instances of xmalloc followed by memset to zero the buffer were
replaced by XCNEW or XCNEWVEC.

I regtested on x86-64, Ubuntu 14.04, but the patch touches many
architecture-specific files.  For those I'll have to rely on the
buildbot or people complaining that I broke their gdb.

gdb/ChangeLog:

	* aarch64-linux-nat.c (aarch64_add_process): Likewise.
	* aarch64-tdep.c (aarch64_gdbarch_init): Likewise.
	* ada-exp.y (write_ambiguous_var): Likewise.
	* ada-lang.c (resolve_subexp): Likewise.
	(user_select_syms): Likewise.
	(assign_aggregate): Likewise.
	(ada_evaluate_subexp): Likewise.
	(cache_symbol): Likewise.
	* addrmap.c (allocate_key): Likewise.
	(addrmap_create_mutable): Likewise.
	* aix-thread.c (sync_threadlists): Likewise.
	* alpha-tdep.c (alpha_push_dummy_call): Likewise.
	(alpha_gdbarch_init): Likewise.
	* amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise.
	* arm-linux-nat.c (arm_linux_add_process): Likewise.
	* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
	* arm-tdep.c (push_stack_item): Likewise.
	(arm_displaced_step_copy_insn): Likewise.
	(arm_gdbarch_init): Likewise.
	(_initialize_arm_tdep): Likewise.
	* avr-tdep.c (push_stack_item): Likewise.
	* ax-general.c (new_agent_expr): Likewise.
	* block.c (block_initialize_namespace): Likewise.
	* breakpoint.c (alloc_counted_command_line): Likewise.
	(update_dprintf_command_list): Likewise.
	(parse_breakpoint_sals): Likewise.
	(decode_static_tracepoint_spec): Likewise.
	(until_break_command): Likewise.
	(clear_command): Likewise.
	(update_global_location_list): Likewise.
	(get_breakpoint_objfile_data) Likewise.
	* btrace.c (ftrace_new_function): Likewise.
	(btrace_set_insn_history): Likewise.
	(btrace_set_call_history): Likewise.
	* buildsym.c (add_symbol_to_list): Likewise.
	(record_pending_block): Likewise.
	(start_subfile): Likewise.
	(start_buildsym_compunit): Likewise.
	(push_subfile): Likewise.
	(end_symtab_get_static_block): Likewise.
	(buildsym_init): Likewise.
	* cli/cli-cmds.c (source_command): Likewise.
	* cli/cli-decode.c (add_cmd): Likewise.
	* cli/cli-script.c (build_command_line): Likewise.
	(setup_user_args): Likewise.
	(realloc_body_list): Likewise.
	(process_next_line): Likewise.
	(copy_command_lines): Likewise.
	* cli/cli-setshow.c (do_set_command): Likewise.
	* coff-pe-read.c (read_pe_exported_syms): Likewise.
	* coffread.c (coff_locate_sections): Likewise.
	(coff_symtab_read): Likewise.
	(coff_read_struct_type): Likewise.
	* common/cleanups.c (make_my_cleanup2): Likewise.
	* common/common-exceptions.c (throw_it): Likewise.
	* common/filestuff.c (make_cleanup_close): Likewise.
	* common/format.c (parse_format_string): Likewise.
	* common/queue.h (DEFINE_QUEUE_P): Likewise.
	* compile/compile-object-load.c (munmap_list_add): Likewise.
	(compile_object_load): Likewise.
	* compile/compile-object-run.c (compile_object_run): Likewise.
	* compile/compile.c (append_args): Likewise.
	* corefile.c (specify_exec_file_hook): Likewise.
	* cp-support.c (make_symbol_overload_list): Likewise.
	* cris-tdep.c (push_stack_item): Likewise.
	(cris_gdbarch_init): Likewise.
	* ctf.c (ctf_trace_file_writer_new): Likewise.
	* dbxread.c (init_header_files): Likewise.
	(add_new_header_file): Likewise.
	(init_bincl_list): Likewise.
	(dbx_end_psymtab): Likewise.
	(start_psymtab): Likewise.
	(dbx_end_psymtab): Likewise.
	* dcache.c (dcache_init): Likewise.
	* dictionary.c (dict_create_hashed): Likewise.
	(dict_create_hashed_expandable): Likewise.
	(dict_create_linear): Likewise.
	(dict_create_linear_expandable): Likewise.
	* dtrace-probe.c (dtrace_process_dof_probe): Likewise.
	* dummy-frame.c (register_dummy_frame_dtor): Likewise.
	* dwarf2-frame-tailcall.c (cache_new_ref1): Likewise.
	* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
	(decode_frame_entry_1): Likewise.
	* dwarf2expr.c (new_dwarf_expr_context): Likewise.
	* dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise.
	* dwarf2read.c (dwarf2_has_info): Likewise.
	(create_signatured_type_table_from_index): Likewise.
	(dwarf2_read_index): Likewise.
	(dw2_get_file_names_reader): Likewise.
	(create_all_type_units): Likewise.
	(read_cutu_die_from_dwo): Likewise.
	(init_tu_and_read_dwo_dies): Likewise.
	(init_cutu_and_read_dies): Likewise.
	(create_all_comp_units): Likewise.
	(queue_comp_unit): Likewise.
	(inherit_abstract_dies): Likewise.
	(read_call_site_scope): Likewise.
	(dwarf2_add_field): Likewise.
	(dwarf2_add_typedef): Likewise.
	(dwarf2_add_member_fn): Likewise.
	(attr_to_dynamic_prop): Likewise.
	(abbrev_table_alloc_abbrev): Likewise.
	(abbrev_table_read_table): Likewise.
	(add_include_dir): Likewise.
	(add_file_name): Likewise.
	(dwarf_decode_line_header): Likewise.
	(dwarf2_const_value_attr): Likewise.
	(dwarf_alloc_block): Likewise.
	(parse_macro_definition): Likewise.
	(set_die_type): Likewise.
	(write_psymtabs_to_index): Likewise.
	(create_cus_from_index): Likewise.
	(dwarf2_create_include_psymtab): Likewise.
	(process_psymtab_comp_unit_reader): Likewise.
	(build_type_psymtab_dependencies): Likewise.
	(read_comp_units_from_section): Likewise.
	(compute_compunit_symtab_includes): Likewise.
	(create_dwo_unit_in_dwp_v1): Likewise.
	(create_dwo_unit_in_dwp_v2): Likewise.
	(read_func_scope): Likewise.
	(process_structure_scope): Likewise.
	(mark_common_block_symbol_computed): Likewise.
	(load_partial_dies): Likewise.
	(dwarf2_symbol_mark_computed): Likewise.
	* elfread.c (elf_symfile_segments): Likewise.
	(elf_read_minimal_symbols): Likewise.
	* environ.c (make_environ): Likewise.
	* eval.c (evaluate_subexp_standard): Likewise.
	* event-loop.c (create_file_handler): Likewise.
	(create_async_signal_handler): Likewise.
	(create_async_event_handler): Likewise.
	(create_timer): Likewise.
	* exec.c (build_section_table): Likewise.
	* fbsd-nat.c (fbsd_remember_child): Likewise.
	* fork-child.c (fork_inferior): Likewise.
	* frv-tdep.c (new_variant): Likewise.
	* gdbarch.sh (gdbarch_alloc): Likewise.
	(append_name): Likewise.
	* gdbtypes.c (rank_function): Likewise.
	(copy_type_recursive): Likewise.
	(add_dyn_prop): Likewise.
	* gnu-nat.c (make_proc): Likewise.
	(make_inf): Likewise.
	(gnu_write_inferior): Likewise.
	* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
	(build_std_type_info_type): Likewise.
	* guile/scm-param.c (compute_enum_list): Likewise.
	* guile/scm-utils.c (gdbscm_parse_function_args): Likewise.
	* guile/scm-value.c (gdbscm_value_call): Likewise.
	* h8300-tdep.c (h8300_gdbarch_init): Likewise.
	* hppa-tdep.c (hppa_init_objfile_priv_data): Likewise.
	(read_unwind_info): Likewise.
	* ia64-tdep.c (ia64_gdbarch_init): Likewise.
	* infcall.c (dummy_frame_context_saver_setup): Likewise.
	(call_function_by_hand_dummy): Likewise.
	* infcmd.c (step_once): Likewise.
	(finish_forward): Likewise.
	(attach_command): Likewise.
	(notice_new_inferior): Likewise.
	* inferior.c (add_inferior_silent): Likewise.
	* infrun.c (add_displaced_stepping_state): Likewise.
	(save_infcall_control_state): Likewise.
	(save_inferior_ptid): Likewise.
	(_initialize_infrun): Likewise.
	* jit.c (bfd_open_from_target_memory): Likewise.
	(jit_gdbarch_data_init): Likewise.
	* language.c (add_language): Likewise.
	* linespec.c (decode_line_2): Likewise.
	* linux-nat.c (add_to_pid_list): Likewise.
	(add_initial_lwp): Likewise.
	* linux-thread-db.c (add_thread_db_info): Likewise.
	(record_thread): Likewise.
	(info_auto_load_libthread_db): Likewise.
	* m32c-tdep.c (m32c_gdbarch_init): Likewise.
	* m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise.
	* m68k-tdep.c (m68k_gdbarch_init): Likewise.
	* m88k-tdep.c (m88k_analyze_prologue): Likewise.
	* macrocmd.c (macro_define_command): Likewise.
	* macroexp.c (gather_arguments): Likewise.
	* macroscope.c (sal_macro_scope): Likewise.
	* macrotab.c (new_macro_table): Likewise.
	* mdebugread.c (push_parse_stack): Likewise.
	(parse_partial_symbols): Likewise.
	(parse_symbol): Likewise.
	(psymtab_to_symtab_1): Likewise.
	(new_block): Likewise.
	(new_psymtab): Likewise.
	(mdebug_build_psymtabs): Likewise.
	(add_pending): Likewise.
	(elfmdebug_build_psymtabs): Likewise.
	* mep-tdep.c (mep_gdbarch_init): Likewise.
	* mi/mi-main.c (mi_execute_command): Likewise.
	* mi/mi-parse.c (mi_parse_argv): Likewise.
	* minidebug.c (lzma_open): Likewise.
	* minsyms.c (terminate_minimal_symbol_table): Likewise.
	* mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise.
	* mips-tdep.c (mips_gdbarch_init): Likewise.
	* mn10300-tdep.c (mn10300_gdbarch_init): Likewise.
	* msp430-tdep.c (msp430_gdbarch_init): Likewise.
	* mt-tdep.c (mt_registers_info): Likewise.
	* nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise.
	* nat/linux-btrace.c (linux_enable_bts): Likewise.
	(linux_enable_pt): Likewise.
	* nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise.
	(linux_xfer_osdata_processgroups): Likewise.
	* nios2-tdep.c (nios2_gdbarch_init): Likewise.
	* nto-procfs.c (procfs_meminfo): Likewise.
	* objc-lang.c (start_msglist): Likewise.
	(selectors_info): Likewise.
	(classes_info): Likewise.
	(find_methods): Likewise.
	* objfiles.c (allocate_objfile): Likewise.
	(update_section_map): Likewise.
	* osabi.c (gdbarch_register_osabi): Likewise.
	(gdbarch_register_osabi_sniffer): Likewise.
	* parse.c (start_arglist): Likewise.
	* ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise.
	(hwdebug_insert_point): Likewise.
	* printcmd.c (display_command): Likewise.
	(ui_printf): Likewise.
	* procfs.c (create_procinfo): Likewise.
	(load_syscalls): Likewise.
	(proc_get_LDT_entry): Likewise.
	(proc_update_threads): Likewise.
	* prologue-value.c (make_pv_area): Likewise.
	(pv_area_store): Likewise.
	* psymtab.c (extend_psymbol_list): Likewise.
	(init_psymbol_list): Likewise.
	(allocate_psymtab): Likewise.
	* python/py-inferior.c (add_thread_object): Likewise.
	* python/py-param.c (compute_enum_values): Likewise.
	* python/py-value.c (valpy_call): Likewise.
	* python/py-varobj.c (py_varobj_iter_next): Likewise.
	* python/python.c (ensure_python_env): Likewise.
	* record-btrace.c (record_btrace_start_replaying): Likewise.
	* record-full.c (record_full_reg_alloc): Likewise.
	(record_full_mem_alloc): Likewise.
	(record_full_end_alloc): Likewise.
	(record_full_core_xfer_partial): Likewise.
	* regcache.c (get_thread_arch_aspace_regcache): Likewise.
	* remote-fileio.c (remote_fileio_init_fd_map): Likewise.
	* remote-notif.c (remote_notif_state_allocate): Likewise.
	* remote.c (demand_private_info): Likewise.
	(remote_notif_stop_alloc_reply): Likewise.
	(remote_enable_btrace): Likewise.
	* reverse.c (save_bookmark_command): Likewise.
	* rl78-tdep.c (rl78_gdbarch_init): Likewise.
	* rx-tdep.c (rx_gdbarch_init): Likewise.
	* s390-linux-nat.c (s390_insert_watchpoint): Likewise.
	* ser-go32.c (dos_get_tty_state): Likewise.
	(dos_copy_tty_state): Likewise.
	* ser-mingw.c (ser_windows_open): Likewise.
	(ser_console_wait_handle): Likewise.
	(ser_console_get_tty_state): Likewise.
	(make_pipe_state): Likewise.
	(net_windows_open): Likewise.
	* ser-unix.c (hardwire_get_tty_state): Likewise.
	(hardwire_copy_tty_state): Likewise.
	* solib-aix.c (solib_aix_new_lm_info): Likewise.
	* solib-dsbt.c (dsbt_current_sos): Likewise.
	(dsbt_relocate_main_executable): Likewise.
	* solib-frv.c (frv_current_sos): Likewise.
	(frv_relocate_main_executable): Likewise.
	* solib-spu.c (spu_bfd_fopen): Likewise.
	* solib-svr4.c (lm_info_read): Likewise.
	(svr4_copy_library_list): Likewise.
	(svr4_default_sos): Likewise.
	* source.c (find_source_lines): Likewise.
	(line_info): Likewise.
	(add_substitute_path_rule): Likewise.
	* spu-linux-nat.c (spu_bfd_open): Likewise.
	* spu-tdep.c (info_spu_dma_cmdlist): Likewise.
	* stabsread.c (dbx_lookup_type): Likewise.
	(read_type): Likewise.
	(read_member_functions): Likewise.
	(read_struct_fields): Likewise.
	(read_baseclasses): Likewise.
	(read_args): Likewise.
	(_initialize_stabsread): Likewise.
	* stack.c (func_command): Likewise.
	* stap-probe.c (handle_stap_probe): Likewise.
	* symfile.c (addrs_section_sort): Likewise.
	(addr_info_make_relative): Likewise.
	(load_section_callback): Likewise.
	(add_symbol_file_command): Likewise.
	(init_filename_language_table): Likewise.
	* symtab.c (create_filename_seen_cache): Likewise.
	(sort_search_symbols_remove_dups): Likewise.
	(search_symbols): Likewise.
	* target.c (make_cleanup_restore_target_terminal): Likewise.
	* thread.c (new_thread): Likewise.
	(enable_thread_stack_temporaries): Likewise.
	(make_cleanup_restore_current_thread): Likewise.
	(thread_apply_all_command): Likewise.
	* tic6x-tdep.c (tic6x_gdbarch_init): Likewise.
	* top.c (gdb_readline_wrapper): Likewise.
	* tracefile-tfile.c (tfile_trace_file_writer_new): Likewise.
	* tracepoint.c (trace_find_line_command): Likewise.
	(all_tracepoint_actions_and_cleanup): Likewise.
	(make_cleanup_restore_current_traceframe): Likewise.
	(get_uploaded_tp): Likewise.
	(get_uploaded_tsv): Likewise.
	* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
	(tui_alloc_win_info): Likewise.
	(tui_alloc_content): Likewise.
	(tui_add_content_elements): Likewise.
	* tui/tui-disasm.c (tui_find_disassembly_address): Likewise.
	(tui_set_disassem_content): Likewise.
	* ui-file.c (ui_file_new): Likewise.
	(stdio_file_new): Likewise.
	(tee_file_new): Likewise.
	* utils.c (make_cleanup_restore_integer): Likewise.
	(add_internal_problem_command): Likewise.
	* v850-tdep.c (v850_gdbarch_init): Likewise.
	* valops.c (find_oload_champ): Likewise.
	* value.c (allocate_value_lazy): Likewise.
	(record_latest_value): Likewise.
	(create_internalvar): Likewise.
	* varobj.c (install_variable): Likewise.
	(new_variable): Likewise.
	(new_root_variable): Likewise.
	(cppush): Likewise.
	(_initialize_varobj): Likewise.
	* windows-nat.c (windows_make_so): Likewise.
	* x86-nat.c (x86_add_process): Likewise.
	* xcoffread.c (arrange_linetable): Likewise.
	(allocate_include_entry): Likewise.
	(process_linenos): Likewise.
	(SYMBOL_DUP): Likewise.
	(xcoff_start_psymtab): Likewise.
	(xcoff_end_psymtab): Likewise.
	* xml-support.c (gdb_xml_parse_attr_ulongest): Likewise.
	* xtensa-tdep.c (xtensa_register_type): Likewise.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.

gdb/gdbserver/ChangeLog:

	* ax.c (gdb_parse_agent_expr): Likewise.
	(compile_bytecodes): Likewise.
	* dll.c (loaded_dll): Likewise.
	* event-loop.c (append_callback_event): Likewise.
	(create_file_handler): Likewise.
	(create_file_event): Likewise.
	* hostio.c (handle_open): Likewise.
	* inferiors.c (add_thread): Likewise.
	(add_process): Likewise.
	* linux-aarch64-low.c (aarch64_linux_new_process): Likewise.
	* linux-arm-low.c (arm_new_process): Likewise.
	(arm_new_thread): Likewise.
	* linux-low.c (add_to_pid_list): Likewise.
	(linux_add_process): Likewise.
	(handle_extended_wait): Likewise.
	(add_lwp): Likewise.
	(enqueue_one_deferred_signal): Likewise.
	(enqueue_pending_signal): Likewise.
	(linux_resume_one_lwp_throw): Likewise.
	(linux_resume_one_thread): Likewise.
	(linux_read_memory): Likewise.
	(linux_write_memory): Likewise.
	* linux-mips-low.c (mips_linux_new_process): Likewise.
	(mips_linux_new_thread): Likewise.
	(mips_add_watchpoint): Likewise.
	* linux-x86-low.c (initialize_low_arch): Likewise.
	* lynx-low.c (lynx_add_process): Likewise.
	* mem-break.c (set_raw_breakpoint_at): Likewise.
	(set_breakpoint): Likewise.
	(add_condition_to_breakpoint): Likewise.
	(add_commands_to_breakpoint): Likewise.
	(clone_agent_expr): Likewise.
	(clone_one_breakpoint): Likewise.
	* regcache.c (new_register_cache): Likewise.
	* remote-utils.c (look_up_one_symbol): Likewise.
	* server.c (queue_stop_reply): Likewise.
	(start_inferior): Likewise.
	(queue_stop_reply_callback): Likewise.
	(handle_target_event): Likewise.
	* spu-low.c (fetch_ppc_memory): Likewise.
	(store_ppc_memory): Likewise.
	* target.c (set_target_ops): Likewise.
	* thread-db.c (thread_db_load_search): Likewise.
	(try_thread_db_load_1): Likewise.
	* tracepoint.c (add_tracepoint): Likewise.
	(add_tracepoint_action): Likewise.
	(create_trace_state_variable): Likewise.
	(cmd_qtdpsrc): Likewise.
	(cmd_qtro): Likewise.
	(add_while_stepping_state): Likewise.
	* win32-low.c (child_add_thread): Likewise.
	(get_image_name): Likewise.
2015-08-26 17:18:12 -04:00
Keith Seitz f00aae0f7b Explicit locations: use new location API
This patch converts the code base to use the new struct event_location
API being introduced. This patch preserves the current functionality and
adds no new features.

The "big picture" API usage introduced by this patch may be illustrated
with a simple exmaple. Where previously developers would write:

void
my_command (char *arg, int from_tty)
{
   create_breakpoint (..., arg, ...);
   ...
}

one now uses:

void
my_command (char *arg, int from_tty)
{
   struct event_locaiton *location;
   struct cleanup *back_to;

   location = string_to_event_locaiton (&arg, ...);
   back_to = make_cleanup_delete_event_location (location);
   create_breakpoint (..., location, ...);
   do_cleanups (back_to);
}

Linespec-decoding functions (now called location-decoding) such as
decode_line_full no longer skip argument pointers over processed input.
That functionality has been moved into string_to_event_location as
demonstrated above.

gdb/ChangeLog

	* ax-gdb.c: Include location.h.
	(agent_command_1) Use linespec location instead of address
	string.
	* break-catch-throw.c: Include location.h.
	(re_set_exception_catchpoint): Use linespec locations instead
	of address strings.
	* breakpoint.c: Include location.h.
	(create_overlay_event_breakpoint, create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint, update_breakpoints_after_exec):
	Use linespec location instead of address string.
	(print_breakpoint_location):  Use locations and
	event_location_to_string.
	Print extra_string for pending locations for non-MI streams.
	(print_one_breakpoint_location): Use locations and
	event_location_to_string.
	(init_raw_breakpoint_without_location): Initialize b->location.
	(create_thread_event_breakpoint): Use linespec location instead of
	address string.
	(init_breakpoint_sal): Likewise.
	Only save extra_string if it is non-NULL and not the empty string.
	Use event_location_to_string instead of `addr_string'.
	Constify `p' and `endp'.
	Use skip_spaces_const/skip_space_const instead of non-const versions.
	Copy the location into the breakpoint.
	If LOCATION is NULL, save the breakpoint address as a linespec location
	instead of an address string.
	(create_breakpoint_sal): Change `addr_string' parameter to a struct
	event_location. All uses updated.
	(create_breakpoints_sal): Likewise for local variable `addr_string'.
	(parse_breakpoint_sals): Use locations instead of address strings.
	Remove check for empty linespec with conditional.
	Refactor.
	(decode_static_tracepoint_spec): Make argument const and update
	function.
	(create_breakpoint): Change `arg' to a struct event_location and
	rename.
	Remove `copy_arg' and `addr_start'.
	If EXTRA_STRING is empty, set it to NULL.
	Don't populate `canonical' for pending breakpoints.
	Pass `extra_string' to find_condition_and_thread.
	Clear `extra_string' if `rest' was NULL.
	Do not error with "garbage after location" if setting a dprintf
	breakpoint.
	Copy the location into the breakpoint instead of an address string.
	(break_command_1): Use string_to_event_location and pass this to
	create_breakpoint instead of an address string.
	Check against `arg_cp' for a probe linespec.
	(dprintf_command): Use string_to_event_location and pass this to
	create_breakpoint instead of an address string.
	Throw an exception if no format string was specified.
	(print_recreate_ranged_breakpoint): Use event_location_to_string
	instead of address strings.
	(break_range_command, until_break_command)
	(init_ada_exception_breakpoint): Use locations instead
	of address strings.
	(say_where): Print out extra_string for pending locations.
	(base_breakpoint_dtor): Delete `location' and `location_range_end' of
	the breakpoint.
	(base_breakpoint_create_sals_from_location): Use struct event_location
	instead of address string.
	Remove `addr_start' and `copy_arg' parameters.
	(base_breakpoint_decode_location): Use struct event_location instead of
	address string.
	(bkpt_re_set): Use locations instead of address strings.
	Use event_location_empty_p to check for unset location.
	(bkpt_print_recreate): Use event_location_to_string instead of
	an address string.
	Print out extra_string for pending locations.
	(bkpt_create_sals_from_location, bkpt_decode_location)
 	(bkpt_probe_create_sals_from_location): Use struct event_location
	instead of address string.
	(bkpt_probe_decode_location): Use struct event_location instead of
	address string.
	(tracepoint_print_recreate): Use event_location_to_string to
	recreate the tracepoint.
	(tracepoint_create_sals_from_location, tracepoint_decode_location)
	(tracepoint_probe_create_sals_from_location)
	(tracepoint_probe_decode_location): Use struct event_location
	instead of address string.
	(dprintf_print_recreate): Use event_location_to_string to recreate
	the dprintf.
	(dprintf_re_set): Remove check for valid/missing format string.
	(strace_marker_create_sals_from_location)
	(strace_marker_create_breakpoints_sal, strace_marker_decode_location)
	(update_static_tracepoint): Use struct event_location instead of
	address string.
	(location_to_sals): Likewise.
	Pass `extra_string' to find_condition_and_thread.
	For newly resolved pending breakpoint locations, clear the location's
	string representation.
	Assert that the breakpoint's condition string is NULL when
	condition_not_parsed.
	(breakpoint_re_set_default, create_sals_from_location_default)
	(decode_location_default, trace_command, ftrace_command)
	(strace_command, create_tracepoint_from_upload): Use locations
	instead of address strings.
	* breakpoint.h (struct breakpoint_ops) <create_sals_from_location>:
	Use struct event_location instead of address string.
	Update all uses.
	<decode_location>: Likewise.
	(struct breakpoint) <addr_string>: Change to struct event_location
	and rename `location'.
	<addr_string_range_end>: Change to struct event_location and rename
	`location_range_end'.
	(create_breakpoint): Use struct event_location instead of address
	string.
	* cli/cli-cmds.c: Include location.h.
	(edit_command, list_command): Use locations instead of address strings.
	* elfread.c: Include location.h.
	(elf_gnu_ifunc_resolver_return_stop): Use event_location_to_string.
	* guile/scm-breakpoint.c: Include location.h.
	(bpscm_print_breakpoint_smob): Use event_location_to_string.
	(gdbscm_register_breakpoint): Use locations instead of address
	strings.
	* linespec.c: Include location.h.
	(struct ls_parser) <stream>: Change to const char *.
	(PARSER_STREAM): Update.
	(lionespec_lexer_lex_keyword): According to find_condition_and_thread,
	keywords must be followed by whitespace.
	(canonicalize_linespec): Save a linespec location into `canonical'.
	Save a canonical linespec into `canonical'.
	(parse_linespec): Change `argptr' to const char * and rename `arg'.
	All uses updated.
	Update function description.
	(linespec_parser_new): Initialize `parser'.
	Update initialization of  parsing stream.
	(event_location_to_sals): New function.
	(decode_line_full): Change `argptr' to a struct event_location and
	rename it `location'.
	Use locations instead of address strings.
	Call event_location_to_sals instead of parse_linespec.
	(decode_line_1): Likewise.
	(decode_line_with_current_source, decode_line_with_last_displayed)
	Use locations instead of address strings.
	(decode_objc): Likewise.
	Change `argptr' to const char * and rename `arg'.
	(destroy_linespec_result): Delete the linespec result's location
	instead of freeing the address string.
	* linespec.h (struct linespec_result) <addr_string>: Change to
	struct event_location and rename to ...
	<location>: ... this.
	(decode_line_1, decode_line_full): Change `argptr' to struct
	event_location.  All callers updated.
	* mi/mi-cmd-break.c: Include language.h, location.h, and linespec.h.
	(mi_cmd_break_insert_1): Use locations instead of address strings.
	Throw an error if there was "garbage" at the end of the specified
	linespec.
	* probe.c: Include location.h.
	(parse_probes): Change `argptr' to struct event_location.
	Use event locations instead of address strings.
	* probe.h (parse_probes): Change `argptr' to struct event_location.
	* python/py-breakpoint.c: Include location.h.
	(bppy_get_location): Constify local variable `str'.
	Use event_location_to_string.
	(bppy_init): Use locations instead of address strings.
	* python/py-finishbreakpoint.c: Include location.h.
	(bpfinishpy_init): Remove local variable `addr_str'.
	Use locations instead of address strings.
	* python/python.c: Include location.h.
	(gdbpy_decode_line): Use locations instead of address strings.
	* remote.c: Include location.h.
	(remote_download_tracepoint): Use locations instead of address
	strings.
	* spu-tdep.c: Include location.h.
	(spu_catch_start): Remove local variable `buf'.
	Use locations instead of address strings.
	* tracepoint.c: Include location.h.
	(scope_info): Use locations instead of address strings.
	(encode_source_string): Constify parameter `src'.
	* tracepoint.h (encode_source_string): Likewise.

gdb/testsuite/ChangeLog

	* gdb.base/dprintf-pending.exp: Update dprintf "without format"
	test.
	Add tests for missing ",FMT" and ",".
2015-08-11 17:09:35 -07:00
Doug Evans 18a94d75a0 Remove special support in gdb for Sun's version of stabs.
Discussion:
https://sourceware.org/ml/gdb-patches/2015-05/msg00169.html

gdb/ChangeLog:

	* NEWS: Mention Sun's version of stabs is no longer supported.
	* elfread.c (free_elfinfo): Delete.  All uses updated.
	(elfstab_offset_sections): Delete.  All uses updated.
	* gdb-stabs.h (stab_section_info): Delete.  All uses updated.
	* psympriv.h (partial_symtab) <section_offsets>: Delete.
	All uses updated.
	* psymtab.c (start_psymtab_common): Delete arg section_offsets.
	All callers updated.

gdb/doc/ChangeLog:

	* stabs.texinfo (ELF Linker Relocation): Mention Sun stabs is no
	longer supported.
2015-06-19 11:34:43 -07:00
Gary Benson 61012eef84 New common function "startswith"
This commit introduces a new inline common function "startswith"
which takes two string arguments and returns nonzero if the first
string starts with the second.  It also updates the 295 places
where this logic was written out longhand to use the new function.

gdb/ChangeLog:

	* common/common-utils.h (startswith): New inline function.
	All places where this logic was used updated to use the above.
2015-03-06 09:42:06 +00:00
Jan Kratochvil 80c570537e SEGV in ppc64_elf_get_synthetic_symtab reading a separate debug file
The attached patch fixes the SEGV and lets GDB successfully
load all kernel modules installed by default on RHEL 7.

Valgrind on F-21 x86_64 host has shown me more clear what is the problem:

Reading symbols from /home/jkratoch/t/cordic.ko...Reading symbols from
/home/jkratoch/t/cordic.ko.debug...=================================================================
==22763==ERROR: AddressSanitizer: heap-use-after-free on address 0x6120000461c8 at pc 0x150cdbd bp 0x7fffffffc7e0 sp 0x7fffffffc7d0
READ of size 8 at 0x6120000461c8 thread T0
    #0 0x150cdbc in ppc64_elf_get_synthetic_symtab /home/jkratoch/redhat/gdb-test-asan/bfd/elf64-ppc.c:3282
    #1 0x8c5274 in elf_read_minimal_symbols /home/jkratoch/redhat/gdb-test-asan/gdb/elfread.c:1205
    #2 0x8c55e7 in elf_symfile_read /home/jkratoch/redhat/gdb-test-asan/gdb/elfread.c:1268
[...]
0x6120000461c8 is located 264 bytes inside of 288-byte region [0x6120000460c0,0x6120000461e0)
freed by thread T0 here:
    #0 0x7ffff715454f in __interceptor_free (/lib64/libasan.so.1+0x5754f)
    #1 0xde9cde in xfree common/common-utils.c:98
    #2 0x9a04f7 in do_my_cleanups common/cleanups.c:155
    #3 0x9a05d3 in do_cleanups common/cleanups.c:177
    #4 0x8c538a in elf_read_minimal_symbols /home/jkratoch/redhat/gdb-test-asan/gdb/elfread.c:1229
    #5 0x8c55e7 in elf_symfile_read /home/jkratoch/redhat/gdb-test-asan/gdb/elfread.c:1268
[...]
previously allocated by thread T0 here:
    #0 0x7ffff71547c7 in malloc (/lib64/libasan.so.1+0x577c7)
    #1 0xde9b95 in xmalloc common/common-utils.c:41
    #2 0x8c4da2 in elf_read_minimal_symbols /home/jkratoch/redhat/gdb-test-asan/gdb/elfread.c:1147
    #3 0x8c55e7 in elf_symfile_read /home/jkratoch/redhat/gdb-test-asan/gdb/elfread.c:1268
[...]
SUMMARY: AddressSanitizer: heap-use-after-free /home/jkratoch/redhat/gdb-test-asan/bfd/elf64-ppc.c:3282 ppc64_elf_get_synthetic_symtab
[...]
==22763==ABORTING

A similar case a few lines later I have fixed in 2010 by:
        https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=3f1eff0a2c7f0e7078f011f55b8e7f710aae0cc2

My testcase does not always reproduce it but at least a bit:
 * GDB without ppc64 target (even as a secondary one) is reported as "untested"
 * ASAN-built GDB with ppc64 target always crashes (and PASSes with this fix)
 * unpatched non-ASAN-built GDB with ppc64 target crashes from commandline
 * unpatched non-ASAN-built GDB with ppc64 target PASSes from runtest (?)

gdb/ChangeLog
2015-02-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* elfread.c (elf_read_minimal_symbols): Use bfd_alloc for
	bfd_canonicalize_symtab.

gdb/testsuite/ChangeLog
2015-02-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.arch/cordic.ko.bz2: New file.
	* gdb.arch/cordic.ko.debug.bz2: New file.
	* gdb.arch/ppc64-symtab-cordic.exp: New file.
2015-02-26 14:08:01 +01:00
Tom Tromey e36122e9d7 Fix redefinition errors in C++ mode
In C, we can forward declare static structure instances.  That doesn't
work in C++ though.  C++ treats these as definitions.  So then the
compiler complains about symbol redefinition, like:

 src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
 src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here

The intent of static here is naturally to avoid making these objects
visible outside the compilation unit.  The equivalent in C++ would be
to instead define the objects in the anonymous namespace.  But given
that it's desirable to leave the codebase compiling as both C and C++
for a while, this just makes the objects extern.

(base_breakpoint_ops is already declared in breakpoint.h, so we can
just remove the forward declare from breakpoint.c)

gdb/ChangeLog:
2015-02-11  Tom Tromey  <tromey@redhat.com>
	    Pedro Alves <palves@redhat.com>

	* breakpoint.c (base_breakpoint_ops): Delete.
	* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
	* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
	* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
	* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
	* python/py-arch.c (arch_object_type): Make extern.
	* python/py-block.c (block_syms_iterator_object_type): Make extern.
	* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
	* python/py-cmd.c (cmdpy_object_type): Make extern.
	* python/py-continueevent.c (continue_event_object_type)
	* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
	parameter.  Update all callers.
	* python/py-evtregistry.c (eventregistry_object_type): Make extern.
	* python/py-exitedevent.c (exited_event_object_type): Make extern.
	* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
	* python/py-function.c (fnpy_object_type): Make extern.
	* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
	* python/py-infevents.c (call_pre_event_object_type)
	(inferior_call_post_event_object_type).
	(memory_changed_event_object_type): Make extern.
	* python/py-infthread.c (thread_object_type): Make extern.
	* python/py-lazy-string.c (lazy_string_object_type): Make extern.
	* python/py-linetable.c (linetable_entry_object_type)
	(linetable_object_type, ltpy_iterator_object_type): Make extern.
	* python/py-newobjfileevent.c (new_objfile_event_object_type)
	(clear_objfiles_event_object_type): Make extern.
	* python/py-objfile.c (objfile_object_type): Make extern.
	* python/py-param.c (parmpy_object_type): Make extern.
	* python/py-progspace.c (pspace_object_type): Make extern.
	* python/py-signalevent.c (signal_event_object_type): Make extern.
	* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
	* python/py-type.c (type_object_type, field_object_type)
	(type_iterator_object_type): Make extern.
	* python/python.c (python_extension_script_ops)
	(python_extension_ops): Make extern.
	* stap-probe.c (stap_probe_ops): Make extern.
2015-02-11 11:20:21 +00:00
Joel Brobecker 32d0add0a6 Update year range in copyright notice of all files owned by the GDB project.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2015-01-01 13:32:14 +04:00
Simon Marchi db7a9bcd53 A few comment cleanups
I stumbled upon a few comments that I think are outdated.

Comment for elfread.c (elf_symfile_init): As far as history goes in git,
I don't see anything related to that.

Comment for elfread.c (elf_symfile_read): References a parameter that was
removed in 1999.

Comment for struct sym_fns/sym_offsets: References a parameter that was
changed in 1999.

gdb/ChangeLog:

	* elfread.c (elf_symfile_init): Remove stale comment.
	(elf_symfile_read): Same.
	* symfile.h (struct sym_fns): Same.
2014-12-18 11:39:44 -05:00
Maciej W. Rozycki 3e29f34a4e MIPS: Keep the ISA bit in compressed code addresses
1. Background information

The MIPS architecture, as originally designed and implemented in
mid-1980s has a uniform instruction word size that is 4 bytes, naturally
aligned.  As such all MIPS instructions are located at addresses that
have their bits #1 and #0 set to zeroes, and any attempt to execute an
instruction from an address that has any of the two bits set to one
causes an address error exception.  This may for example happen when a
jump-register instruction is executed whose register value used as the
jump target has any of these bits set.

Then in mid 1990s LSI sought a way to improve code density for their
TinyRISC family of MIPS cores and invented an alternatively encoded
instruction set in a joint effort with MIPS Technologies (then a
subsidiary of SGI).  The new instruction set has been named the MIPS16
ASE (Application-Specific Extension) and uses a variable instruction
word size, which is 2 bytes (as the name of the ASE suggests) for most,
but there are a couple of exceptions that take 4 bytes, and then most of
the 2-byte instructions can be treated with a 2-byte extension prefix to
expand the range of the immediate operands used.

As a result instructions are no longer 4-byte aligned, instead they are
aligned to a multiple of 2.  That left the bit #0 still unused for code
references, be it for the standard MIPS (i.e. as originally invented) or
for the MIPS16 instruction set, and based on that observation a clever
trick was invented that on one hand allowed the processor to be
seamlessly switched between the two instruction sets at any time at the
run time while on the other avoided the introduction of any special
control register to do that.

So it is the bit #0 of the instruction address that was chosen as the
selector and named the ISA bit.  Any instruction executed at an even
address is interpreted as a standard MIPS instruction (the address still
has to have its bit #1 clear), any instruction executed at an odd
address is interpreted as a MIPS16 instruction.

To switch between modes ordinary jump instructions are used, such as
used for function calls and returns, specifically the bit #0 of the
source register used in jump-register instructions selects the execution
(ISA) mode for the following piece of code to be interpreted in.
Additionally new jump-immediate instructions were added that flipped the
ISA bit to select the opposite mode upon execution.  They were
considered necessary to avoid the need to make register jumps in all
cases as the original jump-immediate instructions provided no way to
change the bit #0 at all.

This was all important for cases where standard MIPS and MIPS16 code had
to be mixed, either for compatibility with the existing binary code base
or to access resources not reachable from MIPS16 code (the MIPS16
instruction set only provides access to general-purpose registers, and
not for example floating-point unit registers or privileged coprocessor
0 registers) -- pieces of code in the opposite mode can be executed as
ordinary subroutine calls.

A similar approach has been more recently adopted for the MIPS16
replacement instruction set defined as the so called microMIPS ASE.
This is another instruction set encoding introduced to the MIPS
architecture.  Just like the MIPS16 ASE, the microMIPS instruction set
uses a variable-length encoding, where each instruction takes a multiple
of 2 bytes.  The ISA bit has been reused and for microMIPS-capable
processors selects between the standard MIPS and the microMIPS mode
instead.

2. Statement of the problem

To put it shortly, MIPS16 and microMIPS code pointers used by GDB are
different to these observed at the run time.  This results in the same
expressions being evaluated producing different results in GDB and in
the program being debugged.  Obviously it's the results obtained at the
run time that are correct (they define how the program behaves) and
therefore by definition the results obtained in GDB are incorrect.

A bit longer description will record that obviously at the run time the
ISA bit has to be set correctly (refer to background information above
if unsure why so) or the program will not run as expected.  This is
recorded in all the executable file structures used at the run time: the
dynamic symbol table (but not always the static one!), the GOT, and
obviously in all the addresses embedded in code or data of the program
itself, calculated by applying the appropriate relocations at the static
link time.

While a program is being processed by GDB, the ISA bit is stripped off
from any code addresses, presumably to make them the same as the
respective raw memory byte address used by the processor to access the
instruction in the instruction fetch access cycle.  This stripping is
actually performed outside GDB proper, in BFD, specifically
_bfd_mips_elf_symbol_processing (elfxx-mips.c, see the piece of code at
the very bottom of that function, starting with an: "If this is an
odd-valued function symbol, assume it's a MIPS16 or microMIPS one."
comment).

This function is also responsible for symbol table dumps made by
`objdump' too, so you'll never see the ISA bit reported there by that
tool, you need to use `readelf'.

This is however unlike what is ever done at the run time, the ISA bit
once present is never stripped off, for example a cast like this:

(short *) main

will not strip the ISA bit off and if the resulting pointer is intended
to be used to access instructions as data, for example for software
instruction decoding (like for fault recovery or emulation in a signal
handler) or for self-modifying code then the bit still has to be
stripped off by an explicit AND operation.

This is probably best illustrated with a simple real program example.
Let's consider the following simple program:

$ cat foobar.c
int __attribute__ ((mips16)) foo (void)
{
  return 1;
}

int __attribute__ ((mips16)) bar (void)
{
  return 2;
}

int __attribute__ ((nomips16)) foo32 (void)
{
  return 3;
}

int (*foo32p) (void) = foo32;
int (*foop) (void) = foo;
int fooi = (int) foo;

int
main (void)
{
  return foop ();
}
$

This is plain C with no odd tricks, except from the instruction mode
attributes.  They are not necessary to trigger this problem, I just put
them here so that the program can be contained in a single source file
and to make it obvious which function is MIPS16 code and which is not.

Let's try it with Linux, so that everyone can repeat this experiment:

$ mips-linux-gnu-gcc -mips16 -g -O2 -o foobar foobar.c
$

Let's have a look at some interesting symbols:

$ mips-linux-gnu-readelf -s foobar | egrep 'table|foo|bar'
Symbol table '.dynsym' contains 7 entries:
Symbol table '.symtab' contains 95 entries:
    55: 00000000     0 FILE    LOCAL  DEFAULT  ABS foobar.c
    66: 0040068c     4 FUNC    GLOBAL DEFAULT [MIPS16]    12 bar
    68: 00410848     4 OBJECT  GLOBAL DEFAULT   21 foo32p
    70: 00410844     4 OBJECT  GLOBAL DEFAULT   21 foop
    78: 00400684     8 FUNC    GLOBAL DEFAULT   12 foo32
    80: 00400680     4 FUNC    GLOBAL DEFAULT [MIPS16]    12 foo
    88: 00410840     4 OBJECT  GLOBAL DEFAULT   21 fooi
$

Hmm, no sight of the ISA bit, but notice how foo and bar (but not
foo32!) have been marked as MIPS16 functions (ELF symbol structure's
`st_other' field is used for that).

So let's try to run and poke at this program with GDB.  I'll be using a
native system for simplicity (I'll be using ellipses here and there to
remove unrelated clutter):

$ ./foobar
$ echo $?
1
$

So far, so good.

$ gdb ./foobar
[...]
(gdb) break main
Breakpoint 1 at 0x400490: file foobar.c, line 23.
(gdb) run
Starting program: .../foobar

Breakpoint 1, main () at foobar.c:23
23        return foop ();
(gdb)

Yay, it worked!  OK, so let's poke at it:

(gdb) print main
$1 = {int (void)} 0x400490 <main>
(gdb) print foo32
$2 = {int (void)} 0x400684 <foo32>
(gdb) print foo32p
$3 = (int (*)(void)) 0x400684 <foo32>
(gdb) print bar
$4 = {int (void)} 0x40068c <bar>
(gdb) print foo
$5 = {int (void)} 0x400680 <foo>
(gdb) print foop
$6 = (int (*)(void)) 0x400681 <foo>
(gdb)

A-ha!  Here's the difference and finally the ISA bit!

(gdb) print /x fooi
$7 = 0x400681
(gdb) p/x $pc
p/x $pc
$8 = 0x400491
(gdb)

And here as well...

(gdb) advance foo
foo () at foobar.c:4
4       }
(gdb) disassemble
Dump of assembler code for function foo:
   0x00400680 <+0>:     jr      ra
   0x00400682 <+2>:     li      v0,1
End of assembler dump.
(gdb) finish
Run till exit from #0  foo () at foobar.c:4
main () at foobar.c:24
24      }
Value returned is $9 = 1
(gdb) continue
Continuing.
[Inferior 1 (process 14103) exited with code 01]
(gdb)

So let's be a bit inquisitive...

(gdb) run
Starting program: .../foobar

Breakpoint 1, main () at foobar.c:23
23        return foop ();
(gdb)

Actually we do not like to run foo here at all.  Let's run bar instead!

(gdb) set foop = bar
(gdb) print foop
$10 = (int (*)(void)) 0x40068c <bar>
(gdb)

Hmm, no ISA bit.  Is it going to work?

(gdb) advance bar
bar () at foobar.c:9
9       }
(gdb) p/x $pc
$11 = 0x40068c
(gdb) disassemble
Dump of assembler code for function bar:
=> 0x0040068c <+0>:     jr      ra
   0x0040068e <+2>:     li      v0,2
End of assembler dump.
(gdb) finish
Run till exit from #0  bar () at foobar.c:9

Program received signal SIGILL, Illegal instruction.
bar () at foobar.c:9
9       }
(gdb)

Oops!

(gdb) p/x $pc
$12 = 0x40068c
(gdb)

We're still there!

(gdb) continue
Continuing.

Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb)

So let's try something else:

(gdb) run
Starting program: .../foobar

Breakpoint 1, main () at foobar.c:23
23        return foop ();
(gdb) set foop = foo
(gdb) advance foo
foo () at foobar.c:4
4       }
(gdb) disassemble
Dump of assembler code for function foo:
=> 0x00400680 <+0>:     jr      ra
   0x00400682 <+2>:     li      v0,1
End of assembler dump.
(gdb) finish
Run till exit from #0  foo () at foobar.c:4

Program received signal SIGILL, Illegal instruction.
foo () at foobar.c:4
4       }
(gdb) continue
Continuing.

Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb)

The same problem!

(gdb) run
Starting program:
/net/build2-lucid-cs/scratch/macro/mips-linux-fsf-gcc/isa-bit/foobar

Breakpoint 1, main () at foobar.c:23
23        return foop ();
(gdb) set foop = foo32
(gdb) advance foo32
foo32 () at foobar.c:14
14      }
(gdb) disassemble
Dump of assembler code for function foo32:
=> 0x00400684 <+0>:     jr      ra
   0x00400688 <+4>:     li      v0,3
End of assembler dump.
(gdb) finish
Run till exit from #0  foo32 () at foobar.c:14
main () at foobar.c:24
24      }
Value returned is $14 = 3
(gdb) continue
Continuing.
[Inferior 1 (process 14113) exited with code 03]
(gdb)

That did work though, so it's the ISA bit only!

(gdb) quit

Enough!

That's the tip of the iceberg only though.  So let's rebuild the
executable with some dynamic symbols:

$ mips-linux-gnu-gcc -mips16 -Wl,--export-dynamic -g -O2 -o foobar-dyn foobar.c
$ mips-linux-gnu-readelf -s foobar-dyn | egrep 'table|foo|bar'
Symbol table '.dynsym' contains 32 entries:
     6: 004009cd     4 FUNC    GLOBAL DEFAULT   12 bar
     8: 00410b88     4 OBJECT  GLOBAL DEFAULT   21 foo32p
     9: 00410b84     4 OBJECT  GLOBAL DEFAULT   21 foop
    15: 004009c4     8 FUNC    GLOBAL DEFAULT   12 foo32
    17: 004009c1     4 FUNC    GLOBAL DEFAULT   12 foo
    25: 00410b80     4 OBJECT  GLOBAL DEFAULT   21 fooi
Symbol table '.symtab' contains 95 entries:
    55: 00000000     0 FILE    LOCAL  DEFAULT  ABS foobar.c
    69: 004009cd     4 FUNC    GLOBAL DEFAULT   12 bar
    71: 00410b88     4 OBJECT  GLOBAL DEFAULT   21 foo32p
    72: 00410b84     4 OBJECT  GLOBAL DEFAULT   21 foop
    79: 004009c4     8 FUNC    GLOBAL DEFAULT   12 foo32
    81: 004009c1     4 FUNC    GLOBAL DEFAULT   12 foo
    89: 00410b80     4 OBJECT  GLOBAL DEFAULT   21 fooi
$

OK, now the ISA bit is there for a change, but the MIPS16 `st_other'
attribute gone, hmm...  What does `objdump' do then:

$ mips-linux-gnu-objdump -Tt foobar-dyn | egrep 'SYMBOL|foo|bar'
foobar-dyn:     file format elf32-tradbigmips
SYMBOL TABLE:
00000000 l    df *ABS*  00000000              foobar.c
004009cc g     F .text  00000004              0xf0 bar
00410b88 g     O .data  00000004              foo32p
00410b84 g     O .data  00000004              foop
004009c4 g     F .text  00000008              foo32
004009c0 g     F .text  00000004              0xf0 foo
00410b80 g     O .data  00000004              fooi
DYNAMIC SYMBOL TABLE:
004009cc g    DF .text  00000004  Base        0xf0 bar
00410b88 g    DO .data  00000004  Base        foo32p
00410b84 g    DO .data  00000004  Base        foop
004009c4 g    DF .text  00000008  Base        foo32
004009c0 g    DF .text  00000004  Base        0xf0 foo
00410b80 g    DO .data  00000004  Base        fooi
$

Hmm, the attribute (0xf0, printed raw) is back, and the ISA bit gone
again.

Let's have a look at some DWARF-2 records GDB uses (I'll be stripping
off a lot here for brevity) -- debug info:

$ mips-linux-gnu-readelf -wi foobar
Contents of the .debug_info section:
[...]
  Compilation Unit @ offset 0x88:
   Length:        0xbb (32-bit)
   Version:       4
   Abbrev Offset: 62
   Pointer Size:  4
 <0><93>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <94>   DW_AT_producer    : (indirect string, offset: 0x19e): GNU C 4.8.0 20120513 (experimental) -meb -mips16 -march=mips32r2 -mhard-float -mllsc -mplt -mno-synci -mno-shared -mabi=32 -g -O2
    <98>   DW_AT_language    : 1        (ANSI C)
    <99>   DW_AT_name        : (indirect string, offset: 0x190): foobar.c
    <9d>   DW_AT_comp_dir    : (indirect string, offset: 0x225): [...]
    <a1>   DW_AT_ranges      : 0x0
    <a5>   DW_AT_low_pc      : 0x0
    <a9>   DW_AT_stmt_list   : 0x27
 <1><ad>: Abbrev Number: 2 (DW_TAG_subprogram)
    <ae>   DW_AT_external    : 1
    <ae>   DW_AT_name        : foo
    <b2>   DW_AT_decl_file   : 1
    <b3>   DW_AT_decl_line   : 1
    <b4>   DW_AT_prototyped  : 1
    <b4>   DW_AT_type        : <0xc2>
    <b8>   DW_AT_low_pc      : 0x400680
    <bc>   DW_AT_high_pc     : 0x400684
    <c0>   DW_AT_frame_base  : 1 byte block: 9c         (DW_OP_call_frame_cfa)
    <c2>   DW_AT_GNU_all_call_sites: 1
 <1><c2>: Abbrev Number: 3 (DW_TAG_base_type)
    <c3>   DW_AT_byte_size   : 4
    <c4>   DW_AT_encoding    : 5        (signed)
    <c5>   DW_AT_name        : int
 <1><c9>: Abbrev Number: 4 (DW_TAG_subprogram)
    <ca>   DW_AT_external    : 1
    <ca>   DW_AT_name        : (indirect string, offset: 0x18a): foo32
    <ce>   DW_AT_decl_file   : 1
    <cf>   DW_AT_decl_line   : 11
    <d0>   DW_AT_prototyped  : 1
    <d0>   DW_AT_type        : <0xc2>
    <d4>   DW_AT_low_pc      : 0x400684
    <d8>   DW_AT_high_pc     : 0x40068c
    <dc>   DW_AT_frame_base  : 1 byte block: 9c         (DW_OP_call_frame_cfa)
    <de>   DW_AT_GNU_all_call_sites: 1
 <1><de>: Abbrev Number: 2 (DW_TAG_subprogram)
    <df>   DW_AT_external    : 1
    <df>   DW_AT_name        : bar
    <e3>   DW_AT_decl_file   : 1
    <e4>   DW_AT_decl_line   : 6
    <e5>   DW_AT_prototyped  : 1
    <e5>   DW_AT_type        : <0xc2>
    <e9>   DW_AT_low_pc      : 0x40068c
    <ed>   DW_AT_high_pc     : 0x400690
    <f1>   DW_AT_frame_base  : 1 byte block: 9c         (DW_OP_call_frame_cfa)
    <f3>   DW_AT_GNU_all_call_sites: 1
 <1><f3>: Abbrev Number: 5 (DW_TAG_subprogram)
    <f4>   DW_AT_external    : 1
    <f4>   DW_AT_name        : (indirect string, offset: 0x199): main
    <f8>   DW_AT_decl_file   : 1
    <f9>   DW_AT_decl_line   : 21
    <fa>   DW_AT_prototyped  : 1
    <fa>   DW_AT_type        : <0xc2>
    <fe>   DW_AT_low_pc      : 0x400490
    <102>   DW_AT_high_pc     : 0x4004a4
    <106>   DW_AT_frame_base  : 1 byte block: 9c        (DW_OP_call_frame_cfa)
    <108>   DW_AT_GNU_all_tail_call_sites: 1
[...]
$

-- no sign of the ISA bit anywhere -- frame info:

$ mips-linux-gnu-readelf -wf foobar
[...]
Contents of the .debug_frame section:

00000000 0000000c ffffffff CIE
  Version:               1
  Augmentation:          ""
  Code alignment factor: 1
  Data alignment factor: -4
  Return address column: 31

  DW_CFA_def_cfa_register: r29
  DW_CFA_nop

00000010 0000000c 00000000 FDE cie=00000000 pc=00400680..00400684

00000020 0000000c 00000000 FDE cie=00000000 pc=00400684..0040068c

00000030 0000000c 00000000 FDE cie=00000000 pc=0040068c..00400690

00000040 00000018 00000000 FDE cie=00000000 pc=00400490..004004a4
  DW_CFA_advance_loc: 6 to 00400496
  DW_CFA_def_cfa_offset: 32
  DW_CFA_offset: r31 at cfa-4
  DW_CFA_advance_loc: 6 to 0040049c
  DW_CFA_restore: r31
  DW_CFA_def_cfa_offset: 0
  DW_CFA_nop
  DW_CFA_nop
  DW_CFA_nop
[...]
$

-- no sign of the ISA bit anywhere -- range info (GDB doesn't use arange):

$ mips-linux-gnu-readelf -wR foobar
Contents of the .debug_ranges section:

    Offset   Begin    End
    00000000 00400680 00400690
    00000000 00400490 004004a4
    00000000 <End of list>

$

-- no sign of the ISA bit anywhere -- line info:

$ mips-linux-gnu-readelf -wl foobar
Raw dump of debug contents of section .debug_line:
[...]
  Offset:                      0x27
  Length:                      78
  DWARF Version:               2
  Prologue Length:             31
  Minimum Instruction Length:  1
  Initial value of 'is_stmt':  1
  Line Base:                   -5
  Line Range:                  14
  Opcode Base:                 13

 Opcodes:
  Opcode 1 has 0 args
  Opcode 2 has 1 args
  Opcode 3 has 1 args
  Opcode 4 has 1 args
  Opcode 5 has 1 args
  Opcode 6 has 0 args
  Opcode 7 has 0 args
  Opcode 8 has 0 args
  Opcode 9 has 1 args
  Opcode 10 has 0 args
  Opcode 11 has 0 args
  Opcode 12 has 1 args

 The Directory Table is empty.

 The File Name Table:
  Entry Dir     Time    Size    Name
  1     0       0       0       foobar.c

 Line Number Statements:
  Extended opcode 2: set Address to 0x400681
  Special opcode 6: advance Address by 0 to 0x400681 and Line by 1 to 2
  Special opcode 7: advance Address by 0 to 0x400681 and Line by 2 to 4
  Special opcode 55: advance Address by 3 to 0x400684 and Line by 8 to 12
  Special opcode 7: advance Address by 0 to 0x400684 and Line by 2 to 14
  Advance Line by -7 to 7
  Special opcode 131: advance Address by 9 to 0x40068d and Line by 0 to 7
  Special opcode 7: advance Address by 0 to 0x40068d and Line by 2 to 9
  Advance PC by 3 to 0x400690
  Extended opcode 1: End of Sequence

  Extended opcode 2: set Address to 0x400491
  Advance Line by 21 to 22
  Copy
  Special opcode 6: advance Address by 0 to 0x400491 and Line by 1 to 23
  Special opcode 60: advance Address by 4 to 0x400495 and Line by -1 to 22
  Special opcode 34: advance Address by 2 to 0x400497 and Line by 1 to 23
  Special opcode 62: advance Address by 4 to 0x40049b and Line by 1 to 24
  Special opcode 32: advance Address by 2 to 0x40049d and Line by -1 to 23
  Special opcode 6: advance Address by 0 to 0x40049d and Line by 1 to 24
  Advance PC by 7 to 0x4004a4
  Extended opcode 1: End of Sequence
[...]

-- a-ha, the ISA bit is there!  However it's not always right for some
reason, I don't have a small test case to show it, but here's an excerpt
from MIPS16 libc, a prologue of a function:

00019630 <__libc_init_first>:
   19630:       e8a0            jrc     ra
   19632:       6500            nop

00019634 <_init>:
   19634:       f000 6a11       li      v0,17
   19638:       f7d8 0b08       la      v1,15e00 <_DYNAMIC+0x15c54>
   1963c:       f400 3240       sll     v0,16
   19640:       e269            addu    v0,v1
   19642:       659a            move    gp,v0
   19644:       64f6            save    48,ra,s0-s1
   19646:       671c            move    s0,gp
   19648:       d204            sw      v0,16(sp)
   1964a:       f352 984c       lw      v0,-27828(s0)
   1964e:       6724            move    s1,a0

and the corresponding DWARF-2 line info:

 Line Number Statements:
  Extended opcode 2: set Address to 0x19631
  Advance Line by 44 to 45
  Copy
  Special opcode 8: advance Address by 0 to 0x19631 and Line by 3 to 48
  Special opcode 66: advance Address by 4 to 0x19635 and Line by 5 to 53
  Advance PC by constant 17 to 0x19646
  Special opcode 25: advance Address by 1 to 0x19647 and Line by 6 to 59
  Advance Line by -6 to 53
  Special opcode 33: advance Address by 2 to 0x19649 and Line by 0 to 53
  Special opcode 39: advance Address by 2 to 0x1964b and Line by 6 to 59
  Advance Line by -6 to 53
  Special opcode 61: advance Address by 4 to 0x1964f and Line by 0 to 53

-- see that "Advance PC by constant 17" there?  It clears the ISA bit,
however code at 0x19646 is not standard MIPS code at all.  For some
reason the constant is always 17, I've never seen DW_LNS_const_add_pc
used with any other value -- is that a binutils bug or what?

3. Solution:

I think we should retain the value of the ISA bit in code references,
that is effectively treat them as cookies as they indeed are (although
trivially calculated) rather than raw memory byte addresses.

In a perfect world both the static symbol table and the respective
DWARF-2 records should be fixed to include the ISA bit in all the cases.
I think however that this is infeasible.

All the uses of `_bfd_mips_elf_symbol_processing' can not necessarily be
tracked down.  This function is used by `elf_slurp_symbol_table' that in
turn is used by `bfd_canonicalize_symtab' and
`bfd_canonicalize_dynamic_symtab', which are public interfaces.

Similarly DWARF-2 records are used outside GDB, one notable if a bit
questionable is the exception unwinder (libgcc/unwind-dw2.c) -- I have
identified at least bits in `execute_cfa_program' and
`uw_frame_state_for', both around the calls to `_Unwind_IsSignalFrame',
that would need an update as they effectively flip the ISA bit freely;
see also the comment about MASK_RETURN_ADDR in gcc/config/mips/mips.h.
But there may be more places.  Any change in how DWARF-2 records are
produced would require an update there and would cause compatibility
problems with libgcc.a binaries already distributed; given that this is
a static library a complex change involving function renames would
likely be required.

I propose therefore to accept the existing inconsistencies and deal with
them entirely within GDB.  I have figured out that the ISA bit lost in
various places can still be recovered as long as we have symbol
information -- that'll have the `st_other' attribute correctly set to
one of standard MIPS/MIPS16/microMIPS encoding.

Here's the resulting change.  It adds a couple of new `gdbarch' hooks,
one to update symbol information with the ISA bit lost in
`_bfd_mips_elf_symbol_processing', and two other ones to adjust DWARF-2
records as they're processed.  The ISA bit is set in each address
handled according to information retrieved from the symbol table for the
symbol spanning the address if any; limits are adjusted based on the
address they point to related to the respective base address.
Additionally minimal symbol information has to be adjusted accordingly
in its gdbarch hook.

With these changes in place some complications with ISA bit juggling in
the PC that never fully worked can be removed from the MIPS backend.
Conversely, the generic dynamic linker event special breakpoint symbol
handler has to be updated to call the minimal symbol gdbarch hook to
record that the symbol is a MIPS16 or microMIPS address if applicable or
the breakpoint will be set at the wrong address and either fail to work
or cause SIGTRAPs (this is because the symbol is handled early on and
bypasses regular symbol processing).

4. Results obtained

The change fixes the example above -- to repeat only the crucial steps:

(gdb) break main
Breakpoint 1 at 0x400491: file foobar.c, line 23.
(gdb) run
Starting program: .../foobar

Breakpoint 1, main () at foobar.c:23
23        return foop ();
(gdb) print foo
$1 = {int (void)} 0x400681 <foo>
(gdb) set foop = bar
(gdb) advance bar
bar () at foobar.c:9
9       }
(gdb) disassemble
Dump of assembler code for function bar:
=> 0x0040068d <+0>:     jr      ra
   0x0040068f <+2>:     li      v0,2
End of assembler dump.
(gdb) finish
Run till exit from #0  bar () at foobar.c:9
main () at foobar.c:24
24      }
Value returned is $2 = 2
(gdb) continue
Continuing.
[Inferior 1 (process 14128) exited with code 02]
(gdb)

-- excellent!

The change removes about 90 failures per MIPS16 multilib in mips-sde-elf
testing too, results for MIPS16 are now similar to that for standard
MIPS; microMIPS results are a bit worse because of host-I/O problems in
QEMU used instead of MIPSsim for microMIPS testing only:

                === gdb Summary ===

# of expected passes            14299
# of unexpected failures        187
# of expected failures          56
# of known failures             58
# of unresolved testcases       11
# of untested testcases         52
# of unsupported tests          174

MIPS16:

                === gdb Summary ===

# of expected passes            14298
# of unexpected failures        187
# of unexpected successes       2
# of expected failures          54
# of known failures             58
# of unresolved testcases       12
# of untested testcases         52
# of unsupported tests          174

microMIPS:

                === gdb Summary ===

# of expected passes            14149
# of unexpected failures        201
# of unexpected successes       2
# of expected failures          54
# of known failures             58
# of unresolved testcases       7
# of untested testcases         53
# of unsupported tests          175

2014-12-12  Maciej W. Rozycki  <macro@codesourcery.com>
            Maciej W. Rozycki  <macro@mips.com>
            Pedro Alves  <pedro@codesourcery.com>

	gdb/
	* gdbarch.sh (elf_make_msymbol_special): Change type to `F',
	remove `predefault' and `invalid_p' initializers.
	(make_symbol_special): New architecture method.
	(adjust_dwarf2_addr, adjust_dwarf2_line): Likewise.
	(objfile, symbol): New declarations.
	* arch-utils.h (default_elf_make_msymbol_special): Remove
	prototype.
	(default_make_symbol_special): New prototype.
	(default_adjust_dwarf2_addr): Likewise.
	(default_adjust_dwarf2_line): Likewise.
	* mips-tdep.h (mips_unmake_compact_addr): New prototype.
	* arch-utils.c (default_elf_make_msymbol_special): Remove
	function.
	(default_make_symbol_special): New function.
	(default_adjust_dwarf2_addr): Likewise.
	(default_adjust_dwarf2_line): Likewise.
	* dwarf2-frame.c (decode_frame_entry_1): Call
	`gdbarch_adjust_dwarf2_addr'.
	* dwarf2loc.c (dwarf2_find_location_expression): Likewise.
	* dwarf2read.c (create_addrmap_from_index): Likewise.
	(process_psymtab_comp_unit_reader): Likewise.
	(add_partial_symbol): Likewise.
	(add_partial_subprogram): Likewise.
	(process_full_comp_unit): Likewise.
	(read_file_scope): Likewise.
	(read_func_scope): Likewise.  Call `gdbarch_make_symbol_special'.
	(read_lexical_block_scope): Call `gdbarch_adjust_dwarf2_addr'.
	(read_call_site_scope): Likewise.
	(dwarf2_ranges_read): Likewise.
	(dwarf2_record_block_ranges): Likewise.
	(read_attribute_value): Likewise.
	(dwarf_decode_lines_1): Call `gdbarch_adjust_dwarf2_line'.
	(new_symbol_full): Call `gdbarch_adjust_dwarf2_addr'.
	* elfread.c (elf_symtab_read): Don't call
	`gdbarch_elf_make_msymbol_special' if unset.
	* mips-linux-tdep.c (micromips_linux_sigframe_validate): Strip
	the ISA bit from the PC.
	* mips-tdep.c (mips_unmake_compact_addr): New function.
	(mips_elf_make_msymbol_special): Set the ISA bit in the symbol's
	address appropriately.
	(mips_make_symbol_special): New function.
	(mips_pc_is_mips): Set the ISA bit before symbol lookup.
	(mips_pc_is_mips16): Likewise.
	(mips_pc_is_micromips): Likewise.
	(mips_pc_isa): Likewise.
	(mips_adjust_dwarf2_addr): New function.
	(mips_adjust_dwarf2_line): Likewise.
	(mips_read_pc, mips_unwind_pc): Keep the ISA bit.
	(mips_addr_bits_remove): Likewise.
	(mips_skip_trampoline_code): Likewise.
	(mips_write_pc): Don't set the ISA bit.
	(mips_eabi_push_dummy_call): Likewise.
	(mips_o64_push_dummy_call): Likewise.
	(mips_gdbarch_init): Install `mips_make_symbol_special',
	`mips_adjust_dwarf2_addr' and `mips_adjust_dwarf2_line' gdbarch
	handlers.
	* solib.c (gdb_bfd_lookup_symbol_from_symtab): Get
	target-specific symbol address adjustments.
	* gdbarch.h: Regenerate.
	* gdbarch.c: Regenerate.

2014-12-12  Maciej W. Rozycki  <macro@codesourcery.com>

	gdb/testsuite/
	* gdb.base/func-ptrs.c: New file.
	* gdb.base/func-ptrs.exp: New file.
2014-12-12 13:49:06 +00:00
Maciej W. Rozycki 9b807e7bbb Also mark ELF solib trampoline minimal symbols special
In installing minimal symbols for ELF shared library trampolines
we "forget" to make individual symbols special where required.  This
leads to problems on the MIPS target using microMIPS SVR4 lazy stubs.
Lacking the special annotation these stubs are treated as standard
MIPS code and this makes GDB insert the wrong software breakpoint
instruction, breaking e.g. single-stepping through these stubs.  This
is not a very frequent scenario as microMIPS SVR4 lazy stubs are
typically only used in shared libraries with the main executable
using PLT, handled elsewhere.  Still it triggers e.g. when a software
watchpoint has been installed.  The symptom is SIGILL or the program
going astray, depending on the endianness.  Disassembly of these stubs
is also wrong.

	* elfread.c (elf_symtab_read): Also mark solib trampoline minimal
	symbols special.
2014-10-03 17:38:39 +01:00
Gary Benson 6d3d12ebef Include string.h in common-defs.h
This commit includes string.h in common-defs.h and removes all other
inclusions.

gdb/
2014-08-07  Gary Benson  <gbenson@redhat.com>

	* common/common-defs.h: Include string.h.
	* aarch64-tdep.c: Do not include string.h.
	* ada-exp.y: Likewise.
	* ada-lang.c: Likewise.
	* ada-lex.l: Likewise.
	* ada-typeprint.c: Likewise.
	* ada-valprint.c: Likewise.
	* aix-thread.c: Likewise.
	* alpha-linux-tdep.c: Likewise.
	* alpha-mdebug-tdep.c: Likewise.
	* alpha-nat.c: Likewise.
	* alpha-osf1-tdep.c: Likewise.
	* alpha-tdep.c: Likewise.
	* alphanbsd-tdep.c: Likewise.
	* amd64-dicos-tdep.c: Likewise.
	* amd64-linux-tdep.c: Likewise.
	* amd64-nat.c: Likewise.
	* amd64-sol2-tdep.c: Likewise.
	* amd64fbsd-tdep.c: Likewise.
	* amd64obsd-tdep.c: Likewise.
	* arch-utils.c: Likewise.
	* arm-linux-nat.c: Likewise.
	* arm-linux-tdep.c: Likewise.
	* arm-tdep.c: Likewise.
	* arm-wince-tdep.c: Likewise.
	* armbsd-tdep.c: Likewise.
	* armnbsd-nat.c: Likewise.
	* armnbsd-tdep.c: Likewise.
	* armobsd-tdep.c: Likewise.
	* avr-tdep.c: Likewise.
	* ax-gdb.c: Likewise.
	* ax-general.c: Likewise.
	* bcache.c: Likewise.
	* bfin-tdep.c: Likewise.
	* breakpoint.c: Likewise.
	* build-id.c: Likewise.
	* buildsym.c: Likewise.
	* c-exp.y: Likewise.
	* c-lang.c: Likewise.
	* c-typeprint.c: Likewise.
	* c-valprint.c: Likewise.
	* charset.c: Likewise.
	* cli-out.c: Likewise.
	* cli/cli-cmds.c: Likewise.
	* cli/cli-decode.c: Likewise.
	* cli/cli-dump.c: Likewise.
	* cli/cli-interp.c: Likewise.
	* cli/cli-logging.c: Likewise.
	* cli/cli-script.c: Likewise.
	* cli/cli-setshow.c: Likewise.
	* cli/cli-utils.c: Likewise.
	* coffread.c: Likewise.
	* common/agent.c: Likewise.
	* common/buffer.c: Likewise.
	* common/buffer.h: Likewise.
	* common/common-utils.c: Likewise.
	* common/filestuff.c: Likewise.
	* common/filestuff.c: Likewise.
	* common/format.c: Likewise.
	* common/print-utils.c: Likewise.
	* common/rsp-low.c: Likewise.
	* common/signals.c: Likewise.
	* common/vec.h: Likewise.
	* common/xml-utils.c: Likewise.
	* core-regset.c: Likewise.
	* corefile.c: Likewise.
	* corelow.c: Likewise.
	* cp-abi.c: Likewise.
	* cp-name-parser.y: Likewise.
	* cp-support.c: Likewise.
	* cp-valprint.c: Likewise.
	* cris-tdep.c: Likewise.
	* d-exp.y: Likewise.
	* darwin-nat.c: Likewise.
	* dbxread.c: Likewise.
	* dcache.c: Likewise.
	* demangle.c: Likewise.
	* dicos-tdep.c: Likewise.
	* disasm.c: Likewise.
	* doublest.c: Likewise.
	* dsrec.c: Likewise.
	* dummy-frame.c: Likewise.
	* dwarf2-frame.c: Likewise.
	* dwarf2loc.c: Likewise.
	* dwarf2read.c: Likewise.
	* elfread.c: Likewise.
	* environ.c: Likewise.
	* eval.c: Likewise.
	* event-loop.c: Likewise.
	* exceptions.c: Likewise.
	* exec.c: Likewise.
	* expprint.c: Likewise.
	* f-exp.y: Likewise.
	* f-lang.c: Likewise.
	* f-typeprint.c: Likewise.
	* f-valprint.c: Likewise.
	* fbsd-nat.c: Likewise.
	* findcmd.c: Likewise.
	* findvar.c: Likewise.
	* fork-child.c: Likewise.
	* frame.c: Likewise.
	* frv-linux-tdep.c: Likewise.
	* frv-tdep.c: Likewise.
	* gdb.c: Likewise.
	* gdb_bfd.c: Likewise.
	* gdbarch.c: Likewise.
	* gdbarch.sh: Likewise.
	* gdbtypes.c: Likewise.
	* gnu-nat.c: Likewise.
	* gnu-v2-abi.c: Likewise.
	* gnu-v3-abi.c: Likewise.
	* go-exp.y: Likewise.
	* go-lang.c: Likewise.
	* go32-nat.c: Likewise.
	* guile/guile.c: Likewise.
	* guile/scm-auto-load.c: Likewise.
	* hppa-hpux-tdep.c: Likewise.
	* hppa-linux-nat.c: Likewise.
	* hppanbsd-tdep.c: Likewise.
	* hppaobsd-tdep.c: Likewise.
	* i386-cygwin-tdep.c: Likewise.
	* i386-dicos-tdep.c: Likewise.
	* i386-linux-tdep.c: Likewise.
	* i386-nto-tdep.c: Likewise.
	* i386-sol2-tdep.c: Likewise.
	* i386-tdep.c: Likewise.
	* i386bsd-tdep.c: Likewise.
	* i386gnu-nat.c: Likewise.
	* i386nbsd-tdep.c: Likewise.
	* i386obsd-tdep.c: Likewise.
	* i387-tdep.c: Likewise.
	* ia64-libunwind-tdep.c: Likewise.
	* ia64-linux-nat.c: Likewise.
	* inf-child.c: Likewise.
	* inf-ptrace.c: Likewise.
	* inf-ttrace.c: Likewise.
	* infcall.c: Likewise.
	* infcmd.c: Likewise.
	* inflow.c: Likewise.
	* infrun.c: Likewise.
	* interps.c: Likewise.
	* iq2000-tdep.c: Likewise.
	* irix5-nat.c: Likewise.
	* jv-exp.y: Likewise.
	* jv-lang.c: Likewise.
	* jv-typeprint.c: Likewise.
	* jv-valprint.c: Likewise.
	* language.c: Likewise.
	* linux-fork.c: Likewise.
	* linux-nat.c: Likewise.
	* lm32-tdep.c: Likewise.
	* m2-exp.y: Likewise.
	* m2-typeprint.c: Likewise.
	* m32c-tdep.c: Likewise.
	* m32r-linux-nat.c: Likewise.
	* m32r-linux-tdep.c: Likewise.
	* m32r-rom.c: Likewise.
	* m32r-tdep.c: Likewise.
	* m68hc11-tdep.c: Likewise.
	* m68k-tdep.c: Likewise.
	* m68kbsd-tdep.c: Likewise.
	* m68klinux-nat.c: Likewise.
	* m68klinux-tdep.c: Likewise.
	* m88k-tdep.c: Likewise.
	* machoread.c: Likewise.
	* macrocmd.c: Likewise.
	* main.c: Likewise.
	* mdebugread.c: Likewise.
	* mem-break.c: Likewise.
	* memattr.c: Likewise.
	* memory-map.c: Likewise.
	* mep-tdep.c: Likewise.
	* mi/mi-cmd-break.c: Likewise.
	* mi/mi-cmd-disas.c: Likewise.
	* mi/mi-cmd-env.c: Likewise.
	* mi/mi-cmd-stack.c: Likewise.
	* mi/mi-cmd-var.c: Likewise.
	* mi/mi-cmds.c: Likewise.
	* mi/mi-console.c: Likewise.
	* mi/mi-getopt.c: Likewise.
	* mi/mi-interp.c: Likewise.
	* mi/mi-main.c: Likewise.
	* mi/mi-parse.c: Likewise.
	* microblaze-rom.c: Likewise.
	* microblaze-tdep.c: Likewise.
	* mingw-hdep.c: Likewise.
	* minidebug.c: Likewise.
	* minsyms.c: Likewise.
	* mips-irix-tdep.c: Likewise.
	* mips-linux-tdep.c: Likewise.
	* mips-tdep.c: Likewise.
	* mips64obsd-tdep.c: Likewise.
	* mipsnbsd-tdep.c: Likewise.
	* mipsread.c: Likewise.
	* mn10300-linux-tdep.c: Likewise.
	* mn10300-tdep.c: Likewise.
	* monitor.c: Likewise.
	* moxie-tdep.c: Likewise.
	* mt-tdep.c: Likewise.
	* nat/linux-btrace.c: Likewise.
	* nat/linux-osdata.c: Likewise.
	* nat/linux-procfs.c: Likewise.
	* nat/linux-ptrace.c: Likewise.
	* nat/linux-waitpid.c: Likewise.
	* nbsd-tdep.c: Likewise.
	* nios2-linux-tdep.c: Likewise.
	* nto-procfs.c: Likewise.
	* nto-tdep.c: Likewise.
	* objc-lang.c: Likewise.
	* objfiles.c: Likewise.
	* opencl-lang.c: Likewise.
	* osabi.c: Likewise.
	* osdata.c: Likewise.
	* p-exp.y: Likewise.
	* p-lang.c: Likewise.
	* p-typeprint.c: Likewise.
	* parse.c: Likewise.
	* posix-hdep.c: Likewise.
	* ppc-linux-nat.c: Likewise.
	* ppc-sysv-tdep.c: Likewise.
	* ppcfbsd-tdep.c: Likewise.
	* ppcnbsd-tdep.c: Likewise.
	* ppcobsd-tdep.c: Likewise.
	* printcmd.c: Likewise.
	* procfs.c: Likewise.
	* prologue-value.c: Likewise.
	* python/py-auto-load.c: Likewise.
	* python/py-gdb-readline.c: Likewise.
	* ravenscar-thread.c: Likewise.
	* regcache.c: Likewise.
	* registry.c: Likewise.
	* remote-fileio.c: Likewise.
	* remote-m32r-sdi.c: Likewise.
	* remote-mips.c: Likewise.
	* remote-notif.c: Likewise.
	* remote-sim.c: Likewise.
	* remote.c: Likewise.
	* reverse.c: Likewise.
	* rs6000-aix-tdep.c: Likewise.
	* ser-base.c: Likewise.
	* ser-go32.c: Likewise.
	* ser-mingw.c: Likewise.
	* ser-pipe.c: Likewise.
	* ser-tcp.c: Likewise.
	* ser-unix.c: Likewise.
	* serial.c: Likewise.
	* sh-tdep.c: Likewise.
	* sh64-tdep.c: Likewise.
	* shnbsd-tdep.c: Likewise.
	* skip.c: Likewise.
	* sol-thread.c: Likewise.
	* solib-dsbt.c: Likewise.
	* solib-frv.c: Likewise.
	* solib-osf.c: Likewise.
	* solib-som.c: Likewise.
	* solib-spu.c: Likewise.
	* solib-target.c: Likewise.
	* solib.c: Likewise.
	* somread.c: Likewise.
	* source.c: Likewise.
	* sparc-nat.c: Likewise.
	* sparc-sol2-tdep.c: Likewise.
	* sparc-tdep.c: Likewise.
	* sparc64-tdep.c: Likewise.
	* sparc64fbsd-tdep.c: Likewise.
	* sparc64nbsd-tdep.c: Likewise.
	* sparcnbsd-tdep.c: Likewise.
	* spu-linux-nat.c: Likewise.
	* spu-multiarch.c: Likewise.
	* spu-tdep.c: Likewise.
	* stabsread.c: Likewise.
	* stack.c: Likewise.
	* std-regs.c: Likewise.
	* symfile.c: Likewise.
	* symmisc.c: Likewise.
	* symtab.c: Likewise.
	* target.c: Likewise.
	* thread.c: Likewise.
	* tilegx-linux-nat.c: Likewise.
	* tilegx-tdep.c: Likewise.
	* top.c: Likewise.
	* tracepoint.c: Likewise.
	* tui/tui-command.c: Likewise.
	* tui/tui-data.c: Likewise.
	* tui/tui-disasm.c: Likewise.
	* tui/tui-file.c: Likewise.
	* tui/tui-layout.c: Likewise.
	* tui/tui-out.c: Likewise.
	* tui/tui-regs.c: Likewise.
	* tui/tui-source.c: Likewise.
	* tui/tui-stack.c: Likewise.
	* tui/tui-win.c: Likewise.
	* tui/tui-windata.c: Likewise.
	* tui/tui-winsource.c: Likewise.
	* typeprint.c: Likewise.
	* ui-file.c: Likewise.
	* ui-out.c: Likewise.
	* user-regs.c: Likewise.
	* utils.c: Likewise.
	* v850-tdep.c: Likewise.
	* valarith.c: Likewise.
	* valops.c: Likewise.
	* valprint.c: Likewise.
	* value.c: Likewise.
	* varobj.c: Likewise.
	* vax-tdep.c: Likewise.
	* vaxnbsd-tdep.c: Likewise.
	* vaxobsd-tdep.c: Likewise.
	* windows-nat.c: Likewise.
	* xcoffread.c: Likewise.
	* xml-support.c: Likewise.
	* xstormy16-tdep.c: Likewise.
	* xtensa-linux-nat.c: Likewise.

gdb/gdbserver/
2014-08-07  Gary Benson  <gbenson@redhat.com>

	* server.h: Do not include string.h.
	* event-loop.c: Likewise.
	* linux-low.c: Likewise.
	* regcache.c: Likewise.
	* remote-utils.c: Likewise.
	* spu-low.c: Likewise.
	* utils.c: Likewise.
2014-08-07 09:06:47 +01:00
Tom Tromey 5d9cf8a4d3 move probes to be per-bfd
This patch moves the probe data from the objfile to the per-BFD
object.  This lets the probes be shared between different inferiors
(and different objfiles when dlmopen is in use, should gdb ever handle
that).

2014-03-03  Tom Tromey  <tromey@redhat.com>

	* elfread.c (probe_key): Change to bfd_data.
	(elf_get_probes, probe_key_free, _initialize_elfread): Probes are
	now per-BFD, not per-objfile.
	* stap-probe.c (stap_probe_destroy): Update comment.
	(handle_stap_probe): Allocate on the per-BFD obstack.
2014-03-03 12:47:25 -07:00
Tom Tromey 729662a522 change probes to be program-space-independent
This changes the probes to be independent of the program space.

After this, when a probe's address is needed, it is determined by
applying offsets at the point of use.

This introduces a bound_probe object, similar to bound minimal
symbols.  Objects of this type are used when it's necessary to pass a
probe and its corresponding objfile.

This removes the backlink from probe to objfile, which was primarily
used to fetch the architecture to use.

This adds a get_probe_address function which calls a probe method to
compute the probe's relocated address.  Similarly, it adds an objfile
parameter to the semaphore methods so they can do the relocation
properly as well.

2014-03-03  Tom Tromey  <tromey@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Use bound probes.
	* breakpoint.c (create_longjmp_master_breakpoint): Use
	get_probe_address.
	(add_location_to_breakpoint, bkpt_probe_insert_location)
	(bkpt_probe_remove_location): Update.
	* breakpoint.h (struct bp_location) <probe>: Now a bound_probe.
	* elfread.c (elf_symfile_relocate_probe): Remove.
	(elf_probe_fns): Update.
	(insert_exception_resume_breakpoint): Change type of "probe"
	parameter to bound_probe.
	(check_exception_resume): Update.
	* objfiles.c (objfile_relocate1): Don't relocate probes.
	* probe.c (bound_probe_s): New typedef.
	(parse_probes): Use get_probe_address.  Set sal's objfile.
	(find_probe_by_pc): Return a bound_probe.
	(collect_probes): Return a VEC(bound_probe_s).
	(compare_probes): Update.
	(gen_ui_out_table_header_info): Change type of "probes"
	parameter.  Update.
	(info_probes_for_ops): Update.
	(get_probe_address): New function.
	(probe_safe_evaluate_at_pc): Update.
	* probe.h (struct probe_ops) <get_probe_address>: New field.
	<set_semaphore, clear_semaphore>: Add objfile parameter.
	(struct probe) <objfile>: Remove field.
	<arch>: New field.
	<address>: Update comment.
	(struct bound_probe): New.
	(find_probe_by_pc): Return a bound_probe.
	(get_probe_address): Declare.
	* solib-svr4.c (struct probe_and_action) <address>: New field.
	(hash_probe_and_action, equal_probe_and_action): Update.
	(register_solib_event_probe): Add address parameter.
	(solib_event_probe_at): Update.
	(svr4_create_probe_breakpoints): Add objfile parameter.  Use
	get_probe_address.
	* stap-probe.c (struct stap_probe) <sem_addr>: Update comment.
	(stap_get_probe_address): New function.
	(stap_can_evaluate_probe_arguments, compute_probe_arg)
	(compile_probe_arg): Update.
	(stap_set_semaphore, stap_clear_semaphore): Compute semaphore's
	address.
	(handle_stap_probe): Don't relocate the probe.
	(stap_relocate): Remove.
	(stap_gen_info_probes_table_values): Update.
	(stap_probe_ops): Remove stap_relocate.
	* symfile-debug.c (debug_sym_relocate_probe): Remove.
	(debug_sym_probe_fns): Update.
	* symfile.h (struct sym_probe_fns) <sym_relocate_probe>: Remove.
	* symtab.c (init_sal): Use memset.
	* symtab.h (struct symtab_and_line) <objfile>: New field.
	* tracepoint.c (start_tracing, stop_tracing): Update.
2014-03-03 12:47:20 -07:00
Tom Tromey 5f6cac4085 add short-circuit logic to elfread.c
If minimal symbols have already been read into a per-BFD object, then
a symbol reader can skip re-reading them.  This changes the ELF reader
to do so.

We only skip the work if the file is ELF+DWARF.  If it has stabs or
mdebug sections, then I think extra information is computed during the
minsym creation pass; and so we must still repeat it.  Eventually even
this will go away, once all symbol types have switched to being
progspace-independent.  In the meantime this has no negative effect --
it is just a missing optimization for a small set of users.

This change also required a somewhat non-obvious change to the OBJSTAT
accounting code.  If a symbol reader skips re-reading minimal symbols,
then the corresponding OBJSTAT will not be updated.  This leads to a
test failure in gdb.base/maint.exp.

To fix this, I've moved the needed stat field out of objfile and into
the per-BFD object.

2014-02-26  Tom Tromey  <tromey@redhat.com>

	* elfread.c (elf_read_minimal_symbols): Return early if
	minimal symbols have already been read.  Add "ei" parameter.
	(elf_symfile_read): Call elf_read_minimal_symbols earlier.
	* minsyms.c (prim_record_minimal_symbol_full): Update.
	* objfiles.h (struct objstats) <n_minsyms>: Move...
	(struct objfile_per_bfd_storage) <n_minsyms>: ... here.
	* symmisc.c (print_objfile_statistics): Update.
2014-02-26 12:11:18 -07:00
Tom Tromey 2750ef2799 split out elf_read_minimal_symbols
This is just a simple refactoring in elfread.c to split out the
minsym-reading code into its own function.

2014-02-26  Tom Tromey  <tromey@redhat.com>

	* elfread.c (elf_read_minimal_symbols): New function, from
	elf_symfile_read.
	(elf_symfile_read): Call it.
2014-02-26 12:11:18 -07:00
Tom Tromey 2273f0ac95 change minsyms not to be relocated at read-time
This removes the runtime offsets from minsyms.  Instead, these offsets
will now be applied whenever the minsym's address is computed.

This patch redefines MSYMBOL_VALUE_ADDRESS to actually use the offsets
from the given objfile.  Then, it updates all the symbol readers,
changing them so that they do not add in the section offset when
creating the symbol.

This change also lets us remove relocation of minsyms from
objfile_relocate1 and also msymbols_sort.

2014-02-26  Tom Tromey  <tromey@redhat.com>

	* minsyms.c (msymbols_sort): Remove.
	* minsyms.h (msymbols_sort): Remove.
	* objfiles.c (objfile_relocate1): Don't relocate minsyms.
	* symtab.h (MSYMBOL_VALUE_ADDRESS): Use objfile offsets.
	* elfread.c (elf_symtab_read): Don't add section offsets.
	* xcoffread.c (record_minimal_symbol): Don't add section offset
	to minimal symbol address.
	* somread.c (text_offset, data_offset): Remove.
	(som_symtab_read): Don't add section offsets to minimal symbol
	addresses.
	* coff-pe-read.c (add_pe_forwarded_sym, read_pe_exported_syms):
	Don't add section offsets to minimal symbols.
	* coffread.c (coff_symtab_read): Don't add section offsets
	to minimal symbol addresses.
	* machoread.c (macho_symtab_add_minsym): Don't add section offset
	to minimal symbol addresses.
	* mipsread.c (read_alphacoff_dynamic_symtab): Don't add
	section offset to minimal symbol addresses.
	* mdebugread.c (parse_partial_symbols): Don't add section
	offset to minimal symbol addresses.
	* dbxread.c (read_dbx_dynamic_symtab): Don't add section
	offset to minimal symbol addresses.
2014-02-26 12:11:17 -07:00
Tom Tromey 77e371c079 start change to progspace independence
This patch starts changing minimal symbols to be independent of the
program space.

Specifically, it adds a new objfile parameter to MSYMBOL_VALUE_ADDRESS
and changes all the code to use it.  This is needed so we can change
gdb to apply the section offset when a minsym's address is computed,
as opposed to baking the offsets into the symbol itself.

A few spots still need the unrelocated address.  For these, we
introduce MSYMBOL_VALUE_RAW_ADDRESS.

As a convenience, we also add the new macro BMSYMBOL_VALUE_ADDRESS,
which computes the address of a bound minimal symbol.  This just does
the obvious thing with the fields.

Note that this change does not actually enable program space
independence.  That requires more changes to gdb.  However, to ensure
that these changes compile properly, this patch does add the needed
section lookup code to MSYMBOL_VALUE_ADDRESS -- it just ensures it has
no effect at runtime by multiplying the offset by 0.

2014-02-26  Tom Tromey  <tromey@redhat.com>

	* ada-lang.c (ada_main_name): Update.
	(ada_add_standard_exceptions): Update.
	* ada-tasks.c (ada_tasks_inferior_data_sniffer): Update.
	* aix-thread.c (pdc_symbol_addrs, pd_enable): Update.
	* arm-tdep.c (skip_prologue_function, arm_skip_stub): Update.
	* auxv.c (ld_so_xfer_auxv): Update.
	* avr-tdep.c (avr_scan_prologue): Update.
	* ax-gdb.c (gen_var_ref): Update.
	* blockframe.c (get_pc_function_start)
	(find_pc_partial_function_gnu_ifunc): Update.
	* breakpoint.c (create_overlay_event_breakpoint)
	(create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint): Update.
	* bsd-uthread.c (bsd_uthread_lookup_address): Update.
	* c-valprint.c (c_val_print): Update.
	* coff-pe-read.c (add_pe_forwarded_sym): Update.
	* common/agent.c (agent_look_up_symbols): Update.
	* dbxread.c (find_stab_function_addr, end_psymtab): Update.
	* dwarf2loc.c (call_site_to_target_addr): Update.
	* dwarf2read.c (dw2_find_pc_sect_symtab): Update.
	* elfread.c (elf_gnu_ifunc_record_cache)
	(elf_gnu_ifunc_resolve_by_got): Update.
	* findvar.c (default_read_var_value): Update.
	* frame.c (inside_main_func): Update.
	* frv-tdep.c (frv_frame_this_id): Update.
	* glibc-tdep.c (glibc_skip_solib_resolver): Update.
	* gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline):
	Update.
	* hppa-hpux-tdep.c (hppa64_hpux_search_dummy_call_sequence)
	(hppa_hpux_find_dummy_bpaddr): Update.
	* hppa-tdep.c (hppa_symbol_address): Update.
	* infcmd.c (until_next_command): Update.
	* jit.c (jit_read_descriptor, jit_breakpoint_re_set_internal):
	Update.
	* linespec.c (minsym_found, add_minsym): Update.
	* linux-nat.c (get_signo): Update.
	* linux-thread-db.c (inferior_has_bug): Update.
	* m32c-tdep.c (m32c_return_value)
	(m32c_m16c_address_to_pointer): Update.
	* m32r-tdep.c (m32r_frame_this_id): Update.
	* m68hc11-tdep.c (m68hc11_get_register_info): Update.
	* machoread.c (macho_resolve_oso_sym_with_minsym): Update.
	* maint.c (maintenance_translate_address): Update.
	* minsyms.c (lookup_minimal_symbol_by_pc_name): Update.
	(frob_address): New function.
	(lookup_minimal_symbol_by_pc_section_1): Use raw addresses,
	frob_address.  Rename parameter to "pc_in".
	(compare_minimal_symbols, compact_minimal_symbols): Use raw
	addresses.
	(find_solib_trampoline_target, minimal_symbol_upper_bound):
	Update.
	* mips-linux-tdep.c (mips_linux_skip_resolver): Update.
	* mips-tdep.c (mips_skip_pic_trampoline_code): Update.
	* objc-lang.c (find_objc_msgsend): Update.
	* objfiles.c (objfile_relocate1): Update.
	* obsd-tdep.c (obsd_skip_solib_resolver): Update.
	* p-valprint.c (pascal_val_print): Update.
	* parse.c (write_exp_msymbol): Update.
	* ppc-linux-tdep.c (ppc_linux_spe_context_lookup)
	(ppc_elfv2_skip_entrypoint): Update.
	* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
	* printcmd.c (build_address_symbolic, msym_info)
	(address_info): Update.
	* proc-service.c (ps_pglobal_lookup): Update.
	* psymtab.c (find_pc_sect_psymtab_closer)
	(find_pc_sect_psymtab, find_pc_sect_symtab_from_partial):
	Change msymbol parameter to bound_minimal_symbol.
	* ravenscar-thread.c (get_running_thread_id): Update.
	* remote.c (remote_check_symbols): Update.
	* sh64-tdep.c (sh64_elf_make_msymbol_special): Use raw
	address.
	* sol2-tdep.c (sol2_skip_solib_resolver): Update.
	* solib-dsbt.c (lm_base): Update.
	* solib-frv.c (lm_base, main_got): Update.
	* solib-irix.c (locate_base): Update.
	* solib-som.c (som_solib_create_inferior_hook)
	(link_map_start): Update.
	* solib-spu.c (spu_enable_break, ocl_enable_break): Update.
	* solib-svr4.c (elf_locate_base, enable_break): Update.
	* spu-tdep.c (spu_get_overlay_table, spu_catch_start)
	(flush_ea_cache): Update.
	* stabsread.c (define_symbol, scan_file_globals): Update.
	* stack.c (find_frame_funname): Update.
	* symfile-debug.c (debug_qf_expand_symtabs_matching)
	(debug_qf_find_pc_sect_symtab): Update.
	* symfile.c (simple_read_overlay_table)
	(simple_overlay_update): Update.
	* symfile.h (struct quick_symbol_functions)
	<find_pc_sect_symtab>: Change type of msymbol to
	bound_minimal_symbol.
	* symmisc.c (dump_msymbols): Update.
	* symtab.c (find_pc_sect_symtab_via_partial)
	(find_pc_sect_psymtab, find_pc_sect_line, skip_prologue_sal)
	(search_symbols, print_msymbol_info): Update.
	* symtab.h (MSYMBOL_VALUE_RAW_ADDRESS): New macro.
	(MSYMBOL_VALUE_ADDRESS): Redefine.
	(BMSYMBOL_VALUE_ADDRESS): New macro.
	* tracepoint.c (scope_info): Update.
	* tui/tui-disasm.c (tui_find_disassembly_address)
	(tui_get_begin_asm_address): Update.
	* valops.c (find_function_in_inferior): Update.
	* value.c (value_static_field, value_fn_field): Update.
2014-02-26 12:11:17 -07:00
Tom Tromey 3b7344d5ab use bound_minsym as result for lookup_minimal_symbol et al
This patch changes a few minimal symbol lookup functions to return a
bound_minimal_symbol rather than a pointer to the minsym.  This change
helps prepare gdb for computing a minimal symbol's address at the
point of use.

Note that this changes even those functions that ostensibly search a
single objfile.  That was necessary because, in fact, those functions
can search an objfile and its separate debug objfiles; and it is
important for the caller to know in which objfile the minimal symbol
was actually found.

The bulk of this patch is mechanical.

2014-02-26  Tom Tromey  <tromey@redhat.com>

	* ada-lang.c (ada_update_initial_language): Update.
	(ada_main_name, ada_has_this_exception_support): Update.
	* ada-tasks.c (ada_tasks_inferior_data_sniffer): Update.
	* aix-thread.c (pdc_symbol_addrs, pd_enable): Update.
	* arm-tdep.c (arm_skip_stub): Update.
	* auxv.c (ld_so_xfer_auxv): Update.
	* avr-tdep.c (avr_scan_prologue): Update.
	* ax-gdb.c (gen_var_ref): Update.
	* breakpoint.c (struct breakpoint_objfile_data)
	<overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change
	type to bound_minimal_symbol.
	(create_overlay_event_breakpoint)
	(create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint): Update.
	* bsd-uthread.c (bsd_uthread_lookup_address): Update.
	* c-exp.y (classify_name): Update.
	* coffread.c (coff_symfile_read): Update.
	* common/agent.c (agent_look_up_symbols): Update.
	* d-lang.c (d_main_name): Update.
	* dbxread.c (find_stab_function_addr, end_psymtab): Update.
	* dec-thread.c (enable_dec_thread): Update.
	* dwarf2loc.c (call_site_to_target_addr): Update.
	* elfread.c (elf_gnu_ifunc_resolve_by_got): Update.
	* eval.c (evaluate_subexp_standard): Update.
	* findvar.c (struct minsym_lookup_data) <result>: Change type
	to bound_minimal_symbol.
	<objfile>: Remove.
	(minsym_lookup_iterator_cb, default_read_var_value): Update.
	* frame.c (inside_main_func): Update.
	* frv-tdep.c (frv_frame_this_id): Update.
	* gcore.c (call_target_sbrk): Update.
	* glibc-tdep.c (glibc_skip_solib_resolver): Update.
	* gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline):
	Update.
	* go-lang.c (go_main_name): Update.
	* hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code)
	(hppa_hpux_find_import_stub_for_addr): Update.
	* hppa-tdep.c (hppa_extract_17,	hppa_lookup_stub_minimal_symbol):
	Update.  Change return type.
	* hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return
	type.
	* jit.c (jit_breakpoint_re_set_internal): Update.
	* linux-fork.c (inferior_call_waitpid, checkpoint_command):
	Update.
	* linux-nat.c (get_signo): Update.
	* linux-thread-db.c (inferior_has_bug): Update
	* m32c-tdep.c (m32c_return_value)
	(m32c_m16c_address_to_pointer): Update.
	* m32r-tdep.c (m32r_frame_this_id): Update.
	* m68hc11-tdep.c (m68hc11_get_register_info): Update.
	* machoread.c (macho_resolve_oso_sym_with_minsym): Update.
	* minsyms.c (lookup_minimal_symbol_internal): Rename to
	lookup_minimal_symbol.  Change return type.
	(lookup_minimal_symbol): Remove.
	(lookup_bound_minimal_symbol): Update.
	(lookup_minimal_symbol_text): Change return type.
	(lookup_minimal_symbol_solib_trampoline): Change return type.
	* minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text)
	(lookup_minimal_symbol_solib_trampoline): Change return type.
	* mips-linux-tdep.c (mips_linux_skip_resolver): Update.
	* objc-lang.c (lookup_objc_class, lookup_child_selector)
	(value_nsstring, find_imps): Update.
	* obsd-tdep.c (obsd_skip_solib_resolver): Update.
	* p-lang.c (pascal_main_name): Update.
	* ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update.
	* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
	* proc-service.c (ps_pglobal_lookup): Update.
	* ravenscar-thread.c (get_running_thread_msymbol): Change
	return type.
	(has_ravenscar_runtime, get_running_thread_id): Update.
	* remote.c (remote_check_symbols): Update.
	* sol-thread.c (ps_pglobal_lookup): Update.
	* sol2-tdep.c (sol2_skip_solib_resolver): Update.
	* solib-dsbt.c (lm_base): Update.
	* solib-frv.c (lm_base, frv_relocate_section_addresses):
	Update.
	* solib-irix.c (locate_base): Update.
	* solib-som.c (som_solib_create_inferior_hook)
	(som_solib_desire_dynamic_linker_symbols, link_map_start):
	Update.
	* solib-spu.c (spu_enable_break): Update.
	* solib-svr4.c (elf_locate_base, enable_break): Update.
	* spu-tdep.c (spu_get_overlay_table, spu_catch_start)
	(flush_ea_cache): Update.
	* stabsread.c (define_symbol): Update.
	* symfile.c (simple_read_overlay_table): Update.
	* symtab.c (find_pc_sect_line): Update.
	* tracepoint.c (scope_info): Update.
	* tui-disasm.c (tui_get_begin_asm_address): Update.
	* value.c (value_static_field): Update.
2014-02-26 12:11:17 -07:00
Tom Tromey efd66ac669 change minsym representation
In a later patch we're going to change the minimal symbol address
calculation to apply section offsets at the point of use.  To make it
simpler to catch potential problem spots, this patch changes the
representation of minimal symbols and introduces new
minimal-symbol-specific variants of the various accessors.  This is
necessary because it would be excessively ambitious to try to convert
all the symbol types at once.

The core of this change is just renaming a field in minimal_symbol;
the rest is just a fairly mechanical rewording.

2014-02-26  Tom Tromey  <tromey@redhat.com>

	* symtab.h (struct minimal_symbol) <mginfo>: Rename from ginfo.
	(MSYMBOL_VALUE, MSYMBOL_VALUE_ADDRESS, MSYMBOL_VALUE_BYTES)
	(MSYMBOL_BLOCK_VALUE, MSYMBOL_VALUE_CHAIN, MSYMBOL_LANGUAGE)
	(MSYMBOL_SECTION, MSYMBOL_OBJ_SECTION, MSYMBOL_NATURAL_NAME)
	(MSYMBOL_LINKAGE_NAME, MSYMBOL_PRINT_NAME, MSYMBOL_DEMANGLED_NAME)
	(MSYMBOL_SET_LANGUAGE, MSYMBOL_SEARCH_NAME)
	(MSYMBOL_MATCHES_SEARCH_NAME, MSYMBOL_SET_NAMES): New macros.
	* ada-lang.c (ada_main_name): Update.
	(ada_lookup_simple_minsym): Update.
	(ada_make_symbol_completion_list): Update.
	(ada_add_standard_exceptions): Update.
	* ada-tasks.c (read_atcb, ada_tasks_inferior_data_sniffer): Update.
	* aix-thread.c (pdc_symbol_addrs, pd_enable): Update.
	* amd64-windows-tdep.c (amd64_skip_main_prologue): Update.
	* arm-tdep.c (skip_prologue_function): Update.
	(arm_skip_stack_protector, arm_skip_stub): Update.
	* arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update.
	(arm_wince_skip_main_prologue): Update.
	* auxv.c (ld_so_xfer_auxv): Update.
	* avr-tdep.c (avr_scan_prologue): Update.
	* ax-gdb.c (gen_var_ref): Update.
	* block.c (call_site_for_pc): Update.
	* blockframe.c (get_pc_function_start): Update.
	(find_pc_partial_function_gnu_ifunc): Update.
	* breakpoint.c (create_overlay_event_breakpoint): Update.
	(create_longjmp_master_breakpoint): Update.
	(create_std_terminate_master_breakpoint): Update.
	(create_exception_master_breakpoint): Update.
	(resolve_sal_pc): Update.
	* bsd-uthread.c (bsd_uthread_lookup_address): Update.
	* btrace.c (ftrace_print_function_name, ftrace_function_switched):
	Update.
	* c-valprint.c (c_val_print): Update.
	* coff-pe-read.c (add_pe_forwarded_sym): Update.
	* coffread.c (coff_symfile_read): Update.
	* common/agent.c (agent_look_up_symbols): Update.
	* dbxread.c (find_stab_function_addr): Update.
	(end_psymtab): Update.
	* dwarf2loc.c (call_site_to_target_addr): Update.
	(func_verify_no_selftailcall): Update.
	(tailcall_dump): Update.
	(call_site_find_chain_1): Update.
	(dwarf_expr_reg_to_entry_parameter): Update.
	* elfread.c (elf_gnu_ifunc_record_cache): Update.
	(elf_gnu_ifunc_resolve_by_got): Update.
	* f-valprint.c (info_common_command): Update.
	* findvar.c (read_var_value): Update.
	* frame.c (get_prev_frame_1): Update.
	(inside_main_func): Update.
	* frv-tdep.c (frv_skip_main_prologue): Update.
	(frv_frame_this_id): Update.
	* glibc-tdep.c (glibc_skip_solib_resolver): Update.
	* gnu-v2-abi.c (gnuv2_value_rtti_type): Update.
	* gnu-v3-abi.c (gnuv3_rtti_type): Update.
	(gnuv3_skip_trampoline): Update.
	* hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline): Update.
	(hppa64_hpux_in_solib_call_trampoline): Update.
	(hppa_hpux_skip_trampoline_code): Update.
	(hppa64_hpux_search_dummy_call_sequence): Update.
	(hppa_hpux_find_import_stub_for_addr): Update.
	(hppa_hpux_find_dummy_bpaddr): Update.
	* hppa-tdep.c (hppa_symbol_address)
	(hppa_lookup_stub_minimal_symbol): Update.
	* i386-tdep.c (i386_skip_main_prologue): Update.
	(i386_pe_skip_trampoline_code): Update.
	* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Update.
	* infcall.c (get_function_name): Update.
	* infcmd.c (until_next_command): Update.
	* jit.c (jit_breakpoint_re_set_internal): Update.
	(jit_inferior_init): Update.
	* linespec.c (minsym_found): Update.
	(add_minsym): Update.
	* linux-fork.c (info_checkpoints_command): Update.
	* linux-nat.c (get_signo): Update.
	* linux-thread-db.c (inferior_has_bug): Update.
	* m32c-tdep.c (m32c_return_value): Update.
	(m32c_m16c_address_to_pointer): Update.
	(m32c_m16c_pointer_to_address): Update.
	* m32r-tdep.c (m32r_frame_this_id): Update.
	* m68hc11-tdep.c (m68hc11_get_register_info): Update.
	* machoread.c (macho_resolve_oso_sym_with_minsym): Update.
	* maint.c (maintenance_translate_address): Update.
	* minsyms.c (add_minsym_to_hash_table): Update.
	(add_minsym_to_demangled_hash_table): Update.
	(msymbol_objfile): Update.
	(lookup_minimal_symbol): Update.
	(iterate_over_minimal_symbols): Update.
	(lookup_minimal_symbol_text): Update.
	(lookup_minimal_symbol_by_pc_name): Update.
	(lookup_minimal_symbol_solib_trampoline): Update.
	(lookup_minimal_symbol_by_pc_section_1): Update.
	(lookup_minimal_symbol_and_objfile): Update.
	(prim_record_minimal_symbol_full): Update.
	(compare_minimal_symbols): Update.
	(compact_minimal_symbols): Update.
	(build_minimal_symbol_hash_tables): Update.
	(install_minimal_symbols): Update.
	(terminate_minimal_symbol_table): Update.
	(find_solib_trampoline_target): Update.
	(minimal_symbol_upper_bound): Update.
	* mips-linux-tdep.c (mips_linux_skip_resolver): Update.
	* mips-tdep.c (mips_stub_frame_sniffer): Update.
	(mips_skip_pic_trampoline_code): Update.
	* msp430-tdep.c (msp430_skip_trampoline_code): Update.
	* objc-lang.c (selectors_info): Update.
	(classes_info): Update.
	(find_methods): Update.
	(find_imps): Update.
	(find_objc_msgsend): Update.
	* objfiles.c (objfile_relocate1): Update.
	* objfiles.h (ALL_OBJFILE_MSYMBOLS): Update.
	* obsd-tdep.c (obsd_skip_solib_resolver): Update.
	* p-valprint.c (pascal_val_print): Update.
	* parse.c (write_exp_msymbol): Update.
	* ppc-linux-tdep.c (powerpc_linux_in_dynsym_resolve_code)
	(ppc_linux_spe_context_lookup, ppc_elfv2_skip_entrypoint): Update.
	* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
	* printcmd.c (build_address_symbolic): Update.
	(sym_info): Update.
	(address_info): Update.
	* proc-service.c (ps_pglobal_lookup): Update.
	* psymtab.c (find_pc_sect_psymtab_closer): Update.
	(find_pc_sect_psymtab): Update.
	* python/py-framefilter.c (py_print_frame): Update.
	* ravenscar-thread.c (get_running_thread_id): Update.
	* record-btrace.c (btrace_call_history, btrace_get_bfun_name):
	Update.
	* remote.c (remote_check_symbols): Update.
	* rs6000-tdep.c (rs6000_skip_main_prologue): Update.
	(rs6000_skip_trampoline_code): Update.
	* sh64-tdep.c (sh64_elf_make_msymbol_special): Update.
	* sol2-tdep.c (sol2_skip_solib_resolver): Update.
	* solib-dsbt.c (lm_base): Update.
	* solib-frv.c (lm_base): Update.
	(main_got): Update.
	* solib-irix.c (locate_base): Update.
	* solib-som.c (som_solib_create_inferior_hook): Update.
	(som_solib_desire_dynamic_linker_symbols): Update.
	(link_map_start): Update.
	* solib-spu.c (spu_enable_break): Update.
	(ocl_enable_break): Update.
	* solib-svr4.c (elf_locate_base): Update.
	(enable_break): Update.
	* spu-tdep.c (spu_get_overlay_table): Update.
	(spu_catch_start): Update.
	(flush_ea_cache): Update.
	* stabsread.c (define_symbol): Update.
	(scan_file_globals): Update.
	* stack.c (find_frame_funname): Update.
	(frame_info): Update.
	* symfile.c (simple_read_overlay_table): Update.
	(simple_overlay_update): Update.
	* symmisc.c (dump_msymbols): Update.
	* symtab.c (fixup_section): Update.
	(find_pc_sect_line): Update.
	(skip_prologue_sal): Update.
	(search_symbols): Update.
	(print_msymbol_info): Update.
	(rbreak_command): Update.
	(MCOMPLETION_LIST_ADD_SYMBOL): New macro.
	(completion_list_objc_symbol): Update.
	(default_make_symbol_completion_list_break_on): Update.
	* tracepoint.c (scope_info): Update.
	* tui/tui-disasm.c (tui_find_disassembly_address): Update.
	(tui_get_begin_asm_address): Update.
	* valops.c (find_function_in_inferior): Update.
	* value.c (value_static_field): Update.
	(value_fn_field): Update.
2014-02-26 12:11:16 -07:00
Will Newton 4b7d1f7fb4 gdb/elfread.c: Enable ifunc support on ARM.
There are two failures in the gnu-ifunc.exp test on ARM. These are
due to the failure to resolve the correct target function when
attempting to breakpoint a GNU ifunc resolved function:

(gdb) break gnu_ifunc
Breakpoint 4 at gnu-indirect-function resolver at 0x2aacb5a2

when gnu_ifunc has been resolved this should actually be:

(gdb) break gnu_ifunc
Breakpoint 4 at 0x868c

There are two reasons for this. The first is that ARM does not have a
separate .got.plt section so looking this up will always fail. The second
is that the Thumb bit needs to be stripped from the address to allow
it to be reliably compared when inserting into the ifunc cache.

Tested with no regressions on arm-linux-gnueabihf and
x86_64-unknown-linux-gnu.

gdb/ChangeLog:

2014-02-10  Will Newton  <will.newton@linaro.org>

	* elfread.c (elf_rel_plt_read): Look for a .got section if
	looking up .got.plt fails.
	(elf_gnu_ifunc_resolve_by_got): Call gdbarch_addr_bits_remove
	on address passed to elf_gnu_ifunc_record_cache.
	(elf_gnu_ifunc_resolve_addr): Likewise.
	(elf_gnu_ifunc_resolver_return_stop): Likewise.
2014-02-10 16:45:47 +00:00
Tom Tromey fc270c357a replace XCALLOC with XCNEWVEC or XCNEW
This removes XCALLOC and replaces it either with XCNEWVEC, or, if the
number of elements being requested was 1, with XCNEW.

2014-01-13  Tom Tromey  <tromey@redhat.com>

	* defs.h (XCALLOC): Remove.
	* bcache.c (bcache_xmalloc): Use XCNEW, not XCALLOC.
	(print_bcache_statistics): Use XCNEWVEC, not XCALLOC.
	* dwarf2loc.c (allocate_piece_closure): Likewise.
	* elfread.c (elf_symfile_segments): Likewise.
	(elf_symfile_segments): Likewise.
	* gdbtypes.c (copy_type_recursive): Likewise.
	* i386-tdep.c (i386_gdbarch_init): Use XCNEW, not XCALLOC.
	* jit.c (jit_frame_sniffer): Use XCNEWVEC, not XCALLOC.
	* minsyms.c (prim_record_minimal_symbol_full): Use XCNEW, not
	XCALLOC.
	* mt-tdep.c (mt_gdbarch_init): Likewise.
	* opencl-lang.c (allocate_lval_closure): Use XCNEWVEC, not
	XCALLOC.
	* psymtab.c (psymbol_compare): Use XCNEW, not XCALLOC.
	* regcache.c (regcache_xmalloc_1): Use XCNEWVEC, not XCALLOC.
	* registry.c (registry_alloc_data): Likewise.
	* rs6000-tdep.c (rs6000_gdbarch_init): Use XCNEW, not XCALLOC.
	* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
	* serial.c (serial_fdopen_ops): Likewise.
	* solib-aix.c (solib_aix_get_section_offsets): Use XCNEWVEC, not
	XCALLOC.
	* spu-tdep.c (spu_gdbarch_init): Use XCNEW, not XCALLOC.
	* symfile.c (default_symfile_segments): Use XCNEW and XCNEWVEC,
	not XCALLOC.
2014-01-13 07:31:29 -07:00
Tom Tromey 41bf6acad7 replace XZALLOC with XCNEW
This replaces XZALLOC with XCNEW and removes XZALLOC.
This change is purely mechanical.

2014-01-13  Tom Tromey  <tromey@redhat.com>

	* defs.h (XZALLOC): Remove.
	* ada-lang.c (get_ada_inferior_data): Use XCNEW, not XZALLOC.
	* ada-tasks.c (get_ada_tasks_pspace_data): Likewise.
	(get_ada_tasks_inferior_data): Likewise.
	* auto-load.c (get_auto_load_pspace_data): Likewise.
	* auxv.c (get_auxv_inferior_data): Likewise.
	* bfd-target.c (target_bfd_reopen): Likewise.
	* breakpoint.c (get_catch_syscall_inferior_data): Likewise.
	(deprecated_insert_raw_breakpoint): Likewise.
	* bsd-uthread.c (bsd_uthread_pid_to_str): Likewise.
	* corelow.c (core_open): Likewise.
	* darwin-nat.c (darwin_check_new_threads): Likewise.
	(darwin_attach_pid): Likewise.
	* dummy-frame.c (dummy_frame_push): Likewise.
	* dwarf2-frame.c (dwarf2_frame_cache): Likewise.
	* dwarf2loc.c (allocate_piece_closure): Likewise.
	* elfread.c (elf_symfile_segments): Likewise.
	* eval.c (ptrmath_type_p): Likewise.
	* exceptions.c (EXCEPTIONS_SIGJMP_BUF): Likewise.
	* gdbtypes.c (alloc_type_arch): Likewise.
	(alloc_type_instance): Likewise.
	* hppa-tdep.c (hppa_gdbarch_init): Likewise.
	* inf-child.c (inf_child_can_use_agent): Likewise.
	* inflow.c (get_inflow_inferior_data): Likewise.
	* infrun.c (save_infcall_suspend_state): Likewise.
	* jit.c (jit_reader_load): Likewise.
	(get_jit_objfile_data): Likewise.
	(get_jit_program_space_data): Likewise.
	(jit_object_open_impl): Likewise.
	(jit_symtab_open_impl): Likewise.
	(jit_block_open_impl): Likewise.
	(jit_frame_sniffer): Likewise.
	* linux-fork.c (add_fork): Likewise.
	* maint.c (make_command_stats_cleanup): Likewise.
	* objfiles.c (get_objfile_pspace_data): Likewise.
	* opencl-lang.c (struct lval_closure): Likewise.
	* osdata.c (osdata_start_osdata): Likewise.
	* progspace.c (new_address_space): Likewise.
	(add_program_space): Likewise.
	* remote-sim.c (get_sim_inferior_data): Likewise.
	* sh-tdep.c (sh_gdbarch_init): Likewise.
	* skip.c (Ignore): Likewise.
	(skip_delete_command): Likewise.
	* solib-aix.c (get_solib_aix_inferior_data): Likewise.
	(library_list_start_library): Likewise.
	(solib_aix_current_sos): Likewise.
	* solib-darwin.c (get_darwin_info): Likewise.
	(darwin_current_sos): Likewise.
	* solib-dsbt.c (get_dsbt_info): Likewise.
	* solib-ia64-hpux.c (new_so_list): Likewise.
	(ia64_hpux_get_solib_linkage_addr): Likewise.
	* solib-spu.c (append_ocl_sos): Likewise.
	(spu_current_sos): Likewise.
	* solib-svr4.c (get_svr4_info): Likewise.
	(svr4_keep_data_in_core): Likewise.
	(library_list_start_library): Likewise.
	(svr4_default_sos): Likewise.
	(svr4_read_so_list): Likewise.
	* solib-target.c (library_list_start_library): Likewise.
	(solib_target_current_sos): Likewise.
	* sparc-tdep.c (sparc32_gdbarch_init): Likewise.
	* symfile-debug.c (install_symfile_debug_logging): Likewise.
	* symfile.c (default_symfile_segments): Likewise.
	* target-descriptions.c (tdesc_data_init): Likewise.
	(tdesc_create_reg): Likewise.
	(struct tdesc_type *): Likewise.
	(tdesc_create_vector): Likewise.
	(tdesc_set_struct_size): Likewise.
	(struct tdesc_type *): Likewise.
	(tdesc_free_feature): Likewise.
	(tdesc_create_feature): Likewise.
	* windows-nat.c (windows_add_thread): Likewise.
	(windows_make_so): Likewise.
	* xml-support.c (gdb_xml_body_text): Likewise.
	(gdb_xml_create_parser_and_cleanup): Likewise.
	(xml_process_xincludes): Likewise.
	* xml-syscall.c (allocate_syscalls_info): Likewise.
	(syscall_create_syscall_desc): Likewise.
2014-01-13 07:31:27 -07:00
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Tom Tromey 37fbcad0be remove some sym_probe_fns methods
While looking into the probe API, it seemed to me that there were a
number of methods in sym_probe_fns that were not needed.  This patch
removes them.

Specifically, it seems to me that sym_probe_fns ought to be concerned
with the API for constructing the probes.  Any method relating to some
aspect of an individual probe can be handled via the probe's own
vtable.  That is, the double indirection here doesn't seem useful --
it certainly isn't in fact used, but also I couldn't think of a
potential use.

2013-12-06  Tom Tromey  <tromey@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Use
	get_probe_argument_count and evaluate_probe_argument.
	* elfread.c (elf_get_probe_argument_count)
	(elf_can_evaluate_probe_arguments, elf_evaluate_probe_argument)
	(elf_compile_to_ax): Remove.
	(elf_probe_fns): Update.
	* probe.c (get_probe_argument_count, can_evaluate_probe_arguments)
	(evaluate_probe_argument): Call method on probe, not via sym
	functions.
	* stap-probe.c (compute_probe_arg): Use get_probe_argument_count,
	evaluate_probe_argument.
	(compile_probe_arg): Use get_probe_argument_count.  Call method on
	probe, not via sym functions.
	* symfile-debug.c (debug_sym_get_probe_argument_count)
	(debug_can_evaluate_probe_arguments)
	(debug_sym_evaluate_probe_argument, debug_sym_compile_to_ax):
	Remove.
	(debug_sym_probe_fns): Remove.
	* symfile.h (struct sym_probe_fns) <sym_get_probe_argument_count,
	can_evaluate_probe_arguments, sym_evaluate_probe_argument,
	sym_compile_to_ax>: Remove fields.
2013-12-06 08:57:55 -07:00
Tom Tromey 0e9f083f4c remove gdb_string.h
This removes gdb_string.h.  This patch is purely mechanical.  I
created it by running the two commands:

    git rm common/gdb_string.h
    perl -pi -e's/"gdb_string.h"/<string.h>/;'  *.[chyl] */*.[chyl]

2013-11-18  Tom Tromey  <tromey@redhat.com>

	* common/gdb_string.h: Remove.
	* aarch64-tdep.c: Use string.h, not gdb_string.h.
	* ada-exp.y: Use string.h, not gdb_string.h.
	* ada-lang.c: Use string.h, not gdb_string.h.
	* ada-lex.l: Use string.h, not gdb_string.h.
	* ada-typeprint.c: Use string.h, not gdb_string.h.
	* ada-valprint.c: Use string.h, not gdb_string.h.
	* aix-thread.c: Use string.h, not gdb_string.h.
	* alpha-linux-tdep.c: Use string.h, not gdb_string.h.
	* alpha-mdebug-tdep.c: Use string.h, not gdb_string.h.
	* alpha-nat.c: Use string.h, not gdb_string.h.
	* alpha-osf1-tdep.c: Use string.h, not gdb_string.h.
	* alpha-tdep.c: Use string.h, not gdb_string.h.
	* alphanbsd-tdep.c: Use string.h, not gdb_string.h.
	* amd64-dicos-tdep.c: Use string.h, not gdb_string.h.
	* amd64-linux-nat.c: Use string.h, not gdb_string.h.
	* amd64-linux-tdep.c: Use string.h, not gdb_string.h.
	* amd64-nat.c: Use string.h, not gdb_string.h.
	* amd64-sol2-tdep.c: Use string.h, not gdb_string.h.
	* amd64fbsd-tdep.c: Use string.h, not gdb_string.h.
	* amd64obsd-tdep.c: Use string.h, not gdb_string.h.
	* arch-utils.c: Use string.h, not gdb_string.h.
	* arm-linux-nat.c: Use string.h, not gdb_string.h.
	* arm-linux-tdep.c: Use string.h, not gdb_string.h.
	* arm-tdep.c: Use string.h, not gdb_string.h.
	* arm-wince-tdep.c: Use string.h, not gdb_string.h.
	* armbsd-tdep.c: Use string.h, not gdb_string.h.
	* armnbsd-nat.c: Use string.h, not gdb_string.h.
	* armnbsd-tdep.c: Use string.h, not gdb_string.h.
	* armobsd-tdep.c: Use string.h, not gdb_string.h.
	* avr-tdep.c: Use string.h, not gdb_string.h.
	* ax-gdb.c: Use string.h, not gdb_string.h.
	* ax-general.c: Use string.h, not gdb_string.h.
	* bcache.c: Use string.h, not gdb_string.h.
	* bfin-tdep.c: Use string.h, not gdb_string.h.
	* breakpoint.c: Use string.h, not gdb_string.h.
	* build-id.c: Use string.h, not gdb_string.h.
	* buildsym.c: Use string.h, not gdb_string.h.
	* c-exp.y: Use string.h, not gdb_string.h.
	* c-lang.c: Use string.h, not gdb_string.h.
	* c-typeprint.c: Use string.h, not gdb_string.h.
	* c-valprint.c: Use string.h, not gdb_string.h.
	* charset.c: Use string.h, not gdb_string.h.
	* cli-out.c: Use string.h, not gdb_string.h.
	* cli/cli-cmds.c: Use string.h, not gdb_string.h.
	* cli/cli-decode.c: Use string.h, not gdb_string.h.
	* cli/cli-dump.c: Use string.h, not gdb_string.h.
	* cli/cli-interp.c: Use string.h, not gdb_string.h.
	* cli/cli-logging.c: Use string.h, not gdb_string.h.
	* cli/cli-script.c: Use string.h, not gdb_string.h.
	* cli/cli-setshow.c: Use string.h, not gdb_string.h.
	* cli/cli-utils.c: Use string.h, not gdb_string.h.
	* coffread.c: Use string.h, not gdb_string.h.
	* common/common-utils.c: Use string.h, not gdb_string.h.
	* common/filestuff.c: Use string.h, not gdb_string.h.
	* common/linux-procfs.c: Use string.h, not gdb_string.h.
	* common/linux-ptrace.c: Use string.h, not gdb_string.h.
	* common/signals.c: Use string.h, not gdb_string.h.
	* common/vec.h: Use string.h, not gdb_string.h.
	* core-regset.c: Use string.h, not gdb_string.h.
	* corefile.c: Use string.h, not gdb_string.h.
	* corelow.c: Use string.h, not gdb_string.h.
	* cp-abi.c: Use string.h, not gdb_string.h.
	* cp-support.c: Use string.h, not gdb_string.h.
	* cp-valprint.c: Use string.h, not gdb_string.h.
	* cris-tdep.c: Use string.h, not gdb_string.h.
	* d-lang.c: Use string.h, not gdb_string.h.
	* dbxread.c: Use string.h, not gdb_string.h.
	* dcache.c: Use string.h, not gdb_string.h.
	* demangle.c: Use string.h, not gdb_string.h.
	* dicos-tdep.c: Use string.h, not gdb_string.h.
	* disasm.c: Use string.h, not gdb_string.h.
	* doublest.c: Use string.h, not gdb_string.h.
	* dsrec.c: Use string.h, not gdb_string.h.
	* dummy-frame.c: Use string.h, not gdb_string.h.
	* dwarf2-frame.c: Use string.h, not gdb_string.h.
	* dwarf2loc.c: Use string.h, not gdb_string.h.
	* dwarf2read.c: Use string.h, not gdb_string.h.
	* elfread.c: Use string.h, not gdb_string.h.
	* environ.c: Use string.h, not gdb_string.h.
	* eval.c: Use string.h, not gdb_string.h.
	* event-loop.c: Use string.h, not gdb_string.h.
	* exceptions.c: Use string.h, not gdb_string.h.
	* exec.c: Use string.h, not gdb_string.h.
	* expprint.c: Use string.h, not gdb_string.h.
	* f-exp.y: Use string.h, not gdb_string.h.
	* f-lang.c: Use string.h, not gdb_string.h.
	* f-typeprint.c: Use string.h, not gdb_string.h.
	* f-valprint.c: Use string.h, not gdb_string.h.
	* fbsd-nat.c: Use string.h, not gdb_string.h.
	* findcmd.c: Use string.h, not gdb_string.h.
	* findvar.c: Use string.h, not gdb_string.h.
	* fork-child.c: Use string.h, not gdb_string.h.
	* frame.c: Use string.h, not gdb_string.h.
	* frv-linux-tdep.c: Use string.h, not gdb_string.h.
	* frv-tdep.c: Use string.h, not gdb_string.h.
	* gdb.c: Use string.h, not gdb_string.h.
	* gdb_bfd.c: Use string.h, not gdb_string.h.
	* gdbarch.c: Use string.h, not gdb_string.h.
	* gdbtypes.c: Use string.h, not gdb_string.h.
	* gnu-nat.c: Use string.h, not gdb_string.h.
	* gnu-v2-abi.c: Use string.h, not gdb_string.h.
	* gnu-v3-abi.c: Use string.h, not gdb_string.h.
	* go-exp.y: Use string.h, not gdb_string.h.
	* go-lang.c: Use string.h, not gdb_string.h.
	* go32-nat.c: Use string.h, not gdb_string.h.
	* hppa-hpux-tdep.c: Use string.h, not gdb_string.h.
	* hppa-linux-nat.c: Use string.h, not gdb_string.h.
	* hppanbsd-tdep.c: Use string.h, not gdb_string.h.
	* hppaobsd-tdep.c: Use string.h, not gdb_string.h.
	* i386-cygwin-tdep.c: Use string.h, not gdb_string.h.
	* i386-dicos-tdep.c: Use string.h, not gdb_string.h.
	* i386-linux-nat.c: Use string.h, not gdb_string.h.
	* i386-linux-tdep.c: Use string.h, not gdb_string.h.
	* i386-nto-tdep.c: Use string.h, not gdb_string.h.
	* i386-sol2-tdep.c: Use string.h, not gdb_string.h.
	* i386-tdep.c: Use string.h, not gdb_string.h.
	* i386bsd-tdep.c: Use string.h, not gdb_string.h.
	* i386gnu-nat.c: Use string.h, not gdb_string.h.
	* i386nbsd-tdep.c: Use string.h, not gdb_string.h.
	* i386obsd-tdep.c: Use string.h, not gdb_string.h.
	* i387-tdep.c: Use string.h, not gdb_string.h.
	* ia64-libunwind-tdep.c: Use string.h, not gdb_string.h.
	* ia64-linux-nat.c: Use string.h, not gdb_string.h.
	* inf-child.c: Use string.h, not gdb_string.h.
	* inf-ptrace.c: Use string.h, not gdb_string.h.
	* inf-ttrace.c: Use string.h, not gdb_string.h.
	* infcall.c: Use string.h, not gdb_string.h.
	* infcmd.c: Use string.h, not gdb_string.h.
	* inflow.c: Use string.h, not gdb_string.h.
	* infrun.c: Use string.h, not gdb_string.h.
	* interps.c: Use string.h, not gdb_string.h.
	* iq2000-tdep.c: Use string.h, not gdb_string.h.
	* irix5-nat.c: Use string.h, not gdb_string.h.
	* jv-exp.y: Use string.h, not gdb_string.h.
	* jv-lang.c: Use string.h, not gdb_string.h.
	* jv-typeprint.c: Use string.h, not gdb_string.h.
	* jv-valprint.c: Use string.h, not gdb_string.h.
	* language.c: Use string.h, not gdb_string.h.
	* linux-fork.c: Use string.h, not gdb_string.h.
	* linux-nat.c: Use string.h, not gdb_string.h.
	* lm32-tdep.c: Use string.h, not gdb_string.h.
	* m2-exp.y: Use string.h, not gdb_string.h.
	* m2-typeprint.c: Use string.h, not gdb_string.h.
	* m32c-tdep.c: Use string.h, not gdb_string.h.
	* m32r-linux-nat.c: Use string.h, not gdb_string.h.
	* m32r-linux-tdep.c: Use string.h, not gdb_string.h.
	* m32r-rom.c: Use string.h, not gdb_string.h.
	* m32r-tdep.c: Use string.h, not gdb_string.h.
	* m68hc11-tdep.c: Use string.h, not gdb_string.h.
	* m68k-tdep.c: Use string.h, not gdb_string.h.
	* m68kbsd-tdep.c: Use string.h, not gdb_string.h.
	* m68klinux-nat.c: Use string.h, not gdb_string.h.
	* m68klinux-tdep.c: Use string.h, not gdb_string.h.
	* m88k-tdep.c: Use string.h, not gdb_string.h.
	* macrocmd.c: Use string.h, not gdb_string.h.
	* main.c: Use string.h, not gdb_string.h.
	* mdebugread.c: Use string.h, not gdb_string.h.
	* mem-break.c: Use string.h, not gdb_string.h.
	* memattr.c: Use string.h, not gdb_string.h.
	* memory-map.c: Use string.h, not gdb_string.h.
	* mep-tdep.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-break.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-disas.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-env.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-stack.c: Use string.h, not gdb_string.h.
	* mi/mi-cmd-var.c: Use string.h, not gdb_string.h.
	* mi/mi-cmds.c: Use string.h, not gdb_string.h.
	* mi/mi-console.c: Use string.h, not gdb_string.h.
	* mi/mi-getopt.c: Use string.h, not gdb_string.h.
	* mi/mi-interp.c: Use string.h, not gdb_string.h.
	* mi/mi-main.c: Use string.h, not gdb_string.h.
	* mi/mi-parse.c: Use string.h, not gdb_string.h.
	* microblaze-rom.c: Use string.h, not gdb_string.h.
	* microblaze-tdep.c: Use string.h, not gdb_string.h.
	* mingw-hdep.c: Use string.h, not gdb_string.h.
	* minidebug.c: Use string.h, not gdb_string.h.
	* minsyms.c: Use string.h, not gdb_string.h.
	* mips-irix-tdep.c: Use string.h, not gdb_string.h.
	* mips-linux-tdep.c: Use string.h, not gdb_string.h.
	* mips-tdep.c: Use string.h, not gdb_string.h.
	* mips64obsd-tdep.c: Use string.h, not gdb_string.h.
	* mipsnbsd-tdep.c: Use string.h, not gdb_string.h.
	* mipsread.c: Use string.h, not gdb_string.h.
	* mn10300-linux-tdep.c: Use string.h, not gdb_string.h.
	* mn10300-tdep.c: Use string.h, not gdb_string.h.
	* monitor.c: Use string.h, not gdb_string.h.
	* moxie-tdep.c: Use string.h, not gdb_string.h.
	* mt-tdep.c: Use string.h, not gdb_string.h.
	* nbsd-tdep.c: Use string.h, not gdb_string.h.
	* nios2-linux-tdep.c: Use string.h, not gdb_string.h.
	* nto-procfs.c: Use string.h, not gdb_string.h.
	* nto-tdep.c: Use string.h, not gdb_string.h.
	* objc-lang.c: Use string.h, not gdb_string.h.
	* objfiles.c: Use string.h, not gdb_string.h.
	* opencl-lang.c: Use string.h, not gdb_string.h.
	* osabi.c: Use string.h, not gdb_string.h.
	* osdata.c: Use string.h, not gdb_string.h.
	* p-exp.y: Use string.h, not gdb_string.h.
	* p-lang.c: Use string.h, not gdb_string.h.
	* p-typeprint.c: Use string.h, not gdb_string.h.
	* parse.c: Use string.h, not gdb_string.h.
	* posix-hdep.c: Use string.h, not gdb_string.h.
	* ppc-linux-nat.c: Use string.h, not gdb_string.h.
	* ppc-sysv-tdep.c: Use string.h, not gdb_string.h.
	* ppcfbsd-tdep.c: Use string.h, not gdb_string.h.
	* ppcnbsd-tdep.c: Use string.h, not gdb_string.h.
	* ppcobsd-tdep.c: Use string.h, not gdb_string.h.
	* printcmd.c: Use string.h, not gdb_string.h.
	* procfs.c: Use string.h, not gdb_string.h.
	* prologue-value.c: Use string.h, not gdb_string.h.
	* python/py-auto-load.c: Use string.h, not gdb_string.h.
	* python/py-gdb-readline.c: Use string.h, not gdb_string.h.
	* ravenscar-thread.c: Use string.h, not gdb_string.h.
	* regcache.c: Use string.h, not gdb_string.h.
	* registry.c: Use string.h, not gdb_string.h.
	* remote-fileio.c: Use string.h, not gdb_string.h.
	* remote-m32r-sdi.c: Use string.h, not gdb_string.h.
	* remote-mips.c: Use string.h, not gdb_string.h.
	* remote-sim.c: Use string.h, not gdb_string.h.
	* remote.c: Use string.h, not gdb_string.h.
	* reverse.c: Use string.h, not gdb_string.h.
	* rs6000-aix-tdep.c: Use string.h, not gdb_string.h.
	* ser-base.c: Use string.h, not gdb_string.h.
	* ser-go32.c: Use string.h, not gdb_string.h.
	* ser-mingw.c: Use string.h, not gdb_string.h.
	* ser-pipe.c: Use string.h, not gdb_string.h.
	* ser-tcp.c: Use string.h, not gdb_string.h.
	* ser-unix.c: Use string.h, not gdb_string.h.
	* serial.c: Use string.h, not gdb_string.h.
	* sh-tdep.c: Use string.h, not gdb_string.h.
	* sh64-tdep.c: Use string.h, not gdb_string.h.
	* shnbsd-tdep.c: Use string.h, not gdb_string.h.
	* skip.c: Use string.h, not gdb_string.h.
	* sol-thread.c: Use string.h, not gdb_string.h.
	* solib-dsbt.c: Use string.h, not gdb_string.h.
	* solib-frv.c: Use string.h, not gdb_string.h.
	* solib-osf.c: Use string.h, not gdb_string.h.
	* solib-spu.c: Use string.h, not gdb_string.h.
	* solib-target.c: Use string.h, not gdb_string.h.
	* solib.c: Use string.h, not gdb_string.h.
	* somread.c: Use string.h, not gdb_string.h.
	* source.c: Use string.h, not gdb_string.h.
	* sparc-nat.c: Use string.h, not gdb_string.h.
	* sparc-sol2-tdep.c: Use string.h, not gdb_string.h.
	* sparc-tdep.c: Use string.h, not gdb_string.h.
	* sparc64-tdep.c: Use string.h, not gdb_string.h.
	* sparc64fbsd-tdep.c: Use string.h, not gdb_string.h.
	* sparc64nbsd-tdep.c: Use string.h, not gdb_string.h.
	* sparcnbsd-tdep.c: Use string.h, not gdb_string.h.
	* spu-linux-nat.c: Use string.h, not gdb_string.h.
	* spu-multiarch.c: Use string.h, not gdb_string.h.
	* spu-tdep.c: Use string.h, not gdb_string.h.
	* stabsread.c: Use string.h, not gdb_string.h.
	* stack.c: Use string.h, not gdb_string.h.
	* std-regs.c: Use string.h, not gdb_string.h.
	* symfile.c: Use string.h, not gdb_string.h.
	* symmisc.c: Use string.h, not gdb_string.h.
	* symtab.c: Use string.h, not gdb_string.h.
	* target.c: Use string.h, not gdb_string.h.
	* thread.c: Use string.h, not gdb_string.h.
	* tilegx-linux-nat.c: Use string.h, not gdb_string.h.
	* tilegx-tdep.c: Use string.h, not gdb_string.h.
	* top.c: Use string.h, not gdb_string.h.
	* tracepoint.c: Use string.h, not gdb_string.h.
	* tui/tui-command.c: Use string.h, not gdb_string.h.
	* tui/tui-data.c: Use string.h, not gdb_string.h.
	* tui/tui-disasm.c: Use string.h, not gdb_string.h.
	* tui/tui-file.c: Use string.h, not gdb_string.h.
	* tui/tui-layout.c: Use string.h, not gdb_string.h.
	* tui/tui-out.c: Use string.h, not gdb_string.h.
	* tui/tui-regs.c: Use string.h, not gdb_string.h.
	* tui/tui-source.c: Use string.h, not gdb_string.h.
	* tui/tui-stack.c: Use string.h, not gdb_string.h.
	* tui/tui-win.c: Use string.h, not gdb_string.h.
	* tui/tui-windata.c: Use string.h, not gdb_string.h.
	* tui/tui-winsource.c: Use string.h, not gdb_string.h.
	* typeprint.c: Use string.h, not gdb_string.h.
	* ui-file.c: Use string.h, not gdb_string.h.
	* ui-out.c: Use string.h, not gdb_string.h.
	* user-regs.c: Use string.h, not gdb_string.h.
	* utils.c: Use string.h, not gdb_string.h.
	* v850-tdep.c: Use string.h, not gdb_string.h.
	* valarith.c: Use string.h, not gdb_string.h.
	* valops.c: Use string.h, not gdb_string.h.
	* valprint.c: Use string.h, not gdb_string.h.
	* value.c: Use string.h, not gdb_string.h.
	* varobj.c: Use string.h, not gdb_string.h.
	* vax-tdep.c: Use string.h, not gdb_string.h.
	* vaxnbsd-tdep.c: Use string.h, not gdb_string.h.
	* vaxobsd-tdep.c: Use string.h, not gdb_string.h.
	* windows-nat.c: Use string.h, not gdb_string.h.
	* xcoffread.c: Use string.h, not gdb_string.h.
	* xml-support.c: Use string.h, not gdb_string.h.
	* xstormy16-tdep.c: Use string.h, not gdb_string.h.
	* xtensa-linux-nat.c: Use string.h, not gdb_string.h.
2013-11-18 13:29:00 -07:00
Tom Tromey 5c4c8a5911 remove unused field from struct elfinfo
I noticed that one field in elfread.c:struct elfinfo is unused.
This patch removes it.

	* elfread.c (struct elfinfo) <stabindexsect>: Remove.
	(elf_locate_sections): Update.
2013-10-17 15:41:46 +00:00
Tom Tromey dc294be54c fix PR symtab/15597
This patch fixes gdb PR symtab/15597.

The bug is that the .gnu_debugaltlink section includes the build-id of
the alt file, but gdb does not use it.

This patch fixes the problem by changing gdb to do what it ought to
always have done: verify the build id of the file found using the
filename in .gnu_debugaltlink; and if that does not match, try to find
the correct debug file using the build-id and debug-file-directory.

This patch touches BFD.  Previously, gdb had its own code for parsing
.gnu_debugaltlink; I changed it to use the BFD functions after those
were introduced.  However, the BFD functions are incorrect -- they
assume that .gnu_debugaltlink is formatted like .gnu_debuglink.
However, it it is not.  Instead, it consists of a file name followed
by the build-id -- no alignment, and the build-id is not a CRC.

Fixing this properly is a bit of a pain.  But, because
separate_alt_debug_file_exists just has a FIXME for the build-id case,
I did not fix it properly.  Instead I introduced a hack.  This leaves
BFD working just as well as it did before my patch.

I'm willing to do something better here but I could use some guidance
as to what.  It seems that the build-id code in BFD is largely punted
on.

FWIW gdb is the only user of bfd_get_alt_debug_link_info outside of
BFD itself.

I moved the build-id logic out of elfread.c and into a new file.
This seemed cleanest to me.

Writing a test case was a bit of a pain.  I added a couple new
features to the DWARF assembler to handle this.

Built and regtested on x86-64 Fedora 18.

	* bfd-in2.h: Rebuild.
	* opncls.c (bfd_get_alt_debug_link_info): Add buildid_len
	parameter.  Change type of buildid_out.  Update.
	(get_alt_debug_link_info_shim): New function.
	(bfd_follow_gnu_debuglink): Use it.

	* Makefile.in (SFILES): Add build-id.c.
	(HFILES_NO_SRCDIR): Add build-id.h.
	* build-id.c: New file, largely from elfread.c.  Modified
	most functions.
	* build-id.h: New file.
	* dwarf2read.c (dwarf2_get_dwz_file): Update for change to
	bfd_get_alt_debug_link_info.  Verify dwz file's build-id.
	Search for dwz file using build-id.
	* elfread.c (build_id_bfd_get, build_id_verify)
	(build_id_to_debug_filename, find_separate_debug_file): Remove.

	* gdb.dwarf2/dwzbuildid.exp: New file.
	* lib/dwarf.exp (Dwarf::_section): Add "flags" and "type"
	parameters.
	(Dwarf::_defer_output): Change "section" parameter to
	"section_spec"; update.
	(Dwarf::gnu_debugaltlink, Dwarf::_note, Dwarf::build_id): New
	procs.
2013-10-08 19:56:15 +00:00
Doug Evans 8fb8eb5ca4 New option "set debug symfile on".
* NEWS: Mention "set debug symfile".
	* Makefile.in (SFILES): Add symfile-debug.c.
	(COMMON_OBS): Add symfile-debug.o.
	* elfread.c (elf_symfile_read): Use objfile_set_sym_fns to set the
	objfile's symbol functions.
	* objfiles.h (objfile_set_sym_fns): Declare.
	* symfile-debug.c: New file.
	* symfile.c (syms_from_objfile_1): Use objfile_set_sym_fns to set the
	objfile's symbol functions.
	(reread_symbols): Ditto.
2013-09-25 23:17:12 +00:00
Doug Evans c256e17165 * symfile.h (struct sym_fns): Delete member "sym_flavour".
All uses updated.
	(add_symtab_fns): Update prototype.
	* symfile.c (sym_fns_ptr): Delete.  Replace with ...
	(registered_sym_fns): ... this.
	(symtab_fns): Update.
	(add_symtab_fns): New arg "flavour".  All callers updated.
	(find_sym_fns): Rewrite to use new sym_fns registry.
2013-09-25 22:48:19 +00:00
Jan Kratochvil 24ba069af8 Keep objfile original filename
gdb/
2013-09-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Pass down original filename for objfile.
	* coffread.c (coff_symfile_read): Update symbol_file_add_separate call.
	* elfread.c (elf_symfile_read): Likewise.
	* jit.c (jit_object_close_impl): Update allocate_objfile call, no
	longer set ORIGINAL_NAME.
	(jit_bfd_try_read_symtab): Update symbol_file_add_from_bfd call.
	* jv-lang.c (get_dynamics_objfile): Update allocate_objfile call.
	* machoread.c (macho_add_oso_symfile): Add parameter name.  Update
	symbol_file_add_from_bfd call.
	(macho_symfile_read_all_oso): Update two macho_add_oso_symfile calls.
	(macho_check_dsym): Add parameter filenamep.  Change function comment.
	Set *filenamep.
	(macho_symfile_read): New variable dsym_filename.  Update
	macho_check_dsym call.  Use it for symbol_file_add_separate.
	* objfiles.c (allocate_objfile): Add parameter name.  New comment for
	it.  Use it for objfile->original_name.
	(objfile_name): Return OBFD's filename, if available.
	* objfiles.h (allocate_objfile): Add new parameter name.
	* solib.c (solib_read_symbols): Update symbol_file_add_from_bfd call.
	* symfile-mem.c (symbol_file_add_from_memory): Update
	symbol_file_add_from_bfd call.
	* symfile.c (read_symbols): Update symbol_file_add_separate call, new
	comment for it.
	(symbol_file_add_with_addrs): New parameter name, add function comment
	for it.  Remove variable name.  Update allocate_objfile call.
	(symbol_file_add_separate): New parameter name, add function comment
	for it.  Update symbol_file_add_with_addrs call.
	(symbol_file_add_from_bfd): New parameter name.  Update
	symbol_file_add_with_addrs call.
	(symbol_file_add): Update symbol_file_add_from_bfd call.
	(reread_symbols): New variable original_name.  Save
	objfile->original_name by it.
	* symfile.h (symbol_file_add_from_bfd, symbol_file_add_separate): Add
	second parameter.
2013-09-24 14:00:06 +00:00
Jan Kratochvil 4262abfb98 Code cleanup: Add objfile_name accessor
gdb/
2013-09-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Code cleanup: Add objfile_name accessor function.
	* ada-lang.c (is_known_support_routine): Use objfile_name.
	* auto-load.c (source_gdb_script_for_objfile)
	(auto_load_objfile_script): Likewise.
	* coffread.c (coff_symtab_read, read_one_sym): Likewise.
	* dbxread.c (dbx_symfile_read): Likewise.
	* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
	* dwarf2loc.c (locexpr_describe_location_piece): Likewise.
	* dwarf2read.c (dwarf2_get_dwz_file, dwarf2_read_index)
	(dw2_symtab_iter_next, dw2_expand_symtabs_matching)
	(lookup_dwp_signatured_type, lookup_dwo_unit)
	(dwarf2_build_psymtabs_hard, scan_partial_symbols, process_queue)
	(fixup_go_packaging, process_imported_unit_die, dwarf2_physname)
	(read_import_statement, create_dwo_cu, open_and_init_dwp_file)
	(lookup_dwo_cutu, read_call_site_scope, dwarf2_ranges_read)
	(dwarf2_record_block_ranges, read_common_block, read_typedef)
	(read_subrange_type, load_partial_dies, read_partial_die)
	(read_addr_index_1, read_str_index, dwarf_decode_lines_1)
	(die_containing_type, build_error_marker_type, lookup_die_type)
	(follow_die_ref_or_sig, follow_die_ref, dwarf2_fetch_die_loc_sect_off)
	(dwarf2_fetch_constant_bytes, follow_die_sig, get_signatured_type)
	(get_DW_AT_signature_type, write_psymtabs_to_index)
	(save_gdb_index_command): Likewise.
	* elfread.c (find_separate_debug_file_by_buildid, elf_symfile_read):
	Likewise.
	* expprint.c (dump_subexp_body_standard): Likewise.
	* gdbtypes.c (type_name_no_tag_or_error): Likewise.
	* jit.c (jit_object_close_impl): Use the objfile field name renamed to
	original_name.
	* linux-thread-db.c (try_thread_db_load_from_pdir_1): New variable
	obj_name, use objfile_name for it, use the variable.
	(try_thread_db_load_from_pdir, has_libpthread, thread_db_new_objfile):
	Use objfile_name.
	* machoread.c (macho_symtab_read, macho_check_dsym)
	(macho_symfile_relocate): Likewise.
	* maint.c (maintenance_translate_address): Likewise.
	* minidebug.c (find_separate_debug_file_in_section): Likewise.
	* minsyms.c (install_minimal_symbols): Likewise.
	* objfiles.c (allocate_objfile): Use the objfile field name renamed to
	original_name.
	(filter_overlapping_sections): Use objfile_name.
	(objfile_name): New function.
	* objfiles.h (struct objfile): Rename field name to original_name.
	(objfile_name): New prototype.
	* printcmd.c (sym_info, address_info): Use objfile_name.
	* probe.c (parse_probes, collect_probes, compare_probes)
	(info_probes_for_ops): Likewise.
	* progspace.c (clone_program_space): Likewise.
	* psymtab.c (require_partial_symbols, dump_psymtab, allocate_psymtab)
	(maintenance_info_psymtabs): Likewise.
	* python/py-auto-load.c (gdbpy_load_auto_script_for_objfile)
	(source_section_scripts): Likewise.
	* python/py-objfile.c (objfpy_get_filename): Likewise.
	* python/py-progspace.c (pspy_get_filename): Likewise.
	* solib-aix.c (solib_aix_get_toc_value): Likewise.
	* solib-som.c (match_main, som_solib_section_offsets): Likewise.
	* solib.c (solib_read_symbols): Likewise.
	* stabsread.c (scan_file_globals): Likewise.
	* stap-probe.c (handle_stap_probe): Likewise.
	* symfile.c (symbol_file_clear, separate_debug_file_exists)
	(find_separate_debug_file_by_debuglink): Likewise.
	(reread_symbols): Likewise.  Use the objfile field name renamed to
	original_name.
	(allocate_symtab): Use objfile_name.
	* symmisc.c (print_symbol_bcache_statistics, print_objfile_statistics)
	(dump_objfile, dump_msymbols, dump_symtab_1)
	(maintenance_print_msymbols, maintenance_print_objfiles)
	(maintenance_info_symtabs, maintenance_check_symtabs): Likewise.
	* target.c (target_translate_tls_address, target_info): Likewise.
	* xcoffread.c (xcoff_initial_scan): Make variable name const.  Use
	objfile_name.
2013-09-24 13:57:38 +00:00
Doug Evans 4f00dda370 * elfread.c (elf_symfile_read): Move "Done reading minimal symbols"
debugging printf to better location.
2013-08-24 00:12:25 +00:00
Tom Tromey df6d544176 move gdbarch object from objfile to per-BFD
This moves the "gdbarch" field from the objfile into the BFD.

This field's value is derived from the BFD and is immutable over the
lifetime of the BFD.  This makes it a reasonable candidate for pushing
into the per-BFD object.

This is part of the long-term objfile splitting project.  In the long
run I think this patch will make it simpler to moves types from the
objfile to the per-BFD object; but the patch makes sense as a minor
cleanup by itself.

Built and regtested on x86-64 Fedora 18.

	* cp-namespace.c (cp_lookup_symbol_imports_or_template): Use
	get_objfile_arch.
	* elfread.c (elf_rel_plt_read, elf_gnu_ifunc_record_cache)
	(elf_gnu_ifunc_resolve_by_got): Use get_objfile_arch.
	* jit.c (jit_object_close_impl): Update.
	* jv-lang.c (get_dynamics_objfile): Update.
	* linespec.c (add_minsym): Use get_dynamics_objfile.
	* objfiles.c (get_objfile_bfd_data): Initialize 'gdbarch' field.
	(allocate_objfile): Don't initialize 'gdbarch' field.
	(get_objfile_arch): Update.
	* objfiles.h (struct objfile_per_bfd_storage) <gdbarch>: New field,
	moved from...
	(struct objfile) <gdbarch>: ... here.  Remove.
	* stap-probe.c (stap_can_evaluate_probe_arguments): Use
	get_objfile_arch.
	* symfile.c (init_entry_point_info): Use get_objfile_arch.
2013-08-20 15:04:51 +00:00
Sergio Durigan Junior 25f9533e51 2013-07-24 Sergio Durigan Junior <sergiodj@redhat.com>
* breakpoint.c (create_longjmp_master_breakpoint): Check if probe
	interface can evaluate arguments.  Fallback to the old mode if it
	cannot.
	(create_exception_master_breakpoint): Likewise.
	* elfread.c (elf_can_evaluate_probe_arguments): New function.
	(struct sym_probe_fns elf_probe_fns): Export function above to the
	probe interface.
	* probe.c (can_evaluate_probe_arguments): New function.
	* probe.h (struct probe_ops) <can_evaluate_probe_arguments>: New
	function pointer.
	(can_evaluate_probe_arguments): New function prototype.
	* solib-svr4.c (svr4_create_solib_event_breakpoints): Check if
	probe interface can evaluate arguments.  Fallback to the old mode
	if it cannot.
	* stap-probe.c (stap_get_probe_argument_count): Check if probe
	interface can evaluate arguments.  Warning the user if it cannot.
	(stap_can_evaluate_probe_arguments): New function.
	(struct probe_ops stap_probe_ops): Export function above to the
	probe interface.
	* symfile.h (struct sym_probe_fns) <can_evaluate_probe_arguments>:
	New function pointer.
2013-07-24 19:50:32 +00:00
Doug Evans 3189cb1297 * dbxread.c (process_one_symbol): Constify section_offsets parameter.
* stabsread.h (process_one_symbol): Update declaration.
	* dwarf2read.c (dw2_relocate): Constify new_offsets, delta parameters.
	* elfread.c (elf_symfile_relocate_probe): Ditto.
	* psymtab.c (relocate_psymtabs): Ditto.
	* objfiles.c (objfile_relocate1): Constify new_offsets parameter.
	(objfile_relocate): Ditto.
	* objfiles.h (objfile_relocate): Update declaration.
	* symfile.c (relative_addr_info_to_section_offsets): Constify
	addrs parameter.
	(default_symfile_offsets): Ditto.
	(syms_from_objfile_1): Constify offsets parameter.
	(syms_from_objfile): Ditto.
	(symbol_file_add_with_addrs_or_offsets): Ditto.
	(symfile_map_offsets_to_segments): Constify data parameter.
	* symfile.h (struct quick_symbol_functions): Constify new_offsets,
	delta parameters of member relocate.
	(struct sym_probe_fns): Constify new_offsets,
	delta parameters of member sym_relocate_probe.
	(struct sym_fns): Constify section_addr_info parameter of member
	sym_offsets.
	(relative_addr_info_to_section_offsets): Update declaration.
	(default_symfile_offsets): Ditto.
	(syms_from_objfile): Ditto.
	(symfile_map_offsets_to_segments): Ditto.
2013-05-06 19:15:17 +00:00
Tom Tromey 715c6909e2 * elfread.c (elf_symtab_read): Install versioned symbol under
unversioned name as well.
2013-04-15 17:31:17 +00:00
Tom Tromey e27d198cc4 PR symtab/8424:
* blockframe.c (find_pc_partial_function_gnu_ifunc): Check
	SYMBOL_SECTION, not SYMBOL_OBJ_SECTION.
	* breakpoint.c (resolve_sal_pc): Update.
	* elfread.c (elf_gnu_ifunc_record_cache): Update.
	* findvar.c (struct minsym_lookup_data) <objfile>: New field.
	(minsym_lookup_iterator_cb): Use it.
	(default_read_var_value): Update.
	* hppa-hpux-tdep.c (hppa64_hpux_in_solib_call_trampoline):
	Update.
	* infcmd.c (jump_command): Update.
	* linespec.c (minsym_found): Update.
	* maint.c (maintenance_translate_address): Update.
	* minsyms.c (lookup_minimal_symbol_by_pc_section_1): Update.
	(prim_record_minimal_symbol_full): Don't set SYMBOL_OBJ_SECTION.
	* parse.c (write_exp_msymbol): Update.
	* printcmd.c (address_info): Update.
	* psymtab.c (find_pc_sect_psymbol): Update.
	(fixup_psymbol_section): Check SYMBOL_SECTION, not
	SYMBOL_OBJ_SECTION.
	(add_psymbol_to_bcache): Correctly initialize SYMBOL_SECTION.
	Don't initialize SYMBOL_OBJ_SECTION.
	* spu-tdep.c (spu_catch_start): Update.
	* stabsread.c (define_symbol): Don't set SYMBOL_SECTION.
	* symmisc.c (dump_msymbols, print_symbol): Update.
	* symtab.c (fixup_section): Don't set 'obj_section'.  Change
	how fallback section is computed.
	(fixup_symbol_section): Update.
	(find_pc_sect_symtab, find_function_start_sal, skip_prologue_sal):
	Update.
	(allocate_symbol, initialize_symbol, allocate_template_symbol):
	Initialize SYMBOL_SECTION.
	* symtab.h (struct general_symbol_info) <section>: Update comment.
	<obj_section>: Remove.
	(SYMBOL_OBJ_SECTION): Add 'objfile' argument.  Rewrite.
	(SYMBOL_OBJFILE): New macro.
2013-04-08 20:18:11 +00:00
Tom Tromey e6dc44a8f5 * coffread.c (record_minimal_symbol): Update.
* dbxread.c (record_minimal_symbol): Update.
	* elfread.c (record_minimal_symbol): Update.
	* machoread.c (macho_symtab_add_minsym): Update.
	* mdebugread.c (record_minimal_symbol, parse_partial_symbols):
	Update.
	* minsyms.c (prim_record_minimal_symbol): Update.
	(prim_record_minimal_symbol_full): Remove 'bfd_section'
	argument.
	(prim_record_minimal_symbol_and_info): Likewise.
	* minsyms.h (prim_record_minimal_symbol_full)
	(prim_record_minimal_symbol_and_info): Update.
	* symtab.c (allocate_symbol, initialize_symbol)
	(allocate_template_symbol): Initialize SYMBOL_SECTION.
	* xcoffread.c (record_minimal_symbol, scan_xcoff_symtab):
	Update.
2013-04-08 20:13:22 +00:00
Tom Tromey 65cf356359 * coffread.c (cs_to_section): Use gdb_bfd_section_index.
* elfread.c (record_minimal_symbol, elf_symtab_read): Use
	gdb_bfd_section_index.
	* gdb_bfd.c (gdb_bfd_section_index, gdb_bfd_count_sections):
	New functions.
	* gdb_bfd.h (gdb_bfd_section_index, gdb_bfd_count_sections):
	Declare.
	* machoread.c (macho_symtab_add_minsym, macho_symfile_offsets):
	Update.
	* objfiles.c (add_to_objfile_sections_full): New function.
	(add_to_objfile_sections): Use it.
	(build_section_table): Rewrite.
	(objfile_relocate1): Use gdb_bfd_section_index.  Update.
	* objfiles.h (obj_section_offset): Use gdb_bfd_section_index.
	(struct objfile) <sections>: Update comment.
	(ALL_OBJFILE_OSECTIONS): Skip sections where the_bfd_section
	is NULL.
	(ALL_OBJSECTIONS): Use it.
	* solib-dsbt.c (dsbt_relocate_main_executable): Update.
	* solib-frv.c (frv_relocate_main_executable): Update.
	* solib-target.c (solib_target_relocate_section_addresses):
	Use gdb_bfd_section_index.
	* symfile.c (build_section_addr_info_from_section_table):
	Use gdb_bfd_section_index.
	(build_section_addr_info_from_bfd, place_section): Likewise.
	* symtab.c (fixup_section): Update.
	* xcoffread.c (find_targ_sec): Use gdb_bfd_section_index.
2013-04-08 20:04:42 +00:00
Tom Tromey 7cbd4a934e * minsyms.h (struct bound_minimal_symbol): New.
(lookup_minimal_symbol_and_objfile): Return bound_minimal_symbol.
	Remove objfile argument.
	(lookup_minimal_symbol_by_pc_section, lookup_minimal_symbol_by_pc):
	Return bound_minimal_symbol.
	* minsyms.c (lookup_minimal_symbol_by_pc_1)
	(lookup_minimal_symbol_by_pc_section, lookup_minimal_symbol_by_pc):
	Return bound_minimal_symbol.
	(in_gnu_ifunc_stub): Update.
	(lookup_minimal_symbol_and_objfile): Return bound_minimal_symbol.
	Remove 'objfile_p' argument.
	(lookup_solib_trampoline_symbol_by_pc): Update.
	* ada-tasks.c, amd64-windows-tdep.c, arm-tdep.c,
	arm-wince-tdep.c, block.c, blockframe.c, breakpoint.c, btrace.c,
	c-valprint.c, dwarf2loc.c, elfread.c, frame.c, frv-tdep.c,
	glibc-tdep.c, gnu-v2-abi.c, gnu-v3-abi.c, hppa-hpux-tdep.c,
	i386-tdep.c, ia64-tdep.c, infcall.c, infcmd.c, jit.c,
	linux-fork.c, m32c-tdep.c, m68hc11-tdep.c, maint.c,
	mips-tdep.c, p-valprint.c, parse.c, ppc-linux-tdep.c,
	ppc-sysv-tdep.c, printcmd.c, rs6000-tdep.c, sh64-tdep.c,
	stack.c, symtab.c, tui/tui-disasm.c: Update.
2013-04-08 19:59:09 +00:00
Sergio Durigan Junior bb869963da From: Sergio Durigan Junior <sergiodj@redhat.com>
Subject: [PATCH] Fix for PR c++/15203 and PR c++/15210
Date: Sat, 09 Mar 2013 02:50:49 -0300 (5 days, 4 hours, 57 minutes ago)
Message-ID: <m3a9qdnmti.fsf@redhat.com>

Hi,

This bug was reported internally at our Bugzilla, along with a proposed
fix.  After talking to Keith about it, he investigated and came up with
another patch needed to really fix the issue on CVS HEAD.

The first part of the fix is the patch to cp-namespace.c.  It handles
the case when we are accessing a static variable inside a function
(inside a class) by the full linespec (is it right, Keith?).  E.g.:

    class foo
    {
    public:
        int bar()
        {
            static int var = 0;
        }
    };

And then, printing the value of `var':

    (gdb) print 'foo::bar()::var'

GDB would fall in an internal_error:

    gdb/cp-namespace.c:816: internal-error: cp_lookup_nested_symbol called on a non-aggregate type.

This is because `cp_lookup_nested_symbol' is not handling the case when
TYPE_CODE is either _FUNC or _METHOD.  This patch fixes it by returning
NULL in this case.

The second part of the fix is the patch to elfread.c.  It is needed
because the BSF_GNU_UNIQUE flag was added to some symbols in
<http://sourceware.org/ml/binutils/2009-06/msg00016.html>.  Because of
that, (still) the command:

    (gdb) print 'foo::bar()::var'

where `var' is a static variable returns:

    "No symbol "foo::bar()::var" in current context."

So with the second patch applied the command finally DTRT:

    (gdb) print 'foo::bar()::var'
    $1 = 0

This may not be the ideal solution, according to Keith it would be good
to implement productions on c-exp.y in order to recognize
CLASS::FUNCTION::VARIABLE, but it is a solution which works with what we
have today.

I regtested it in Fedora 17 x86_64 with -m64 and -m32, including
gdbserver, without regressions.

gdb/:
2013-03-14  Keith Seitz  <keiths@redhat.com>
	    Alan Matsuoka  <alanm@redhat.com>

	PR c++/15203
	PR c++/15210
	* cp-namespace.c (cp_lookup_nested_symbol): Handle TYPE_CODE_FUNC and
	TYPE_CODE_METHOD.
	* elfread.c (elf_symtab_read): Handle BSF_GNU_UNIQUE for certain
	symbols.

gdb/testsuite/:
2013-03-14  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR c++/15203
	PR c++/15210
	* gdb.cp/m-static.cc (keepalive_int): New function.
	(gnu_obj_1::method): New variable `sintvar', call `keepalive_int'.
	* gdb.cp/m-static.exp: New test for `sintvar'.
2013-03-14 11:13:36 +00:00
Doug Evans 7b6c814ed7 * elfread.c (elf_symfile_read): Move debugging printf to more
logical location.
2013-03-06 21:20:02 +00:00
Alan Modra 24c274a133 * elfread.c (elf_symtab_read): Do not use udata.p here to find
symbol size.
	* ppc64-tdep.c (ppc64_elf_make_msymbol_special): New function.
	* ppc64-tdep.h (ppc64_elf_make_msymbol_special): Declare.
	* ppc-linux-tdep.c (ppc_linux_init_abi): Set up to use the above.
	* ppcfbsd-tdep.c (ppcfbsd_init_abi): Likewise.
2013-02-22 23:24:24 +00:00
Jan Kratochvil bfada1897a gdb/
Code cleanup.
	* elfread.c (build_id_bfd_get): Make the return type const.
	(build_id_verify): Make the check parameter const.
	(build_id_to_debug_filename): Make the build_id parameter and variable
	data const.
	(find_separate_debug_file_by_buildid): Make the variable build_id const.
2013-02-22 16:40:56 +00:00
Alan Modra c03551323c bfd/
* elf-bfd.h (struct elf_build_id): Extracted from..
	(struct elf_build_id_info): ..here.  Delete.
	(struct output_elf_obj_tdata): New, extracted from..
	(struct elf_obj_tdata): ..here.  Reorganize for better packing.
	Add "o" field.
	(elf_program_header_size): Reference tdata->o.
	(elf_seg_map, elf_next_file_pos, elf_eh_frame_hdr, elf_linker,
	elf_stack_flags, elf_shstrtab, elf_strtab_sec, elf_shstrtab_sec,
	elf_section_syms, elf_num_section_syms, elf_flags_init): Likewise.
	* elf.c (bfd_elf_allocate_object): Allocate output_elf_obj_tdata
	when opening bfd in any mode that might write.
	(_bfd_elf_write_object_contents): Use build_id field in
	output_elf_obj_tdata.
	(_bfd_elf_close_and_cleanup): Tweak elf_shstrtab test.
	(elfobj_grok_gnu_build_id): Adjust for elf_tdata changes.
gdb/
	* elfread.c (build_id_bfd_get): Adjust for elf_tdata changes.
ld/
	* emultempl/elf32.em (write_build_id, setup_build_id): Adjust
	for elf_tdata changes.
2013-02-21 04:35:22 +00:00
Alan Modra 30e8ee25e3 include/
* bfdlink.h (struct bfd_link_info): Delete emit_note_gnu_build_id.
bfd/
	* configure.in: Bump version to 2.23.52.
	* elf-bfd.h (struct elf_build_id_info): New.
	(struct elf_obj_tdata): Delete after_write_object_contents,
	after_write_object_contents_info and build_id_size.  Make build_id
	a pointer to struct elf_build_id_info.
	* elf.c (_bfd_elf_write_object_contents): Style.  Update
	after_write_ibject_contents invocation.
	(elfobj_grok_gnu_build_id): Update for new build_id struct.  Don't
	allow zero size notes.
	* configure: Regenerate.
gdb/
	* elfread.c (struct build_id): Delete.  Use struct elf_build_id
	throughout file instead.
	(build_id_bfd_get): Update to use new elf_tdata build_id field.
	Don't xmalloc return value.
	(build_id_verify): Similarly.  Don't xfree.
	(build_id_to_debug_filename): Update.
	(find_separate_debug_file_by_buildid): Update, don't xfree.
ld/
	* emultempl/elf32.em (emit_note_gnu_build_id): New static var.
	Replace all info->emit_note_gnu_build_id refs.
	(id_note_section_size): Rename from
	gld${EMULATION_NAME}_id_note_section_size.
	(struct build_id_info): Delete.
	(write_build_id): Rename from
	gld${EMULATION_NAME}_write_build_id_section.
	Update elf_tdata usage.  Style, formatting.
	(setup_build_id): New function.
	(gld${EMULATION_NAME}_after_open): Use setup_build_id.
2013-02-18 23:50:32 +00:00
Jan Kratochvil 8a92335bfc gdb/
* elfread.c (elf_symfile_read): Limit separate debug info additions to
	files with no separate debug info.
	* objfiles.c (add_separate_debug_objfile): Add gdb_assert calls.
	* symfile.c (read_symbols): Call find_separate_debug_file_in_section
	only for files with no separate debug info.

gdb/testsuite/
	* gdb.base/gnu-debugdata.exp): Create ${binfile}.debug,
	${binfile}.mini_debuginfo-debuglink, add -k to xz, use now
	${binfile}.mini_debuginfo-debuglink and
	${binfile}.mini_debuginfo-debuglink.xz.
2013-02-01 19:39:04 +00:00
Joel Brobecker 28e7fd6234 Update years in copyright notice for the GDB files.
Two modifications:
  1. The addition of 2013 to the copyright year range for every file;
  2. The use of a single year range, instead of potentially multiple
     year ranges, as approved by the FSF.
2013-01-01 06:33:28 +00:00
Tom Tromey d2f4b8feb9 * coffread.c (coff_symfile_init): Use set_objfile_data.
(coff_symfile_read): Use DBX_SYMFILE_INFO.
	* dbxread.c (dbx_objfile_data_key): New global.
	(dbx_symfile_init): Use set_objfile_data.
	(dbx_symfile_finish): Don't free deprecated_sym_stab_info.
	(dbx_free_symfile_info): New function.
	(coffstab_build_psymtabs, elfstab_build_psymtabs): Use
	DBX_SYMFILE_INFO.
	(stabsect_build_psymtabs): Use set_objfile_data.
	(_initialize_dbxreadb): Initialize dbx_objfile_data_key.
	* elfread.c (elf_symtab_read): Use DBX_SYMFILE_INFO,
	set_objfile_data.
	(free_elfinfo): Use DBX_SYMFILE_INFO.
	(elf_symfile_finish): Don't free deprecated_sym_stab_info.
	(elfstab_offset_sections): Use DBX_SYMFILE_INFO.
	* gdb-stabs.h (dbx_objfile_data_key): Declare.
	(DBX_SYMFILE_INFO): Rewrite to use objfile_data.
	* objfiles.h (struct objfile) <deprecated_sym_stab_info>: Remove.
	* somread.c (som_symfile_finish): Don't free
	deprecated_sym_stab_info.
2012-12-12 15:57:01 +00:00
Yao Qi 85ddcc7021 gdb/
2012-11-21  Yao Qi  <yao@codesourcery.com>

	PR tdep/7438
	* gdbarch.sh (smash_text_address): Remove.
	* gdbarch.c, gdbarch.h: Regenerate.
	* arm-tdep.c (arm_smash_text_address): Remove.
	(arm_gdbarch_init): Don't call set_gdbarch_smash_text_address.
	* hppa-tdep.c (hppa_smash_text_address): Remove.
	(hppa_addr_bits_remove): Rename from hppa_smash_text_address.
	(hppa_gdbarch_init): Don't call set_gdbarch_smash_text_address.
	Caller update.
	* coffread.c (coff_symtab_read): Caller update.
	* dbxread.c (process_one_symbol): Likewise.
	* elfread.c (record_minimal_symbol): Likewise.
	* somread.c (som_symtab_read): Likewise.
2012-11-21 00:29:55 +00:00
Joel Brobecker d9eaeb59a4 Name of symbol missing when printing global variable's address
The build_address_symbolic funnction filters out data symbols if
their size is set to zero.  But the problem is that the COFF symbol
table (for instance) does not provide any size information, leaving
the size to its default value of zero, thus always triggering
the filter.

This shows up when trying to print the address of a global variable
when debugging a Windows executable, for instance.

gdb/ChangeLog:

        * symtab.h (struct minimal_symbol) [has_size]: New field.
        (MSYMBOL_SIZE): Adjust to forbid macro from being used as lvalue.
        (SET_MSYMBOL_SIZE, MSYMBOL_HAS_SIZE): New macros.
        * printcmd.c (build_address_symbolic): Only filter out zero-sized
        minimal symbols if the symbol's size is actually known.
        * minsyms.c (prim_record_minimal_symbol_full): Adjust setting
        of msymbol's size field.  Add comment.
        * elfread.c (elf_symtab_read, elf_rel_plt_read): Use
        SET_MSYMBOL_SIZE to set the minimal symbol size.
2012-09-11 21:26:16 +00:00
Tom Tromey 706e37059f * elfread.c (elf_symtab_read): Update.
* objfiles.c (objfiles_bfd_data): New global.
	(get_objfile_bfd_data, free_objfile_per_bfd_storage)
	(objfile_bfd_data_free, set_objfile_per_bfd): New functions.
	(allocate_objfile, free_objfile): Update.
	(_initialize_objfiles): Initialize objfiles_bfd_data.
	* objfiles.h (struct objfile_per_bfd_storage): New.
	(struct objfile) <per_bfd>: New field.
	<filename_cache>: Remove.
	(set_objfile_per_bfd): Declare.
	* symfile.c (reread_symbols): Update.  Call
	set_objfile_per_bfd.
	(allocate_symtab): Update.
	* symmisc.c (print_symbol_bcache_statistics): Update.
	(print_objfile_statistics): Print the size of the BFD obstack.
gdb/testsuite
	* gdb.base/maint.exp: Update.
2012-08-22 16:01:09 +00:00
Tom Tromey 08d2cd740c * symfile.c (separate_debug_file_exists): Update.
(gdb_bfd_open_maybe_remote): Rename from bfd_open_maybe_remote.
	(reread_symbols): Update.
	* elfread.c (build_id_verify): Update.
	* symfile.h (gdb_bfd_open_maybe_remote): Rename from
	bfd_open_maybe_remote.
2012-07-23 15:03:59 +00:00
Tom Tromey 8ac244b433 * coffread.c (coff_symfile_read): Make a cleanup for 'debugfile'
and 'abfd'.
	* elfread.c (elf_symfile_read): Make a cleanup for 'debugfile'
	and 'abfd'.
	* jit.c (jit_bfd_try_read_symtab): Make a cleanup for 'nbfd'.
	* machoread.c (macho_add_oso_symfile): Make a cleanup for
	'abfd'.
	(macho_symfile_read): Make a cleanup for 'dsym_bfd'.
	* objfiles.c (allocate_objfile): Acquire a new reference.
	* rs6000-nat.c (add_vmap): Don't acquire a BFD reference.
	* solib.c (solib_read_symbols): Don't acquire a BFD reference.
	* spu-linux-nat.c (spu_symbol_file_add_from_memory): Make
	a cleanup for 'nbfd'.
	* symfile-mem.c (symbol_file_add_from_memory): Make a cleanup
	for 'nbfd'.
	* symfile.c (symbol_file_add_with_addrs_or_offsets): Don't
	make a cleanup for 'abfd'.
	(symbol_file_add): Make a BFD cleanup.
2012-07-23 14:58:44 +00:00
Tom Tromey cbb099e886 * dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
	(free_dwo_file): Use gdb_bfd_unref.
	* cli/cli-dump.c: Include gdb_bfd.h.
	(bfd_openw_with_cleanup): Use gdb_bfd_ref.
	(bfd_openr_with_cleanup): Likewise.
	* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
	gdb_bfd_unref.
	* utils.c: Include gdb_bfd.h.
	(do_bfd_close_cleanup): Use gdb_bfd_unref.
	* symfile.c: Include gdb_bfd.h.
	(separate_debug_file_exists): Use gdb_bfd_unref.
	(bfd_open_maybe_remote): Use gdb_bfd_ref.
	(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
	(generic_load): Use gdb_bfd_ref.
	(reread_symbols): Use gdb_bfd_unref.
	* symfile-mem.c: Include gdb_bfd.h.
	(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
	* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
	* solib.c: Include gdb_bfd.h.
	(solib_bfd_fopen): Use gdb_bfd_ref.
	(solib_bfd_open): Use gdb_bfd_unref.
	(free_so_symbols): Use gdb_bfd_unref.
	(reload_shared_libraries_1): Use gdb_bfd_unref.
	* solib-spu.c: Include gdb_bfd.h.
	(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
	* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
	gdb_bfd_unref.
	* solib-frv.c: Include gdb_bfd.h.
	(enable_break2): Use gdb_bfd_unref.
	* solib-dsbt.c: Include gdb_bfd.h.
	(enable_break2): Use gdb_bfd_unref.
	* solib-darwin.c: Include gdb_bfd.h.
	(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
	gdb_bfd_unref.
	(darwin_bfd_open): Use gdb_bfd_unref.
	* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
	* remote-mips.c: Include gdb_bfd.h.
	(mips_load_srec): Use gdb_bfd_ref.
	(pmon_load_fast): Use gdb_bfd_ref.
	* remote-m32r-sdi.c: Include gdb_bfd.h.
	(m32r_load): Use gdb_bfd_ref.
	* record.c: Include gdb_bfd.h.
	(record_save_cleanups): Use gdb_bfd_unref.
	(cmd_record_save): Use gdb_bfd_unref.
	* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
	gdb_bfd_unref.
	* objfiles.h (gdb_bfd_close_or_warn): Remove.
	(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
	* objfiles.c: Include gdb_bfd.h.
	(free_objfile): Use gdb_bfd_unref.
	(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
	gdb_bfd.c.
	* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
	(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
	(macho_check_dsym): Likewise.
	* m32r-rom.c: Include gdb_bfd.h.
	(m32r_load): Use gdb_bfd_ref.
	(m32r_upload_command): Use gdb_bfd_ref.
	* jit.c: Include gdb_bfd.h.
	(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
	* gdb_bfd.h: New file.
	* gdb_bfd.c: New file.
	* gcore.c: Include gdb_bfd.h.
	(create_gcore_bfd): Use gdb_bfd_ref.
	(do_bfd_delete_cleanup): Use gdb_bfd_unref.
	(gcore_command): Use gdb_bfd_unref.
	* exec.c: Include gdb_bfd.h.
	(exec_close): Use gdb_bfd_unref.
	(exec_close_1): Use gdb_bfd_unref.
	(exec_file_attach): Use gdb_bfd_ref.
	* elfread.c: Include gdb_bfd.h.
	(build_id_verify): Use gdb_bfd_unref.
	* dsrec.c: Include gdb_bfd.h.
	(load_srec): Use gdb_bfd_ref.
	* corelow.c: Include gdb_bfd.h.
	(core_close): Use gdb_bfd_unref.
	(core_open): Use gdb_bfd_ref.
	* bfd-target.c: Include gdb_bfd.h.
	(target_bfd_xclose): Use gdb_bfd_unref.
	(target_bfd_reopen): Use gdb_bfd_ref.
	* Makefile.in (SFILES): Add gdb_bfd.c.
	(HFILES_NO_SRCDIR): Add gdb_bfd.h.
	(COMMON_OBS): Add gdb_bfd.o.
2012-07-18 19:33:34 +00:00
Sergio Durigan Junior 6bac747387 2012-07-18 Sergio Durigan Junior <sergiodj@redhat.com>
* elfread.c (elf_get_probe_argument_count): Remove `objfile' argument.
	(elf_compile_to_ax): Likewise.
	* infrun.c (insert_exception_resume_from_probe): Likewise.
	(check_exception_resume): Remove `objfile' variable.
	* probe.c (find_probe_by_pc): Remove `objfile' argument.
	(struct probe_and_objfile, probe_and_objfile_s): Delete.
	(collect_probes): Adjust return value to `VEC (probe_p) *'.
	(compare_entries): Rename to...
	(compare_probes): ...this.  Adjust function to work with
	`struct probe *'.  Rename variables `ea' and `eb' to `pa' and `pb'
	respectively.
	(gen_ui_out_table_header_info): Adjust `probes' argument to be
	`VEC (probe_p) *'.
	(print_ui_out_info): Adjust argument to be `struct probe *'.
	(info_probes_for_ops): Adjust internal computations to use
	`VEC (probe_p) *'.
	(probe_safe_evaluate_at_pc): Refactor to not pass `objfile' anymore.
	* probe.h (struct probe_ops) <get_probe_argument_count, compile_to_ax,
	gen_info_probes_table_values>: Remove `objfile' argument.
	(struct probe) <objfile>: New field.
	(find_probe_by_pc): Remove `objfile' argument.
	* stap-probe.c (stap_parse_probe_arguments): Likewise.
	(stap_get_probe_argument_count): Likewise.
	(stap_get_arg): Likewise.
	(stap_evaluate_probe_argument): Likewise.
	(stap_compile_to_ax): Likewise.
	(compile_probe_arg): Refactor not to pass `objfile' anymore.
	(handle_stap_probe): Fill `objfile' field from `struct probe'.
	(stap_gen_info_probes_table_header): Remove `objfile' argument.
	* symfile.h (struct sym_probe_fns) <sym_evaluate_probe_argument,
	sym_compile_to_ax>: Likewise.
2012-07-18 16:12:17 +00:00
Doug Evans 45cfd46896 * NEWS: Mention new options "set debug dwarf2-read" and
"set debug symtab-create".
	* dwarf2read.c (dwarf2_read_debug): New static global.
	(dwarf2_build_psymtabs_hard): Add debugging printfs.
	(process_queue): Ditto.
	(process_full_comp_unit): Ditto.
	(_initialize_dwarf2_read): Add new option "set debug dwarf2-read".
	* elfread.c (elf_symfile_read): Add debugging printf.
	* minsyms.c (install_minimal_symbols): Ditto.
	* psymtab.c (allocate_psymtab): Ditto.
	* symfile.c (allocate_symtab): Ditto.
	* symtab.c (symtab_create_debug): New global.
	(_initialize_symtab): Add new option "set debug symtab-create".
	* symtab.h (symtab_create_debug): Declare.

	doc/
	* gdb.texinfo (Debugging Output): Document debug options dwarf2-read
	and symtab-create.
2012-06-26 20:14:03 +00:00
Doug Evans 422d65e705 * symtab.h (minimal_symbol): New member created_by_gdb.
* elfread.c (elf_symtab_read): Set created_by_gdb for @plt minsym
	created by gdb.
	* symtab.c (lookup_symbol_in_objfile_from_linkage_name): New function.
	(search_symbols): Call it instead of lookup_symbol.
	Skip symbols created by gdb.  Only scan minsyms if nfiles == 0.

	testsuite:
	* gdb.base/info-fun.exp: New file.
	* gdb.base/info-fun.c: New file.
	* gdb.base/info-fun-solib.c: New file.
2012-06-19 00:53:35 +00:00
Sergio Durigan Junior 22e048c9dd 2012-05-18 Sergio Durigan Junior <sergiodj@redhat.com>
* ada-lang.c:
	* ada-tasks.c:
	* ada-varobj.c:
	* amd64-darwin-tdep.c:
	* arm-symbian-tdep.c:
	* arm-tdep.c:
	* avr-tdep.c:
	* ax-gdb.c:
	* bfin-linux-tdep.c:
	* breakpoint.c:
	* c-valprint.c:
	* cli/cli-cmds.c:
	* coffread.c:
	* cp-support.c:
	* cris-tdep.c:
	* dwarf2-frame-tailcall.c:
	* dwarf2-frame.c:
	* dwarf2expr.c:
	* dwarf2loc.c:
	* dwarf2read.c:
	* elfread.c:
	* eval.c:
	* expprint.c:
	* f-valprint.c:
	* frv-tdep.c:
	* h8300-tdep.c:
	* hppa-hpux-tdep.c:
	* hppa-tdep.c:
	* hppanbsd-tdep.c:
	* i386-nto-tdep.c:
	* i386-tdep.c:
	* i387-tdep.c:
	* ia64-tdep.c:
	* jit.c:
	* linespec.c:
	* linux-tdep.c:
	* lm32-tdep.c:
	* m2-valprint.c:
	* m32c-tdep.c:
	* m32r-rom.c:
	* m32r-tdep.c:
	* m68k-tdep.c:
	* m68klinux-tdep.c:
	* mi/mi-main.c:
	* microblaze-tdep.c:
	* mips-linux-tdep.c:
	* mips-tdep.c:
	* mn10300-tdep.c:
	* p-valprint.c:
	* parse.c:
	* ppc-linux-tdep.c:
	* ppc-sysv-tdep.c:
	* printcmd.c:
	* python/py-finishbreakpoint.c:
	* python/py-inferior.c:
	* python/py-infthread.c:
	* python/py-type.c:
	* python/python.c:
	* remote-fileio.c:
	* remote-m32r-sdi.c:
	* remote-mips.c:
	* reverse.c:
	* rl78-tdep.c:
	* rs6000-aix-tdep.c:
	* rs6000-tdep.c:
	* s390-tdep.c:
	* score-tdep.c:
	* sh64-tdep.c:
	* skip.c:
	* solib-darwin.c:
	* solib-dsbt.c:
	* solib-frv.c:
	* sparc-tdep.c:
	* spu-multiarch.c:
	* spu-tdep.c:
	* stack.c:
	* symfile.c:
	* symtab.c:
	* tic6x-tdep.c:
	* tracepoint.c:
	* v850-tdep.c:
	* valarith.c:
	* valprint.c:
	* value.c:
	* xcoffread.c:
	* xtensa-tdep.c:
	* ada-lang.c:
	* ada-tasks.c:
	* ada-varobj.c:
	* amd64-darwin-tdep.c:
	* arm-symbian-tdep.c:
	* arm-tdep.c: Delete unused variables.
2012-05-18 21:02:52 +00:00
Maciej W. Rozycki 6a3a010ba6 gdb/
* breakpoint.h (bp_location): Add related_address member.
	* inferior.h (get_return_value): Take a pointer to struct value
	instead of struct type for the function requested.
	* value.h (using_struct_return): Likewise.
	* gdbarch.sh (return_value): Take a pointer to struct value
	instead of struct type for the function requested.
	* breakpoint.c (set_breakpoint_location_function): Initialize
	related_address for bp_gnu_ifunc_resolver breakpoints.
	* elfread.c (elf_gnu_ifunc_resolver_return_stop): Pass the
	requested function's address to gdbarch_return_value.
	* eval.c (evaluate_subexp_standard): Pass the requested
	function's address to using_struct_return.
	* infcall.c (call_function_by_hand): Pass the requested
	function's address to using_struct_return and
	gdbarch_return_value.
	* infcmd.c (get_return_value): Take a pointer to struct value
	instead of struct type for the function requested.
	(print_return_value): Update accordingly.
	(finish_command_continuation): Likewise.
	* stack.c (return_command): Pass the requested function's
	address to using_struct_return and gdbarch_return_value.
	* value.c (using_struct_return): Take a pointer to struct value
	instead of struct type for the function requested.  Pass the
	requested function's address to gdbarch_return_value.
	* python/py-finishbreakpoint.c (finish_breakpoint_object):
	New function_value member, replacing function_type.
	(bpfinishpy_dealloc): Update accordingly.
	(bpfinishpy_pre_stop_hook): Likewise.
	(bpfinishpy_init): Likewise.  Record the requested function's
	address.
	* mips-tdep.c (mips_fval_reg): New enum.
	(mips_o32_push_dummy_call): For MIPS16 FP doubles do not swap
	words put in GP registers.
	(mips_o64_push_dummy_call): Update a comment.
	(mips_o32_return_value): Take a pointer to struct value instead
	of struct type for the function requested and use it to check if
	using the MIPS16 calling convention.  Return the designated
	general purpose registers for floating-point values returned in
	MIPS16 mode.
	(mips_o64_return_value): Likewise.
	* ppc-tdep.h (ppc_sysv_abi_return_value): Update prototype.
	(ppc_sysv_abi_broken_return_value): Likewise.
	(ppc64_sysv_abi_return_value): Likewise.
	* alpha-tdep.c (alpha_return_value): Take a pointer to struct
	value instead of struct type for the function requested.
	* amd64-tdep.c (amd64_return_value): Likewise.
	* amd64-windows-tdep.c (amd64_windows_return_value): Likewise.
	* arm-tdep.c (arm_return_value): Likewise.
	* avr-tdep.c (avr_return_value): Likewise.
	* bfin-tdep.c (bfin_return_value): Likewise.
	* cris-tdep.c (cris_return_value): Likewise.
	* frv-tdep.c (frv_return_value): Likewise.
	* h8300-tdep.c (h8300_return_value): Likewise.
	(h8300h_return_value): Likewise.
	* hppa-tdep.c (hppa32_return_value): Likewise.
	(hppa64_return_value): Likewise.
	* i386-tdep.c (i386_return_value): Likewise.
	* ia64-tdep.c (ia64_return_value): Likewise.
	* iq2000-tdep.c (iq2000_return_value): Likewise.
	* lm32-tdep.c (lm32_return_value): Likewise.
	* m32c-tdep.c (m32c_return_value): Likewise.
	* m32r-tdep.c (m32r_return_value): Likewise.
	* m68hc11-tdep.c (m68hc11_return_value): Likewise.
	* m68k-tdep.c (m68k_return_value): Likewise.
	(m68k_svr4_return_value): Likewise.
	* m88k-tdep.c (m88k_return_value): Likewise.
	* mep-tdep.c (mep_return_value): Likewise.
	* microblaze-tdep.c (microblaze_return_value): Likewise.
	* mn10300-tdep.c (mn10300_return_value): Likewise.
	* moxie-tdep.c (moxie_return_value): Likewise.
	* mt-tdep.c (mt_return_value): Likewise.
	* ppc-linux-tdep.c (ppc_linux_return_value): Likewise.
	* ppc-sysv-tdep.c (ppc_sysv_abi_return_value): Likewise.
	(ppc_sysv_abi_broken_return_value): Likewise.
	(ppc64_sysv_abi_return_value): Likewise.
	* ppcnbsd-tdep.c (ppcnbsd_return_value): Likewise.
	* rl78-tdep.c (rl78_return_value): Likewise.
	* rs6000-aix-tdep.c (rs6000_return_value): Likewise.
	* rx-tdep.c (rx_return_value): Likewise.
	* s390-tdep.c (s390_return_value): Likewise.
	* score-tdep.c (score_return_value): Likewise.
	* sh-tdep.c (sh_return_value_nofpu): Likewise.
	(sh_return_value_fpu): Likewise.
	* sh64-tdep.c (sh64_return_value): Likewise.
	* sparc-tdep.c (sparc32_return_value): Likewise.
	* sparc64-tdep.c (sparc64_return_value): Likewise.
	* spu-tdep.c (spu_return_value): Likewise.
	* tic6x-tdep.c (tic6x_return_value): Likewise.
	* v850-tdep.c (v850_return_value): Likewise.
	* vax-tdep.c (vax_return_value): Likewise.
	* xstormy16-tdep.c (xstormy16_return_value): Likewise.
	* xtensa-tdep.c (xtensa_return_value): Likewise.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.

	gdb/testsuite/
	* gdb.base/return-nodebug.exp: Also test float and double types.
2012-05-16 14:35:09 +00:00
Alan Modra 45dfa85a1e Replace all uses of bfd_abs_section, bfd_com_section, bfd_und_section
and bfd_ind_section with their _ptr variants, or use corresponding
bfd_is_* macros.
2012-05-05 03:05:32 +00:00
Sergio Durigan Junior 55aa24fb2e 2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com>
Tom Tromey  <tromey@redhat.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (SFILES): Add `probe' and `stap-probe'.
	(COMMON_OBS): Likewise.
	(HFILES_NO_SRCDIR): Add `probe'.
	* NEWS: Mention support for static and SystemTap probes.
	* amd64-tdep.c (amd64_init_abi): Initializing proper fields used by
	SystemTap probes' arguments parser.
	* arm-linux-tdep.c: Including headers needed to perform the parsing
	of SystemTap probes' arguments.
	(arm_stap_is_single_operand): New function.
	(arm_stap_parse_special_token): Likewise.
	(arm_linux_init_abi): Initializing proper fields used by SystemTap
	probes' arguments parser.
	* ax-gdb.c (require_rvalue): Removing static declaration.
	(gen_expr): Likewise.
	* ax-gdb.h (gen_expr): Declaring function.
	(require_rvalue): Likewise.
	* breakpoint.c: Include `gdb_regex.h' and `probe.h'.
	(bkpt_probe_breakpoint_ops): New variable.
	(momentary_breakpoint_from_master): Set the `probe' value.
	(add_location_to_breakpoint): Likewise.
	(break_command_1): Using proper breakpoint_ops according to the
	argument passed by the user in the command line.
	(bkpt_probe_insert_location): New function.
	(bkpt_probe_remove_location): Likewise.
	(bkpt_probe_create_sals_from_address): Likewise.
	(bkpt_probe_decode_linespec): Likewise.
	(tracepoint_probe_create_sals_from_address): Likewise.
	(tracepoint_probe_decode_linespec): Likewise.
	(tracepoint_probe_breakpoint_ops): New variable.
	(trace_command): Using proper breakpoint_ops according to the
	argument passed by the user in the command line.
	(initialize_breakpoint_ops): Initializing breakpoint_ops for
	static probes on breakpoints and tracepoints.
	* breakpoint.h (struct bp_location) <probe>: New field.
	* cli-utils.c (skip_spaces_const): New function.
	(extract_arg): Likewise.
	* cli-utils.h (skip_spaces_const): Likewise.
	(extract_arg): Likewise.
	* coffread.c (coff_sym_fns): Add `sym_probe_fns' value.
	* configure.ac: Append `stap-probe.o' to be generated when ELF
	support is present.
	* configure: Regenerate.
	* dbxread.c (aout_sym_fns): Add `sym_probe_fns' value.
	* elfread.c: Include `probe.h' and `arch-utils.h'.
	(probe_key): New variable.
	(elf_get_probes): New function.
	(elf_get_probe_argument_count): Likewise.
	(elf_evaluate_probe_argument): Likewise.
	(elf_compile_to_ax): Likewise.
	(elf_symfile_relocate_probe): Likewise.
	(stap_probe_key_free): Likewise.
	(elf_probe_fns): New variable.
	(elf_sym_fns): Add `sym_probe_fns' value.
	(elf_sym_fns_lazy_psyms): Likewise.
	(elf_sym_fns_gdb_index): Likewise.
	(_initialize_elfread): Initialize objfile cache for static
	probes.
	* gdb_vecs.h (struct probe): New forward declaration.
	(probe_p): New VEC declaration.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.
	* gdbarch.sh (stap_integer_prefix): New variable.
	(stap_integer_suffix): Likewise.
	(stap_register_prefix): Likewise.
	(stap_register_suffix): Likewise.
	(stap_register_indirection_prefix): Likewise.
	(stap_register_indirection_suffix): Likewise.
	(stap_gdb_register_prefix): Likewise.
	(stap_gdb_register_suffix): Likewise.
	(stap_is_single_operand): New function.
	(stap_parse_special_token): Likewise.
	(struct stap_parse_info): Forward declaration.
	* i386-tdep.c: Including headers needed to perform the parsing
	of SystemTap probes' arguments.
	(i386_stap_is_single_operand): New function.
	(i386_stap_parse_special_token): Likewise.
	(i386_elf_init_abi): Initializing proper fields used by SystemTap
	probes' arguments parser.
	* i386-tdep.h (i386_stap_is_single_operand): New function.
	(i386_stap_parse_special_token): Likewise.
	* machoread.c (macho_sym_fns): Add `sym_probe_fns' value.
	* mipsread.c (ecoff_sym_fns): Likewise.
	* objfiles.c (objfile_relocate1): Support relocation for static
	probes.
	* parse.c (prefixify_expression): Remove static declaration.
	(initialize_expout): Likewise.
	(reallocate_expout): Likewise.
	* parser-defs.h (initialize_expout): Declare function.
	(reallocate_expout): Likewise.
	(prefixify_expression): Likewise.
	* ppc-linux-tdep.c: Including headers needed to perform the parsing
	of SystemTap probes' arguments.
	(ppc_stap_is_single_operand): New function.
	(ppc_stap_parse_special_token): Likewise.
	(ppc_linux_init_abi): Initializing proper fields used by SystemTap
	probes' arguments parser.
	* probe.c: New file, for generic statically defined probe support.
	* probe.h: Likewise.
	* s390-tdep.c: Including headers needed to perform the parsing of
	SystemTap probes' arguments.
	(s390_stap_is_single_operand): New function.
	(s390_gdbarch_init): Initializing proper fields used by SystemTap
	probes' arguments parser.
	* somread.c (som_sym_fns): Add `sym_probe_fns' value.
	* stap-probe.c: New file, for SystemTap probe support.
	* stap-probe.h: Likewise.
	* symfile.h: Include `gdb_vecs.h'.
	(struct sym_probe_fns): New struct.
	(struct sym_fns) <sym_probe_fns>: New field.
	* symtab.c (init_sal): Initialize `probe' field.
	* symtab.h (struct probe): Forward declaration.
	(struct symtab_and_line) <probe>: New field.
	* tracepoint.c (start_tracing): Adjust semaphore on breakpoints
	locations.
	(stop_tracing): Likewise.
	* xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 20:47:57 +00:00
Jan Kratochvil e4ab2fad14 gdb/
Code cleanup.
	* charset.c (find_charset_names): Remove variables ix and elt.
	Use free_char_ptr_vec.
	* elfread.c (build_id_to_debug_filename): New variables debugdir_vec,
	back_to and ix.  Use dirnames_to_char_ptr_vec.  Remove variable
	debugdir_end.  New variable debugdir_len.
	* gdb_vecs.h (free_char_ptr_vec, make_cleanup_free_char_ptr_vec)
	(dirnames_to_char_ptr_vec_append, dirnames_to_char_ptr_vec): New
	declarations.
	* progspace.c (clear_program_space_solib_cache): Remove variables ix
	and elt.  Use free_char_ptr_vec.
	* source.c (add_path): Remove variables argv, arg and argv_index.
	New variables dir_vec, back_to, ix and name.
	Use dirnames_to_char_ptr_vec_append.  Use freeargv instead of
	make_cleanup_freeargv.  Remove variable separator.  Simplify the code
	no longer expecting DIRNAME_SEPARATOR.
	(openp): Remove variable p, p1 and len.  New variables dir_vec,
	back_to, ix and dir.  Use dirnames_to_char_ptr_vec.  Simplify the code
	no longer expecting DIRNAME_SEPARATOR.
	* symfile.c (find_separate_debug_file): New variables debugdir_vec,
	back_to and ix.  Use dirnames_to_char_ptr_vec.  Remove variable
	debugdir_end.
	* utils.c (free_char_ptr_vec, do_free_char_ptr_vec)
	(make_cleanup_free_char_ptr_vec, dirnames_to_char_ptr_vec_append)
	(dirnames_to_char_ptr_vec): New functions.
2012-04-17 15:47:09 +00:00
Jan Kratochvil c70a6932bb gdb/
* arm-linux-tdep.c (arm_linux_copy_svc): Reset stale FRAME.
	* breakpoint.c (until_break_command): Likewise.
	* elfread.c (elf_gnu_ifunc_resolver_stop): Likewise.
	* infcall.c (call_function_by_hand): Likewise.
	* infcmd.c (finish_forward): Likewise.
	* infrun.c (insert_exception_resume_breakpoint): Likewise.
2012-02-29 14:52:44 +00:00
Doug Evans 28ee876ac0 * elfread.c (elf_symfile_segments): Fix warning text. 2012-02-21 06:44:13 +00:00
Doug Evans 2c02bd7290 * blockframe.c (find_pc_partial_function_gnu_ifunc): Change type of
"name" parameter to const char ** from char **.  All callers updated.
	(find_pc_partial_function): Ditto.
	(cache_pc_function_name): Change type to const char * from char *.
	* symtab.h ((find_pc_partial_function_gnu_ifunc): Update.
	(find_pc_partial_function): Update.
	* alpha-tdep.h (struct gdbarch_tdep, member pc_in_sigtramp): Change
	type of "name" parameter to const char * from char *.
	All uses updated.
	* arch-utils.c (generic_in_solib_return_trampoline): Change
	type of "name" parameter to const char * from char *.
	* arch-utils.h (generic_in_solib_return_trampoline): Update.
	* frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Change
	type of "name" parameter to const char * from char *.
	* gdbarch.sh (in_solib_return_trampoline): Ditto.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.
	* hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Update.
	* rs6000-tdep.c (rs6000_in_solib_return_trampoline): Update.
	* m32r-linux-tdep.c (m32r_linux_pc_in_sigtramp): Change
	type of "name" parameter to const char * from char *.
	* skip.c (skip_function_pc): Ditto.
	* sparc-sol2-tdep.c (sparc_sol2_pc_in_sigtramp): Ditto.
	* sparc-tdep.h (sparc_sol2_pc_in_sigtramp): Update.
	* sparc64fbsd-tdep.c (sparc64fbsd_pc_in_sigtramp): Ditto.
	* sparc64nbsd-tdep.c (sparc64nbsd_pc_in_sigtramp): Ditto.
	* sparc64obsd-tdep.c (sparc64obsd_pc_in_sigtramp): Ditto.
	* sparcnbsd-tdep.c (sparc32nbsd_pc_in_sigtramp): Ditto.
	* sparcobsd-tdep.c (sparc32obsd_pc_in_sigtramp): Ditto.
	* nbsd-tdep.c (nbsd_pc_in_sigtramp): Similary for "func_name".
	* nbsd-tdep.h (nbsd_pc_in_sigtramp): Update.
2012-02-02 20:19:17 +00:00
Joel Brobecker 0b30217134 Copyright year update in most files of the GDB Project.
gdb/ChangeLog:

        Copyright year update in most files of the GDB Project.
2012-01-04 08:17:56 +00:00
Tom Tromey 0af1e9a54b * elfread.c (elf_symtab_read): Put the filename in the filename
bcache.
2011-12-21 21:30:31 +00:00
Joel Brobecker 828cfa8d0b try ignoring bad PLT entries in ELF symbol tables
Comment says it all:

         /* On ia64-hpux, we have discovered that the system linker
            adds undefined symbols with nonzero addresses that cannot
            be right (their address points inside the code of another
            function in the .text section).  This creates problems
            when trying to determine which symbol corresponds to
            a given address.

            We try to detect those buggy symbols by checking which
            section we think they correspond to.  Normally, PLT symbols
            are stored inside their own section, and the typical name
            for that section is ".plt".  So, if there is a ".plt"
            section, and yet the section name of our symbol does not
            start with ".plt", we ignore that symbol.  */

gdb/ChangeLog:

        * elfread.c (elf_symtab_read): Ignore undefined symbols with
        nonzero addresses if they do not correspond to a .plt section
        when one is available in the objfile.
2011-12-19 04:36:29 +00:00
Tom Tromey f8eba3c616 the "ambiguous linespec" series
gdb
2011-12-06  Joel Brobecker  <brobecker@acacore.com>

        * language.h (struct language_defn): Add new component
        la_symbol_name_compare.
        * symfile.h (struct quick_symbol_functions): Update the profile
        of parameter "name_matcher" for the expand_symtabs_matching
        method.  Update the documentation accordingly.
        * ada-lang.h (ada_name_for_lookup): Add declaration.
        * ada-lang.c (ada_name_for_lookup): New function, extracted out
        from ada_iterate_over_symbols.
        (ada_iterate_over_symbols): Do not encode symbol name anymore.
        (ada_expand_partial_symbol_name): Adjust profile.
        (ada_language_defn): Add value for la_symbol_name_compare field.
        * linespec.c: #include "ada-lang.h".
        (iterate_name_matcher): Add language parameter. Replace call
        to strcmp_iw by call to language->la_symbol_name_compare.
        (decode_variable): Encode COPY if current language is Ada.
        * dwarf2read.c (dw2_expand_symtabs_matching): Adjust profile
        of name_matcher parameter.  Adjust call to name_matcher.
        * psymtab.c (expand_symtabs_matching_via_partial): Likewise.
        (expand_partial_symbol_names): Update profile of parameter "fun".
        * psymtab.h (expand_partial_symbol_names): Update profile of
        parameter "fun".
        * symtab.c (demangle_for_lookup): Update function documentation.
        (search_symbols_name_matches): Add language parameter.
        (expand_partial_symbol_name): Likewise.
        * c-lang.c (c_language_defn, cplus_language_defn)
        (asm_language_defn, minimal_language_defn): Add value for
        la_symbol_name_compare field.
        * d-lang.c (d_language_defn): Likewise.
        * f-lang.c (f_language_defn): Ditto.
        * jv-lang.c (java_language_defn): Ditto.
        * m2-lang.c (m2_language_defn): Ditto.
        * objc-lang.c (objc_language_defn): Ditto.
        * opencl-lang.c (opencl_language_defn): Ditto.
        * p-lang.c (pascal_language_defn): Ditto.
        * language.c (unknown_language_defn, auto_language_defn)
        (local_language_defn): Ditto.

2011-12-06  Tom Tromey  <tromey@redhat.com>

	* linespec.c (iterate_over_all_matching_symtabs): Use
	LA_ITERATE_OVER_SYMBOLS.
	(lookup_prefix_sym, add_matching_symbols_to_info): Likewise.
	(find_function_symbols, decode_variable): Remove Ada special
	case.
	* language.h (struct language_defn) <la_iterate_over_symbols>: New
	field.
	(LA_ITERATE_OVER_SYMBOLS): New macro.
	* language.c (unknown_language_defn, auto_language_defn)
	(local_language_defn): Update.
	* c-lang.c (c_language_defn, cplus_language_defn)
	(asm_language_defn, minimal_language_defn): Update.
	* d-lang.c (d_language_defn): Update.
	* f-lang.c (f_language_defn): Update.
	* jv-lang.c (java_language_defn): Update.
	* m2-lang.c (m2_language_defn): Update.
	* objc-lang.c (objc_language_defn): Update.
	* opencl-lang.c (opencl_language_defn): Update.
	* p-lang.c (pascal_language_defn): Update.
	* ada-lang.c (ada_iterate_over_symbols): New function.
	(ada_language_defn): Update.

2011-12-06  Tom Tromey  <tromey@redhat.com>
	    Joel Brobecker  <brobecker@acacore.com>

	PR breakpoints/13105, PR objc/8341, PR objc/8343, PR objc/8366,
	PR objc/8535, PR breakpoints/11657, PR breakpoints/11970,
	PR breakpoints/12023, PR breakpoints/12334, PR breakpoints/12856,
	PR shlibs/8929, PR shlibs/7393:
	* python/py-type.c (compare_maybe_null_strings): Rename from
	compare_strings.
	(check_types_equal): Update.
	* utils.c (compare_strings): New function.
	* tui/tui-winsource.c (tui_update_breakpoint_info): Update for
	location changes.
	* tracepoint.c (scope_info): Update.
	(trace_find_line_command): Use DECODE_LINE_FUNFIRSTLINE.
	* symtab.h (iterate_over_minimal_symbols)
	(iterate_over_some_symtabs, iterate_over_symtabs)
	(find_pcs_for_symtab_line, iterate_over_symbols)
	(demangle_for_lookup): Declare.
	(expand_line_sal): Remove.
	* symtab.c (iterate_over_some_symtabs, iterate_over_symtabs)
	(lookup_symtab_callback): New functions.
	(lookup_symtab): Rewrite.
	(demangle_for_lookup): New function, extract from
	lookup_symbol_in_language.
	(lookup_symbol_in_language): Use it.
	(iterate_over_symbols): New function.
	(find_line_symtab): Update.
	(find_pcs_for_symtab_line): New functions.
	(find_line_common): Add 'start' argument.
	(decode_line_spec): Update.  Change argument to 'flags', change
	interpretation.
	(append_expanded_sal): Remove.
	(append_exact_match_to_sals): Remove.
	(expand_line_sal): Remove.
	* symfile.h (struct quick_symbol_functions) <lookup_symtab>:
	Remove.
	<map_symtabs_matching_filename>: New field.
	* stack.c (func_command): Only look in the current program space.
	Use DECODE_LINE_FUNFIRSTLINE.
	* source.c (line_info): Set pspace on sal.  Check program space in
	the loop.  Use DECODE_LINE_LIST_MODE.
	(select_source_symtab): Use DECODE_LINE_FUNFIRSTLINE.
	* solib-target.c: Remove DEF_VEC_I(CORE_ADDR).
	* python/python.c (gdbpy_decode_line): Update.
	* psymtab.c (partial_map_expand_apply): New function.
	(partial_map_symtabs_matching_filename): Rename from
	lookup_partial_symbol.  Update arguments.
	(lookup_symtab_via_partial_symtab): Remove.
	(psym_functions): Update.
	* objc-lang.h (parse_selector, parse_method): Don't declare.
	(find_imps): Update.
	* objc-lang.c (parse_selector, parse_method): Now static.
	(find_methods): Change arguments.  Fill in a vector of symbol
	names.
	(uniquify_strings): New function.
	(find_imps): Change arguments.
	* minsyms.c (iterate_over_minimal_symbols): New function.
	* linespec.h (enum decode_line_flags): New.
	(struct linespec_sals): New.
	(struct linespec_result) <canonical>: Remove.
	<pre_expanded, addr_string, sals>: New fields.
	(destroy_linespec_result, make_cleanup_destroy_linespec_result)
	(decode_line_full): Declare.
	(decode_line_1): Update.
	* linespec.c (struct address_entry, struct linespec_state, struct
	collect_info): New types.
	(add_sal_to_sals_basic, add_sal_to_sals, hash_address_entry)
	(eq_address_entry, maybe_add_address): New functions.
	(total_number_of_methods): Remove.
	(iterate_name_matcher, iterate_over_all_matching_symtabs): New
	functions.
	(find_methods): Change arguments.  Don't canonicalize input.
	Simplify logic.
	(add_matching_methods, add_constructors)
	(build_canonical_line_spec): Remove.
	(filter_results, convert_results_to_lsals): New functions.
	(decode_line_2): Change arguments.  Rewrite for new data
	structures.
	(decode_line_internal): Rename from decode_line_1.  Change
	arguments.  Add cleanups.  Update for new data structures.
	(linespec_state_constructor, linespec_state_destructor)
	(decode_line_full, decode_line_1): New functions.
	(decode_indirect): Change arguments.  Update.
	(locate_first_half): Use skip_spaces.
	(decode_objc): Change arguments.  Update for new data structures.
	Simplify logic.
	(decode_compound): Change arguments.  Add cleanups.  Remove
	fallback code, replace with error.
	(struct decode_compound_collector): New type.
	(collect_one_symbol): New function.
	(lookup_prefix_sym): Change arguments.  Update.
	(compare_symbol_name, add_all_symbol_names_from_pspace)
	(find_superclass_methods ): New functions.
	(find_method): Rewrite.
	(struct symtab_collector): New type.
	(add_symtabs_to_list, collect_symtabs_from_filename): New
	functions.
	(symtabs_from_filename): Change API.  Rename from
	symtab_from_filename.
	(collect_function_symbols): New function.
	(find_function_symbols): Change API.  Rename from
	find_function_symbol.  Rewrite.
	(decode_all_digits): Change arguments.  Rewrite.
	(decode_dollar): Change arguments.  Use decode_variable.
	(decode_label): Change arguments.  Rewrite.
	(collect_symbols): New function.
	(minsym_found): Change arguments.  Rewrite.
	(check_minsym, search_minsyms_for_name)
	(add_matching_symbols_to_info): New function.
	(decode_variable): Change arguments.  Iterate over all symbols.
	(symbol_found): Remove.
	(symbol_to_sal): New function.
	(init_linespec_result, destroy_linespec_result)
	(cleanup_linespec_result, make_cleanup_destroy_linespec_result):
	New functions.
	(decode_digits_list_mode, decode_digits_ordinary): New functions.
	* dwarf2read.c (dw2_map_expand_apply): New function.
	(dw2_map_symtabs_matching_filename): Rename from
	dw2_lookup_symtab.  Change arguments.
	(dwarf2_gdb_index_functions): Update.
	* dwarf2loc.c: Remove DEF_VEC_I(CORE_ADDR).
	* defs.h (compare_strings): Declare.
	* cli/cli-cmds.c (compare_strings): Move to utils.c.
	(edit_command, list_command): Use DECODE_LINE_LIST_MODE.  Call
	filter_sals.
	(compare_symtabs, filter_sals): New functions.
	* breakpoint.h (struct bp_location) <line_number, source_file>:
	New fields.
	(struct breakpoint) <line_number, source_file>: Remove.
	<filter>: New field.
	* breakpoint.c (print_breakpoint_location, init_raw_breakpoint)
	(momentary_breakpoint_from_master, add_location_to_breakpoint):
	Update for changes to locations.
	(init_breakpoint_sal): Add 'filter' argument.  Set 'filter' on
	breakpoint.
	(create_breakpoint_sal): Add 'filter' argument.
	(remove_sal, expand_line_sal_maybe): Remove.
	(create_breakpoints_sal): Remove 'sals' argument.  Handle
	pre-expanded sals and the filter.
	(parse_breakpoint_sals): Use decode_line_full.
	(check_fast_tracepoint_sals): Use get_sal_arch.
	(create_breakpoint): Create a linespec_sals.  Update.
	(break_range_command): Use decode_line_full.  Update.
	(until_break_command): Update.
	(clear_command): Update match conditions for linespec.c changes.
	Use DECODE_LINE_LIST_MODE.
	(say_where): Update for changes to locations.
	(bp_location_dtor): Free 'source_file'.
	(base_breakpoint_dtor): Free 'filter'.  Don't free 'source_file'.
	(update_static_tracepoint): Update for changes to locations.
	(update_breakpoint_locations): Disable ranged breakpoint if too
	many locations match.  Update.
	(addr_string_to_sals): Use decode_line_full.  Resolve all sal
	PCs.
	(breakpoint_re_set_default): Don't call expand_line_sal_maybe.
	(decode_line_spec_1): Update.  Change argument name to 'flags',
	change interpretation.
	* block.h (block_containing_function): Declare.
	* block.c (block_containing_function): New function.
	* skip.c (skip_function_command): Update.
	(skip_re_set): Update.
	* infcmd.c (jump_command): Use DECODE_LINE_FUNFIRSTLINE.
	* mi/mi-main.c (mi_cmd_trace_find): Use DECODE_LINE_FUNFIRSTLINE.
	* NEWS: Add entry.

2011-12-06  Tom Tromey  <tromey@redhat.com>

	* elfread.c (elf_gnu_ifunc_resolver_return_stop): Allow
	breakpoint's pspace to be NULL.
	* breakpoint.h (struct breakpoint) <pspace>: Update comment.
	* breakpoint.c (init_raw_breakpoint): Conditionally set
	breakpoint's pspace.
	(init_breakpoint_sal): Don't set breakpoint's pspace.
	(prepare_re_set_context): Conditionally switch program space.
	(addr_string_to_sals): Check executing_startup on location's
	program space.

2011-12-06  Tom Tromey  <tromey@redhat.com>

	* breakpoint.h (enum enable_state) <bp_startup_disabled>: Remove.
	* breakpoint.c (should_be_inserted): Explicitly check if program
	space is executing startup.
	(describe_other_breakpoints): Update.
	(disable_breakpoints_before_startup): Change executing_startup
	earlier.  Remove loop.
	(enable_breakpoints_after_startup): Likewise.
	(init_breakpoint_sal): Don't use bp_startup_disabled.
	(create_breakpoint): Don't use bp_startup_disabled.
	(update_global_location_list): Use should_be_inserted.
	(bkpt_re_set): Update.
gdb/testsuite
2011-12-06  Joel Brobecker  <brobecker@acacore.com>

        * gdb.ada/fullname_bp.exp: Add tests for other valid linespecs
        involving a fully qualified function name.

2011-12-06  Tom Tromey  <tromey@redhat.com>

	* gdb.ada/homonym.exp: Add three breakpoint tests.

2011-12-06  Tom Tromey  <tromey@redhat.com>

	* gdb.base/solib-weak.exp (do_test): Remove kfail.
	* gdb.trace/tracecmd.exp: Disable pending breakpoints earlier.
	* gdb.objc/objcdecode.exp: Update for output changes.
	* gdb.linespec/linespec.exp: New file.
	* gdb.linespec/lspec.cc: New file.
	* gdb.linespec/lspec.h: New file.
	* gdb.linespec/body.h: New file.
	* gdb.linespec/base/two/thefile.cc: New file.
	* gdb.linespec/base/one/thefile.cc: New file.
	* gdb.linespec/Makefile.in: New file.
	* gdb.cp/templates.exp (test_template_breakpoints): Update for
	output changes.
	* gdb.cp/re-set-overloaded.exp: Remove kfail.
	* gdb.cp/ovldbreak.exp: Update for output changes.  "all" test now
	makes one breakpoint.
	* gdb.cp/method2.exp (test_break): Update for output changes.
	* gdb.cp/mb-templates.exp: Update for output changes.
	* gdb.cp/mb-inline.exp: Update for output changes.
	* gdb.cp/mb-ctor.exp: Update for output changes.
	* gdb.cp/ovsrch.exp: Use fully-qualified names.
	* gdb.base/solib-symbol.exp: Run to main later.  Breakpoint now
	has multiple matches.
	* gdb.base/sepdebug.exp: Disable pending breakpoints.  Update for
	error message change.
	* gdb.base/list.exp (test_list_filename_and_number): Update for
	error message change.
	* gdb.base/break.exp: Disable pending breakpoints.  Update for
	output changes.
	* configure.ac: Add gdb.linespec.
	* configure: Rebuild.
	* Makefile.in (ALL_SUBDIRS): Add gdb.linespec.
gdb/doc
2011-12-06  Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (Set Breaks): Update for new behavior.
2011-12-06 18:54:43 +00:00
Pedro Alves 7f86f0587f 2011-08-09 Pedro Alves <pedro@codesourcery.com>
gdb/
	* elfread.c (elf_symtab_read): Ditto.
	* maint.c (maintenance_command): Ditto.
	* somread.c (som_symtab_read): Ditto.
	* solib.c (solib_find, solib_map_sections, update_solib_list)
	(solib_add, info_sharedlibrary_command, solib_name_from_address)
	(solib_create_inferior_hook, in_solib_dynsym_resolve_code)
	(sharedlibrary_command, no_shared_libraries): Rework comments.
	* solib-irix.c (locate_base, disable_break, enable_break)
	(irix_solib_create_inferior_hook, irix_solib_create_inferior_hook)
	(irix_current_sos, irix_open_symbol_file_object)
	(irix_special_symbol_handling): Ditto.
	* solib-sunos.c (locate_base, first_link_map_member)
	(sunos_current_sos, disable_break, enable_break)
	(sunos_special_symbol_handling, sunos_solib_create_inferior_hook):
	Ditto.
	* solib-svr4.c (bfd_lookup_symbol, elf_locate_base, locate_base)
	(open_symbol_file_object, svr4_current_sos, enable_break)
	(svr4_special_symbol_handling, svr4_solib_create_inferior_hook):
	Ditto.
	* solib-frv.c (bfd_lookup_symbol, open_symbol_file_object)
	(frv_current_sos, enable_break, frv_special_symbol_handling)
	(frv_solib_create_inferior_hook): Ditto.
	* solist.h (struct target_so_ops): Extend the comments of the
	special_symbol_handling, current_sos and open_symbol_file_object
	methods.
2011-08-09 12:51:47 +00:00