[RFC] info threads takes an argument

Jan Kratochvil jan.kratochvil@redhat.com
Thu Feb 17 21:22:00 GMT 2011


On Thu, 17 Feb 2011 20:45:58 +0100, Michael Snyder wrote:
> You're right, there is an extra .* in there.
> Can you please try the attached?

It still FAILs.  Shouldn't there be \[^\r\n\]* instead of \[\r\n\]*?
BTW i7-920 (4 cores + hyperthreading), Fedora 15 x86_64.

Attaching also my attempt first today but I haven't finished it to a state to
make it running as I have too much stuff to do here now.

BTW I do not like any .* there in such unanchored regexes, it is still too
fragile while it may not cause problems right now.  The part ". 3 .*\"... can
match almost anything, some random digit between 1 to 6 can possibly appear
somewhere and it can eat some text again.


Thanks,
Jan
-------------- next part --------------
Test Run By jkratoch on Thu Feb 17 21:49:51 2011
Native configuration is x86_64-unknown-linux-gnu

		=== gdb tests ===

Schedule of variations:
    unix

Running target unix
Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /usr/share/dejagnu/config/unix.exp as generic interface file for target.
Using ./config/unix.exp as tool-and-target-specific interface file.
Running ./gdb.threads/thread-find.exp ...
Executing on host: gcc ./gdb.threads/linux-dp.c  -g  -lpthreads -lm   -o /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/linux-dp    (timeout = 300)
spawn -ignore SIGHUP gcc ./gdb.threads/linux-dp.c -g -lpthreads -lm -o /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/linux-dp
/usr/bin/ld: cannot find -lpthreads
collect2: ld returned 1 exit status
compiler exited with status 1
output is:
/usr/bin/ld: cannot find -lpthreads
collect2: ld returned 1 exit status

Executing on host: gcc ./gdb.threads/linux-dp.c  -g  -lpthread -lm   -o /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/linux-dp    (timeout = 300)
spawn -ignore SIGHUP gcc ./gdb.threads/linux-dp.c -g -lpthread -lm -o /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/linux-dp
PASS: gdb.threads/thread-find.exp: successfully compiled posix threads test case
spawn /home/jkratoch/redhat/gdb-clean/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/jkratoch/redhat/gdb-clean/gdb/testsuite/../data-directory
GNU gdb (GDB) 7.2.50.20110217-cvs
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) set height 0
(gdb) set width 0
(gdb) dir
Reinitialize source path to empty? (y or n) y
Source directories searched: $cdir:$cwd
(gdb) dir ./gdb.threads
Source directories searched: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/./gdb.threads:$cdir:$cwd
(gdb) kill
The program is not being run.
(gdb) file /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/linux-dp
Reading symbols from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/linux-dp...done.
(gdb) set print sevenbit-strings
(gdb) PASS: gdb.threads/thread-find.exp: set print sevenbit-strings
delete breakpoints
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) break main
Breakpoint 1 at 0x400eb8: file ./gdb.threads/linux-dp.c, line 162.
(gdb) run 
Starting program: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/linux-dp 
[Thread debugging using libthread_db enabled]

Breakpoint 1, main (argc=1, argv=0x7fffffffe058) at ./gdb.threads/linux-dp.c:162
162	  num_philosophers = 5;
(gdb) break 198
Breakpoint 2 at 0x401017: file ./gdb.threads/linux-dp.c, line 198.
(gdb) continue
Continuing.
[New Thread 0x7ffff759e700 (LWP 21313)]
  _ 0 _
  ! 0 _
[New Thread 0x7ffff6d9d700 (LWP 21314)]
      _ 1 _
      ! 1 _
[New Thread 0x7ffff659c700 (LWP 21315)]
          _ 2 _
          ! 2 _
[New Thread 0x7ffff5d9b700 (LWP 21316)]
              _ 3 _
              ! 3 _
[New Thread 0x7ffff559a700 (LWP 21317)]
                  _ 4 _

