Commit | Line | Data |
---|---|---|
61baf725 | 1 | # Copyright 2011-2017 Free Software Foundation, Inc. |
1bfeeb0f JL |
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 3 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, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # This file was written by Justin Lebar. (justin.lebar@gmail.com) | |
17 | ||
18 | # | |
19 | # Tests skipping shared libraries. | |
20 | # | |
21 | ||
22 | # This only works on GNU/Linux. | |
23 | if { ![isnative] || [is_remote host] || ![istarget *-linux*] || [skip_shlib_tests]} { | |
24 | continue | |
25 | } | |
26 | ||
27 | set test "skip-solib" | |
28 | set srcfile_main "${test}-main.c" | |
89e208db | 29 | set executable_main ${test}-test |
0ab77f5f | 30 | set binfile_main [standard_output_file ${executable_main}] |
1bfeeb0f JL |
31 | set srcfile_lib "${test}-lib.c" |
32 | set libname "lib${test}" | |
0ab77f5f | 33 | set binfile_lib [standard_output_file ${libname}.so] |
1bfeeb0f JL |
34 | |
35 | # | |
36 | # Compile our program under test. The main program references a shared library | |
37 | # libskip-solib.so, which contains two functions, square(), which is | |
38 | # referenced by the main program, and multiply(), which is not referenced by | |
39 | # the main program. | |
40 | # | |
41 | ||
42 | if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug additional_flags=-fPIC -Wl,-soname,${libname}.so]] != ""} { | |
43 | return -1 | |
44 | } | |
45 | ||
46 | if {[gdb_compile "${srcdir}/${subdir}/${srcfile_main}" "${binfile_main}.o" object debug] != ""} { | |
47 | return -1 | |
48 | } | |
49 | ||
0ab77f5f | 50 | set testobjdir [standard_output_file {}] |
1bfeeb0f | 51 | if {[gdb_compile "${binfile_main}.o" "${binfile_main}" executable \ |
0ab77f5f TT |
52 | [list debug "additional_flags=-L$testobjdir -l${test} \ |
53 | -Wl,-rpath=$testobjdir"]] != ""} { | |
1bfeeb0f JL |
54 | return -1 |
55 | } | |
56 | ||
89e208db | 57 | clean_restart ${executable_main} |
1bfeeb0f JL |
58 | |
59 | # | |
60 | # At this point, if we try to skip the file ${srcfile_lib} or the function | |
61 | # multiply(), we should get a prompt asking us if we want to enable the | |
62 | # skip entry pending a shared library load. | |
63 | # | |
64 | ||
65 | gdb_test "skip file ${srcfile_lib}" \ | |
66 | "File ${srcfile_lib} will be skipped when stepping." \ | |
67 | "ignoring file in solib" \ | |
68 | "No source file named ${srcfile_lib}.* | |
69 | Ignore file pending future shared library load.*" \ | |
70 | "y" | |
71 | ||
72 | # | |
85817405 | 73 | # Checkinfo skip list. |
1bfeeb0f JL |
74 | # |
75 | gdb_test "info skip" \ | |
cce0e923 DE |
76 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* |
77 | 1\\s+y\\s+n\\s+${srcfile_lib}\\s+n\\s+<none>\\s*" \ | |
1bfeeb0f JL |
78 | "info skip with pending file" |
79 | ||
80 | if ![runto_main] { fail "skip tests suppressed" } | |
81 | ||
82 | # | |
83 | # We shouldn't step into square(), since we skipped skip-solib-lib.c. | |
84 | # | |
85 | gdb_test "step" "" | |
86 | gdb_test "bt" "#0\\s+main.*" "step after ignoring solib file." | |
87 | ||
1bfeeb0f JL |
88 | # |
89 | # Now restart gdb and testing ignoring of a function inside a solib. | |
90 | # | |
89e208db | 91 | clean_restart ${executable_main} |
1bfeeb0f JL |
92 | |
93 | gdb_test "skip function multiply" \ | |
85817405 | 94 | "Function multiply will be skipped when stepping\\." \ |
1bfeeb0f JL |
95 | "ignoring function in solib" \ |
96 | "No function found named multiply..* | |
97 | Ignore function pending future shared library load.*" \ | |
98 | "y" | |
99 | ||
100 | if ![runto_main] { fail "skip tests suppressed" } | |
101 | ||
102 | # | |
103 | # Our first step should take us into square. | |
104 | # | |
105 | gdb_test "step" "square.*" | |
106 | ||
107 | # | |
108 | # Now our entry should no longer be pending. | |
109 | # | |
110 | gdb_test "info skip" \ | |
cce0e923 DE |
111 | "Num\\s+Enb\\s+Glob\\s+File\\s+RE\\s+Function\\s* |
112 | 1\\s+y\\s+n\\s+<none>\\s+n\\s+multiply\\s*" \ | |
85817405 | 113 | "info skip for function multiply" |
1bfeeb0f JL |
114 | |
115 | # | |
116 | # This step shouldn't go into multiply -- we should skip it and go on to the | |
117 | # last line of square. | |
118 | # | |
119 | gdb_test "step" "" | |
120 | gdb_test "bt" "#0\\s+square.*" |