]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
Fix IPA detection in ftrace-insn-reloc.exp
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / ftrace-insn-reloc.exp
1 # Copyright 2015-2016 Free Software Foundation, Inc.
2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation; either version 3 of the License, or
5 # (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
15 load_lib "trace-support.exp"
16
17 standard_testfile insn-reloc.c
18 set executable $testfile
19 set expfile $testfile.exp
20
21 # Some targets have leading underscores on assembly symbols.
22 set additional_flags [gdb_target_symbol_prefix_flags]
23
24 if [prepare_for_testing $expfile $executable $srcfile \
25 [list debug $additional_flags]] {
26 untested "failed to prepare for trace tests"
27 return -1
28 }
29
30 if ![runto_main] {
31 fail "Can't run to main to check for trace support"
32 return -1
33 }
34
35 if ![gdb_target_supports_trace] {
36 unsupported "target does not support trace"
37 return -1
38 }
39
40 set libipa [get_in_proc_agent]
41 gdb_load_shlibs $libipa
42
43 # Can't use prepare_for_testing, because that splits compiling into
44 # building objects and then linking, and we'd fail with "linker input
45 # file unused because linking not done" when building the object.
46
47 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
48 executable [list debug $additional_flags shlib=$libipa] ] != "" } {
49 untested "failed to compile ftrace tests"
50 return -1
51 }
52 clean_restart ${executable}
53
54 if ![runto_main] {
55 fail "Can't run to main for ftrace tests"
56 return 0
57 }
58
59 gdb_reinitialize_dir $srcdir/$subdir
60
61 if { [gdb_test "info sharedlibrary" ".*[file tail ${libipa}].*" "IPA loaded"] != 0 } {
62 untested "Could not find IPA lib loaded"
63 return 1
64 }
65
66 # Read function name from testcases[N].
67
68 proc read_testcase { n } {
69 global gdb_prompt
70
71 set result -1
72 gdb_test_multiple "print testcases\[${n}\]" "read name of test case ${n}" {
73 -re "\[$\].*= .*<(.*)>.*$gdb_prompt $" {
74 set result $expect_out(1,string)
75 }
76 -re "$gdb_prompt $" { }
77 }
78
79 return $result
80 }
81
82 set n_testcases [gdb_readexpr "n_testcases"]
83
84 if { ${n_testcases} == 0 } {
85 untested "No instruction relocation to test"
86 return 1
87 }
88
89 # Set a fast tracepoint on each set_point${i} symbol. There is one for
90 # each testcase.
91 for { set i 0 } { ${i} < ${n_testcases} } { incr i } {
92 set testcase [read_testcase $i]
93
94 gdb_test "ftrace *set_point$i" "Fast tracepoint .*" \
95 "fast tracepoint on ${testcase}"
96 }
97
98 gdb_test "break pass" ".*" ""
99 gdb_test "break fail" ".*" ""
100
101 gdb_test_no_output "tstart" "start trace experiment"
102
103 # Make sure we have hit the pass breakpoint for each testcase.
104 for { set i 0 } { ${i} < ${n_testcases} } { incr i } {
105 set testcase [read_testcase $i]
106
107 gdb_test "continue" \
108 ".*Breakpoint \[0-9\]+, pass \(\).*" \
109 "relocated instruction at ${testcase}"
110 }
111
112 gdb_test "tstatus" ".*Collected ${n_testcases} trace frames.*" "check on trace status"
113
114 gdb_test "tstop" "" ""