summaryrefslogtreecommitdiff
path: root/gdb/thread.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2010-12-21 19:10:08 +0000
committerTom Tromey <tromey@redhat.com>2010-12-21 19:10:08 +0000
commit07433744611d5ed4beebbc27d382daa1daf7a134 (patch)
treefa540899ab481ee2684dfc1a5c367b3fbc65192f /gdb/thread.c
parentc4e773b1fb01910f9ff94a7f64f8f94620980be3 (diff)
downloadgdb-07433744611d5ed4beebbc27d382daa1daf7a134.tar.gz
gdb
* thread.c (print_thread_info): Make a ui-out table in CLI mode. gdb/testsuite * gdb.threads/execl.exp: Update. * gdb.threads/linux-dp.exp: Update. * gdb.threads/manythreads.exp: Update. * gdb.threads/tls.exp: Update.
Diffstat (limited to 'gdb/thread.c')
-rw-r--r--gdb/thread.c65
1 files changed, 59 insertions, 6 deletions
diff --git a/gdb/thread.c b/gdb/thread.c
index 1be325fef62..387b00a14de 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -778,7 +778,49 @@ print_thread_info (struct ui_out *uiout, int requested_thread, int pid)
/* We'll be switching threads temporarily. */
old_chain = make_cleanup_restore_current_thread ();
- make_cleanup_ui_out_list_begin_end (uiout, "threads");
+ /* 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))
+ make_cleanup_ui_out_list_begin_end (uiout, "threads");
+ else
+ {
+ int n_threads = 0;
+
+ for (tp = thread_list; tp; tp = tp->next)
+ {
+ if (requested_thread != -1 && tp->num != requested_thread)
+ continue;
+
+ if (pid != -1 && PIDGET (tp->ptid) != pid)
+ continue;
+
+ if (tp->state_ == THREAD_EXITED)
+ continue;
+
+ ++n_threads;
+ }
+
+ if (n_threads == 0)
+ {
+ if (requested_thread == -1)
+ ui_out_message (uiout, 0, _("No threads.\n"));
+ else
+ ui_out_message (uiout, 0, _("No thread %d.\n"), requested_thread);
+ do_cleanups (old_chain);
+ return;
+ }
+
+ make_cleanup_ui_out_table_begin_end (uiout, 5, n_threads, "threads");
+
+ ui_out_table_header (uiout, 1, ui_left, "current", "");
+ ui_out_table_header (uiout, 4, ui_left, "id", "Id");
+ ui_out_table_header (uiout, 17, ui_left, "target-id", "Target Id");
+ ui_out_table_header (uiout, 1, ui_noalign, "details", "");
+ ui_out_table_header (uiout, 1, ui_left, "frame", "Frame");
+ ui_out_table_body (uiout);
+ }
+
for (tp = thread_list; tp; tp = tp->next)
{
struct cleanup *chain2;
@@ -802,13 +844,23 @@ print_thread_info (struct ui_out *uiout, int requested_thread, int pid)
chain2 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
- if (ptid_equal (tp->ptid, current_ptid))
- ui_out_text (uiout, "* ");
+ if (ui_out_is_mi_like_p (uiout))
+ {
+ /* Compatibility. */
+ if (ptid_equal (tp->ptid, current_ptid))
+ ui_out_text (uiout, "* ");
+ else
+ ui_out_text (uiout, " ");
+ }
else
- ui_out_text (uiout, " ");
+ {
+ if (ptid_equal (tp->ptid, current_ptid))
+ ui_out_field_string (uiout, "current", "*");
+ else
+ ui_out_field_skip (uiout, "current");
+ }
ui_out_field_int (uiout, "id", tp->num);
- ui_out_text (uiout, " ");
ui_out_field_string (uiout, "target-id", target_pid_to_str (tp->ptid));
extra_info = target_extra_thread_info (tp);
@@ -818,7 +870,8 @@ print_thread_info (struct ui_out *uiout, int requested_thread, int pid)
ui_out_field_string (uiout, "details", extra_info);
ui_out_text (uiout, ")");
}
- ui_out_text (uiout, " ");
+ else if (! ui_out_is_mi_like_p (uiout))
+ ui_out_field_skip (uiout, "details");
if (tp->state_ == THREAD_RUNNING)
ui_out_text (uiout, "(running)\n");