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