Commit | Line | Data |
---|---|---|
ecd75fc8 | 1 | # Copyright 2012-2014 Free Software Foundation, Inc. |
afacd7f3 GB |
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 | if { [skip_shlib_tests] } { | |
17 | return 0 | |
18 | } | |
19 | ||
20 | standard_testfile | |
21 | ||
22 | set libname $testfile-solib | |
23 | set srcfile_lib $srcdir/$subdir/$libname.c | |
24 | set binfile_lib [standard_output_file $libname.so] | |
25 | ||
26 | set normal_bp "_dl_debug_state" | |
27 | set probes_bp "dl_main" | |
28 | ||
29 | if { [gdb_compile_shlib $srcfile_lib $binfile_lib \ | |
30 | [list additional_flags=-fPIC]] != "" } { | |
31 | untested "Could not compile $binfile_lib." | |
32 | return -1 | |
33 | } | |
34 | ||
35 | if { [prepare_for_testing $testfile.exp $testfile $srcfile \ | |
36 | [list additional_flags=-DSHLIB_NAME=\"$binfile_lib\" libs=-ldl]] } { | |
37 | return -1 | |
38 | } | |
39 | ||
40 | # Enable stop-on-solib-events | |
41 | gdb_test_no_output "set stop-on-solib-events 1" | |
42 | ||
43 | # Start the inferior and run to the first stop | |
44 | gdb_run_cmd | |
45 | gdb_test "" ".*Stopped due to shared library event.*" | |
46 | ||
47 | # XFAIL if we are not using probes | |
48 | set test "ensure using probes" | |
49 | set using_probes 0 | |
50 | gdb_test_multiple "bt" $test { | |
51 | -re "#0 +\[^\r\n\]*\\m(__GI_)?$normal_bp\\M.*$gdb_prompt $" { | |
52 | untested "probes not present on this system" | |
53 | } | |
54 | -re "#0 +\[^\r\n\]*\\m(__GI_)?$probes_bp\\M.*$gdb_prompt $" { | |
55 | pass $test | |
56 | set using_probes 1 | |
57 | } | |
58 | } | |
59 | ||
60 | if { $using_probes } { | |
61 | # Run til it loads our library | |
62 | set test "run til our library loads" | |
63 | set not_loaded_library 1 | |
64 | while { $not_loaded_library } { | |
65 | set not_loaded_library 0 | |
66 | gdb_test_multiple "c" $test { | |
67 | -re "Inferior loaded $binfile_lib\\M.*$gdb_prompt $" { | |
68 | pass $test | |
69 | } | |
70 | -re "Stopped due to shared library event\\M.*$gdb_prompt $" { | |
71 | set not_loaded_library 1 | |
72 | } | |
73 | } | |
74 | } | |
75 | ||
76 | # Call something to ensure that relocation occurred | |
77 | gdb_test "call foo(23)" "\\\$.* = 31.*\\\M.*" | |
78 | } |