Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.threads / thread-specific.exp
blob66f0bd2261c8872654566b8f72e292e989d5e7ba
1 # Copyright 2004 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Daniel Jacobowitz <drow@mvista.com>.
21 # It tests that the correct breakpoint is reported when we hit a
22 # thread-specific breakpoint inserted for several threads.
24 if $tracelevel then {
25 strace $tracelevel
28 set prms_id 0
29 set bug_id 0
31 set testfile "thread-specific"
32 set srcfile ${testfile}.c
33 set binfile ${objdir}/${subdir}/${testfile}
35 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
36 return -1
39 # Return a list of the valid thread IDs, with the initial thread first.
40 proc get_thread_list { } {
41 global gdb_prompt
42 global expect_out
44 set thr_list ""
46 gdb_test_multiple "info threads" "get threads list" {
47 -re "info threads\r\n" {
48 exp_continue
50 -re "^\\* *(\[0-9\]*) Thread \[^\n\]*main\[^\n\]*\n" {
51 set thr_list "$expect_out(1,string) $thr_list"
52 exp_continue
54 -re "^ *(\[0-9\]*) Thread \[^\n\]*\n" {
55 lappend thr_list $expect_out(1,string)
56 exp_continue
58 -re ".*$gdb_prompt $" {
59 if { [llength $thr_list] != 0 } {
60 pass "get threads list"
61 } else {
62 fail "get threads list (no threads)"
67 return $thr_list
70 # Start with a fresh gdb.
72 gdb_exit
73 gdb_start
74 gdb_reinitialize_dir $srcdir/$subdir
76 gdb_load ${binfile}
78 gdb_test "set print sevenbit-strings" ""
79 gdb_test "set width 0" ""
81 runto_main
83 gdb_breakpoint [gdb_get_line_number "thread-specific.exp: last thread start"]
84 gdb_continue_to_breakpoint "all threads started"
86 set line [gdb_get_line_number "thread-specific.exp: thread loop"]
87 set threads [get_thread_list]
89 if {[llength $threads] == 0} {
90 # We have already issued a FAIL above.
91 return 1
94 gdb_test_multiple "break $line thread [lindex $threads 0]" \
95 "breakpoint $line main thread" {
96 -re "Breakpoint (\[0-9\]*) at.* file .*$srcfile, line.*$gdb_prompt $" {
97 set main_breakpoint $expect_out(1,string)
98 pass "breakpoint $line main thread"
102 foreach thread [lrange $threads 1 end] {
103 gdb_breakpoint "$line thread $thread"
106 gdb_test_multiple "continue" "continue to thread-specific breakpoint" {
107 -re "Breakpoint $main_breakpoint, .* at .*\r\n$gdb_prompt $" {
108 fail "continue to thread-specific breakpoint (wrong breakpoint)"
110 -re "Breakpoint .* at .*\r\n$gdb_prompt $" {
111 pass "continue to thread-specific breakpoint"
115 return 0