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