Fix: Null pointer dereference in ldlex.l
[binutils-gdb.git] / gdb / testsuite / gdb.trace / trace-buffer-size.exp
bloba22f82e81c6890c66314d731cc2a2af1bb6ec571
1 # Copyright 1998-2023 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"
18 standard_testfile
20 if [prepare_for_testing "failed to prepare" $testfile $srcfile \
21 {debug nowarnings}] {
22 return -1
25 if ![runto_main] {
26 return -1
29 if ![gdb_target_supports_trace] {
30 unsupported "target does not support trace"
31 return -1
34 set BUFFER_SIZE 4
35 set default_size -1
36 set test "get default buffer size"
38 # Save default trace buffer size in 'default_size'.
39 gdb_test_multiple "tstatus" $test {
40 -re ".*Trace buffer has ($decimal) bytes of ($decimal) bytes free.*$gdb_prompt $" {
41 set default_size $expect_out(2,string)
42 pass $test
46 # If we did not get the default size then there is no point in running the
47 # tests below.
48 if { $default_size < 0 } {
49 return -1
52 # Change buffer size to 'BUFFER_SIZE'.
53 gdb_test_no_output \
54 "set trace-buffer-size $BUFFER_SIZE" \
55 "set trace buffer size 1"
57 gdb_test "tstatus" \
58 ".*Trace buffer has $decimal bytes of $BUFFER_SIZE bytes free.*" \
59 "tstatus check 2"
61 gdb_test "show trace-buffer-size $BUFFER_SIZE" \
62 "Requested size of trace buffer is $BUFFER_SIZE.*" \
63 "show trace buffer size"
65 # -1 means "no limit on GDB's end. Let the target choose."
66 gdb_test_no_output \
67 "set trace-buffer-size -1" \
68 "set trace buffer size 2"
70 # "unlimited" means the same.
71 gdb_test_no_output "set trace-buffer-size unlimited"
73 # Test that tstatus gives us default buffer size now.
74 gdb_test "tstatus" \
75 ".*Trace buffer has $decimal bytes of $default_size bytes free.*" \
76 "tstatus check 3"
78 gdb_test_no_output \
79 "set trace-buffer-size $BUFFER_SIZE" \
80 "set trace buffer size 3"
82 # We set trace buffer to very small size. Then after running trace,
83 # we check if it is full. This will show if setting trace buffer
84 # size really worked.
85 gdb_breakpoint ${srcfile}:[gdb_get_line_number "breakpoint1"]
86 gdb_test "trace test_function" \
87 "Tracepoint \[0-9\]+ at .*" \
88 "set tracepoint at test_function"
89 gdb_trace_setactions "Set action for trace point 1" "" \
90 "collect var" "^$"
91 gdb_test_no_output "tstart"
92 gdb_test "continue" \
93 "Continuing.*Breakpoint $decimal.*" \
94 "run trace experiment 1"
95 gdb_test "tstatus" \
96 ".*Trace stopped because the buffer was full.*" \
97 "buffer full check 1"
99 # Use the default size -- the trace buffer should not end up
100 # full this time
101 clean_restart ${testfile}
102 runto_main
103 gdb_breakpoint ${srcfile}:[gdb_get_line_number "breakpoint1"]
104 gdb_test "trace test_function" \
105 "Tracepoint \[0-9\]+ at .*" \
106 "set tracepoint at test_function"
107 gdb_trace_setactions "Set action for trace point 2" "" \
108 "collect var" "^$"
109 gdb_test_no_output "tstart"
110 gdb_test "continue" \
111 "Continuing.*Breakpoint $decimal.*" \
112 "run trace experiment 2"
113 gdb_test "tstatus" \
114 ".*Trace is running on the target.*" \
115 "buffer full check 2"
116 gdb_test_no_output "tstop"