Breakpoint 2, main (argc=1, argv=0x7fffffffe058) at ./gdb.threads/linux-dp.c:199
199	  sleep (1000000);
(gdb) PASS: gdb.threads/thread-find.exp: continue to breakpoint: main thread's sleep
thread apply 1 thread name threadname_1

Thread 1 (Thread 0x7ffff7fe7720 (LWP 21310)):
(gdb) PASS: gdb.threads/thread-find.exp: name thread 1
thread apply 2 thread name threadname_2

Thread 2 (Thread 0x7ffff759e700 (LWP 21313)):
(gdb) PASS: gdb.threads/thread-find.exp: name thread 2
thread apply 3 thread name threadname_3

Thread 3 (Thread 0x7ffff6d9d700 (LWP 21314)):
(gdb) PASS: gdb.threads/thread-find.exp: name thread 3
thread apply 4 thread name threadname_4

Thread 4 (Thread 0x7ffff659c700 (LWP 21315)):
(gdb) PASS: gdb.threads/thread-find.exp: name thread 4
thread apply 5 thread name threadname_5

Thread 5 (Thread 0x7ffff5d9b700 (LWP 21316)):
(gdb) PASS: gdb.threads/thread-find.exp: name thread 5
thread apply 6 thread name threadname_6

Thread 6 (Thread 0x7ffff559a700 (LWP 21317)):
(gdb) PASS: gdb.threads/thread-find.exp: name thread 6
info threads
  Id   Target Id         Frame 
  6    Thread 0x7ffff559a700 (LWP 21317) "threadname_6" __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136
  5    Thread 0x7ffff5d9b700 (LWP 21316) "threadname_5" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
  4    Thread 0x7ffff659c700 (LWP 21315) "threadname_4" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
  3    Thread 0x7ffff6d9d700 (LWP 21314) "threadname_3" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
  2    Thread 0x7ffff759e700 (LWP 21313) "threadname_2" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
* 1    Thread 0x7ffff7fe7720 (LWP 21310) "threadname_1" main (argc=1, argv=0x7fffffffe058) at ./gdb.threads/linux-dp.c:199
(gdb) PASS: gdb.threads/thread-find.exp: collect thread id
echo 0x7ffff559a700\n
0x7ffff559a700
(gdb) PASS: gdb.threads/thread-find.exp: got thread ids
info threads
  Id   Target Id         Frame 
  6    Thread 0x7ffff559a700 (LWP 21317) "threadname_6" __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136
  5    Thread 0x7ffff5d9b700 (LWP 21316) "threadname_5" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
  4    Thread 0x7ffff659c700 (LWP 21315) "threadname_4" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
  3    Thread 0x7ffff6d9d700 (LWP 21314) "threadname_3" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
  2    Thread 0x7ffff759e700 (LWP 21313) "threadname_2" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
* 1    Thread 0x7ffff7fe7720 (LWP 21310) "threadname_1" main (argc=1, argv=0x7fffffffe058) at ./gdb.threads/linux-dp.c:199
(gdb) PASS: gdb.threads/thread-find.exp: collect process id
info threads
  Id   Target Id         Frame 
  6    Thread 0x7ffff559a700 (LWP 21317) "threadname_6" __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136
  5    Thread 0x7ffff5d9b700 (LWP 21316) "threadname_5" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
  4    Thread 0x7ffff659c700 (LWP 21315) "threadname_4" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
  3    Thread 0x7ffff6d9d700 (LWP 21314) "threadname_3" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
  2    Thread 0x7ffff759e700 (LWP 21313) "threadname_2" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
