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