Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: gdb/testsuite/gdb.base/solib-search.exp

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/testsuite/gdb.base/solib-search.c ('k') | gdb/testsuite/gdb.base/solib-search-lib1.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2013 Free Software Foundation, Inc.
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 # Test solib-search-path, and in the case of solib-svr4.c whether l_addr_p
17 # is properly reset when the path is changed.
18
19 if {[is_remote target] || [skip_shlib_tests]} {
20 untested solib-search.exp
21 return -1
22 }
23
24 # This is required by gdb_compile_shlib.
25 if {[get_compiler_info]} {
26 warning "Could not get compiler info"
27 untested solib-search.exp
28 return 1
29 }
30
31 # Build "wrong" and "right" versions of the libraries in separate directories.
32 set wrong_lib_subdir "solib-search-wrong"
33 set right_lib_subdir "solib-search-right"
34
35 # First library file.
36 set libname1 "solib-search-lib1"
37 set srcfile1_lib ${srcdir}/${subdir}/${libname1}.c
38 set wrong_binfile1_lib \
39 [standard_output_file ${wrong_lib_subdir}/${libname1}.so]
40 set right_binfile1_lib \
41 [standard_output_file ${right_lib_subdir}/${libname1}.so]
42 # Second library file.
43 set libname2 "solib-search-lib2"
44 set srcfile2_lib ${srcdir}/${subdir}/${libname2}.c
45 set wrong_binfile2_lib \
46 [standard_output_file ${wrong_lib_subdir}/${libname2}.so]
47 set right_binfile2_lib \
48 [standard_output_file ${right_lib_subdir}/${libname2}.so]
49 # Link with the library that lives here.
50 # This is so that we can replace what gdb sees with the wrong copy,
51 # and then tell gdb to use the right copy that lives someplace else.
52 set binfile1_lib [standard_output_file ${libname1}.so]
53 set binfile2_lib [standard_output_file ${libname2}.so]
54
55 set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
56 set wrong_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=1"
57 set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192 -DRIGHT"
58
59 # Binary file.
60 standard_testfile .c
61 set bin_flags [list debug shlib=${binfile1_lib} shlib=${binfile2_lib}]
62
63 remote_exec build "rm -rf [standard_output_file ${wrong_lib_subdir}]"
64 remote_exec build "rm -rf [standard_output_file ${right_lib_subdir}]"
65 remote_exec build "mkdir [standard_output_file ${wrong_lib_subdir}]"
66 remote_exec build "mkdir [standard_output_file ${right_lib_subdir}]"
67
68 if { [gdb_compile_shlib ${srcfile1_lib} ${wrong_binfile1_lib} $wrong_lib_flags] != ""
69 || [gdb_compile_shlib ${srcfile2_lib} ${wrong_binfile2_lib} $wrong_lib_flag s] != ""
70 || [gdb_compile_shlib ${srcfile1_lib} ${right_binfile1_lib} $right_lib_flag s] != ""
71 || [gdb_compile_shlib ${srcfile2_lib} ${right_binfile2_lib} $right_lib_flag s] != "" } {
72 untested "Could not compile libs."
73 return -1
74 }
75
76 # Build the test binary using the right copies of the libraries.
77 remote_exec build "ln -sf ${right_lib_subdir}/${libname1}.so ${binfile1_lib}"
78 remote_exec build "ln -sf ${right_lib_subdir}/${libname2}.so ${binfile2_lib}"
79 if { [gdb_compile $srcdir/$subdir/${srcfile} ${binfile} \
80 executable $bin_flags] != "" } {
81 untested "Could not compile $binfile."
82 return -1
83 }
84
85 clean_restart $testfile
86
87 if { ![runto_main] } {
88 fail "Can't run to main"
89 return
90 }
91
92 gdb_breakpoint "break_here"
93 gdb_continue "break_here"
94
95 set corefile [standard_output_file solib-search.core]
96 set core_supported [gdb_gcore_cmd "$corefile" "save a corefile"]
97
98 if {!$core_supported} {
99 return -1
100 }
101
102 # Before we restart gdb, replace the libs with the "wrong" ones.
103 remote_exec build "ln -sf ${wrong_lib_subdir}/${libname1}.so ${binfile1_lib}"
104 remote_exec build "ln -sf ${wrong_lib_subdir}/${libname2}.so ${binfile2_lib}"
105
106 clean_restart $testfile
107
108 set core_loaded [gdb_core_cmd $corefile "re-load generated corefile"]
109 if { $core_loaded == -1 } {
110 # No use proceeding from here.
111 return
112 }
113
114 proc test_backtrace { expect_fail } {
115 global gdb_prompt
116
117 set count 0
118 set total_expected 5
119
120 if { $expect_fail } {
121 set testname "backtrace (with wrong libs)"
122 } else {
123 set testname "backtrace (with right libs)"
124 }
125 # N.B. The order of the tests here is important.
126 # We need to count each function in the backtrace, and expect matches
127 # the first one it finds.
128 gdb_test_multiple "backtrace" $testname {
129 -re "\[^\r\n\]* in lib2_func4 \[^\r\n\]*" {
130 incr count
131 exp_continue
132 }
133 -re "\[^\r\n\]* in lib1_func3 \[^\r\n\]*" {
134 incr count
135 exp_continue
136 }
137 -re "\[^\r\n\]* in lib2_func2 \[^\r\n\]*" {
138 incr count
139 exp_continue
140 }
141 -re "\[^\r\n\]* in lib1_func1 \[^\r\n\]*" {
142 incr count
143 exp_continue
144 }
145 -re "\[^\r\n\]* in main \[^\r\n\]*" {
146 incr count
147 exp_continue
148 }
149 -re "\[\r\n\]$gdb_prompt $" {
150 pass "$testname (data collection)"
151 }
152 }
153
154 set fail 0
155 if { $expect_fail } {
156 # If the backtrace output is correct the test isn't sufficiently
157 # testing what it should.
158 if { $count == $total_expected } {
159 set fail 1
160 }
161 } else {
162 if { $count != $total_expected } {
163 set fail 1
164 }
165 }
166 if { $fail } {
167 fail $testname
168 } else {
169 pass $testname
170 }
171 }
172
173 # Verify the backtrace is messed up.
174 test_backtrace 1
175
176 # Remove the copies gdb currently sees: the absolute path is encoded in
177 # the core file and we want gdb to find the right copies elsewhere.
178 remote_exec build "rm -f ${binfile1_lib}"
179 remote_exec build "rm -f ${binfile2_lib}"
180 # Set solib-search-path to use the correct copies of libraries.
181 gdb_test "set solib-search-path [standard_output_file ${right_lib_subdir}]" \
182 "" \
183 "set solib-search-path"
184
185 # Verify gdb has properly updated the location of the libraries.
186 test_backtrace 0
187 gdb_test "p lib1_size" " = 8192"
188 gdb_test "p lib2_size" " = 8192"
189
OLDNEW
« no previous file with comments | « gdb/testsuite/gdb.base/solib-search.c ('k') | gdb/testsuite/gdb.base/solib-search-lib1.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698