1 # Copyright 2011 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.
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.
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/>.
15 load_lib "trace-support.exp";
21 if {[skip_shlib_tests]} {
25 set testfile "change-loc"
26 set libfile1 "change-loc-1"
27 set libfile2 "change-loc-2"
28 set srcfile $testfile.c
29 set executable $testfile
30 set libsrc1 $srcdir/$subdir/$libfile1.c
31 set libsrc2 $srcdir/$subdir/$libfile2.c
32 set binfile $objdir/$subdir/$testfile
33 set lib_sl1 $objdir/$subdir/$libfile1.sl
34 set lib_sl2 $objdir/$subdir/$libfile2.sl
38 if [get_compiler_info ${binfile}] {
42 # Some targets have leading underscores on assembly symbols.
43 set additional_flags [list debug shlib=$lib_sl1 shlib_load [gdb_target_symbol_prefix_flags]]
45 if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != ""
46 || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""
47 || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $additional_flags] != ""} {
48 untested "Could not compile either $libsrc1 or $srcdir/$subdir/$srcfile."
52 clean_restart $executable
54 gdb_load_shlibs $lib_sl1
55 gdb_load_shlibs $lib_sl2
58 fail "Can't run to main to check for trace support"
62 if { ![gdb_target_supports_trace] } then {
63 unsupported "Current target does not support trace"
67 if [is_amd64_regs_target] {
69 } elseif [is_x86_like_target] {
76 # Set tracepoint during tracing experiment.
78 proc tracepoint_change_loc_1 { trace_type } {
85 set old_pf_prefix $pf_prefix
86 set pf_prefix "$pf_prefix 1 $trace_type:"
88 clean_restart ${testfile}
90 fail "Can't run to main"
91 set pf_prefix $old_pf_prefix
94 gdb_test_no_output "delete break 1"
96 # Set a tracepoint we'll never meet. Just to avoid the complain after
97 # type `tstart' later.
99 gdb_test "trace main" "Tracepoint \[0-9\] at.* file .*$srcfile, line.*" \
100 "set tracepoint on main"
102 gdb_test "break marker" "Breakpoint.*at.* file .*$srcfile, line.*" \
103 "breakpoint on marker"
105 gdb_test_no_output "tstart"
107 gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
108 "continue to marker 1"
109 # Set a tracepoint during tracing.
110 gdb_test "${trace_type} set_tracepoint" ".*" "set tracepoint on set_tracepoint"
112 gdb_trace_setactions "set action for tracepoint" "" \
113 "collect \$$pcreg" "^$"
115 # tracepoint has two locations after shlib change-loc-1 is loaded.
116 gdb_test "info trace" \
117 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
118 \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*" \
119 "tracepoint with two locations"
121 setup_kfail "gdb/13392" x86_64-*-*
122 gdb_test "continue" ".*Breakpoint.*marker.*at.*$srcfile.*" \
123 "continue to marker 2"
125 # tracepoint has three locations after shlib change-loc-2 is loaded.
126 gdb_test "info trace" \
127 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
128 \[0-9\]+\[\t \]+\(|fast \)tracepoint\[ \]+keep y.*\<MULTIPLE\>.*4\.1.* in func4.*4\.2.* in func4.*4\.3.* in func4 .*" \
129 "tracepoint with three locations"
131 gdb_test_no_output "tstop"
133 setup_kfail "gdb/13392" x86_64-*-*
134 gdb_test "tfind" "Found trace frame 0, tracepoint 4.*" "tfind frame 0"
135 gdb_test "tfind" "Target failed to find requested trace frame\\..*"
137 set pf_prefix $old_pf_prefix
141 tracepoint_change_loc_1 "trace"
143 # Re-compile test case with IPA.
144 set libipa $objdir/../gdbserver/libinproctrace.so
145 gdb_load_shlibs $libipa
147 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable \
148 [list debug nowarnings shlib=$libipa shlib=$lib_sl1 shlib_load] ] != "" } {
149 untested change-loc.exp
153 tracepoint_change_loc_1 "ftrace"