1 # Copyright
2012-2019 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.
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.
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
/>.
16 if {[skip_shlib_tests
]} {
17 untested
"skipping shared library tests"
21 if {[get_compiler_info
]} {
22 warning
"Could not get compiler info"
23 untested
"no compiler info"
28 if { [gdb_compile
"${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug shlib_load}] != "" } {
29 untested
"failed to compile"
33 set testfile2 catch
-load-so
34 set srcfile2 $
{testfile2
}.c
35 set binfile2
[standard_output_file $
{testfile2
}.so
]
36 set binfile2_dlopen
[shlib_target_file $
{testfile2
}.so
]
37 if { [gdb_compile_shlib
"${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug}] != "" } {
38 untested
"failed to compile shared library"
42 # Run one
set of tests.
43 # SCENARIO is the
name of the test scenario
, it is just used in test
45 # KIND is passed to the
"catch" command.
46 # MATCH is a
boolean saying whether we expect the catchpoint to be hit.
47 proc one_catch_load_test
{scenario kind match sostop
} {
48 with_test_prefix
"${scenario}" {
49 global verbose testfile testfile2 binfile2 binfile2_dlopen
51 global decimal gdb_prompt
53 clean_restart $testfile
54 gdb_load_shlib $binfile2
57 fail
"can't run to main"
61 gdb_breakpoint
[gdb_get_line_number
"final breakpoint here"]
62 gdb_test_no_output
"set var libname = \"$binfile2_dlopen\""
63 gdb_test_no_output
"set stop-on-solib-events $sostop"
64 gdb_test
"catch $kind" "Catchpoint $decimal \\(.*\\)"
66 gdb_test_multiple
"continue" "continue" {
67 -re
"Catchpoint $decimal\r\n.*loaded .*(\\\\|/)$testfile2.*\r\n.*$gdb_prompt $" {
75 -re
"Stopped due to shared library event.*\r\n$gdb_prompt $" {
83 -re
"Breakpoint $decimal, .*\r\n$gdb_prompt $" {
91 -re
".*$gdb_prompt $" {
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
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
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" \
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
108 one_catch_load_test
"rx unload" "unload $testfile2" 1 0
109 one_catch_load_test
"rx unload with stop-on-solib-events" \
110 "unload $testfile2" 1 1
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" \