aboutsummaryrefslogtreecommitdiff
path: root/gdb/thread.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-01-15 21:46:22 +0000
committerPedro Alves <palves@redhat.com>2016-01-15 21:46:22 +0000
commit3f5b7598805c8253c43c989a540a2408c8b685ad (patch)
tree74f71dc4893338da7d523e24e80a635aa48ce2cc /gdb/thread.c
parent9c03a84f6cc54af01d4fe655f6e0a0aa13d8ef74 (diff)
downloadgdb-3f5b7598805c8253c43c989a540a2408c8b685ad.zip
gdb-3f5b7598805c8253c43c989a540a2408c8b685ad.tar.gz
gdb-3f5b7598805c8253c43c989a540a2408c8b685ad.tar.bz2
Fix "thread apply $conv_var" and misc other related problems
This fixes a few bugs in "thread apply". While this works: (gdb) thread apply 1 p 1234 Thread 1 (Thread 0x7ffff7fc1740 (LWP 14048)): $1 = 1234 This doesn't: (gdb) thread apply $thr p 1234 Thread 1 (Thread 0x7ffff7fc1740 (LWP 12039)): Invalid thread ID: p 1234 (gdb) ~~~~ Also, while this works: (gdb) thread apply 1 Please specify a command following the thread ID list This doesn't: (gdb) thread apply $thr Thread 1 (Thread 0x7ffff7fc1740 (LWP 12039)): [Current thread is 1 (Thread 0x7ffff7fc1740 (LWP 12039))] (gdb) ~~~~ And, while this works: (gdb) thread apply Please specify a thread ID list This obviously bogus invocation is just silent: (gdb) thread apply bt (gdb) gdb/ChangeLog: 2016-01-15 Pedro Alves <palves@redhat.com> * thread.c (thread_apply_command): Use the tid range parser to advance past the thread ID list. * tid-parse.c (get_positive_number_trailer): New function. (parse_thread_id): Use it. (get_tid_or_range): Use it. Return 0 instead of throwing invalid thread ID error. (get_tid_or_range): Detect negative values. Return 0 instead of throwing invalid thread ID error. gdb/testsuite/ChangeLog: 2016-01-15 Pedro Alves <palves@redhat.com> * gdb.multi/tids.exp (thr_apply_info_thr_error): Remove "p 1234" command from "thread apply" invocation. (thr_apply_info_thr_invalid): Default the expected output to the input tid list. (top level): Add tests that use convenience variables. Add tests for "thread apply" with a valid TID list, but missing the command.
Diffstat (limited to 'gdb/thread.c')
-rw-r--r--gdb/thread.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/gdb/thread.c b/gdb/thread.c
index b3b3995..56de6e1 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1818,7 +1818,7 @@ thread_apply_all_command (char *cmd, int from_tty)
static void
thread_apply_command (char *tidlist, int from_tty)
{
- char *cmd;
+ char *cmd = NULL;
struct cleanup *old_chain;
char *saved_cmd;
struct tid_range_parser parser;
@@ -1826,11 +1826,25 @@ thread_apply_command (char *tidlist, int from_tty)
if (tidlist == NULL || *tidlist == '\000')
error (_("Please specify a thread ID list"));
- for (cmd = tidlist; *cmd != '\000' && !isalpha (*cmd); cmd++);
+ tid_range_parser_init (&parser, tidlist, current_inferior ()->num);
+ while (!tid_range_parser_finished (&parser))
+ {
+ int inf_num, thr_start, thr_end;
+
+ if (!tid_range_parser_get_tid_range (&parser,
+ &inf_num, &thr_start, &thr_end))
+ {
+ cmd = (char *) tid_range_parser_string (&parser);
+ break;
+ }
+ }
- if (*cmd == '\000')
+ if (cmd == NULL)
error (_("Please specify a command following the thread ID list"));
+ if (tidlist == cmd || !isalpha (cmd[0]))
+ invalid_thread_id_error (cmd);
+
/* Save a copy of the command in case it is clobbered by
execute_command. */
saved_cmd = xstrdup (cmd);