]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / ftrace-insn-reloc.exp
1 # Copyright 2015-2024 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
19 # Some targets have leading underscores on assembly symbols.
20 set additional_flags [gdb_target_symbol_prefix_flags]
21
22 if [prepare_for_testing "failed to prepare" $testfile-no-ipa $srcfile \
23 [list debug $additional_flags]] {
24 return -1
25 }
26
27 if ![runto_main] {
28 return -1
29 }
30
31 if ![gdb_target_supports_trace] {
32 unsupported "target does not support trace"
33 return -1
34 }
35
36 set libipa [get_in_proc_agent]
37
38 # Can't use prepare_for_testing, because that splits compiling into
39 # building objects and then linking, and we'd fail with "linker input
40 # file unused because linking not done" when building the object.
41
42 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
43 executable [list debug $additional_flags shlib=$libipa] ] != "" } {
44 untested "failed to compile"
45 return -1
46 }
47 clean_restart $testfile
48 set remote_libipa [gdb_load_shlib $libipa]
49
50 if ![runto_main] {
51 return 0
52 }
53
54 gdb_reinitialize_dir $srcdir/$subdir
55
56 if { [gdb_test "info sharedlibrary" ".*[file tail $libipa].*" "IPA loaded"] != 0 } {
57 untested "could not find IPA lib loaded"
58 return 1
59 }
60
61 # Read function name from testcases[N].
62
63 proc read_testcase { n } {
64 global gdb_prompt
65
66 set result -1
67 gdb_test_multiple "print testcases\[${n}\]" "read name of test case ${n}" {
68 -re "\[$\].*= .*<(.*)>.*$gdb_prompt $" {
69 set result $expect_out(1,string)
70 }
71 -re "$gdb_prompt $" { }
72 }
73
74 return $result
75 }
76
77 set n_testcases [gdb_readexpr "n_testcases"]
78
79 if { ${n_testcases} == 0 } {
80 untested "no instruction relocation to test"
81 return 1
82 }
83
84 # Set a fast tracepoint on each set_point${i} symbol. There is one for
85 # each testcase.
86 for { set i 0 } { ${i} < ${n_testcases} } { incr i } {
87 set testcase [read_testcase $i]
88
89 gdb_test "ftrace *set_point$i" "Fast tracepoint .*" \
90 "fast tracepoint on ${testcase}"
91 }
92
93 gdb_test "break pass" ".*" ""
94 gdb_test "break fail" ".*" ""
95
96 gdb_test_no_output "tstart" "start trace experiment"
97
98 # Make sure we have hit the pass breakpoint for each testcase.
99 for { set i 0 } { ${i} < ${n_testcases} } { incr i } {
100 set testcase [read_testcase $i]
101
102 gdb_test "continue" \
103 ".*Breakpoint \[0-9\]+, pass \(\).*" \
104 "relocated instruction at ${testcase}"
105 }
106
107 gdb_test "tstatus" ".*Collected ${n_testcases} trace frames.*" "check on trace status"
108
109 gdb_test "tstop" "" ""