Stallman - Debugging with GDB - The GNU Source-Level Debugger 9e (FSF, Linux and UNIX

[ Pobierz całość w formacie PDF ]
Debugging with GDB
The gnu Source-Level Debugger
Ninth Edition, for GDB version 5.1.1
January 2002
Richard Stallman, Roland Pesch, Stan Shebs, et al.
Copyright c
1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
2002 Free Software Foundation, Inc.
Published by the Free Software Foundation
59 Temple Place - Suite 330,
Boston, MA 02111-1307 USA
ISBN 1-882114-88-4
Permission is granted to copy, distribute and/or modify this document under the terms
of the GNU Free Documentation License, Version 1.1 or any later version published by
the Free Software Foundation; with the Invariant Sections being “Free Software” and “Free
Software Needs Free Documentation”, with the Front-Cover Texts being “A GNU Manual,”
and with the Back-Cover Texts as in (a) below.
(a) The Free Software Foundation’s Back-Cover Text is: “You have freedom to copy and
modify this GNU Manual, like GNU software. Copies published by the Free Software
Foundation raise funds for GNU development.”
i
Table of Contents
Summary of GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
Free software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
Free Software Needs Free Documentation . . . . . . . . . . . . . . . . . . . . . .
1
Contributors to GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
1 A Sample GDB Session . . . . . . . . . . . . . . . . . . . .
7
2 Getting In and Out of GDB . . . . . . . . . . . . . . .
11
2.1 Invoking GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
2.1.1 Choosing les . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12
2.1.2 Choosing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13
2.2 Quitting GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15
2.3 Shell commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15
3 GDB Commands . . . . . . . . . . . . . . . . . . . . . . . . .
17
3.1 Command syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17
3.2 Command completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17
3.3 Getting help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19
4 Running Programs Under GDB . . . . . . . . . . .
23
4.1 Compiling for debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23
4.2 Starting your program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23
4.3 Your program's arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
24
4.4 Your program's environment . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25
4.5 Your program's working directory . . . . . . . . . . . . . . . . . . . . . . .
26
4.6 Your program's input and output . . . . . . . . . . . . . . . . . . . . . . . .
26
4.7 Debugging an already-running process . . . . . . . . . . . . . . . . . . .
27
4.8 Killing the child process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
28
4.9 Debugging programs with multiple threads . . . . . . . . . . . . . . .
28
4.10 Debugging programs with multiple processes . . . . . . . . . . . .
30
5 Stopping and Continuing . . . . . . . . . . . . . . . . . .
33
5.1 Breakpoints, watchpoints, and catchpoints . . . . . . . . . . . . . . .
33
5.1.1 Setting breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . .
34
5.1.2 Setting watchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . .
37
5.1.3 Setting catchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . .
39
5.1.4 Deleting breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . .
40
5.1.5 Disabling breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . .
41
5.1.6 Break conditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
42
5.1.7 Breakpoint command lists . . . . . . . . . . . . . . . . . . . . . .
43
5.1.8 Breakpoint menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
44
ii
Debugging with GDB
5.1.9 \Cannot insert breakpoints" . . . . . . . . . . . . . . . . . . . .
45
5.2 Continuing and stepping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
45
5.3 Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
48
5.4 Stopping and starting multi-thread programs . . . . . . . . . . . . .
50
6 Examining the Stack . . . . . . . . . . . . . . . . . . . . . .
53
6.1 Stack frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
53
6.2 Backtraces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
54
6.3 Selecting a frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
55
6.4 Information about a frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
56
7 Examining Source Files . . . . . . . . . . . . . . . . . . .
57
7.1 Printing source lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
57
7.2 Searching source les . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
58
7.3 Specifying source directories . . . . . . . . . . . . . . . . . . . . . . . . . . . .
59
7.4 Source and machine code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
59
8 Examining Data . . . . . . . . . . . . . . . . . . . . . . . . . .
63
8.1 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
63
8.2 Program variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
64
8.3 Articial arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
65
8.4 Output formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
66
8.5 Examining memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
67
8.6 Automatic display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
68
8.7 Print settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
70
8.8 Value history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
75
8.9 Convenience variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
76
8.10 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
77
8.11 Floating point hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
78
8.12 Memory Region Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
78
8.12.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
79
8.12.1.1 Memory Access Mode . . . . . . . . . . . . . . . .
79
8.12.1.2 Memory Access Size . . . . . . . . . . . . . . . . . .
79
8.12.1.3 Data Cache . . . . . . . . . . . . . . . . . . . . . . . . . .
80
9 Tracepoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
81
9.1 Commands to Set Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . .
81
9.1.1 Create and Delete Tracepoints . . . . . . . . . . . . . . . . . .
81
9.1.2 Enable and Disable Tracepoints . . . . . . . . . . . . . . . . .
82
9.1.3 Tracepoint Passcounts . . . . . . . . . . . . . . . . . . . . . . . . .
82
9.1.4 Tracepoint Action Lists . . . . . . . . . . . . . . . . . . . . . . . .
83
9.1.5 Listing Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . .
84
9.1.6 Starting and Stopping Trace Experiment . . . . . . . .
85
9.2 Using the collected data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
85
9.2.1
tfind
n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
85
9.2.2
tdump
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
87
9.2.3
save-tracepoints
lename . . . . . . . . . . . . . . . . . . . .
88
9.3 Convenience Variables for Tracepoints . . . . . . . . . . . . . . . . . . .
88
[ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • monka.htw.pl