gdb/gdbserver:
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / trace-mt.exp
1 # Copyright 2012 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 set testfile "trace-mt"
18 set executable $testfile
19 set srcfile $testfile.c
20 set binfile $objdir/$subdir/$testfile
21 set expfile $testfile.exp
22
23 # Some targets have leading underscores on assembly symbols.
24 set additional_flags [gdb_target_symbol_prefix_flags]
25
26 if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
27 executable [list debug $additional_flags] ] != "" } {
28 untested "Couldn't compile test program"
29 return -1
30 }
31
32 clean_restart ${testfile}
33
34 if ![runto_main] {
35 fail "Can't run to main to check for trace support"
36 return -1
37 }
38
39 if ![gdb_target_supports_trace] {
40 unsupported "target does not support trace"
41 return -1
42 }
43
44 proc step_over_tracepoint { trace_type } \
45 {with_test_prefix "step over $trace_type" \
46 {
47 global executable
48 global hex
49
50 # Start with a fresh gdb.
51 clean_restart ${executable}
52 # Make sure inferior is running in all-stop mode.
53 gdb_test_no_output "set non-stop 0"
54 if ![runto_main] {
55 fail "Can't run to main"
56 return -1
57 }
58
59 gdb_test "break set_point1" "Breakpoint \[0-9\] at $hex: file.*"
60 gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to set_point1"
61
62 gdb_test "${trace_type} *\$pc" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
63 gdb_test_no_output "tstart"
64
65 gdb_test "stepi" ".*"
66 gdb_test_no_output "tstop"
67 }}
68
69 # Set breakpoint and tracepoint at the same address.
70
71 proc break_trace_same_addr { trace_type option } \
72 {with_test_prefix "$trace_type $option" \
73 {
74 global executable
75 global hex
76
77 # Start with a fresh gdb.
78 clean_restart ${executable}
79 if ![runto_main] {
80 fail "Can't run to main"
81 return -1
82 }
83
84 gdb_test_no_output "set breakpoint always-inserted ${option}"
85
86 gdb_test "break end" "Breakpoint \[0-9\] at $hex: file.*"
87
88 gdb_test "break set_point1" "Breakpoint \[0-9\] at $hex: file.*"
89 gdb_test "${trace_type} set_point1" "\(Fast t|T\)racepoint \[0-9\] at $hex: file.*"
90
91 gdb_test_no_output "tstart"
92
93 gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to set_point1 1"
94 gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to set_point1 2"
95
96 gdb_test "continue" "Continuing\\.\[ \r\n\]+.*Breakpoint.*" "continue to end"
97 gdb_test_no_output "tstop"
98
99 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
100 gdb_test "tfind" "Found trace frame 1, tracepoint .*" "tfind frame 1"
101
102 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
103 }}
104
105 foreach break_always_inserted { "on" "off" } {
106 break_trace_same_addr "trace" ${break_always_inserted}
107 }
108
109 step_over_tracepoint "trace"
110
111 set libipa $objdir/../gdbserver/libinproctrace.so
112 gdb_load_shlibs $libipa
113
114 # Compile test case again with IPA.
115 if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
116 executable [list debug $additional_flags shlib=$libipa] ] != "" } {
117 untested "failed to compile ftrace tests"
118 return -1
119 }
120 clean_restart ${executable}
121
122 if ![runto_main] {
123 fail "Can't run to main for ftrace tests"
124 return 0
125 }
126
127 gdb_reinitialize_dir $srcdir/$subdir
128 if { [gdb_test "info sharedlibrary" ".*libinproctrace\.so.*" "IPA loaded"] != 0 } {
129 untested "Could not find IPA lib loaded"
130 } else {
131 foreach break_always_inserted { "on" "off" } {
132 break_trace_same_addr "ftrace" ${break_always_inserted}
133 }
134
135 step_over_tracepoint "ftrace"
136 }
This page took 0.032971 seconds and 4 git commands to generate.