aboutsummaryrefslogtreecommitdiff
path: root/gdb/thread.c
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2008-11-17 12:13:49 +0000
committerVladimir Prus <vladimir@codesourcery.com>2008-11-17 12:13:49 +0000
commit3ee1c036ac61c61fc906fc93eb63fe625cacaa55 (patch)
treebc7ff8d51fe05ebb01a917b4a3f5a86bb6adddb5 /gdb/thread.c
parent1604c175b2d182fae01fe4b3ef01df5cc4598c0b (diff)
downloadgdb-3ee1c036ac61c61fc906fc93eb63fe625cacaa55.zip
gdb-3ee1c036ac61c61fc906fc93eb63fe625cacaa55.tar.gz
gdb-3ee1c036ac61c61fc906fc93eb63fe625cacaa55.tar.bz2
Implement -list-thread-groups.
* thread.c (print_thread_info): New parameter pid, to print threads of specific process. * gdbthread.h (print_thread_info): New parameter pid. * mi/mi-cmds.c (mi_cmds): Register -list-thread-groups. * mi/mi-cmds.h (mi_cmd_list_thread_groups): New. * mi/mi-main.c (mi_cmd_thread_info): Adjust. (print_one_process, mi_cmd_list_thread_groups): New.
Diffstat (limited to 'gdb/thread.c')
-rw-r--r--gdb/thread.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/gdb/thread.c b/gdb/thread.c
index b1e318d..1f50e6a 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -636,9 +636,14 @@ set_stop_requested (ptid_t ptid, int stop)
use from MI.
If REQUESTED_THREAD is not -1, it's the GDB id of the thread
that should be printed. Otherwise, all threads are
- printed. */
+ printed.
+ If PID is not -1, only print threads from the process PID.
+ Otherwise, threads from all attached PIDs are printed.
+ If both REQUESTED_THREAD and PID are not -1, then the thread
+ is printed if it belongs to the specified process. Otherwise,
+ an error is raised. */
void
-print_thread_info (struct ui_out *uiout, int requested_thread)
+print_thread_info (struct ui_out *uiout, int requested_thread, int pid)
{
struct thread_info *tp;
ptid_t current_ptid;
@@ -661,6 +666,13 @@ print_thread_info (struct ui_out *uiout, int requested_thread)
if (requested_thread != -1 && tp->num != requested_thread)
continue;
+ if (pid != -1 && PIDGET (tp->ptid) != pid)
+ {
+ if (requested_thread != -1)
+ error (_("Requested thread not found in requested process"));
+ continue;
+ }
+
if (ptid_equal (tp->ptid, current_ptid))
current_thread = tp->num;
@@ -715,7 +727,7 @@ print_thread_info (struct ui_out *uiout, int requested_thread)
the "info threads" command. */
do_cleanups (old_chain);
- if (requested_thread == -1)
+ if (pid == -1 && requested_thread == -1 )
{
gdb_assert (current_thread != -1
|| !thread_list);
@@ -740,7 +752,7 @@ The current thread <Thread ID %d> has terminated. See `help thread'.\n",
static void
info_threads_command (char *arg, int from_tty)
{
- print_thread_info (uiout, -1);
+ print_thread_info (uiout, -1, -1);
}
/* Switch from one thread to another. */