* lib/gdb.exp (gdb_compile): Add support for Windows DLLs.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / unload.exp
1 # Copyright 2003, 2004, 2005, 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 # This file was created by Jeff Johnston. (jjohnstn@redhat.com)
18
19 if $tracelevel then {
20 strace $tracelevel
21 }
22
23 #
24 # test running programs
25 #
26 set prms_id 0
27 set bug_id 0
28
29 if {[skip_shlib_tests]} {
30 return 0
31 }
32
33 # TODO: Use LoadLibrary on these targets instead of dlopen.
34 if {([istarget arm*-*-symbianelf*]
35 || [istarget *-*-mingw*]
36 || [istarget *-*-cygwin*]
37 || [istarget *-*-pe*])} {
38 return 0
39 }
40
41 set testfile "unload"
42 set libfile "unloadshr"
43 set libsrcfile ${libfile}.c
44 set srcfile $srcdir/$subdir/$testfile.c
45 set binfile $objdir/$subdir/$testfile
46 set shlibdir ${objdir}/${subdir}
47 set libsrc $srcdir/$subdir/$libfile.c
48 set lib_sl $objdir/$subdir/$libfile.sl
49
50 set lib_opts debug
51 set exec_opts [list debug additional_flags=-DSHLIB_DIR\=\"${shlibdir}\"]
52
53 switch -glob [istarget] {
54 "hppa*-hp-hpux*" { }
55 "*-*-linux*" { lappend exec_opts "libs=-ldl" }
56 "*-*-solaris*" { lappend exec_opts "libs=-ldl" }
57 default { }
58 }
59
60 if [get_compiler_info ${binfile}] {
61 return -1
62 }
63
64 if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
65 || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} {
66 untested "Couldn't compile $libsrc or $srcfile."
67 return -1
68 }
69
70 # Start with a fresh gdb.
71
72 gdb_exit
73 gdb_start
74 gdb_reinitialize_dir $srcdir/$subdir
75 gdb_load ${binfile}
76 gdb_load_shlibs $lib_sl
77
78 if [target_info exists gdb_stub] {
79 gdb_step_for_stub;
80 }
81
82 #
83 # Test setting a breakpoint in a dynamically loaded library which is
84 # manually loaded and unloaded
85 #
86
87 gdb_test_multiple "break shrfunc1" "set pending breakpoint" {
88 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
89 gdb_test "y" "Breakpoint.*shrfunc1.*pending." "set pending breakpoint"
90 }
91 }
92
93 gdb_test "info break" \
94 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
95 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*shrfunc1.*" \
96 "single pending breakpoint info"
97
98 set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}]
99
100 gdb_run_cmd
101 gdb_test "" \
102 "Breakpoint.*at.*
103 Pending breakpoint \"shrfunc1\" resolved.*
104 Breakpoint.*, shrfunc1 \\\(x=3\\\).*unloadshr.c:$unloadshr_line.*" \
105 "running program"
106
107 gdb_test "continue" \
108 "Continuing.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \
109 "continuing to end of program"
110
111 #
112 # Try to rerun program and verify that shared breakpoint is reset properly
113 #
114
115 gdb_run_cmd
116 gdb_test "" \
117 ".*Breakpoint.*shrfunc1.*at.*unloadshr.c:$unloadshr_line.*" \
118 "rerun to shared library breakpoint"
119
120 gdb_test "continue" \
121 "Continuing.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \
122 "continuing to end of program second time"
123
This page took 0.0329 seconds and 4 git commands to generate.