* [commit] Simplify "thread apply" with get_number_or_range
@ 2011-02-19 2:18 Michael Snyder
2011-02-24 20:30 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Michael Snyder @ 2011-02-19 2:18 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 77 bytes --]
I love this. I'm going to look for other commands to which it could apply.
[-- Attachment #2: getnum2.txt --]
[-- Type: text/plain, Size: 2384 bytes --]
2011-02-18 Michael Snyder <msnyder@vmware.com>
* thread.c (thread_apply_command): Re-implement using
get_number_or_range.
Index: thread.c
===================================================================
RCS file: /cvs/src/src/gdb/thread.c,v
retrieving revision 1.134
diff -u -p -u -p -r1.134 thread.c
--- thread.c 19 Feb 2011 01:02:56 -0000 1.134
+++ thread.c 19 Feb 2011 01:22:56 -0000
@@ -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
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;
+ start = get_number_or_range (&tidlist);
- while (*tidlist == ' ' || *tidlist == '\t')
- tidlist++;
+ make_cleanup_restore_current_thread ();
- 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;
+ tp = find_thread_id (start);
- while (*tidlist == ' ' || *tidlist == '\t')
- tidlist++;
- }
+ if (!tp)
+ warning (_("Unknown thread %d."), start);
+ else if (!thread_alive (tp))
+ warning (_("Thread %d has terminated."), start);
else
- end = start;
-
- make_cleanup_restore_current_thread ();
-
- for (; start <= end; start++)
{
- tp = find_thread_id (start);
+ 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);
}
}
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [commit] Simplify "thread apply" with get_number_or_range
2011-02-19 2:18 [commit] Simplify "thread apply" with get_number_or_range Michael Snyder
@ 2011-02-24 20:30 ` Tom Tromey
2011-02-24 20:33 ` Michael Snyder
2011-02-24 21:27 ` info inferior, was " Michael Snyder
0 siblings, 2 replies; 6+ messages in thread
From: Tom Tromey @ 2011-02-24 20:30 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
Michael> I love this. I'm going to look for other commands to which it
Michael> could apply.
If you are still looking, today I noticed that "info inferiors" could
use this...
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [commit] Simplify "thread apply" with get_number_or_range
2011-02-24 20:30 ` Tom Tromey
@ 2011-02-24 20:33 ` Michael Snyder
2011-02-24 20:40 ` Tom Tromey
2011-02-24 21:27 ` info inferior, was " Michael Snyder
1 sibling, 1 reply; 6+ messages in thread
From: Michael Snyder @ 2011-02-24 20:33 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
Tom Tromey wrote:
> Michael> I love this. I'm going to look for other commands to which it
> Michael> could apply.
>
> If you are still looking, today I noticed that "info inferiors" could
> use this...
Cool! Is there a test in the testsuite for it?
^ permalink raw reply [flat|nested] 6+ messages in thread
* info inferior, was Re: [commit] Simplify "thread apply" with get_number_or_range
2011-02-24 20:30 ` Tom Tromey
2011-02-24 20:33 ` Michael Snyder
@ 2011-02-24 21:27 ` Michael Snyder
2011-02-25 13:22 ` Pedro Alves
1 sibling, 1 reply; 6+ messages in thread
From: Michael Snyder @ 2011-02-24 21:27 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches, Pedro Alves
Tom Tromey wrote:
> Michael> I love this. I'm going to look for other commands to which it
> Michael> could apply.
>
> If you are still looking, today I noticed that "info inferiors" could
> use this...
Pedro, I notice that "print_inferior" is exported, but I can't find any
more uses of it. Should I worry if I need to change its prototype?
Michael
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: info inferior, was Re: [commit] Simplify "thread apply" with get_number_or_range
2011-02-24 21:27 ` info inferior, was " Michael Snyder
@ 2011-02-25 13:22 ` Pedro Alves
0 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2011-02-25 13:22 UTC (permalink / raw)
To: Michael Snyder; +Cc: Tom Tromey, gdb-patches
On Thursday 24 February 2011 20:48:02, Michael Snyder wrote:
> Tom Tromey wrote:
> > Michael> I love this. I'm going to look for other commands to which it
> > Michael> could apply.
> >
> > If you are still looking, today I noticed that "info inferiors" could
> > use this...
>
> Pedro, I notice that "print_inferior" is exported, but I can't find any
> more uses of it.
Yeah, it as meant for MI, but MI ended up implementing it's own
way of printing inferiors. It could be made static.
> Should I worry if I need to change its prototype?
Nope.
--
Pedro Alves
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-02-25 13:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-19 2:18 [commit] Simplify "thread apply" with get_number_or_range Michael Snyder
2011-02-24 20:30 ` Tom Tromey
2011-02-24 20:33 ` Michael Snyder
2011-02-24 20:40 ` Tom Tromey
2011-02-24 21:27 ` info inferior, was " Michael Snyder
2011-02-25 13:22 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox