1# Copyright 2009-2013 Free Software Foundation, Inc. 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 16load_lib "trace-support.exp"; 17 18 19gdb_exit 20gdb_start 21standard_testfile actions.c 22if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ 23 executable {debug nowarnings}] != "" } { 24 untested tsv.exp 25 return -1 26} 27gdb_load $binfile 28 29gdb_test "tvariable \$tvar1" \ 30 "Trace state variable \\\$tvar1 created, with initial value 0." \ 31 "Create a trace state variable" 32 33gdb_test "tvariable \$tvar2 = 45" \ 34 "Trace state variable \\\$tvar2 created, with initial value 45." \ 35 "Create a trace state variable with initial value" 36 37gdb_test "tvariable \$tvar2 = -92" \ 38 "Trace state variable \\\$tvar2 now has initial value -92." \ 39 "Change initial value of a trace state variable" 40 41gdb_test "tvariable \$tvar3 = 2 + 3" \ 42 "Trace state variable \\\$tvar3 created, with initial value 5." \ 43 "Create a trace state variable with expression" 44 45gdb_test "tvariable \$tvar3 = 1234567000000" \ 46 "Trace state variable \\\$tvar3 now has initial value 1234567000000." \ 47 "Init trace state variable to a 64-bit value" 48 49gdb_test "tvariable $" \ 50 "Must supply a non-empty variable name" \ 51 "tvariable syntax error, not empty variable name" 52 53gdb_test "tvariable main" \ 54 "Name of trace variable should start with '\\\$'" \ 55 "tvariable syntax error, bad name" 56 57gdb_test "tvariable \$\$" \ 58 "Syntax must be \\\$NAME \\\[ = EXPR \\\]" \ 59 "tvariable syntax error, bad name 2" 60 61gdb_test "tvariable \$123" \ 62 "\\\$123 is not a valid trace state variable name" \ 63 "tvariable syntax error, bad name 3" 64 65gdb_test "tvariable \$tvar1 - 93" \ 66 "Syntax must be \\\$NAME \\\[ = EXPR \\\]" \ 67 "tvariable syntax error, not an assignment" 68 69gdb_test "tvariable \$tvar0 = 1 = 1" \ 70 "Left operand of assignment is not an lvalue\." \ 71 "tvariable creation fails with invalid expression" 72 73gdb_test "info tvariables" \ 74 "Name\[\t \]+Initial\[\t \]+Current.* 75\\\$tvar1\[\t \]+0\[\t \]+<undefined>.* 76\\\$tvar2\[\t \]+-92\[\t \]+<undefined>.* 77\\\$tvar3\[\t \]+1234567000000\[\t \]+.*<undefined>.*" \ 78 "List tvariables" 79 80gdb_test "print \$tvar2" " = void" \ 81 "Print a trace state variable before run" 82 83gdb_test_no_output "delete tvariable \$tvar2" \ 84 "delete trace state variable" 85 86gdb_test "info tvariables" \ 87 "Name\[\t \]+Initial\[\t \]+Current.* 88\\\$tvar1\[\t \]+0\[\t \]+<undefined>.* 89\\\$tvar3\[\t \]+1234567000000\[\t \]+.*<undefined>.*" \ 90 "List tvariables after deletion" 91 92gdb_test "delete tvariable" \ 93 "" \ 94 "Delete all trace state variables" \ 95 "Delete all trace state variables.*y or n.*$" \ 96 "y" 97 98gdb_test "info tvariables" \ 99 "No trace state variables.*" \ 100 "List tvariables after deleting all" 101 102# Now try running a trace. 103 104runto_main 105gdb_reinitialize_dir $srcdir/$subdir 106 107# The rest of the testing needs actual tracing to work. 108if { ![gdb_target_supports_trace] } then { 109 unsupported "Current target does not support trace" 110 return 1; 111} 112 113# define relative source line numbers: 114# all subsequent line numbers are relative to this first one (baseline) 115 116set baseline [gdb_find_recursion_test_baseline $srcfile]; 117if { $baseline == -1 } then { 118 fail "Could not find gdb_recursion_test function" 119 return; 120} 121 122set testline1 [expr $baseline + 7] 123 124gdb_delete_tracepoints 125set trcpt1 [gdb_gettpnum gdb_c_test]; 126set trcpt2 [gdb_gettpnum gdb_asm_test]; 127set trcpt3 [gdb_gettpnum $testline1]; 128if { $trcpt1 <= 0 || $trcpt2 <= 0 || $trcpt3 <= 0 } then { 129 fail "setting tracepoints" 130 return; 131} 132 133gdb_test "tvariable \$tvar5 = 15" \ 134 "Trace state variable \\\$tvar5 created, with initial value 15." \ 135 "Create a trace state variable tvar5" 136 137gdb_trace_setactions "collect tsv for first tracepoint" \ 138 "$trcpt1" \ 139 "collect \$tvar5 += 1" "^$" 140 141gdb_test "tstart" ".*" "" 142 143gdb_test "print \$tvar5" " = 15" \ 144 "Print a trace state variable at start of run" 145 146# Be sure not to fall off the end of the program. 147gdb_test "break end" ".*" "" 148gdb_test "continue" \ 149 "Continuing.*Breakpoint $decimal, end.*" \ 150 "run trace experiment" 151 152gdb_test "print \$tvar5" " = 16" \ 153 "Print a trace state variable during run" 154 155gdb_test "tstop" ".*" "" 156 157gdb_test "print \$tvar5" " = 16" \ 158 "Print a trace state variable after run" 159 160 161