Target interface for reverse debugging.
* target.h (enum target_waitkind):
Add new wait event, TARGET_WAITKIND_NO_HISTORY.
(struct target_ops): New method to_can_execute_reverse.
(target_can_execute_reverse): New macro.
* target.c (update_current_target): Inherit to_can_execute_reverse.
Remote interface for reverse debugging.
* remote.c (remote_can_execute_reverse): New target method.
(remote_resume): Check for reverse exec direction, and send
appropriate command to target.
(remote_wait_as): Check target response for NO_HISTORY status.
Also check for empty reply (target doesn't understand "bs" or "bc).
(remote_vcont_resume): Jump out if attempting reverse execution.
Event handling interface for reverse debugging.
* infrun.c (execution_direction): New state variable.
(enum inferior_stop_reason): Add NO_HISTORY reason.
(handle_inferior_event): Handle TARGET_WAITKIND_NO_HISTORY.
Handle stepping over a function call in reverse.
Handle stepping thru a line range in reverse.
Handle setting a step-resume breakpoint in reverse.
Handle stepping into a function in reverse.
Handle stepping between line ranges in reverse.
(print_stop_reason): Print reason for NO_HISTORY.
(step_into_function): Rename to handle_step_into_function.
(handle_step_into_function_backward): New function.
(set_exec_direction_func, show_exec_direction_func): New funcs.
(proceed): No need to singlestep over a breakpoint
when resuming in reverse.
* inferior.h (enum exec_direction_kind): New enum.
(execution_direction): Export new execution state variable.
* breakpoint.c (make_breakpoint_silent): New function.
* breakpoint.h (make_breakpoint_silent): Export.
* infcmd.c (finish_command): Check for reverse exec direction.
(finish_backward): New function, handle finish cmd in reverse.
User interface for reverse execution.
* Makefile.in (reverse.c): New file.
* reverse.c: New file. User interface for reverse execution.
Delete bp_catch_fork and bp_catch_vfork.
(struct breakpoint_ops): Add new methods "insert", "remove"
and "breakpoint_hit".
* breakpoint.c (create_fork_vfork_event_catchpoint)
(create_fork_event_catchpoint, create_vfork_event_catchpoint): Remove.
(insert_catchpoint): Remove handling of bp_catch_fork and
bp_catch_vfork catchpoints, and handle them as bp_catchpoint
catchpoints instead.
(insert_bp_location, update_breakpoints_after_exec)
(remove_breakpoint, bpstat_check_location, bpstat_what)
(allocate_bp_location): Likewise.
(print_it_typical, print_one_breakpoint_location, mention): Remove
handling of bp_catch_fork and bp_catch_vfork breakpoints.
(ep_is_catchpoint, user_settable_breakpoint)
(breakpoint_address_is_meaningful, adjust_breakpoint_address)
(breakpoint_re_set_one, disable_command, enable_command):
Remove use of bp_catch_fork and bp_catch_vfork. Add handling of
bp_catchpoint breakpoints.
(insert_catch_fork, remove_catch_fork, breakpoint_hit_catch_fork)
(print_it_catch_fork, print_one_catch_fork, print_mention_catch_fork):
New functions.
(catch_fork_breakpoint_ops): New static constant.
(insert_catch_vfork, remove_catch_vfork, breakpoint_hit_catch_vfork)
(print_it_catch_vfork, print_one_catch_vfork)
(print_mention_catch_vfork): New functions.
(catch_vfork_breakpoint_ops): New static constant.
(create_catchpoint, create_fork_vfork_event_catchpoint): New functions.
(catch_fork_command_1): Use create_fork_vfork_event_catchpoint
to create the fork and vfork catchpoints.
(gnu_v3_exception_catchpoint_ops): Set new breakpoint_ops fields.
* ada-lang.c (catch_exception_breakpoint_ops): Set new breakpoint_ops
fields.
(catch_exception_unhandled_breakpoint_ops): Likewise.
(catch_assert_breakpoint_ops): Likewise.
* breakpoint.c (breakpoint_init_inferior): Clean up the moribund
locations list.
(moribund_breakpoint_here_p): Record the moribund
location in the moribund_locations vector.
* breakpoint.h (moribund_breakpoint_here_p): Declare.
(displaced_step_fixup): Check if the breakpoint the thread was
trying to step over has been removed since having been placed in
the displaced stepping queue.
(adjust_pc_after_break): In non-stop mode, check for a moribund
breakpoint at the stop pc.
(handle_inferior_event): Don't retire moribund breakpoints on
TARGET_WAITKIND_IGNORE.
gdb/testsuite/
* gdb.mi/mi-nsmoribund.exp, gdb.mi/nsmoribund.c: New test.
continuations.
* gdbthread.h (struct thread_info): Add comments around
continuations and intermediate_continuations.
(save_infrun_state, load_infrun_state): Delete continuations and
intermediate_continuations arguments.
* infrun.c (fetch_inferior_event): Only call normal_stop if
stop_soon is NO_STOP_QUIETLY.
(context_switch): Don't context-switch the continuations.
* thread.c (clear_thread_inferior_resources): Discard all
continuations of the thread we're clearing.
(save_infrun_state, load_infrun_state): Delete continuations and
intermediate_continuations arguments, and the code referencing
them.
* utils.c: Include "gdbthread.h".
(cmd_continuation, intermediate_continuation): Delete.
(add_continuation): Add thread_info* argument. Install the
continuation on it.
(restore_thread_cleanup): New.
(do_all_continuations_ptid, do_all_continuations_thread_callback):
New.
(do_all_continuations): Reimplement.
(discard_all_continuations_thread_callback,
discard_all_continuations_thread): New.
(discard_all_continuations): Reimplement.
(add_intermediate_continuation): Add thread_info* argument.
Install the continuation on it.
(do_all_intermediate_continuations_thread_callback)
(do_all_intermediate_continuations_thread): New.
(do_all_intermediate_continuations): Reimplement.
(discard_all_intermediate_continuations_thread_callback): New.
(discard_all_intermediate_continuations_thread): New.
(discard_all_intermediate_continuations): Reimplement.
* breakpoint.c (until_break_command): Install the continuation on
the current thread.
* defs.h (cmd_continuation, intermediate_continuation): Delete.
(struct thread_info): Forward declare.
(add_continuation, add_intermediate_continuation): Add
thread_info* argument.
(do_all_continuations_thread, discard_all_continuations_thread)
(do_all_intermediate_continuations_thread)
(discard_all_intermediate_continuations_thread): Declare.
* inf-loop.c (inferior_event_handler): In non-stop only run
continuations on the thread that stopped. In all-stop, run
continuations on all threads.
* infcmd.c (step_once, finish_command): Adjust.
* breakpoint.h (bpstat_do_actions): Remove bpstat* argument.
* breakpoint.c (bpstat_do_actions): Rename to ...
(bpstat_do_actions_1): ... this. Make static. Change return type
to int. Return true if a breakpoint proceeded.
(bpstat_do_actions): New, as wrapper around bpstat_do_actions_1.
(delete_breakpoint): Don't reference the global stop_bpstat; it's
gone.
* gdbthread.h (struct thread_info): Add stop_bpstat.
(save_infrun_state, load_infrun_state): Remove stop_bpstat
argument.
* thread.c (load_infrun_state, save_infrun_state): Remove
stop_bpstat argument, and the code referencing it.
* infcall.c: Include "gdbthread.h".
(call_function_by_hand): Adjust.
* exceptions.c: Include "gdbthread.h".
(throw_exception): Adjust.
* infcmd.c (stop_bpstat): Delete.
(continue_command): In all-stop, set the ignore count on the
thread that reported the stop. In non-stop, set it on the current
thread.
(finish_command_continuation): Adjust.
(program_info): Adjust.
* infrun.c (clear_proceed_status): Adjust.
(context_switch): Don't context-switch stop_bpstat.
(handle_inferior_event): Adjust.
(normal_stop): Adjust.
(save_inferior_status, restore_inferior_status): Adjust.
* inf-loop.c (inferior_event_handler): Remove parameter to
bpstat_do_actions call.
* top.c (command_loop): Remove parameter to bpstat_do_actions
call. Call it unconditionally.
* event-top.c (command_handler): Ditto.
* python/python.c (execute_gdb_command): Ditto.
non-permanent breakpoints.
(bpstat_stop_status): Change enable_state to bp_disabled only for
non-permanent breakpoints.
(bp_loc_is_permanent): New function.
(create_breakpoint): Check if the location points to a permanent
breakpoint and if it does, make breakpoint permanent.
(update_breakpoint_locations): Make sure new locations of permanent
breakpoints are properly initialized.
* i386-tdep.c (i386_skip_permanent_breakpoint): New function.
(i386_gdbarch_init): Set gdbarch_skip_permanent_breakpoint.
* gdb.arch/i386-bp_permanent.exp: New test.
(create_overlay_event_breakpoint_1): ... this. Add OBJFILE parameter.
(create_overlay_event_breakpoint): Loop over all objfiles to install
multiple instances of the overlay event breakpoint if present.
* breakpoint.c (always_inserted_auto, always_inserted_on)
(always_inserted_off, always_inserted_enums): New.
(always_inserted_mode): Change type to char* and point to
always_inserted_auto.
(show_always_inserted_mode): In auto mode, also show the current
effect of the option.
(breakpoints_always_inserted_mode): Adjust for the new auto mode.
(_initialize_breakpoint): Make the "set breakpoints
always-inserted" command an enum command. Extend help to describe
the auto mode.
gdb/doc/
* gdb.texinfo (breakpoint always-inserted) Describe the auto mode
setting, and make it the default.
(Non-Stop Mode): Remove "set breakpoints always-inserted 1" from
non-stop script example.
Rewrite continuations internals on top of cleanups and plug
continuation arguments leaks.
* defs.h (struct continuation): Make it opaque.
(add_continuation, add_intermediate_continuation): Drop the int
argument of the continuation hook argument. Add
continuation_free_args argument.
(do_all_continuations, do_all_intermediate_continuations): Drop
the error_p argument.
* utils.c (add_continuation): Drop the int argument of the
continuation hook argument. Add continuation_free_args argument.
Reimplement on top of cleanups.
(do_all_continuations): Drop error argument. Reimplement on top
of cleanups.
(discard_all_continuations): Reimplement on top of cleanups.
(add_intermediate_continuation): Drop the int argument of the
continuation hook argument. Add continuation_free_args argument.
Reimplement on top of cleanups.
(do_all_intermediate_continuations): Drop error argument.
Reimplement on top of cleanups.
(discard_all_intermediate_continuations): Reimplement on top of
cleanups.
* breakpoint.c (until_break_command_continuation): Drop error
argument. Add xfree as continuation argument deleter.
* inf-loop.c (inferior_event_handler): On error, discard all
continuations. Adjust to new do_all_intermediate_continuations
and do_all_continuations interfaces.
* infcmd.c (step_1_continuation): Drop error_p argument. Adjust.
Pass xfree as continuation argument deleter.
(finish_command_continuation): Drop error_p argument. Adjust.
(finish_command_continuation_free_arg): New.
(finish_command): Pass finish_command_continuation_free_arg as
continuation argument deleter. Adjust to new do_all_continuations
interfaces.
(attach_command_continuation): Drop error_p argument.
(attach_command_continuation_free_args): New.
(attach_command): Pass attach_command_continuation_free_args as
continuation argument deleter.
* interps.c (interp_set): Adjust to new do_all_continuations
interfaces.
* event-top.c (stdin_event_handler): In error, also discard the
intermediate continuations.
* top.c (execute_command): Remove unused arg1 and arg2 locals.
* breakpoint.c (struct until_break_command_continuation_args):
New.
(until_break_command_continuation): Take a void* instead of a
continuations_arg. Adjust.
(until_break_command): Adjust to use struct
until_break_command_continuation_args instead of struct
continuation_arg.
* infcmd.c (struct step_1_continuation_args): New.
(step_1_continuation): Take a void* instead of a
continuations_arg. Adjust to use struct step_1_continuation_args.
(step_once): Adjust to use struct step_1_continuation_args.
(struct finish_command_continuation_args): New.
(finish_command_continuation): Take a void* instead of a
continuations_arg. Adjust to use struct
finish_command_continuation_args.
(finish_command): Adjust to use struct
finish_command_continuation_args.
(struct attach_command_continuation_args): New.
(attach_command_continuation): Take a void* instead of a
continuations_arg. Adjust to use struct
attach_command_continuation_args.
(attach_command): Adjust to use struct
attach_command_continuation_args.
* defs.h (struct continuation_arg): Delete.
(struct continuation): Replace the struct continuation_arg*
parameter of continuation_hook by a void*. Replace "arg_list"
member by a new "args" member with void* type.
(add_continuation, add_intermediate_continuation): Replace struct
continuation_arg type usages by void* usages.
* utils.c (add_continuation, do_all_continuations)
(add_intermediate_continuation)
(do_all_intermediate_continuations): Replace struct
continuation_arg type usages by void* usages. Pass "args" instead
of "arg_list".
* gdbthread.h: Remove unneeded forward declarations.
Include "inferior.h".
(struct thread_info): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi and stop_signal members.
(save_infrun_state): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat parameters.
(load_infrun_state): Add continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat parameters.
* thread.c (load_infrun_state): In non-stop mode, load
continuations, intermediate_continuations, proceed_to_finish,
step_over_calls, stop_step, step_multi and stop_signal.
(save_infrun_state): Store continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(save_infrun_state): Store continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(free_thread): Clear The thread's stop_bpstat.
* inferior.h (context_switch_to): Declare.
* infrun.c (ecss): New global.
(context_switch): Context switch continuations,
intermediate_continuations, proceed_to_finish, step_over_calls,
stop_step, step_multi, stop_signal and stop_bpstat.
(wait_for_inferior): Use global ecss.
(async_ecss, async_ecs): Delete.
(fetch_inferior_event): Use global ecss.
(context_switch_to): New.
* top.c (execute_command): In non-stop, only check if the current
thread is running, in all-stop, check if there's any thread
running.
* breakpoint.c (bpstat_remove_breakpoint): New.
(bpstat_remove_breakpoint_callback): New.
(delete_breakpoint): Clear the stop_bpstats of all threads.
* mi/mi-main.c (mi_cmd_execute): In non-stop, only check if the
current thread is running, in all-stop, check if there's any
thread running.
* Makefile.in (gdbthread_h): Depend on $(inferior_h).
* target.h (struct target_waitstatus): Store related_pid as a ptid.
(inferior_has_forked, inferior_has_vforked, inferior_has_execd):
Take a ptid_t.
* breakpoint.h (struct breakpoint): Change forked_inferior_pid
type to ptid.
* breakpoint.c (print_it_typical, bpstat_check_location)
(print_one_breakpoint_location, set_raw_breakpoint_without_location)
(create_fork_vfork_event_catchpoint): Adjust.
* infrun.c (fork_event): Change parent_pid and child_pid types to
ptid.
(follow_exec, inferior_has_forked, inferior_has_vforked)
(inferior_has_execd): Take a ptid_t and don't trim it.
* linux-thread-db.c (thread_db_wait): Don't trim the returned ptid.
* linux-nat.c (linux_child_follow_fork): Adjust.
* inf-ptrace.c (inf_ptrace_wait): Adjust.
* inf-ttrace.c (inf_ttrace_wait): Adjust.
* win32-nat.c (get_win32_debug_event): Don't set related_pid.
* inferior.h (target_executing): Delete.
* gdbthread.h (struct thread_info): Add executing_ field.
(set_executing, is_executing): New.
* thread.c (main_thread_executing): New.
(init_thread_list): Clear it and also main_thread_running.
(is_running): Return false if target has no execution.
(any_running, is_executing, set_executing): New.
* top.c: Include "gdbthread.h".
(target_executing): Delete.
(execute_command): Replace target_executing check by any_running.
* event-top.c: Include "gdbthread.h".
(display_gdb_prompt, command_handler): Replace target_executing by
is_running.
* inf-loop.c: Include "gdbthread.h". Don't mark as not executing
here. Replace target_executing by is_running.
* infrun.c (handle_inferior_event): Mark all threads as
not-executing.
* linux-nat.c (linux_nat_resume): Don't mark thread as executing
here.
* stack.c (get_selected_block): Return null if inferior is
executing.
* target.c (target_resume): Mark resumed ptid as executing.
* breakpoint.c (until_break_command): Replace target_executing
check by is_executing.
* remote.c (remote_async_resume): Don't mark inferior as executing
here.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Replace target_executing
by any_running.
* mi/mi-main.c (mi_cmd_exec_interrupt, mi_cmd_execute)
(mi_execute_async_cli_command): Replace target_executing by
is_running.
* frame.c (get_current_frame): Error out if the current thread is
executing.
(has_stack_frames): New.
(get_selected_frame, deprecated_safe_get_selected_frame): Check
has_stack_frames.
* Makefile.in (event-top.o, frame.o, inf-loop.o, top.o): Depend on
$(gdbthread_h).
* breakpoint.c (bpstat_copy): Call RELEASE_VALUE on the new OLD_VAL.
gdb/testsuite/
* gdb.base/value-double-free.exp, gdb.base/value-double-free.c: New.
(gdb_stdint_h, gdb_stdint.h, stamp-int): Delete. Remove
all dependencies on $(gdb_stdint_h).
(distclean): Do not delete gdb_stdint.h.
* acinclude.m4: Do not use stdint.m4.
* configure.ac: Set GNULIB_STDINT_H. Remove tests for stdint.h,
uintptr_t, and gdb_stdint.h.
* defs.h: Include <stdint.h>.
* gdb_thread_db.h: Assume stdint.h is already included.
* breakpoint.c, findcmd.c, hppa-tdep.c, inf-ptrace.c, proc-service.c,
rs6000-nat.c, spu-linux-nat.c, target.c, win32-nat.c: Do not
include gdb_stdint.h.
* configure, config.in: Regenerate.
* defs.h (make_cleanup_restore_integer): New declaration.
(struct cleanup): New field free_arg.
(make_my_cleanup_2): New.
* utils.c (restore_integer_closure, restore_integer)
(make_cleanup_restore_integer): New.
(make_my_cleanup): Initialize the free_arg field and
renamed to make_my_cleanup_2.
(do_my_cleanups): Call free_arg.
(discard_cleanups): Call free_arg.
* breakpoint.c (restore_always_inserted_mode): Remove.
(update_breakpoints_after_exec): Use make_cleanup_restore_integer.
temporary catchpoints. In MI add missing fields 'reason', 'disp',
'bkptno'.
(print_mention_exception_catchpoint): Add 'Temporary' for temporary
catchpoints.
(handle_gnu_v3_exceptions): Use tempflag.
to_watchpoint_addr_within_range.
(target_watchpoint_addr_within_range): New function.
* target.c (update_current_target): Inherit
to_watchpoint_addr_within_range, defaulting to
default_watchpoint_addr_within_range.
(default_watchpoint_addr_within_range): New function.
(debug_to_watchpoint_addr_within_range): New function.
(setup_target_debug): Set to_watchpoint_addr_within_range.
* ppc-linux-nat.c (ppc_linux_watchpoint_addr_within_range):
New function.
(_initialize_ppc_linux_nat): Set to_watchpoint_addr_within_range.
* breakpoint.c (watchpoints_triggered): Use
target_watchpoint_addr_within_range.
* gdbint.texinfo (Algorithms): Describe
target_watchpoint_addr_within_range.
* breakpoint.c (create_breakpoint): Add breakpoint_ops argument and
assign its value to the breakpoint created.
(create_breakpoints): Add breakpoint_ops argument and pass it
to create_breakpoint call.
(break_command_really): Add breakpoint_ops argument and pass/assign
appropriately.
(break_command_1): Pass NULL as ops argument.
(set_breakpoint): Pass NULL as ops argument.
(print_one_exception_catchpoint): Print <PENDING> if no loc available.
(handle_gnu_v3_exceptions): Call generic breakpoint code to insert
catch and throw catchpoints.
* breakpoint.c (until_break_command_continuation): Add
the 'error' parameter. Directly delete the breakoint as
opposed to running cleanups.
(until_break_command): Install continuation only
after starting the target. Don't use exec cleanups,
use ordinary cleanups. Discard cleanups is successfully
started the target in async mode.
(make_cleanup_delete_breakpoint): Remove.
* breakpoint.h (make_cleanup_delete_breakpoint): Remove
declaration.
* defs.h (do_exec_cleanups, make_exec_cleanup): Remove
declarations.
(struct continations): Add the 'error' parameter to the
continuation_hook field.
(add_continuation, do_all_continuations)
(add_intermediate_continuation)
(do_all_intermediate_continuations): Add the 'error' parameter.
* exceptions.c (throw_exception): Don't call do_exec_cleanups.
* inf-loop.c (inferior_event_handler): Instead of calling
discard_all_continuations, use do_all_continuations with 1 as
'error' parameter. Pass 0 as 'error' parameter in existing uses
of discard_all_continuations.
* infcmd.c (step_1): Do not use exec cleanup. For async case, discard
cleanups.
(step_once): Install continuation only after resuming the target.
(step_1_continuation): Disable longjmp breakpoint on error.
(finish_command_continuation): Add the error parameter. Delete
the finish breakpoint directly, do not use cleanups.
(finish_command): Do not use exec_cleanups. Always setup
continuation. For sync case, immediately run them.
(attach_command_continuation): Add the error parameter.
* infrun.c (fetch_inferior_event): Do not use exec cleanups to
remove step_resume_breakpoint -- adjust delete it directly.
* interps.c (interp_set): Adjust call to do_all_continations.
* mi/mi-interp.c (mi_interpreter_exec_continuation): Do not
do exec cleanups.
* mi/mi-main.c (mi_cmd_target_select): Do not do exec
cleanups.
(mi_cmd_execute): Do not use exec_cleanup.
(mi_execute_async_cli_command): Simplify the string concatenation
logic. Do no use exec cleanup.
(mi_exec_async_cli_cmd_continuation): New parameter error.
Free last_async_command.
* top.c (command_line_handler_continuation): New parameter error.
* utils.c (exec_cleanup_chain, make_exec_cleanup)
(do_exec_cleanups): Remove.
(add_continuation, do_all_continations)
(add_intermediate_continuation)
(do_all_intermediate_continuations): New parameter error.
* infrun.c (normal_stop) Move breakpoint_auto_delete further down
to allow printing to 'see' real reason of stop. This fixes PR 2424.
* breakpoint.c (bpdisp_texst): New function. The function takes over
the role of bpstats static array in print_one_breakpoint_location.
(print_it_typical): Print "Temporary breakpoint" instead
of just "Breakpoint" when breakpoint is, well, temporary. For mi-like
protocols, print disp field.
(print_one_breakpoint_location): Removed bpdisps static definition.
Call new bpstat_text function to get value for 'disp' field.
(mention): Print "Temporary breakpoint" instead of just "Breakpoint".
* Makefile.in (infcmd.o, inf-loop.o): Update dependencies.
* breakpoint.c (bpstat_do_actions): In async mode,
don't jump to top expecting stop_bpstat to be already
updated.
* event-loop.c (start_event_loop): Call async_enable_stdin
on exception.
* event-top.c (async_enable_stdin): Do nothing if sync_execution
is not set.
(command_handler): Do not setup continuation here.
(command_line_handler_continuation): Move to...
* top.c (command_line_handler_continuation): ... here.
(execute_command): In async mode, register continuation.
Don't check frame's language in running in async mode.
* exceptions.c (throw_exception): Don't do exec_error_cleanups.
* inf-loop.c (complete_execution): Inline into...
(inferior_event_handler): ... here. Clear target_executing before
doing any cleanups. Don't try to show prompt if the target was
resumed.
* infcmd.c (signal_command): Add support for async mode.
(finish_command): Only add continuation if the target was
successfully resumed.
* remote.c (init_async_opts): Register to_get_thread_local_address
handler.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Don't mess
with sync_execution.
* tui/tui-interp.c (tui_command_loop): Call async_enable_stdin
on exception.