GDB copyright headers update after running GDB's copyright.py script.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / solib-disc.exp
CommitLineData
618f726f 1# Copyright 2007-2016 Free Software Foundation, Inc.
b0f4b84b
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
b0f4b84b
DJ
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
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>. */
b0f4b84b
DJ
15
16# Test connecting and disconnecting at shared library events.
17
18if {[skip_shlib_tests]} {
19 return 0
20}
21
03f2bd59 22set gdbserver_reconnect_p 1
b0f4b84b
DJ
23if { [info proc gdb_reconnect] == "" } {
24 return 0
25}
26
27set testfile solib-disc
28set libfile so-disc-shr
29set srcfile ${testfile}.c
30set binfile ${objdir}/${subdir}/${testfile}
31
32set libsrc "${srcdir}/${subdir}/${libfile}.c"
33set libname "${libfile}.so"
34set libobj "${objdir}/${subdir}/${libname}"
35set execsrc "${srcdir}/${subdir}/${srcfile}"
759f0f0b
PA
36set lib_dlopen [shlib_target_file ${libname}]
37set lib_syms [shlib_symbol_file ${libname}]
b0f4b84b
DJ
38
39remote_exec build "rm -f ${binfile}"
40
4c93b1db 41if [get_compiler_info] {
b0f4b84b
DJ
42 return -1
43}
44
c588eb20 45set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen}\"]
b0f4b84b
DJ
46
47if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
48 || [gdb_compile $execsrc ${binfile} executable $exec_opts] != "" } {
49 return -1
50}
51
52gdb_exit
53gdb_start
54gdb_reinitialize_dir $srcdir/$subdir
55gdb_load ${binfile}
56gdb_load_shlibs $libobj
57
58if ![runto_main] then {
59 fail "Can't run to main"
60 return 0
61}
62
27d3a1a2 63gdb_test_no_output "set stop-on-solib-events 1"
b0f4b84b 64
484abf42 65gdb_test "continue" "Stopped due to shared library event.*" "continue to load"
b0f4b84b
DJ
66
67set msg "save \$pc after load"
68set saved_pc ""
69gdb_test_multiple "print/x \$pc" $msg {
70 -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
71 set saved_pc $expect_out(1,string)
72 pass $msg
73 }
74}
75
76gdb_test "disconnect" "Ending remote debugging\\." "disconnect after load"
77if { [gdb_reconnect] == 0 } {
78 pass "reconnect after load"
79} else {
80 fail "reconnect after load"
81 return 0
82}
83
84gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after load"
85
86
484abf42 87gdb_test "continue" "Stopped due to shared library event.*" "continue to unload"
b0f4b84b
DJ
88
89set msg "save \$pc after unload"
90set saved_pc ""
91gdb_test_multiple "print/x \$pc" $msg {
92 -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
93 set saved_pc $expect_out(1,string)
94 pass $msg
95 }
96}
97
98gdb_test "disconnect" "Ending remote debugging\\." "disconnect after unload"
99if { [gdb_reconnect] == 0 } {
100 pass "reconnect after unload"
101} else {
102 fail "reconnect after unload"
103 return 0
104}
105
106gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after unload"
This page took 1.086899 seconds and 4 git commands to generate.