1 # Copyright 2007 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17 # Test connecting and disconnecting at shared library events.
19 if {[skip_shlib_tests]} {
23 if { [info proc gdb_reconnect] == "" } {
27 set testfile solib-disc
28 set libfile so-disc-shr
29 set srcfile ${testfile}.c
30 set binfile ${objdir}/${subdir}/${testfile}
32 set libsrc "${srcdir}/${subdir}/${libfile}.c"
33 set libname "${libfile}.so"
34 set libobj "${objdir}/${subdir}/${libname}"
35 set execsrc "${srcdir}/${subdir}/${srcfile}"
37 remote_exec build "rm -f ${binfile}"
39 if [get_compiler_info ${binfile}] {
43 set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME\=\"${libname}\"]
45 if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
46 || [gdb_compile $execsrc ${binfile} executable $exec_opts] != "" } {
52 gdb_reinitialize_dir $srcdir/$subdir
54 gdb_load_shlibs $libobj
56 if ![runto_main] then {
57 fail "Can't run to main"
61 gdb_test "set stop-on-solib-events 1" ""
63 gdb_test "continue" "Stopped due to shared library event" "continue to load"
65 set msg "save \$pc after load"
67 gdb_test_multiple "print/x \$pc" $msg {
68 -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
69 set saved_pc $expect_out(1,string)
74 gdb_test "disconnect" "Ending remote debugging\\." "disconnect after load"
75 if { [gdb_reconnect] == 0 } {
76 pass "reconnect after load"
78 fail "reconnect after load"
82 gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after load"
85 gdb_test "continue" "Stopped due to shared library event" "continue to unload"
87 set msg "save \$pc after unload"
89 gdb_test_multiple "print/x \$pc" $msg {
90 -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
91 set saved_pc $expect_out(1,string)
96 gdb_test "disconnect" "Ending remote debugging\\." "disconnect after unload"
97 if { [gdb_reconnect] == 0 } {
98 pass "reconnect after unload"
100 fail "reconnect after unload"
104 gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after unload"