* 1    Thread 0x7ffff7fe7720 (LWP 21310) "threadname_1" main (argc=1, argv=0x7fffffffe058) at ./gdb.threads/linux-dp.c:199
(gdb) PASS: gdb.threads/thread-find.exp: collect lwp id
echo 21317\n
21317
(gdb) PASS: gdb.threads/thread-find.exp: got lwp ids
thread find threadname_6
Thread 6 has name 'threadname_6'
(gdb) PASS: gdb.threads/thread-find.exp: find thread name 6
thread find threadname_5
Thread 5 has name 'threadname_5'
(gdb) PASS: gdb.threads/thread-find.exp: find thread name 5
thread find threadname_4
Thread 4 has name 'threadname_4'
(gdb) PASS: gdb.threads/thread-find.exp: find thread name 4
thread find threadname_3
Thread 3 has name 'threadname_3'
(gdb) PASS: gdb.threads/thread-find.exp: find thread name 3
thread find threadname_2
Thread 2 has name 'threadname_2'
(gdb) PASS: gdb.threads/thread-find.exp: find thread name 2
thread find threadname_1
Thread 1 has name 'threadname_1'
(gdb) PASS: gdb.threads/thread-find.exp: find thread name 1
thread find 0x7ffff559a700
Thread 6 has target id 'Thread 0x7ffff559a700 (LWP 21317)'
(gdb) PASS: gdb.threads/thread-find.exp: find thread id 6
thread find 0x7ffff5d9b700
Thread 5 has target id 'Thread 0x7ffff5d9b700 (LWP 21316)'
(gdb) PASS: gdb.threads/thread-find.exp: find thread id 5
thread find 0x7ffff659c700
Thread 4 has target id 'Thread 0x7ffff659c700 (LWP 21315)'
(gdb) PASS: gdb.threads/thread-find.exp: find thread id 4
thread find 0x7ffff6d9d700
Thread 3 has target id 'Thread 0x7ffff6d9d700 (LWP 21314)'
(gdb) PASS: gdb.threads/thread-find.exp: find thread id 3
thread find 0x7ffff759e700
Thread 2 has target id 'Thread 0x7ffff759e700 (LWP 21313)'
(gdb) PASS: gdb.threads/thread-find.exp: find thread id 2
thread find 0x7ffff7fe7720
Thread 1 has target id 'Thread 0x7ffff7fe7720 (LWP 21310)'
(gdb) PASS: gdb.threads/thread-find.exp: find thread id 1
thread find 21317
Thread 6 has target id 'Thread 0x7ffff559a700 (LWP 21317)'
(gdb) PASS: gdb.threads/thread-find.exp: find lwp id 6
thread find 21316
Thread 5 has target id 'Thread 0x7ffff5d9b700 (LWP 21316)'
(gdb) PASS: gdb.threads/thread-find.exp: find lwp id 5
thread find 21315
Thread 4 has target id 'Thread 0x7ffff659c700 (LWP 21315)'
(gdb) PASS: gdb.threads/thread-find.exp: find lwp id 4
thread find 21314
Thread 3 has target id 'Thread 0x7ffff6d9d700 (LWP 21314)'
(gdb) PASS: gdb.threads/thread-find.exp: find lwp id 3
thread find 21313
Thread 2 has target id 'Thread 0x7ffff759e700 (LWP 21313)'
(gdb) PASS: gdb.threads/thread-find.exp: find lwp id 2
thread find 21310
Thread 1 has target id 'Thread 0x7ffff7fe7720 (LWP 21310)'
(gdb) PASS: gdb.threads/thread-find.exp: find lwp id 1
thread find foobarbaz
No threads match 'foobarbaz'
(gdb) PASS: gdb.threads/thread-find.exp: no thread
thread find threadname_[345]
Thread 5 has name 'threadname_5'
Thread 4 has name 'threadname_4'
Thread 3 has name 'threadname_3'
(gdb) PASS: gdb.threads/thread-find.exp: test regular exp
info threads 2 4 6
  Id   Target Id         Frame 
  2    Thread 0x7ffff759e700 (LWP 21313) "threadname_2" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
  Id   Target Id         Frame 
  4    Thread 0x7ffff659c700 (LWP 21315) "threadname_4" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
  Id   Target Id         Frame 
  6    Thread 0x7ffff559a700 (LWP 21317) "threadname_6" __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136
