]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.trace/tracecmd.exp
Switch the license of all .c files to GPLv3.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / tracecmd.exp
CommitLineData
6aba47ca 1# Copyright 1998, 2007 Free Software Foundation, Inc.
c906108c
SS
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 2 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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# This file was written by Michael Snyder (msnyder@cygnus.com)
21
22load_lib "trace-support.exp";
23
24if $tracelevel then {
25 strace $tracelevel
26}
27
28set prms_id 0
29set bug_id 0
30
31gdb_exit
32gdb_start
33if [istarget "m68k-*-elf"] then {
34 set srcfile gdb_c_test.c
35 set binfile [board_info target d490_binfile];
36} else {
37 set testfile "actions"
38 set srcfile ${testfile}.c
39 set binfile $objdir/$subdir/$testfile
40 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
fc91c6c2 41 executable {debug nowarnings}] != "" } {
b60f0898
JB
42 untested tracecmd.exp
43 return -1
c906108c
SS
44 }
45}
46gdb_reinitialize_dir $srcdir/$subdir
47
48# If testing on a remote host, download the source file.
49# remote_download host $srcdir/$subdir/$srcfile
50
51gdb_file_cmd $binfile
52
53# define relative source line numbers:
54# all subsequent line numbers are relative to this first one (baseline)
55set baseline [gdb_find_recursion_test_baseline $srcfile];
56if { $baseline == -1 } then {
57 fail "Could not find gdb_recursion_test function"
58 return;
59}
60
61set testline1 [expr $baseline + 1]
62set testline2 [expr $baseline + 3]
63
64#
65# test "help tracepoints"
66#
67
68set helpcnt 0;
d8295fe9
VP
69test_class_help "tracepoints" {
70 "Tracing of program execution without stopping the program\.[\r\n\]+"
71} "1.0: help tracepoints"
c906108c
SS
72
73#
74# test trace command:
75#
76
77# 1.1 trace source line
78gdb_delete_tracepoints
79gdb_test "trace $srcfile:$testline2" \
80 "Tracepoint $decimal at $hex: file.*$srcfile, line $testline2." \
81 "1.1a: set tracepoint at sourceline"
82gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline2" \
83 "1.1b: trace sourcefile:line"
84
85# 1.2 trace invalid source line
86gdb_delete_tracepoints
87gdb_test "trace $srcfile:99999" "No line 99999 in file \".*$srcfile\"." \
88 "1.2a: trace invalid line in sourcefile"
89gdb_test "info trace" "No tracepoints.*" \
90 "1.2b: reject invalid line in srcfile"
91
92# 1.3 trace line in invalid source file
93gdb_delete_tracepoints
94gdb_test "trace NoSuChFiLe.c:1" "No source file named NoSuChFiLe.c." \
95 "1.3a: trace invalid source file"
96gdb_test "info trace" "No tracepoints.*" \
97 "1.3b: reject invalid srcfile"
98
99# 1.4 trace function by name
100gdb_delete_tracepoints
101gdb_test "trace gdb_recursion_test" \
102 "Tracepoint $decimal at $hex: file.*$srcfile, line $testline1." \
103 "1.4a: trace function by name"
104gdb_test "info trace" "in gdb_recursion_test.*$srcfile:$testline1" \
105 "1.4b: trace function by name"
106
107# 1.5 trace non-existant function
108gdb_delete_tracepoints
109gdb_test "trace NoSuChFuNc" "Function \"NoSuChFuNc\" not defined." \
110 "1.5a: trace invalid function"
111gdb_test "info trace" "No tracepoints.*" \
112 "1.5b: reject invalid srcfile"
113
114# 1.6 trace at a specific address
115# Collect the address of "gdb_asm_test", and use that.
116send_gdb "print gdb_asm_test\n"
117gdb_expect {
118 -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" {
119 set asm_test_addr $expect_out(1,string)
120 }
121 timeout { }
122}
123
124gdb_delete_tracepoints
125gdb_test "trace \*0x$asm_test_addr" \
126 "Tracepoint $decimal at .*$asm_test_addr.*" \
127 "1.6a: trace at specific address"
128gdb_test "info trace" "$asm_test_addr.*gdb_asm_test.*" \
129 "1.6b: verify trace at specific address"
130
131# 1.7 trace at function's exact address
132# Collect the address of the function for comparison
133send_gdb "print gdb_recursion_test\n"
134gdb_expect {
135 -re "\[$\]\[0-9\].*0x(\[0-9a-fA-F\]+).*$gdb_prompt $" {
136 set c_test_addr $expect_out(1,string)
137 }
138 timeout { }
139}
140
141gdb_delete_tracepoints
142gdb_test "trace \*gdb_recursion_test" \
143 "Tracepoint $decimal at .*$c_test_addr.*" \
144 "1.7a: trace at function label (before prologue)"
145gdb_test "info trace" "$c_test_addr.*in gdb_recursion_test.*:$baseline" \
146 "1.7b: verify trace at specific address"
147
148# 1.8 trace at invalid address
149# no address is invalid
150
151# 1.9 trace no arguments
152gdb_test "trace" "trace command requires an argument" \
153 "1.9: trace <no arguments>"
154
155# 1.10 set large number of tracepoints
156# deferred to limits test module
157
158# 1.11 tracepoint conditions
159# conditions on tracepoints not implemented
160
161# 1.12 set tracepoint in prologue
162# [see tfind.exp]
163
164# 1.13 trace on recursion
165# interesting only in "live" session: see backtrace.exp for live test.
166
167# 1.14 help trace
168gdb_test "help trace" "Set a tracepoint at .*" "1.14: help trace"
169
170