]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/solib-disc.exp
This commit was manufactured by cvs2svn to create branch
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / solib-disc.exp
1 # Copyright 2007, 2008 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
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
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 # Test connecting and disconnecting at shared library events.
17
18 if {[skip_shlib_tests]} {
19 return 0
20 }
21
22 if { [info proc gdb_reconnect] == "" } {
23 return 0
24 }
25
26 set testfile solib-disc
27 set libfile so-disc-shr
28 set srcfile ${testfile}.c
29 set binfile ${objdir}/${subdir}/${testfile}
30
31 set libsrc "${srcdir}/${subdir}/${libfile}.c"
32 set libname "${libfile}.so"
33 set libobj "${objdir}/${subdir}/${libname}"
34 set execsrc "${srcdir}/${subdir}/${srcfile}"
35
36 remote_exec build "rm -f ${binfile}"
37
38 if [get_compiler_info ${binfile}] {
39 return -1
40 }
41
42 set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME\=\"${libname}\"]
43
44 if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
45 || [gdb_compile $execsrc ${binfile} executable $exec_opts] != "" } {
46 return -1
47 }
48
49 gdb_exit
50 gdb_start
51 gdb_reinitialize_dir $srcdir/$subdir
52 gdb_load ${binfile}
53 gdb_load_shlibs $libobj
54
55 if ![runto_main] then {
56 fail "Can't run to main"
57 return 0
58 }
59
60 gdb_test "set stop-on-solib-events 1" ""
61
62 gdb_test "continue" "Stopped due to shared library event" "continue to load"
63
64 set msg "save \$pc after load"
65 set saved_pc ""
66 gdb_test_multiple "print/x \$pc" $msg {
67 -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
68 set saved_pc $expect_out(1,string)
69 pass $msg
70 }
71 }
72
73 gdb_test "disconnect" "Ending remote debugging\\." "disconnect after load"
74 if { [gdb_reconnect] == 0 } {
75 pass "reconnect after load"
76 } else {
77 fail "reconnect after load"
78 return 0
79 }
80
81 gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after load"
82
83
84 gdb_test "continue" "Stopped due to shared library event" "continue to unload"
85
86 set msg "save \$pc after unload"
87 set saved_pc ""
88 gdb_test_multiple "print/x \$pc" $msg {
89 -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
90 set saved_pc $expect_out(1,string)
91 pass $msg
92 }
93 }
94
95 gdb_test "disconnect" "Ending remote debugging\\." "disconnect after unload"
96 if { [gdb_reconnect] == 0 } {
97 pass "reconnect after unload"
98 } else {
99 fail "reconnect after unload"
100 return 0
101 }
102
103 gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after unload"