Automatic date update in version.in
[binutils-gdb.git] / gdb / testsuite / gdb.trace / passc-dyn.exp
bloba5f55d966d815d6182857a0c917154a036e4be5e
1 #   Copyright 1998-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file was written by Michael Snyder (msnyder@cygnus.com)
18 load_lib "trace-support.exp"
20 standard_testfile actions.c
21 require gdb_trace_common_supports_arch
22 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
23           executable {debug nowarnings}] != "" } {
24     untested "failed to compile"
25     return -1
28 clean_restart $binfile
29 runto_main
31 if {![gdb_target_supports_trace]} {
32     unsupported "current target does not support trace"
33     return 1
37 # If testing on a remote host, download the source file.
38 # remote_download host $srcdir/$subdir/$srcfile
42 # test passcount dynamically (live target)
45 set baseline [gdb_find_recursion_test_baseline $srcfile]
47 if {$baseline == -1} {
48     fail "could not find gdb_recursion_test function"
49     return
52 # define relative source line numbers:
53 # all subsequent line numbers are relative to this first one (baseline)
55 set testline2  [expr $baseline +  4]
56 set testline3  [expr $baseline +  5]
57 set testline4  [expr $baseline +  6]
60 # test passcount command semantics (live test)
63 ## Set three tracepoints with three different passcounts.
64 ## Verify that the experiment stops after the one with the 
65 ## lowest passcount is hit.
67 gdb_delete_tracepoints
68 set tdp2 [gdb_gettpnum "$testline2"]
69 set tdp3 [gdb_gettpnum "$testline3"]
70 set tdp4 [gdb_gettpnum "$testline4"]
71 if {$tdp2 <= 0 || $tdp3 <= 0 || $tdp4 <= 0} {
72     fail "setting tracepoints"
73     return
76 gdb_test "passcount 4 $tdp2" "Setting tracepoint $tdp2's passcount to 4" \
77         "4.5: set passcount for tracepoint $tdp2"
78 gdb_test "passcount 2 $tdp3" "Setting tracepoint $tdp3's passcount to 2" \
79         "4.5: set passcount for tracepoint $tdp3"
80 gdb_test "passcount 3 $tdp4" "Setting tracepoint $tdp4's passcount to 3" \
81         "4.5: set passcount for tracepoint $tdp4"
83 gdb_test "tstart" ".*" ""
85 gdb_breakpoint "end" qualified
86 gdb_test "continue" \
87     "Continuing.*Breakpoint $decimal, end.*" \
88     "run trace experiment"
89 gdb_test "tstop" ".*" ""
91 with_test_prefix "trace_frame -1" {
92     gdb_test "tfind none" ".*"
93     gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x -1 x" \
94         "print \$trace_frame"
97 with_test_prefix "trace_frame 0" {
98     gdb_test "tfind tracepoint $tdp2" ".*"
99     gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 0 x" \
100         "print \$trace_frame"
103 with_test_prefix "trace_frame 1" {
104     gdb_test "tfind tracepoint $tdp3" ".*"
105     gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 1 x" \
106         "print \$trace_frame"
109 with_test_prefix "trace_frame 2" {
110     gdb_test "tfind tracepoint $tdp4" ".*"
111     gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 2 x" \
112         "print \$trace_frame"
115 with_test_prefix "trace_frame 3" {
116     gdb_test "tfind tracepoint $tdp2" ".*"
117     gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 3 x" \
118         "print \$trace_frame"
121 with_test_prefix "trace_frame 4" {
122     gdb_test "tfind tracepoint $tdp3" ".*"
123     gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 4 x" \
124         "print \$trace_frame"
127 ## We should now be at the last frame, because this frame's passcount
128 ## should have caused collection to stop.  If we do a tfind now, 
129 ## it should fail.
131 gdb_test "tfind" "failed to find.*" "4.5: dynamic passcount test"
133 # Finished!
134 gdb_test "tfind none" ".*"