2005-11-09 Randolph Chung <tausq@debian.org>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / unload.exp
1 # Copyright 2003, 2004, 2005
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 # This file was created by Jeff Johnston. (jjohnstn@redhat.com)
19
20 if $tracelevel then {
21 strace $tracelevel
22 }
23
24 #
25 # test running programs
26 #
27 set prms_id 0
28 set bug_id 0
29
30 # are we on a target board?
31 if ![isnative] then {
32 return 0
33 }
34
35 set testfile "unload"
36 set libfile "unloadshr"
37 set libsrcfile ${libfile}.c
38 set srcfile $srcdir/$subdir/$testfile.c
39 set binfile $objdir/$subdir/$testfile
40 set shlibdir ${objdir}/${subdir}
41 set libsrc $srcdir/$subdir/$libfile.c
42 set lib_sl $objdir/$subdir/$libfile.sl
43
44 set dl_lib_flag ""
45 switch -glob [istarget] {
46 "hppa*-hp-hpux*" { }
47 "*-*-linux*" { set dl_lib_flag "libs=-ldl" }
48 "*-*-solaris*" { set dl_lib_flag "libs=-ldl" }
49 default { }
50 }
51
52 set lib_opts debug
53 set exec_opts [list debug $dl_lib_flag additional_flags=-DSHLIB_DIR\=\"${shlibdir}\"]
54
55 if [get_compiler_info ${binfile}] {
56 return -1
57 }
58
59 if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
60 || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} {
61 untested "Couldn't compile $libsrc or $srcfile."
62 return -1
63 }
64
65 # Start with a fresh gdb.
66
67 gdb_exit
68 gdb_start
69 gdb_reinitialize_dir $srcdir/$subdir
70 gdb_load ${binfile}
71
72 if [target_info exists gdb_stub] {
73 gdb_step_for_stub;
74 }
75
76 #
77 # Test setting a breakpoint in a dynamically loaded library which is
78 # manually loaded and unloaded
79 #
80
81 gdb_test_multiple "break shrfunc1" "set pending breakpoint" {
82 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
83 gdb_test "y" "Breakpoint.*shrfunc1.*pending." "set pending breakpoint"
84 }
85 }
86
87 gdb_test "info break" \
88 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
89 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*shrfunc1.*" \
90 "single pending breakpoint info"
91
92 set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}]
93
94 gdb_test "run" \
95 "Starting program.*unload.*
96 Breakpoint.*at.*
97 Pending breakpoint \"shrfunc1\" resolved.*
98 Breakpoint.*, shrfunc1 \\\(x=3\\\).*unloadshr.c:$unloadshr_line.*" \
99 "running program"
100
101 gdb_test "continue" \
102 "Continuing.*y is 7.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \
103 "continuing to end of program"
104
105 #
106 # Try to rerun program and verify that shared breakpoint is reset properly
107 #
108
109 gdb_test "run" \
110 ".*Breakpoint.*shrfunc1.*at.*unloadshr.c:$unloadshr_line.*" \
111 "rerun to shared library breakpoint"
112
113 gdb_test "continue" \
114 "Continuing.*y is 7.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \
115 "continuing to end of program second time"
116
This page took 0.034155 seconds and 4 git commands to generate.