1 # Copyright 1998-2013 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 load_lib "trace-support.exp"
20 if [prepare_for_testing ${testfile}.exp $testfile $srcfile \
22 untested "failed to prepare for trace tests"
27 fail "can't run to main to check for trace support"
31 if ![gdb_target_supports_trace] {
32 unsupported "target does not support trace"
38 set test "get default buffer size"
40 # Save default trace buffer size in 'default_size'.
41 gdb_test_multiple "tstatus" $test {
42 -re ".*Trace buffer has ($decimal) bytes of ($decimal) bytes free.*" {
43 set default_size $expect_out(2,string)
48 # If we did not get the default size then there is no point in running the
50 if { $default_size < 0 } {
54 # Change buffer size to 'BUFFER_SIZE'.
56 "set trace-buffer-size $BUFFER_SIZE" \
57 "set trace buffer size 1"
60 ".*Trace buffer has $decimal bytes of $BUFFER_SIZE bytes free.*" \
63 gdb_test "show trace-buffer-size $BUFFER_SIZE" \
64 "Requested size of trace buffer is $BUFFER_SIZE.*" \
65 "show trace buffer size"
68 "set trace-buffer-size -1" \
69 "set trace buffer size 2"
71 # Test that tstatus gives us default buffer size now.
73 ".*Trace buffer has $decimal bytes of $default_size bytes free.*" \
77 "set trace-buffer-size $BUFFER_SIZE" \
78 "set trace buffer size 3"
80 # We set trace buffer to very small size. Then after running trace,
81 # we check if it is full. This will show if setting trace buffer
83 gdb_breakpoint ${srcfile}:[gdb_get_line_number "breakpoint1"]
84 gdb_test "trace test_function" \
85 "Tracepoint \[0-9\]+ at .*" \
86 "set tracepoint at test_function"
87 gdb_trace_setactions "Set action for trace point 1" "" \
89 gdb_test_no_output "tstart"
91 "Continuing.*Breakpoint $decimal.*" \
92 "run trace experiment 1"
94 ".*Trace stopped because the buffer was full.*" \
97 # Use the default size -- the trace buffer should not end up
99 clean_restart ${testfile}
101 gdb_breakpoint ${srcfile}:[gdb_get_line_number "breakpoint1"]
102 gdb_test "trace test_function" \
103 "Tracepoint \[0-9\]+ at .*" \
104 "set tracepoint at test_function"
105 gdb_trace_setactions "Set action for trace point 2" "" \
107 gdb_test_no_output "tstart"
108 gdb_test "continue" \
109 "Continuing.*Breakpoint $decimal.*" \
110 "run trace experiment 2"
112 ".*Trace is running on the target.*" \
113 "buffer full check 2"
114 gdb_test_no_output "tstop"