1 # Copyright 1998, 2007, 2008, 2009 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/>.
16 # This file was written by Michael Snyder (msnyder@cygnus.com)
18 load_lib "trace-support.exp";
29 if [istarget "m68k-*-elf"] then {
30 set srcfile gdb_c_test.c
31 set binfile [board_info target d490_binfile];
33 set testfile "actions"
34 set srcfile ${testfile}.c
35 set binfile $objdir/$subdir/tracecmd
36 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
37 executable {debug nowarnings}] != "" } {
42 gdb_reinitialize_dir $srcdir/$subdir
44 # If testing on a remote host, download the source file.
45 # remote_download host $srcdir/$subdir/$srcfile
49 # define relative source line numbers:
50 # all subsequent line numbers are relative to this first one (baseline)
51 set baseline [gdb_find_recursion_test_baseline $srcfile];
52 if { $baseline == -1 } then {
53 fail "Could not find gdb_recursion_test function"
57 set testline1 [expr $baseline + 1]
58 set testline2 [expr $baseline + 3]
61 # test "help tracepoints"
65 test_class_help "tracepoints" {
66 "Tracing of program execution without stopping the program\.[\r\n\]+"
67 } "1.0: help tracepoints"
73 # 1.1 trace source line
74 gdb_delete_tracepoints
75 gdb_test "trace $srcfile:$testline2" \
76 "Tracepoint $decimal at $hex: file.*$srcfile, line $testline2." \
77 "1.1a: set tracepoint at sourceline"
78 gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2" \
79 "1.1b: trace sourcefile:line"
81 # 1.2 trace invalid source line
82 gdb_delete_tracepoints
83 gdb_test "trace $srcfile:99999" "No line 99999 in file \".*$srcfile\"." \
84 "1.2a: trace invalid line in sourcefile"
85 gdb_test "info trace" "No tracepoints.*" \
86 "1.2b: reject invalid line in srcfile"
88 # 1.3 trace line in invalid source file
89 gdb_delete_tracepoints
90 gdb_test "set breakpoint pending off" ""
91 gdb_test "trace NoSuChFiLe.c:1" "No source file named NoSuChFiLe.c." \
92 "1.3a: trace invalid source file"
93 gdb_test "info trace" "No tracepoints.*" \
94 "1.3b: reject invalid srcfile"
96 # 1.4 trace function by name
97 gdb_delete_tracepoints
98 gdb_test "trace gdb_recursion_test" \
99 "Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \
100 "1.4a: trace function by name"
101 gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1" \
102 "1.4b: trace function by name"
104 # 1.5 trace non-existant function
105 gdb_delete_tracepoints
106 gdb_test "trace NoSuChFuNc" "Function \"NoSuChFuNc\" not defined." \
107 "1.5a: trace invalid function"
108 gdb_test "info trace" "No tracepoints.*" \
109 "1.5b: reject invalid srcfile"
111 # 1.6 trace at a specific address
112 # Collect the address of "gdb_asm_test", and use that.
113 send_gdb "print gdb_asm_test\n"
115 -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" {
116 set asm_test_addr $expect_out(1,string)
121 gdb_delete_tracepoints
122 gdb_test "trace \*0x$asm_test_addr" \
123 "Tracepoint $decimal at .*$asm_test_addr.*" \
124 "1.6a: trace at specific address"
125 gdb_test "info trace" "$asm_test_addr.*gdb_asm_test.*" \
126 "1.6b: verify trace at specific address"
128 # 1.7 trace at function's exact address
129 # Collect the address of the function for comparison
130 send_gdb "print gdb_recursion_test\n"
132 -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" {
133 set c_test_addr $expect_out(1,string)
138 gdb_delete_tracepoints
139 gdb_test "trace \*gdb_recursion_test" \
140 "Tracepoint $decimal at .*$c_test_addr.*" \
141 "1.7a: trace at function label (before prologue)"
142 gdb_test "info trace" "$c_test_addr.*in gdb_recursion_test.*:$baseline" \
143 "1.7b: verify trace at specific address"
145 # 1.8 trace at invalid address
146 # no address is invalid
148 # 1.9 trace no arguments
149 gdb_test "trace" "No default breakpoint address now." \
150 "1.9: trace <no arguments>"
152 # 1.10 set large number of tracepoints
153 # deferred to limits test module
155 # 1.11 tracepoint conditions
156 # conditions on tracepoints not implemented
158 # 1.12 set tracepoint in prologue
161 # 1.13 trace on recursion
162 # interesting only in "live" session: see backtrace.exp for live test.
165 gdb_test "help trace" "Set a tracepoint at .*" "1.14: help trace"