]>
Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 2003, 2004, 2005, 2007 Free Software Foundation, Inc. |
37fdf854 JJ |
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) | |
37fdf854 JJ |
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 | # are we on a target board? | |
30 | if ![isnative] then { | |
31 | return 0 | |
32 | } | |
33 | ||
34 | set testfile "unload" | |
35 | set libfile "unloadshr" | |
36 | set libsrcfile ${libfile}.c | |
5ea106f7 PG |
37 | set srcfile $srcdir/$subdir/$testfile.c |
38 | set binfile $objdir/$subdir/$testfile | |
37fdf854 | 39 | set shlibdir ${objdir}/${subdir} |
5ea106f7 PG |
40 | set libsrc $srcdir/$subdir/$libfile.c |
41 | set lib_sl $objdir/$subdir/$libfile.sl | |
37fdf854 JJ |
42 | |
43 | set dl_lib_flag "" | |
44 | switch -glob [istarget] { | |
45 | "hppa*-hp-hpux*" { } | |
46 | "*-*-linux*" { set dl_lib_flag "libs=-ldl" } | |
9cbe82da | 47 | "*-*-solaris*" { set dl_lib_flag "libs=-ldl" } |
37fdf854 JJ |
48 | default { } |
49 | } | |
50 | ||
5ea106f7 PG |
51 | set lib_opts debug |
52 | set exec_opts [list debug $dl_lib_flag additional_flags=-DSHLIB_DIR\=\"${shlibdir}\"] | |
37fdf854 | 53 | |
5ea106f7 PG |
54 | if [get_compiler_info ${binfile}] { |
55 | return -1 | |
37fdf854 JJ |
56 | } |
57 | ||
5ea106f7 PG |
58 | if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" |
59 | || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} { | |
60 | untested "Couldn't compile $libsrc or $srcfile." | |
61 | return -1 | |
37fdf854 JJ |
62 | } |
63 | ||
5ea106f7 | 64 | # Start with a fresh gdb. |
37fdf854 JJ |
65 | |
66 | gdb_exit | |
67 | gdb_start | |
68 | gdb_reinitialize_dir $srcdir/$subdir | |
69 | gdb_load ${binfile} | |
70 | ||
71 | if [target_info exists gdb_stub] { | |
72 | gdb_step_for_stub; | |
73 | } | |
74 | ||
75 | # | |
76 | # Test setting a breakpoint in a dynamically loaded library which is | |
77 | # manually loaded and unloaded | |
78 | # | |
79 | ||
80 | gdb_test_multiple "break shrfunc1" "set pending breakpoint" { | |
81 | -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" { | |
82 | gdb_test "y" "Breakpoint.*shrfunc1.*pending." "set pending breakpoint" | |
83 | } | |
84 | } | |
85 | ||
86 | gdb_test "info break" \ | |
87 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
88 | \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*shrfunc1.*" \ | |
89 | "single pending breakpoint info" | |
90 | ||
0107feed | 91 | set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}] |
37fdf854 | 92 | |
b741e217 DJ |
93 | gdb_run_cmd |
94 | gdb_test "" \ | |
95 | "Breakpoint.*at.* | |
37fdf854 JJ |
96 | Pending breakpoint \"shrfunc1\" resolved.* |
97 | Breakpoint.*, shrfunc1 \\\(x=3\\\).*unloadshr.c:$unloadshr_line.*" \ | |
98 | "running program" | |
99 | ||
100 | gdb_test "continue" \ | |
b741e217 | 101 | "Continuing.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \ |
37fdf854 JJ |
102 | "continuing to end of program" |
103 | ||
104 | # | |
105 | # Try to rerun program and verify that shared breakpoint is reset properly | |
106 | # | |
107 | ||
b741e217 DJ |
108 | gdb_run_cmd |
109 | gdb_test "" \ | |
37fdf854 JJ |
110 | ".*Breakpoint.*shrfunc1.*at.*unloadshr.c:$unloadshr_line.*" \ |
111 | "rerun to shared library breakpoint" | |
112 | ||
113 | gdb_test "continue" \ | |
b741e217 | 114 | "Continuing.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \ |
1236e623 | 115 | "continuing to end of program second time" |
edd9b715 | 116 |