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