(gdb) PASS: gdb.threads/thread-find.exp: info threads 2 4 6
info threads 3-5
  Id   Target Id         Frame 
  3    Thread 0x7ffff6d9d700 (LWP 21314) "threadname_3" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
  Id   Target Id         Frame 
  4    Thread 0x7ffff659c700 (LWP 21315) "threadname_4" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
  Id   Target Id         Frame 
  5    Thread 0x7ffff5d9b700 (LWP 21316) "threadname_5" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
(gdb) FAIL: gdb.threads/thread-find.exp: info threads 3-5
info threads 5-3
  Id   Target Id         Frame 
  5    Thread 0x7ffff5d9b700 (LWP 21316) "threadname_5" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
inverted range
(gdb) PASS: gdb.threads/thread-find.exp: test inverted range
info threads 3-3
  Id   Target Id         Frame 
  3    Thread 0x7ffff6d9d700 (LWP 21314) "threadname_3" 0x00007ffff7678213 in select () at ../sysdeps/unix/syscall-template.S:82
(gdb) PASS: gdb.threads/thread-find.exp: info threads 3-3
testcase ./gdb.threads/thread-find.exp completed in 1 seconds

		=== gdb Summary ===

# of expected passes		37
# of unexpected failures	1
Executing on host: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/jkratoch/redhat/gdb-clean/gdb/testsuite/../data-directory --version    (timeout = 300)
spawn -ignore SIGHUP /home/jkratoch/redhat/gdb-clean/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/jkratoch/redhat/gdb-clean/gdb/testsuite/../data-directory --version
GNU gdb (GDB) 7.2.50.20110217-cvs
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
/home/jkratoch/redhat/gdb-clean/gdb/testsuite/../../gdb/gdb version  7.2.50.20110217-cvs -nw -nx -data-directory /home/jkratoch/redhat/gdb-clean/gdb/testsuite/../data-directory 

