Commit Graph

214 Commits

Author SHA1 Message Date
Tom Tromey 76727919ce Convert observers to C++
This converts observers from using a special source-generating script
to be plain C++.  This version of the patch takes advantage of C++11
by using std::function and variadic templates; incorporates Pedro's
patches; and renames the header file to "observable.h" (this change
eliminates the need for a clean rebuild).

Note that Pedro's patches used a template lambda in tui-hooks.c, but
this failed to compile on some buildbot instances (presumably due to
differing C++ versions); I replaced this with an ordinary template
function.

Regression tested on the buildbot.

gdb/ChangeLog
2018-03-19  Pedro Alves  <palves@redhat.com>
	    Tom Tromey  <tom@tromey.com>

	* unittests/observable-selftests.c: New file.
	* common/observable.h: New file.
	* observable.h: New file.
	* ada-lang.c, ada-tasks.c, agent.c, aix-thread.c, annotate.c,
	arm-tdep.c, auto-load.c, auxv.c, break-catch-syscall.c,
	breakpoint.c, bsd-uthread.c, cli/cli-interp.c, cli/cli-setshow.c,
	corefile.c, dummy-frame.c, event-loop.c, event-top.c, exec.c,
	extension.c, frame.c, gdbarch.c, guile/scm-breakpoint.c,
	infcall.c, infcmd.c, inferior.c, inflow.c, infrun.c, jit.c,
	linux-tdep.c, linux-thread-db.c, m68klinux-tdep.c,
	mi/mi-cmd-break.c, mi/mi-interp.c, mi/mi-main.c, objfiles.c,
	ppc-linux-nat.c, ppc-linux-tdep.c, printcmd.c, procfs.c,
	python/py-breakpoint.c, python/py-finishbreakpoint.c,
	python/py-inferior.c, python/py-unwind.c, ravenscar-thread.c,
	record-btrace.c, record-full.c, record.c, regcache.c, remote.c,
	riscv-tdep.c, sol-thread.c, solib-aix.c, solib-spu.c, solib.c,
	spu-multiarch.c, spu-tdep.c, stack.c, symfile-mem.c, symfile.c,
	symtab.c, thread.c, top.c, tracepoint.c, tui/tui-hooks.c,
	tui/tui-interp.c, valops.c: Update all users.
	* tui/tui-hooks.c (tui_bp_created_observer)
	(tui_bp_deleted_observer, tui_bp_modified_observer)
	(tui_inferior_exit_observer, tui_before_prompt_observer)
	(tui_normal_stop_observer, tui_register_changed_observer):
	Remove.
	(tui_observers_token): New global.
	(attach_or_detach, tui_attach_detach_observers): New functions.
	(tui_install_hooks, tui_remove_hooks): Use
	tui_attach_detach_observers.
	* record-btrace.c (record_btrace_thread_observer): Remove.
	(record_btrace_thread_observer_token): New global.
	* observer.sh: Remove.
	* observer.c: Rename to observable.c.
	* observable.c (namespace gdb_observers): Define new objects.
	(observer_debug): Move into gdb_observers namespace.
	(struct observer, struct observer_list, xalloc_observer_list_node)
	(xfree_observer_list_node, generic_observer_attach)
	(generic_observer_detach, generic_observer_notify): Remove.
	(_initialize_observer): Update.
	Don't include observer.inc.
	* Makefile.in (generated_files): Remove observer.h, observer.inc.
	(clean mostlyclean): Likewise.
	(observer.h, observer.inc): Remove targets.
	(SUBDIR_UNITTESTS_SRCS): Add observable-selftests.c.
	(COMMON_SFILES): Use observable.c, not observer.c.
	* .gitignore: Remove observer.h.

gdb/doc/ChangeLog
2018-03-19  Tom Tromey  <tom@tromey.com>

	* observer.texi: Remove.

gdb/testsuite/ChangeLog
2018-03-19  Tom Tromey  <tom@tromey.com>

	* gdb.gdb/observer.exp: Remove.
2018-03-19 09:37:49 -06:00
Tom Tromey fdf07f3aeb Change enable_thread_stack_temporaries to an RAII class
This started as a patch to change enable_thread_stack_temporaries to
be an RAII class, but then I noticed that this code used a VEC, so I
went ahead and did a bit more C++-ification, changing
stack_temporaries_enabled to a bool and changing stack_temporaries to
a std::vector.

Regression tested by the buildbot.

gdb/ChangeLog
2018-03-08  Tom Tromey  <tom@tromey.com>

	* infcall.c (struct call_return_meta_info)
	<stack_temporaries_enabled>: Remove.
	(get_call_return_value, call_function_by_hand_dummy): Update.
	* thread.c (disable_thread_stack_temporaries): Remove.
	(enable_thread_stack_temporaries): Remove.
	(thread_stack_temporaries_enabled_p): Return bool.
	(push_thread_stack_temporary, value_in_thread_stack_temporaries)
	(get_last_thread_stack_temporary): Update.
	* eval.c (evaluate_subexp): Update.
	* gdbthread.h (class enable_thread_stack_temporaries): Now a
	class, not a function.
	(value_ptr, value_vec): Remove typedefs.
	(class thread_info) <stack_temporaries_enabled>: Now bool.
	<stack_temporaries>: Now a std::vector.
	(thread_stack_temporaries_enabled_p)
	(value_in_thread_stack_temporaries): Return bool.
2018-03-08 21:57:14 -07:00
Tom Tromey 6ccb583f75 Remove a cleanup from call_function_by_hand_dummy
This removes a cleanup from call_function_by_hand_dummy, replacing
manual allocation with std::vector.

Regression tested by the buildbot.

gdb/ChangeLog
2018-02-21  Tom Tromey  <tom@tromey.com>

	* infcall.c (call_function_by_hand_dummy): Use std::vector.
2018-02-21 08:54:49 -07:00
Joel Brobecker e2882c8578 Update copyright year range in all GDB files
gdb/ChangeLog:

        Update copyright year range in all GDB files
2018-01-02 07:38:06 +04: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
Tom Tromey 395423c418 Remove cleanup from call_function_by_hand_dummy
This changes call_function_by_hand_dummy to use std::string, removing
a cleanup.

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

	* infcall.c (call_function_by_hand_dummy): Use std::string.
2017-10-19 15:58:12 -06:00
Tom Tromey 223ffa714c Remove make_cleanup_restore_target_terminal
This removes make_cleanup_restore_target_terminal and generally
C++-ifies target terminal handling.  It changes all target_terminal_*
functions to be static members of a new target_terminal class and
changes the cleanup to be a scoped_* class.
make_cleanup_override_quit_handler is also removed in favor of simply
using scoped_restore.

Note that there are some files in this patch that I could not compile.
Considering that some of the rewrites were automated, and that none of
these files involed cleanups, I feel that this is relatively safe.

Regression tested by the buildbot.

gdb/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

	* windows-nat.c (get_windows_debug_event, windows_wait)
	(do_initial_windows_stuff, windows_attach): Update.
	* utils.c (vwarning, internal_vproblem): Update.
	(ui_unregister_input_event_handler_cleanup)
	(prepare_to_handle_input): Remove.
	(class scoped_input_handler): New.
	(defaulted_query, prompt_for_continue): Update.
	* tui/tui-hooks.c (tui_refresh_frame_and_register_information):
	Update.
	* top.c (undo_terminal_modifications_before_exit): Update.
	* target/target.h (target_terminal_init, target_terminal_inferior)
	(target_terminal_ours): Don't declare.
	(class target_terminal): New.
	* target.h (target_terminal_is_inferior, target_terminal_is_ours)
	(target_terminal_ours_for_output)
	(make_cleanup_restore_target_terminal): Don't declare.
	(target_terminal_info): Remove.
	* target.c (enum terminal_state, terminal_state): Remove.
	(target_terminal::terminal_state): Define.
	(target_terminal::init): Rename from target_terminal_init.
	(target_terminal::inferior): Rename from
	target_terminal_inferior.
	(target_terminal::ours): Rename from target_terminal_ours.
	(target_terminal::ours_for_output): Rename from
	target_terminal_ours_for_output.
	(target_terminal::info): New method.
	(cleanup_restore_target_terminal)
	(make_cleanup_restore_target_terminal): Remove.
	* solib.c (handle_solib_event): Update.
	* remote.c (remote_serial_quit_handler): Update.
	(remote_terminal_inferior, remote_wait_as): Update.
	* record-full.c (record_full_wait_1): Update.
	* nto-procfs.c (procfs_create_inferior): Update.
	* nat/fork-inferior.c (startup_inferior): Update.
	* mi/mi-interp.c (mi_new_thread, mi_thread_exit)
	(mi_record_changed, mi_inferior_added, mi_inferior_appeared)
	(mi_inferior_exit, mi_inferior_removed, mi_traceframe_changed)
	(mi_tsv_created, mi_tsv_deleted, mi_tsv_modified)
	(mi_breakpoint_created, mi_breakpoint_deleted)
	(mi_breakpoint_modified, mi_on_resume, mi_solib_loaded)
	(mi_solib_unloaded, mi_command_param_changed, mi_memory_changed)
	(mi_user_selected_context_changed, report_initial_inferior):
	Update.
	* linux-nat.c (linux_nat_attach, linux_nat_terminal_ours)
	(linux_nat_terminal_inferior): Update.
	* infrun.c (follow_fork_inferior)
	(handle_vfork_child_exec_or_exit, do_target_resume)
	(check_curr_ui_sync_execution_done, handle_inferior_event_1)
	(handle_signal_stop, maybe_remove_breakpoints, normal_stop):
	Update.
	* inflow.c (child_terminal_init, info_terminal_command): Update.
	* infcmd.c (post_create_inferior, continue_1, prepare_one_step)
	(attach_command): Update.
	* infcall.c (call_thread_fsm_should_stop): Update.
	* gnu-nat.c (gnu_attach): Update.
	* extension.c (struct active_ext_lang_state)
	(restore_active_ext_lang): Update.
	* exceptions.c (print_flush): Update.
	* event-top.c (async_enable_stdin, default_quit_handler): Update.
	(struct quit_handler_cleanup_data, restore_quit_handler)
	(restore_quit_handler_dtor, make_cleanup_override_quit_handler):
	Remove.
	* cp-support.c (gdb_demangle): Update.
	* breakpoint.c (update_inserted_breakpoint_locations)
	(insert_breakpoint_locations, handle_jit_event)
	(disable_breakpoints_in_unloaded_shlib): Update.
	* annotate.c (annotate_breakpoints_invalid)
	(annotate_frames_invalid): Update.

gdb/gdbserver/ChangeLog
2017-09-20  Tom Tromey  <tom@tromey.com>

	* target.c (target_terminal::terminal_state): Define.
	(target_terminal::init): Rename from target_terminal_init.
	(target_terminal::inferior): Rename from
	target_terminal_inferior.
	(target_terminal::ours): Rename from target_terminal_ours.
	(target_terminal::ours_for_output, target_terminal::info): New.
2017-09-20 16:09:50 -06: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
Artemiy Volkov aa0061181a Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.

