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