* gdbthread.h (print_thread_info): Change prototype.
* thread.c (print_thread_info): Accept char* instead of int for
requested_threads argument. Use new function number_is_in_list
to determine which threads to list.
(info_threads_command): Pass char* to print_thread_info.
* cli/cli-utils.c (number_is_in_list): New function.
* cli/cli-utils.h (number_is_in_list): Export.
* mi/mi-main.c (mi_cmd_thread_info): Pass char* to
print_thread_info.
(print_one_inferior): Ditto.
(mi_cmd_list_thread_groups): Ditto.
2011-02-21 Michael Snyder <msnyder@vmware.com>
* gdb.threads/thread-find.exp: Update patterns for changes in
output of "info threads" command.
+2011-02-21 Michael Snyder <msnyder@vmware.com>
+
+ * gdbthread.h (print_thread_info): Change prototype.
+ * thread.c (print_thread_info): Accept char* instead of int for
+ requested_threads argument. Use new function number_is_in_list
+ to determine which threads to list.
+ (info_threads_command): Pass char* to print_thread_info.
+ * cli/cli-utils.c (number_is_in_list): New function.
+ * cli/cli-utils.h (number_is_in_list): Export.
+ * mi/mi-main.c (mi_cmd_thread_info): Pass char* to
+ print_thread_info.
+ (print_one_inferior): Ditto.
+ (mi_cmd_list_thread_groups): Ditto.
+
2011-02-21 Jan Kratochvil <jan.kratochvil@redhat.com>
* common/Makefile.in (CFLAGS): New.
return last_retval;
}
+/* Accept a number and a string-form list of numbers such as is
+ accepted by get_number_or_range. Return TRUE if the number is
+ in the list.
+
+ By definition, an empty list includes all numbers. This is to
+ be interpreted as typing a command such as "delete break" with
+ no arguments. */
+
+int
+number_is_in_list (char *list, int number)
+{
+ if (list == NULL || *list == '\0')
+ return 1;
+
+ while (list != NULL && *list != '\0')
+ if (get_number_or_range (&list) == number)
+ return 1;
+
+ return 0;
+}
+
/* See documentation in cli-utils.h. */
char *
extern int get_number_or_range (char **);
+/* Accept a number and a string-form list of numbers such as is
+ accepted by get_number_or_range. Return TRUE if the number is
+ in the list.
+
+ By definition, an empty list includes all numbers. This is to
+ be interpreted as typing a command such as "delete break" with
+ no arguments. */
+
+extern int number_is_in_list (char *list, int number);
+
/* Skip leading whitespace characters in INP, returning an updated
pointer. If INP is NULL, return NULL. */
`set print thread-events'. */
extern int print_thread_events;
-extern void print_thread_info (struct ui_out *uiout, int thread,
+extern void print_thread_info (struct ui_out *uiout, char *threads,
int pid);
extern struct cleanup *make_cleanup_restore_current_thread (void);
void
mi_cmd_thread_info (char *command, char **argv, int argc)
{
- int thread = -1;
-
if (argc != 0 && argc != 1)
error ("Invalid MI command");
- if (argc == 1)
- thread = atoi (argv[0]);
-
- print_thread_info (uiout, thread, -1);
+ print_thread_info (uiout, argv[0], -1);
}
struct collect_cores_data
}
if (top_data->recurse)
- print_thread_info (uiout, -1, inferior->pid);
+ print_thread_info (uiout, NULL, inferior->pid);
do_cleanups (back_to);
}
if (!inf)
error ("Non-existent thread group id '%d'", id);
- print_thread_info (uiout, -1, inf->pid);
+ print_thread_info (uiout, NULL, inf->pid);
}
else
{
+2011-02-21 Michael Snyder <msnyder@vmware.com>
+
+ * gdb.threads/thread-find.exp: Update patterns for changes in
+ output of "info threads" command.
+
2011-02-21 Matthew Gretton-Dann <matthew.gretton-dann@arm.com>
Ulrich Weigand <uweigand@de.ibm.com>
set see6 0
gdb_test_multiple "info threads 2 4 6" "info threads 2 4 6" {
- -re ". 1 \[^\r\n\]*\"threadname_1\" \[^\r\n\]*" {
- set see1 1
- exp_continue
- }
- -re ". 2 \[^\r\n\]*\"threadname_2\" \[^\r\n\]*" {
- set see2 1
+ -re ". 6 \[^\r\n\]*\"threadname_6\" \[^\r\n\]*" {
+ set see6 1
exp_continue
}
- -re ". 3 \[^\r\n\]*\"threadname_3\" \[^\r\n\]*" {
- set see3 1
+ -re ". 5 \[^\r\n\]*\"threadname_5\" \[^\r\n\]*" {
+ set see5 1
exp_continue
}
-re ". 4 \[^\r\n\]*\"threadname_4\" \[^\r\n\]*" {
set see4 1
exp_continue
}
- -re ". 5 \[^\r\n\]*\"threadname_5\" \[^\r\n\]*" {
- set see5 1
+ -re ". 3 \[^\r\n\]*\"threadname_3\" \[^\r\n\]*" {
+ set see3 1
exp_continue
}
- -re ". 6 \[^\r\n\]*\"threadname_6\" \[^\r\n\]*" {
- set see6 1
+ -re ". 2 \[^\r\n\]*\"threadname_2\" \[^\r\n\]*" {
+ set see2 1
+ exp_continue
+ }
+ -re ". 1 \[^\r\n\]*\"threadname_1\" \[^\r\n\]*" {
+ set see1 1
exp_continue
}
-re "$gdb_prompt $" {
set see6 0
gdb_test_multiple "info threads 3-5" "info threads 3-5" {
- -re ". 1 .*\"threadname_1\" \[^\r\n\]*" {
- set see1 1
- exp_continue
- }
- -re ". 2 .*\"threadname_2\" \[^\r\n\]*" {
- set see2 1
+ -re ". 6 .*\"threadname_6\" \[^\r\n\]*" {
+ set see6 1
exp_continue
}
- -re ". 3 .*\"threadname_3\" \[^\r\n\]*" {
- set see3 1
+ -re ". 5 .*\"threadname_5\" \[^\r\n\]*" {
+ set see5 1
exp_continue
}
-re ". 4 .*\"threadname_4\" \[^\r\n\]*" {
set see4 1
exp_continue
}
- -re ". 5 .*\"threadname_5\" \[^\r\n\]*" {
- set see5 1
+ -re ". 3 .*\"threadname_3\" \[^\r\n\]*" {
+ set see3 1
exp_continue
}
- -re ". 6 .*\"threadname_6\" \[^\r\n\]*" {
- set see6 1
+ -re ". 2 .*\"threadname_2\" \[^\r\n\]*" {
+ set see2 1
+ exp_continue
+ }
+ -re ". 1 .*\"threadname_1\" \[^\r\n\]*" {
+ set see1 1
exp_continue
}
-re "$gdb_prompt $" {
#include "annotate.h"
#include "cli/cli-decode.h"
#include "gdb_regex.h"
+#include "cli/cli-utils.h"
/* Definition of struct thread_info exported to gdbthread.h. */
}
/* Prints the list of threads and their details on UIOUT.
- This is a version of 'info_thread_command' suitable for
+ This is a version of 'info_threads_command' suitable for
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
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, int pid)
+print_thread_info (struct ui_out *uiout, char *requested_threads, int pid)
{
struct thread_info *tp;
ptid_t current_ptid;
for (tp = thread_list; tp; tp = tp->next)
{
- if (requested_thread != -1 && tp->num != requested_thread)
+ if (!number_is_in_list (requested_threads, tp->num))
continue;
if (pid != -1 && PIDGET (tp->ptid) != pid)
if (n_threads == 0)
{
- if (requested_thread == -1)
+ if (requested_threads == NULL || *requested_threads == '\0')
ui_out_message (uiout, 0, _("No threads.\n"));
else
- ui_out_message (uiout, 0, _("No thread %d.\n"), requested_thread);
+ ui_out_message (uiout, 0, _("No threads match '%s'.\n"),
+ requested_threads);
do_cleanups (old_chain);
return;
}
struct cleanup *chain2;
int core;
- if (requested_thread != -1 && tp->num != requested_thread)
+ if (!number_is_in_list (requested_threads, tp->num))
continue;
if (pid != -1 && PIDGET (tp->ptid) != pid)
{
- if (requested_thread != -1)
+ if (requested_threads != NULL && *requested_threads != '\0')
error (_("Requested thread not found in requested process"));
continue;
}
the "info threads" command. */
do_cleanups (old_chain);
- if (pid == -1 && requested_thread == -1)
+ if (pid == -1 && requested_threads == NULL)
{
gdb_assert (current_thread != -1
|| !thread_list
static void
info_threads_command (char *arg, int from_tty)
{
- int tid = -1;
-
- if (arg == NULL || *arg == '\0')
- {
- print_thread_info (uiout, -1, -1);
- return;
- }
-
- while (arg != NULL && *arg != '\0')
- {
- tid = get_number_or_range (&arg);
-
- if (tid <= 0)
- error (_("invalid thread id %d"), tid);
-
- print_thread_info (uiout, tid, -1);
- }
+ print_thread_info (uiout, arg, -1);
}
/* Switch from one thread to another. */