gdb/ChangeLog

	PR gdb/14441
	* aarch64-tdep.c (aarch64_type_align)
	(aarch64_extract_return_value, aarch64_store_return_value): Change
	lvalue reference type checks to general reference type checks.
	* amd64-tdep.c (amd64_classify): Likewise.
	* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
	Likewise.
	* arm-tdep.c (arm_type_align, arm_extract_return_value)
	(arm_store_return_value): Likewise.
	* ax-gdb.c (gen_fetch, gen_cast): Likewise.
	* c-typeprint.c (c_print_type): Likewise.
	* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
	(cplus_number_of_children, cplus_describe_child): Likewise.
	* compile/compile-c-symbols.c (generate_vla_size): Likewise.
	* completer.c (expression_completer): Likewise.
	* cp-support.c (make_symbol_overload_list_adl_namespace):
	Likewise.
	* darwin-nat-info.c (info_mach_region_command): Likewise.
	* dwarf2loc.c (entry_data_value_coerce_ref)
	(value_of_dwarf_reg_entry): Likewise.
	* eval.c (ptrmath_type_p, evaluate_subexp_standard)
	(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
	Likewise.
	* findvar.c (extract_typed_address, store_typed_address):
	Likewise.
	* gdbtypes.c (rank_one_type): Likewise.
	* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
	* infcall.c (value_arg_coerce): Likewise.
	* language.c (pointer_type): Likewise.
	* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
	Likewise.
	* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
	* mn10300-tdep.c (mn10300_type_align): Likewise.
	* msp430-tdep.c (msp430_push_dummy_call): Likewise.
	* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
	(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
	Likewise.
	* printcmd.c (print_formatted, x_command): Likewise.
	* python/py-type.c (typy_get_composite, typy_template_argument):
	Likewise.
	* python/py-value.c (valpy_referenced_value)
	(valpy_get_dynamic_type, value_has_field): Likewise.
	* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
	* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
	* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
	* spu-tdep.c (spu_scalar_value_p): Likewise.
	* symtab.c (lookup_symbol_aux): Likewise.
	* typeprint.c (whatis_exp, print_type_scalar): Likewise.
	* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
	Likewise.
	* valops.c (value_cast_pointers, value_cast)
	(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
	(value_struct_elt, value_struct_elt_bitpos)
	(value_find_oload_method_list, find_overload_match)
	(value_rtti_indirect_type): Likewise.
	* valprint.c (val_print_scalar_type_p, generic_val_print):
	Likewise.
	* value.c (value_actual_type, value_as_address, unpack_long)
	(pack_long, pack_unsigned_long, coerce_ref_if_computed)
	(coerce_ref): Likewise.
	* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 13:47:54 -07:00
Artemiy Volkov a65cfae5f8 Add ability to return rvalue reference values from value_ref
Parameterize value_ref() by the kind of reference type the value of which
is requested. Change all callers to use the new API.

gdb/ChangeLog

	PR gdb/14441
	* ada-lang.c (ada_evaluate_subexp): Adhere to the new
	value_ref() interface.
	* c-valprint.c (c_value_print): Likewise.
	* infcall.c (value_arg_coerce): Likewise.
	* python/py-value.c (valpy_reference_value): Likewise.
	* valops.c (value_cast, value_reinterpret_cast)
	(value_dynamic_cast, typecmp): Likewise.
	(value_ref): Parameterize by kind of return value reference type.
	* value.h (value_ref): Add new parameter "refcode".
2017-03-20 13:47:41 -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
Tom Tromey 4b6749b9a4 Use scoped_restore for current_ui
This changes most uses of make_cleanup_restore_current_ui to use
scoped_restore.  The use in switch_thru_all_uis_init still remains;
that is dealt with in a later patch by replacing this iterator with a
real class.

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

	* top.c (new_ui_command, wait_sync_command_done)
	(gdb_readline_wrapper): Use scoped_restore.
	* infrun.c (fetch_inferior_event): Use scoped_restore.
	* infcall.c (call_thread_fsm_should_stop): Use scoped_restore.
2016-10-21 14:17:32 -06:00
Pedro Alves 6d61dee599 Fix PR 20345 - call_function_by_hand_dummy: Assertion `tp->thread_fsm == &sm->thread_fsm' failed
If you run an infcall from the command line, and immediately after run
some other command, GDB incorrectly processes the other command before
the infcall finishes.

The problem is that the fix for PR gdb/20418 (Problems with
synchronous commands and new-ui, git 3eb7562a98) moved the
add_file_handler/delete_file_handler calls out of
target_terminal_$foo, and missed adjusting the infcall code.

gdb/ChangeLog:
2016-09-28  Pedro Alves  <palves@redhat.com>

	* infcall.c (run_inferior_call): Remove input from the event
	loop while running the infcall.

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

	* gdb.base/infcall-input.c: New file.
	* gdb.base/infcall-input.exp: New file.
2016-09-28 17:44:57 -04:00
Pedro Alves a025b477cc Introduce make_cleanup_restore_current_ui
Just a tidy, no functional changes.

gdb/ChangeLog:
2016-09-06  Pedro Alves  <palves@redhat.com>

	* event-top.c (restore_ui_cleanup): Now static.
	(make_cleanup_restore_current_ui): New function.
	(switch_thru_all_uis_init): Use it.
	* infcall.c (call_thread_fsm_should_stop): Use it.
	* infrun.c (fetch_inferior_event): Use it.
	* top.c (new_ui_command): Use it.
	* top.h (restore_ui_cleanup): Delete declaration.
	(make_cleanup_restore_current_ui): New declaration.
2016-09-06 23:17:14 +01:00
Ulrich Weigand a9ff5f12cf Remove obsolete TYPE_FLAG_... values
Now that init_type no longer takes a FLAGS argument, there is no user of
the TYPE_FLAGS_... enum values left.  This commit removes them (and all
references to them in comments as well).

This is mostly a no-op, except for a change to the Python type printer,
which attempted to use them before.  (As best as I can tell, this wasn't
really needed anyway, since it was only used to pretty-print type
*instance* flags, which only use the instance flags.)

gdb/ChangeLog:

	* gdbtypes.h (enum type_flag_value): Remove.
	Remove references to TYPE_FLAG_... in comments throughout.
	* gdbtypes.c (recursive_dump_type): Do not print TYPE_FLAG_...
	flags, print the corresponding TYPE_... access macro names.
	Remove references to TYPE_FLAG_... in comments throughout.
	* infcall.c: Remove references to TYPE_FLAG_... in comments.
	* valprint.c: Likewise.
	* gdb-gdb.py (class TypeFlag): No longer consider TYPE_FLAG_...
	values, only TYPE_INSTANCE_FLAG_... values.
	(class TypeFlagsPrinter): Likewise.

gdb/testsuite/ChangeLog:

	* gdb.cp/hang.exp: Remove reference to TYPE_FLAG_STUB in comment.

Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2016-09-06 17:29:15 +02:00
Pedro Alves 8980e177bb Push thread->control.command_interp to the struct thread_fsm
I noticed that if we step into an inline function, step_1 never
reaches proceed, and thus nevers sets the thread's
tp->control.command_interp.  Because of that,
should_print_stop_to_console fails to determine that is should print
stop output to the console.

The fix is to set the thread's command_interp earlier.  However, I
realized that we can move that field to the thread_fsm, given that its
lifetime is exactly the same as thread_fsm.  So the patch plumbs all
fsms constructors to take the command interp and store it in the
thread_fsm.

We can see the fix in action, with e.g., the gdb.opt/inline-cmds.exp
test, and issuing a step when stopped at line 67:

 &"s\n"
 ^running
 *running,thread-id="all"
 (gdb)
 ~"67\t  result = func2 ();\n"
 *stopped,reason="end-stepping-range",frame={addr="0x00000000004004d0",func="main",args=[],file="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.opt/inline-cmds.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.opt/inline-cmds.c",line="67"},thread-id="1",stopped-threads="all",core="0"
 (gdb)
 s
 &"s\n"
 ^running
 *running,thread-id="all"
 (gdb)
+ ~"func2 () at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.opt/inline-cmds.c:67\n"
+ ~"67\t  result = func2 ();\n"
 *stopped,reason="end-stepping-range",frame={addr="0x00000000004004d0",func="func2",args=[],file="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.opt/inline-cmds.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.opt/inline-cmds.c",line="67"},thread-id="1",stopped-threads="all",core="0"
 (gdb)

(The inline-cmds.exp command is adjusted to exercise this.)

(Due to the follow_fork change, this also fixes "next N" across a fork
with "set follow-fork child" with "set detach-on-fork on".  Commands
that rely on internal breakpoints, like "finish" will still require
more work to migrate breakpoints etc. to the child thread.)

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (new_until_break_fsm): Add 'cmd_interp' parameter.
	(until_break_fsm_should_stop, until_break_fsm_clean_up): Add
	thread parameter.
	(until_break_command): Pass command interpreter to thread fsm
	ctor.
	* cli/cli-interp.c (should_print_stop_to_console): Adjust.
	* gdbthread.h (struct thread_control_state) <command_interp>:
	Delete field.
	* infcall.c (new_call_thread_fsm): Add 'cmd_interp' parameter.
	Pass it down.
	(call_thread_fsm_should_stop): Add thread parameter.
	(call_function_by_hand_dummy): Pass command interpreter to thread
	fsm ctor.  Pass thread pointer to fsm clean up method.
	* infcmd.c: Include interps.h.
	(struct step_command_fsm) <thread>: Delete field.
	(new_step_command_fsm): Add 'cmd_interp' parameter.  Pass it down.
	(step_command_fsm_prepare): Remove references to fsm's thread
	field.
	(step_1): Pass command interpreter to thread
	fsm ctor.  Pass thread pointer to fsm clean up method.
	(step_command_fsm_should_stop, step_command_fsm_clean_up): Add
	thread parameter and use it.
	(new_until_next_fsm): Add 'cmd_interp' parameter.  Pass it down.
	(until_next_fsm_should_stop, until_next_fsm_clean_up): Add thread
	parameter and use it.
	(until_next_command): Pass command interpreter to thread fsm ctor.
	(struct finish_command_fsm) <thread>: Delete field.
	(finish_command_fsm_ops): Add NULL slot for should_notify_stop.
	(new_finish_command_fsm): Add 'cmd_interp' parameter and pass it
	down.  Remove thread parameter and adjust.
	(finish_command_fsm_should_stop, finish_command_fsm_clean_up): Add
	thread parameter and use it.
	(finish_command): Pass command interpreter to thread fsm ctor.
	Don't pass thread.
	* infrun.c (follow_fork): Move thread fsm to child fork instead of
	command interpreter, only.
	(clear_proceed_status_thread): Remove reference to command_interp.
	(proceed): Don't record the thread's command interpreter.
	(clean_up_just_stopped_threads_fsms): Pass thread to fsm clean_up
	method.
	(fetch_inferior_event): Pass thread to fsm should_stop method.
	* thread-fsm.c (thread_fsm_ctor): Add 'cmd_interp' parameter.
	Store it.
	(thread_fsm_clean_up, thread_fsm_should_stop): Add thread
	parameter and pass it down.
	* thread-fsm.h (struct thread_fsm) <command_interp>: New field.
	(struct thread_fsm_ops) <clean_up, should_stop>: Add thread
	parameter.
	(thread_fsm_ctor): Add 'cmd_interp' parameter.
	(thread_fsm_clean_up, thread_fsm_should_stop): Add thread
	parameter.
	* thread.c (thread_cancel_execution_command): Pass thread to
	thread fsm clean_up method.

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

	* gdb.opt/inline-cmds.c: Add "set mi break here" marker.
	* gdb.opt/inline-cmds.exp: Add MI tests.
2016-06-21 01:11:53 +01:00
Pedro Alves 3b12939dfc Replace the sync_execution global with a new enum prompt_state tristate
When sync_execution (a boolean) is true, it means we're running a
foreground command -- we hide the prompt stop listening to input, give
the inferior the terminal, then go to the event loop waiting for the
target to stop.

With multiple independent UIs, we need to track whether each UI is
synchronously blocked waiting for the target.  IOW, if you do
"continue" in one console, that console stops accepting commands, but
you should still be free to type other commands in the others
consoles.

Just simply making sync_execution be per-UI alone not sufficient,
because of this in fetch_inferior_event:

  /* If the inferior was in sync execution mode, and now isn't,
     restore the prompt (a synchronous execution command has finished,
     and we're ready for input).  */
  if (current_ui->async && was_sync && !sync_execution)
    observer_notify_sync_execution_done ();

We'd have to record at entry the "was_sync" state for each UI, not
just of the current UI.

This patch instead replaces the sync_execution flag by a per-UI
tristate flag indicating the command line prompt state:

 enum prompt_state
 {
   /* The command line is blocked simulating synchronous execution.
      This is used to implement the foreground execution commands
      ('run', 'continue', etc.).  We won't display the prompt and
      accept further commands until the execution is actually over.  */
   PROMPT_BLOCKED,

   /* The command finished; display the prompt before returning back to
      the top level.  */
   PROMPT_NEEDED,

   /* We've displayed the prompt already, ready for input.  */
   PROMPTED,
 ;

I think the end result is _much_ clearer than the current code, and,
it addresses the original motivation too.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

	* annotate.c: Include top.h.
	(async_background_execution_p): Delete.
	(print_value_flags): Check the UI's prompt state rather then
	async_background_execution_p.
	* event-loop.c (start_event_loop): Set the prompt state to
	PROMPT_NEEDED.
	* event-top.c (display_gdb_prompt, async_enable_stdin)
	(async_disable_stdin): Check the current UI's prompt state instead
	of the sync_execution global.
	(command_line_handler): Set the prompt state to PROMPT_NEEDED
	before running a command, and display the prompt if still needed
	afterwards.
	* infcall.c (struct call_thread_fsm) <waiting_ui>: New field.
	(new_call_thread_fsm): New parameter 'waiting_ui'.  Store it.
	(call_thread_fsm_should_stop): Set the prompt state to
	PROMPT_NEEDED.
	(run_inferior_call): Adjust to temporarily set the prompt state to
	PROMPT_BLOCKED instead of using the sync_execution global.
	(call_function_by_hand_dummy): Pass the current UI to
	new_call_thread_fsm.
	* infcmd.c: Include top.h.
	(continue_1): Check the current UI's prompt state instead of the
	sync_execution global.
	(continue_command): Validate global execution state before calling
	prepare_execution_command.
	(step_1): Call all_uis_check_sync_execution_done.
	(attach_post_wait): Don't call async_enable_stdin here.  Remove
	reference to sync_execution.
	* infrun.c (sync_execution): Delete global.
	(follow_fork_inferior)
	(reinstall_readline_callback_handler_cleanup): Check the current
	UI's prompt state instead of the sync_execution global.
	(check_curr_ui_sync_execution_done)
	(all_uis_check_sync_execution_done): New functions.
	(fetch_inferior_event): Call all_uis_check_sync_execution_done
	instead of trying to determine whether the global sync execution
	changed.
	(handle_no_resumed): Check the prompt state of all UIs.
	(normal_stop): Emit the no unwait-for even to all PROMPT_BLOCKED
	UIs.  Emit the "Switching to" notification to all UIs.  Enable
	stdin in all UIs.
	* infrun.h (sync_execution): Delete.
	(all_uis_check_sync_execution_done): Declare.
	* main.c (captured_command_loop): Don't call
	interp_pre_command_loop if the prompt is blocked.
	(catch_command_errors, catch_command_errors_const): Adjust.
	(captured_main): Set the initial prompt state to PROMPT_NEEDED.
	* mi/mi-interp.c (display_mi_prompt): Set the prompt state to
	PROMPTED.
	(mi_interpreter_resume): Don't clear sync_execution.  Remove hack
	comment.
	(mi_execute_command_input_handler): Set the prompt state to
	PROMPT_NEEDED before executing the command, and only display the
	prompt if the prompt state is PROMPT_NEEDED afterwards.
	(mi_on_resume_1): Adjust to check the prompt state.
	* target.c (target_terminal_inferior): Adjust to check the prompt
	state.
	* top.c (wait_sync_command_done, maybe_wait_sync_command_done)
	(execute_command): Check the current UI's prompt state instead of
	sync_execution.
	* top.h (enum prompt_state): New.
	(struct ui) <prompt_state>: New field.
	(ALL_UIS): New macro.
2016-06-21 01:11:51 +01:00
Pedro Alves cb81451067 Make the interpreters be per UI
Make each UI have its own interpreter list, top level interpreter,
current interpreter, etc.  The "interpreter_async" global is not
really specific to an struct interp (it crosses interpreter-exec ...),
so I moved it to "struct ui" directly, while the other globals were
left hidden in interps.c, opaque to the rest of GDB.

gdb/ChangeLog:
2016-06-21  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (bpstat_do_actions_1): Access the current UI's
	async field instead of the interpreter_async global.
	* cli/cli-script.c (execute_user_command, while_command)
	(if_command, script_from_file): Likewise.
	* compile/compile.c: Include top.h instead of interps.h.
	(compile_file_command, compile_code_command)
	(compile_print_command): Access the current UI's async field
	instead of the interpreter_async global.
	* guile/guile.c: Include top.h instead of interps.h.
	(guile_repl_command, guile_command, gdbscm_execute_gdb_command):
	Access the current UI's async field instead of the
	interpreter_async global.
	* guile/scm-ports.c: Include top.h instead of interps.h.
	(ioscm_with_output_to_port_worker): Access the current UI's async
	field instead of the interpreter_async global.
	* inf-loop.c (inferior_event_handler): Likewise.
	* infcall.c (run_inferior_call): Likewise.
	* infrun.c (reinstall_readline_callback_handler_cleanup)
	(fetch_inferior_event): Likewise.
	* interps.c (interpreter_async): Delete.
	(struct ui_interp_info): New.
	(get_current_interp_info): New function.
	(interp_list, current_interpreter, top_level_interpreter_ptr):
	Delete.
	(interp_add, interp_set, interp_lookup, interp_ui_out)
	(current_interp_set_logging, interp_set_temp)
	(current_interp_named_p): Adjust to per-UI interpreters.
	(command_interpreter): Delete.
	(command_interp, current_interp_command_loop, interp_quiet_p)
	(interp_exec, interpreter_exec_cmd, interpreter_completer)
	(top_level_interpreter, top_level_interpreter_data): Adjust to
	per-UI interpreters.
	* interps.h (interpreter_async): Delete.
	* main.c (captured_command_loop): Access the current UI's async
	field instead of the interpreter_async global.
	* python/python.c (python_interactive_command, python_command)
	(execute_gdb_command): Likewise.
	* top.c (maybe_wait_sync_command_done, execute_command_to_string):
	Access the current UI's async field instead of the
	interpreter_async global.
	* top.h (struct tl_interp_info): Forward declare.
	(struct ui) <interp_info, async>: New fields.
2016-06-21 01:11:45 +01: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
Pedro Alves 0700e23e5f Garbage collect dummy_frame_ctx_saver
Since the "finish" command and infcall's FSMs are now responsible for
saving the return value, the dummy_frame_ctx_saver is no longer needed
anywhere.

gdb/ChangeLog:
2015-09-09  Pedro Alves  <palves@redhat.com>

	* infcall.c (struct dummy_frame_context_saver): Delete.
	(dummy_frame_context_saver_free, dummy_frame_context_saver_dtor)
	(dummy_frame_context_saver_drop)
	(dummy_frame_context_saver_cleanup)
	(dummy_frame_context_saver_get_regs)
	(dummy_frame_context_saver_setup): Delete.
	* infcall.h (dummy_frame_context_saver_drop)
	(dummy_frame_context_saver_cleanup)
	(dummy_frame_context_saver_get_regs, dummy_frame_context_saver):
	Delete.
	(get_return_value): Remove 'ctx_saver' paremeter.  Adjust.
	* inferior.h (get_return_value): Remove 'ctx_saver' paremeter.
	* python/py-finishbreakpoint.c (bpfinishpy_pre_stop_hook): Adjust.
2015-09-09 18:25:15 +01:00
Pedro Alves 388a708404 Convert infcalls to thread_fsm mechanism
This removes infcall-specific special casing from normal_stop,
simplifying it.

Like the "finish" command's, the FSM is responsible for storing the
function's return value.

gdb/ChangeLog:
2015-09-09  Pedro Alves  <palves@redhat.com>

	* infcall.c: Include thread_fsm.h.
	(struct call_return_meta_info): New.
	(get_call_return_value): New function, factored out from
	call_function_by_hand_dummy.
	(struct call_thread_fsm): New.
	(call_thread_fsm_ops): New global.
	(new_call_thread_fsm, call_thread_fsm_should_stop)
	(call_thread_fsm_should_notify_stop): New functions.
	(run_inferior_call): Add 'sm' parameter.  Associate the FSM with
	the thread.
	(call_function_by_hand_dummy): Create a new call_thread_fsm
	instance, associate it with the thread, and wait for the FSM to
	finish.  If finished successfully, fetch the function's result
	value out of the FSM.
	* infrun.c (fetch_inferior_event): If the FSM says the stop
	shouldn't be notified, don't call normal_stop.
	(maybe_remove_breakpoints): New function, factored out from ...
	(normal_stop): ... here.  Simplify.
	* infrun.h (maybe_remove_breakpoints): Declare.
	* thread-fsm.c (thread_fsm_should_notify_stop): New function.
	(thread-fsm.h) <struct thread_fsm_ops>: New field.
	(thread_fsm_should_notify_stop): Declare.
2015-09-09 18:24:34 +01:00
Pedro Alves 0b333c5e7d Merge async and sync code paths some more
This patch makes the execution control code use largely the same
mechanisms in both sync- and async-capable targets.  This means using
continuations and use the event loop to react to target events on sync
targets as well.  The trick is to immediately mark infrun's event loop
source after resume instead of calling wait_for_inferior.  Then
fetch_inferior_event is adjusted to do a blocking wait on sync
targets.

Tested on x86_64 Fedora 20, native and gdbserver, with and without
"maint set target-async off".

gdb/ChangeLog:
2015-09-09  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (bpstat_do_actions_1, until_break_command): Don't
	check whether the target can async.
	* inf-loop.c (inferior_event_handler): Only call target_async if
	the target can async.
	* infcall.c: Include top.h and interps.h.
	(run_inferior_call): For the interpreter to sync mode while
	running the infcall.  Call wait_sync_command_done instead of
	wait_for_inferior plus normal_stop.
	* infcmd.c (prepare_execution_command): Don't check whether the
	target can async when running in the foreground.
	(step_1): Delete synchronous case handling.
	(step_once): Always install a continuation, even in sync mode.
	(until_next_command, finish_forward): Don't check whether the
	target can async.
	(attach_command_post_wait, notice_new_inferior): Always install a
	continuation, even in sync mode.
	* infrun.c (mark_infrun_async_event_handler): New function.
	(proceed): In sync mode, mark infrun's event source instead of
	waiting for events here.
	(fetch_inferior_event): If the target can't async, do a blocking
	wait.
	(prepare_to_wait): In sync mode, mark infrun's event source.
	(infrun_async_inferior_event_handler): No longer bail out if the
	target can't async.
	* infrun.h (mark_infrun_async_event_handler): New declaration.
	* linux-nat.c (linux_nat_wait_1): Remove calls to
	set_sigint_trap/clear_sigint_trap.
	(linux_nat_terminal_inferior): No longer check whether the target
	can async.
	* mi/mi-interp.c (mi_on_sync_execution_done): Update and simplify
	comment.
	(mi_execute_command_input_handler): No longer check whether the
	target is async.  Update and simplify comment.
	* target.c (default_target_wait): New function.
	* target.h (struct target_ops) <to_wait>: Now defaults to
	default_target_wait.
	(default_target_wait): Declare.
	* top.c (wait_sync_command_done): New function, factored out from
	...
	(maybe_wait_sync_command_done): ... this.
	* top.h (wait_sync_command_done): Declare.
	* target-delegates.c: Regenerate.
2015-09-09 18:23:23 +01: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
Simon Marchi f168693bc9 Remove CHECK_TYPEDEF, use check_typedef instead
I think that the CHECK_TYPEDEF macro is not necessary, and even a bit
annoying.  It makes unclear the fact that the "type" variables gets
overwritten.  It has actually bitten me a few times.  I think the
following, explicit form, is better.

  type = check_typedef (type);

This patches changes all instances of CHECK_TYPEDEF for an equivalent
call to check_typedef.  The bulk of the change was done with this sed:

  sed -i 's/CHECK_TYPEDEF (\([^)]*\));/\1 = check_typedef (\1);/' <file>.c

The ChangeLog was generated using David Malcom's generate_changelog.py.
I manually fixed those places where it gets the wrong function name,
hopefully all of them.

The patch was built-tested, and I ran a few smoke tests.

gdb/ChangeLog:
	* gdbtypes.h (CHECK_TYPEDEF): Remove.
	* aarch64-tdep.c (aarch64_return_in_memory): Replace CHECK_TYPEDEF
        with check_typedef.
	* ada-lang.c (decode_constrained_packed_array_type): Likewise.
	(ada_array_length): Likewise.
	(find_parallel_type_by_descriptive_type): Likewise.
	(ada_check_typedef): Likewise.
	* arm-tdep.c (arm_return_in_memory): Likewise.
	* ax-gdb.c (gen_trace_static_fields): Likewise.
	(gen_struct_ref_recursive): Likewise.
	* c-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise.
	(variable: block COLONCOLON name): Likewise.
	(qualified_name: TYPENAME COLONCOLON name): Likewise.
	* c-lang.c (classify_type): Likewise.
	* c-typeprint.c (c_print_type): Likewise.
	(c_print_typedef): Likewise.
	(c_type_print_base): Likewise.
	* c-valprint.c (c_val_print): Likewise.
	* compile/compile-c-types.c (convert_type): Likewise.
	* compile/compile-object-load.c (get_out_value_type): Likewise.
	* completer.c (add_struct_fields): Likewise.
	(expression_completer): Likewise.
	* cp-namespace.c (cp_find_type_baseclass_by_name): Likewise.
	(cp_lookup_nested_symbol_1): Likewise.
	(cp_lookup_nested_symbol): Likewise.
	* cp-valprint.c (cp_print_value_fields): Likewise.
	(cp_print_static_field): Likewise.
	* d-valprint.c (d_val_print): Likewise.
	* eval.c (evaluate_subexp_standard): Likewise.
	(evaluate_subexp_for_sizeof): Likewise.
	* f-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise.
	* f-typeprint.c (f_type_print_base): Likewise.
	* f-valprint.c (f_val_print): Likewise.
	* gdbtypes.c (get_discrete_bounds): Likewise.
	(create_array_type_with_stride): Likewise.
	(type_name_no_tag_or_error): Likewise.
	(lookup_struct_elt_type): Likewise.
	(get_unsigned_type_max): Likewise.
	(internal_type_vptr_fieldno): Likewise.
	(set_type_vptr_fieldno): Likewise.
	(internal_type_vptr_basetype): Likewise.
	(set_type_vptr_basetype): Likewise.
        (get_vptr_fieldno): Likewise.
	(is_integral_type): Likewise.
	(is_scalar_type): Likewise.
        (is_scalar_type_recursive): Likewise.
	(distance_to_ancestor): Likewise.
	(is_unique_ancestor_worker): Likewise.
	(check_types_equal): Likewise.
	* gnu-v2-abi.c (gnuv2_value_rtti_type): Likewise.
	* gnu-v3-abi.c (gnuv3_dynamic_class): Likewise.
	(gnuv3_get_vtable): Likewise.
	(gnuv3_pass_by_reference): Likewise.
	* go-exp.y (exp : SIZEOF_KEYWORD '(' type ')' %prec UNARY): Likewise.
	* go-lang.c (gccgo_string_p): Likewise.
	(go_classify_struct_type): Likewise.
	* go-typeprint.c (go_print_type): Likewise.
	* go-valprint.c (go_val_print): Likewise.
	* guile/scm-math.c (vlscm_binop): Likewise.
	* guile/scm-value.c (gdbscm_value_dynamic_type): Likewise.
	(gdbscm_value_to_bytevector): Likewise.
	(gdbscm_value_to_bool): Likewise.
	(gdbscm_value_to_integer): Likewise.
	(gdbscm_value_to_real): Likewise.
	* infcall.c (call_function_by_hand_dummy): Likewise.
	* infcmd.c (get_return_value): Likewise.
	* jv-lang.c (is_object_type): Likewise.
	* jv-typeprint.c (java_type_print_base): Likewise.
	* jv-valprint.c (java_print_value_fields): Likewise.
	(java_val_print): Likewise.
	* linespec.c (find_methods): Likewise.
	(collect_one_symbol): Likewise.
	* m2-typeprint.c (m2_print_type): Likewise.
	(m2_print_typedef): Likewise.
	(m2_get_discrete_bounds): Likewise.
	* m2-valprint.c (m2_print_long_set): Likewise.
	(m2_print_unbounded_array): Likewise.
	(m2_print_array_contents): Likewise.
	(m2_val_print): Likewise.
	* opencl-lang.c (opencl_print_type): Likewise.
	* p-exp.y (exp : SIZEOF '(' type ')' %prec UNARY): Likewise.
	* p-typeprint.c (pascal_print_type): Likewise.
	(pascal_print_typedef): Likewise.
	(pascal_type_print_base): Likewise.
	* p-valprint.c (pascal_val_print): Likewise.
	(pascal_object_print_value_fields): Likewise.
	(pascal_object_print_static_field): Likewise.
	* python/py-type.c (typy_fields_items): Likewise.
	(typy_get_composite): Likewise.
	* python/py-value.c (valpy_get_dynamic_type): Likewise.
	(valpy_binop): Likewise.
	(valpy_long): Likewise.
	(valpy_float): Likewise.
	* stack.c (return_command): Likewise.
	* symtab.c (check_field): Likewise.
	(lookup_symbol_aux): Likewise.
	* tic6x-tdep.c (tic6x_return_value): Likewise.
	* typeprint.c (print_type_scalar): Likewise.
	* valarith.c (value_vector_widen): Likewise.
	* valops.c (value_cast): Likewise.
	(value_assign): Likewise.
	(do_search_struct_field): Likewise.
	(search_struct_method): Likewise.
	(find_method_list): Likewise.
	* valprint.c (val_print_scalar_type_p): Likewise.
	(valprint_check_validity): Likewise.
	(generic_val_print): Likewise.
	* value.c (unpack_double): Likewise.
	(value_primitive_field): Likewise.
	(unpack_bits_as_long): Likewise.
2015-07-14 16:42:16 -04:00
Pedro Alves 28bf096c62 PR threads/18127 - threads spawned by infcall end up stuck in "running" state
Refs:
 https://sourceware.org/ml/gdb/2015-03/msg00024.html
 https://sourceware.org/ml/gdb/2015-06/msg00005.html

On GNU/Linux, if an infcall spawns a thread, that thread ends up with
stuck running state.  This happens because:

 - when linux-nat.c detects a new thread, it marks them as running,
   and does not report anything to the core.

 - we skip finish_thread_state when the thread that is running the
   infcall stops.

As result, that new thread ends up with stuck "running" state, even
though it really is stopped.

On Windows, _all_ threads end up stuck in running state, not just the
one that was spawned.  That happens because when a new thread is
detected, unlike linux-nat.c, windows-nat.c reports
TARGET_WAITKIND_SPURIOUS to infrun.  It's the fact that that event
does not cause a user-visible stop that triggers the problem.  When
the target is re-resumed, we call set_running with a wildcard ptid,
which marks all thread as running.  That set_running is not suppressed
because the (leader) thread being resumed does not have in_infcall
set.  Later, when the infcall finally finishes successfully, nothing
marks all threads back to stopped.

We can trigger the same problem on all targets by having a thread
other than the one that is running the infcall report a breakpoint hit
to infrun, and then have that breakpoint not cause a stop.  That's
what the included test does.

The fix is to stop GDB from suppressing the set_running calls while
doing an infcall, and then set the threads back to stopped when the
call finishes, iff they were originally stopped before the infcall
started.  (Note the MI *running/*stopped event suppression isn't
affected.)

Tested on x86_64 GNU/Linux.

gdb/ChangeLog:
2015-06-29  Pedro Alves  <palves@redhat.com>

	PR threads/18127
	* infcall.c (run_inferior_call): On infcall success, if the thread
	was marked stopped before, reset it back to stopped.
	* infrun.c (resume): Don't suppress the set_running calls when
	doing an infcall.
	(normal_stop): Only discard the finish_thread_state cleanup if the
	infcall succeeded.

gdb/testsuite/ChangeLog:
2015-06-29  Pedro Alves  <palves@redhat.com>

	PR threads/18127
	* gdb.threads/hand-call-new-thread.c: New file.
	* gdb.threads/hand-call-new-thread.c: New file.
2015-06-29 16:07:57 +01:00
Jan Kratochvil 5fe75eec33 compile: Fix ASAN crash for gdb.compile/compile.exp
(gdb) PASS: gdb.compile/compile.exp: set unwindonsignal on
compile code *(volatile int *) 0 = 0;
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7fba426 in _gdb_expr (__regs=0x7ffff7fb8000) at gdb command line:1
1	gdb command line: No such file or directory.
=================================================================
==10462==ERROR: AddressSanitizer: heap-use-after-free on address 0x621000cf7a3d at pc 0x0000004e46b9 bp 0x7ffdeb0f7a40 sp 0x7ffdeb0f71b8
READ of size 10 at 0x621000cf7a3d thread T0
    #0 0x4e46b8 in printf_common(void*, char const*, __va_list_tag*) [clone .isra.6] (/home/jkratoch/redhat/gdb-clean-asan/gdb/gdb+0x4e46
b8)
    #1 0x4f645e in vasprintf (/home/jkratoch/redhat/gdb-clean-asan/gdb/gdb+0x4f645e)
    #2 0xe5cf00 in xstrvprintf common/common-utils.c:120
    #3 0xe74192 in throw_it common/common-exceptions.c:332
    #4 0xe742f6 in throw_verror common/common-exceptions.c:361
    #5 0xddc89e in verror /home/jkratoch/redhat/gdb-clean-asan/gdb/utils.c:541
    #6 0xe734bd in error common/errors.c:43
    #7 0xafa1d6 in call_function_by_hand_dummy /home/jkratoch/redhat/gdb-clean-asan/gdb/infcall.c:1031
    #8 0xe81858 in compile_object_run compile/compile-object-run.c:119
    #9 0xe7733c in eval_compile_command compile/compile.c:577
    #10 0xe7541e in compile_code_command compile/compile.c:153

It is obvious why that happens, dummy_frame_pop() will call compile objfile
cleanup which will free that objfile and NAME then becomes a stale pointer.

> Is there any reason we release OBJFILE in the dummy frame dtor?  Why
> don't we register a cleanup to release in OBJFILE in compile_object_run?
> together with releasing compile_module?  'struct compile_module' has a
> field objfile, which should be released together with
> 'struct compile_module' instead of dummy_frame.

(gdb) break puts
Breakpoint 2 at 0x3830c6fd30: file ioputs.c, line 34.
(gdb) compile code puts("hello")
Breakpoint 2, _IO_puts (str=0x7ffff7ff8000 "hello") at ioputs.c:34
34      {
The program being debugged stopped while in a function called from GDB.
Evaluation of the expression containing the function
(_gdb_expr) will be abandoned.
When the function is done executing, GDB will silently stop.
(gdb) bt
(gdb) _

Now compile_object_run() called from line
	(gdb) compile code puts("hello")
has finished for a long time.  But we still need to have that injected code
OBJFILE valid when GDB is executing it.  Therefore OBJFILE is freed only from
destructor of the frame #1.

At the patched line of call_function_by_hand_dummy() the dummy frame
destructor has not yet been run but it will be run before the fetched NAME
will get used.

gdb/ChangeLog
2015-05-19  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix ASAN crash for gdb.compile/compile.exp.
	* infcall.c (call_function_by_hand_dummy): Use xstrdup for NAME.
2015-05-19 16:12:30 +02:00
Jan Kratochvil 46c03469b3 Remove stop_registers
Now stop_registers are no longer used and it can be removed.

I am not much sure what 'proceed_to_finish' really means now so I make a wild
guess while updating comments about it.

gdb/ChangeLog
2015-05-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdbthread.h (struct thread_control_state): Update comment for
	proceed_to_finish.
	* infcall.c (run_inferior_call): Update comment about
	proceed_to_finish.
	* infcmd.c (get_return_value): Update comment about stop_registers.
	(finish_forward): Update comment about proceed_to_finish.
	* infrun.c (stop_registers): Remove.
	(clear_proceed_status, normal_stop): Remove stop_registers handling.
	* infrun.h (stop_registers): Remove.
2015-05-13 20:49:45 +02:00
Jan Kratochvil 8a6c403112 infcall: stop_registers -> register_dummy_frame_dtor
With dummy_frame destructors GDB no longer has to use global stop_registers.
dummy_frame's registers can be now stored associated with their specific
dummy_frame.

gdb/ChangeLog
2015-05-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* infcall.c (struct dummy_frame_context_saver)
	(dummy_frame_context_saver_data_free, dummy_frame_context_saver_dtor)
	(dummy_frame_context_saver_drop, dummy_frame_context_saver_cleanup)
	(dummy_frame_context_saver_get_regs, dummy_frame_context_saver_setup):
	New.
	(call_function_by_hand_dummy): Move discard_cleanups of
	inf_status_cleanup before dummy_frame_push.  Call
	dummy_frame_context_saver_setup and prepare context_saver_cleanup.
	Use dummy_frame_context_saver_get_regs instead of stop_registers.
	* infcall.h (struct dummy_frame_context_saver)
	(dummy_frame_context_saver_drop, dummy_frame_context_saver_cleanup)
	(dummy_frame_context_saver_get_regs, dummy_frame_context_saver_setup):
	New declarations.
	* infcmd.c: Include infcall.h.
	(get_return_value): Add parameter ctx_saver, use it instead of
	stop_registers.
	(print_return_value): Add parameter ctx_saver, pass it.
	(struct finish_command_continuation_args): Add field ctx_saver.
	(finish_command_continuation): Update print_return_value caller.
	(finish_command_continuation_free_arg): Free also ctx_saver.
	(finish_forward): Call dummy_frame_context_saver_setup.
	* inferior.h (struct dummy_frame_context_saver): New declaration.
	(get_return_value): Add parameter ctx_saver.
	* python/py-finishbreakpoint.c (bpfinishpy_pre_stop_hook): Update
	get_return_value caller.
2015-05-13 20:49:08 +02:00
Jan Kratochvil 558e546967 dummy_frame_dtor_ftype vs. call_function_by_hand_dummy_dtor_ftype cleanup
Both dummy_frame_dtor_ftype and call_function_by_hand_dummy_dtor_ftype
represent the same type, there was some mistake/duplication during check-in.

gdb/ChangeLog
2015-05-08  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dummy-frame.c (struct dummy_frame): Use proper typedef for dtor.
	* dummy-frame.h (dummy_frame_dtor_ftype): Add its comment.
	* infcall.c (call_function_by_hand_dummy): Use proper typedef for
	dummy_dtor parameter.
	* infcall.h: Include dummy-frame.h.
	(call_function_by_hand_dummy_dtor_ftype): Remove.
	(call_function_by_hand_dummy): Use proper typedef for dummy_dtor
	parameter.
2015-05-13 15:55:09 +02:00
Pedro Alves 64ce06e4cd Remove 'step' parameters from 'proceed' and 'resume'
The "step" parameters of 'proceed' and 'resume' aren't really useful
as indication of whether run control wants to single-step the target,
as that information must already be retrievable from
currently_stepping.  In fact, if currently_stepping disagrees with
whether we single-stepped the target, then things break.  Thus instead
of having the same information in two places, this patch removes those
parameters.

Setting 'step_start_function' is the only user of proceed's 'step'
argument, other than passing the 'step' argument down to 'resume' and
debug log output.  Move that instead to set_step_frame, where we
already set other related fields.

clear_proceed_status keeps its "step" parameter for now because it
needs to know which set of threads should have their state cleared,
and is called before the "stepping_command" flag is set.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/ChangeLog:
2015-03-24  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (until_break_command): Adjust call to proceed.
	* gdbthread.h (struct thread_control_state) <stepping_command>:
	New field.
	* infcall.c (run_inferior_call): Adjust call to proceed.
	* infcmd.c (run_command_1, proceed_thread_callback, continue_1):
	Adjust calls to proceed.
	(set_step_frame): Set the current thread's step_start_function
	here.
	(step_once): Adjust calls to proceed.
	(jump_command, signal_command, until_next_command)
	(finish_backward, finish_forward, proceed_after_attach_callback)
	(attach_command_post_wait): Adjust calls to proceed.
	* infrun.c (proceed_after_vfork_done): Adjust call to proceed.
	(do_target_resume): New function, factored out from ...
	(resume): ... here.  Remove 'step' parameter.  Instead, check
	currently_stepping to determine whether the thread should be
	single-stepped.
	(proceed): Remove 'step' parameter and don't set the thread's
	step_start_function here.  Adjust call to 'resume'.
	(handle_inferior_event): Adjust calls to 'resume'.
	(switch_back_to_stepped_thread): Use do_target_resume instead of
	'resume'.
	(keep_going): Adjust calls to 'resume'.
	* infrun.h (proceed): Remove 'step' parameter.
	(resume): Likewise.
	* windows-nat.c (do_initial_windows_stuff): Adjust call to
	'resume'.
	* mi/mi-main.c (proceed_thread): Adjust call to 'proceed'.
2015-03-24 17:55:53 +00:00
Pedro Alves 492d29ea1c Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:

~~~
  volatile gdb_exception ex;

  TRY_CATCH (ex, RETURN_MASK_ERROR)
    {
    }
  if (ex.reason < 0)
    {
    }
~~~

to this:

~~~
  TRY
    {
    }
  CATCH (ex, RETURN_MASK_ERROR)
    {
    }
  END_CATCH
~~~

Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.

This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.

TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:

  TRY
    {
    }

  // some code here.

  CATCH (ex, RETURN_MASK_ERROR)
    {
    }
  END_CATCH

Just like it isn't valid to do that with C++'s native try/catch.

By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.

The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved.  After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch].  The result was folded into this patch so that GDB
still builds at each incremental step.

END_CATCH is necessary for two reasons:

First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:

  #define CATCH(EXCEPTION, mask) \
    for (struct gdb_exception EXCEPTION; \
         exceptions_state_mc_catch (&EXCEPTION, MASK); \
	 EXCEPTION = exception_none)

would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.

Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow.  That will
be done in END_CATCH.

After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.

IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.

gdb/ChangeLog.
2015-03-07  Pedro Alves  <palves@redhat.com>

	* common/common-exceptions.c (struct catcher) <exception>: No
	longer a pointer to volatile exception.  Now an exception value.
	<mask>: Delete field.
	(exceptions_state_mc_init): Remove all parameters.  Adjust.
	(exceptions_state_mc): No longer pop the catcher here.
	(exceptions_state_mc_catch): New function.
	(throw_exception): Adjust.
	* common/common-exceptions.h (exceptions_state_mc_init): Remove
	all parameters.
	(exceptions_state_mc_catch): Declare.
	(TRY_CATCH): Rename to ...
	(TRY): ... this.  Remove EXCEPTION and MASK parameters.
	(CATCH, END_CATCH): New.
	All callers adjusted.

gdb/gdbserver/ChangeLog:
2015-03-07  Pedro Alves  <palves@redhat.com>

	Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
	instead.
2015-03-07 15:14:14 +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
Jan Kratochvil ed12ef62cc introduce call_function_by_hand_dummy
This provides a variant of call_function_by_hand that allows the dummy
frame destructor to be set.  This is used by the compiler code to
manage some resources when calling the gdb-generated inferior
function.

gdb/ChangeLog
2014-12-12  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* infcall.h (call_function_by_hand_dummy): Declare.
	* infcall.c (call_function_by_hand): Use
	call_function_by_hand_dummy.
	(call_function_by_hand_dummy): Rename from call_function_by_hand.
	Add arguments.  Register a destructor.
2014-12-12 22:26:41 +01:00
Nick Bull 162078c893 New python events: inferior call, register/memory changed.
gdb/ChangeLog:

	* NEWS: Mention new Python events.
	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-infevents.o.
	(SUBDIR_PYTHON_SRCS): Add py-infevents.c.
	(py-infevents.o): New rule.
	* doc/observer.texi (inferior_call_pre, inferior_call_post)
	(memory_changed, register_changed): New observers.
	* infcall.c (call_function_by_hand): Notify observer before and
	after inferior call.
	* python/py-event.h (inferior_call_kind): New enum.
	(emit_inferior_call_event): New prototype.
	(emit_register_changed_event): New prototype.
	(emit_memory_changed_event): New prototype.
	* python/py-events.h (events_object): New registries
	inferior_call, memory_changed and register_changed.
	* python/py-evts.c (gdbpy_initialize_py_events): Add the
	inferior_call, memory_changed and register_changed registries.
	* python/py-infevents.c: New.
	* python/py-inferior.c (python_on_inferior_call_pre)
	(python_on_inferior_call_post, python_on_register_change)
	(python_on_memory_change): New functions.
	(gdbpy_initialize_inferior): Attach python handler to new
	observers.
	* python/py-infthread.c(gdbpy_create_ptid_object): New.
	(thpy_get_ptid) Use gdbpy_create_ptid_object.
	* python/python-internal.h:
	(gdbpy_create_ptid_object)
	(gdbpy_initialize_inferior_call_pre_event)
	(gdbpy_initialize_inferior_call_post_event)
	(gdbpy_initialize_register_changed_event)
	(gdbpy_initialize_memory_changed_event): New prototypes.
	* python/python.c (_initialize_python): Initialize new events.
	* valops.c (value_assign): Notify register_changed observer.

gdb/doc/ChangeLog:

	* python.texi (Events In Python): Document new events
	InferiorCallPreEvent, InferiorCallPostEvent, MemoryChangedEvent
	and RegisterChangedEvent.

gdb/testsuite/ChangeLog:

	* gdb.python/py-events.py (inferior_call_handler): New.
	(register_changed_handler, memory_changed_handler): New.
	(test_events.invoke): Register new handlers.
	* gdb.python/py-events.exp: Add tests for inferior call,
	memory_changed and register_changed events.
2014-12-02 11:15:29 -08:00
Doug Evans 71dd4b30a7 revert previous patch so that I can re-commit with correct author 2014-12-02 11:12:49 -08:00
Doug Evans dc6c87175b New python events: infcall, register/memory changed.
gdb/ChangeLog:

	* NEWS: Mention new Python events.
	* Makefile.in (SUBDIR_PYTHON_OBS): Add py-infevents.o.
	(SUBDIR_PYTHON_SRCS): Add py-infevents.c.
	(py-infevents.o): New rule.
	* doc/observer.texi (inferior_call_pre, inferior_call_post)
	(memory_changed, register_changed): New observers.
	* infcall.c (call_function_by_hand): Notify observer before and
	after inferior call.
	* python/py-event.h (inferior_call_kind): New enum.
	(emit_inferior_call_event): New prototype.
	(emit_register_changed_event): New prototype.
	(emit_memory_changed_event): New prototype.
	* python/py-events.h (events_object): New registries
	inferior_call, memory_changed and register_changed.
	* python/py-evts.c (gdbpy_initialize_py_events): Add the
	inferior_call, memory_changed and register_changed registries.
	* python/py-infevents.c: New.
	* python/py-inferior.c (python_on_inferior_call_pre)
	(python_on_inferior_call_post, python_on_register_change)
	(python_on_memory_change): New functions.
	(gdbpy_initialize_inferior): Attach python handler to new
	observers.
	* python/py-infthread.c(gdbpy_create_ptid_object): New.
	(thpy_get_ptid) Use gdbpy_create_ptid_object.
	* python/python-internal.h:
	(gdbpy_create_ptid_object)
	(gdbpy_initialize_inferior_call_pre_event)
	(gdbpy_initialize_inferior_call_post_event)
	(gdbpy_initialize_register_changed_event)
	(gdbpy_initialize_memory_changed_event): New prototypes.
	* python/python.c (_initialize_python): Initialize new events.
	* valops.c (value_assign): Notify register_changed observer.

gdb/doc/ChangeLog:

	* python.texi (Events In Python): Document new events
	InferiorCallPreEvent, InferiorCallPostEvent, MemoryChangedEvent
	and RegisterChangedEvent.

gdb/testsuite/ChangeLog:

	* gdb.python/py-events.py (inferior_call_handler): New.
	(register_changed_handler, memory_changed_handler): New.
	(test_events.invoke): Register new handlers.
	* gdb.python/py-events.exp: Add tests for inferior call,
	memory_changed and register_changed events.
2014-12-02 10:59:08 -08:00
Siva Chandra 6c659fc2c7 Enable chained function calls in C++ expressions.
gdb/ChangeLog:

	* eval.c: Include gdbthread.h.
	(evaluate_subexp): Enable thread stack temporaries before
	evaluating a complete expression and clean them up after the
	evaluation is complete.
	* gdbthread.h: Include common/vec.h.
	(value_ptr): New typedef.
	(VEC (value_ptr)): New vector type.
	(value_vec): New typedef.
	(struct thread_info): Add new fields stack_temporaries_enabled
	and stack_temporaries.
	(enable_thread_stack_temporaries)
	(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
	(get_last_thread_stack_temporary)
	(value_in_thread_stack_temporaries): Declare.
	* gdbtypes.c (class_or_union_p): New function.
	* gdbtypes.h (class_or_union_p): Declare.
	* infcall.c (call_function_by_hand): Store return values of class
	type as	temporaries on stack.
	* thread.c (enable_thread_stack_temporaries): New function.
	(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
	(get_last_thread_stack_temporary): Likewise.
	(value_in_thread_stack_temporaries): Likewise.
	* value.c (value_force_lval): New function.
	* value.h (value_force_lval): Declare.

gdb/testsuite/ChangeLog:

	* gdb.cp/chained-calls.cc: New file.
	* gdb.cp/chained-calls.exp: New file.
	* gdb.cp/smartp.exp: Remove KFAIL for "p c2->inta".
2014-11-28 16:01:16 -08:00
Gary Benson c765fdb902 Remove spurious exceptions.h inclusions
defs.h includes utils.h, and utils.h includes exceptions.h.  All GDB
.c files include defs.h as their first line, so no file other than
utils.h needs to include exceptions.h.  This commit removes all such
inclusions.

gdb/ChangeLog:

	* ada-lang.c: Do not include exceptions.h.
	* ada-valprint.c: Likewise.
	* amd64-tdep.c: Likewise.
	* auto-load.c: Likewise.
	* block.c: Likewise.
	* break-catch-throw.c: Likewise.
	* breakpoint.c: Likewise.
	* btrace.c: Likewise.
	* c-lang.c: Likewise.
	* cli/cli-cmds.c: Likewise.
	* cli/cli-interp.c: Likewise.
	* cli/cli-script.c: Likewise.
	* completer.c: Likewise.
	* corefile.c: Likewise.
	* corelow.c: Likewise.
	* cp-abi.c: Likewise.
	* cp-support.c: Likewise.
	* cp-valprint.c: Likewise.
	* darwin-nat.c: Likewise.
	* dwarf2-frame-tailcall.c: Likewise.
	* dwarf2-frame.c: Likewise.
	* dwarf2loc.c: Likewise.
	* dwarf2read.c: Likewise.
	* eval.c: Likewise.
	* event-loop.c: Likewise.
	* event-top.c: Likewise.
	* f-valprint.c: Likewise.
	* frame-unwind.c: Likewise.
	* frame.c: Likewise.
	* gdbtypes.c: Likewise.
	* gnu-v2-abi.c: Likewise.
	* gnu-v3-abi.c: Likewise.
	* guile/scm-auto-load.c: Likewise.
	* guile/scm-breakpoint.c: Likewise.
	* guile/scm-cmd.c: Likewise.
	* guile/scm-frame.c: Likewise.
	* guile/scm-lazy-string.c: Likewise.
	* guile/scm-param.c: Likewise.
	* guile/scm-symbol.c: Likewise.
	* guile/scm-type.c: Likewise.
	* hppa-hpux-tdep.c: Likewise.
	* i386-tdep.c: Likewise.
	* inf-loop.c: Likewise.
	* infcall.c: Likewise.
	* infcmd.c: Likewise.
	* infrun.c: Likewise.
	* interps.c: Likewise.
	* interps.h: Likewise.
	* jit.c: Likewise.
	* linespec.c: Likewise.
	* linux-nat.c: Likewise.
	* linux-thread-db.c: Likewise.
	* m32r-rom.c: Likewise.
	* main.c: Likewise.
	* memory-map.c: Likewise.
	* mi/mi-cmd-break.c: Likewise.
	* mi/mi-cmd-stack.c: Likewise.
	* mi/mi-interp.c: Likewise.
	* mi/mi-main.c: Likewise.
	* monitor.c: Likewise.
	* nto-procfs.c: Likewise.
	* objc-lang.c: Likewise.
	* p-valprint.c: Likewise.
	* parse.c: Likewise.
	* ppc-linux-tdep.c: Likewise.
	* printcmd.c: Likewise.
	* probe.c: Likewise.
	* python/py-auto-load.c: Likewise.
	* python/py-breakpoint.c: Likewise.
	* python/py-cmd.c: Likewise.
	* python/py-finishbreakpoint.c: Likewise.
	* python/py-frame.c: Likewise.
	* python/py-framefilter.c: Likewise.
	* python/py-function.c: Likewise.
	* python/py-gdb-readline.c: Likewise.
	* python/py-inferior.c: Likewise.
	* python/py-infthread.c: Likewise.
	* python/py-lazy-string.c: Likewise.
	* python/py-linetable.c: Likewise.
	* python/py-param.c: Likewise.
	* python/py-prettyprint.c: Likewise.
	* python/py-symbol.c: Likewise.
	* python/py-type.c: Likewise.
	* python/py-value.c: Likewise.
	* python/python-internal.h: Likewise.
	* python/python.c: Likewise.
	* record-btrace.c: Likewise.
	* record-full.c: Likewise.
	* regcache.c: Likewise.
	* remote-fileio.c: Likewise.
	* remote-mips.c: Likewise.
	* remote.c: Likewise.
	* rs6000-aix-tdep.c: Likewise.
	* rs6000-nat.c: Likewise.
	* skip.c: Likewise.
	* solib-darwin.c: Likewise.
	* solib-dsbt.c: Likewise.
	* solib-frv.c: Likewise.
	* solib-ia64-hpux.c: Likewise.
	* solib-spu.c: Likewise.
	* solib-svr4.c: Likewise.
	* solib.c: Likewise.
	* spu-tdep.c: Likewise.
	* stack.c: Likewise.
	* stap-probe.c: Likewise.
	* symfile-mem.c: Likewise.
	* symmisc.c: Likewise.
	* target.c: Likewise.
	* thread.c: Likewise.
	* top.c: Likewise.
	* tracepoint.c: Likewise.
	* tui/tui-interp.c: Likewise.
	* typeprint.c: Likewise.
	* utils.c: Likewise.
	* valarith.c: Likewise.
	* valops.c: Likewise.
	* valprint.c: Likewise.
	* value.c: Likewise.
	* varobj.c: Likewise.
	* windows-nat.c: Likewise.
	* xml-support.c: Likewise.
2014-10-08 09:33:22 +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
Gary Benson dccbb60975 Include gdb_assert.h in common-defs.h
This commit includes gdb_assert.h in common-defs.h and removes all
other inclusions.

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

	* common/common-defs.h: Include gdb_assert.h.
	* aarch64-tdep.c: Do not include gdb_assert.h.
	* addrmap.c: Likewise.
	* aix-thread.c: Likewise.
	* alpha-linux-tdep.c: Likewise.
	* alpha-mdebug-tdep.c: Likewise.
	* alphanbsd-tdep.c: Likewise.
	* amd64-nat.c: Likewise.
	* amd64-tdep.c: Likewise.
	* amd64bsd-nat.c: Likewise.
	* amd64fbsd-nat.c: Likewise.
	* amd64fbsd-tdep.c: Likewise.
	* amd64nbsd-nat.c: Likewise.
	* amd64nbsd-tdep.c: Likewise.
	* amd64obsd-nat.c: Likewise.
	* amd64obsd-tdep.c: Likewise.
	* arch-utils.c: Likewise.
	* arm-tdep.c: Likewise.
	* armbsd-tdep.c: Likewise.
	* auxv.c: Likewise.
	* bcache.c: Likewise.
	* bfin-tdep.c: Likewise.
	* blockframe.c: Likewise.
	* breakpoint.c: Likewise.
	* bsd-kvm.c: Likewise.
	* bsd-uthread.c: Likewise.
	* buildsym.c: Likewise.
	* c-exp.y: Likewise.
	* c-lang.c: Likewise.
	* charset.c: Likewise.
	* cleanups.c: Likewise.
	* cli-out.c: Likewise.
	* cli/cli-decode.c: Likewise.
	* cli/cli-dump.c: Likewise.
	* cli/cli-logging.c: Likewise.
	* cli/cli-script.c: Likewise.
	* cli/cli-utils.c: Likewise.
	* coffread.c: Likewise.
	* common/common-utils.c: Likewise.
	* common/queue.h: Likewise.
	* common/signals.c: Likewise.
	* common/vec.h: Likewise.
	* complaints.c: Likewise.
	* completer.c: Likewise.
	* corelow.c: Likewise.
	* cp-abi.c: Likewise.
	* cp-name-parser.y: Likewise.
	* cp-namespace.c: Likewise.
	* cp-support.c: Likewise.
	* cris-tdep.c: Likewise.
	* dbxread.c: Likewise.
	* dictionary.c: Likewise.
	* doublest.c: Likewise.
	* dsrec.c: Likewise.
	* dummy-frame.c: Likewise.
	* dwarf2-frame-tailcall.c: Likewise.
	* dwarf2-frame.c: Likewise.
	* dwarf2expr.c: Likewise.
	* dwarf2loc.c: Likewise.
	* dwarf2read.c: Likewise.
	* eval.c: Likewise.
	* event-loop.c: Likewise.
	* exceptions.c: Likewise.
	* expprint.c: Likewise.
	* f-valprint.c: Likewise.
	* fbsd-nat.c: Likewise.
	* findvar.c: Likewise.
	* frame-unwind.c: Likewise.
	* frame.c: Likewise.
	* frv-tdep.c: Likewise.
	* gcore.c: Likewise.
	* gdb-dlfcn.c: Likewise.
	* gdb_bfd.c: Likewise.
	* gdbarch.c: Likewise.
	* gdbarch.sh: Likewise.
	* gdbtypes.c: Likewise.
	* gnu-nat.c: Likewise.
	* gnu-v3-abi.c: Likewise.
	* go-lang.c: Likewise.
	* guile/scm-exception.c: Likewise.
	* guile/scm-gsmob.c: Likewise.
	* guile/scm-lazy-string.c: Likewise.
	* guile/scm-math.c: Likewise.
	* guile/scm-pretty-print.c: Likewise.
	* guile/scm-safe-call.c: Likewise.
	* guile/scm-utils.c: Likewise.
	* guile/scm-value.c: Likewise.
	* h8300-tdep.c: Likewise.
	* hppa-hpux-nat.c: Likewise.
	* hppa-tdep.c: Likewise.
	* hppanbsd-tdep.c: Likewise.
	* hppaobsd-tdep.c: Likewise.
	* i386-darwin-nat.c: Likewise.
	* i386-darwin-tdep.c: Likewise.
	* i386-nto-tdep.c: Likewise.
	* i386-tdep.c: Likewise.
	* i386bsd-nat.c: Likewise.
	* i386fbsd-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-tdep.c: Likewise.
	* inf-ptrace.c: Likewise.
	* inf-ttrace.c: Likewise.
	* infcall.c: Likewise.
	* infcmd.c: Likewise.
	* infrun.c: Likewise.
	* inline-frame.c: Likewise.
	* interps.c: Likewise.
	* jv-lang.c: Likewise.
	* jv-typeprint.c: Likewise.
	* linux-fork.c: Likewise.
	* linux-nat.c: Likewise.
	* linux-thread-db.c: Likewise.
	* m32c-tdep.c: Likewise.
	* m32r-linux-nat.c: Likewise.
	* m32r-tdep.c: Likewise.
	* m68k-tdep.c: Likewise.
	* m68kbsd-nat.c: Likewise.
	* m68kbsd-tdep.c: Likewise.
	* m88k-tdep.c: Likewise.
	* machoread.c: Likewise.
	* macroexp.c: Likewise.
	* macrotab.c: Likewise.
	* maint.c: Likewise.
	* mdebugread.c: Likewise.
	* memory-map.c: Likewise.
	* mep-tdep.c: Likewise.
	* mi/mi-common.c: Likewise.
	* microblaze-tdep.c: Likewise.
	* mingw-hdep.c: Likewise.
	* mips-linux-nat.c: Likewise.
	* mips-linux-tdep.c: Likewise.
	* mips-tdep.c: Likewise.
	* mips64obsd-tdep.c: Likewise.
	* mipsnbsd-tdep.c: Likewise.
	* mn10300-linux-tdep.c: Likewise.
	* mn10300-tdep.c: Likewise.
	* moxie-tdep.c: Likewise.
	* mt-tdep.c: Likewise.
	* nat/linux-btrace.c: Likewise.
	* nat/linux-osdata.c: Likewise.
	* nat/linux-ptrace.c: Likewise.
	* nat/mips-linux-watch.c: Likewise.
	* nios2-linux-tdep.c: Likewise.
	* nios2-tdep.c: Likewise.
	* objc-lang.c: Likewise.
	* objfiles.c: Likewise.
	* obsd-nat.c: Likewise.
	* opencl-lang.c: Likewise.
	* osabi.c: Likewise.
	* parse.c: Likewise.
	* ppc-linux-nat.c: Likewise.
	* ppc-sysv-tdep.c: Likewise.
	* ppcfbsd-nat.c: Likewise.
	* ppcfbsd-tdep.c: Likewise.
	* ppcnbsd-nat.c: Likewise.
	* ppcnbsd-tdep.c: Likewise.
	* ppcobsd-nat.c: Likewise.
	* ppcobsd-tdep.c: Likewise.
	* printcmd.c: Likewise.
	* procfs.c: Likewise.
	* prologue-value.c: Likewise.
	* psymtab.c: Likewise.
	* python/py-lazy-string.c: Likewise.
	* python/py-value.c: Likewise.
	* regcache.c: Likewise.
	* reggroups.c: Likewise.
	* registry.c: Likewise.
	* remote-sim.c: Likewise.
	* remote.c: Likewise.
	* rs6000-aix-tdep.c: Likewise.
	* rs6000-tdep.c: Likewise.
	* s390-linux-tdep.c: Likewise.
	* score-tdep.c: Likewise.
	* ser-base.c: Likewise.
	* ser-mingw.c: Likewise.
	* sh-tdep.c: Likewise.
	* sh64-tdep.c: Likewise.
	* solib-darwin.c: Likewise.
	* solib-spu.c: Likewise.
	* solib-svr4.c: Likewise.
	* source.c: Likewise.
	* sparc-nat.c: Likewise.
	* sparc-sol2-tdep.c: Likewise.
	* sparc-tdep.c: Likewise.
	* sparc64-sol2-tdep.c: Likewise.
	* sparc64-tdep.c: Likewise.
	* sparc64fbsd-tdep.c: Likewise.
	* sparc64nbsd-tdep.c: Likewise.
	* sparc64obsd-tdep.c: Likewise.
	* sparcnbsd-tdep.c: Likewise.
	* sparcobsd-tdep.c: Likewise.
	* spu-multiarch.c: Likewise.
	* spu-tdep.c: Likewise.
	* stabsread.c: Likewise.
	* stack.c: Likewise.
	* symfile.c: Likewise.
	* symtab.c: Likewise.
	* target-descriptions.c: Likewise.
	* target-memory.c: Likewise.
	* target.c: Likewise.
	* tic6x-linux-tdep.c: Likewise.
	* tic6x-tdep.c: Likewise.
	* tilegx-linux-nat.c: Likewise.
	* tilegx-tdep.c: Likewise.
	* top.c: Likewise.
	* tramp-frame.c: Likewise.
	* tui/tui-out.c: Likewise.
	* tui/tui-winsource.c: Likewise.
	* ui-out.c: Likewise.
	* user-regs.c: Likewise.
	* utils.c: Likewise.
	* v850-tdep.c: Likewise.
	* valops.c: Likewise.
	* value.c: Likewise.
	* varobj.c: Likewise.
	* vax-nat.c: Likewise.
	* xml-syscall.c: Likewise.
	* xml-tdesc.c: Likewise.
	* xstormy16-tdep.c: Likewise.
	* xtensa-linux-nat.c: Likewise.
	* xtensa-tdep.c: Likewise.

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

	* server.h: Do not include gdb_assert.h.
2014-08-07 09:06:45 +01:00
Pedro Alves 705096250d Always pass signals to the right thread
Currently, GDB can pass a signal to the wrong thread in several
different but related scenarios.

E.g., if thread 1 stops for signal SIGFOO, the user switches to thread
2, and then issues "continue", SIGFOO is actually delivered to thread
2, not thread 1.  This obviously messes up programs that use
pthread_kill to send signals to specific threads.

This has been a known issue for a long while.  Back in 2008 when I
made stop_signal be per-thread (2020b7ab), I kept the behavior -- see
code in 'proceed' being removed -- wanting to come back to it later.
The time has finally come now.

The patch fixes this -- on resumption, intercepted signals are always
delivered to the thread that had intercepted them.

Another example: if thread 1 stops for a breakpoint, the user switches
to thread 2, and then issues "signal SIGFOO", SIGFOO is actually
delivered to thread 1, not thread 2, because 'proceed' first switches
to thread 1 to step over its breakpoint...  If the user deletes the
breakpoint before issuing "signal FOO", then the signal is delivered
to thread 2 (the current thread).

"signal SIGFOO" can be used for two things: inject a signal in the
program while the program/thread had stopped for none, bypassing
"handle nopass"; or changing/suppressing a signal the program had
stopped for.  These scenarios are really two faces of the same coin,
and GDB can't really guess what the user is trying to do.  GDB might
have intercepted signals in more than one thread even (see the new
signal-command-multiple-signals-pending.exp test).  At least in the
inject case, it's obviously clear to me that the user means to deliver
the signal to the currently selected thread, so best is to make the
command's behavior consistent and easy to explain.

Then, if the user is trying to suppress/change a signal the program
had stopped for instead of injecting a new signal, but, the user had
changed threads meanwhile, then she will be surprised that with:

  (gdb) continue
  Thread 1 stopped for signal SIGFOO.
  (gdb) thread 2
  (gdb) signal SIGBAR

... GDB actually delivers SIGFOO to thread 1, and SIGBAR to thread 2
(with scheduler-locking off, which is the default, because then
"signal" or any other resumption command resumes all threads).

So the patch makes GDB detect that, and ask for confirmation:

  (gdb) thread 1
  [Switching to thread 1 (Thread 10979)]
  (gdb) signal SIGUSR2
  Note:
    Thread 3 previously stopped with signal SIGUSR2, User defined signal 2.
    Thread 2 previously stopped with signal SIGUSR1, User defined signal 1.
  Continuing thread 1 (the current thread) with specified signal will
  still deliver the signals noted above to their respective threads.
  Continue anyway? (y or n)

All these scenarios are covered by the new tests.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/
2014-07-25  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention signal passing and "signal" command changes.
	* gdbthread.h (struct thread_suspend_state) <stop_signal>: Extend
	comment.
	* breakpoint.c (until_break_command): Adjust clear_proceed_status
	call.
	* infcall.c (run_inferior_call): Adjust clear_proceed_status call.
	* infcmd.c (proceed_thread_callback, continue_1, step_once)
	(jump_command): Adjust clear_proceed_status call.
	(signal_command): Warn if other thread that are resumed have
	signals that will be delivered.  Adjust clear_proceed_status call.
	(until_next_command, finish_command)
	(proceed_after_attach_callback, attach_command_post_wait)
	(attach_command): Adjust clear_proceed_status call.
	* infrun.c (proceed_after_vfork_done): Likewise.
	(proceed_after_attach_callback): Adjust comment.
	(clear_proceed_status_thread): Clear stop_signal if not in pass
	state.
	(clear_proceed_status_callback): Delete.
	(clear_proceed_status): New 'step' parameter.  Only clear the
	proceed status of threads the command being prepared is about to
	resume.
	(proceed): If passed in an explicit signal, override stop_signal
	with it.  Don't pass the last stop signal to the thread we're
	resuming.
	(init_wait_for_inferior): Adjust clear_proceed_status call.
	(switch_back_to_stepped_thread): Clear the signal if it should not
	be passed.
	* infrun.h (clear_proceed_status): New 'step' parameter.
	(user_visible_resume_ptid): Add comment.
	* linux-nat.c (linux_nat_resume_callback): Don't check whether the
	signal is in pass state.
	* remote.c (append_pending_thread_resumptions): Likewise.
	* mi/mi-main.c (proceed_thread): Adjust clear_proceed_status call.

gdb/doc/
2014-07-25  Pedro Alves  <palves@redhat.com>
	    Eli Zaretskii  <eliz@gnu.org>

	* gdb.texinfo (Signaling) <signal command>: Explain what happens
	with multi-threaded programs.

gdb/testsuite/
2014-07-25  Pedro Alves  <palves@redhat.com>

	* gdb.threads/signal-command-handle-nopass.c: New file.
	* gdb.threads/signal-command-handle-nopass.exp: New file.
	* gdb.threads/signal-command-multiple-signals-pending.c: New file.
	* gdb.threads/signal-command-multiple-signals-pending.exp: New file.
	* gdb.threads/signal-delivered-right-thread.c: New file.
	* gdb.threads/signal-delivered-right-thread.exp: New file.
2014-07-25 16:57:31 +01:00
Pedro Alves c933f875f4 Put the inferior's terminal settings in effect while running (fg) infcalls
The "call" and "print" commands presently always run synchronously, in
the foreground, but GDB currently forgets to put the inferior's
terminal settings into effect while running them, on async-capable
targets, resulting in:

 (gdb) print func ()
 hello world

 Program received signal SIGTTOU, Stopped (tty output).
 0x000000373bceb8d0 in __libc_tcdrain (fd=1) at ../sysdeps/unix/sysv/linux/tcdrain.c:29
 29          return INLINE_SYSCALL (ioctl, 3, fd, TCSBRK, 1);
 The program being debugged was signaled while in a function called from GDB.
 GDB remains in the frame where the signal was received.
 To change this behavior use "set unwindonsignal on".
 Evaluation of the expression containing the function
 (func) will be abandoned.
 When the function is done executing, GDB will silently stop.
 (gdb)

That's because target_terminal_inferior skips actually doing anything
if running in the background, and, nothing is setting sync_execution
while running infcalls:

 void
 target_terminal_inferior (void)
 {
   /* A background resume (``run&'') should leave GDB in control of the
      terminal.  Use target_can_async_p, not target_is_async_p, since at
      this point the target is not async yet.  However, if sync_execution
      is not set, we know it will become async prior to resume.  */
   if (target_can_async_p () && !sync_execution)
     return;

This would best be all cleaned up by making GDB not even call
target_terminal_inferior and try to pass the terminal to the inferior
if running in the background, but that's a more invasive fix that is
better done post-7.8.

This was originally caught by a patch later in this series that makes
catch_command_errors use exception_print instead of
print_any_exception.  Note that print_flush calls serial_drain_output
while print_any_exception doesnt't have that bit.  And,
gdb.gdb/python-selftest.exp does:

 gdb_test "call catch_command_errors(execute_command, \"python print 5\", 0, RETURN_MASK_ALL)" \
   "Python not initialized.* = 0"

which without this fix results in SIGTTOU...

gdb/
2014-07-14  Pedro Alves  <palves@redhat.com>

	* infcall.c (run_inferior_call): Set 'sync_execution' while
	running the inferior call.

gdb/testsuite/
2014-07-14  Pedro Alves  <palves@redhat.com>

	* gdb.base/execution-termios.c: New file.
	* gdb.base/execution-termios.exp: New file.
2014-07-14 19:55:30 +01:00
Yao Qi b67a2c6fd4 Associate dummy_frame with ptid
This patch is to add ptid into dummy_frame and extend frame_id to
dummy_frame_id (which has a ptid field).  With this change, GDB uses
dummy_frame_id (thread ptid and frame_id) to find the dummy frames.

Currently, dummy frames are looked up by frame_id, which isn't
accurate in non-stop or multi-process mode.  The test case
gdb.multi/dummy-frame-restore.exp shows the problem and this patch can
fix it.

Test dummy-frame-restore.exp makes two inferiors stop at
different functions, say, inferior 1 stops at f1 while inferior 2
stops at f2.  Set a breakpoint to a function, do the inferior call
in two inferiors, and GDB has two dummy frames of the same frame_id.
When the inferior call is finished, GDB will look up a dummy frame
from its stack/list and restore the inferior's regcache.  Two
inferiors are finished in different orders, the inferiors' states are
restored differently, which is wrong.  Running dummy-frame-restore.exp
under un-patched GDB, we'll get two fails:

FAIL: gdb.multi/dummy-frame-restore.exp: inf 2 first: after infcall: bt in inferior 2
FAIL: gdb.multi/dummy-frame-restore.exp: inf 2 first: after infcall: bt in inferior 1

With this patch applied, GDB will choose the correct dummy_frame to
restore for a given inferior, because ptid is considered when looking up
dummy frames.  Two fails above are fixed.

Regression tested on x86_64-linux, both native and gdbserver.

gdb:

2014-06-27  Yao Qi  <yao@codesourcery.com>

	* breakpoint.c (check_longjmp_breakpoint_for_call_dummy):
	Change parameter type to 'struct thread_info *'.  Caller
	updated.
	* breakpoint.h (check_longjmp_breakpoint_for_call_dummy):
	Update declaration.
	* dummy-frame.c (struct dummy_frame_id): New.
	(dummy_frame_id_eq): New function.
	(struct dummy_frame) <id>: Change its type to 'struct
	dummy_frame_id'.
	(dummy_frame_push): Add parameter ptid and save it in
	dummy_frame_id.
	(pop_dummy_frame_bpt): Use ptid of dummy_frame instead of
	inferior_ptid.
	(pop_dummy_frame): Assert that the ptid of dummy_frame equals
	to inferior_ptid.
	(lookup_dummy_frame): Change parameter type to 'struct
	dummy_frame_id *'.  Callers updated.  Call dummy_frame_id_eq
	instead of frame_id_eq.
	(dummy_frame_pop): Add parameter ptid.  Callers updated.
	Update comments.  Compose dummy_frame_id and pass it to
	lookup_dummy_frame.
	(dummy_frame_discard): Add parameter ptid.
	(dummy_frame_sniffer): Compose dummy_frame_id and call
	dummy_frame_id_eq instead of frame_id_eq.
	(fprint_dummy_frames): Print ptid.
	* dummy-frame.h: Remove comments.
	(dummy_frame_push): Add ptid in declaration.
	(dummy_frame_pop, dummy_frame_discard): Likewise.

gdb/testsuite:

2014-06-27  Yao Qi  <yao@codesourcery.com>

	* gdb.multi/dummy-frame-restore.exp: New.
	* gdb.multi/dummy-frame-restore.c: New.

gdb/doc:

2014-06-27  Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (Maintenance Commands): Update the output of
	'maint print dummy-frames' command.
2014-06-27 20:06:56 +08:00
Pedro Alves 4ae57c0522 unbreak infcalls
I managed to miss an interaction between the recent *running patch,
and target-async, which resulted in infcalls being completely broken
on GNU/Linux and remote targets (that is, the async-capable targets).

 Temporary breakpoint 1, main () at threads.c:35
 35          long i = 0;
 (gdb) p malloc (0)
 The program being debugged stopped while in a function called from GDB.
 Evaluation of the expression containing the function
 (malloc) will be abandoned.
 When the function is done executing, GDB will silently stop.
 (gdb) p malloc (0)

 Program received signal SIGSEGV, Segmentation fault.
 0x000000000058d7e8 in get_regcache_aspace (regcache=0x0) at ../../src/gdb/regcache.c:281
 281       return regcache->aspace;
 (top-gdb)

The issue is that when running an infcall, the thread is no longer
marked as running, so run_inferior_call is not calling
wait_for_inferior anymore.

Fix this by doing what the comment actually says we do:

  "Do here what `proceed' itself does in sync mode."

And proceed doesn't check whether the target is running.

I notice this is broken in case of the early return in proceed, but we
were broken before in that case anyway, because run_inferior_call will
think the call actually ran.  Seems like we should make proceed have a
boolean return, and go through all callers making use of it, if
necessary.

But for now, just fix the regression.

Tested on x86_64 Fedora 20.

gdb/
2014-05-29  Pedro Alves  <palves@redhat.com>

	* infcall.c (run_inferior_call): Don't check whether the current
	thread is running after the proceed call.
2014-05-29 17:17:30 +01:00
Pedro Alves 45741a9c32 Add new infrun.h header.
Move infrun.c declarations out of inferior.h to a new infrun.h file.

Tested by building on:

 i686-w64-mingw32, enable-targets=all
 x86_64-linux, enable-targets=all
 i586-pc-msdosdjgpp

And also grepped the whole tree for each symbol moved to find where
infrun.h might be necessary.

gdb/
2014-05-22  Pedro Alves  <palves@redhat.com>

	* inferior.h (debug_infrun, debug_displaced, stop_on_solib_events)
	(sync_execution, sched_multi, step_stop_if_no_debug, non_stop)
	(disable_randomization, enum exec_direction_kind)
	(execution_direction, stop_registers, start_remote)
	(clear_proceed_status, proceed, resume, user_visible_resume_ptid)
	(wait_for_inferior, normal_stop, get_last_target_status)
	(prepare_for_detach, fetch_inferior_event, init_wait_for_inferior)
	(insert_step_resume_breakpoint_at_sal)
	(follow_inferior_reset_breakpoints, stepping_past_instruction_at)
	(set_step_info, print_stop_event, signal_stop_state)
	(signal_print_state, signal_pass_state, signal_stop_update)
	(signal_print_update, signal_pass_update)
	(update_signals_program_target, clear_exit_convenience_vars)
	(displaced_step_dump_bytes, update_observer_mode)
	(signal_catch_update, gdb_signal_from_command): Move
	declarations ...
	* infrun.h: ... to this new file.
	* amd64-tdep.c: Include infrun.h.
	* annotate.c: Include infrun.h.
	* arch-utils.c: Include infrun.h.
	* arm-linux-tdep.c: Include infrun.h.
	* arm-tdep.c: Include infrun.h.
	* break-catch-sig.c: Include infrun.h.
	* breakpoint.c: Include infrun.h.
	* common/agent.c: Include infrun.h instead of inferior.h.
	* corelow.c: Include infrun.h.
	* event-top.c: Include infrun.h.
	* go32-nat.c: Include infrun.h.
	* i386-tdep.c: Include infrun.h.
	* inf-loop.c: Include infrun.h.
	* infcall.c: Include infrun.h.
	* infcmd.c: Include infrun.h.
	* infrun.c: Include infrun.h.
	* linux-fork.c: Include infrun.h.
	* linux-nat.c: Include infrun.h.
	* linux-thread-db.c: Include infrun.h.
	* monitor.c: Include infrun.h.
	* nto-tdep.c: Include infrun.h.
	* procfs.c: Include infrun.h.
	* record-btrace.c: Include infrun.h.
	* record-full.c: Include infrun.h.
	* remote-m32r-sdi.c: Include infrun.h.
	* remote-mips.c: Include infrun.h.
	* remote-notif.c: Include infrun.h.
	* remote-sim.c: Include infrun.h.
	* remote.c: Include infrun.h.
	* reverse.c: Include infrun.h.
	* rs6000-tdep.c: Include infrun.h.
	* s390-linux-tdep.c: Include infrun.h.
	* solib-irix.c: Include infrun.h.
	* solib-osf.c: Include infrun.h.
	* solib-svr4.c: Include infrun.h.
	* target.c: Include infrun.h.
	* top.c: Include infrun.h.
	* windows-nat.c: Include infrun.h.
	* mi/mi-interp.c: Include infrun.h.
	* mi/mi-main.c: Include infrun.h.
	* python/py-threadevent.c: Include infrun.h.
2014-05-22 12:29:11 +01:00
Pedro Alves beb460e8d2 make dprintf.exp pass in target async mode
When target-async is enabled, dprintf.exp fails:

 Running ../../../src/gdb/testsuite/gdb.base/dprintf.exp ...
 FAIL: gdb.base/dprintf.exp: 1st dprintf, call
 FAIL: gdb.base/dprintf.exp: 2nd dprintf, call
 FAIL: gdb.base/dprintf.exp: Set dprintf function
 FAIL: gdb.base/dprintf.exp: 1st dprintf, fprintf
 FAIL: gdb.base/dprintf.exp: 2nd dprintf, fprintf

 Breakpoint 2, main (argc=1, argv=0x7fffffffd3f8) at ../../../src/gdb/testsuite/gdb.base/dprintf.c:33
 33        int loc = 1234;
 (gdb) continue
 Continuing.
 kickoff 1234
 also to stderr 1234
 At foo entry
 (gdb) FAIL: gdb.base/dprintf.exp: 1st dprintf, call

The problem is that GDB gave the prompt back to the user too early.

This happens when calling functions while handling an event that
doesn't cause a user visible stop.  dprintf with "set dprintf-style
gdb" is one such case.  This patch adds a test case that has a
breakpoint with a condition that calls a function that returns false,
so that regression testing isn't dependent on the implementation of
dprintf.

The problem happens because run_inferior_call causes GDB to forget
that it is running in sync_execution mode, so any event that runs an
inferior call causes fetch_inferior_event to display the prompt, even
if the event should not result in a user visible stop (that is, gdb
resumes the inferior and waits for the next event).

This patch fixes the issue by noticing when GDB was in sync_execution
mode in run_inferior_call, and taking care to restore this state
afterward.

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

	PR cli/15718
	* infcall.c: Include event-top.h.
	(run_inferior_call): Call async_disable_stdin if needed.

gdb/testsuite/
2014-03-20  Tom Tromey  <tromey@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	PR cli/15718
	* gdb.base/condbreak-call-false.c: New file.
	* gdb.base/condbreak-call-false.exp: New file.
2014-03-20 17:49:51 +00: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
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00