/* Multi-process/thread control for GDB, the GNU debugger.
- Copyright (C) 1986-2016 Free Software Foundation, Inc.
+ Copyright (C) 1986-2017 Free Software Foundation, Inc.
Contributed by Lynx Real-Time Systems, Inc. Los Gatos, CA.
current_thread = tp->global_num;
num++;
- ui_out_field_int (uiout, "thread-id", tp->global_num);
+ uiout->field_int ("thread-id", tp->global_num);
}
do_cleanups (cleanup_chain);
if (current_thread != -1)
- ui_out_field_int (uiout, "current-thread-id", current_thread);
- ui_out_field_int (uiout, "number-of-threads", num);
+ uiout->field_int ("current-thread-id", current_thread);
+ uiout->field_int ("number-of-threads", num);
return GDB_RC_OK;
}
error (_("Selected thread is running."));
}
+/* See gdbthread.h. */
+
+bool
+can_access_registers_ptid (ptid_t ptid)
+{
+ /* No thread, no registers. */
+ if (ptid_equal (ptid, null_ptid))
+ return false;
+
+ /* Don't try to read from a dead thread. */
+ if (is_exited (ptid))
+ return false;
+
+ /* ... or from a spinning thread. FIXME: see validate_registers_access. */
+ if (is_executing (ptid))
+ return false;
+
+ return true;
+}
+
int
pc_in_thread_step_range (CORE_ADDR pc, struct thread_info *thread)
{
/* For backward compatibility, we make a list for MI. A table is
preferable for the CLI, though, because it shows table
headers. */
- if (ui_out_is_mi_like_p (uiout))
+ if (uiout->is_mi_like_p ())
make_cleanup_ui_out_list_begin_end (uiout, "threads");
else
{
if (n_threads == 0)
{
if (requested_threads == NULL || *requested_threads == '\0')
- ui_out_message (uiout, _("No threads.\n"));
+ uiout->message (_("No threads.\n"));
else
- ui_out_message (uiout, _("No threads match '%s'.\n"),
+ uiout->message (_("No threads match '%s'.\n"),
requested_threads);
do_cleanups (old_chain);
return;
}
- if (show_global_ids || ui_out_is_mi_like_p (uiout))
+ if (show_global_ids || uiout->is_mi_like_p ())
make_cleanup_ui_out_table_begin_end (uiout, 5, n_threads, "threads");
else
make_cleanup_ui_out_table_begin_end (uiout, 4, n_threads, "threads");
- ui_out_table_header (uiout, 1, ui_left, "current", "");
+ uiout->table_header (1, ui_left, "current", "");
- if (!ui_out_is_mi_like_p (uiout))
- ui_out_table_header (uiout, 4, ui_left, "id-in-tg", "Id");
- if (show_global_ids || ui_out_is_mi_like_p (uiout))
- ui_out_table_header (uiout, 4, ui_left, "id", "GId");
- ui_out_table_header (uiout, 17, ui_left, "target-id", "Target Id");
- ui_out_table_header (uiout, 1, ui_left, "frame", "Frame");
- ui_out_table_body (uiout);
+ if (!uiout->is_mi_like_p ())
+ uiout->table_header (4, ui_left, "id-in-tg", "Id");
+ if (show_global_ids || uiout->is_mi_like_p ())
+ uiout->table_header (4, ui_left, "id", "GId");
+ uiout->table_header (17, ui_left, "target-id", "Target Id");
+ uiout->table_header (1, ui_left, "frame", "Frame");
+ uiout->table_body ();
}
ALL_THREADS_BY_INFERIOR (inf, tp)
chain2 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
- if (ui_out_is_mi_like_p (uiout))
+ if (uiout->is_mi_like_p ())
{
/* Compatibility. */
if (ptid_equal (tp->ptid, current_ptid))
- ui_out_text (uiout, "* ");
+ uiout->text ("* ");
else
- ui_out_text (uiout, " ");
+ uiout->text (" ");
}
else
{
if (ptid_equal (tp->ptid, current_ptid))
- ui_out_field_string (uiout, "current", "*");
+ uiout->field_string ("current", "*");
else
- ui_out_field_skip (uiout, "current");
+ uiout->field_skip ("current");
}
- if (!ui_out_is_mi_like_p (uiout))
- ui_out_field_string (uiout, "id-in-tg", print_thread_id (tp));
+ if (!uiout->is_mi_like_p ())
+ uiout->field_string ("id-in-tg", print_thread_id (tp));
- if (show_global_ids || ui_out_is_mi_like_p (uiout))
- ui_out_field_int (uiout, "id", tp->global_num);
+ if (show_global_ids || uiout->is_mi_like_p ())
+ uiout->field_int ("id", tp->global_num);
/* For the CLI, we stuff everything into the target-id field.
This is a gross hack to make the output come out looking
extra_info = target_extra_thread_info (tp);
name = tp->name ? tp->name : target_thread_name (tp);
- if (ui_out_is_mi_like_p (uiout))
+ if (uiout->is_mi_like_p ())
{
- ui_out_field_string (uiout, "target-id", target_id);
+ uiout->field_string ("target-id", target_id);
if (extra_info)
- ui_out_field_string (uiout, "details", extra_info);
+ uiout->field_string ("details", extra_info);
if (name)
- ui_out_field_string (uiout, "name", name);
+ uiout->field_string ("name", name);
}
else
{
contents = xstrdup (target_id);
str_cleanup = make_cleanup (xfree, contents);
- ui_out_field_string (uiout, "target-id", contents);
+ uiout->field_string ("target-id", contents);
do_cleanups (str_cleanup);
}
if (tp->state == THREAD_RUNNING)
- ui_out_text (uiout, "(running)\n");
+ uiout->text ("(running)\n");
else
{
/* The switch below puts us at the top of the stack (leaf
switch_to_thread (tp->ptid);
print_stack_frame (get_selected_frame (NULL),
/* For MI output, print frame level. */
- ui_out_is_mi_like_p (uiout),
+ uiout->is_mi_like_p (),
LOCATION, 0);
}
- if (ui_out_is_mi_like_p (uiout))
+ if (uiout->is_mi_like_p ())
{
char *state = "stopped";
if (tp->state == THREAD_RUNNING)
state = "running";
- ui_out_field_string (uiout, "state", state);
+ uiout->field_string ("state", state);
}
core = target_core_of_thread (tp->ptid);
- if (ui_out_is_mi_like_p (uiout) && core != -1)
- ui_out_field_int (uiout, "core", core);
+ if (uiout->is_mi_like_p () && core != -1)
+ uiout->field_int ("core", core);
do_cleanups (chain2);
}
if (pid == -1 && requested_threads == NULL)
{
- if (ui_out_is_mi_like_p (uiout)
+ if (uiout->is_mi_like_p ()
&& !ptid_equal (inferior_ptid, null_ptid))
{
int num = ptid_to_global_thread_id (inferior_ptid);
gdb_assert (num != 0);
- ui_out_field_int (uiout, "current-thread-id", num);
+ uiout->field_int ("current-thread-id", num);
}
if (!ptid_equal (inferior_ptid, null_ptid) && is_exited (inferior_ptid))
- ui_out_message (uiout, "\n\
+ uiout->message ("\n\
The current thread <Thread ID %s> has terminated. See `help thread'.\n",
print_thread_id (inferior_thread ()));
else if (thread_list != NULL
&& ptid_equal (inferior_ptid, null_ptid))
- ui_out_message (uiout, "\n\
+ uiout->message ("\n\
No selected thread. See `help thread'.\n");
}
}
select_frame (get_current_frame ());
/* Warn the user. */
- if (frame_level > 0 && !ui_out_is_mi_like_p (current_uiout))
+ if (frame_level > 0 && !current_uiout->is_mi_like_p ())
{
warning (_("Couldn't restore frame #%d in "
"current thread. Bottom (innermost) frame selected:"),
const char *tidstr = (const char *) tidstr_v;
struct thread_info *tp;
- if (ui_out_is_mi_like_p (uiout))
+ if (uiout->is_mi_like_p ())
{
int num = value_as_long (parse_and_eval (tidstr));
if (selection & USER_SELECTED_THREAD)
{
- if (ui_out_is_mi_like_p (uiout))
+ if (uiout->is_mi_like_p ())
{
- ui_out_field_int (uiout, "new-thread-id",
+ uiout->field_int ("new-thread-id",
inferior_thread ()->global_num);
}
else
{
- ui_out_text (uiout, "[Switching to thread ");
- ui_out_field_string (uiout, "new-thread-id", print_thread_id (tp));
- ui_out_text (uiout, " (");
- ui_out_text (uiout, target_pid_to_str (inferior_ptid));
- ui_out_text (uiout, ")]");
+ uiout->text ("[Switching to thread ");
+ uiout->field_string ("new-thread-id", print_thread_id (tp));
+ uiout->text (" (");
+ uiout->text (target_pid_to_str (inferior_ptid));
+ uiout->text (")]");
}
}
if (tp->state == THREAD_RUNNING)
{
if (selection & USER_SELECTED_THREAD)
- ui_out_text (uiout, "(running)\n");
+ uiout->text ("(running)\n");
}
else if (selection & USER_SELECTED_FRAME)
{
if (selection & USER_SELECTED_THREAD)
- ui_out_text (uiout, "\n");
+ uiout->text ("\n");
if (has_stack_frames ())
print_stack_frame_to_uiout (uiout, get_selected_frame (NULL),