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.
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.
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}"]] != "" } {
39 #
Return a list of the valid thread IDs
, with the initial thread first.
40 proc get_thread_list
{ } {
46 gdb_test_multiple
"info threads" "get threads list" {
47 -re
"info threads\r\n" {
50 -re
"^\\* *(\[0-9\]*) Thread \[^\n\]*main\[^\n\]*\n" {
51 set thr_list
"$expect_out(1,string) $thr_list"
54 -re
"^ *(\[0-9\]*) Thread \[^\n\]*\n" {
55 lappend thr_list $expect_out
(1,string
)
58 -re
".*$gdb_prompt $" {
59 if { [llength $thr_list
] != 0 } {
60 pass
"get threads list"
62 fail
"get threads list (no threads)"
70 # Start with a fresh gdb.
74 gdb_reinitialize_dir $srcdir
/$subdir
78 gdb_test
"set print sevenbit-strings" ""
79 gdb_test
"set width 0" ""
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.
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"