Commit | Line | Data |
---|---|---|
4c38e0a4 | 1 | # Copyright 2007, 2008, 2009, 2010 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 | ||
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}" | |
759f0f0b PA |
35 | set lib_dlopen [shlib_target_file ${libname}] |
36 | set lib_syms [shlib_symbol_file ${libname}] | |
b0f4b84b DJ |
37 | |
38 | remote_exec build "rm -f ${binfile}" | |
39 | ||
40 | if [get_compiler_info ${binfile}] { | |
41 | return -1 | |
42 | } | |
43 | ||
759f0f0b | 44 | set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME\=\"${lib_dlopen}\"] |
b0f4b84b DJ |
45 | |
46 | if { [gdb_compile_shlib $libsrc $libobj {debug}] != "" | |
47 | || [gdb_compile $execsrc ${binfile} executable $exec_opts] != "" } { | |
48 | return -1 | |
49 | } | |
50 | ||
51 | gdb_exit | |
52 | gdb_start | |
53 | gdb_reinitialize_dir $srcdir/$subdir | |
54 | gdb_load ${binfile} | |
55 | gdb_load_shlibs $libobj | |
56 | ||
57 | if ![runto_main] then { | |
58 | fail "Can't run to main" | |
59 | return 0 | |
60 | } | |
61 | ||
27d3a1a2 | 62 | gdb_test_no_output "set stop-on-solib-events 1" |
b0f4b84b DJ |
63 | |
64 | gdb_test "continue" "Stopped due to shared library event" "continue to load" | |
65 | ||
66 | set msg "save \$pc after load" | |
67 | set saved_pc "" | |
68 | gdb_test_multiple "print/x \$pc" $msg { | |
69 | -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" { | |
70 | set saved_pc $expect_out(1,string) | |
71 | pass $msg | |
72 | } | |
73 | } | |
74 | ||
75 | gdb_test "disconnect" "Ending remote debugging\\." "disconnect after load" | |
76 | if { [gdb_reconnect] == 0 } { | |
77 | pass "reconnect after load" | |
78 | } else { | |
79 | fail "reconnect after load" | |
80 | return 0 | |
81 | } | |
82 | ||
83 | gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after load" | |
84 | ||
85 | ||
86 | gdb_test "continue" "Stopped due to shared library event" "continue to unload" | |
87 | ||
88 | set msg "save \$pc after unload" | |
89 | set saved_pc "" | |
90 | gdb_test_multiple "print/x \$pc" $msg { | |
91 | -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" { | |
92 | set saved_pc $expect_out(1,string) | |
93 | pass $msg | |
94 | } | |
95 | } | |
96 | ||
97 | gdb_test "disconnect" "Ending remote debugging\\." "disconnect after unload" | |
98 | if { [gdb_reconnect] == 0 } { | |
99 | pass "reconnect after unload" | |
100 | } else { | |
101 | fail "reconnect after unload" | |
102 | return 0 | |
103 | } | |
104 | ||
105 | gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after unload" |