X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gdb%2Ftestsuite%2Fgdb.threads%2Fthread-find.exp;h=5eb27dfe0c20ff318a665a2fa6d2310d7d20739d;hb=61baf725eca99af2569262d10aca03dcde2698f6;hp=dd18a958535b148e87220faf09569f887cec17fb;hpb=60f98dde0ae5b9d8a59732a67c6ea0b272cc1615;p=external%2Fbinutils.git diff --git a/gdb/testsuite/gdb.threads/thread-find.exp b/gdb/testsuite/gdb.threads/thread-find.exp index dd18a95..5eb27df 100644 --- a/gdb/testsuite/gdb.threads/thread-find.exp +++ b/gdb/testsuite/gdb.threads/thread-find.exp @@ -1,5 +1,4 @@ -# Copyright 2011 -# Free Software Foundation, Inc. +# Copyright 2011-2017 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,20 +16,12 @@ # Please email any bugs, comments, and/or additions to this file to: # bug-gdb@gnu.org -if $tracelevel then { - strace $tracelevel -} - -set testfile "linux-dp" -set srcfile ${testfile}.c -set binfile ${objdir}/${subdir}/${testfile} +standard_testfile linux-dp.c if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != ""} { return -1 } -gdb_start -gdb_reinitialize_dir $srcdir/$subdir -gdb_load ${binfile} +clean_restart ${binfile} gdb_test_no_output "set print sevenbit-strings" runto_main @@ -64,29 +55,11 @@ gdb_test "thread apply 6 thread name threadname_6" \ "name thread 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) - 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) + -re ". (\[0-9\]+) \[^\r\n\]*\[Tt\]hread (\[0-9a-fA-Fx\]+)\[^\r\n\]* \"threadname_\[0-9\]+\" \[^\r\n\]*" { + set thr_num $expect_out(1,string) + set thread$thr_num $expect_out(2,string) exp_continue } -re ".*$gdb_prompt $" { @@ -99,29 +72,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) - 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) + -re ". (\[0-9\]+) \[^\r\n\]*\[Pp\]rocess (\[0-9a-fA-Fx\]+)\[^\r\n\]* \"threadname_\[0-9\]+\" \[^\r\n\]*" { + set thr_num $expect_out(1,string) + set process$thr_num $expect_out(2,string) exp_continue } -re ".*$gdb_prompt $" { @@ -134,29 +89,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 ". (\[0-9\]+) \[^\r\n\]*LWP (\[0-9a-fA-Fx\]+)\[^\r\n\]* \"threadname_\[0-9\]+\" \[^\r\n\]*" { + set thr_num $expect_out(1,string) + set lwp$thr_num $expect_out(2,string) exp_continue } -re ".*$gdb_prompt $" { @@ -250,36 +187,13 @@ gdb_test "thread find foobarbaz" "No threads match .*" "no thread" # Test regular expression # -set see1 0 -set see2 0 -set see3 0 -set see4 0 -set see5 0 -set see6 0 - +for {set i 1} {$i <= 6} {incr i} { + set see$i 0 +} gdb_test_multiple "thread find threadname_\[345\]" "test regular exp" { - -re "Thread 6 has name \[^\r\n\]*" { - set see6 1 - exp_continue - } - -re "Thread 5 has name \[^\r\n\]*" { - set see5 1 - exp_continue - } - -re "Thread 4 has name \[^\r\n\]*" { - set see4 1 - exp_continue - } - -re "Thread 3 has name \[^\r\n\]*" { - set see3 1 - exp_continue - } - -re "Thread 2 has name \[^\r\n\]*" { - set see2 1 - exp_continue - } - -re "Thread 1 has name \[^\r\n\]*" { - set see1 1 + -re "Thread (\[0-9\]+) has name \[^\r\n\]*" { + set thr_num $expect_out(1,string) + set see$thr_num 1 exp_continue } -re ".*$gdb_prompt $" { @@ -295,39 +209,16 @@ gdb_test_multiple "thread find threadname_\[345\]" "test regular exp" { # Test info threads on a subset of threads # -set see1 0 -set see2 0 -set see3 0 -set see4 0 -set see5 0 -set see6 0 - +for {set i 1} {$i <= 6} {incr i} { + set see$i 0 +} gdb_test_multiple "info threads 2 4 6" "info threads 2 4 6" { - -re ". 6 .*\"threadname_6.*\" \[\r\n\]*" { - set see6 1 - exp_continue - } - -re ". 5 .*\"threadname_5.*\" \[\r\n\]*" { - set see5 1 - exp_continue - } - -re ". 4 .*\"threadname_4.*\" \[\r\n\]*" { - set see4 1 - exp_continue - } - -re ". 3 .*\"threadname_3.*\" \[\r\n\]*" { - set see3 1 + -re ". (\[0-9\]+) \[^\r\n\]*\"threadname_\[0-9\]+\" \[^\r\n\]*" { + set thr_num $expect_out(1,string) + set see$thr_num 1 exp_continue } - -re ". 2 .*\"threadname_2.*\" \[\r\n\]*" { - set see2 1 - exp_continue - } - -re ". 1 .*\"threadname_1.*\" \[\r\n\]*" { - set see1 1 - exp_continue - } - -re ".*$gdb_prompt $" { + -re "$gdb_prompt $" { if { $see2 && $see4 && $see6 && !$see1 && !$see3 && !$see5 } then { pass "info threads 2 4 6" } else { @@ -340,39 +231,16 @@ gdb_test_multiple "info threads 2 4 6" "info threads 2 4 6" { # Test info threads on a range # -set see1 0 -set see2 0 -set see3 0 -set see4 0 -set see5 0 -set see6 0 - +for {set i 1} {$i <= 6} {incr i} { + set see$i 0 +} gdb_test_multiple "info threads 3-5" "info threads 3-5" { - -re ". 6 .*\"threadname_6.*\" \[\r\n\]*" { - set see6 1 - exp_continue - } - -re ". 5 .*\"threadname_5.*\" \[\r\n\]*" { - set see5 1 - exp_continue - } - -re ". 4 .*\"threadname_4.*\" \[\r\n\]*" { - set see4 1 + -re ". (\[0-9\]+) \[^\r\n\]*\"threadname_\[0-9\]+\" \[^\r\n\]*" { + set thr_num $expect_out(1,string) + set see$thr_num 1 exp_continue } - -re ". 3 .*\"threadname_3.*\" \[\r\n\]*" { - set see3 1 - exp_continue - } - -re ". 2 .*\"threadname_2.*\" \[\r\n\]*" { - set see2 1 - exp_continue - } - -re ". 1 .*\"threadname_1.*\" \[\r\n\]*" { - set see1 1 - exp_continue - } - -re ".*$gdb_prompt $" { + -re "$gdb_prompt $" { if { $see3 && $see4 && $see5 && !$see1 && !$see2 && !$see6 } then { pass "info threads 3-5" } else { @@ -387,36 +255,13 @@ gdb_test "info threads 5-3" "inverted range" "test inverted range" # Test degenerate range -set see1 0 -set see2 0 -set see3 0 -set see4 0 -set see5 0 -set see6 0 - +for {set i 1} {$i <= 6} {incr i} { + set see$i 0 +} gdb_test_multiple "info threads 3-3" "info threads 3-3" { - -re ". 6 .*\"threadname_6.*\" \[\r\n\]*" { - set see6 1 - exp_continue - } - -re ". 5 .*\"threadname_5.*\" \[\r\n\]*" { - set see5 1 - exp_continue - } - -re ". 4 .*\"threadname_4.*\" \[\r\n\]*" { - set see4 1 - exp_continue - } - -re ". 3 .*\"threadname_3.*\" \[\r\n\]*" { - set see3 1 - exp_continue - } - -re ". 2 .*\"threadname_2.*\" \[\r\n\]*" { - set see2 1 - exp_continue - } - -re ". 1 .*\"threadname_1.*\" \[\r\n\]*" { - set see1 1 + -re ". (\[0-9\]+) .*\"threadname_\[0-9\]+\" \[^\r\n\]*" { + set thr_num $expect_out(1,string) + set see$thr_num 1 exp_continue } -re ".*$gdb_prompt $" { @@ -428,3 +273,12 @@ gdb_test_multiple "info threads 3-3" "info threads 3-3" { } } +# Test bad input + +gdb_test "info thread foo" \ + "Invalid thread ID: foo" \ + "info thread foo" + +gdb_test "info thread foo -1" \ + "Invalid thread ID: foo -1" \ + "info thread foo -1"