]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.threads/thread-specific.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / thread-specific.exp
CommitLineData
6aba47ca 1# Copyright 2004, 2007 Free Software Foundation, Inc.
c47cebdb
DJ
2
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.
12#
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.
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
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.
23
24if $tracelevel then {
25 strace $tracelevel
26}
27
28set prms_id 0
29set bug_id 0
30
31set testfile "thread-specific"
32set srcfile ${testfile}.c
33set binfile ${objdir}/${subdir}/${testfile}
34
35if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
36 return -1
37}
38
39# Return a list of the valid thread IDs, with the initial thread first.
40proc get_thread_list { } {
41 global gdb_prompt
42 global expect_out
43
44 set thr_list ""
45
46 gdb_test_multiple "info threads" "get threads list" {
47 -re "info threads\r\n" {
48 exp_continue
49 }
50 -re "^\\* *(\[0-9\]*) Thread \[^\n\]*main\[^\n\]*\n" {
51 set thr_list "$expect_out(1,string) $thr_list"
52 exp_continue
53 }
54 -re "^ *(\[0-9\]*) Thread \[^\n\]*\n" {
55 lappend thr_list $expect_out(1,string)
56 exp_continue
57 }
58 -re ".*$gdb_prompt $" {
59 if { [llength $thr_list] != 0 } {
60 pass "get threads list"
61 } else {
62 fail "get threads list (no threads)"
63 }
64 }
65 }
66
67 return $thr_list
68}
69
70# Start with a fresh gdb.
71
72gdb_exit
73gdb_start
74gdb_reinitialize_dir $srcdir/$subdir
75
76gdb_load ${binfile}
77
78gdb_test "set print sevenbit-strings" ""
79gdb_test "set width 0" ""
80
81runto_main
82
83gdb_breakpoint [gdb_get_line_number "thread-specific.exp: last thread start"]
84gdb_continue_to_breakpoint "all threads started"
85
86set line [gdb_get_line_number "thread-specific.exp: thread loop"]
87set threads [get_thread_list]
88
9cf689d7
DJ
89if {[llength $threads] == 0} {
90 # We have already issued a FAIL above.
91 return 1
92}
93
c47cebdb
DJ
94gdb_test_multiple "break $line thread [lindex $threads 0]" \
95 "breakpoint $line main thread" {
44c75849 96 -re "Breakpoint (\[0-9\]*) at.* file .*$srcfile, line.*$gdb_prompt $" {
c47cebdb
DJ
97 set main_breakpoint $expect_out(1,string)
98 pass "breakpoint $line main thread"
99 }
100}
101
102foreach thread [lrange $threads 1 end] {
103 gdb_breakpoint "$line thread $thread"
104}
105
106gdb_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)"
109 }
110 -re "Breakpoint .* at .*\r\n$gdb_prompt $" {
111 pass "continue to thread-specific breakpoint"
112 }
113}
114
115return 0