1 1.1.1.3 christos # Copyright 2015-2019 Free Software Foundation, Inc. 2 1.1 christos # This program is free software; you can redistribute it and/or modify 3 1.1 christos # it under the terms of the GNU General Public License as published by 4 1.1 christos # the Free Software Foundation; either version 3 of the License, or 5 1.1 christos # (at your option) any later version. 6 1.1 christos # 7 1.1 christos # This program is distributed in the hope that it will be useful, 8 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 1.1 christos # GNU General Public License for more details. 11 1.1 christos # 12 1.1 christos # You should have received a copy of the GNU General Public License 13 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 14 1.1 christos 15 1.1 christos load_lib "trace-support.exp" 16 1.1 christos 17 1.1.1.3 christos if {[skip_shlib_tests]} { 18 1.1.1.3 christos return 0 19 1.1.1.3 christos } 20 1.1.1.3 christos 21 1.1 christos standard_testfile 22 1.1 christos set executable $testfile 23 1.1 christos set expfile $testfile.exp 24 1.1 christos 25 1.1 christos # Some targets have leading underscores on assembly symbols. 26 1.1 christos set options [list debug [gdb_target_symbol_prefix_flags]] 27 1.1 christos 28 1.1 christos # Check that the target supports trace. 29 1.1.1.3 christos if ![gdb_trace_common_supports_arch] { 30 1.1.1.3 christos unsupported "no trace-common.h support for arch" 31 1.1.1.3 christos return -1 32 1.1.1.3 christos } 33 1.1 christos if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { 34 1.1.1.2 christos untested "failed to compile" 35 1.1 christos return -1 36 1.1 christos } 37 1.1 christos 38 1.1 christos clean_restart ${testfile} 39 1.1 christos 40 1.1 christos if ![runto_main] { 41 1.1.1.2 christos fail "can't run to main to check for trace support" 42 1.1 christos return -1 43 1.1 christos } 44 1.1 christos 45 1.1 christos if ![gdb_target_supports_trace] { 46 1.1 christos unsupported "target does not support trace" 47 1.1 christos return -1 48 1.1 christos } 49 1.1 christos 50 1.1 christos # Compile the test case with the in-process agent library. 51 1.1 christos set libipa [get_in_proc_agent] 52 1.1 christos gdb_load_shlib $libipa 53 1.1 christos 54 1.1 christos lappend options shlib=$libipa 55 1.1 christos 56 1.1 christos if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { 57 1.1.1.2 christos untested "failed to compile with in-process agent library" 58 1.1 christos return -1 59 1.1 christos } 60 1.1 christos 61 1.1 christos # This test makes sure that disabling and enabling tracepoints works 62 1.1 christos # correctly. TRACEPOINT_CMD is the command used to set tracepoints 63 1.1 christos # (e.g. trace or ftrace). 64 1.1 christos 65 1.1 christos proc test_tracepoint_enable_disable { tracepoint_cmd } { 66 1.1 christos with_test_prefix "test_tracepoint_enable_disable $tracepoint_cmd" { 67 1.1 christos global executable 68 1.1 christos clean_restart ${executable} 69 1.1 christos 70 1.1 christos set expected 0 71 1.1 christos 72 1.1 christos if ![runto_main] { 73 1.1.1.2 christos fail "can't run to main." 74 1.1 christos return -1 75 1.1 christos } 76 1.1 christos 77 1.1 christos gdb_test "$tracepoint_cmd point_a" "(Tracepoint|Fast tracepoint) 2.*" 78 1.1 christos gdb_test "$tracepoint_cmd point_b" "(Tracepoint|Fast tracepoint) 3.*" 79 1.1 christos gdb_breakpoint "break_here" 80 1.1 christos gdb_test_no_output "tstart" 81 1.1 christos 82 1.1 christos # Test that tracepoints start enabled 83 1.1 christos with_test_prefix "start" { 84 1.1 christos gdb_continue "break_here" 85 1.1 christos incr expected 2 86 1.1 christos gdb_test "tstatus" "Collected $expected trace frames.*" 87 1.1 christos } 88 1.1 christos 89 1.1 christos # Test that disabling works 90 1.1 christos with_test_prefix "disable #1" { 91 1.1 christos gdb_test_no_output "disable 2" 92 1.1 christos gdb_continue "break_here" 93 1.1 christos incr expected 1 94 1.1 christos gdb_test "tstatus" "Collected $expected trace frames.*" 95 1.1 christos } 96 1.1 christos 97 1.1 christos with_test_prefix "disable #2" { 98 1.1 christos gdb_test_no_output "disable 3" 99 1.1 christos gdb_continue "break_here" 100 1.1 christos gdb_test "tstatus" "Collected $expected trace frames.*" 101 1.1 christos } 102 1.1 christos 103 1.1 christos # Test that disabling an already disabled tracepoint works 104 1.1 christos with_test_prefix "disable #3" { 105 1.1 christos gdb_test_no_output "disable 2" 106 1.1 christos gdb_continue "break_here" 107 1.1 christos gdb_test "tstatus" "Collected $expected trace frames.*" 108 1.1 christos } 109 1.1 christos 110 1.1 christos # Test that enabling works 111 1.1 christos with_test_prefix "enable #1" { 112 1.1 christos gdb_test_no_output "enable 2" 113 1.1 christos gdb_continue "break_here" 114 1.1 christos incr expected 1 115 1.1 christos gdb_test "tstatus" "Collected $expected trace frames.*" 116 1.1 christos } 117 1.1 christos 118 1.1 christos with_test_prefix "enable #2" { 119 1.1 christos gdb_test_no_output "enable 3" 120 1.1 christos gdb_continue "break_here" 121 1.1 christos incr expected 2 122 1.1 christos gdb_test "tstatus" "Collected $expected trace frames.*" 123 1.1 christos } 124 1.1 christos 125 1.1 christos # Test that enabling an already enabled tracepoint works 126 1.1 christos with_test_prefix "enable #3" { 127 1.1 christos gdb_test_no_output "enable 3" 128 1.1 christos gdb_continue "break_here" 129 1.1 christos incr expected 2 130 1.1 christos gdb_test "tstatus" "Collected $expected trace frames.*" 131 1.1 christos } 132 1.1 christos } 133 1.1 christos } 134 1.1 christos 135 1.1 christos test_tracepoint_enable_disable trace 136 1.1 christos test_tracepoint_enable_disable ftrace 137