Chapter 12.
Tracepoints
In some applications, it is not feasible for the debugger to interrupt the program’s execution long
enough for the developer to learn anything helpful about its behavior. If the program’s correctness
depends on its real-time behavior, delays introduced by a debugger might cause the program to change
its behavior drastically, or perhaps fail, even when the code itself is correct. It is useful to be able to
observe the program’s behavior without interrupting it.
Using gdb’s
trace
and
collect
commands, you can specify locations in the program, called
tra-
cepoints
, and arbitrary expressions to evaluate when those tracepoints are reached. Later, using the
tfind
command, you can examine the values those expressions had when the program hit the trace-
points. The expressions may also denote objects in memory--structures or arrays, for example--whose
values gdb should record; while visiting a particular tracepoint, you may inspect those objects as if
they were in memory at that moment. However, because gdb records these values without interacting
with you, it can do so quickly and unobtrusively, hopefully not disturbing the program’s behavior.
The tracepoint facility is currently available only for remote targets. Refer to Chapter 18
Specifying
a Debugging Target
. In addition, your remote target must know how to collect trace data. This func-
tionality is implemented in the remote stub; however, none of the stubs distributed with gdb support
tracepoints as of this writing.
This chapter describes the tracepoint commands and features.
12.1. Commands to Set Tracepoints
Before running such a
trace experiment
, an arbitrary number of tracepoints can be set. Like a break-
point (refer to Section 7.1.1
Setting breakpoints
), a tracepoint has a number assigned to it by gdb.
Like with breakpoints, tracepoint numbers are successive integers starting from one. Many of the
commands associated with tracepoints take the tracepoint number as their argument, to identify which
tracepoint to work on.
For each tracepoint, you can specify, in advance, some arbitrary set of data that you want the target to
collect in the trace buffer when it hits that tracepoint. The collected data can include registers, local
variables, or global data. Later, you can use gdb commands to examine the values these data had at
the time the tracepoint was hit.
This section describes commands to set tracepoints and associated conditions and actions.
12.1.1. Create and Delete Tracepoints
trace
The
trace
command is very similar to the
break
command. Its argument can be a source line,
a function name, or an address in the target program. Refer to Section 7.1.1
Setting breakpoints
.
The
trace
command defines a tracepoint, which is a point in the target program where the
debugger will briefly stop, collect some data, and then allow the program to continue. Setting a
tracepoint or changing its commands doesn’t take effect until the next
tstart
command; thus,
you cannot change the tracepoint attributes once a trace experiment is running.
Here are some examples of using the
trace
command:
(gdb)
trace foo.c:121
// a source file and line number
(gdb)
trace +2
// 2 lines forward
Summary of Contents for ENTERPRISE LINUX 3 - SECURITY GUIDE
Page 1: ...Red Hat Enterprise Linux 3 Debugging with gdb ...
Page 12: ...2 Chapter 1 Debugging with gdb ...
Page 28: ...18 Chapter 4 Getting In and Out of gdb ...
Page 34: ...24 Chapter 5 gdb Commands ...
Page 44: ...34 Chapter 6 Running Programs Under gdb ...
Page 68: ...58 Chapter 8 Examining the Stack ...
Page 98: ...88 Chapter 10 Examining Data ...
Page 112: ...102 Chapter 12 Tracepoints ...
Page 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Page 138: ...128 Chapter 14 Using gdb with Different Languages ...
Page 144: ...134 Chapter 15 Examining the Symbol Table ...
Page 170: ...160 Chapter 19 Debugging remote programs ...
Page 198: ...188 Chapter 21 Controlling gdb ...
Page 204: ...194 Chapter 22 Canned Sequences of Commands ...
Page 206: ...196 Chapter 23 Command Interpreters ...
Page 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Page 296: ...286 Chapter 27 gdb Annotations ...
Page 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Page 322: ...312 Chapter 30 Using History Interactively ...
Page 362: ...352 Appendix D gdb Remote Serial Protocol ...
Page 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Page 386: ...376 Appendix G GNU Free Documentation License ...
Page 410: ......