0% found this document useful (0 votes)
159 views658 pages

GDB

The document is the Tenth Edition of 'Debugging with gdb', detailing the GNU Source-Level Debugger, specifically version 7.6.0. It covers various aspects of using gdb, including commands, running programs, debugging techniques, and examining data. The document is published by the Free Software Foundation and is available under the GNU Free Documentation License.

Uploaded by

borella.m7606
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
159 views658 pages

GDB

The document is the Tenth Edition of 'Debugging with gdb', detailing the GNU Source-Level Debugger, specifically version 7.6.0. It covers various aspects of using gdb, including commands, running programs, debugging techniques, and examining data. The document is published by the Free Software Foundation and is available under the GNU Free Documentation License.

Uploaded by

borella.m7606
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 658

Debugging with gdb

The gnu Source-Level Debugger


Tenth Edition, for gdb version 7.6.0.20130624
(GDB)

Richard Stallman, Roland Pesch, Stan Shebs, et al.

(Send bugs and comments on gdb to http://www.gnu.org/software/gdb/bugs/.)


Debugging with gdb
TEXinfo 2011-02-14.11

Published by the Free Software Foundation


51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
ISBN 978-0-9831592-3-0
c 1988-2013 Free Software Foundation, Inc.
Copyright
Permission is granted to copy, distribute and/or modify this document under the terms
of the GNU Free Documentation License, Version 1.3 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 FSFs Back-Cover Text is: You are free to copy and modify this GNU Manual. Buying copies from GNU Press supports the FSF in developing GNU and promoting
software freedom.

Table of Contents
Summary of gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Free Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Free Software Needs Free Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Contributors to gdb. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

A Sample gdb Session . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Getting In and Out of gdb . . . . . . . . . . . . . . . . . . . 11


2.1

Invoking gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.1 Choosing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.2 Choosing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.3 What gdb Does During Startup . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Quitting gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 Shell Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.4 Logging Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

gdb Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.1
3.2
3.3

11
12
13
16
17
17
17

Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Command Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Running Programs Under gdb . . . . . . . . . . . . . . . 25


4.1 Compiling for Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Starting your Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3 Your Programs Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4 Your Programs Environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5 Your Programs Working Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.6 Your Programs Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.7 Debugging an Already-running Process . . . . . . . . . . . . . . . . . . . . . . . .
4.8 Killing the Child Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.9 Debugging Multiple Inferiors and Programs. . . . . . . . . . . . . . . . . . . .
4.10 Debugging Programs with Multiple Threads . . . . . . . . . . . . . . . . . .
4.11 Debugging Forks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.12 Setting a Bookmark to Return to Later. . . . . . . . . . . . . . . . . . . . . . .
4.12.1 A Non-obvious Benefit of Using Checkpoints . . . . . . . . . . . . .

25
26
28
29
30
30
31
32
32
35
38
40
42

ii

Debugging with gdb

Stopping and Continuing . . . . . . . . . . . . . . . . . . . . . 43


5.1

Breakpoints, Watchpoints, and Catchpoints . . . . . . . . . . . . . . . . . . .


5.1.1 Setting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.2 Setting Watchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.3 Setting Catchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.4 Deleting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.5 Disabling Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.6 Break Conditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.7 Breakpoint Command Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.8 Dynamic Printf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.9 How to save breakpoints to a file . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.10 Static Probe Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.11 Cannot insert breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.12 Breakpoint address adjusted... . . . . . . . . . . . . . . . . . . . . . . . .
5.2 Continuing and Stepping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3 Skipping Over Functions and Files . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.4 Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.5 Stopping and Starting Multi-thread Programs . . . . . . . . . . . . . . . . .
5.5.1 All-Stop Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.5.2 Non-Stop Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.5.3 Background Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.5.4 Thread-Specific Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.5.5 Interrupted System Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.5.6 Observer Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

43
44
50
53
57
57
59
60
61
63
63
64
64
65
68
70
72
72
73
75
76
76
77

Running programs backward . . . . . . . . . . . . . . . . . 79

Recording Inferiors Execution and Replaying


It . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Examining the Stack . . . . . . . . . . . . . . . . . . . . . . . . . . 87


8.1
8.2
8.3
8.4

Stack Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Backtraces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Selecting a Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Information About a Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

87
88
90
91

Examining Source Files . . . . . . . . . . . . . . . . . . . . . . . 93


9.1
9.2
9.3

Printing Source Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


Specifying a Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Editing Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.3.1 Choosing your Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.4 Searching Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.5 Specifying Source Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.6 Source and Machine Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

93
94
95
96
96
96
99

iii

10

Examining Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

10.1 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.2 Ambiguous Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.3 Program Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.4 Artificial Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.5 Output Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.6 Examining Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.7 Automatic Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.8 Print Settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.9 Pretty Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.9.1 Pretty-Printer Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.9.2 Pretty-Printer Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.9.3 Pretty-Printer Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.10 Value History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.11 Convenience Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.12 Convenience Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.13 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.14 Floating Point Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.15 Vector Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.16 Operating System Auxiliary Information . . . . . . . . . . . . . . . . . . .
10.17 Memory Region Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.17.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.17.1.1 Memory Access Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.17.1.2 Memory Access Size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.17.1.3 Data Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.17.2 Memory Access Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.18 Copy Between Memory and a File . . . . . . . . . . . . . . . . . . . . . . . . .
10.19 How to Produce a Core File from Your Program . . . . . . . . . . .
10.20 Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.21 Caching Data of Remote Targets . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.22 Search Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11

Debugging Optimized Code . . . . . . . . . . . . . . . . 141

11.1
11.2

12

105
106
107
109
110
111
113
115
123
123
123
124
125
126
127
128
130
130
130
132
133
133
133
133
134
134
135
135
138
139

Inline Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141


Tail Call Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

C Preprocessor Macros . . . . . . . . . . . . . . . . . . . . . 145

iv

Debugging with gdb

13

Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

13.1 Commands to Set Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


13.1.1 Create and Delete Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . .
13.1.2 Enable and Disable Tracepoints . . . . . . . . . . . . . . . . . . . . . . . .
13.1.3 Tracepoint Passcounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.1.4 Tracepoint Conditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.1.5 Trace State Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.1.6 Tracepoint Action Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.1.7 Listing Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.1.8 Listing Static Tracepoint Markers . . . . . . . . . . . . . . . . . . . . . .
13.1.9 Starting and Stopping Trace Experiments . . . . . . . . . . . . . .
13.1.10 Tracepoint Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.2 Using the Collected Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.2.1 tfind n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.2.2 tdump. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.2.3 save tracepoints filename . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.3 Convenience Variables for Tracepoints . . . . . . . . . . . . . . . . . . . . . . .
13.4 Using Trace Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

14

Debugging Programs That Use Overlays


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

14.1
14.2
14.3
14.4

15

149
150
152
153
153
153
154
156
157
158
160
161
161
163
164
164
165

How Overlays Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


Overlay Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Automatic Overlay Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Overlay Sample Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

167
168
170
171

Using gdb with Different Languages . . . . . . 173

15.1 Switching Between Source Languages . . . . . . . . . . . . . . . . . . . . . . .


15.1.1 List of Filename Extensions and Languages . . . . . . . . . . . . .
15.1.2 Setting the Working Language . . . . . . . . . . . . . . . . . . . . . . . . .
15.1.3 Having gdb Infer the Source Language . . . . . . . . . . . . . . . . .
15.2 Displaying the Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.3 Type and Range Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.3.1 An Overview of Type Checking . . . . . . . . . . . . . . . . . . . . . . . .
15.3.2 An Overview of Range Checking . . . . . . . . . . . . . . . . . . . . . . .
15.4 Supported Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.1 C and C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.1.1 C and C++ Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.1.2 C and C++ Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.1.3 C++ Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.1.4 C and C++ Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.1.5 C and C++ Type and Range Checks . . . . . . . . . . . . . . .
15.4.1.6 gdb and C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.1.7 gdb Features for C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.1.8 Decimal Floating Point format . . . . . . . . . . . . . . . . . . . .
15.4.2 D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.3 Go. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

173
173
174
174
174
175
175
176
177
177
177
179
180
181
181
181
181
183
183
183

v
15.4.4 Objective-C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.4.1 Method Names in Commands . . . . . . . . . . . . . . . . . . . . .
15.4.4.2 The Print Command With Objective-C . . . . . . . . . . . .
15.4.5 OpenCL C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.5.1 OpenCL C Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.5.2 OpenCL C Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.5.3 OpenCL C Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.6 Fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.6.1 Fortran Operators and Expressions . . . . . . . . . . . . . . . .
15.4.6.2 Fortran Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.6.3 Special Fortran Commands . . . . . . . . . . . . . . . . . . . . . . . .
15.4.7 Pascal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.8 Modula-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.8.1 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.8.2 Built-in Functions and Procedures . . . . . . . . . . . . . . . . .
15.4.8.3 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.8.4 Modula-2 Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.8.5 Modula-2 Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.8.6 Deviations from Standard Modula-2 . . . . . . . . . . . . . . .
15.4.8.7 Modula-2 Type and Range Checks. . . . . . . . . . . . . . . . .
15.4.8.8 The Scope Operators :: and . . . . . . . . . . . . . . . . . . . . .
15.4.8.9 gdb and Modula-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.9 Ada . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.9.2 Omissions from Ada . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.9.3 Additions to Ada . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.9.4 Stopping at the Very Beginning . . . . . . . . . . . . . . . . . . .
15.4.9.5 Extensions for Ada Tasks . . . . . . . . . . . . . . . . . . . . . . . . .
15.4.9.6 Tasking Support when Debugging Core Files . . . . . .
15.4.9.7 Tasking Support when using the Ravenscar Profile
........................................................
15.4.9.8 Known Peculiarities of Ada Mode . . . . . . . . . . . . . . . . .
15.5 Unsupported Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

184
184
184
185
185
185
185
185
185
185
186
186
186
186
187
188
189
191
191
191
191
192
192
192
193
194
195
196
198
199
199
200

16

Examining the Symbol Table . . . . . . . . . . . . . . 201

17

Altering Execution. . . . . . . . . . . . . . . . . . . . . . . . . . 209

17.1
17.2
17.3
17.4
17.5
17.6

Assignment to Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Continuing at a Different Address . . . . . . . . . . . . . . . . . . . . . . . . . . .
Giving your Program a Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Returning from a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Calling Program Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Patching Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

209
210
211
211
212
213

vi

Debugging with gdb

18

gdb Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

18.1
18.2
18.3
18.4
18.5
18.6

19

Active Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231


Commands for Managing Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Choosing Target Byte Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

Debugging Remote Programs . . . . . . . . . . . . . . 235

20.1 Connecting to a Remote Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


20.2 Sending files to a remote system . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.3 Using the gdbserver Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.3.1 Running gdbserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.3.1.1 Attaching to a Running Program . . . . . . . . . . . . . . . . . .
20.3.1.2 Multi-Process Mode for gdbserver . . . . . . . . . . . . . . . .
20.3.1.3 TCP port allocation lifecycle of gdbserver . . . . . . . .
20.3.1.4 Other Command-Line Arguments for gdbserver . . .
20.3.2 Connecting to gdbserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.3.3 Monitor Commands for gdbserver . . . . . . . . . . . . . . . . . . . . .
20.3.4 Tracepoints support in gdbserver . . . . . . . . . . . . . . . . . . . . . .
20.4 Remote Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.5 Implementing a Remote Stub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20.5.1 What the Stub Can Do for You . . . . . . . . . . . . . . . . . . . . . . . .
20.5.2 What You Must Do for the Stub . . . . . . . . . . . . . . . . . . . . . . .
20.5.3 Putting it All Together. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

21

215
223
227
227
228
229

Specifying a Debugging Target . . . . . . . . . . . . 231

19.1
19.2
19.3

20

Commands to Specify Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


Debugging Information in Separate Files . . . . . . . . . . . . . . . . . . . .
Debugging information in a special section . . . . . . . . . . . . . . . . . .
Index Files Speed Up gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Errors Reading Symbol Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
GDB Data Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

235
237
237
237
238
238
239
239
240
240
241
242
247
248
248
250

Configuration-Specific Information . . . . . . . . 251

21.1 Native . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.1.1 HP-UX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.1.2 BSD libkvm Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.1.3 SVR4 Process Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.1.4 Features for Debugging djgpp Programs . . . . . . . . . . . . . . .
21.1.5 Features for Debugging MS Windows PE Executables . .
21.1.5.1 Support for DLLs without Debugging Symbols. . . . .
21.1.5.2 DLL Name Prefixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.1.5.3 Working with Minimal Symbols . . . . . . . . . . . . . . . . . . .
21.1.6 Commands Specific to gnu Hurd Systems . . . . . . . . . . . . . .
21.1.7 Darwin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.2 Embedded Operating Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.2.1 Using gdb with VxWorks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.2.1.1 Connecting to VxWorks . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.2.1.2 VxWorks Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

251
251
251
251
253
255
257
257
258
258
261
261
261
262
262

vii
21.2.1.3 Running Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3 Embedded Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.1 ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.2 Renesas M32R/D and M32R/SDI . . . . . . . . . . . . . . . . . . . . . .
21.3.3 M68k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.4 MicroBlaze . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.5 MIPS Embedded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.6 OpenRISC 1000. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.7 PowerPC Embedded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.8 HP PA Embedded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.9 Tsqware Sparclet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.9.1 Setting File to Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.9.2 Connecting to Sparclet . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.9.3 Sparclet Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.9.4 Running and Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.10 Fujitsu Sparclite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.11 Zilog Z8000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.12 Atmel AVR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.13 CRIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.14 Renesas Super-H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.4 Architectures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.4.1 AArch64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.4.2 x86 Architecture-specific Issues . . . . . . . . . . . . . . . . . . . . . . . . .
21.4.3 Alpha. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.4.4 MIPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.4.5 HPPA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.4.6 Cell Broadband Engine SPU architecture . . . . . . . . . . . . . . .
21.4.7 PowerPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

22

263
263
263
265
266
267
267
269
271
272
273
273
273
273
274
274
274
275
275
275
276
276
276
276
276
278
278
279

Controlling gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

22.1 Prompt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22.2 Command Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22.3 Command History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22.4 Screen Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22.5 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22.6 Configuring the Current ABI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22.7 Automatically loading associated files . . . . . . . . . . . . . . . . . . . . . . .
22.7.1 Automatically loading init file in the current directory . .
22.7.2 Automatically loading thread debugging library . . . . . . . .
22.7.3 The objfile-gdb.gdb file . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22.7.4 Security restriction for auto-loading . . . . . . . . . . . . . . . . . . . .
22.7.5 Displaying files tried for auto-load . . . . . . . . . . . . . . . . . . . . . .
22.8 Optional Warnings and Messages. . . . . . . . . . . . . . . . . . . . . . . . . . . .
22.9 Optional Messages about Internal Happenings . . . . . . . . . . . . . . .
22.10 Other Miscellaneous Settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

281
281
282
283
284
285
286
288
288
288
289
290
291
292
296

viii

Debugging with gdb

23

Extending gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297

23.1 Canned Sequences of Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . .


23.1.1 User-defined Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.1.2 User-defined Command Hooks. . . . . . . . . . . . . . . . . . . . . . . . . .
23.1.3 Command Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.1.4 Commands for Controlled Output . . . . . . . . . . . . . . . . . . . . . .
23.2 Scripting gdb using Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.1 Python Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2 Python API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.1 Basic Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.2 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.3 Values From Inferior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.4 Types In Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.5 Pretty Printing API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.6 Selecting Pretty-Printers . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.7 Writing a Pretty-Printer . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.8 Type Printing API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.9 Inferiors In Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.10 Events In Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.11 Threads In Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.12 Commands In Python . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.13 Parameters In Python . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.14 Writing new convenience functions . . . . . . . . . . . . . . .
23.2.2.15 Program Spaces In Python . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.16 Objfiles In Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.17 Accessing inferior stack frames from Python. . . . . .
23.2.2.18 Accessing frame blocks from Python. . . . . . . . . . . . . .
23.2.2.19 Python representation of Symbols. . . . . . . . . . . . . . . .
23.2.2.20 Symbol table representation in Python. . . . . . . . . . . .
23.2.2.21 Manipulating breakpoints using Python . . . . . . . . . .
23.2.2.22 Finish Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.2.23 Python representation of lazy strings. . . . . . . . . . . . .
23.2.2.24 Python representation of architectures . . . . . . . . . . . .
23.2.3 Python Auto-loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.3.1 The objfile-gdb.py file . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.3.2 The .debug_gdb_scripts section . . . . . . . . . . . . . . . . .
23.2.3.3 Which flavor to choose? . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.4 Python modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.4.1 gdb.printing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.4.2 gdb.types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2.4.3 gdb.prompt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.3 Creating new spellings of existing commands . . . . . . . . . . . . . . . .

24

297
297
299
300
301
303
303
304
304
308
309
313
317
318
319
321
322
323
325
326
329
331
332
333
333
336
337
340
342
344
345
346
346
347
348
348
349
349
350
351
352

Command Interpreters . . . . . . . . . . . . . . . . . . . . . 355

ix

25

gdb Text User Interface . . . . . . . . . . . . . . . . . . . . 357

25.1
25.2
25.3
25.4
25.5

TUI Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TUI Key Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TUI Single Key Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TUI-specific Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TUI Configuration Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

357
358
359
359
361

26

Using gdb under gnu Emacs . . . . . . . . . . . . . . . 363

27

The gdb/mi Interface . . . . . . . . . . . . . . . . . . . . . . . 365

Function and Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


Notation and Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.3 gdb/mi General Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.3.1 Context management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.3.2 Asynchronous command execution and non-stop mode . .
27.3.3 Thread groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.4 gdb/mi Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.4.1 gdb/mi Input Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.4.2 gdb/mi Output Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.5 gdb/mi Compatibility with CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.6 gdb/mi Development and Front Ends . . . . . . . . . . . . . . . . . . . . . . .
27.7 gdb/mi Output Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.7.1 gdb/mi Result Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.7.2 gdb/mi Stream Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.7.3 gdb/mi Async Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.7.4 gdb/mi Breakpoint Information . . . . . . . . . . . . . . . . . . . . . . . .
27.7.5 gdb/mi Frame Information . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.7.6 gdb/mi Thread Information . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.7.7 gdb/mi Ada Exception Information . . . . . . . . . . . . . . . . . . . .
27.8 Simple Examples of gdb/mi Interaction . . . . . . . . . . . . . . . . . . . . .
27.9 gdb/mi Command Description Format . . . . . . . . . . . . . . . . . . . . . .
27.10 gdb/mi Breakpoint Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.11 gdb/mi Catchpoint Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.12 gdb/mi Program Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.13 gdb/mi Thread Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.14 gdb/mi Ada Tasking Commands . . . . . . . . . . . . . . . . . . . . . . . . . .
27.15 gdb/mi Program Execution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.16 gdb/mi Stack Manipulation Commands . . . . . . . . . . . . . . . . . . . .
27.17 gdb/mi Variable Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.18 gdb/mi Data Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.19 gdb/mi Tracepoint Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.20 gdb/mi Symbol Query Commands . . . . . . . . . . . . . . . . . . . . . . . . .
27.21 gdb/mi File Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27.22 gdb/mi Target Manipulation Commands. . . . . . . . . . . . . . . . . . .
27.23 gdb/mi File Transfer Commands . . . . . . . . . . . . . . . . . . . . . . . . . .
27.24 Miscellaneous gdb/mi Commands . . . . . . . . . . . . . . . . . . . . . . . . .

365
365
365
366
367
367
368
368
369
370
371
371
371
372
372
376
377
378
378
378
379
380
388
389
391
393
394
401
406
416
425
429
429
431
434
435

Debugging with gdb

28

gdb Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443

28.1
28.2
28.3
28.4
28.5
28.6
28.7

29

What is an Annotation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
The Server Prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Annotation for gdb Input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Invalidation Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Running the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Displaying Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

JIT Compilation Interface . . . . . . . . . . . . . . . . . 447

29.1 JIT Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


29.2 Registering Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
29.3 Unregistering Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
29.4 Custom Debug Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
29.4.1 Using JIT Debug Info Readers . . . . . . . . . . . . . . . . . . . . . . . . .
29.4.2 Writing JIT Debug Info Readers . . . . . . . . . . . . . . . . . . . . . . .

30

443
444
444
445
445
445
446

447
448
448
448
449
449

In-Process Agent. . . . . . . . . . . . . . . . . . . . . . . . . . . . 451

30.1 In-Process Agent Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451


30.1.1 IPA Protocol Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452
30.1.2 IPA Protocol Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453

31

Reporting Bugs in gdb . . . . . . . . . . . . . . . . . . . . . 455

31.1
31.2

32

Have You Found a Bug? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455


How to Report Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455

Command Line Editing. . . . . . . . . . . . . . . . . . . . . 459

32.1 Introduction to Line Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


32.2 Readline Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32.2.1 Readline Bare Essentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32.2.2 Readline Movement Commands . . . . . . . . . . . . . . . . . . . . . . . .
32.2.3 Readline Killing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32.2.4 Readline Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32.2.5 Searching for Commands in the History . . . . . . . . . . . . . . . .
32.3 Readline Init File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32.3.1 Readline Init File Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32.3.2 Conditional Init Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32.3.3 Sample Init File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32.4 Bindable Readline Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32.4.1 Commands For Moving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32.4.2 Commands For Manipulating The History . . . . . . . . . . . . . .
32.4.3 Commands For Changing Text . . . . . . . . . . . . . . . . . . . . . . . . .
32.4.4 Killing And Yanking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32.4.5 Specifying Numeric Arguments . . . . . . . . . . . . . . . . . . . . . . . . .
32.4.6 Letting Readline Type For You. . . . . . . . . . . . . . . . . . . . . . . . .
32.4.7 Keyboard Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32.4.8 Some Miscellaneous Commands . . . . . . . . . . . . . . . . . . . . . . . .

459
459
459
460
460
461
461
462
462
468
469
472
472
472
474
475
476
476
477
477

xi
32.5

33

Readline vi Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479

Using History Interactively . . . . . . . . . . . . . . . . 481

33.1 History Expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


33.1.1 Event Designators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
33.1.2 Word Designators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
33.1.3 Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

481
481
482
482

Appendix A

In Memoriam . . . . . . . . . . . . . . . . . . . . 485

Appendix B

Formatting Documentation . . . . . 487

Appendix C

Installing gdb . . . . . . . . . . . . . . . . . . . . 489

C.1
C.2
C.3
C.4
C.5
C.6

Requirements for Building gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


Invoking the gdb configure Script . . . . . . . . . . . . . . . . . . . . . . . .
Compiling gdb in Another Directory . . . . . . . . . . . . . . . . . . . . . . . .
Specifying Names for Hosts and Targets . . . . . . . . . . . . . . . . . . . . .
configure Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
System-wide configuration and settings . . . . . . . . . . . . . . . . . . . . . .

489
490
491
492
493
494

Appendix D

Maintenance Commands. . . . . . . . 495

Appendix E

gdb Remote Serial Protocol . . . . 503

E.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.2 Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.3 Stop Reply Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.4 General Query Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.5 Architecture-Specific Protocol Details . . . . . . . . . . . . . . . . . . . . . . . .
E.5.1 ARM-specific Protocol Details . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.5.1.1 ARM Breakpoint Kinds . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.5.2 MIPS-specific Protocol Details . . . . . . . . . . . . . . . . . . . . . . . . . .
E.5.2.1 MIPS Register Packet Format . . . . . . . . . . . . . . . . . . . . . .
E.5.2.2 MIPS Breakpoint Kinds . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.6 Tracepoint Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.6.1 Relocate instruction reply packet. . . . . . . . . . . . . . . . . . . . . . . .
E.7 Host I/O Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.8 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.9 Notification Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.10 Remote Protocol Support for Non-Stop Mode . . . . . . . . . . . . . . .
E.11 Packet Acknowledgment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.12 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.13 File-I/O Remote Protocol Extension . . . . . . . . . . . . . . . . . . . . . . . .
E.13.1 File-I/O Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.13.2 Protocol Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.13.3 The F Request Packet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.13.4 The F Reply Packet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

503
504
514
515
534
534
534
534
534
534
534
541
542
543
544
545
546
547
547
547
548
548
549

xii

Debugging with gdb


E.13.5 The Ctrl-C Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.13.6 Console I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.13.7 List of Supported Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
lseek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
rename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
unlink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stat/fstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
gettimeofday . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
isatty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.13.8 Protocol-specific Representation of Datatypes . . . . . . . . . .
Integral Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Pointer Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Memory Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
struct stat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
struct timeval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.13.9 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Open Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
mode t Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Errno Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Lseek Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.13.10 File-I/O Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.14 Library List Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.15 Library List Format for SVR4 Targets . . . . . . . . . . . . . . . . . . . . . .
E.16 Memory Map Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.17 Thread List Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.18 Traceframe Info Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
E.19 Branch Trace Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

549
549
550
550
551
551
552
552
553
553
554
554
555
555
555
556
556
556
556
557
557
557
557
558
558
558
558
559
560
561
562
562
563

Appendix F The GDB Agent Expression


Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
F.1
F.2
F.3
F.4
F.5

General Bytecode Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


Bytecode Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using Agent Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Varying Target Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Rationale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

565
567
572
573
573

xiii

Appendix G

Target Descriptions . . . . . . . . . . . . . 577

G.1 Retrieving Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


G.2 Target Description Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.2.1 Inclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.2.2 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.2.3 OS ABI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.2.4 Compatible Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.2.5 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.2.6 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.2.7 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.3 Predefined Target Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.4 Standard Target Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.4.1 AArch64 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.4.2 ARM Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.4.3 i386 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.4.4 MIPS Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.4.5 M68K Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.4.6 PowerPC Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
G.4.7 TMS320C6x Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

577
577
578
578
579
579
579
579
580
581
582
582
582
583
583
584
584
584

Appendix H Operating System Information


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585
H.1

Process list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585

Appendix I

Trace File Format . . . . . . . . . . . . . . . 587

Appendix J

.gdb_index section format. . . . . . . 589

Appendix K GNU GENERAL PUBLIC


LICENSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
Appendix L
GNU Free Documentation License
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605
Concept Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613
Command, Variable, and Function Index . . . . . . 627

Summary of gdb

Summary of gdb
The purpose of a debugger such as gdb is to allow you to see what is going on inside
another program while it executesor what another program was doing at the moment it
crashed.
gdb can do four main kinds of things (plus other things in support of these) to help you
catch bugs in the act:

Start your program, specifying anything that might affect its behavior.
Make your program stop on specified conditions.
Examine what has happened, when your program has stopped.
Change things in your program, so you can experiment with correcting the effects of
one bug and go on to learn about another.

You can use gdb to debug programs written in C and C++. For more information, see
Section 15.4 [Supported Languages], page 177. For more information, see Section 15.4.1 [C
and C++], page 177.
Support for D is partial. For information on D, see Section 15.4.2 [D], page 183.
Support for Modula-2 is partial.
[Modula-2], page 186.

For information on Modula-2, see Section 15.4.8

Support for OpenCL C is partial. For information on OpenCL C, see Section 15.4.5
[OpenCL C], page 185.
Debugging Pascal programs which use sets, subranges, file variables, or nested functions
does not currently work. gdb does not support entering expressions, printing values, or
similar features using Pascal syntax.
gdb can be used to debug programs written in Fortran, although it may be necessary
to refer to some variables with a trailing underscore.
gdb can be used to debug programs written in Objective-C, using either the Apple/NeXT or the GNU Objective-C runtime.

Free Software
gdb is free software, protected by the gnu General Public License (GPL). The GPL gives
you the freedom to copy or adapt a licensed programbut every person getting a copy also
gets with it the freedom to modify that copy (which means that they must get access to the
source code), and the freedom to distribute further copies. Typical software companies use
copyrights to limit your freedoms; the Free Software Foundation uses the GPL to preserve
these freedoms.
Fundamentally, the General Public License is a license which says that you have these
freedoms and that you cannot take these freedoms away from anyone else.

Free Software Needs Free Documentation


The biggest deficiency in the free software community today is not in the softwareit is the
lack of good free documentation that we can include with the free software. Many of our
most important programs do not come with free reference manuals and free introductory

Debugging with gdb

texts. Documentation is an essential part of any software package; when an important free
software package does not come with a free manual and a free tutorial, that is a major gap.
We have many such gaps today.
Consider Perl, for instance. The tutorial manuals that people normally use are non-free.
How did this come about? Because the authors of those manuals published them with
restrictive termsno copying, no modification, source files not availablewhich exclude
them from the free software world.
That wasnt the first time this sort of thing happened, and it was far from the last.
Many times we have heard a GNU user eagerly describe a manual that he is writing, his
intended contribution to the community, only to learn that he had ruined everything by
signing a publication contract to make it non-free.
Free documentation, like free software, is a matter of freedom, not price. The problem
with the non-free manual is not that publishers charge a price for printed copiesthat in
itself is fine. (The Free Software Foundation sells printed copies of manuals, too.) The
problem is the restrictions on the use of the manual. Free manuals are available in source
code form, and give you permission to copy and modify. Non-free manuals do not allow
this.
The criteria of freedom for a free manual are roughly the same as for free software.
Redistribution (including the normal kinds of commercial redistribution) must be permitted,
so that the manual can accompany every copy of the program, both on-line and on paper.
Permission for modification of the technical content is crucial too. When people modify the software, adding or changing features, if they are conscientious they will change
the manual tooso they can provide accurate and clear documentation for the modified
program. A manual that leaves you no choice but to write a new manual to document a
changed version of the program is not really available to our community.
Some kinds of limits on the way modification is handled are acceptable. For example,
requirements to preserve the original authors copyright notice, the distribution terms, or
the list of authors, are ok. It is also no problem to require modified versions to include
notice that they were modified. Even entire sections that may not be deleted or changed
are acceptable, as long as they deal with nontechnical topics (like this one). These kinds of
restrictions are acceptable because they dont obstruct the communitys normal use of the
manual.
However, it must be possible to modify all the technical content of the manual, and then
distribute the result in all the usual media, through all the usual channels. Otherwise, the
restrictions obstruct the use of the manual, it is not free, and we need another manual to
replace it.
Please spread the word about this issue. Our community continues to lose manuals
to proprietary publishing. If we spread the word that free software needs free reference
manuals and free tutorials, perhaps the next person who wants to contribute by writing
documentation will realize, before it is too late, that only free manuals contribute to the
free software community.
If you are writing documentation, please insist on publishing it under the GNU Free
Documentation License or another free documentation license. Remember that this decision requires your approvalyou dont have to let the publisher decide. Some commercial
publishers will use a free license if you insist, but they will not propose the option; it is up

Summary of gdb

to you to raise the issue and say firmly that this is what you want. If the publisher you
are dealing with refuses, please try other publishers. If youre not sure whether a proposed
license is free, write to [email protected].
You can encourage commercial publishers to sell more free, copylefted manuals and
tutorials by buying them, and particularly by buying copies from the publishers that paid
for their writing or for major improvements. Meanwhile, try to avoid buying non-free
documentation at all. Check the distribution terms of a manual before you buy it, and
insist that whoever seeks your business must respect your freedom. Check the history of
the book, and try to reward the publishers that have paid or pay the authors to work on it.
The Free Software Foundation maintains a list of free documentation published by other
publishers, at http://www.fsf.org/doc/other-free-books.html.

Contributors to gdb
Richard Stallman was the original author of gdb, and of many other gnu programs. Many
others have contributed to its development. This section attempts to credit major contributors. One of the virtues of free software is that everyone is free to contribute to it; with
regret, we cannot actually acknowledge everyone here. The file ChangeLog in the gdb
distribution approximates a blow-by-blow account.
Changes much prior to version 2.0 are lost in the mists of time.
Plea: Additions to this section are particularly welcome. If you or your friends
(or enemies, to be evenhanded) have been unfairly omitted from this list, we
would like to add your names!
So that they may not regard their many labors as thankless, we particularly thank those
who shepherded gdb through major releases: Andrew Cagney (releases 6.3, 6.2, 6.1, 6.0,
5.3, 5.2, 5.1 and 5.0); Jim Blandy (release 4.18); Jason Molenda (release 4.17); Stan Shebs
(release 4.14); Fred Fish (releases 4.16, 4.15, 4.13, 4.12, 4.11, 4.10, and 4.9); Stu Grossman
and John Gilmore (releases 4.8, 4.7, 4.6, 4.5, and 4.4); John Gilmore (releases 4.3, 4.2, 4.1,
4.0, and 3.9); Jim Kingdon (releases 3.5, 3.4, and 3.3); and Randy Smith (releases 3.2, 3.1,
and 3.0).
Richard Stallman, assisted at various times by Peter TerMaat, Chris Hanson, and
Richard Mlynarik, handled releases through 2.8.
Michael Tiemann is the author of most of the gnu C++ support in gdb, with significant
additional contributions from Per Bothner and Daniel Berlin. James Clark wrote the gnu
C++ demangler. Early work on C++ was by Peter TerMaat (who also did much general
update work leading to release 3.0).
gdb uses the BFD subroutine library to examine multiple object-file formats; BFD was
a joint project of David V. Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John
Gilmore.
David Johnson wrote the original COFF support; Pace Willison did the original support
for encapsulated COFF.
Brent Benson of Harris Computer Systems contributed DWARF 2 support.
Adam de Boor and Bradley Davis contributed the ISI Optimum V support. Per Bothner,
Noboyuki Hikichi, and Alessandro Forin contributed MIPS support. Jean-Daniel Fekete
contributed Sun 386i support. Chris Hanson improved the HP9000 support. Noboyuki

Debugging with gdb

Hikichi and Tomoyuki Hasei contributed Sony/News OS 3 support. David Johnson contributed Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support. Jeff
Law contributed HP PA and SOM support. Keith Packard contributed NS32K support.
Doug Rabson contributed Acorn Risc Machine support. Bob Rusk contributed Harris
Nighthawk CX-UX support. Chris Smith contributed Convex support (and Fortran debugging). Jonathan Stone contributed Pyramid support. Michael Tiemann contributed
SPARC support. Tim Tucker contributed support for the Gould NP1 and Gould Powernode. Pace Willison contributed Intel 386 support. Jay Vosburgh contributed Symmetry
support. Marko Mlinar contributed OpenRISC 1000 support.
Andreas Schwab contributed M68K gnu/Linux support.
Rich Schaefer and Peter Schauer helped with support of SunOS shared libraries.
Jay Fenlason and Roland McGrath ensured that gdb and GAS agree about several
machine instruction sets.
Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped develop remote
debugging. Intel Corporation, Wind River Systems, AMD, and ARM contributed remote
debugging modules for the i960, VxWorks, A29K UDI, and RDI targets, respectively.
Brian Fox is the author of the readline libraries providing command-line editing and
command history.
Andrew Beers of SUNY Buffalo wrote the language-switching code, the Modula-2 support, and contributed the Languages chapter of this manual.
Fred Fish wrote most of the support for Unix System Vr4. He also enhanced the
command-completion support to cover C++ overloaded symbols.
Hitachi America (now Renesas America), Ltd. sponsored the support for H8/300,
H8/500, and Super-H processors.
NEC sponsored the support for the v850, Vr4xxx, and Vr5xxx processors.
Mitsubishi (now Renesas) sponsored the support for D10V, D30V, and M32R/D processors.
Toshiba sponsored the support for the TX39 Mips processor.
Matsushita sponsored the support for the MN10200 and MN10300 processors.
Fujitsu sponsored the support for SPARClite and FR30 processors.
Kung Hsu, Jeff Law, and Rick Sladkey added support for hardware watchpoints.
Michael Snyder added support for tracepoints.
Stu Grossman wrote gdbserver.
Jim Kingdon, Peter Schauer, Ian Taylor, and Stu Grossman made nearly innumerable
bug fixes and cleanups throughout gdb.
The following people at the Hewlett-Packard Company contributed support for the PARISC 2.0 architecture, HP-UX 10.20, 10.30, and 11.0 (narrow mode), HPs implementation
of kernel threads, HPs aC++ compiler, and the Text User Interface (nee Terminal User
Interface): Ben Krepp, Richard Title, John Bishop, Susan Macchia, Kathy Mann, Satish
Pai, India Paul, Steve Rehrauer, and Elena Zannoni. Kim Haase provided HP-specific
information in this manual.
DJ Delorie ported gdb to MS-DOS, for the DJGPP project. Robert Hoehne made
significant contributions to the DJGPP port.

Summary of gdb

Cygnus Solutions has sponsored gdb maintenance and much of its development since
1991. Cygnus engineers who have worked on gdb fulltime include Mark Alexander, Jim
Blandy, Per Bothner, Kevin Buettner, Edith Epstein, Chris Faylor, Fred Fish, Martin
Hunt, Jim Ingham, John Gilmore, Stu Grossman, Kung Hsu, Jim Kingdon, John Metzler,
Fernando Nasser, Geoffrey Noer, Dawn Perchik, Rich Pixley, Zdenek Radouch, Keith Seitz,
Stan Shebs, David Taylor, and Elena Zannoni. In addition, Dave Brolley, Ian Carmichael,
Steve Chamberlain, Nick Clifton, JT Conklin, Stan Cox, DJ Delorie, Ulrich Drepper, Frank
Eigler, Doug Evans, Sean Fagan, David Henkel-Wallace, Richard Henderson, Jeff Holcomb,
Jeff Law, Jim Lemke, Tom Lord, Bob Manson, Michael Meissner, Jason Merrill, Catherine
Moore, Drew Moseley, Ken Raeburn, Gavin Romig-Koch, Rob Savoye, Jamie Smith, Mike
Stump, Ian Taylor, Angela Thomas, Michael Tiemann, Tom Tromey, Ron Unrau, Jim
Wilson, and David Zuhn have made contributions both large and small.
Andrew Cagney, Fernando Nasser, and Elena Zannoni, while working for Cygnus Solutions, implemented the original gdb/mi interface.
Jim Blandy added support for preprocessor macros, while working for Red Hat.
Andrew Cagney designed gdbs architecture vector. Many people including Andrew
Cagney, Stephane Carrez, Randolph Chung, Nick Duffek, Richard Henderson, Mark Kettenis, Grace Sainsbury, Kei Sakamoto, Yoshinori Sato, Michael Snyder, Andreas Schwab,
Jason Thorpe, Corinna Vinschen, Ulrich Weigand, and Elena Zannoni, helped with the
migration of old architectures to this new framework.
Andrew Cagney completely re-designed and re-implemented gdbs unwinder framework,
this consisting of a fresh new design featuring frame IDs, independent frame sniffers, and
the sentinel frame. Mark Kettenis implemented the dwarf 2 unwinder, Jeff Johnston the
libunwind unwinder, and Andrew Cagney the dummy, sentinel, tramp, and trad unwinders.
The architecture-specific changes, each involving a complete rewrite of the architectures
frame code, were carried out by Jim Blandy, Joel Brobecker, Kevin Buettner, Andrew
Cagney, Stephane Carrez, Randolph Chung, Orjan Friberg, Richard Henderson, Daniel
Jacobowitz, Jeff Johnston, Mark Kettenis, Theodore A. Roth, Kei Sakamoto, Yoshinori
Sato, Michael Snyder, Corinna Vinschen, and Ulrich Weigand.
Christian Zankel, Ross Morley, Bob Wilson, and Maxim Grigoriev from Tensilica, Inc.
contributed support for Xtensa processors. Others who have worked on the Xtensa port of
gdb in the past include Steve Tjiang, John Newlin, and Scott Foehner.
Michael Eager and staff of Xilinx, Inc., contributed support for the Xilinx MicroBlaze
architecture.

Chapter 1: A Sample gdb Session

1 A Sample gdb Session


You can use this manual at your leisure to read all about gdb. However, a handful of
commands are enough to get started using the debugger. This chapter illustrates those
commands.
In this sample session, we emphasize user input like this: input, to make it easier to pick
out from the surrounding output.
One of the preliminary versions of gnu m4 (a generic macro processor) exhibits the
following bug: sometimes, when we change its quote strings from the default, the commands
used to capture one macro definition within another stop working. In the following short m4
session, we define a macro foo which expands to 0000; we then use the m4 built-in defn to
define bar as th