Commit | Line | Data |
---|---|---|
e2882c85 | 1 | # Copyright 1998-2018 Free Software Foundation, Inc. |
f6f899bf HAQ |
2 | |
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. | |
7 | # | |
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. | |
12 | # | |
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/>. | |
15 | ||
16 | load_lib "trace-support.exp" | |
17 | ||
18 | standard_testfile | |
19 | ||
5b362f04 | 20 | if [prepare_for_testing "failed to prepare" $testfile $srcfile \ |
f6f899bf | 21 | {debug nowarnings}] { |
f6f899bf HAQ |
22 | return -1 |
23 | } | |
24 | ||
25 | if ![runto_main] { | |
26 | fail "can't run to main to check for trace support" | |
27 | return -1 | |
28 | } | |
29 | ||
30 | if ![gdb_target_supports_trace] { | |
31 | unsupported "target does not support trace" | |
ae59b1da | 32 | return -1 |
f6f899bf HAQ |
33 | } |
34 | ||
35 | set BUFFER_SIZE 4 | |
36 | set default_size -1 | |
37 | set test "get default buffer size" | |
38 | ||
39 | # Save default trace buffer size in 'default_size'. | |
40 | gdb_test_multiple "tstatus" $test { | |
c12440c9 | 41 | -re ".*Trace buffer has ($decimal) bytes of ($decimal) bytes free.*$gdb_prompt $" { |
f6f899bf HAQ |
42 | set default_size $expect_out(2,string) |
43 | pass $test | |
44 | } | |
45 | } | |
46 | ||
47 | # If we did not get the default size then there is no point in running the | |
48 | # tests below. | |
49 | if { $default_size < 0 } { | |
ae59b1da | 50 | return -1 |
f6f899bf HAQ |
51 | } |
52 | ||
53 | # Change buffer size to 'BUFFER_SIZE'. | |
54 | gdb_test_no_output \ | |
55 | "set trace-buffer-size $BUFFER_SIZE" \ | |
56 | "set trace buffer size 1" | |
57 | ||
58 | gdb_test "tstatus" \ | |
59 | ".*Trace buffer has $decimal bytes of $BUFFER_SIZE bytes free.*" \ | |
60 | "tstatus check 2" | |
61 | ||
62 | gdb_test "show trace-buffer-size $BUFFER_SIZE" \ | |
63 | "Requested size of trace buffer is $BUFFER_SIZE.*" \ | |
64 | "show trace buffer size" | |
65 | ||
f81d1120 | 66 | # -1 means "no limit on GDB's end. Let the target choose." |
f6f899bf HAQ |
67 | gdb_test_no_output \ |
68 | "set trace-buffer-size -1" \ | |
69 | "set trace buffer size 2" | |
70 | ||
f81d1120 PA |
71 | # "unlimited" means the same. |
72 | gdb_test_no_output "set trace-buffer-size unlimited" | |
73 | ||
f6f899bf HAQ |
74 | # Test that tstatus gives us default buffer size now. |
75 | gdb_test "tstatus" \ | |
76 | ".*Trace buffer has $decimal bytes of $default_size bytes free.*" \ | |
77 | "tstatus check 3" | |
78 | ||
79 | gdb_test_no_output \ | |
80 | "set trace-buffer-size $BUFFER_SIZE" \ | |
81 | "set trace buffer size 3" | |
82 | ||
83 | # We set trace buffer to very small size. Then after running trace, | |
84 | # we check if it is full. This will show if setting trace buffer | |
85 | # size really worked. | |
86 | gdb_breakpoint ${srcfile}:[gdb_get_line_number "breakpoint1"] | |
87 | gdb_test "trace test_function" \ | |
88 | "Tracepoint \[0-9\]+ at .*" \ | |
89 | "set tracepoint at test_function" | |
90 | gdb_trace_setactions "Set action for trace point 1" "" \ | |
91 | "collect var" "^$" | |
92 | gdb_test_no_output "tstart" | |
93 | gdb_test "continue" \ | |
94 | "Continuing.*Breakpoint $decimal.*" \ | |
95 | "run trace experiment 1" | |
96 | gdb_test "tstatus" \ | |
97 | ".*Trace stopped because the buffer was full.*" \ | |
98 | "buffer full check 1" | |
99 | ||
100 | # Use the default size -- the trace buffer should not end up | |
101 | # full this time | |
102 | clean_restart ${testfile} | |
103 | runto_main | |
104 | gdb_breakpoint ${srcfile}:[gdb_get_line_number "breakpoint1"] | |
105 | gdb_test "trace test_function" \ | |
106 | "Tracepoint \[0-9\]+ at .*" \ | |
107 | "set tracepoint at test_function" | |
108 | gdb_trace_setactions "Set action for trace point 2" "" \ | |
109 | "collect var" "^$" | |
110 | gdb_test_no_output "tstart" | |
111 | gdb_test "continue" \ | |
112 | "Continuing.*Breakpoint $decimal.*" \ | |
113 | "run trace experiment 2" | |
114 | gdb_test "tstatus" \ | |
115 | ".*Trace is running on the target.*" \ | |
116 | "buffer full check 2" | |
117 | gdb_test_no_output "tstop" |