diff options
author | Vladimir Prus <vladimir@codesourcery.com> | 2008-11-17 12:13:49 +0000 |
---|---|---|
committer | Vladimir Prus <vladimir@codesourcery.com> | 2008-11-17 12:13:49 +0000 |
commit | c52c9073d08225f822d625a8d76819ba5a0470bf (patch) | |
tree | 05f82d4b834bb86aa408c670994486fc4a71a5f6 /gdb/mi | |
parent | 3c505739f7646cd155eba4c1246894c7cf3b6eeb (diff) | |
download | gdb-c52c9073d08225f822d625a8d76819ba5a0470bf.tar.gz |
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/mi')
-rw-r--r-- | gdb/mi/mi-cmds.c | 1 | ||||
-rw-r--r-- | gdb/mi/mi-cmds.h | 1 | ||||
-rw-r--r-- | gdb/mi/mi-main.c | 51 |
3 files changed, 52 insertions, 1 deletions
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c index ca0f4286a9e..d38de35da40 100644 --- a/gdb/mi/mi-cmds.c +++ b/gdb/mi/mi-cmds.c @@ -90,6 +90,7 @@ struct mi_cmd mi_cmds[] = { "interpreter-exec", { NULL, 0 }, mi_cmd_interpreter_exec}, { "list-features", { NULL, 0 }, mi_cmd_list_features}, { "list-target-features", { NULL, 0 }, mi_cmd_list_target_features}, + { "list-thread-groups", { NULL, 0 }, mi_cmd_list_thread_groups }, { "overlay-auto", { NULL, 0 }, NULL }, { "overlay-list-mapping-state", { NULL, 0 }, NULL }, { "overlay-list-overlays", { NULL, 0 }, NULL }, diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h index 16887aed873..a9bb1e0978b 100644 --- a/gdb/mi/mi-cmds.h +++ b/gdb/mi/mi-cmds.h @@ -67,6 +67,7 @@ extern mi_cmd_argv_ftype mi_cmd_inferior_tty_show; extern mi_cmd_argv_ftype mi_cmd_interpreter_exec; extern mi_cmd_argv_ftype mi_cmd_list_features; extern mi_cmd_argv_ftype mi_cmd_list_target_features; +extern mi_cmd_argv_ftype mi_cmd_list_thread_groups; extern mi_cmd_argv_ftype mi_cmd_stack_info_depth; extern mi_cmd_argv_ftype mi_cmd_stack_info_frame; extern mi_cmd_argv_ftype mi_cmd_stack_list_args; diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 455400837e0..f739bbb8533 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -46,6 +46,7 @@ #include "mi-main.h" #include "language.h" #include "valprint.h" +#include "inferior.h" #include <ctype.h> #include <sys/time.h> @@ -245,7 +246,55 @@ mi_cmd_thread_info (char *command, char **argv, int argc) if (argc == 1) thread = atoi (argv[0]); - print_thread_info (uiout, thread); + print_thread_info (uiout, thread, -1); +} + +static int +print_one_inferior (struct inferior *inferior, void *arg) +{ + struct cleanup *back_to = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + + ui_out_field_fmt (uiout, "id", "%d", inferior->pid); + ui_out_field_string (uiout, "type", "process"); + ui_out_field_int (uiout, "pid", inferior->pid); + + do_cleanups (back_to); + return 0; +} + +void +mi_cmd_list_thread_groups (char *command, char **argv, int argc) +{ + struct cleanup *back_to; + int available = 0; + char *id = NULL; + + if (argc > 0 && strcmp (argv[0], "--available") == 0) + { + ++argv; + --argc; + available = 1; + } + + if (argc > 0) + id = argv[0]; + + back_to = make_cleanup (&null_cleanup, NULL); + + if (id) + { + int pid = atoi (id); + if (!in_inferior_list (pid)) + error ("Invalid thread group id '%s'", id); + print_thread_info (uiout, -1, pid); + } + else + { + make_cleanup_ui_out_list_begin_end (uiout, "groups"); + iterate_over_inferiors (print_one_inferior, NULL); + } + + do_cleanups (back_to); } void |