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