1 # Copyright (C) 2014-2019 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/>.
19 # This returns -1 on failure to compile or start, 0 otherwise.
21 global testfile hex srcfile binfile
25 if {[dtrace_build_usdt_test_program] == -1} {
26 untested "failed to compile"
30 clean_restart ${binfile}
36 gdb_test "print \$_probe_argc" "No probe at PC $hex" \
37 "check argument not at probe point"
39 # Test the 'info probes' command.
40 gdb_test "info probes dtrace" \
41 "test *progress-counter *$hex +no.*test *two-locations *$hex +always.*test *two-locations *$hex +always.*" \
44 # Disabling the probe test:two-locations shall have no effect,
45 # since no is-enabled probes are defined for it in the object
48 gdb_test "disable probe test two-locations" \
49 "Probe test:two-locations cannot be disabled.*" \
50 "disable probe test two-locations"
52 # On the other hand, the probe test:progress-counter can be
53 # enabled and then disabled again.
55 gdb_test "enable probe test progress-counter" \
56 "Probe test:progress-counter enabled.*" \
57 "enable probe test progress-counter"
59 gdb_test "disable probe test progress-counter" \
60 "Probe test:progress-counter disabled.*" \
61 "disable probe test progress-counter"
63 # Since test:progress-counter is disabled we can run to the second
64 # instance of the test:two-locations probe.
66 if {![runto "-probe-dtrace test:two-locations"]} {
67 fail "run to the first test:two-locations probe point"
69 if {![runto "-probe-dtrace test:two-locations"]} {
70 fail "run to the second test:two-locations probe point"
73 # Go back to the breakpoint on main() and enable the
74 # test:progress-counter probe. Set a breakpoint on it and see
75 # that it gets reached.
81 gdb_test "enable probe test progress-counter" \
82 "Probe test:progress-counter enabled.*" \
83 "enable probe test progress-counter"
85 gdb_test "break -probe-dtrace test:progress-counter" \
86 ".*Breakpoint \[0-9\]+ .*" "set breakpoint in test:progress-counter"
87 gdb_continue_to_breakpoint "test:progress-counter"
89 # Test probe arguments.
90 gdb_test "print \$_probe_argc" " = 2" \
91 "print \$_probe_argc for probe progress-counter"
92 gdb_test "print \$_probe_arg0" \
93 " = $hex \"application\"" \
94 "print \$_probe_arg0 for probe progress-counter"
95 gdb_test "print \$_probe_arg1" " = 1" \
96 "print \$_probe_arg1 for probe progress-counter"
98 # Set a breakpoint with multiple probe locations.
99 gdb_test "break -pdtrace test:two-locations" \
100 "Breakpoint \[0-9\]+ at $hex.*2 locations.*" \
101 "set multi-location probe breakpoint (probe two-locations)"