Home | History | Annotate | Line # | Download | only in gdb.trace
trace-enable-disable.exp revision 1.1.1.2
      1 # Copyright 2015-2017 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 
     15 load_lib "trace-support.exp"
     16 
     17 standard_testfile
     18 set executable $testfile
     19 set expfile $testfile.exp
     20 
     21 # Some targets have leading underscores on assembly symbols.
     22 set options [list debug [gdb_target_symbol_prefix_flags]]
     23 
     24 # Check that the target supports trace.
     25 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
     26     untested "failed to compile"
     27     return -1
     28 }
     29 
     30 clean_restart ${testfile}
     31 
     32 if ![runto_main] {
     33     fail "can't run to main to check for trace support"
     34     return -1
     35 }
     36 
     37 if ![gdb_target_supports_trace] {
     38     unsupported "target does not support trace"
     39     return -1
     40 }
     41 
     42 # Compile the test case with the in-process agent library.
     43 set libipa [get_in_proc_agent]
     44 gdb_load_shlib $libipa
     45 
     46 lappend options shlib=$libipa
     47 
     48 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
     49     untested "failed to compile with in-process agent library"
     50     return -1
     51 }
     52 
     53 # This test makes sure that disabling and enabling tracepoints works
     54 # correctly.  TRACEPOINT_CMD is the command used to set tracepoints
     55 # (e.g. trace or ftrace).
     56 
     57 proc test_tracepoint_enable_disable { tracepoint_cmd } {
     58     with_test_prefix "test_tracepoint_enable_disable $tracepoint_cmd" {
     59 	global executable
     60 	clean_restart ${executable}
     61 
     62 	set expected 0
     63 
     64 	if ![runto_main] {
     65 	    fail "can't run to main."
     66 	    return -1
     67 	}
     68 
     69 	gdb_test "$tracepoint_cmd point_a" "(Tracepoint|Fast tracepoint) 2.*"
     70 	gdb_test "$tracepoint_cmd point_b" "(Tracepoint|Fast tracepoint) 3.*"
     71 	gdb_breakpoint "break_here"
     72 	gdb_test_no_output "tstart"
     73 
     74 	# Test that tracepoints start enabled
     75 	with_test_prefix "start" {
     76 	    gdb_continue "break_here"
     77 	    incr expected 2
     78 	    gdb_test "tstatus" "Collected $expected trace frames.*"
     79 	}
     80 
     81 	# Test that disabling works
     82 	with_test_prefix "disable #1" {
     83 	    gdb_test_no_output "disable 2"
     84 	    gdb_continue "break_here"
     85 	    incr expected 1
     86 	    gdb_test "tstatus" "Collected $expected trace frames.*"
     87 	}
     88 
     89 	with_test_prefix "disable #2" {
     90 	    gdb_test_no_output "disable 3"
     91 	    gdb_continue "break_here"
     92 	    gdb_test "tstatus" "Collected $expected trace frames.*"
     93 	}
     94 
     95 	# Test that disabling an already disabled tracepoint works
     96 	with_test_prefix "disable #3" {
     97 	    gdb_test_no_output "disable 2"
     98 	    gdb_continue "break_here"
     99 	    gdb_test "tstatus" "Collected $expected trace frames.*"
    100 	}
    101 
    102 	# Test that enabling works
    103 	with_test_prefix "enable #1" {
    104 	    gdb_test_no_output "enable 2"
    105 	    gdb_continue "break_here"
    106 	    incr expected 1
    107 	    gdb_test "tstatus" "Collected $expected trace frames.*"
    108 	}
    109 
    110 	with_test_prefix "enable #2" {
    111 	    gdb_test_no_output "enable 3"
    112 	    gdb_continue "break_here"
    113 	    incr expected 2
    114 	    gdb_test "tstatus" "Collected $expected trace frames.*"
    115 	}
    116 
    117 	# Test that enabling an already enabled tracepoint works
    118 	with_test_prefix "enable #3" {
    119 	    gdb_test_no_output "enable 3"
    120 	    gdb_continue "break_here"
    121 	    incr expected 2
    122 	    gdb_test "tstatus" "Collected $expected trace frames.*"
    123 	}
    124     }
    125 }
    126 
    127 test_tracepoint_enable_disable trace
    128 test_tracepoint_enable_disable ftrace
    129