1 # Copyright 2015-2020 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.
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.
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/>.
15 load_lib "trace-support.exp"
17 if {[skip_shlib_tests]} {
22 set executable $testfile
23 set expfile $testfile.exp
25 # Some targets have leading underscores on assembly symbols.
26 set options [list debug [gdb_target_symbol_prefix_flags]]
28 # Check that the target supports trace.
29 if ![gdb_trace_common_supports_arch] {
30 unsupported "no trace-common.h support for arch"
33 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
34 untested "failed to compile"
38 clean_restart ${testfile}
41 fail "can't run to main to check for trace support"
45 if ![gdb_target_supports_trace] {
46 unsupported "target does not support trace"
50 # Compile the test case with the in-process agent library.
51 set libipa [get_in_proc_agent]
52 gdb_load_shlib $libipa
54 lappend options shlib=$libipa
56 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
57 untested "failed to compile with in-process agent library"
61 # This test makes sure that disabling and enabling tracepoints works
62 # correctly. TRACEPOINT_CMD is the command used to set tracepoints
63 # (e.g. trace or ftrace).
65 proc test_tracepoint_enable_disable { tracepoint_cmd } {
66 with_test_prefix "test_tracepoint_enable_disable $tracepoint_cmd" {
68 clean_restart ${executable}
73 fail "can't run to main."
77 gdb_test "$tracepoint_cmd point_a" "(Tracepoint|Fast tracepoint) 2.*"
78 gdb_test "$tracepoint_cmd point_b" "(Tracepoint|Fast tracepoint) 3.*"
79 gdb_breakpoint "break_here"
80 gdb_test_no_output "tstart"
82 # Test that tracepoints start enabled
83 with_test_prefix "start" {
84 gdb_continue "break_here"
86 gdb_test "tstatus" "Collected $expected trace frames.*"
89 # Test that disabling works
90 with_test_prefix "disable #1" {
91 gdb_test_no_output "disable 2"
92 gdb_continue "break_here"
94 gdb_test "tstatus" "Collected $expected trace frames.*"
97 with_test_prefix "disable #2" {
98 gdb_test_no_output "disable 3"
99 gdb_continue "break_here"
100 gdb_test "tstatus" "Collected $expected trace frames.*"
103 # Test that disabling an already disabled tracepoint works
104 with_test_prefix "disable #3" {
105 gdb_test_no_output "disable 2"
106 gdb_continue "break_here"
107 gdb_test "tstatus" "Collected $expected trace frames.*"
110 # Test that enabling works
111 with_test_prefix "enable #1" {
112 gdb_test_no_output "enable 2"
113 gdb_continue "break_here"
115 gdb_test "tstatus" "Collected $expected trace frames.*"
118 with_test_prefix "enable #2" {
119 gdb_test_no_output "enable 3"
120 gdb_continue "break_here"
122 gdb_test "tstatus" "Collected $expected trace frames.*"
125 # Test that enabling an already enabled tracepoint works
126 with_test_prefix "enable #3" {
127 gdb_test_no_output "enable 3"
128 gdb_continue "break_here"
130 gdb_test "tstatus" "Collected $expected trace frames.*"
135 test_tracepoint_enable_disable trace
136 test_tracepoint_enable_disable ftrace