]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.trace/trace-enable-disable.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / trace-enable-disable.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 require allow_shlib_tests
18
19 standard_testfile
20 set executable $testfile
21 set expfile $testfile.exp
22
23 # Some targets have leading underscores on assembly symbols.
24 set options [list debug [gdb_target_symbol_prefix_flags]]
25
26 # Check that the target supports trace.
27 require gdb_trace_common_supports_arch
28 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
29 untested "failed to compile"
30 return -1
31 }
32
33 clean_restart ${testfile}
34
35 if ![runto_main] {
36 return -1
37 }
38
39 if ![gdb_target_supports_trace] {
40 unsupported "target does not support trace"
41 return -1
42 }
43
44 # Compile the test case with the in-process agent library.
45 set libipa [get_in_proc_agent]
46 gdb_load_shlib $libipa
47
48 lappend options shlib=$libipa
49
50 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
51 untested "failed to compile with in-process agent library"
52 return -1
53 }
54
55 # This test makes sure that disabling and enabling tracepoints works
56 # correctly. TRACEPOINT_CMD is the command used to set tracepoints
57 # (e.g. trace or ftrace).
58
59 proc test_tracepoint_enable_disable { tracepoint_cmd } {
60 with_test_prefix "test_tracepoint_enable_disable $tracepoint_cmd" {
61 global executable
62 clean_restart ${executable}
63
64 set expected 0
65
66 if ![runto_main] {
67 return -1
68 }
69
70 gdb_test "$tracepoint_cmd point_a" "(Tracepoint|Fast tracepoint) 2.*"
71 gdb_test "$tracepoint_cmd point_b" "(Tracepoint|Fast tracepoint) 3.*"
72 gdb_breakpoint "break_here"
73 gdb_test_no_output "tstart"
74
75 # Test that tracepoints start enabled
76 with_test_prefix "start" {
77 gdb_continue "break_here"
78 incr expected 2
79 gdb_test "tstatus" "Collected $expected trace frames.*"
80 }
81
82 # Test that disabling works
83 with_test_prefix "disable #1" {
84 gdb_test_no_output "disable 2"
85 gdb_continue "break_here"
86 incr expected 1
87 gdb_test "tstatus" "Collected $expected trace frames.*"
88 }
89
90 with_test_prefix "disable #2" {
91 gdb_test_no_output "disable 3"
92 gdb_continue "break_here"
93 gdb_test "tstatus" "Collected $expected trace frames.*"
94 }
95
96 # Test that disabling an already disabled tracepoint works
97 with_test_prefix "disable #3" {
98 gdb_test_no_output "disable 2"
99 gdb_continue "break_here"
100 gdb_test "tstatus" "Collected $expected trace frames.*"
101 }
102
103 # Test that enabling works
104 with_test_prefix "enable #1" {
105 gdb_test_no_output "enable 2"
106 gdb_continue "break_here"
107 incr expected 1
108 gdb_test "tstatus" "Collected $expected trace frames.*"
109 }
110
111 with_test_prefix "enable #2" {
112 gdb_test_no_output "enable 3"
113 gdb_continue "break_here"
114 incr expected 2
115 gdb_test "tstatus" "Collected $expected trace frames.*"
116 }
117
118 # Test that enabling an already enabled tracepoint works
119 with_test_prefix "enable #3" {
120 gdb_test_no_output "enable 3"
121 gdb_continue "break_here"
122 incr expected 2
123 gdb_test "tstatus" "Collected $expected trace frames.*"
124 }
125 }
126 }
127
128 test_tracepoint_enable_disable trace
129 test_tracepoint_enable_disable ftrace