runtest completed at Thu Feb 17 21:49:52 2011
-------------- next part --------------
diff --git a/gdb/testsuite/gdb.threads/thread-find.exp b/gdb/testsuite/gdb.threads/thread-find.exp
index dd18a95..fb73963 100644
--- a/gdb/testsuite/gdb.threads/thread-find.exp
+++ b/gdb/testsuite/gdb.threads/thread-find.exp
@@ -65,31 +65,11 @@ gdb_test "thread apply 6 thread name threadname_6" \
 
 # Collect thread ids, if any.
 gdb_test_multiple "info threads" "collect thread id" {
-    -re ". 6 .*\[Tt\]hread (\[0-9a-fA-Fx\]+).* \"threadname_6\" \[^\r\n\]*" {
-	set thread6 $expect_out(1,string)
+    -re "\r\n. (\d) +\[Tt\]hread (\[0-9a-fA-Fx\]+) \[^\r\n\]* \"threadname_\1\" \[^\r\n\]*" {
+	eval "set thread$expect_out(1,string) \\$expect_out(2,string)"
 	exp_continue
     }
-    -re ". 5 .*\[Tt\]hread (\[0-9a-fA-Fx\]+).* \"threadname_5\" \[^\r\n\]*" {
-	set thread5 $expect_out(1,string)
-	exp_continue
-    }
-    -re ". 4 .*\[Tt\]hread (\[0-9a-fA-Fx\]+).* \"threadname_4\" \[^\r\n\]*" {
-	set thread4 $expect_out(1,string)
-	exp_continue
-    }
-    -re ". 3 .*\[Tt\]hread (\[0-9a-fA-Fx\]+).* \"threadname_3\" \[^\r\n\]*" {
-	set thread3 $expect_out(1,string)
-	exp_continue
-    }
-    -re ". 2 .*\[Tt\]hread (\[0-9a-fA-Fx\]+).* \"threadname_2\" \[^\r\n\]*" {
-	set thread2 $expect_out(1,string)
-	exp_continue
-    }
-    -re ". 1 .*\[Tt\]hread (\[0-9a-fA-Fx\]+).* \"threadname_1\" \[^\r\n\]*" {
-	set thread1 $expect_out(1,string)
-	exp_continue
-    }
-    -re ".*$gdb_prompt $" {
+    -re "\r\n$gdb_prompt $" {
 	pass "collect thread id"
     }
 }
@@ -100,31 +80,11 @@ if { [info exists thread6] } then {
 
 # Collect process ids, if any.
 gdb_test_multiple "info threads" "collect thread id" {
-    -re ". 6 .*\[Pp\]rocess (\[0-9a-fA-Fx\]+).* \"threadname_6\" \[^\r\n\]*" {
-	set process6 $expect_out(1,string)
-	exp_continue
-    }
-    -re ". 5 .*\[Pp\]rocess (\[0-9a-fA-Fx\]+).* \"threadname_5\" \[^\r\n\]*" {
-	set process5 $expect_out(1,string)
-	exp_continue
-    }
-    -re ". 4 .*\[Pp\]rocess (\[0-9a-fA-Fx\]+).* \"threadname_4\" \[^\r\n\]*" {
-	set process4 $expect_out(1,string)
-	exp_continue
-    }
-    -re ". 3 .*\[Pp\]rocess (\[0-9a-fA-Fx\]+).* \"threadname_3\" \[^\r\n\]*" {
-	set process3 $expect_out(1,string)
+    -re "\r\n. (\d) +\[Pp\]rocess (\[0-9a-fA-Fx\]+) \[^\r\n\]* \"threadname_\1\" \[^\r\n\]*" {
+	eval "set process$expect_out(1,string) \\$expect_out(2,string)"
 	exp_continue
     }
-    -re ". 2 .*\[Pp\]rocess (\[0-9a-fA-Fx\]+).* \"threadname_2\" \[^\r\n\]*" {
-	set process2 $expect_out(1,string)
-	exp_continue
-    }
-    -re ". 1 .*\[Pp\]rocess (\[0-9a-fA-Fx\]+).* \"threadname_1\" \[^\r\n\]*" {
-	set process1 $expect_out(1,string)
-	exp_continue
-    }
-    -re ".*$gdb_prompt $" {
+    -re "\r\n$gdb_prompt $" {
 	pass "collect process id"
     }
 }
@@ -135,31 +95,11 @@ if { [info exists process6] } then {
 
 # Collect lwp ids, if any.
 gdb_test_multiple "info threads" "collect thread id" {
-    -re ". 6 .*LWP (\[0-9a-fA-Fx\]+).* \"threadname_6\" \[^\r\n\]*" {
-	set lwp6 $expect_out(1,string)
-	exp_continue
-    }
-    -re ". 5 .*LWP (\[0-9a-fA-Fx\]+).* \"threadname_5\" \[^\r\n\]*" {
-	set lwp5 $expect_out(1,string)
-	exp_continue
-    }
-    -re ". 4 .*LWP (\[0-9a-fA-Fx\]+).* \"threadname_4\" \[^\r\n\]*" {
-	set lwp4 $expect_out(1,string)
-	exp_continue
-    }
-    -re ". 3 .*LWP (\[0-9a-fA-Fx\]+).* \"threadname_3\" \[^\r\n\]*" {
-	set lwp3 $expect_out(1,string)
-	exp_continue
-    }
-    -re ". 2 .*LWP (\[0-9a-fA-Fx\]+).* \"threadname_2\" \[^\r\n\]*" {
-	set lwp2 $expect_out(1,string)
-	exp_continue
-    }
-    -re ". 1 .*LWP (\[0-9a-fA-Fx\]+).* \"threadname_1\" \[^\r\n\]*" {
-	set lwp1 $expect_out(1,string)
+    -re "\r\n. (\d) +LWP (\[0-9a-fA-Fx\]+) \[^\r\n\]* \"threadname_\1\" \[^\r\n\]*" {
+	eval "set lwp$expect_out(1,string) \\$expect_out(2,string)"
 	exp_continue
     }
-    -re ".*$gdb_prompt $" {
+    -re "\r\n$gdb_prompt $" {
 	pass "collect lwp id"
     }
 }


More information about the Gdb-patches mailing list