| 1 | # Copyright (C) 2014-2016 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 | load_lib "dtrace.exp" |
| 17 | |
| 18 | # Run the tests. |
| 19 | # This returns -1 on failure to compile or start, 0 otherwise. |
| 20 | proc dtrace_test {} { |
| 21 | global testfile hex srcfile binfile |
| 22 | |
| 23 | standard_testfile |
| 24 | |
| 25 | if {[dtrace_build_usdt_test_program] == -1} { |
| 26 | untested "failed to compile" |
| 27 | return -1 |
| 28 | } |
| 29 | |
| 30 | clean_restart ${binfile} |
| 31 | |
| 32 | if ![runto_main] { |
| 33 | return -1 |
| 34 | } |
| 35 | |
| 36 | gdb_test "print \$_probe_argc" "No probe at PC $hex" \ |
| 37 | "check argument not at probe point" |
| 38 | |
| 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.*" \ |
| 42 | "info probes dtrace" |
| 43 | |
| 44 | # Disabling the probe test:two-locations shall have no effect, |
| 45 | # since no is-enabled probes are defined for it in the object |
| 46 | # file. |
| 47 | |
| 48 | gdb_test "disable probe test two-locations" \ |
| 49 | "Probe test:two-locations cannot be disabled.*" \ |
| 50 | "disable probe test two-locations" |
| 51 | |
| 52 | # On the other hand, the probe test:progress-counter can be |
| 53 | # enabled and then disabled again. |
| 54 | |
| 55 | gdb_test "enable probe test progress-counter" \ |
| 56 | "Probe test:progress-counter enabled.*" \ |
| 57 | "enable probe test progress-counter" |
| 58 | |
| 59 | gdb_test "disable probe test progress-counter" \ |
| 60 | "Probe test:progress-counter disabled.*" \ |
| 61 | "disable probe test progress-counter" |
| 62 | |
| 63 | # Since test:progress-counter is disabled we can run to the second |
| 64 | # instance of the test:two-locations probe. |
| 65 | |
| 66 | if {![runto "-probe-dtrace test:two-locations"]} { |
| 67 | fail "run to the first test:two-locations probe point" |
| 68 | } |
| 69 | if {![runto "-probe-dtrace test:two-locations"]} { |
| 70 | fail "run to the second test:two-locations probe point" |
| 71 | } |
| 72 | |
| 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. |
| 76 | |
| 77 | if ![runto_main] { |
| 78 | return -1 |
| 79 | } |
| 80 | |
| 81 | gdb_test "enable probe test progress-counter" \ |
| 82 | "Probe test:progress-counter enabled.*" \ |
| 83 | "enable probe test progress-counter" |
| 84 | |
| 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" |
| 88 | |
| 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" |
| 97 | |
| 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)" |
| 102 | |
| 103 | return 0 |
| 104 | } |
| 105 | |
| 106 | dtrace_test |