This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] Simplify "info threads" with get_number_or_range


Wow, this is great.
I will look into using it for thread-apply too.

2011-02-18  Michael Snyder  <msnyder@vmware.com>

	* thread.c (info_threads_command): Re-implement using 
	get_number_or_range.

Index: thread.c
===================================================================
RCS file: /cvs/src/src/gdb/thread.c,v
retrieving revision 1.133
diff -u -p -u -p -r1.133 thread.c
--- thread.c	16 Feb 2011 09:46:09 -0000	1.133
+++ thread.c	19 Feb 2011 01:01:36 -0000
@@ -976,32 +976,12 @@ info_threads_command (char *arg, int fro
 
   while (arg != NULL && *arg != '\0')
     {
-      int tmp_tid = strtol (arg, &arg, 0);
-      unsigned int highrange;
+      tid = get_number_or_range (&arg);
 
-      if (tmp_tid <= 0)
-	error (_("invalid thread id %d"), tmp_tid);
+      if (tid <= 0)
+	error (_("invalid thread id %d"), tid);
 
-      tid = tmp_tid;
       print_thread_info (uiout, tid, -1);
-
-      while (*arg == ' ' || *arg == '\t')
-	++arg;
-
-      if (*arg == '-')
-	{
-	  /* Do a range of threads.  Must be in ascending order.  */
-	  ++arg;	/* Skip the hyphen.  */
-	  highrange = strtoul (arg, &arg, 0);
-	  if (highrange < tid)
-	    error (_("inverted range"));
-
-	  /* Do the threads in the range (first one already done).  */
-	  while (tid < highrange)
-	    {
-	      print_thread_info (uiout, ++tid, -1);
-	    }
-	}
     }
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]