Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2004-2016 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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c47cebdb | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c47cebdb DJ |
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. | |
e22f8b7c | 12 | # |
c47cebdb | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c47cebdb | 15 | |
c47cebdb DJ |
16 | # This file was written by Daniel Jacobowitz <drow@mvista.com>. |
17 | # It tests that the correct breakpoint is reported when we hit a | |
18 | # thread-specific breakpoint inserted for several threads. | |
19 | ||
c47cebdb | 20 | |
0efbbabc | 21 | standard_testfile |
c47cebdb | 22 | |
0efbbabc | 23 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug] != "" } { |
c47cebdb DJ |
24 | return -1 |
25 | } | |
26 | ||
27 | # Return a list of the valid thread IDs, with the initial thread first. | |
28 | proc get_thread_list { } { | |
29 | global gdb_prompt | |
30 | global expect_out | |
31 | ||
32 | set thr_list "" | |
33 | ||
34 | gdb_test_multiple "info threads" "get threads list" { | |
35 | -re "info threads\r\n" { | |
36 | exp_continue | |
37 | } | |
b32306ca UW |
38 | -re "New Thread \[^\n\]*\n" { |
39 | exp_continue | |
40 | } | |
a283af87 AS |
41 | -re "^ *Id *Target Id\[^\n\]*\n" { |
42 | exp_continue | |
43 | } | |
44 | -re "^\\* *(\[0-9\]*) *Thread \[^\n\]*main\[^\n\]*\n" { | |
c47cebdb DJ |
45 | set thr_list "$expect_out(1,string) $thr_list" |
46 | exp_continue | |
47 | } | |
a283af87 | 48 | -re "^ *(\[0-9\]*) *Thread \[^\n\]*\n" { |
c47cebdb DJ |
49 | lappend thr_list $expect_out(1,string) |
50 | exp_continue | |
51 | } | |
52 | -re ".*$gdb_prompt $" { | |
53 | if { [llength $thr_list] != 0 } { | |
54 | pass "get threads list" | |
55 | } else { | |
56 | fail "get threads list (no threads)" | |
57 | } | |
58 | } | |
59 | } | |
60 | ||
61 | return $thr_list | |
62 | } | |
63 | ||
0efbbabc | 64 | clean_restart ${binfile} |
c47cebdb | 65 | |
12b5d08a MS |
66 | gdb_test_no_output "set print sevenbit-strings" |
67 | gdb_test_no_output "set width 0" | |
c47cebdb | 68 | |
663f6d42 PA |
69 | # As this test only runs a single inferior, $_thread and $_gthread |
70 | # should match throughout. | |
6aed2dbc | 71 | gdb_test {print $_thread} ".* = 0" "thread var when not running" |
663f6d42 | 72 | gdb_test {print $_gthread} ".* = 0" "gthread var when not running" |
6aed2dbc | 73 | |
c47cebdb DJ |
74 | runto_main |
75 | ||
76 | gdb_breakpoint [gdb_get_line_number "thread-specific.exp: last thread start"] | |
77 | gdb_continue_to_breakpoint "all threads started" | |
78 | ||
79 | set line [gdb_get_line_number "thread-specific.exp: thread loop"] | |
80 | set threads [get_thread_list] | |
81 | ||
9cf689d7 DJ |
82 | if {[llength $threads] == 0} { |
83 | # We have already issued a FAIL above. | |
84 | return 1 | |
85 | } | |
86 | ||
6aed2dbc | 87 | gdb_test {print $_thread} ".* = [lindex $threads 0]" "thread var in main" |
663f6d42 | 88 | gdb_test {print $_gthread} ".* = [lindex $threads 0]" "gthread var in main" |
6aed2dbc | 89 | |
c47cebdb DJ |
90 | gdb_test_multiple "break $line thread [lindex $threads 0]" \ |
91 | "breakpoint $line main thread" { | |
44c75849 | 92 | -re "Breakpoint (\[0-9\]*) at.* file .*$srcfile, line.*$gdb_prompt $" { |
c47cebdb DJ |
93 | set main_breakpoint $expect_out(1,string) |
94 | pass "breakpoint $line main thread" | |
95 | } | |
96 | } | |
97 | ||
98 | foreach thread [lrange $threads 1 end] { | |
99 | gdb_breakpoint "$line thread $thread" | |
100 | } | |
101 | ||
ecebef6a | 102 | set this_breakpoint -1 |
c47cebdb DJ |
103 | gdb_test_multiple "continue" "continue to thread-specific breakpoint" { |
104 | -re "Breakpoint $main_breakpoint, .* at .*\r\n$gdb_prompt $" { | |
105 | fail "continue to thread-specific breakpoint (wrong breakpoint)" | |
106 | } | |
6aed2dbc SS |
107 | -re "Breakpoint (\[0-9\]*), .* at .*\r\n$gdb_prompt $" { |
108 | set this_breakpoint $expect_out(1,string) | |
c47cebdb DJ |
109 | pass "continue to thread-specific breakpoint" |
110 | } | |
111 | } | |
112 | ||
ecebef6a MR |
113 | set this_thread -1 |
114 | if { $this_breakpoint != -1 } { | |
115 | gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" { | |
116 | -re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" { | |
117 | set this_thread $expect_out(1,string) | |
118 | pass "found breakpoint for thread number" | |
119 | } | |
6aed2dbc | 120 | } |
ecebef6a MR |
121 | } else { |
122 | untested "info on bp" | |
6aed2dbc SS |
123 | } |
124 | ||
ecebef6a MR |
125 | if { $this_thread != -1 } { |
126 | gdb_test {print $_thread} ".* = $this_thread" "thread var at break" | |
663f6d42 | 127 | gdb_test {print $_gthread} ".* = $this_thread" "gthread var at break" |
ecebef6a MR |
128 | } else { |
129 | untested "thread var at break" | |
130 | } | |
6aed2dbc | 131 | |
c47cebdb | 132 | return 0 |