xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.trace/passc-dyn.exp (revision 924795e69c8bb3f17afd8fcbb799710cc1719dc4)
1#   Copyright 1998-2020 Free Software Foundation, Inc.
2#
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.
7#
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.
12#
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/>.
15
16# This file was written by Michael Snyder (msnyder@cygnus.com)
17
18load_lib "trace-support.exp"
19
20
21gdb_exit
22gdb_start
23standard_testfile actions.c
24if ![gdb_trace_common_supports_arch] {
25    unsupported "no trace-common.h support for arch"
26    return -1
27}
28if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
29	  executable {debug nowarnings}] != "" } {
30    untested "failed to compile"
31    return -1
32}
33gdb_load $binfile
34gdb_test "tstop"       ".*" ""
35gdb_test "tfind none"  ".*" ""
36runto_main
37gdb_reinitialize_dir $srcdir/$subdir
38
39if { ![gdb_target_supports_trace] } then {
40    unsupported "current target does not support trace"
41    return 1
42
43}
44
45# If testing on a remote host, download the source file.
46# remote_download host $srcdir/$subdir/$srcfile
47
48
49#
50# test passcount dynamically (live target)
51#
52
53set baseline [gdb_find_recursion_test_baseline $srcfile]
54
55if { $baseline == -1 } then {
56    fail "could not find gdb_recursion_test function"
57    return
58}
59
60# define relative source line numbers:
61# all subsequent line numbers are relative to this first one (baseline)
62
63set testline2  [expr $baseline +  4]
64set testline3  [expr $baseline +  5]
65set testline4  [expr $baseline +  6]
66
67#
68# test passcount command semantics (live test)
69#
70
71## Set three tracepoints with three different passcounts.
72## Verify that the experiment stops after the one with the
73## lowest passcount is hit.
74
75gdb_delete_tracepoints
76set tdp2 [gdb_gettpnum "$testline2"]
77set tdp3 [gdb_gettpnum "$testline3"]
78set tdp4 [gdb_gettpnum "$testline4"]
79if { $tdp2 <= 0 || $tdp3 <= 0 || $tdp4 <= 0 } then {
80    fail "setting tracepoints"
81    return
82}
83
84gdb_test "passcount 4 $tdp2" "Setting tracepoint $tdp2's passcount to 4" \
85	"4.5: set passcount for tracepoint $tdp2"
86gdb_test "passcount 2 $tdp3" "Setting tracepoint $tdp3's passcount to 2" \
87	"4.5: set passcount for tracepoint $tdp3"
88gdb_test "passcount 3 $tdp4" "Setting tracepoint $tdp4's passcount to 3" \
89	"4.5: set passcount for tracepoint $tdp4"
90
91gdb_test "tstart" ".*" ""
92
93gdb_breakpoint "end" qualified
94gdb_test "continue" \
95    "Continuing.*Breakpoint $decimal, end.*" \
96    "run trace experiment"
97gdb_test "tstop" ".*" ""
98
99gdb_test "tfind none" ".*" ""
100if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x -1 x" ""] {
101    untested "skipping further tests due to print failure"
102    return -1
103}
104
105gdb_test "tfind tracepoint $tdp2" ".*" ""
106if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 0 x" ""] {
107    untested "skipping further tests due to print failure"
108    return -1
109}
110
111gdb_test "tfind tracepoint $tdp3" ".*" ""
112if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 1 x" ""] {
113    untested "skipping further tests due to print failure"
114    return -1
115}
116
117gdb_test "tfind tracepoint $tdp4" ".*" ""
118if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 2 x" ""] {
119    untested "skipping further tests due to print failure"
120    return -1
121}
122
123gdb_test "tfind tracepoint $tdp2" ".*" ""
124if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 3 x" ""] {
125    untested "skipping further tests due to print failure"
126    return -1
127}
128
129gdb_test "tfind tracepoint $tdp3" ".*" ""
130if [gdb_test "printf \"x \%d x\\n\", \$trace_frame" "x 4 x" ""] {
131    untested "skipping further tests due to print failure"
132    return -1
133}
134
135## We should now be at the last frame, because this frame's passcount
136## should have caused collection to stop.  If we do a tfind now,
137## it should fail.
138
139gdb_test "tfind" "failed to find.*" "4.5: dynamic passcount test"
140
141# Finished!
142gdb_test "tfind none" ".*" ""
143
144