Commit | Line | Data |
---|---|---|
c5a57081 | 1 | # Copyright 2011-2012 Free Software Foundation, Inc. |
4511b1ba YQ |
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 | ||
15 | load_lib "trace-support.exp"; | |
16 | ||
17 | set testfile "status-stop" | |
18 | set executable $testfile | |
19 | set srcfile ${testfile}.c | |
20 | set binfile $objdir/$subdir/$testfile | |
21 | set expfile $testfile.exp | |
22 | ||
23 | ||
24 | if [prepare_for_testing $expfile $executable $srcfile \ | |
25 | {debug nowarnings}] { | |
26 | untested "failed to prepare for trace tests" | |
27 | return -1 | |
28 | } | |
29 | ||
ff7d1690 YQ |
30 | if ![runto_main] { |
31 | fail "Can't run to main to check for trace support" | |
32 | return -1 | |
33 | } | |
34 | ||
35 | if ![gdb_target_supports_trace] { | |
36 | unsupported "target does not support trace" | |
37 | return -1; | |
38 | } | |
39 | ||
4511b1ba YQ |
40 | # Verify that the sequence of commands "tstart tstop tstart" works well. |
41 | ||
42 | proc test_tstart_tstop_tstart { } { | |
43 | global executable | |
44 | global pf_prefix | |
45 | global hex | |
46 | ||
47 | set old_pf_prefix $pf_prefix | |
48 | set pf_prefix "$pf_prefix tstart_tstop_tstart:" | |
49 | ||
50 | # Start with a fresh gdb. | |
51 | clean_restart ${executable} | |
52 | if ![runto_main] { | |
53 | fail "Can't run to main" | |
54 | set pf_prefix $old_pf_prefix | |
55 | return -1 | |
56 | } | |
57 | ||
58 | gdb_test "trace func1" "Tracepoint \[0-9\] at $hex: file.*" | |
59 | gdb_test_no_output "tstart" | |
60 | ||
61 | gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*" | |
62 | gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" | |
63 | ||
64 | gdb_test_no_output "tstop" | |
65 | ||
66 | gdb_test_no_output "tstart" | |
67 | ||
68 | set pf_prefix $old_pf_prefix | |
69 | } | |
70 | ||
71 | # Verify the sequence of commands "tstart tstart" works well. | |
72 | ||
73 | proc test_tstart_tstart { } { | |
74 | global executable | |
75 | global pf_prefix | |
76 | global hex | |
77 | ||
78 | set old_pf_prefix $pf_prefix | |
79 | set pf_prefix "$pf_prefix tstart_tstart:" | |
80 | ||
81 | # Start with a fresh gdb. | |
82 | clean_restart ${executable} | |
83 | if ![runto_main] { | |
84 | fail "Can't run to main" | |
85 | set pf_prefix $old_pf_prefix | |
86 | return -1 | |
87 | } | |
88 | ||
89 | gdb_test "trace func1" "Tracepoint \[0-9\] at $hex: file.*" | |
90 | gdb_test_no_output "tstart" | |
91 | ||
92 | gdb_test "tstart" "" "tstart again" "A trace is running already. Start a new run\\? \\(y or n\\) " "y" | |
93 | ||
94 | set pf_prefix $old_pf_prefix | |
95 | } | |
96 | ||
97 | # Verify that trace stops clearly when trace buffer is full. | |
98 | ||
99 | proc test_buffer_full_tstart { } { | |
100 | global executable | |
101 | global pf_prefix | |
102 | global hex | |
103 | ||
104 | set old_pf_prefix $pf_prefix | |
105 | set pf_prefix "$pf_prefix buffer_full_tstart:" | |
106 | ||
107 | # Start with a fresh gdb. | |
108 | clean_restart ${executable} | |
109 | if ![runto_main] { | |
110 | fail "Can't run to main" | |
111 | set pf_prefix $old_pf_prefix | |
112 | return -1 | |
113 | } | |
114 | ||
115 | gdb_test "trace func2" "Tracepoint \[0-9\] at $hex: file.*" | |
116 | gdb_trace_setactions "collect buf: define actions" \ | |
117 | "" \ | |
118 | "collect buf" "^$" | |
119 | ||
120 | gdb_test_no_output "tstart" | |
121 | gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*" | |
122 | gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" "continue to end" | |
123 | ||
124 | gdb_test "tstatus" ".*buffer was full.*" | |
125 | gdb_test_no_output "tstart" | |
126 | ||
127 | set old_pf_prefix $pf_prefix | |
128 | } | |
129 | ||
130 | test_tstart_tstop_tstart | |
131 | ||
132 | test_tstart_tstart | |
133 | ||
134 | test_buffer_full_tstart |