Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.base / unload.exp
blobb852b1907f0ba10ccb51a51dd194b8aa3f620f0f
1 # Copyright 2003, 2004, 2005
2 # Free Software Foundation, Inc.
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.
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.
18 # This file was created by Jeff Johnston. (jjohnstn@redhat.com)
20 if $tracelevel then {
21 strace $tracelevel
25 # test running programs
27 set prms_id 0
28 set bug_id 0
30 # are we on a target board?
31 if ![isnative] then {
32 return 0
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
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 { }
52 set lib_opts debug
53 set exec_opts [list debug $dl_lib_flag additional_flags=-DSHLIB_DIR\=\"${shlibdir}\"]
55 if [get_compiler_info ${binfile}] {
56 return -1
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
65 # Start with a fresh gdb.
67 gdb_exit
68 gdb_start
69 gdb_reinitialize_dir $srcdir/$subdir
70 gdb_load ${binfile}
72 if [target_info exists gdb_stub] {
73 gdb_step_for_stub;
77 # Test setting a breakpoint in a dynamically loaded library which is
78 # manually loaded and unloaded
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"
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"
92 set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}]
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"
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"
106 # Try to rerun program and verify that shared breakpoint is reset properly
109 gdb_test "run" \
110 ".*Breakpoint.*shrfunc1.*at.*unloadshr.c:$unloadshr_line.*" \
111 "rerun to shared library breakpoint"
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"