* infrun.c (inferior_ignoring_startup_exec_events): Delete.
[external/binutils.git] / gdb / testsuite / gdb.base / solib-disc.exp
1 # Copyright 2007 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
16
17 # Test connecting and disconnecting at shared library events.
18
19 if {[skip_shlib_tests]} {
20     return 0
21 }
22
23 if { [info proc gdb_reconnect] == "" } {
24     return 0
25 }
26
27 set testfile solib-disc
28 set libfile so-disc-shr
29 set srcfile ${testfile}.c
30 set binfile ${objdir}/${subdir}/${testfile}
31
32 set libsrc "${srcdir}/${subdir}/${libfile}.c"
33 set libname "${libfile}.so"
34 set libobj "${objdir}/${subdir}/${libname}"
35 set execsrc "${srcdir}/${subdir}/${srcfile}"
36
37 remote_exec build "rm -f ${binfile}"
38
39 if [get_compiler_info ${binfile}] {
40     return -1
41 }
42
43 set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME\=\"${libname}\"]
44
45 if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
46      || [gdb_compile $execsrc ${binfile} executable $exec_opts] != "" } {
47     return -1
48 }
49
50 gdb_exit
51 gdb_start
52 gdb_reinitialize_dir $srcdir/$subdir
53 gdb_load ${binfile}
54 gdb_load_shlibs $libobj
55
56 if ![runto_main] then {
57     fail "Can't run to main"
58     return 0
59 }
60
61 gdb_test "set stop-on-solib-events 1" ""
62
63 gdb_test "continue" "Stopped due to shared library event" "continue to load"
64
65 set msg "save \$pc after load"
66 set saved_pc ""
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)
70         pass $msg
71     }
72 }
73
74 gdb_test "disconnect" "Ending remote debugging\\." "disconnect after load"
75 if { [gdb_reconnect] == 0 } {
76     pass "reconnect after load"
77 } else {
78     fail "reconnect after load"
79     return 0
80 }
81
82 gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after load"
83
84
85 gdb_test "continue" "Stopped due to shared library event" "continue to unload"
86
87 set msg "save \$pc after unload"
88 set saved_pc ""
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)
92         pass $msg
93     }
94 }
95
96 gdb_test "disconnect" "Ending remote debugging\\." "disconnect after unload"
97 if { [gdb_reconnect] == 0 } {
98     pass "reconnect after unload"
99 } else {
100     fail "reconnect after unload"
101     return 0
102 }
103
104 gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after unload"