/* Target-struct-independent code to start (run) and stop an inferior
process.
- Copyright (C) 1986-2016 Free Software Foundation, Inc.
+ Copyright (C) 1986-2017 Free Software Foundation, Inc.
This file is part of GDB.
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
static struct step_over_info step_over_info;
/* Record the address of the breakpoint/instruction we're currently
- stepping over. */
+ stepping over.
+ N.B. We record the aspace and address now, instead of say just the thread,
+ because when we need the info later the thread may be running. */
static void
set_step_over_info (struct address_space *aspace, CORE_ADDR address,
step_over_what step_what;
int must_be_in_line;
+ gdb_assert (!tp->stop_requested);
+
next = thread_step_over_chain_next (tp);
/* If this inferior already has a displaced step in process,
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;
}
{
struct thread_info *tp = inferior_thread ();
+ gdb_assert (!tp->stop_requested);
+
/* Install inferior's terminal modes. */
target_terminal_inferior ();
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
single-step). */
int step;
+ gdb_assert (!tp->stop_requested);
gdb_assert (!thread_is_in_step_over_chain (tp));
QUIT;
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
static void process_event_stop_test (struct execution_control_state *ecs);
static int switch_back_to_stepped_thread (struct execution_control_state *ecs);
-/* Callback for iterate over threads. If the thread is stopped, but
- the user/frontend doesn't know about that yet, go through
- normal_stop, as if the thread had just stopped now. ARG points at
- a ptid. If PTID is MINUS_ONE_PTID, applies to all threads. If
- ptid_is_pid(PTID) is true, applies to all threads of the process
- pointed at by PTID. Otherwise, apply only to the thread pointed by
- PTID. */
-
-static int
-infrun_thread_stop_requested_callback (struct thread_info *info, void *arg)
-{
- ptid_t ptid = * (ptid_t *) arg;
-
- if ((ptid_equal (info->ptid, ptid)
- || ptid_equal (minus_one_ptid, ptid)
- || (ptid_is_pid (ptid)
- && ptid_get_pid (ptid) == ptid_get_pid (info->ptid)))
- && is_running (info->ptid)
- && !is_executing (info->ptid))
- {
- struct cleanup *old_chain;
- struct execution_control_state ecss;
- struct execution_control_state *ecs = &ecss;
-
- memset (ecs, 0, sizeof (*ecs));
-
- old_chain = make_cleanup_restore_current_thread ();
-
- overlay_cache_invalid = 1;
- /* Flush target cache before starting to handle each event.
- Target was running and cache could be stale. This is just a
- heuristic. Running threads may modify target memory, but we
- don't get any event. */
- target_dcache_invalidate ();
-
- /* Go through handle_inferior_event/normal_stop, so we always
- have consistent output as if the stop event had been
- reported. */
- ecs->ptid = info->ptid;
- ecs->event_thread = info;
- ecs->ws.kind = TARGET_WAITKIND_STOPPED;
- ecs->ws.value.sig = GDB_SIGNAL_0;
-
- handle_inferior_event (ecs);
-
- if (!ecs->wait_some_more)
- {
- /* Cancel any running execution command. */
- thread_cancel_execution_command (info);
-
- normal_stop ();
- }
-
- do_cleanups (old_chain);
- }
-
- return 0;
-}
-
/* This function is attached as a "thread_stop_requested" observer.
Cleanup local state that assumed the PTID was to be resumed, and
report the stop to the frontend. */
{
struct thread_info *tp;
- /* PTID was requested to stop. Remove matching threads from the
- step-over queue, so we don't try to resume them
- automatically. */
+ /* PTID was requested to stop. If the thread was already stopped,
+ but the user/frontend doesn't know about that yet (e.g., the
+ thread had been temporarily paused for some step-over), set up
+ for reporting the stop now. */
ALL_NON_EXITED_THREADS (tp)
if (ptid_match (tp->ptid, ptid))
{
+ if (tp->state != THREAD_RUNNING)
+ continue;
+ if (tp->executing)
+ continue;
+
+ /* Remove matching threads from the step-over queue, so
+ start_step_over doesn't try to resume them
+ automatically. */
if (thread_is_in_step_over_chain (tp))
thread_step_over_chain_remove (tp);
- }
- iterate_over_threads (infrun_thread_stop_requested_callback, &ptid);
+ /* If the thread is stopped, but the user/frontend doesn't
+ know about that yet, queue a pending event, as if the
+ thread had just stopped now. Unless the thread already had
+ a pending event. */
+ if (!tp->suspend.waitstatus_pending_p)
+ {
+ tp->suspend.waitstatus_pending_p = 1;
+ tp->suspend.waitstatus.kind = TARGET_WAITKIND_STOPPED;
+ tp->suspend.waitstatus.value.sig = GDB_SIGNAL_0;
+ }
+
+ /* Clear the inline-frame state, since we're re-processing the
+ stop. */
+ clear_inline_frame_state (tp->ptid);
+
+ /* If this thread was paused because some other thread was
+ doing an inline-step over, let that finish first. Once
+ that happens, we'll restart all threads and consume pending
+ stop events then. */
+ if (step_over_info_valid_p ())
+ continue;
+
+ /* Otherwise we can process the (new) pending event now. Set
+ it so this pending event is considered by
+ do_target_wait. */
+ tp->resumed = 1;
+ }
}
static void
const struct target_waitstatus *ws)
{
char *status_string = target_waitstatus_to_string (ws);
- struct ui_file *tmp_stream = mem_fileopen ();
- char *text;
+ string_file stb;
/* The text is split over several lines because it was getting too long.
Call fprintf_unfiltered (gdb_stdlog) once so that the text is still
output as a unit; we want only one timestamp printed if debug_timestamp
is set. */
- fprintf_unfiltered (tmp_stream,
- "infrun: target_wait (%d.%ld.%ld",
- ptid_get_pid (waiton_ptid),
- ptid_get_lwp (waiton_ptid),
- ptid_get_tid (waiton_ptid));
+ stb.printf ("infrun: target_wait (%d.%ld.%ld",
+ ptid_get_pid (waiton_ptid),
+ ptid_get_lwp (waiton_ptid),
+ ptid_get_tid (waiton_ptid));
if (ptid_get_pid (waiton_ptid) != -1)
- fprintf_unfiltered (tmp_stream,
- " [%s]", target_pid_to_str (waiton_ptid));
- fprintf_unfiltered (tmp_stream, ", status) =\n");
- fprintf_unfiltered (tmp_stream,
- "infrun: %d.%ld.%ld [%s],\n",
- ptid_get_pid (result_ptid),
- ptid_get_lwp (result_ptid),
- ptid_get_tid (result_ptid),
- target_pid_to_str (result_ptid));
- fprintf_unfiltered (tmp_stream,
- "infrun: %s\n",
- status_string);
-
- text = ui_file_xstrdup (tmp_stream, NULL);
+ stb.printf (" [%s]", target_pid_to_str (waiton_ptid));
+ stb.printf (", status) =\n");
+ stb.printf ("infrun: %d.%ld.%ld [%s],\n",
+ ptid_get_pid (result_ptid),
+ ptid_get_lwp (result_ptid),
+ ptid_get_tid (result_ptid),
+ target_pid_to_str (result_ptid));
+ stb.printf ("infrun: %s\n", status_string);
/* This uses %s in part to handle %'s in the text, but also to avoid
a gcc error: the format attribute requires a string literal. */
- fprintf_unfiltered (gdb_stdlog, "%s", text);
+ fprintf_unfiltered (gdb_stdlog, "%s", stb.c_str ());
xfree (status_string);
- xfree (text);
- ui_file_delete (tmp_stream);
}
/* Select a thread at random, out of those which are resumed and have
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)
return 0;
}
+/* If the event thread has the stop requested flag set, pretend it
+ stopped for a GDB_SIGNAL_0 (i.e., as if it stopped due to
+ target_stop). */
+
+static bool
+handle_stop_requested (struct execution_control_state *ecs)
+{
+ if (ecs->event_thread->stop_requested)
+ {
+ ecs->ws.kind = TARGET_WAITKIND_STOPPED;
+ ecs->ws.value.sig = GDB_SIGNAL_0;
+ handle_signal_stop (ecs);
+ return true;
+ }
+ return false;
+}
+
/* Auxiliary function that handles syscall entry/return events.
It returns 1 if the inferior should keep going (and GDB
should ignore the event), or 0 if the event deserves to be
= bpstat_stop_status (get_regcache_aspace (regcache),
stop_pc, ecs->ptid, &ecs->ws);
+ if (handle_stop_requested (ecs))
+ return 0;
+
if (bpstat_causes_stop (ecs->event_thread->control.stop_bpstat))
{
/* Catchpoint hit. */
}
}
+ if (handle_stop_requested (ecs))
+ return 0;
+
/* If no catchpoint triggered for this, then keep going. */
keep_going (ecs);
return 1;
= bpstat_stop_status (get_regcache_aspace (regcache),
stop_pc, ecs->ptid, &ecs->ws);
+ if (handle_stop_requested (ecs))
+ return;
+
if (bpstat_causes_stop (ecs->event_thread->control.stop_bpstat))
{
/* A catchpoint triggered. */
case TARGET_WAITKIND_SPURIOUS:
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_SPURIOUS\n");
+ if (handle_stop_requested (ecs))
+ return;
if (!ptid_equal (ecs->ptid, inferior_ptid))
context_switch (ecs->ptid);
resume (GDB_SIGNAL_0);
case TARGET_WAITKIND_THREAD_CREATED:
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_THREAD_CREATED\n");
+ if (handle_stop_requested (ecs))
+ return;
if (!ptid_equal (ecs->ptid, inferior_ptid))
context_switch (ecs->ptid);
if (!switch_back_to_stepped_thread (ecs))
}
gdb_flush (gdb_stdout);
- target_mourn_inferior ();
+ target_mourn_inferior (inferior_ptid);
stop_print_frame = 0;
stop_waiting (ecs);
return;
= bpstat_stop_status (get_regcache_aspace (get_current_regcache ()),
stop_pc, ecs->ptid, &ecs->ws);
+ if (handle_stop_requested (ecs))
+ return;
+
/* If no catchpoint triggered for this, then keep going. Note
that we're interested in knowing the bpstat actually causes a
stop, not just if it may explain the signal. Software
current_inferior ()->waiting_for_vfork_done = 0;
current_inferior ()->pspace->breakpoints_not_allowed = 0;
+
+ if (handle_stop_requested (ecs))
+ return;
+
/* This also takes care of reinserting breakpoints in the
previously locked inferior. */
keep_going (ecs);
xfree (ecs->ws.value.execd_pathname);
ecs->ws.value.execd_pathname = NULL;
+ if (handle_stop_requested (ecs))
+ return;
+
/* If no catchpoint triggered for this, then keep going. */
if (!bpstat_causes_stop (ecs->event_thread->control.stop_bpstat))
{
case TARGET_WAITKIND_STOPPED:
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_STOPPED\n");
- ecs->event_thread->suspend.stop_signal = ecs->ws.value.sig;
handle_signal_stop (ecs);
return;
delete_just_stopped_threads_single_step_breakpoints ();
stop_pc = regcache_read_pc (get_thread_regcache (inferior_ptid));
+
+ if (handle_stop_requested (ecs))
+ return;
+
observer_notify_no_history ();
stop_waiting (ecs);
return;
continue;
}
+ gdb_assert (!tp->stop_requested);
+
/* If some thread needs to start a step-over at this point, it
should still be in the step-over queue, and thus skipped
above. */
back an event. */
gdb_assert (ecs->event_thread->control.trap_expected);
- if (ecs->event_thread->suspend.stop_signal == GDB_SIGNAL_TRAP)
- clear_step_over_info ();
+ clear_step_over_info ();
}
if (!target_is_non_stop_p ())
gdb_assert (ecs->ws.kind == TARGET_WAITKIND_STOPPED);
+ ecs->event_thread->suspend.stop_signal = ecs->ws.value.sig;
+
/* Do we need to clean up the state of a thread that has
completed a displaced single-step? (Doing so usually affects
the PC, so do it here, before we set stop_pc.) */
if (random_signal)
random_signal = !stopped_by_watchpoint;
+ /* Always stop if the user explicitly requested this thread to
+ remain stopped. */
+ if (ecs->event_thread->stop_requested)
+ {
+ random_signal = 1;
+ if (debug_infrun)
+ fprintf_unfiltered (gdb_stdlog, "infrun: user-requested stop\n");
+ }
+
/* For the program's own signals, act according to
the signal handling tables. */
&& ecs->event_thread->control.trap_expected
&& ecs->event_thread->control.step_resume_breakpoint == NULL)
{
- int was_in_line;
-
/* We were just starting a new sequence, attempting to
single-step off of a breakpoint and expecting a SIGTRAP.
Instead this signal arrives. This signal will take us out
"infrun: signal arrived while stepping over "
"breakpoint\n");
- was_in_line = step_over_info_valid_p ();
- clear_step_over_info ();
insert_hp_step_resume_breakpoint_at_frame (frame);
ecs->event_thread->step_after_step_resume_breakpoint = 1;
/* Reset trap_expected to ensure breakpoints are re-inserted. */
ecs->event_thread->control.trap_expected = 0;
- if (target_is_non_stop_p ())
- {
- /* Either "set non-stop" is "on", or the target is
- always in non-stop mode. In this case, we have a bit
- more work to do. Resume the current thread, and if
- we had paused all threads, restart them while the
- signal handler runs. */
- keep_going (ecs);
-
- if (was_in_line)
- {
- restart_threads (ecs->event_thread);
- }
- else if (debug_infrun)
- {
- fprintf_unfiltered (gdb_stdlog,
- "infrun: no need to restart threads\n");
- }
- return;
- }
-
/* If we were nexting/stepping some other thread, switch to
it, so that we don't continue it, losing control. */
if (!switch_back_to_stepped_thread (ecs))
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, "infrun: stop_waiting\n");
- clear_step_over_info ();
-
/* Let callers know we don't want to wait for the inferior anymore. */
ecs->wait_some_more = 0;
{
/* For CLI-like interpreters, print nothing. */
- if (ui_out_is_mi_like_p (uiout))
+ if (uiout->is_mi_like_p ())
{
- ui_out_field_string (uiout, "reason",
+ uiout->field_string ("reason",
async_reason_lookup (EXEC_ASYNC_END_STEPPING_RANGE));
}
}
print_signal_exited_reason (struct ui_out *uiout, enum gdb_signal siggnal)
{
annotate_signalled ();
- if (ui_out_is_mi_like_p (uiout))
- ui_out_field_string
- (uiout, "reason", async_reason_lookup (EXEC_ASYNC_EXITED_SIGNALLED));
- ui_out_text (uiout, "\nProgram terminated with signal ");
+ if (uiout->is_mi_like_p ())
+ uiout->field_string
+ ("reason", async_reason_lookup (EXEC_ASYNC_EXITED_SIGNALLED));
+ uiout->text ("\nProgram terminated with signal ");
annotate_signal_name ();
- ui_out_field_string (uiout, "signal-name",
+ uiout->field_string ("signal-name",
gdb_signal_to_name (siggnal));
annotate_signal_name_end ();
- ui_out_text (uiout, ", ");
+ uiout->text (", ");
annotate_signal_string ();
- ui_out_field_string (uiout, "signal-meaning",
+ uiout->field_string ("signal-meaning",
gdb_signal_to_string (siggnal));
annotate_signal_string_end ();
- ui_out_text (uiout, ".\n");
- ui_out_text (uiout, "The program no longer exists.\n");
+ uiout->text (".\n");
+ uiout->text ("The program no longer exists.\n");
}
void
annotate_exited (exitstatus);
if (exitstatus)
{
- if (ui_out_is_mi_like_p (uiout))
- ui_out_field_string (uiout, "reason",
- async_reason_lookup (EXEC_ASYNC_EXITED));
- ui_out_text (uiout, "[Inferior ");
- ui_out_text (uiout, plongest (inf->num));
- ui_out_text (uiout, " (");
- ui_out_text (uiout, pidstr);
- ui_out_text (uiout, ") exited with code ");
- ui_out_field_fmt (uiout, "exit-code", "0%o", (unsigned int) exitstatus);
- ui_out_text (uiout, "]\n");
+ if (uiout->is_mi_like_p ())
+ uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_EXITED));
+ uiout->text ("[Inferior ");
+ uiout->text (plongest (inf->num));
+ uiout->text (" (");
+ uiout->text (pidstr);
+ uiout->text (") exited with code ");
+ uiout->field_fmt ("exit-code", "0%o", (unsigned int) exitstatus);
+ uiout->text ("]\n");
}
else
{
- if (ui_out_is_mi_like_p (uiout))
- ui_out_field_string
- (uiout, "reason", async_reason_lookup (EXEC_ASYNC_EXITED_NORMALLY));
- ui_out_text (uiout, "[Inferior ");
- ui_out_text (uiout, plongest (inf->num));
- ui_out_text (uiout, " (");
- ui_out_text (uiout, pidstr);
- ui_out_text (uiout, ") exited normally]\n");
+ if (uiout->is_mi_like_p ())
+ uiout->field_string
+ ("reason", async_reason_lookup (EXEC_ASYNC_EXITED_NORMALLY));
+ uiout->text ("[Inferior ");
+ uiout->text (plongest (inf->num));
+ uiout->text (" (");
+ uiout->text (pidstr);
+ uiout->text (") exited normally]\n");
}
}
annotate_signal ();
- if (ui_out_is_mi_like_p (uiout))
+ if (uiout->is_mi_like_p ())
;
else if (show_thread_that_caused_stop ())
{
const char *name;
- ui_out_text (uiout, "\nThread ");
- ui_out_field_fmt (uiout, "thread-id", "%s", print_thread_id (thr));
+ uiout->text ("\nThread ");
+ uiout->field_fmt ("thread-id", "%s", print_thread_id (thr));
name = thr->name != NULL ? thr->name : target_thread_name (thr);
if (name != NULL)
{
- ui_out_text (uiout, " \"");
- ui_out_field_fmt (uiout, "name", "%s", name);
- ui_out_text (uiout, "\"");
+ uiout->text (" \"");
+ uiout->field_fmt ("name", "%s", name);
+ uiout->text ("\"");
}
}
else
- ui_out_text (uiout, "\nProgram");
+ uiout->text ("\nProgram");
- if (siggnal == GDB_SIGNAL_0 && !ui_out_is_mi_like_p (uiout))
- ui_out_text (uiout, " stopped");
+ if (siggnal == GDB_SIGNAL_0 && !uiout->is_mi_like_p ())
+ uiout->text (" stopped");
else
{
- ui_out_text (uiout, " received signal ");
+ uiout->text (" received signal ");
annotate_signal_name ();
- if (ui_out_is_mi_like_p (uiout))
- ui_out_field_string
- (uiout, "reason", async_reason_lookup (EXEC_ASYNC_SIGNAL_RECEIVED));
- ui_out_field_string (uiout, "signal-name",
- gdb_signal_to_name (siggnal));
+ if (uiout->is_mi_like_p ())
+ uiout->field_string
+ ("reason", async_reason_lookup (EXEC_ASYNC_SIGNAL_RECEIVED));
+ uiout->field_string ("signal-name", gdb_signal_to_name (siggnal));
annotate_signal_name_end ();
- ui_out_text (uiout, ", ");
+ uiout->text (", ");
annotate_signal_string ();
- ui_out_field_string (uiout, "signal-meaning",
- gdb_signal_to_string (siggnal));
+ uiout->field_string ("signal-meaning", gdb_signal_to_string (siggnal));
if (siggnal == GDB_SIGNAL_SEGV)
handle_segmentation_fault (uiout);
annotate_signal_string_end ();
}
- ui_out_text (uiout, ".\n");
+ uiout->text (".\n");
}
void
print_no_history_reason (struct ui_out *uiout)
{
- ui_out_text (uiout, "\nNo more reverse-execution history.\n");
+ uiout->text ("\nNo more reverse-execution history.\n");
}
/* Print current location without a level number, if we have changed
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);