1# Copyright 2011-2013 Free Software Foundation, Inc. 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 15load_lib "trace-support.exp" 16 17standard_testfile actions.c 18set executable $testfile 19set expfile tstatus.exp 20 21if [prepare_for_testing $expfile $executable $srcfile \ 22 [list debug]] { 23 untested "failed to prepare for trace tests" 24 return -1 25} 26 27if ![runto_main] { 28 fail "Can't run to main to check for trace support" 29 return -1 30} 31 32if ![gdb_target_supports_trace] { 33 unsupported "target does not support trace" 34 return -1 35} 36 37proc run_trace_experiment {} { 38 global gdb_prompt 39 global decimal 40 41# gdb_test_no_output "set debug remote 1" "" 42 43 gdb_test "continue" \ 44 ".*Breakpoint \[0-9\]+, begin .*" \ 45 "advance to trace begin" 46 47 gdb_test_no_output "tstart my tracing note" "start trace experiment" 48 49 gdb_test "continue" \ 50 ".*Breakpoint \[0-9\]+, end .*" \ 51 "advance through tracing" 52 53 # Now play with tstatus a bit. 54 55 # Since support for notes, user, stop reason, etc. is optional, we 56 # need to match both with and without cases. 57 58 set test "tstatus reports trace note" 59 gdb_test_multiple "tstatus" $test { 60 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trace notes: my tracing note\.\[\r\n\]+Not looking at any trace frame\..*\r\n$gdb_prompt $" { 61 pass $test 62 } 63 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" { 64 unsupported $test 65 } 66 } 67 68 gdb_test "set trace-notes different note" "" "change tracing note" 69 70 set test "tstatus reports different trace note" 71 gdb_test_multiple "tstatus" $test { 72 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trace notes: different note\.\[\r\n\]+Not looking at any trace frame\..*\r\n$gdb_prompt $" { 73 pass $test 74 } 75 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" { 76 unsupported $test 77 } 78 } 79 80 gdb_test "set trace-user me me me" "" "change tracing user" 81 82 set test "tstatus reports trace user" 83 gdb_test_multiple "tstatus" $test { 84 -re "Trace is running.*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 $" { 85 pass $test 86 } 87 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" { 88 unsupported $test 89 } 90 } 91 92 gdb_test_no_output "tstop because I can" "trace stopped with note" 93 94 set test "tstatus reports trace stop reason" 95 gdb_test_multiple "tstatus" $test { 96 -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 $" { 97 pass $test 98 } 99 -re "Trace stopped by a tstop command\..*\r\n$gdb_prompt $" { 100 unsupported $test 101 } 102 } 103 104 set test "info trace reports tracepoint hit count and traceframe usage" 105 gdb_test_multiple "info trace" $test { 106 -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 $" { 107 pass $test 108 } 109 -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+collect parm.*\r\n$gdb_prompt $" { 110 unsupported $test 111 } 112 } 113} 114 115proc test_tracepoints {} { 116 global gdb_prompt 117 118 gdb_test "break begin" ".*" "" 119 120 gdb_test "break end" ".*" "" 121 122 gdb_test "trace gdb_c_test" "Tracepoint .*" \ 123 "tracepoint at gdb_c_test" 124 125 gdb_trace_setactions "collect at set_point: define actions" \ 126 "" \ 127 "collect parm" "^$" 128 129 run_trace_experiment 130 131} 132 133test_tracepoints 134