Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2015-2016 Free Software Foundation, Inc. |
4dafcdeb JB |
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 | ||
52bbc560 JB |
16 | # The purpose of this testcase is to verify that we can "next" over |
17 | # a call to a function provided by one shared library made from another | |
18 | # shared library, and that GDB stops at the expected location. In this | |
19 | # case, the call is made from sub1 (provided by libdso1) and we are | |
20 | # calling sub2 (provided by libdso2). | |
21 | # | |
22 | # Note that, while this is not the main purpose of this testcase, it | |
23 | # also happens to exercise an issue with displaced stepping on amd64 | |
24 | # when libdso1 is mapped at an address greater than 0xffffffff. | |
25 | ||
4dafcdeb JB |
26 | if { [skip_shlib_tests] } { |
27 | return 0 | |
28 | } | |
29 | ||
30 | standard_testfile | |
31 | ||
32 | set output_dir [standard_output_file {}] | |
33 | ||
34 | set libdso2 $testfile-dso2 | |
35 | set srcfile_libdso2 $srcdir/$subdir/$libdso2.c | |
36 | set binfile_libdso2 [standard_output_file $libdso2.so] | |
37 | ||
38 | set libdso1 $testfile-dso1 | |
39 | set srcfile_libdso1 $srcdir/$subdir/$libdso1.c | |
40 | set binfile_libdso1 [standard_output_file $libdso1.so] | |
41 | ||
42 | if { [gdb_compile_shlib $srcfile_libdso2 $binfile_libdso2 \ | |
43 | [list debug additional_flags=-fPIC]] != "" } { | |
bc6c7af4 | 44 | untested "could not compile $binfile_libdso2." |
4dafcdeb JB |
45 | return -1 |
46 | } | |
47 | ||
48 | if { [gdb_compile_shlib $srcfile_libdso1 $binfile_libdso1 \ | |
49 | [list debug additional_flags=-fPIC]] != "" } { | |
bc6c7af4 | 50 | untested "could not compile $binfile_libdso1." |
4dafcdeb JB |
51 | return -1 |
52 | } | |
53 | ||
54 | if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable \ | |
55 | [list debug shlib=$binfile_libdso2 shlib=$binfile_libdso1]] != "" } { | |
56 | return -1 | |
57 | } | |
58 | ||
59 | clean_restart $binfile | |
d9019901 SM |
60 | gdb_load_shlib $binfile_libdso2 |
61 | gdb_load_shlib $binfile_libdso1 | |
4dafcdeb JB |
62 | |
63 | if { ![runto_main] } { | |
64 | return -1 | |
65 | } | |
66 | ||
ea8812bc | 67 | set bp_location [gdb_get_line_number "STOP HERE" [file tail $srcfile_libdso1]] |
26b188a2 | 68 | gdb_breakpoint ${libdso1}.c:${bp_location} |
4dafcdeb JB |
69 | |
70 | gdb_continue_to_breakpoint "at call to sub2" \ | |
71 | ".*sub2 ().*" | |
72 | ||
73 | gdb_test "next" \ | |
74 | ".*return 5;.*" \ | |
75 | "next over call to sub2" |