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