| 1 | # Copyright 2015-2016 Free Software Foundation, Inc. |
| 2 | # This program is free software; you can redistribute it and/or modify |
| 3 | # it under the terms of the GNU General Public License as published by |
| 4 | # the Free Software Foundation; either version 3 of the License, or |
| 5 | # (at your option) any later version. |
| 6 | # |
| 7 | # This program is distributed in the hope that it will be useful, |
| 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | # GNU General Public License for more details. |
| 11 | # |
| 12 | # You should have received a copy of the GNU General Public License |
| 13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 14 | |
| 15 | load_lib "trace-support.exp" |
| 16 | |
| 17 | standard_testfile |
| 18 | set executable $testfile |
| 19 | set expfile $testfile.exp |
| 20 | |
| 21 | # make check RUNTESTFLAGS='gdb.trace/ftrace-lock.exp NUM_THREADS=2' |
| 22 | if ![info exists NUM_THREADS] { |
| 23 | set NUM_THREADS 2 |
| 24 | } |
| 25 | |
| 26 | # Some targets have leading underscores on assembly symbols. |
| 27 | set additional_flags [gdb_target_symbol_prefix_flags] |
| 28 | set options [list debug [gdb_target_symbol_prefix_flags] \ |
| 29 | additional_flags=-DNUM_THREADS=$NUM_THREADS] |
| 30 | |
| 31 | # Check that the target supports trace. |
| 32 | if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { |
| 33 | untested "couldn't compile test program" |
| 34 | return -1 |
| 35 | } |
| 36 | |
| 37 | clean_restart ${testfile} |
| 38 | |
| 39 | if ![runto_main] { |
| 40 | fail "can't run to main to check for trace support" |
| 41 | return -1 |
| 42 | } |
| 43 | |
| 44 | if ![gdb_target_supports_trace] { |
| 45 | unsupported "target does not support trace" |
| 46 | return -1 |
| 47 | } |
| 48 | |
| 49 | # Compile the test case with the in-process agent library. |
| 50 | set libipa [get_in_proc_agent] |
| 51 | set remote_libipa [gdb_load_shlib $libipa] |
| 52 | |
| 53 | lappend options shlib=$libipa |
| 54 | |
| 55 | if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } { |
| 56 | untested "couldn't compile test program with in-process agent library" |
| 57 | return -1 |
| 58 | } |
| 59 | |
| 60 | clean_restart ${executable} |
| 61 | |
| 62 | if ![runto_main] { |
| 63 | fail "can't run to main to check for trace support" |
| 64 | return -1 |
| 65 | } |
| 66 | |
| 67 | if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } { |
| 68 | untested "could not find IPA lib loaded" |
| 69 | return 1 |
| 70 | } |
| 71 | |
| 72 | gdb_test "break end" "" |
| 73 | gdb_test "break fail" "" |
| 74 | |
| 75 | gdb_test "ftrace set_point" "Fast tracepoint .*" \ |
| 76 | "fast tracepoint at a long insn" |
| 77 | |
| 78 | gdb_test "tstart" "" |
| 79 | |
| 80 | # If NUM_THREADS is high then this test case may timeout. Increase the |
| 81 | # timeout temporarily. |
| 82 | with_timeout_factor $NUM_THREADS { |
| 83 | # If the fail function is hit, then the testcase will fail. |
| 84 | gdb_test "continue" ".*Breakpoint \[0-9\]+, end \(\).*" \ |
| 85 | "do not hit the fail function" |
| 86 | } |
| 87 | |
| 88 | gdb_test "tstop" "" |