CORE_ADDR step_range_start = 0;
CORE_ADDR step_range_end = 0;
struct frame_id step_frame_id = { 0 };
- struct interp *command_interp = NULL;
+ struct thread_fsm *thread_fsm = NULL;
if (!non_stop)
{
step_frame_id = tp->control.step_frame_id;
exception_resume_breakpoint
= clone_momentary_breakpoint (tp->control.exception_resume_breakpoint);
- command_interp = tp->control.command_interp;
+ thread_fsm = tp->thread_fsm;
/* For now, delete the parent's sr breakpoint, otherwise,
parent/child sr breakpoints are considered duplicates,
tp->control.step_range_end = 0;
tp->control.step_frame_id = null_frame_id;
delete_exception_resume_breakpoint (tp);
- tp->control.command_interp = NULL;
+ tp->thread_fsm = NULL;
}
parent = inferior_ptid;
tp->control.step_frame_id = step_frame_id;
tp->control.exception_resume_breakpoint
= exception_resume_breakpoint;
- tp->control.command_interp = command_interp;
+ tp->thread_fsm = thread_fsm;
}
else
{
fprintf_filtered (file, _("Follow exec mode is \"%s\".\n"), value);
}
-/* EXECD_PATHNAME is assumed to be non-NULL. */
+/* EXEC_FILE_TARGET is assumed to be non-NULL. */
static void
-follow_exec (ptid_t ptid, char *execd_pathname)
+follow_exec (ptid_t ptid, char *exec_file_target)
{
struct thread_info *th, *tmp;
struct inferior *inf = current_inferior ();
int pid = ptid_get_pid (ptid);
ptid_t process_ptid;
+ char *exec_file_host;
+ struct cleanup *old_chain;
/* This is an exec event that we actually wish to pay attention to.
Refresh our symbol table to the newly exec'd program, remove any
process_ptid = pid_to_ptid (pid);
printf_unfiltered (_("%s is executing new program: %s\n"),
target_pid_to_str (process_ptid),
- execd_pathname);
+ exec_file_target);
/* We've followed the inferior through an exec. Therefore, the
inferior has essentially been killed & reborn. */
breakpoint_init_inferior (inf_execd);
- if (*gdb_sysroot != '\0')
- {
- char *name = exec_file_find (execd_pathname, NULL);
+ exec_file_host = exec_file_find (exec_file_target, NULL);
+ old_chain = make_cleanup (xfree, exec_file_host);
- execd_pathname = (char *) alloca (strlen (name) + 1);
- strcpy (execd_pathname, name);
- xfree (name);
- }
+ /* If we were unable to map the executable target pathname onto a host
+ pathname, tell the user that. Otherwise GDB's subsequent behavior
+ is confusing. Maybe it would even be better to stop at this point
+ so that the user can specify a file manually before continuing. */
+ if (exec_file_host == NULL)
+ warning (_("Could not load symbols for executable %s.\n"
+ "Do you need \"set sysroot\"?"),
+ exec_file_target);
/* Reset the shared library package. This ensures that we get a
shlib event when the child reaches "_start", at which point the
inf = add_inferior_with_spaces ();
inf->pid = pid;
- target_follow_exec (inf, execd_pathname);
+ target_follow_exec (inf, exec_file_target);
set_current_inferior (inf);
set_current_program_space (inf->pspace);
gdb_assert (current_program_space == inf->pspace);
- /* That a.out is now the one to use. */
- exec_file_attach (execd_pathname, 0);
-
- /* SYMFILE_DEFER_BP_RESET is used as the proper displacement for PIE
- (Position Independent Executable) main symbol file will get applied by
- solib_create_inferior_hook below. breakpoint_re_set would fail to insert
- the breakpoints with the zero displacement. */
+ /* Attempt to open the exec file. SYMFILE_DEFER_BP_RESET is used
+ because the proper displacement for a PIE (Position Independent
+ Executable) main symbol file will only be computed by
+ solib_create_inferior_hook below. breakpoint_re_set would fail
+ to insert the breakpoints with the zero displacement. */
+ try_open_exec_file (exec_file_host, inf, SYMFILE_DEFER_BP_RESET);
- symbol_file_add (execd_pathname,
- (inf->symfile_flags
- | SYMFILE_MAINLINE | SYMFILE_DEFER_BP_RESET),
- NULL, 0);
-
- if ((inf->symfile_flags & SYMFILE_NO_READ) == 0)
- set_initial_language ();
+ do_cleanups (old_chain);
/* If the target can specify a description, read it. Must do this
after flipping to the new executable (because the target supplied
int hw_step = 1;
if (execution_direction == EXEC_FORWARD
- && gdbarch_software_single_step_p (gdbarch)
- && gdbarch_software_single_step (gdbarch, get_current_frame ()))
- {
- hw_step = 0;
- }
+ && gdbarch_software_single_step_p (gdbarch))
+ hw_step = !insert_single_step_breakpoints (gdbarch);
+
return hw_step;
}
target_pass_signals ((int) GDB_SIGNAL_LAST, signal_pass);
target_resume (resume_ptid, step, sig);
+
+ target_commit_resume ();
}
/* Resume the inferior, but allow a QUIT. This is useful if the user
tp->control.proceed_to_finish = 0;
- tp->control.command_interp = NULL;
tp->control.stepping_command = 0;
/* Discard any remaining commands or status from previous stop. */
struct execution_control_state ecss;
struct execution_control_state *ecs = &ecss;
struct cleanup *old_chain;
+ struct cleanup *defer_resume_cleanup;
int started;
/* If we're stopped at a fork/vfork, follow the branch set by the
if (siggnal != GDB_SIGNAL_DEFAULT)
tp->suspend.stop_signal = siggnal;
- /* Record the interpreter that issued the execution command that
- caused this thread to resume. If the top level interpreter is
- MI/async, and the execution command was a CLI command
- (next/step/etc.), we'll want to print stop event output to the MI
- console channel (the stepped-to line, etc.), as if the user
- entered the execution command on a real GDB console. */
- tp->control.command_interp = command_interp ();
-
resume_ptid = user_visible_resume_ptid (tp->control.stepping_command);
/* If an exception is thrown from this point on, make sure to
until the target stops again. */
tp->prev_pc = regcache_read_pc (regcache);
+ defer_resume_cleanup = make_cleanup_defer_target_commit_resume ();
+
started = start_step_over ();
if (step_over_info_valid_p ())
error (_("Command aborted."));
}
+ do_cleanups (defer_resume_cleanup);
+ target_commit_resume ();
+
discard_cleanups (old_chain);
/* Tell the event loop to wait for it to stop. If the target
struct thread_info *thr = ecs->event_thread;
if (thr != NULL && thr->thread_fsm != NULL)
- thread_fsm_clean_up (thr->thread_fsm);
+ thread_fsm_clean_up (thr->thread_fsm, thr);
if (!non_stop)
{
continue;
switch_to_thread (thr->ptid);
- thread_fsm_clean_up (thr->thread_fsm);
+ thread_fsm_clean_up (thr->thread_fsm, thr);
}
if (ecs->event_thread != NULL)
{
target_terminal_ours ();
observer_notify_sync_execution_done ();
+ ui_register_input_event_handler (ui);
}
}
void
all_uis_check_sync_execution_done (void)
{
- struct switch_thru_all_uis state;
-
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
check_curr_ui_sync_execution_done ();
}
}
-/* A cleanup that restores the execution direction to the value saved
- in *ARG. */
+/* See infrun.h. */
-static void
-restore_execution_direction (void *arg)
+void
+all_uis_on_sync_execution_starting (void)
{
- enum exec_direction_kind *save_exec_dir = (enum exec_direction_kind *) arg;
-
- execution_direction = *save_exec_dir;
+ SWITCH_THRU_ALL_UIS ()
+ {
+ if (current_ui->prompt_state == PROMPT_NEEDED)
+ async_disable_stdin ();
+ }
}
/* Asynchronous version of wait_for_inferior. It is called by the
struct execution_control_state *ecs = &ecss;
struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
struct cleanup *ts_old_chain;
- enum exec_direction_kind save_exec_dir = execution_direction;
int cmd_done = 0;
ptid_t waiton_ptid = minus_one_ptid;
/* Events are always processed with the main UI as current UI. This
way, warnings, debug output, etc. are always consistently sent to
the main console. */
- make_cleanup (restore_ui_cleanup, current_ui);
- current_ui = main_ui;
+ scoped_restore save_ui = make_scoped_restore (¤t_ui, main_ui);
/* End up with readline processing input, if necessary. */
make_cleanup (reinstall_readline_callback_handler_cleanup, NULL);
event. */
target_dcache_invalidate ();
- make_cleanup (restore_execution_direction, &save_exec_dir);
- execution_direction = target_execution_direction ();
+ scoped_restore save_exec_dir
+ = make_scoped_restore (&execution_direction, target_execution_direction ());
ecs->ptid = do_target_wait (waiton_ptid, &ecs->ws,
target_can_async_p () ? TARGET_WNOHANG : 0);
struct thread_fsm *thread_fsm = thr->thread_fsm;
if (thread_fsm != NULL)
- should_stop = thread_fsm_should_stop (thread_fsm);
+ should_stop = thread_fsm_should_stop (thread_fsm, thr);
}
if (!should_stop)
}
gdb_flush (gdb_stdout);
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
stop_print_frame = 0;
stop_waiting (ecs);
return;
print_stack_frame (get_selected_frame (NULL), 0, source_flag, 1);
}
-/* Cleanup that restores a previous current uiout. */
-
-static void
-restore_current_uiout_cleanup (void *arg)
-{
- struct ui_out *saved_uiout = (struct ui_out *) arg;
-
- current_uiout = saved_uiout;
-}
-
/* See infrun.h. */
void
print_stop_event (struct ui_out *uiout)
{
- struct cleanup *old_chain;
struct target_waitstatus last;
ptid_t last_ptid;
struct thread_info *tp;
get_last_target_status (&last_ptid, &last);
- old_chain = make_cleanup (restore_current_uiout_cleanup, current_uiout);
- current_uiout = uiout;
-
- print_stop_location (&last);
+ {
+ scoped_restore save_uiout = make_scoped_restore (¤t_uiout, uiout);
- /* Display the auto-display expressions. */
- do_displays ();
+ print_stop_location (&last);
- do_cleanups (old_chain);
+ /* Display the auto-display expressions. */
+ do_displays ();
+ }
tp = inferior_thread ();
if (tp->thread_fsm != NULL
ptid_t last_ptid;
struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
ptid_t pid_ptid;
- struct switch_thru_all_uis state;
get_last_target_status (&last_ptid, &last);
&& last.kind != TARGET_WAITKIND_EXITED
&& last.kind != TARGET_WAITKIND_NO_RESUMED)
{
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
target_terminal_ours_for_output ();
printf_filtered (_("[Switching to %s]\n"),
if (last.kind == TARGET_WAITKIND_NO_RESUMED)
{
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
if (current_ui->prompt_state == PROMPT_BLOCKED)
{
target_terminal_ours_for_output ();
if (stopped_by_random_signal)
disable_current_display ();
- SWITCH_THRU_ALL_UIS (state)
+ SWITCH_THRU_ALL_UIS ()
{
async_enable_stdin ();
}
signal_print[GDB_SIGNAL_WAITING] = 0;
signal_stop[GDB_SIGNAL_CANCEL] = 0;
signal_print[GDB_SIGNAL_CANCEL] = 0;
+ signal_stop[GDB_SIGNAL_LIBRT] = 0;
+ signal_print[GDB_SIGNAL_LIBRT] = 0;
/* Update cached state. */
signal_cache_update (-1);