mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-12-12 14:37:43 +00:00
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 Michael Snyder <msnyder@vmware.com> * gdb.threads/thread-find.exp: Update patterns for changes in output of "info threads" command.
This commit is contained in:
parent
dfa58db10c
commit
aea5b2797c
@ -1,3 +1,17 @@
|
||||
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.
|
||||
|
@ -161,6 +161,27 @@ get_number_or_range (char **pp)
|
||||
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 *
|
||||
|
@ -45,6 +45,16 @@ extern int get_number (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. */
|
||||
|
||||
|
@ -377,7 +377,7 @@ extern struct cmd_list_element *thread_cmd_list;
|
||||
`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);
|
||||
|
@ -503,15 +503,10 @@ mi_cmd_thread_list_ids (char *command, char **argv, int argc)
|
||||
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
|
||||
@ -607,7 +602,7 @@ print_one_inferior (struct inferior *inferior, void *xdata)
|
||||
}
|
||||
|
||||
if (top_data->recurse)
|
||||
print_thread_info (uiout, -1, inferior->pid);
|
||||
print_thread_info (uiout, NULL, inferior->pid);
|
||||
|
||||
do_cleanups (back_to);
|
||||
}
|
||||
@ -872,7 +867,7 @@ mi_cmd_list_thread_groups (char *command, char **argv, int argc)
|
||||
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
|
||||
{
|
||||
|
@ -1,3 +1,8 @@
|
||||
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>
|
||||
|
||||
|
@ -303,28 +303,28 @@ set see5 0
|
||||
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
|
||||
exp_continue
|
||||
}
|
||||
-re ". 3 \[^\r\n\]*\"threadname_3\" \[^\r\n\]*" {
|
||||
set see3 1
|
||||
exp_continue
|
||||
}
|
||||
-re ". 4 \[^\r\n\]*\"threadname_4\" \[^\r\n\]*" {
|
||||
set see4 1
|
||||
-re ". 6 \[^\r\n\]*\"threadname_6\" \[^\r\n\]*" {
|
||||
set see6 1
|
||||
exp_continue
|
||||
}
|
||||
-re ". 5 \[^\r\n\]*\"threadname_5\" \[^\r\n\]*" {
|
||||
set see5 1
|
||||
exp_continue
|
||||
}
|
||||
-re ". 6 \[^\r\n\]*\"threadname_6\" \[^\r\n\]*" {
|
||||
set see6 1
|
||||
-re ". 4 \[^\r\n\]*\"threadname_4\" \[^\r\n\]*" {
|
||||
set see4 1
|
||||
exp_continue
|
||||
}
|
||||
-re ". 3 \[^\r\n\]*\"threadname_3\" \[^\r\n\]*" {
|
||||
set see3 1
|
||||
exp_continue
|
||||
}
|
||||
-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 $" {
|
||||
@ -348,28 +348,28 @@ set see5 0
|
||||
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
|
||||
exp_continue
|
||||
}
|
||||
-re ". 3 .*\"threadname_3\" \[^\r\n\]*" {
|
||||
set see3 1
|
||||
exp_continue
|
||||
}
|
||||
-re ". 4 .*\"threadname_4\" \[^\r\n\]*" {
|
||||
set see4 1
|
||||
-re ". 6 .*\"threadname_6\" \[^\r\n\]*" {
|
||||
set see6 1
|
||||
exp_continue
|
||||
}
|
||||
-re ". 5 .*\"threadname_5\" \[^\r\n\]*" {
|
||||
set see5 1
|
||||
exp_continue
|
||||
}
|
||||
-re ". 6 .*\"threadname_6\" \[^\r\n\]*" {
|
||||
set see6 1
|
||||
-re ". 4 .*\"threadname_4\" \[^\r\n\]*" {
|
||||
set see4 1
|
||||
exp_continue
|
||||
}
|
||||
-re ". 3 .*\"threadname_3\" \[^\r\n\]*" {
|
||||
set see3 1
|
||||
exp_continue
|
||||
}
|
||||
-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 $" {
|
||||
|
36
gdb/thread.c
36
gdb/thread.c
@ -44,6 +44,7 @@
|
||||
#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. */
|
||||
|
||||
@ -755,7 +756,7 @@ finish_thread_state_cleanup (void *arg)
|
||||
}
|
||||
|
||||
/* 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
|
||||
@ -766,7 +767,7 @@ finish_thread_state_cleanup (void *arg)
|
||||
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;
|
||||
@ -791,7 +792,7 @@ print_thread_info (struct ui_out *uiout, int requested_thread, int pid)
|
||||
|
||||
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)
|
||||
@ -805,10 +806,11 @@ print_thread_info (struct ui_out *uiout, int requested_thread, int 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;
|
||||
}
|
||||
@ -827,12 +829,12 @@ print_thread_info (struct ui_out *uiout, int requested_thread, int pid)
|
||||
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;
|
||||
}
|
||||
@ -935,7 +937,7 @@ print_thread_info (struct ui_out *uiout, int requested_thread, int pid)
|
||||
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
|
||||
@ -966,23 +968,7 @@ No selected thread. See `help thread'.\n");
|
||||
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. */
|
||||
|
Loading…
Reference in New Issue
Block a user