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]

[PATCH] fix for info thread on bad input


Hi

While I was doing some work on threads. I noticed a bug in
info thread command on bad input.

Let we have 2 threads.

(gdb) info thread
  Id   Target Id         Frame
* 2    Thread 0x7ffff77fd700 (LWP 4169) "a.out" start (arg=0x0) at 11568.c:5
  1    Thread 0x7ffff7fdc700 (LWP 4166) "a.out" 0x00007ffff7bc6148 in pthread_join ()
   from /lib/x86_64-linux-gnu/libpthread.so.0
(gdb) info thread 1 2 foo
  Id   Target Id         Frame
* 2    Thread 0x7ffff77fd700 (LWP 4169) "a.out" start (arg=0x0) at 11568.c:5
  1    Thread 0x7ffff7fdc700 (LWP 4166) "a.out" 0x00007ffff7bc6148 in pthread_join ()
   from /lib/x86_64-linux-gnu/libpthread.so.0

So gdb not giving error "Args must be numbers or $ variables.".
I fixed this iterating over all requested threads.
Please find below patch for it.

gdb/ChangeLog

2013-08-30  Muhammad Waqas  <mwaqas@codesourccery.com>

	*thread.c (print_thread_info): Iterate over
	all requested threads.

testsuite/ChangeLog

2013-08-30  Muhammad Waqas  <mwaqas@codesourccery.com>

	* gdb.threads/thread-find.exp: Add new test for
	info thread on bad input.
---
 gdb/testsuite/gdb.threads/thread-find.exp |    4 ++++
 gdb/thread.c                              |   11 +++++++++++
 2 files changed, 15 insertions(+)

diff --git a/gdb/testsuite/gdb.threads/thread-find.exp b/gdb/testsuite/gdb.threads/thread-find.exp
index ba59e1c..859e16b 100644
--- a/gdb/testsuite/gdb.threads/thread-find.exp
+++ b/gdb/testsuite/gdb.threads/thread-find.exp
@@ -432,3 +432,7 @@ gdb_test "info thread foo" \
 gdb_test "info thread foo -1" \
     "Args must be numbers or '.' variables." \
     "info thread foo -1"
+
+gdb_test "info thread 1 2 3 4 5 6 foo" \
+    "Args must be numbers or '.' variables." \
+    "info thread 1 2 3 4 5 6 foo"
diff --git a/gdb/thread.c b/gdb/thread.c
index 78851e4..e52dfa3 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -790,6 +790,17 @@ print_thread_info (struct ui_out *uiout, char *requested_threads, int pid)
   char *extra_info, *name, *target_id;
   int current_thread = -1;
 
+  if (requested_threads != NULL)
+    {
+      struct get_number_or_range_state state;
+
+      init_number_or_range (&state, requested_threads);
+
+      while (!state.finished)
+        if (get_number_or_range (&state) == 0)
+          error (_("Args must be numbers or '$' variables."));
+    }
+
   update_thread_list ();
   current_ptid = inferior_ptid;
 
-- 
1.7.9.5


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