]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2007-2024 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 | ||
d6195dc9 | 18 | require allow_shlib_tests |
b0f4b84b | 19 | |
03f2bd59 | 20 | set gdbserver_reconnect_p 1 |
b0f4b84b | 21 | if { [info proc gdb_reconnect] == "" } { |
e0a8643d | 22 | unsupported "requires gdbserver reconnect" |
b0f4b84b DJ |
23 | return 0 |
24 | } | |
25 | ||
26 | set testfile solib-disc | |
27 | set libfile so-disc-shr | |
28 | set srcfile ${testfile}.c | |
7470adbb | 29 | set binfile [standard_output_file ${testfile}] |
b0f4b84b DJ |
30 | |
31 | set libsrc "${srcdir}/${subdir}/${libfile}.c" | |
32 | set libname "${libfile}.so" | |
7470adbb | 33 | set libobj [standard_output_file ${libname}] |
b0f4b84b | 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 | ||
c588eb20 | 40 | set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen}\"] |
b0f4b84b DJ |
41 | |
42 | if { [gdb_compile_shlib $libsrc $libobj {debug}] != "" | |
43 | || [gdb_compile $execsrc ${binfile} executable $exec_opts] != "" } { | |
44 | return -1 | |
45 | } | |
46 | ||
c95d486d | 47 | clean_restart $binfile |
d9019901 | 48 | gdb_load_shlib $libobj |
b0f4b84b | 49 | |
65a33d75 | 50 | if {![runto_main]} { |
b0f4b84b DJ |
51 | return 0 |
52 | } | |
53 | ||
27d3a1a2 | 54 | gdb_test_no_output "set stop-on-solib-events 1" |
b0f4b84b | 55 | |
484abf42 | 56 | gdb_test "continue" "Stopped due to shared library event.*" "continue to load" |
b0f4b84b DJ |
57 | |
58 | set msg "save \$pc after load" | |
59 | set saved_pc "" | |
60 | gdb_test_multiple "print/x \$pc" $msg { | |
61 | -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" { | |
62 | set saved_pc $expect_out(1,string) | |
63 | pass $msg | |
64 | } | |
65 | } | |
66 | ||
67 | gdb_test "disconnect" "Ending remote debugging\\." "disconnect after load" | |
68 | if { [gdb_reconnect] == 0 } { | |
69 | pass "reconnect after load" | |
70 | } else { | |
71 | fail "reconnect after load" | |
72 | return 0 | |
73 | } | |
74 | ||
75 | gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after load" | |
76 | ||
77 | ||
484abf42 | 78 | gdb_test "continue" "Stopped due to shared library event.*" "continue to unload" |
b0f4b84b DJ |
79 | |
80 | set msg "save \$pc after unload" | |
81 | set saved_pc "" | |
82 | gdb_test_multiple "print/x \$pc" $msg { | |
83 | -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" { | |
84 | set saved_pc $expect_out(1,string) | |
85 | pass $msg | |
86 | } | |
87 | } | |
88 | ||
89 | gdb_test "disconnect" "Ending remote debugging\\." "disconnect after unload" | |
90 | if { [gdb_reconnect] == 0 } { | |
91 | pass "reconnect after unload" | |
92 | } else { | |
93 | fail "reconnect after unload" | |
94 | return 0 | |
95 | } | |
96 | ||
97 | gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after unload" |