Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2015-2020 Free Software Foundation, Inc. |
9080ac9d SM |
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 | ||
8bca2978 SL |
17 | if {[skip_shlib_tests]} { |
18 | return 0 | |
19 | } | |
20 | ||
9080ac9d SM |
21 | standard_testfile |
22 | set executable $testfile | |
23 | set expfile $testfile.exp | |
24 | ||
25 | # Some targets have leading underscores on assembly symbols. | |
26 | set options [list debug [gdb_target_symbol_prefix_flags]] | |
27 | ||
28 | # Check that the target supports trace. | |
8bca2978 SL |
29 | if ![gdb_trace_common_supports_arch] { |
30 | unsupported "no trace-common.h support for arch" | |
31 | return -1 | |
32 | } | |
9080ac9d | 33 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { |
84c93cd5 | 34 | untested "failed to compile" |
9080ac9d SM |
35 | return -1 |
36 | } | |
37 | ||
38 | clean_restart ${testfile} | |
39 | ||
40 | if ![runto_main] { | |
bc6c7af4 | 41 | fail "can't run to main to check for trace support" |
9080ac9d SM |
42 | return -1 |
43 | } | |
44 | ||
45 | if ![gdb_target_supports_trace] { | |
46 | unsupported "target does not support trace" | |
47 | return -1 | |
48 | } | |
49 | ||
50 | # Compile the test case with the in-process agent library. | |
51 | set libipa [get_in_proc_agent] | |
52 | gdb_load_shlib $libipa | |
53 | ||
54 | lappend options shlib=$libipa | |
55 | ||
56 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { | |
84c93cd5 | 57 | untested "failed to compile with in-process agent library" |
9080ac9d SM |
58 | return -1 |
59 | } | |
60 | ||
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). | |
64 | ||
65 | proc test_tracepoint_enable_disable { tracepoint_cmd } { | |
66 | with_test_prefix "test_tracepoint_enable_disable $tracepoint_cmd" { | |
67 | global executable | |
68 | clean_restart ${executable} | |
69 | ||
70 | set expected 0 | |
71 | ||
72 | if ![runto_main] { | |
bc6c7af4 | 73 | fail "can't run to main." |
9080ac9d SM |
74 | return -1 |
75 | } | |
76 | ||
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" | |
81 | ||
82 | # Test that tracepoints start enabled | |
83 | with_test_prefix "start" { | |
84 | gdb_continue "break_here" | |
85 | incr expected 2 | |
86 | gdb_test "tstatus" "Collected $expected trace frames.*" | |
87 | } | |
88 | ||
89 | # Test that disabling works | |
90 | with_test_prefix "disable #1" { | |
91 | gdb_test_no_output "disable 2" | |
92 | gdb_continue "break_here" | |
93 | incr expected 1 | |
94 | gdb_test "tstatus" "Collected $expected trace frames.*" | |
95 | } | |
96 | ||
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.*" | |
101 | } | |
102 | ||
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.*" | |
108 | } | |
109 | ||
110 | # Test that enabling works | |
111 | with_test_prefix "enable #1" { | |
112 | gdb_test_no_output "enable 2" | |
113 | gdb_continue "break_here" | |
114 | incr expected 1 | |
115 | gdb_test "tstatus" "Collected $expected trace frames.*" | |
116 | } | |
117 | ||
118 | with_test_prefix "enable #2" { | |
119 | gdb_test_no_output "enable 3" | |
120 | gdb_continue "break_here" | |
121 | incr expected 2 | |
122 | gdb_test "tstatus" "Collected $expected trace frames.*" | |
123 | } | |
124 | ||
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" | |
129 | incr expected 2 | |
130 | gdb_test "tstatus" "Collected $expected trace frames.*" | |
131 | } | |
132 | } | |
133 | } | |
134 | ||
135 | test_tracepoint_enable_disable trace | |
136 | test_tracepoint_enable_disable ftrace |