OLD | NEW |
1 # Copyright 2011-2012 Free Software Foundation, Inc. | 1 # Copyright 2011-2013 Free Software Foundation, Inc. |
2 # This program is free software; you can redistribute it and/or modify | 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 | 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 | 4 # the Free Software Foundation; either version 3 of the License, or |
5 # (at your option) any later version. | 5 # (at your option) any later version. |
6 # | 6 # |
7 # This program is distributed in the hope that it will be useful, | 7 # This program is distributed in the hope that it will be useful, |
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 # GNU General Public License for more details. | 10 # GNU General Public License for more details. |
11 # | 11 # |
(...skipping 15 matching lines...) Expand all Loading... |
27 if ![runto_main] { | 27 if ![runto_main] { |
28 fail "Can't run to main to check for trace support" | 28 fail "Can't run to main to check for trace support" |
29 return -1 | 29 return -1 |
30 } | 30 } |
31 | 31 |
32 if ![gdb_target_supports_trace] { | 32 if ![gdb_target_supports_trace] { |
33 unsupported "target does not support trace" | 33 unsupported "target does not support trace" |
34 return -1 | 34 return -1 |
35 } | 35 } |
36 | 36 |
37 set libipa [get_in_proc_agent] | 37 set tstatus_output "" |
38 gdb_load_shlibs $libipa | |
39 | |
40 # Can't use prepare_for_testing, because that splits compiling into | |
41 # building objects and then linking, and we'd fail with "linker input | |
42 # file unused because linking not done" when building the object. | |
43 | |
44 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ | |
45 » executable [list debug shlib=$libipa] ] != "" } { | |
46 untested "failed to compile ftrace tests" | |
47 return -1 | |
48 } | |
49 clean_restart ${executable} | |
50 | |
51 if ![runto_main] { | |
52 fail "Can't run to main for ftrace tests" | |
53 return 0 | |
54 } | |
55 | 38 |
56 proc run_trace_experiment {} { | 39 proc run_trace_experiment {} { |
57 global gdb_prompt | 40 global gdb_prompt |
| 41 global decimal |
| 42 global tstatus_output |
58 | 43 |
59 # gdb_test_no_output "set debug remote 1" "" | 44 # gdb_test_no_output "set debug remote 1" "" |
60 | 45 |
61 gdb_test "continue" \ | 46 gdb_test "continue" \ |
62 ".*Breakpoint \[0-9\]+, begin .*" \ | 47 ".*Breakpoint \[0-9\]+, begin .*" \ |
63 "advance to trace begin" | 48 "advance to trace begin" |
64 | 49 |
65 gdb_test_no_output "tstart my tracing note" "start trace experiment" | 50 gdb_test_no_output "tstart my tracing note" "start trace experiment" |
66 | 51 |
67 gdb_test "continue" \ | 52 gdb_test "continue" \ |
68 ".*Breakpoint \[0-9\]+, end .*" \ | 53 ".*Breakpoint \[0-9\]+, end .*" \ |
69 "advance through tracing" | 54 "advance through tracing" |
70 | 55 |
71 # Now play with tstatus a bit. | 56 # Now play with tstatus a bit. |
72 # Since note support is optional, we need to match both with and without | |
73 # cases. | |
74 | 57 |
75 gdb_test_multiple "tstatus" "check on trace status" { | 58 # Since support for notes, user, stop reason, etc. is optional, we |
| 59 # need to match both with and without cases. |
| 60 |
| 61 set test "tstatus reports trace note" |
| 62 gdb_test_multiple "tstatus" $test { |
76 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trac
e notes: my tracing note\.\[\r\n\]+Not looking at any trace frame\..*\r\n$gdb_pr
ompt $" { | 63 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trac
e notes: my tracing note\.\[\r\n\]+Not looking at any trace frame\..*\r\n$gdb_pr
ompt $" { |
77 » pass "tstatus reports trace note" | 64 » pass $test |
78 } | 65 } |
79 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not
looking at any trace frame.*\r\n$gdb_prompt $" { | 66 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not
looking at any trace frame.*\r\n$gdb_prompt $" { |
80 » pass "tstatus does not report any trace note" | 67 » unsupported $test |
81 } | 68 } |
82 } | 69 } |
83 | 70 |
84 gdb_test "set trace-notes different note" "" "change tracing note" | 71 gdb_test "set trace-notes different note" "" "change tracing note" |
85 | 72 |
86 gdb_test_multiple "tstatus" "check on trace status with diff note" { | 73 set test "tstatus reports different trace note" |
| 74 gdb_test_multiple "tstatus" $test { |
87 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trac
e notes: different note\.\[\r\n\]+Not looking at any trace frame\..*\r\n$gdb_pro
mpt $" { | 75 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trac
e notes: different note\.\[\r\n\]+Not looking at any trace frame\..*\r\n$gdb_pro
mpt $" { |
88 » pass "tstatus reports different trace note" | 76 » pass $test |
89 } | 77 } |
90 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not
looking at any trace frame.*\r\n$gdb_prompt $" { | 78 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not
looking at any trace frame.*\r\n$gdb_prompt $" { |
91 » pass "tstatus does not report any different trace note" | 79 » unsupported $test |
92 } | 80 } |
93 } | 81 } |
94 | 82 |
95 gdb_test "set trace-user me me me" "" "change tracing user" | 83 gdb_test "set trace-user me me me" "" "change tracing user" |
96 | 84 |
97 gdb_test_multiple "tstatus" "check on trace status with diff note" { | 85 set test "tstatus reports trace user" |
| 86 gdb_test_multiple "tstatus" $test { |
98 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trac
e user is me me me\.\[\r\n\]+Trace notes: different note\.\[\r\n\]+Not looking a
t any trace frame\..*\r\n$gdb_prompt $" { | 87 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trac
e user is me me me\.\[\r\n\]+Trace notes: different note\.\[\r\n\]+Not looking a
t any trace frame\..*\r\n$gdb_prompt $" { |
99 » pass "tstatus reports trace user" | 88 » pass $test |
100 } | 89 } |
101 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not
looking at any trace frame.*\r\n$gdb_prompt $" { | 90 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not
looking at any trace frame.*\r\n$gdb_prompt $" { |
102 » pass "tstatus does not report trace user" | 91 » unsupported $test |
103 } | 92 } |
104 } | 93 } |
105 | 94 |
106 gdb_test_no_output "tstop because I can" "trace stopped with note" | 95 gdb_test_no_output "tstop because I can" "trace stopped with note" |
107 | 96 |
108 gdb_test_multiple "tstatus" "check on trace status after stop" { | 97 set test "tstatus reports trace stop reason" |
109 » -re "Trace stopped by a tstop command (because I can)\..*Trace will stop
if GDB disconnects\.\[\r\n\]+Trace user is me me me\.\[\r\n\]+Trace notes: diff
erent note\.\[\r\n\]+Not looking at any trace frame\..*\r\n$gdb_prompt $" { | 98 gdb_test_multiple "tstatus" $test { |
110 » pass "tstatus reports trace stop reason" | 99 » -re "(Trace stopped by a tstop command \\(because I can\\)\..*Trace will
stop if GDB disconnects\.\[\r\n\]+Trace user is me me me\.\[\r\n\]+Trace notes:
different note\.\[\r\n\]+Not looking at any trace frame\.).*\r\n$gdb_prompt $"
{ |
| 100 » set tstatus_output $expect_out(1,string) |
| 101 » pass $test |
111 } | 102 } |
112 » -re "Trace stopped by a tstop command\..*\r\n$gdb_prompt $" { | 103 » -re "(Trace stopped by a tstop command\.).*\r\n$gdb_prompt $" { |
113 » pass "tstatus does not report trace stop reason" | 104 » set tstatus_output $expect_out(1,string) |
| 105 » unsupported $test |
114 } | 106 } |
115 } | 107 } |
116 | 108 |
117 # Tracepoint hit count is optional, so pass it either way. | 109 set test "info trace reports tracepoint hit count and traceframe usage" |
118 | 110 gdb_test_multiple "info trace" $test { |
119 gdb_test_multiple "info trace" "show tracepoint state" { | 111 » -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+tracepoint already hit 1 time\[\
r\n\]+\[\t ]+trace buffer usage ${decimal} bytes\.\[\r\n\]+\[\t ]+collect parm.*
\r\n$gdb_prompt $" { |
120 » -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+tracepoint already hit 1 time\[\
r\n\]+\[\t ]+collect parm.*\r\n$gdb_prompt $" { | 112 » pass $test |
121 » pass "info trace reports tracepoint hit count" | |
122 } | 113 } |
123 -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+collect parm.*\r\n$gdb_prompt $"
{ | 114 -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+collect parm.*\r\n$gdb_prompt $"
{ |
124 » pass "info trace does not report tracepoint hit count" | 115 » unsupported $test |
125 } | 116 } |
126 } | 117 } |
127 } | 118 } |
128 | 119 |
129 proc test_tracepoints {} { | 120 proc test_tracepoints {} { |
130 global gdb_prompt | 121 global gdb_prompt |
131 | 122 |
132 gdb_test "break begin" ".*" "" | 123 gdb_test "break begin" ".*" "" |
133 | 124 |
134 gdb_test "break end" ".*" "" | 125 gdb_test "break end" ".*" "" |
135 | 126 |
136 gdb_test "trace gdb_c_test" "Tracepoint .*" \ | 127 gdb_test "trace gdb_c_test" "Tracepoint .*" \ |
137 "tracepoint at gdb_c_test" | 128 "tracepoint at gdb_c_test" |
138 | 129 |
139 gdb_trace_setactions "collect at set_point: define actions" \ | 130 gdb_trace_setactions "collect at set_point: define actions" \ |
140 "" \ | 131 "" \ |
141 "collect parm" "^$" | 132 "collect parm" "^$" |
142 set fastgood 0 | |
143 | |
144 gdb_test_multiple "ftrace gdb_recursion_test" "set fast tracepoint" { | |
145 -re "May not have a fast tracepoint at .*\r\n$gdb_prompt $" { | |
146 pass "4-byte fast tracepoint could not be set" | |
147 } | |
148 -re "Fast tracepoint .*\r\n$gdb_prompt $" { | |
149 pass "4-byte fast tracepoint is set" | |
150 set fastgood 1 | |
151 } | |
152 } | |
153 | |
154 if { $fastgood } { | |
155 | |
156 gdb_trace_setactions "collect at four_byter: define actions" \ | |
157 "" \ | |
158 "collect globvar, anarg" "^$" | |
159 } | |
160 | 133 |
161 run_trace_experiment | 134 run_trace_experiment |
162 | 135 |
163 } | 136 } |
164 | 137 |
165 gdb_reinitialize_dir $srcdir/$subdir | 138 test_tracepoints |
166 | 139 |
167 if { [gdb_test "info sharedlibrary" ".*${libipa}.*" "IPA loaded"] != 0 } { | 140 set tracefile [standard_output_file ${testfile}] |
168 untested "Could not find IPA lib loaded" | 141 # Save trace frames to tfile. |
169 return 1 | 142 gdb_test "tsave ${tracefile}.tf" \ |
| 143 "Trace data saved to file '${tracefile}.tf'.*" \ |
| 144 "save tfile trace file" |
| 145 # Save trace frames to CTF. |
| 146 gdb_test "tsave -ctf ${tracefile}.ctf" \ |
| 147 "Trace data saved to directory '${tracefile}.ctf'.*" \ |
| 148 "save ctf trace file" |
| 149 |
| 150 # Change target to tfile. |
| 151 set test "change to tfile target" |
| 152 gdb_test_multiple "target tfile ${tracefile}.tf" "$test" { |
| 153 -re "A program is being debugged already. Kill it. .y or n. " { |
| 154 » send_gdb "y\n" |
| 155 » exp_continue |
| 156 } |
| 157 -re "$gdb_prompt $" { |
| 158 » pass "$test" |
| 159 } |
170 } | 160 } |
171 | 161 |
172 test_tracepoints | 162 # Convert "(because I can) to "\(because I can\)" |
| 163 set tstatus_output [string map {\( \\(} $tstatus_output] |
| 164 set tstatus_output [string map {\) \\)} $tstatus_output] |
| 165 |
| 166 # The status should be identical to the status of live inferior. |
| 167 gdb_test "tstatus" "Using a trace file\.\r\n${tstatus_output}.*" \ |
| 168 "tstatus on tfile target" |
| 169 |
| 170 # Change target to ctf if GDB supports. |
| 171 gdb_test_multiple "target ctf ${tracefile}.ctf" "" { |
| 172 -re "Undefined target command: \"ctf ${tracefile}.ctf\"\. Try \"help target
\"\.\r\n$gdb_prompt $" { |
| 173 } |
| 174 -re ".*\r\n$gdb_prompt $" { |
| 175 » gdb_test "tstatus" "Using a trace file\.\r\n${tstatus_output}.*" \ |
| 176 » "tstatus on ctf target" |
| 177 } |
| 178 } |
OLD | NEW |