diff options
author | Michael Snyder <msnyder@vmware.com> | 2011-02-19 01:24:55 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@vmware.com> | 2011-02-19 01:24:55 +0000 |
commit | 65ebfb52d940d569db14b6b231058c69d6cd422a (patch) | |
tree | 7560f17e68bc6832aa67b36cffe54f1bfbff3b6a | |
parent | 7a45ebd700abd6b54a8ef9afea260b258c49061a (diff) | |
download | gdb-65ebfb52d940d569db14b6b231058c69d6cd422a.zip gdb-65ebfb52d940d569db14b6b231058c69d6cd422a.tar.gz gdb-65ebfb52d940d569db14b6b231058c69d6cd422a.tar.bz2 |
2011-02-18 Michael Snyder <msnyder@vmware.com>
* thread.c (thread_apply_command): Re-implement using
get_number_or_range.
-rw-r--r-- | gdb/ChangeLog | 1 | ||||
-rw-r--r-- | gdb/thread.c | 55 |
2 files changed, 17 insertions, 39 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3cae1d3..eb0dd86 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -2,6 +2,7 @@ * thread.c (info_threads_command): Re-implement using get_number_or_range. + (thread_apply_command): Ditto. 2011-02-18 Tom Tromey <tromey@redhat.com> diff --git a/gdb/thread.c b/gdb/thread.c index e297b54..a8d7adf 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -1212,7 +1212,6 @@ static void thread_apply_command (char *tidlist, int from_tty) { char *cmd; - char *p; struct cleanup *old_chain; char *saved_cmd; @@ -1231,51 +1230,29 @@ thread_apply_command (char *tidlist, int from_tty) while (tidlist < cmd) { struct thread_info *tp; - int start, end; + int start; + char *p = tidlist; - start = strtol (tidlist, &p, 10); - if (p == tidlist) - error (_("Error parsing %s"), tidlist); - tidlist = p; - - while (*tidlist == ' ' || *tidlist == '\t') - tidlist++; - - if (*tidlist == '-') /* Got a range of IDs? */ - { - tidlist++; /* Skip the - */ - end = strtol (tidlist, &p, 10); - if (p == tidlist) - error (_("Error parsing %s"), tidlist); - tidlist = p; - - while (*tidlist == ' ' || *tidlist == '\t') - tidlist++; - } - else - end = start; + start = get_number_or_range (&tidlist); make_cleanup_restore_current_thread (); - for (; start <= end; start++) - { - tp = find_thread_id (start); + tp = find_thread_id (start); - if (!tp) - warning (_("Unknown thread %d."), start); - else if (!thread_alive (tp)) - warning (_("Thread %d has terminated."), start); - else - { - switch_to_thread (tp->ptid); + if (!tp) + warning (_("Unknown thread %d."), start); + else if (!thread_alive (tp)) + warning (_("Thread %d has terminated."), start); + else + { + switch_to_thread (tp->ptid); - printf_filtered (_("\nThread %d (%s):\n"), tp->num, - target_pid_to_str (inferior_ptid)); - execute_command (cmd, from_tty); + printf_filtered (_("\nThread %d (%s):\n"), tp->num, + target_pid_to_str (inferior_ptid)); + execute_command (cmd, from_tty); - /* Restore exact command used previously. */ - strcpy (cmd, saved_cmd); - } + /* Restore exact command used previously. */ + strcpy (cmd, saved_cmd); } } |