OLD | NEW |
1 # Copyright 2012 Free Software Foundation, Inc. | 1 # Copyright 2012-2013 Free Software Foundation, Inc. |
2 # This program is free software; you can redistribute it and/or modify | 2 # This program is free software; you can redistribute it and/or modify |
3 # it under the terms of the GNU General Public License as published by | 3 # it under the terms of the GNU General Public License as published by |
4 # the Free Software Foundation; either version 3 of the License, or | 4 # the Free Software Foundation; either version 3 of the License, or |
5 # (at your option) any later version. | 5 # (at your option) any later version. |
6 # | 6 # |
7 # This program is distributed in the hope that it will be useful, | 7 # This program is distributed in the hope that it will be useful, |
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 # GNU General Public License for more details. | 10 # GNU General Public License for more details. |
11 # | 11 # |
12 # You should have received a copy of the GNU General Public License | 12 # You should have received a copy of the GNU General Public License |
13 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 13 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
14 # | 14 # |
15 | 15 |
16 if {[skip_shlib_tests]} { | 16 if {[skip_shlib_tests]} { |
17 untested catch-load.exp | 17 untested catch-load.exp |
18 return -1 | 18 return -1 |
19 } | 19 } |
20 | 20 |
21 if {[get_compiler_info]} { | 21 if {[get_compiler_info]} { |
22 warning "Could not get compiler info" | 22 warning "Could not get compiler info" |
23 untested catch-load.exp | 23 untested catch-load.exp |
24 return -1 | 24 return -1 |
25 } | 25 } |
26 | 26 |
27 set testfile catch-load | 27 standard_testfile .c |
28 set srcfile ${testfile}.c | |
29 set binfile ${objdir}/${subdir}/${testfile} | |
30 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
ug shlib_load}] != "" } { | 28 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
ug shlib_load}] != "" } { |
31 untested catch-load.exp | 29 untested catch-load.exp |
32 return -1 | 30 return -1 |
33 } | 31 } |
34 | 32 |
35 set testfile2 catch-load-so | 33 set testfile2 catch-load-so |
36 set srcfile2 ${testfile2}.c | 34 set srcfile2 ${testfile2}.c |
37 set binfile2 ${objdir}/${subdir}/${testfile2}.so | 35 set binfile2 [standard_output_file ${testfile2}.so] |
38 set binfile2_dlopen [shlib_target_file ${testfile2}.so] | 36 set binfile2_dlopen [shlib_target_file ${testfile2}.so] |
39 if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug}] !
= "" } { | 37 if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug}] !
= "" } { |
40 untested catch-load.exp | 38 untested catch-load.exp |
41 return -1 | 39 return -1 |
42 } | 40 } |
43 | 41 |
44 # Run one set of tests. | 42 # Run one set of tests. |
45 # SCENARIO is the name of the test scenario, it is just used in test | 43 # SCENARIO is the name of the test scenario, it is just used in test |
46 # names. | 44 # names. |
47 # KIND is passed to the "catch" command. | 45 # KIND is passed to the "catch" command. |
48 # MATCH is a boolean saying whether we expect the catchpoint to be hit. | 46 # MATCH is a boolean saying whether we expect the catchpoint to be hit. |
49 proc one_catch_load_test {scenario kind match sostop} { with_test_prefix "${scen
ario}" { | 47 proc one_catch_load_test {scenario kind match sostop} { |
50 global verbose testfile testfile2 binfile2 binfile2_dlopen | 48 with_test_prefix "${scenario}" { |
51 global srcfile | 49 » global verbose testfile testfile2 binfile2 binfile2_dlopen |
52 global decimal gdb_prompt | 50 » global srcfile |
| 51 » global decimal gdb_prompt |
53 | 52 |
54 clean_restart $testfile | 53 » clean_restart $testfile |
55 gdb_load_shlibs $binfile2 | 54 » gdb_load_shlibs $binfile2 |
56 | 55 |
57 if {![runto_main]} { | 56 » if {![runto_main]} { |
58 » fail "can't run to main" | 57 » fail "can't run to main" |
59 » return | 58 » return |
60 } | 59 » } |
61 | 60 |
62 gdb_breakpoint [gdb_get_line_number "final breakpoint here"] | 61 » gdb_breakpoint [gdb_get_line_number "final breakpoint here"] |
63 gdb_test_no_output "set var libname = \"$binfile2_dlopen\"" | 62 » gdb_test_no_output "set var libname = \"$binfile2_dlopen\"" |
64 gdb_test_no_output "set stop-on-solib-events $sostop" | 63 » gdb_test_no_output "set stop-on-solib-events $sostop" |
65 gdb_test "catch $kind" "Catchpoint $decimal \\(.*\\)" | 64 » gdb_test "catch $kind" "Catchpoint $decimal \\(.*\\)" |
66 | 65 |
67 gdb_test_multiple "continue" "continue" { | 66 » gdb_test_multiple "continue" "continue" { |
68 » -re "Catchpoint $decimal\r\n.*loaded .*/$testfile2.*\r\n.*$gdb_prompt $"
{ | 67 » -re "Catchpoint $decimal\r\n.*loaded .*(\\\\|/)$testfile2.*\r\n.*$gd
b_prompt $" { |
69 » if {$match} { | 68 » » if {$match} { |
70 » » pass "continue" | 69 » » pass "continue" |
71 » } else { | 70 » » } else { |
| 71 » » fail "continue" |
| 72 » » } |
| 73 » } |
| 74 |
| 75 » -re "Stopped due to shared library event.*\r\n$gdb_prompt $" { |
| 76 » » if {$sostop} { |
| 77 » » pass "continue" |
| 78 » » } else { |
| 79 » » fail "continue" |
| 80 » » } |
| 81 » } |
| 82 |
| 83 » -re "Breakpoint $decimal, .*\r\n$gdb_prompt $" { |
| 84 » » if {!$match} { |
| 85 » » pass "continue" |
| 86 » » } else { |
| 87 » » fail "continue" |
| 88 » » } |
| 89 » } |
| 90 |
| 91 » -re ".*$gdb_prompt $" { |
72 fail "continue" | 92 fail "continue" |
73 } | 93 } |
74 } | 94 } |
75 | |
76 -re "Stopped due to shared library event.*\r\n$gdb_prompt $" { | |
77 if {$sostop} { | |
78 pass "continue" | |
79 } else { | |
80 fail "continue" | |
81 } | |
82 } | |
83 | |
84 -re "Breakpoint $decimal, .*\r\n$gdb_prompt $" { | |
85 if {!$match} { | |
86 pass "continue" | |
87 } else { | |
88 fail "continue" | |
89 } | |
90 } | |
91 | |
92 -re ".*$gdb_prompt $" { | |
93 fail "continue" | |
94 } | |
95 } | 95 } |
96 }} | 96 } |
97 | 97 |
98 one_catch_load_test "plain load" "load" 1 0 | 98 one_catch_load_test "plain load" "load" 1 0 |
99 one_catch_load_test "plain load with stop-on-solib-events" "load" 1 1 | 99 one_catch_load_test "plain load with stop-on-solib-events" "load" 1 1 |
100 one_catch_load_test "rx load" "load $testfile2" 1 0 | 100 one_catch_load_test "rx load" "load $testfile2" 1 0 |
101 one_catch_load_test "rx load with stop-on-solib-events" "load $testfile2" 1 1 | 101 one_catch_load_test "rx load with stop-on-solib-events" "load $testfile2" 1 1 |
102 one_catch_load_test "non-matching load" "load zardoz" 0 0 | 102 one_catch_load_test "non-matching load" "load zardoz" 0 0 |
103 one_catch_load_test "non-matching load with stop-on-solib-events" \ | 103 one_catch_load_test "non-matching load with stop-on-solib-events" \ |
104 "load zardoz" 0 1 | 104 "load zardoz" 0 1 |
105 | 105 |
106 one_catch_load_test "plain unload" "unload" 1 0 | 106 one_catch_load_test "plain unload" "unload" 1 0 |
107 one_catch_load_test "plain unload with stop-on-solib-events" "unload" 1 1 | 107 one_catch_load_test "plain unload with stop-on-solib-events" "unload" 1 1 |
108 one_catch_load_test "rx unload" "unload $testfile2" 1 0 | 108 one_catch_load_test "rx unload" "unload $testfile2" 1 0 |
109 one_catch_load_test "rx unload with stop-on-solib-events" \ | 109 one_catch_load_test "rx unload with stop-on-solib-events" \ |
110 "unload $testfile2" 1 1 | 110 "unload $testfile2" 1 1 |
111 one_catch_load_test "non-matching unload" "unload zardoz" 0 0 | 111 one_catch_load_test "non-matching unload" "unload zardoz" 0 0 |
112 one_catch_load_test "non-matching unload with stop-on-solib-events" \ | 112 one_catch_load_test "non-matching unload with stop-on-solib-events" \ |
113 "unload zardoz" 0 1 | 113 "unload zardoz" 0 1 |
OLD | NEW |