Commit | Line | Data |
---|---|---|
9b254dd1 | 1 | # Copyright 2003, 2004, 2005, 2007, 2008 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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
37fdf854 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
37fdf854 JJ |
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. | |
e22f8b7c | 12 | # |
37fdf854 | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
37fdf854 JJ |
15 | |
16 | # This file was created by Jeff Johnston. (jjohnstn@redhat.com) | |
37fdf854 JJ |
17 | |
18 | if $tracelevel then { | |
19 | strace $tracelevel | |
20 | } | |
21 | ||
22 | # | |
23 | # test running programs | |
24 | # | |
25 | set prms_id 0 | |
26 | set bug_id 0 | |
27 | ||
93f02886 DJ |
28 | if {[skip_shlib_tests]} { |
29 | return 0 | |
30 | } | |
31 | ||
255e7678 DJ |
32 | # TODO: Use LoadLibrary on this target instead of dlopen. |
33 | if {[istarget arm*-*-symbianelf*]} { | |
37fdf854 JJ |
34 | return 0 |
35 | } | |
36 | ||
37 | set testfile "unload" | |
38 | set libfile "unloadshr" | |
255e7678 | 39 | set libname "${libfile}.sl" |
37fdf854 | 40 | set libsrcfile ${libfile}.c |
5ea106f7 PG |
41 | set srcfile $srcdir/$subdir/$testfile.c |
42 | set binfile $objdir/$subdir/$testfile | |
37fdf854 | 43 | set shlibdir ${objdir}/${subdir} |
5ea106f7 | 44 | set libsrc $srcdir/$subdir/$libfile.c |
255e7678 | 45 | set lib_sl $objdir/$subdir/$libname |
37fdf854 | 46 | |
5ea106f7 PG |
47 | if [get_compiler_info ${binfile}] { |
48 | return -1 | |
37fdf854 JJ |
49 | } |
50 | ||
255e7678 DJ |
51 | set lib_opts debug |
52 | set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME\=\"${libname}\"] | |
53 | ||
5ea106f7 PG |
54 | if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" |
55 | || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} { | |
56 | untested "Couldn't compile $libsrc or $srcfile." | |
57 | return -1 | |
37fdf854 JJ |
58 | } |
59 | ||
5ea106f7 | 60 | # Start with a fresh gdb. |
37fdf854 JJ |
61 | |
62 | gdb_exit | |
63 | gdb_start | |
64 | gdb_reinitialize_dir $srcdir/$subdir | |
65 | gdb_load ${binfile} | |
93f02886 | 66 | gdb_load_shlibs $lib_sl |
37fdf854 JJ |
67 | |
68 | if [target_info exists gdb_stub] { | |
69 | gdb_step_for_stub; | |
70 | } | |
71 | ||
72 | # | |
73 | # Test setting a breakpoint in a dynamically loaded library which is | |
74 | # manually loaded and unloaded | |
75 | # | |
76 | ||
77 | gdb_test_multiple "break shrfunc1" "set pending breakpoint" { | |
78 | -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" { | |
79 | gdb_test "y" "Breakpoint.*shrfunc1.*pending." "set pending breakpoint" | |
80 | } | |
81 | } | |
82 | ||
83 | gdb_test "info break" \ | |
54e52265 VP |
84 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* |
85 | \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*shrfunc1.*" \ | |
37fdf854 JJ |
86 | "single pending breakpoint info" |
87 | ||
0107feed | 88 | set unloadshr_line [gdb_get_line_number "unloadshr break" ${libsrcfile}] |
37fdf854 | 89 | |
b741e217 DJ |
90 | gdb_run_cmd |
91 | gdb_test "" \ | |
fe3f5fa8 | 92 | ".*Breakpoint.*, shrfunc1 \\\(x=3\\\).*unloadshr.c:$unloadshr_line.*" \ |
37fdf854 JJ |
93 | "running program" |
94 | ||
95 | gdb_test "continue" \ | |
b741e217 | 96 | "Continuing.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \ |
37fdf854 JJ |
97 | "continuing to end of program" |
98 | ||
99 | # | |
100 | # Try to rerun program and verify that shared breakpoint is reset properly | |
101 | # | |
102 | ||
b741e217 DJ |
103 | gdb_run_cmd |
104 | gdb_test "" \ | |
37fdf854 JJ |
105 | ".*Breakpoint.*shrfunc1.*at.*unloadshr.c:$unloadshr_line.*" \ |
106 | "rerun to shared library breakpoint" | |
107 | ||
108 | gdb_test "continue" \ | |
b741e217 | 109 | "Continuing.*warning: Temporarily disabling breakpoints for.*unloadshr.sl.*Program exited normally." \ |
1236e623 | 110 | "continuing to end of program second time" |
edd9b715 | 111 |