Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Debugging with gdb 9th Edition Richard Stallman All Chapters Instant Download

Download as pdf or txt
Download as pdf or txt
You are on page 1of 77

Download the full version of the ebook at

https://ebookfinal.com

Debugging with gdb 9th Edition Richard


Stallman

https://ebookfinal.com/download/debugging-with-
gdb-9th-edition-richard-stallman/

Explore and download more ebook at https://ebookfinal.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Debugging with GDB v8 3 1 10th Edition Richard Stallman

https://ebookfinal.com/download/debugging-with-gdb-v8-3-1-10th-
edition-richard-stallman/

ebookfinal.com

Texas Politics 9th Edition Richard H. Kraemer

https://ebookfinal.com/download/texas-politics-9th-edition-richard-h-
kraemer/

ebookfinal.com

Software Development Design and Coding With Patterns


Debugging Unit Testing and Refactoring 3rd Edition John F.
Dooley
https://ebookfinal.com/download/software-development-design-and-
coding-with-patterns-debugging-unit-testing-and-refactoring-3rd-
edition-john-f-dooley/
ebookfinal.com

College Algebra with Trigonometry 9th Edition Raymond A.


Barnett

https://ebookfinal.com/download/college-algebra-with-trigonometry-9th-
edition-raymond-a-barnett/

ebookfinal.com
Linear Algebra with Applications 9th Edition Steven J.
Leon

https://ebookfinal.com/download/linear-algebra-with-applications-9th-
edition-steven-j-leon/

ebookfinal.com

Patent Copyright Trademark An Intellectual Property Desk


Reference 9th Edition Richard Stim Attorney

https://ebookfinal.com/download/patent-copyright-trademark-an-
intellectual-property-desk-reference-9th-edition-richard-stim-
attorney/
ebookfinal.com

Frommer s New York City with Kids 2005 Frommer s With Kids
9th Edition Holly Hughes

https://ebookfinal.com/download/frommer-s-new-york-city-with-
kids-2005-frommer-s-with-kids-9th-edition-holly-hughes/

ebookfinal.com

Social work with groups a comprehensive worktext 9th


edition. Edition Charles Zastrow

https://ebookfinal.com/download/social-work-with-groups-a-
comprehensive-worktext-9th-edition-edition-charles-zastrow/

ebookfinal.com

BUGS in writing a guide to debugging your prose Lyn Dupré

https://ebookfinal.com/download/bugs-in-writing-a-guide-to-debugging-
your-prose-lyn-dupre/

ebookfinal.com
Debugging with gdb 9th Edition Richard Stallman Digital
Instant Download
Author(s): Richard Stallman, Roland Pesch, Stan Shebs, et al.
ISBN(s): 9781882114771, 1882114779
Edition: 9
File Details: PDF, 2.35 MB
Year: 2008
Language: english
Debugging with gdb
The gnu Source-Level Debugger

Ninth Edition, for gdb version 7.0.50.20100218-cvs

(Sourcery G++ Lite 2010q1-188)

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


(Send bugs and comments on gdb to
https://support.codesourcery.com/GNUToolchain/.)
Debugging with gdb
TEXinfo 2008-04-18.10

Published by the Free Software Foundation


51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
ISBN 1-882114-77-9

Copyright c 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
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 FSF’s Back-Cover Text is: “You are free to copy and modify this GNU Man-
ual. Buying copies from GNU Press supports the FSF in developing GNU and promoting
software freedom.”
This edition of the GDB manual is dedicated to the memory of Fred Fish. Fred was a
long-standing contributor to GDB and to Free software in general. We will miss him.
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 Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.1.2 Choosing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.3 What gdb Does During Startup . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2 Quitting gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3 Shell Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.4 Logging Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

3 gdb Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.1 Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.2 Command Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

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


4.1 Compiling for Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2 Starting your Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.3 Your Program’s Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.4 Your Program’s Environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.5 Your Program’s Working Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.6 Your Program’s Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.7 Debugging an Already-running Process . . . . . . . . . . . . . . . . . . . . . . . . 31
4.8 Killing the Child Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.9 Debugging Multiple Inferiors and Programs. . . . . . . . . . . . . . . . . . . . 32
4.10 Debugging Programs with Multiple Threads . . . . . . . . . . . . . . . . . . 35
4.11 Debugging Forks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.12 Setting a Bookmark to Return to Later. . . . . . . . . . . . . . . . . . . . . . . 40
4.12.1 A Non-obvious Benefit of Using Checkpoints . . . . . . . . . . . . . 41
ii Debugging with gdb

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


5.1 Breakpoints, Watchpoints, and Catchpoints . . . . . . . . . . . . . . . . . . . 43
5.1.1 Setting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.1.2 Setting Watchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.1.3 Setting Catchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.1.4 Deleting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.1.5 Disabling Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.1.6 Break Conditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.1.7 Breakpoint Command Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.1.8 “Cannot insert breakpoints” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.1.9 “Breakpoint address adjusted...”. . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.2 Continuing and Stepping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.3 Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.4 Stopping and Starting Multi-thread Programs . . . . . . . . . . . . . . . . . 65
5.4.1 All-Stop Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.4.2 Non-Stop Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.4.3 Background Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.4.4 Thread-Specific Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
5.4.5 Interrupted System Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

6 Running programs backward . . . . . . . . . . . . . . . . . 71

7 Recording Inferior’s Execution and Replaying


It . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

8 Examining the Stack . . . . . . . . . . . . . . . . . . . . . . . . . . 77


8.1 Stack Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
8.2 Backtraces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
8.3 Selecting a Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
8.4 Information About a Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

9 Examining Source Files . . . . . . . . . . . . . . . . . . . . . . . 83


9.1 Printing Source Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
9.2 Specifying a Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
9.3 Editing Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
9.3.1 Choosing your Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
9.4 Searching Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
9.5 Specifying Source Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
9.6 Source and Machine Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
iii

10 Examining Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
10.1 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
10.2 Ambiguous Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
10.3 Program Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
10.4 Artificial Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
10.5 Output Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
10.6 Examining Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
10.7 Automatic Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
10.8 Print Settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
10.9 Value History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
10.10 Convenience Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
10.11 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
10.12 Floating Point Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
10.13 Vector Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
10.14 Operating System Auxiliary Information . . . . . . . . . . . . . . . . . . . 112
10.15 Memory Region Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
10.15.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
10.15.1.1 Memory Access Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
10.15.1.2 Memory Access Size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
10.15.1.3 Data Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
10.15.2 Memory Access Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
10.16 Copy Between Memory and a File . . . . . . . . . . . . . . . . . . . . . . . . . 115
10.17 How to Produce a Core File from Your Program . . . . . . . . . . . 116
10.18 Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
10.19 Caching Data of Remote Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
10.20 Search Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

11 Debugging Optimized Code . . . . . . . . . . . . . . . . 123


11.1 Inline Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

12 C Preprocessor Macros . . . . . . . . . . . . . . . . . . . . . 125

13 Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
13.1 Commands to Set Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
13.1.1 Create and Delete Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . 130
13.1.2 Enable and Disable Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . 131
13.1.3 Tracepoint Passcounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
13.1.4 Tracepoint Conditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
13.1.5 Trace State Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
13.1.6 Tracepoint Action Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
13.1.7 Listing Tracepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
13.1.8 Starting and Stopping Trace Experiments . . . . . . . . . . . . . . 134
13.2 Using the Collected Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
13.2.1 tfind n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
13.2.2 tdump. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
13.2.3 save-tracepoints filename . . . . . . . . . . . . . . . . . . . . . . . . . . 138
13.3 Convenience Variables for Tracepoints . . . . . . . . . . . . . . . . . . . . . . . 139
13.4 Using Trace Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
iv Debugging with gdb

14 Debugging Programs That Use Overlays


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
14.1 How Overlays Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
14.2 Overlay Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
14.3 Automatic Overlay Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
14.4 Overlay Sample Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

15 Using gdb with Different Languages . . . . . . 147


15.1 Switching Between Source Languages . . . . . . . . . . . . . . . . . . . . . . . 147
15.1.1 List of Filename Extensions and Languages . . . . . . . . . . . . . 147
15.1.2 Setting the Working Language . . . . . . . . . . . . . . . . . . . . . . . . . 148
15.1.3 Having gdb Infer the Source Language . . . . . . . . . . . . . . . . . 148
15.2 Displaying the Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
15.3 Type and Range Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
15.3.1 An Overview of Type Checking . . . . . . . . . . . . . . . . . . . . . . . . 149
15.3.2 An Overview of Range Checking . . . . . . . . . . . . . . . . . . . . . . . 150
15.4 Supported Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
15.4.1 C and C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
15.4.1.1 C and C++ Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
15.4.1.2 C and C++ Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
15.4.1.3 C++ Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
15.4.1.4 C and C++ Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
15.4.1.5 C and C++ Type and Range Checks . . . . . . . . . . . . . . . 155
15.4.1.6 gdb and C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
15.4.1.7 gdb Features for C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
15.4.1.8 Decimal Floating Point format . . . . . . . . . . . . . . . . . . . . 157
15.4.2 Objective-C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
15.4.2.1 Method Names in Commands . . . . . . . . . . . . . . . . . . . . . 157
15.4.2.2 The Print Command With Objective-C . . . . . . . . . . . . 158
15.4.3 Fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
15.4.3.1 Fortran Operators and Expressions . . . . . . . . . . . . . . . . 158
15.4.3.2 Fortran Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
15.4.3.3 Special Fortran Commands . . . . . . . . . . . . . . . . . . . . . . . . 159
15.4.4 Pascal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
15.4.5 Modula-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
15.4.5.1 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
15.4.5.2 Built-in Functions and Procedures . . . . . . . . . . . . . . . . . 161
15.4.5.3 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
15.4.5.4 Modula-2 Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
15.4.5.5 Modula-2 Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
15.4.5.6 Deviations from Standard Modula-2 . . . . . . . . . . . . . . . 164
15.4.5.7 Modula-2 Type and Range Checks. . . . . . . . . . . . . . . . . 164
15.4.5.8 The Scope Operators :: and . . . . . . . . . . . . . . . . . . . . . 165
15.4.5.9 gdb and Modula-2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
15.4.6 Ada . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
15.4.6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
15.4.6.2 Omissions from Ada . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
15.4.6.3 Additions to Ada . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
v

15.4.6.4 Stopping at the Very Beginning . . . . . . . . . . . . . . . . . . . 169


15.4.6.5 Extensions for Ada Tasks . . . . . . . . . . . . . . . . . . . . . . . . . 169
15.4.6.6 Tasking Support when Debugging Core Files . . . . . . 172
15.4.6.7 Known Peculiarities of Ada Mode . . . . . . . . . . . . . . . . . 172
15.5 Unsupported Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173

16 Examining the Symbol Table . . . . . . . . . . . . . . 175

17 Altering Execution. . . . . . . . . . . . . . . . . . . . . . . . . . 181


17.1 Assignment to Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
17.2 Continuing at a Different Address . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
17.3 Giving your Program a Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
17.4 Returning from a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
17.5 Calling Program Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
17.6 Patching Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185

18 gdb Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187


18.1 Commands to Specify Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
18.2 Debugging Information in Separate Files . . . . . . . . . . . . . . . . . . . . 193
18.3 Errors Reading Symbol Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
18.4 GDB Data Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

19 Specifying a Debugging Target . . . . . . . . . . . . 199


19.1 Active Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
19.2 Commands for Managing Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
19.3 Choosing Target Byte Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202

20 Debugging Remote Programs . . . . . . . . . . . . . . 203


20.1 Connecting to a Remote Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
20.2 Sending files to a remote system . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
20.3 Using the gdbserver Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
20.3.1 Running gdbserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
20.3.1.1 Attaching to a Running Program . . . . . . . . . . . . . . . . . . 206
20.3.1.2 Multi-Process Mode for gdbserver . . . . . . . . . . . . . . . . 206
20.3.1.3 Other Command-Line Arguments for gdbserver . . . 207
20.3.2 Connecting to gdbserver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
20.3.3 Monitor Commands for gdbserver . . . . . . . . . . . . . . . . . . . . . 207
20.4 Remote Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
20.5 Implementing a Remote Stub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
20.5.1 What the Stub Can Do for You . . . . . . . . . . . . . . . . . . . . . . . . 213
20.5.2 What You Must Do for the Stub . . . . . . . . . . . . . . . . . . . . . . . 214
20.5.3 Putting it All Together. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
vi Debugging with gdb

21 Configuration-Specific Information . . . . . . . . 217


21.1 Native . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
21.1.1 HP-UX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
21.1.2 BSD libkvm Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
21.1.3 SVR4 Process Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
21.1.4 Features for Debugging djgpp Programs . . . . . . . . . . . . . . . 219
21.1.5 Features for Debugging MS Windows PE Executables . . 221
21.1.5.1 Support for DLLs without Debugging Symbols. . . . . 222
21.1.5.2 DLL Name Prefixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
21.1.5.3 Working with Minimal Symbols . . . . . . . . . . . . . . . . . . . 223
21.1.6 Commands Specific to gnu Hurd Systems . . . . . . . . . . . . . . 224
21.1.7 QNX Neutrino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
21.1.8 Darwin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
21.2 Embedded Operating Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
21.2.1 Using gdb with VxWorks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
21.2.1.1 Connecting to VxWorks . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
21.2.1.2 VxWorks Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
21.2.1.3 Running Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
21.3 Embedded Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
21.3.1 ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
21.3.2 Renesas M32R/D and M32R/SDI . . . . . . . . . . . . . . . . . . . . . . 231
21.3.3 M68k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
21.3.4 MicroBlaze . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
21.3.5 MIPS Embedded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
21.3.6 OpenRISC 1000. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
21.3.7 PowerPC Embedded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
21.3.8 HP PA Embedded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
21.3.9 Tsqware Sparclet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
21.3.9.1 Setting File to Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
21.3.9.2 Connecting to Sparclet . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
21.3.9.3 Sparclet Download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
21.3.9.4 Running and Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
21.3.10 Fujitsu Sparclite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
21.3.11 Zilog Z8000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
21.3.12 Atmel AVR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
21.3.13 CRIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
21.3.14 Renesas Super-H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
21.4 Architectures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
21.4.1 x86 Architecture-specific Issues . . . . . . . . . . . . . . . . . . . . . . . . . 240
21.4.2 A29K . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
21.4.3 Alpha. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
21.4.4 MIPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
21.4.5 HPPA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
21.4.6 Cell Broadband Engine SPU architecture . . . . . . . . . . . . . . . 243
21.4.7 PowerPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
vii

22 Controlling gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245


22.1 Prompt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
22.2 Command Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
22.3 Command History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
22.4 Screen Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
22.5 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
22.6 Configuring the Current ABI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
22.7 Optional Warnings and Messages. . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
22.8 Optional Messages about Internal Happenings . . . . . . . . . . . . . . . 251
22.9 Other Miscellaneous Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

23 Extending gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255


23.1 Canned Sequences of Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
23.1.1 User-defined Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
23.1.2 User-defined Command Hooks. . . . . . . . . . . . . . . . . . . . . . . . . . 257
23.1.3 Command Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
23.1.4 Commands for Controlled Output . . . . . . . . . . . . . . . . . . . . . . 259
23.2 Scripting gdb using Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
23.2.1 Python Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
23.2.2 Python API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
23.2.2.1 Basic Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
23.2.2.2 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
23.2.2.3 Auto-loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
23.2.2.4 Values From Inferior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
23.2.2.5 Types In Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
23.2.2.6 Pretty Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
23.2.2.7 Selecting Pretty-Printers . . . . . . . . . . . . . . . . . . . . . . . . . . 271
23.2.2.8 Commands In Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
23.2.2.9 Writing new convenience functions . . . . . . . . . . . . . . . . 275
23.2.2.10 Objfiles In Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
23.2.2.11 Acessing inferior stack frames from Python. . . . . . . 276
23.2.2.12 Python representation of lazy strings. . . . . . . . . . . . . 277

24 Command Interpreters . . . . . . . . . . . . . . . . . . . . . 279

25 gdb Text User Interface . . . . . . . . . . . . . . . . . . . . 281


25.1 TUI Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
25.2 TUI Key Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
25.3 TUI Single Key Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
25.4 TUI-specific Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
25.5 TUI Configuration Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

26 Using gdb under gnu Emacs . . . . . . . . . . . . . . . 287


viii Debugging with gdb

27 The gdb/mi Interface . . . . . . . . . . . . . . . . . . . . . . . 289


Function and Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Notation and Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
27.3 gdb/mi General Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
27.3.1 Context management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
27.3.2 Asynchronous command execution and non-stop mode . . 291
27.3.3 Thread groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
27.4 gdb/mi Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
27.4.1 gdb/mi Input Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
27.4.2 gdb/mi Output Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
27.5 gdb/mi Compatibility with CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
27.6 gdb/mi Development and Front Ends . . . . . . . . . . . . . . . . . . . . . . . 294
27.7 gdb/mi Output Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
27.7.1 gdb/mi Result Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
27.7.2 gdb/mi Stream Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
27.7.3 gdb/mi Async Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
27.7.4 gdb/mi Frame Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
27.7.5 gdb/mi Thread Information . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
27.8 Simple Examples of gdb/mi Interaction . . . . . . . . . . . . . . . . . . . . . 298
27.9 gdb/mi Command Description Format . . . . . . . . . . . . . . . . . . . . . . 299
27.10 gdb/mi Breakpoint Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
27.11 gdb/mi Program Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
27.12 gdb/mi Thread Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
27.13 gdb/mi Program Execution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
27.14 gdb/mi Stack Manipulation Commands . . . . . . . . . . . . . . . . . . . . 319
27.15 gdb/mi Variable Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
27.16 gdb/mi Data Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
27.17 gdb/mi Tracepoint Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
27.18 gdb/mi Symbol Query Commands . . . . . . . . . . . . . . . . . . . . . . . . . 341
27.19 gdb/mi File Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
27.20 gdb/mi Target Manipulation Commands. . . . . . . . . . . . . . . . . . . 343
27.21 gdb/mi File Transfer Commands . . . . . . . . . . . . . . . . . . . . . . . . . . 346
27.22 Miscellaneous gdb/mi Commands . . . . . . . . . . . . . . . . . . . . . . . . . 347

28 gdb Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355


28.1 What is an Annotation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
28.2 The Server Prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
28.3 Annotation for gdb Input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
28.4 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
28.5 Invalidation Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
28.6 Running the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
28.7 Displaying Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358

29 JIT Compilation Interface . . . . . . . . . . . . . . . . . 359


29.1 JIT Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
29.2 Registering Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
29.3 Unregistering Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
ix

30 Reporting Bugs in gdb . . . . . . . . . . . . . . . . . . . . . 361


30.1 Have You Found a Bug? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
30.2 How to Report Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361

31 Command Line Editing. . . . . . . . . . . . . . . . . . . . . 365


31.1 Introduction to Line Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
31.2 Readline Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
31.2.1 Readline Bare Essentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
31.2.2 Readline Movement Commands . . . . . . . . . . . . . . . . . . . . . . . . 366
31.2.3 Readline Killing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366
31.2.4 Readline Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
31.2.5 Searching for Commands in the History . . . . . . . . . . . . . . . . 367
31.3 Readline Init File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
31.3.1 Readline Init File Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
31.3.2 Conditional Init Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
31.3.3 Sample Init File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
31.4 Bindable Readline Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
31.4.1 Commands For Moving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
31.4.2 Commands For Manipulating The History . . . . . . . . . . . . . . 377
31.4.3 Commands For Changing Text . . . . . . . . . . . . . . . . . . . . . . . . . 379
31.4.4 Killing And Yanking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
31.4.5 Specifying Numeric Arguments . . . . . . . . . . . . . . . . . . . . . . . . . 381
31.4.6 Letting Readline Type For You. . . . . . . . . . . . . . . . . . . . . . . . . 381
31.4.7 Keyboard Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
31.4.8 Some Miscellaneous Commands . . . . . . . . . . . . . . . . . . . . . . . . 382
31.5 Readline vi Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

32 Using History Interactively . . . . . . . . . . . . . . . . 385


32.1 History Expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
32.1.1 Event Designators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
32.1.2 Word Designators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
32.1.3 Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386

Appendix A Formatting Documentation . . . . . 389

Appendix B Installing gdb . . . . . . . . . . . . . . . . . . . . 391


B.1 Requirements for Building gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
B.2 Invoking the gdb ‘configure’ Script . . . . . . . . . . . . . . . . . . . . . . . . 392
B.3 Compiling gdb in Another Directory . . . . . . . . . . . . . . . . . . . . . . . . 393
B.4 Specifying Names for Hosts and Targets . . . . . . . . . . . . . . . . . . . . . 394
B.5 ‘configure’ Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
B.6 System-wide configuration and settings . . . . . . . . . . . . . . . . . . . . . . 395

Appendix C Maintenance Commands. . . . . . . . 397


x Debugging with gdb

Appendix D gdb Remote Serial Protocol . . . . 403


D.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
D.2 Standard Replies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
D.3 Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
D.4 Stop Reply Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
D.5 General Query Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
D.6 Architecture-Specific Protocol Details . . . . . . . . . . . . . . . . . . . . . . . . 428
D.6.1 ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
D.6.1.1 Breakpoint Kinds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
D.6.2 MIPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
D.6.2.1 Register Packet Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
D.6.2.2 Breakpoint Kinds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
D.7 Tracepoint Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
D.8 Host I/O Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
D.9 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
D.10 Notification Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
D.11 Remote Protocol Support for Non-Stop Mode . . . . . . . . . . . . . . . 434
D.12 Packet Acknowledgment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
D.13 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
D.14 File-I/O Remote Protocol Extension . . . . . . . . . . . . . . . . . . . . . . . . 437
D.14.1 File-I/O Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
D.14.2 Protocol Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
D.14.3 The F Request Packet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
D.14.4 The F Reply Packet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
D.14.5 The ‘Ctrl-C’ Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
D.14.6 Console I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
D.14.7 List of Supported Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
lseek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
rename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
unlink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
stat/fstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
gettimeofday . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
isatty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
D.14.8 Protocol-specific Representation of Datatypes . . . . . . . . . . 445
Integral Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
Pointer Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
Memory Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
struct stat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
struct timeval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
D.14.9 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
Open Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
mode t Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
Errno Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
xi

Lseek Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448


Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
D.14.10 File-I/O Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
D.15 Library List Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
D.16 Memory Map Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
D.17 Thread List Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451

Appendix E The GDB Agent Expression


Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
E.1 General Bytecode Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
E.2 Bytecode Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
E.3 Using Agent Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
E.4 Varying Target Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
E.5 Rationale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460

Appendix F Trace File Format . . . . . . . . . . . . . . . 465

Appendix G Target Descriptions . . . . . . . . . . . . . 467


G.1 Retrieving Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
G.2 Target Description Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
G.2.1 Inclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
G.2.2 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
G.2.3 OS ABI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
G.2.4 Compatible Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
G.2.5 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
G.2.6 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
G.2.7 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
G.3 Predefined Target Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
G.4 Standard Target Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
G.4.1 ARM Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
G.4.2 i386 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
G.4.3 MIPS Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
G.4.4 M68K Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
G.4.5 PowerPC Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473

Appendix H Operating System Information


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
H.1 Process list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475

Appendix I GNU GENERAL PUBLIC


LICENSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477

Appendix J GNU Free Documentation License


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
J.1 ADDENDUM: How to use this License for your documents . . . 495
xii Debugging with gdb

GDB Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497


Summary of gdb 1

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 executes—or 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 151. For more information, see Section 15.4.1 [C
and C++], page 151.
Support for Modula-2 is partial. For information on Modula-2, see Section 15.4.5
[Modula-2], page 159.
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 Ap-
ple/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 program—but 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 software—it 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
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.
2 Debugging with gdb

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 terms—no copying, no modification, source files not available—which exclude
them from the free software world.
That wasn’t 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 copies—that 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 mod-
ify the software, adding or changing features, if they are conscientious they will change
the manual too—so 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 author’s 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 don’t obstruct the community’s 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 deci-
sion requires your approval—you don’t 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
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 you’re not sure whether a proposed
license is free, write to licensing@gnu.org.
Summary of gdb 3

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 contrib-
utors. 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
Hikichi and Tomoyuki Hasei contributed Sony/News OS 3 support. David Johnson con-
tributed Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support. Jeff
Law contributed HP PA and SOM support. Keith Packard contributed NS32K support.
4 Debugging with gdb

Doug Rabson contributed Acorn Risc Machine support. Bob Rusk contributed Harris
Nighthawk CX-UX support. Chris Smith contributed Convex support (and Fortran de-
bugging). Jonathan Stone contributed Pyramid support. Michael Tiemann contributed
SPARC support. Tim Tucker contributed support for the Gould NP1 and Gould Powern-
ode. 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 sup-
port, 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 proces-
sors.
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 PA-
RISC 2.0 architecture, HP-UX 10.20, 10.30, and 11.0 (narrow mode), HP’s implementation
of kernel threads, HP’s 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.
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
Summary of gdb 5

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 Solu-
tions, implemented the original gdb/mi interface.
Jim Blandy added support for preprocessor macros, while working for Red Hat.
Andrew Cagney designed gdb’s architecture vector. Many people including Andrew
Cagney, Stephane Carrez, Randolph Chung, Nick Duffek, Richard Henderson, Mark Ket-
tenis, 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 gdb’s 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 architecture’s
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 7

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 the same thing. However, when we change the open quote string to <QUOTE>
and the close quote string to <UNQUOTE>, the same procedure fails to define a new synonym
baz:
$ cd gnu/m4
$ ./m4
define(foo,0000)

foo
0000
define(bar,defn(‘foo’))

bar
0000
changequote(<QUOTE>,<UNQUOTE>)

define(baz,defn(<QUOTE>foo<UNQUOTE>))
baz
Ctrl-d
m4: End of input: 0: fatal error: EOF in string
Let us use gdb to try to see what is going on.
$ gdb m4
gdb is free software and you are welcome to distribute copies
of it under certain conditions; type "show copying" to see
the conditions.
There is absolutely no warranty for gdb; type "show warranty"
for details.

gdb 7.0.50.20100218-cvs, Copyright 1999 Free Software Foundation, Inc...


(gdb)
gdb reads only enough symbol data to know where to find the rest when needed; as a result,
the first prompt comes up very quickly. We now tell gdb to use a narrower display width
than usual, so that examples fit in this manual.
(gdb) set width 70
We need to see how the m4 built-in changequote works. Having looked at the source, we
know the relevant subroutine is m4_changequote, so we set a breakpoint there with the
gdb break command.
(gdb) break m4 changequote
Breakpoint 1 at 0x62f4: file builtin.c, line 879.
Using the run command, we start m4 running under gdb control; as long as control does
not reach the m4_changequote subroutine, the program runs as usual:
8 Debugging with gdb

(gdb) run
Starting program: /work/Editorial/gdb/gnu/m4/m4
define(foo,0000)

foo
0000
To trigger the breakpoint, we call changequote. gdb suspends execution of m4, displaying
information about the context where it stops.
changequote(<QUOTE>,<UNQUOTE>)

Breakpoint 1, m4_changequote (argc=3, argv=0x33c70)


at builtin.c:879
879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3))
Now we use the command n (next) to advance execution to the next line of the current
function.
(gdb) n
882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\
: nil,
set_quotes looks like a promising subroutine. We can go into it by using the command s
(step) instead of next. step goes to the next line to be executed in any subroutine, so it
steps into set_quotes.
(gdb) s
set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
at input.c:530
530 if (lquote != def_lquote)
The display that shows the subroutine where m4 is now suspended (and its arguments) is
called a stack frame display. It shows a summary of the stack. We can use the backtrace
command (which can also be spelled bt), to see where we are in the stack as a whole: the
backtrace command displays a stack frame for each active subroutine.
(gdb) bt
#0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
at input.c:530
#1 0x6344 in m4_changequote (argc=3, argv=0x33c70)
at builtin.c:882
#2 0x8174 in expand_macro (sym=0x33320) at macro.c:242
#3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
at macro.c:71
#4 0x79dc in expand_input () at macro.c:40
#5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
We step through a few more lines to see what happens. The first two times, we can use ‘s’;
the next two times we use n to avoid falling into the xstrdup subroutine.
(gdb) s
0x3b5c 532 if (rquote != def_rquote)
(gdb) s
0x3b80 535 lquote = (lq == nil || *lq == ’\0’) ? \
def_lquote : xstrdup(lq);
(gdb) n
536 rquote = (rq == nil || *rq == ’\0’) ? def_rquote\
: xstrdup(rq);
(gdb) n
538 len_lquote = strlen(rquote);
Chapter 1: A Sample gdb Session 9

The last line displayed looks a little odd; we can examine the variables lquote and rquote
to see if they are in fact the new left and right quotes we specified. We use the command
p (print) to see their values.
(gdb) p lquote
$1 = 0x35d40 "<QUOTE>"
(gdb) p rquote
$2 = 0x35d50 "<UNQUOTE>"

lquote and rquote are indeed the new left and right quotes. To look at some context, we
can display ten lines of source surrounding the current line with the l (list) command.
(gdb) l
533 xfree(rquote);
534
535 lquote = (lq == nil || *lq == ’\0’) ? def_lquote\
: xstrdup (lq);
536 rquote = (rq == nil || *rq == ’\0’) ? def_rquote\
: xstrdup (rq);
537
538 len_lquote = strlen(rquote);
539 len_rquote = strlen(lquote);
540 }
541
542 void

Let us step past the two lines that set len_lquote and len_rquote, and then examine the
values of those variables.
(gdb) n
539 len_rquote = strlen(lquote);
(gdb) n
540 }
(gdb) p len lquote
$3 = 9
(gdb) p len rquote
$4 = 7

That certainly looks wrong, assuming len_lquote and len_rquote are meant to be the
lengths of lquote and rquote respectively. We can set them to better values using the p
command, since it can print the value of any expression—and that expression can include
subroutine calls and assignments.
(gdb) p len lquote=strlen(lquote)
$5 = 7
(gdb) p len rquote=strlen(rquote)
$6 = 9

Is that enough to fix the problem of using the new quotes with the m4 built-in defn? We can
allow m4 to continue executing with the c (continue) command, and then try the example
that caused trouble initially:
(gdb) c
Continuing.

define(baz,defn(<QUOTE>foo<UNQUOTE>))

baz
0000
10 Debugging with gdb

Success! The new quotes now work just as well as the default ones. The problem seems to
have been just the two typos defining the wrong lengths. We allow m4 exit by giving it an
EOF as input:
Ctrl-d
Program exited normally.
The message ‘Program exited normally.’ is from gdb; it indicates m4 has finished execut-
ing. We can end our gdb session with the gdb quit command.
(gdb) quit
Chapter 2: Getting In and Out of gdb 11

2 Getting In and Out of gdb


This chapter discusses how to start gdb, and how to get out of it. The essentials are:
• type ‘gdb’ to start gdb.
• type quit or Ctrl-d to exit.

2.1 Invoking gdb


Invoke gdb by running the program gdb. Once started, gdb reads commands from the
terminal until you tell it to exit.
You can also run gdb with a variety of arguments and options, to specify more of your
debugging environment at the outset.
The command-line options described here are designed to cover a variety of situations;
in some environments, some of these options may effectively be unavailable.
The most usual way to start gdb is with one argument, specifying an executable program:
gdb program
You can also start with both an executable program and a core file specified:
gdb program core
You can, instead, specify a process ID as a second argument, if you want to debug a
running process:
gdb program 1234
would attach gdb to process 1234 (unless you also have a file named ‘1234’; gdb does check
for a core file first).
Taking advantage of the second command-line argument requires a fairly complete op-
erating system; when you use gdb as a remote debugger attached to a bare board, there
may not be any notion of “process”, and there is often no way to get a core dump. gdb
will warn you if it is unable to attach or to read core dumps.
You can optionally have gdb pass any arguments after the executable file to the inferior
using --args. This option stops option processing.
gdb --args gcc -O2 -c foo.c
This will cause gdb to debug gcc, and to set gcc’s command-line arguments (see
Section 4.3 [Arguments], page 28) to ‘-O2 -c foo.c’.
You can run gdb without printing the front material, which describes gdb’s
non-warranty, by specifying -silent:
gdb -silent
You can further control how gdb starts up by using command-line options. gdb itself can
remind you of the options available.
Type
gdb -help
to display all available options and briefly describe their use (‘gdb -h’ is a shorter equiva-
lent).
All options and command line arguments you give are processed in sequential order. The
order makes a difference when the ‘-x’ option is used.
12 Debugging with gdb

2.1.1 Choosing Files


When gdb starts, it reads any arguments other than options as specifying an executable
file and core file (or process ID). This is the same as if the arguments were specified by the
‘-se’ and ‘-c’ (or ‘-p’) options respectively. (gdb reads the first argument that does not
have an associated option flag as equivalent to the ‘-se’ option followed by that argument;
and the second argument that does not have an associated option flag, if any, as equivalent
to the ‘-c’/‘-p’ option followed by that argument.) If the second argument begins with a
decimal digit, gdb will first attempt to attach to it as a process, and if that fails, attempt
to open it as a corefile. If you have a corefile whose name begins with a digit, you can
prevent gdb from treating it as a pid by prefixing it with ‘./’, e.g. ‘./12345’.
If gdb has not been configured to included core file support, such as for most embedded
targets, then it will complain about a second argument and ignore it.
Many options have both long and short forms; both are shown in the following list. gdb
also recognizes the long forms if you truncate them, so long as enough of the option is
present to be unambiguous. (If you prefer, you can flag option arguments with ‘--’ rather
than ‘-’, though we illustrate the more usual convention.)

-symbols file
-s file Read symbol table from file file.

-exec file
-e file Use file file as the executable file to execute when appropriate, and for examining
pure data in conjunction with a core dump.

-se file Read symbol table from file file and use it as the executable file.

-core file
-c file Use file file as a core dump to examine.

-pid number
-p number
Connect to process ID number, as with the attach command.

-command file
-x file Execute commands from file file. The contents of this file is evaluated exactly
as the source command would. See Section 23.1.3 [Command files], page 258.

-eval-command command
-ex command
Execute a single gdb command.
This option may be used multiple times to call multiple commands. It may also
be interleaved with ‘-command’ as required.
gdb -ex ’target sim’ -ex ’load’ \
-x setbreakpoints -ex ’run’ a.out

-directory directory
-d directory
Add directory to the path to search for source and script files.
Chapter 2: Getting In and Out of gdb 13

-r
-readnow Read each symbol file’s entire symbol table immediately, rather than the default,
which is to read it incrementally as it is needed. This makes startup slower,
but makes future operations faster.

2.1.2 Choosing Modes


You can run gdb in various alternative modes—for example, in batch mode or quiet mode.
-nx
-n Do not execute commands found in any initialization files. Normally, gdb exe-
cutes the commands in these files after all the command options and arguments
have been processed. See Section 23.1.3 [Command Files], page 258.
-quiet
-silent
-q “Quiet”. Do not print the introductory and copyright messages. These mes-
sages are also suppressed in batch mode.
-batch Run in batch mode. Exit with status 0 after processing all the command files
specified with ‘-x’ (and all commands from initialization files, if not inhibited
with ‘-n’). Exit with nonzero status if an error occurs in executing the gdb
commands in the command files.
Batch mode may be useful for running gdb as a filter, for example to download
and run a program on another computer; in order to make this more useful, the
message
Program exited normally.
(which is ordinarily issued whenever a program running under gdb control
terminates) is not issued when running in batch mode.
-batch-silent
Run in batch mode exactly like ‘-batch’, but totally silently. All gdb output to
stdout is prevented (stderr is unaffected). This is much quieter than ‘-silent’
and would be useless for an interactive session.
This is particularly useful when using targets that give ‘Loading section’ mes-
sages, for example.
Note that targets that give their output via gdb, as opposed to writing directly
to stdout, will also be made silent.
-return-child-result
The return code from gdb will be the return code from the child process (the
process being debugged), with the following exceptions:
• gdb exits abnormally. E.g., due to an incorrect argument or an internal
error. In this case the exit code is the same as it would have been without
‘-return-child-result’.
• The user quits with an explicit value. E.g., ‘quit 1’.
• The child process never runs, or is not allowed to terminate, in which case
the exit code will be -1.
14 Debugging with gdb

This option is useful in conjunction with ‘-batch’ or ‘-batch-silent’, when


gdb is being used as a remote program loader or simulator interface.
-nowindows
-nw “No windows”. If gdb comes with a graphical user interface (GUI) built in,
then this option tells gdb to only use the command-line interface. If no GUI is
available, this option has no effect.
-windows
-w If gdb includes a GUI, then this option requires it to be used if possible.
-cd directory
Run gdb using directory as its working directory, instead of the current direc-
tory.
-fullname
-f gnu Emacs sets this option when it runs gdb as a subprocess. It tells gdb to
output the full file name and line number in a standard, recognizable fashion
each time a stack frame is displayed (which includes each time your program
stops). This recognizable format looks like two ‘\032’ characters, followed by
the file name, line number and character position separated by colons, and a
newline. The Emacs-to-gdb interface program uses the two ‘\032’ characters
as a signal to display the source code for the frame.
-epoch The Epoch Emacs-gdb interface sets this option when it runs gdb as a subpro-
cess. It tells gdb to modify its print routines so as to allow Epoch to display
values of expressions in a separate window.
-annotate level
This option sets the annotation level inside gdb. Its effect is identical to using
‘set annotate level ’ (see Chapter 28 [Annotations], page 355). The annota-
tion level controls how much information gdb prints together with its prompt,
values of expressions, source lines, and other types of output. Level 0 is the
normal, level 1 is for use when gdb is run as a subprocess of gnu Emacs, level
3 is the maximum annotation suitable for programs that control gdb, and level
2 has been deprecated.
The annotation mechanism has largely been superseded by gdb/mi (see
Chapter 27 [GDB/MI], page 289).
--args Change interpretation of command line so that arguments following the exe-
cutable file are passed as command line arguments to the inferior. This option
stops option processing.
-baud bps
-b bps Set the line speed (baud rate or bits per second) of any serial interface used by
gdb for remote debugging.
-l timeout
Set the timeout (in seconds) of any communication used by gdb for remote
debugging.
Chapter 2: Getting In and Out of gdb 15

-tty device
-t device
Run using device for your program’s standard input and output.
-tui Activate the Text User Interface when starting. The Text User Interface man-
ages several text windows on the terminal, showing source, assembly, regis-
ters and gdb command outputs (see Chapter 25 [gdb Text User Interface],
page 281). Alternatively, the Text User Interface can be enabled by invoking
the program ‘gdbtui’. Do not use this option if you run gdb from Emacs (see
Chapter 26 [Using gdb under gnu Emacs], page 287).
-interpreter interp
Use the interpreter interp for interface with the controlling program or device.
This option is meant to be set by programs which communicate with gdb using
it as a back end. See Chapter 24 [Command Interpreters], page 279.
‘--interpreter=mi’ (or ‘--interpreter=mi2’) causes gdb to use the gdb/mi
interface (see Chapter 27 [The gdb/mi Interface], page 289) included since gdb
version 6.0. The previous gdb/mi interface, included in gdb version 5.3 and
selected with ‘--interpreter=mi1’, is deprecated. Earlier gdb/mi interfaces
are no longer supported.
-write Open the executable and core files for both reading and writing. This is equiv-
alent to the ‘set write on’ command inside gdb (see Section 17.6 [Patching],
page 185).
-statistics
This option causes gdb to print statistics about time and memory usage after
it completes each command and returns to the prompt.
-version This option causes gdb to print its version number and no-warranty blurb, and
exit.

2.1.3 What gdb Does During Startup


Here’s the description of what gdb does during session startup:
1. Sets up the command interpreter as specified by the command line (see Section 2.1.2
[Mode Options], page 13).
2. Reads the system-wide init file (if ‘--with-system-gdbinit’ was used when building
gdb; see Section B.6 [System-wide configuration and settings], page 395) and executes
all the commands in that file.
3. Reads the init file (if any) in your home directory1 and executes all the commands in
that file.
4. Processes command line options and operands.
5. Reads and executes the commands from init file (if any) in the current working direc-
tory. This is only done if the current directory is different from your home directory.
Thus, you can have more than one init file, one generic in your home directory, and
another, specific to the program you are debugging, in the directory where you invoke
gdb.
1
On DOS/Windows systems, the home directory is the one pointed to by the HOME environment variable.
16 Debugging with gdb

6. Reads command files specified by the ‘-x’ option. See Section 23.1.3 [Command Files],
page 258, for more details about gdb command files.
7. Reads the command history recorded in the history file. See Section 22.3 [Command
History], page 245, for more details about the command history and the files where
gdb records it.
Init files use the same syntax as command files (see Section 23.1.3 [Command Files],
page 258) and are processed by gdb in the same way. The init file in your home directory
can set options (such as ‘set complaints’) that affect subsequent processing of command
line options and operands. Init files are not executed if you use the ‘-nx’ option (see
Section 2.1.2 [Choosing Modes], page 13).
To display the list of init files loaded by gdb at startup, you can use gdb --help.
The gdb init files are normally called ‘.gdbinit’. The DJGPP port of gdb uses the
name ‘gdb.ini’, due to the limitations of file names imposed by DOS filesystems. The
Windows ports of gdb use the standard name, but if they find a ‘gdb.ini’ file, they warn
you about that and suggest to rename the file to the standard name.

2.2 Quitting gdb


quit [expression ]
q To exit gdb, use the quit command (abbreviated q), or type an end-of-file
character (usually Ctrl-d). If you do not supply expression, gdb will terminate
normally; otherwise it will terminate using the result of expression as the error
code.
An interrupt (often Ctrl-c) does not exit from gdb, but rather terminates the action
of any gdb command that is in progress and returns to gdb command level. It is safe to
type the interrupt character at any time because gdb does not allow it to take effect until
a time when it is safe.
If you have been using gdb to control an attached process or device, you can release
it with the detach command (see Section 4.7 [Debugging an Already-running Process],
page 31).

2.3 Shell Commands


If you need to execute occasional shell commands during your debugging session, there is
no need to leave or suspend gdb; you can just use the shell command.
shell command string
Invoke a standard shell to execute command string. If it exists, the environment
variable SHELL determines which shell to run. Otherwise gdb uses the default
shell (‘/bin/sh’ on Unix systems, ‘COMMAND.COM’ on MS-DOS, etc.).
The utility make is often needed in development environments. You do not have to use
the shell command for this purpose in gdb:
make make-args
Execute the make program with the specified arguments. This is equivalent to
‘shell make make-args ’.
Chapter 2: Getting In and Out of gdb 17

2.4 Logging Output


You may want to save the output of gdb commands to a file. There are several commands
to control gdb’s logging.
set logging on
Enable logging.
set logging off
Disable logging.
set logging file file
Change the name of the current logfile. The default logfile is ‘gdb.txt’.
set logging overwrite [on|off]
By default, gdb will append to the logfile. Set overwrite if you want set
logging on to overwrite the logfile instead.
set logging redirect [on|off]
By default, gdb output will go to both the terminal and the logfile. Set
redirect if you want output to go only to the log file.
show logging
Show the current values of the logging settings.
Chapter 3: gdb Commands 19

3 gdb Commands
You can abbreviate a gdb command to the first few letters of the command name, if that
abbreviation is unambiguous; and you can repeat certain gdb commands by typing just
RET. You can also use the TAB key to get gdb to fill out the rest of a word in a command
(or to show you the alternatives available, if there is more than one possibility).

3.1 Command Syntax


A gdb command is a single line of input. There is no limit on how long it can be. It
starts with a command name, which is followed by arguments whose meaning depends on
the command name. For example, the command step accepts an argument which is the
number of times to step, as in ‘step 5’. You can also use the step command with no
arguments. Some commands do not allow any arguments.
gdb command names may always be truncated if that abbreviation is unambiguous.
Other possible command abbreviations are listed in the documentation for individual com-
mands. In some cases, even ambiguous abbreviations are allowed; for example, s is specially
defined as equivalent to step even though there are other commands whose names start
with s. You can test abbreviations by using them as arguments to the help command.
A blank line as input to gdb (typing just RET) means to repeat the previous command.
Certain commands (for example, run) will not repeat this way; these are commands whose
unintentional repetition might cause trouble and which you are unlikely to want to repeat.
User-defined commands can disable this feature; see Section 23.1.1 [Define], page 255.
The list and x commands, when you repeat them with RET, construct new arguments
rather than repeating exactly as typed. This permits easy scanning of source or memory.
gdb can also use RET in another way: to partition lengthy output, in a way similar to
the common utility more (see Section 22.4 [Screen Size], page 247). Since it is easy to press
one RET too many in this situation, gdb disables command repetition after any command
that generates this sort of display.
Any text from a # to the end of the line is a comment; it does nothing. This is useful
mainly in command files (see Section 23.1.3 [Command Files], page 258).
The Ctrl-o binding is useful for repeating a complex sequence of commands. This
command accepts the current line, like RET, and then fetches the next line relative to the
current line from the history for editing.

3.2 Command Completion


gdb can fill in the rest of a word in a command for you, if there is only one possibility;
it can also show you what the valid possibilities are for the next word in a command, at
any time. This works for gdb commands, gdb subcommands, and the names of symbols
in your program.
Press the TAB key whenever you want gdb to fill out the rest of a word. If there is only
one possibility, gdb fills in the word, and waits for you to finish the command (or press
RET to enter it). For example, if you type
(gdb) info bre TAB
gdb fills in the rest of the word ‘breakpoints’, since that is the only info subcommand
beginning with ‘bre’:
20 Debugging with gdb

(gdb) info breakpoints


You can either press RET at this point, to run the info breakpoints command, or
backspace and enter something else, if ‘breakpoints’ does not look like the command you
expected. (If you were sure you wanted info breakpoints in the first place, you might as
well just type RET immediately after ‘info bre’, to exploit command abbreviations rather
than command completion).
If there is more than one possibility for the next word when you press TAB, gdb sounds
a bell. You can either supply more characters and try again, or just press TAB a second
time; gdb displays all the possible completions for that word. For example, you might want
to set a breakpoint on a subroutine whose name begins with ‘make_’, but when you type b
make_TAB gdb just sounds the bell. Typing TAB again displays all the function names in
your program that begin with those characters, for example:
(gdb) b make_ TAB
gdb sounds bell; press TAB again, to see:
make_a_section_from_file make_environ
make_abs_section make_function_type
make_blockvector make_pointer_type
make_cleanup make_reference_type
make_command make_symbol_completion_list
(gdb) b make_
After displaying the available possibilities, gdb copies your partial input (‘b make_’ in the
example) so you can finish the command.
If you just want to see the list of alternatives in the first place, you can press M-? rather
than pressing TAB twice. M-? means META ?. You can type this either by holding down a
key designated as the META shift on your keyboard (if there is one) while typing ?, or as
ESC followed by ?.
Sometimes the string you need, while logically a “word”, may contain parentheses or
other characters that gdb normally excludes from its notion of a word. To permit word
completion to work in this situation, you may enclose words in ’ (single quote marks) in
gdb commands.
The most likely situation where you might need this is in typing the name of a C++
function. This is because C++ allows function overloading (multiple definitions of the same
function, distinguished by argument type). For example, when you want to set a breakpoint
you may need to distinguish whether you mean the version of name that takes an int
parameter, name(int), or the version that takes a float parameter, name(float). To use
the word-completion facilities in this situation, type a single quote ’ at the beginning of the
function name. This alerts gdb that it may need to consider more information than usual
when you press TAB or M-? to request word completion:
(gdb) b ’bubble( M-?
bubble(double,double) bubble(int,int)
(gdb) b ’bubble(
In some cases, gdb can tell that completing a name requires using quotes. When this
happens, gdb inserts the quote for you (while completing as much as it can) if you do not
type the quote in the first place:
(gdb) b bub TAB
gdb alters your input line to the following, and rings a bell:
(gdb) b ’bubble(
Chapter 3: gdb Commands 21

In general, gdb can tell that a quote is needed (and inserts it) if you have not yet started
typing the argument list when you ask for completion on an overloaded symbol.
For more information about overloaded functions, see Section 15.4.1.3 [C++ Expressions],
page 154. You can use the command set overload-resolution off to disable overload
resolution; see Section 15.4.1.7 [gdb Features for C++], page 156.
When completing in an expression which looks up a field in a structure, gdb also tries1
to limit completions to the field names available in the type of the left-hand-side:
(gdb) p gdb_stdout.M-?
magic to_delete to_fputs to_put to_rewind
to_data to_flush to_isatty to_read to_write
This is because the gdb_stdout is a variable of the type struct ui_file that is defined in
gdb sources as follows:
struct ui_file
{
int *magic;
ui_file_flush_ftype *to_flush;
ui_file_write_ftype *to_write;
ui_file_fputs_ftype *to_fputs;
ui_file_read_ftype *to_read;
ui_file_delete_ftype *to_delete;
ui_file_isatty_ftype *to_isatty;
ui_file_rewind_ftype *to_rewind;
ui_file_put_ftype *to_put;
void *to_data;
}

3.3 Getting Help


You can always ask gdb itself for information on its commands, using the command help.
help
h You can use help (abbreviated h) with no arguments to display a short list of
named classes of commands:
(gdb) help
List of classes of commands:

aliases -- Aliases of other commands


breakpoints -- Making program stop at certain points
data -- Examining data
files -- Specifying and examining files
internals -- Maintenance commands
obscure -- Obscure features
running -- Running the program
stack -- Examining the stack
status -- Status inquiries
support -- Support facilities
tracepoints -- Tracing of program execution without
stopping the program
user-defined -- User-defined commands

Type "help" followed by a class name for a list of

1
The completer can be confused by certain kinds of invalid expressions. Also, it only examines the static
type of the expression, not the dynamic type.
22 Debugging with gdb

commands in that class.


Type "help" followed by command name for full
documentation.
Command name abbreviations are allowed if unambiguous.
(gdb)

help class
Using one of the general help classes as an argument, you can get a list of the
individual commands in that class. For example, here is the help display for
the class status:
(gdb) help status
Status inquiries.

List of commands:

info -- Generic command for showing things


about the program being debugged
show -- Generic command for showing things
about the debugger

Type "help" followed by command name for full


documentation.
Command name abbreviations are allowed if unambiguous.
(gdb)

help command
With a command name as help argument, gdb displays a short paragraph on
how to use that command.
apropos args
The apropos command searches through all of the gdb commands, and their
documentation, for the regular expression specified in args. It prints out all
matches found. For example:
apropos reload
results in:
set symbol-reloading -- Set dynamic symbol table reloading
multiple times in one run
show symbol-reloading -- Show dynamic symbol table reloading
multiple times in one run

complete args
The complete args command lists all the possible completions for the begin-
ning of a command. Use args to specify the beginning of the command you
want completed. For example:
complete i
results in:
if
ignore
info
inspect
This is intended for use by gnu Emacs.
In addition to help, you can use the gdb commands info and show to inquire about
the state of your program, or the state of gdb itself. Each command supports many topics
Chapter 3: gdb Commands 23

of inquiry; this manual introduces each of them in the appropriate context. The listings
under info and under show in the Index point to all the sub-commands. See [GDB Index],
page 497.
info This command (abbreviated i) is for describing the state of your program. For
example, you can show the arguments passed to a function with info args,
list the registers currently in use with info registers, or list the breakpoints
you have set with info breakpoints. You can get a complete list of the info
sub-commands with help info.
set You can assign the result of an expression to an environment variable with set.
For example, you can set the gdb prompt to a $-sign with set prompt $.
show In contrast to info, show is for describing the state of gdb itself. You can
change most of the things you can show, by using the related command set;
for example, you can control what number system is used for displays with set
radix, or simply inquire which is currently in use with show radix.
To display all the settable parameters and their current values, you can use
show with no arguments; you may also use info set. Both commands produce
the same display.
Here are three miscellaneous show subcommands, all of which are exceptional in lacking
corresponding set commands:
show version
Show what version of gdb is running. You should include this information in
gdb bug-reports. If multiple versions of gdb are in use at your site, you may
need to determine which version of gdb you are running; as gdb evolves, new
commands are introduced, and old ones may wither away. Also, many system
vendors ship variant versions of gdb, and there are variant versions of gdb in
gnu/Linux distributions as well. The version number is the same as the one
announced when you start gdb.
show copying
info copying
Display information about permission for copying gdb.
show warranty
info warranty
Display the gnu “NO WARRANTY” statement, or a warranty, if your version
of gdb comes with one.
Chapter 4: Running Programs Under gdb 25

4 Running Programs Under gdb


When you run a program under gdb, you must first generate debugging information when
you compile it.
You may start gdb with its arguments, if any, in an environment of your choice. If you
are doing native debugging, you may redirect your program’s input and output, debug an
already running process, or kill a child process.

4.1 Compiling for Debugging


In order to debug a program effectively, you need to generate debugging information when
you compile it. This debugging information is stored in the object file; it describes the data
type of each variable or function and the correspondence between source line numbers and
addresses in the executable code.
To request debugging information, specify the ‘-g’ option when you run the compiler.
Programs that are to be shipped to your customers are compiled with optimizations,
using the ‘-O’ compiler option. However, some compilers are unable to handle the ‘-g’ and
‘-O’ options together. Using those compilers, you cannot generate optimized executables
containing debugging information.
gcc, the gnu C/C++ compiler, supports ‘-g’ with or without ‘-O’, making it possible
to debug optimized code. We recommend that you always use ‘-g’ whenever you compile
a program. You may think your program is correct, but there is no sense in pushing your
luck. For more information, see Chapter 11 [Optimized Code], page 123.
Older versions of the gnu C compiler permitted a variant option ‘-gg’ for debugging
information. gdb no longer supports this format; if your gnu C compiler has this option,
do not use it.
gdb knows about preprocessor macros and can show you their expansion (see Chapter 12
[Macros], page 125). Most compilers do not include information about preprocessor macros
in the debugging information if you specify the ‘-g’ flag alone, because this information is
rather large. Version 3.1 and later of gcc, the gnu C compiler, provides macro information
if you specify the options ‘-gdwarf-2’ and ‘-g3’; the former option requests debugging
information in the Dwarf 2 format, and the latter requests “extra information”. In the
future, we hope to find more compact ways to represent macro information, so that it can
be included with ‘-g’ alone.

4.2 Starting your Program


run
r Use the run command to start your program under gdb. You must first spec-
ify the program name (except on VxWorks) with an argument to gdb (see
Chapter 2 [Getting In and Out of gdb], page 11), or by using the file or
exec-file command (see Section 18.1 [Commands to Specify Files], page 187).
If you are running your program in an execution environment that supports processes,
run creates an inferior process and makes that process run your program. In some envi-
ronments without processes, run jumps to the start of your program. Other targets, like
‘remote’, are always running. If you get an error message like this one:
Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of How much
Bolshevism is there in America?
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: How much Bolshevism is there in America?


Also a series of articles entitled "Russia from the
inside"

Author: Arno Dosch-Fleurot


Hector J. Boon

Release date: May 12, 2024 [eBook #73613]

Language: English

Original publication: New York: The World, 1921

Credits: Richard Tonsing, Brian Wilson, Bryan Ness, and the


Online Distributed Proofreading Team at
https://www.pgdp.net (This file was produced from
images generously made available by The Internet
Archive/American Libraries.)

*** START OF THE PROJECT GUTENBERG EBOOK HOW MUCH


BOLSHEVISM IS THERE IN AMERICA? ***
Transcriber’s Note:
New original cover art included with this eBook is
granted to the public domain.
How Much Bolshevism Is There in

America?

By ARNO DOSCH-FLEUROT
(World European Staff Correspondent)

Who Has Lived for Years Under the Bolsheviki in Russia and Has
Just Completed a Tour Over the United States Studying Social
Unrest

The Dosch-Fleurot Articles Appeared in The World Jan. 16, 17, 18, 19, 20.

Also a Series of Articles Entitled:

“Russia From the Inside”


By HECTOR BOON.
A New York Business Man, Recently Returned From a Long Stay and
Extensive Travel in Russia

Published by
New York, January, 1921

The Hector Boon Articles Appeared in The World Jan. 9, 10, 11, 12, 13, 14.
COPYRIGHT, 1921,
PRESS PUBLISHING CO.
(NEW YORK WORLD)
EDITOR’S NOTE:

Mr. Dosch-Fleurot travelled about the country to see how


much Bolshevism he could find. He has been trying to
determine how much effect the social revolution in Europe has
had upon America. Returning to New York, he has written five
articles:
In No. 1 he contrasts the industrial situation in this rich
country to the war-impoverished countries of Europe.
In No. 2 he tells how much Bolshevism he found and how
much he did not find.
In No. 3 he gives a new picture of what the industrial
unrest in America is and explains the efforts to organize labor
industrially instead of in trades.
No. 4 goes into the question of industrial peace and how it
can be reached by “industrial councils.”
No. 5 shows how the farmers’ organizations are succeeding
in doing what the “proletariat” has not been able to do in the
way of organizing industrial unions.


ARNO DOSCH-FLEUROT

Mr. Dosch-Fleurot needs no introduction to the American


public. He may be called an expert on Bolshevism, as he was the
only American correspondent in Petrograd when the revolution
broke out in March, 1917, against the Imperial Government. He
remained throughout the Lenine-Trotzky revolution until the
dictatorship of the proletariat was firmly established in the fall
of 1918. In addition to this remarkable experience, he reported
for The World the first vital six months of the German
revolution, when the Spartacists attempted repeatedly to upset
the Ebert-Noske Government. His careful and faithful studies of
social conditions abroad during the period of the war, travelling
in Russia, Germany, Austria, Hungary, Roumania, Czecho-
Slovakia, Poland, Greece, the Scandinavian countries, Belgium,
France and Great Britain, have been features of The World’s
news for the past two years.
Mr. Dosch-Fleurot recently has been appointed The
World’s chief correspondent for Germany and Central Europe,
with headquarters in Berlin. His despatches will be regular
features of The World.

AMERICA’S WAR-BORN WEALTH
INSURANCE AGAINST SPREAD OF
BOLSHEVIST TAINT HERE

Study of Conditions in Various Sections of the United States, From


the Point of View of Europe, Convinces Arno Dosch-Fleurot
That Same Problems of Unrest Do Not Affect Our Workmen
and Ground Is Not Fertile for Insurrection—Prosperity of
Workingmen Cause for Thanksgiving Rather Than Complaint.

The biggest questions in industrial, social, political and


economic life in America are:
Is Bolshevism finding root here?
Is America facing a political revolution?
Are we tainted by the vast social unrest now so
characteristic of England, of all Europe, as well as Asia?
What impulses common to those countries are to be
found in our labor structure?
In an effort to throw light an these vital matters, The World
brought Arno Dosch-Fleurot back from Europe, where he has been
the last four years, to make an investigation. The results of his
extensive inquiry, covering the past three months, during which he
has visited those centres of activity from which he could best obtain
first hand information, are set forth in five articles.

By Arno Dosch-Fleurot.
Copyright, 1921, by the Press Publishing Co. (The New York World).
For the past three years I have been living in the midst of the
social revolution in Europe. A great deal of it has been active
revolution, with the machine guns in the streets. During this time I
have often wondered how much of this unrest was being
communicated to America or how much we were developing here on
our own account.
Looking at America from the point of view of Europe,
particularly Eastern Europe, I have wanted to know—
First—How the Bolshevik revolution in Russia
affected America.
Second—Whether the class war into which the World
War developed had hit America too.
Third—How the United States was readjusting itself
to the inevitable social changes.
At the time the Bolsheviki seized the power in Russia, we
Americans who were there used to say to one another as we
discussed the industrial and social problems that faced the world, “At
home we are going to work this thing out another way.”

Are We Working Out the Problems in Another Way?

For several weeks I have been able to search for the answers to
my own questions. I have been going about the United States
studying the social and industrial unrest. To some of my questions I
have answers which are satisfactory, at least to myself. Behind others
I must still leave interrogation points. In addition I have seen things
I had not thought of, some of them tranquilizing, others disquieting.
In this and the succeeding articles I shall give my impressions of
the unrest in America and its significance from my point of view.
In the first place, I am overwhelmed by our wealth. I
had been away long enough to forget how rich we were, and
we have in the mean while grown much richer. That fact is
of prime importance. Being rich, there is not the gruelling
struggle for existence that makes the problems of unrest in
Europe dangerous. It eases off enormously on whatever
strain there might otherwise be.
Everywhere I turn, in every city, every street, every shop, every
home, there is so much wealth it is hard to believe. After Europe one
would be inclined to say we are disgustingly rich, if the new-wealth,
in spite of the war fortunes, were not so widely distributed. I hear
people complain that workmen have been making so much money
they have been buying themselves $10 silk shirts and their wives are
wearing $50 hats.
It does not seem to me a cause for complaint. Rather it would
appear to be cause for thanksgiving that such things can be. I have
myself seen factory workmen, men who make their living
with their hands, men who belong to unions, going to work
in their own automobiles. I should like to tell that to some
workmen of my acquaintance in Moscow.

Wealth Obscures Depression.

Even though the country is going through an industrial


depression there is so much money about that a casual traveller
would not know it.
In Detroit, where 150,000 factory workmen have been laid off, it
is interesting to see how little difference it has made in the daily life
of this city of a million. Half the families in the city are affected, but
they have money and go on spending it. I could not believe so many
people could be out of work without evident sign of suffering
somewhere, but I spent half a day unsuccessfully trying to find a
soup kitchen or a bread line in Detroit.
Yes, we are rich, and that has spared us much. But with wealth
have come pride and intolerance. I was in a measure prepared for
this, but I did not expect to find it generally accepted as right and
proper.
George Russell, the Irish writer, said to me just before I came
home: “War is an exchange of characteristics. You have been fighting
Prussians. You may find America full of Prussianism.”
I should have thought our sense of liberty were proof against
contamination, but apparently not. As the first sign of Prussianism
we seem to have curtailed free speech. In a dozen cities where I have
been a man need only get on a soap-box and he will land in jail. The
corner orators who used to act as safety valves for over-heated brains
don’t dare show themselves. Men have gone to jail for reading
sections from the Declaration of Independence. I admit they did it
with mocking or malicious intent, but what of it? Since when, has the
democracy of America grown so weak it needs policemen to protect
it? In the West a man need only carry an I. W. W. card in his pocket
to get arrested. They say in Seattle, “The Red Squad has driven the
cards into the shoes.” There are 3,000 “Reds” in jail for various
causes. The most important ones are serving long prison sentences.
There seems to be a common impression that the Imprisonment
of “Reds” is suppressing Bolshevism in the United States. My
observations lead me to the belief the only chance of
revolution, and that not immediate, might come from
continuing to keep these men in prison. Those who are under
prison sentence were convicted under the extraordinary conditions
developed by war. These extraordinary conditions no longer exist,
but these men are still under sentence. The longer they stay in
prison the stronger grows the resentment at their
imprisonment. I find an undercurrent of bitterness, not
very wide but deep, that can breed trouble. The small
minority that is thinking about revolution is thinking about it hard. If
these so-called revolutionists were turned loose without further ado,
under a general amnesty, it would ease off on that hard thinking and
would be helpful to the liberal movement in industry that is trying to
“work this thing out another way.”
The same spirit in the country which is backing the red squads
of the police seems to be actuating a Nation-wide, open-shop
campaign. Men with any liberalism at all—and there are liberals
managing great industries—are not in favor of either. They do not
want the closed shop, but the ruthless way many employers’
associations and groups of associated industries are trying to use the
present reaction as well as the existing depression to “break the back
of labor” is regarded by them as the madness of power and wealth.
I find only two groups of rebels against democracy who view
with favor this knock-down-and-drag-out fight for the open shop. I
might call them roughly Bolshevik employers and Bolshevik
employees.
As I travelled about the country I found that the active advocates
of the open shop frequently referred to it as “the American plan.” The
employers’ association which is pushing it also has a way of
ostentatiously flying the Stars and Stripes. This is particularly
noticeable in the mining communities where there are large bodies of
foreign laborers. At first I could not understand how one group of
Americans came to have the temerity to arrogate to themselves the
word “American.” Then I discovered it was a survival of the war
period. In fighting the Prussian we have adopted some of the
Prussian’s disagreeable characteristics. The war is over, but we have
licked militarist blood. What surprises me most is how few people
recognize the danger of it. The phrase “American plan” has been
allowed to stand without protest, though it practically says to union
men who are just as good Americans as the members of employers’
associations that they are not Americans if they persist in their union
ideas. It is not difficult to imagine how this is misused in the daily
contact between workman and boss. It cannot help but do harm.
In Butte I was walking along the street with some labor leaders,
bound for their headquarters. Thinking we had reached it, I started
to turn into a building over which the Stars and Stripes were flying.
“That’s not it,” said one of them. “Don’t you see the flag of the
American plan?”

No Serious Bolshevism Here.

And yet there is no serious Bolshevism in the United


States, I have been looking for it, and I have not been able
to trace a consistent effort at a Bolshevik movement. There
are no doubt enough people who believe in Bolshevism
who would like to start a Bolshevik movement—but they
have not been able to do it. At least they have not succeeded
in starting it among wage-paid workmen, and there is no
other place to start it.
There is, however, something which is called Bolshevism, and,
as it is also rebellious against the existing order of society, it has been
labelled Bolshevik, but it is really something different. I refer to the
rather crude and unscientific but active, anarcho-syndicalism of the
Industrial Workers of the World.
The two have been confused even by some of the leaders of the I.
W. W., so it is not surprising that the general public, not to mention
the Red squads of the police, have not always been able to make the
distinction; but the difference is there and is of sufficient importance
to prevent the growth of Bolshevism.
Bolshevism, by which is ment the idea that lies behind the
Bolshevik Government in Moscow, is a long way from the One Big
Union—the effective idea behind the I. W. W. Bolshevism has proved
to be state Socialism in action. The I. W. W. is anarcho-syndicalism
trying to make headway in industry.
But even the I. W. W. is not getting anywhere. It may
some day, because it has a broader philosophy than
Bolshevism behind it and because it is aiding in the
movement toward industrial unionism, which is making
some headway. But as an immediate revolutionary
movement the I. W. W. is powerless before the powerful
forces that oppose it.
Chief of these is the American Federation of Labor. The
I. W. W. has never even had a chance to play a serious role
in the United States because the A. F. of L. has fought it
consistently since its inception fifteen years ago.
Industrial unionism, when revolutionary in purpose, even when
developed apart from the I. W. W., has met the same opposition. If
there had been no system of craft unionism in this country there
might have been industrial unionism in this country long ago.
Certainly the I. W. W. would have had a much freer hand. In that
case the employers of the United States would, like the employers of
Europe, have been faced with labor syndicates instead of labor
unions, and that is a very different story.
In Europe labor leaders look upon the American Federation of
Labor as almost a part of the capitalist system. Rumors that the big
American industrials were trying to break the power of the A. F. of L.
had come to Europe before I left and it could hardly be credited. The
syndicalist labor leaders could not understand why the American
manufacturers were fighting their ally.
Since I have been travelling about the United States I have also
found many employers of labor who can also not understand why
there is this vicious open-shop campaign. The industrial manager of
one of the greatest industries in the world said to me hotly:
“If Judge Gary and Wall Street knew what they were
leading to they would stop this anti-union campaign. They
are trying to break down the conservative American
Federation of Labor. If they succeed in destroying the
power of Gompers they will remove the only barrier that
stands between us and a real revolutionary labor
movement, industrial unionism.”
Just how revolutionary industrial unionism is I shall examine
later on, but it is certainly much more revolutionary than the A. F. of
L. And as the craft unions of the A. F. of L. find it increasingly harder
to breathe under the smothering process that is going on under the
“American plan,” the industrial unions find a freer field to work in.
The revolutionists of America, such as they are, could ask nothing
better than the carrying of the open-shop campaign to its most
ruthless finish.
Right now the enemies of union labor of any kind can do about
what they please. There are plenty of men looking for work and they
can break almost any strike that might be declared. Union men and I.
W. W. leaders alike are sitting tight and are trying to save what they
can to go on with when the fight is over. They are not afraid of being
done in forever. They know this period of depression will pass, and,
even if meanwhile the open-shop campaign were carried to the point
where every union in the country were killed off, the union
movement would spring up again. Next time, however, they believe it
might take the more revolutionary form of industrial unionism.
LITTLE OF BOLSHEVISM FOUND IN I. W.
W., MOST RADICAL OF AMERICAN LABOR
MOVEMENTS

By Arno Dosch-Fleurot.
Copyright, 1921, by the Press Publishing Co. (The New York World).
The most radical labor movement in the United States, the one
that makes the most to-do over its revolutionary programme, is the I.
W. W. Whatever there may be of revolutionary tendency in America
is in the I. W. W., or closely affiliated. But looking at America
from the point of view of Europe, if that is all we have
produced in the way of revolutionary material we are
certainly in no immediate danger of becoming a “Soviet
republic.”
The I. W. W. is popularly considered Bolshevik, and has thus
been advertised by the attacks the police have made upon it. There
have also been “criminal Syndicalist” laws passed against it which
have enhanced its importance. But an examination of what it is does
not give cause for serious alarm.
The I. W. W. has never been able to boast of much of a
membership, and it has barely enough members now to keep it alive.
During the past few weeks I have taken a fairly close look at the I. W.
W., or what I could find of it, and I should say it is more of a purpose,
more of a labor philosophy, than a movement. It is out for One Big
Union, but it has not even one small union that stays put.

Provided Organization of Labor Where No Other Union


Could

It has provided a chance for organization when there was no


other union to do it. It went into the woods and the harvest fields and
organized the migratory workers. It had a free and easy way of
organizing, and they were free and easy men. In the woods it
acquired some permanency. The loggers of Oregon, Washington and
Idaho are about the only active members it has. The important
consideration is how much revolution did it instil into them?
According to my observations, very little.
The loggers were told about the preamble of the I. W. W., the
theme of which lies in its first words: “The working class and the
employing class have nothing in common.” With those sentiments
the loggers were in hearty accord. They knew better than the I. W. W.
organizers how true it was in the woods. They wanted better camp
conditions. The I. W. W. gave them a chance for organized protest, so
they joined. They are frontiersmen with the virtues of the frontier;
they stand by their friends. So they stand by the I. W. W. But to say
they become class-conscious revolutionists is absurd.
The leadership at the I. W. W. has syndicalist purpose, but its
membership is merely looking for better working conditions. The
average man who joins the I. W. W. would as willingly join a union
that had less to say about revolution if it were there. The I. W. W.,
like the Salvation Army, works where more bourgeois organizations
fail. At the I. W. W. headquarters in Chicago is turned out a varied
supply of I. W. W. reading matter, but you do not see workers
pouring over it. They glance at occasional pamphlets, but they do not
bother themselves with the anarcho-syndicalist theories. Some few
harvest workers have tried sabotage, and that is about the most
serious charge against the I. W. W.

No Consistent Idea.

Out of the scores of leaflets and pamphlets they can get no


consistent revolutionary idea. They are a confusion of syndicalism,
anarchy, Socialism, Communism and Bolshevism. That is inevitable,
as the writers, not always very thoroughly informed, have tried to
adapt their individual conceptions of the various social revolutionary
movements in Europe to American conditions. The I. W. W., being
the one outstanding revolutionary movement, has drawn to it so
many different types of revolutionists they have mutually destroyed
each other’s theories.
The Bolshevists in the I. W. W. have recently had a serious jolt.
They tried, without success, to induce the loggers to support the
Third Internationale, the propaganda body of the Bolshevik
Government in Moscow. They told the loggers that, as part of the
proletariat, they should give their indorsement to the dictatorship of
the proletariat and the organization of the world revolution from
Moscow.
The loggers are not very long on political ideas, but they wanted
to know about it first. So the editor of the Northwest Industrial
Worker, one of the I. W. W.’s most important publications, explained
it. He is himself a syndicalist and no Bolshevist. Moreover, he lives in
Seattle and knows the loggers are not to be turned into rubber stamp
revolutionists by the propaganda of the Lenine-Zinovieff school. So
in the Northwest Industrial Worker for Oct. 20 he printed the
following editorial:

‘What about the Russian Workers:’

“A vote for the indorsement of the Third Internationale by the


members of the Industrial Workers of the World means a vote
indorsing the actions of the small political group which now holds
Russia under its rule, the Communist Party. There should be no
doubt in the minds of members as to that fact. If the vote for
indorsement carries, members should realize that we shall have
indorsed a political state that is not only upheld by bayonets but
which has sent conquering armies to invade other countries.
“It is unfortunate that members of the I. W. W. have never
received any accurate information as to the actual condition of the
workers of Russia. We have heard many generalizations as to the
conditions of the Russian people, singing the praises of the Soviet
Government. But have members of the I. W. W. ever heard a report
made by industrial unionists or by syndicalists containing reliable
information upon the following matter?”

Questions Are Asked.


“Are the workers of Russia permitted by the Government to
organize upon their own lines without interference?
“Are the workers of Russia permitted to freely travel through the
interior looking for employment?
“What percentage of the workers in the large industrial sections
are organized, and upon what basis?
“Are workers permitted to maintain their own press without
governmental interference?
“Until the members of the I. W. W. have information upon these
and many other matters they are voting in the dark upon something
of which they know nothing. They have a right to know whether
Soviet Russia is a ‘working-class government.’ Communist Party
propaganda will not afford satisfactory answers to these queries.
“We are endeavoring to get enlightenment upon such matters at
first hand, and have already secured some information, but we
realize that we have no right to influence, or attempt to influence, the
vote upon a referendum which is pending. We want the truth about
affairs in Russia. We are interested in the Russian workers more
than we are interested in anything pertaining to that country.”

Absurdity of Label.

I have reproduced this editorial in full partly to show the


absurdity of simply labelling the I. W. W. movement Bolshevik and
letting it go at that. Also, I have never seen an abler editorial against
Bolshevism. And this, mind you, was published in the most
important organ of the I. W. W.
There were people in the I. W. W. movement who did not like it,
and they brought pressure to bear to remove the editor, J. C. Kane,
from his editorial chair. But the loggers read the editorial and liked
it. They would probably never have read it if there had not been a
fuss raised; but, at any rate, they did read it, and approved. Then
they heard that the editor had been fired and they got a little “mass
action” into play and put him back. And they did not indorse the
Third Internationale.
That is a long way from Bolshevism. Nothing like that could
happen in Russia. As an incident it is symptomatic. It shows the
members of the movement insist on running it according to their
individual will. In other words it is not a Bolshevik movement
directed by a highly centralized labor autocracy. It is rather
an anarcho-syndicalist movement bossed from the “job.”

Is “Job-Controlled.”

The Bolshevik-minded within the I. W. W. do not really belong


there. The I. W. W. happens to be the most radical band wagon and
they have climbed on. Incidents such as I have just quoted show
them where they get off. The men who understand better the I. W.
W. movement know it must be based on “job control.” Every time it
has ever done anything it has been a case of “job control”—in other
words, the men on the job decided what they were going to do. Their
successful strikes in the woods the summer of 1917 were, for
instance, declared in the camps.
In the I. W. W. dogmatic concepts do not get far. Revolutionary
phrases take on new meanings and disconcert their originators. The
phrase “direct action,” for example, is well understood in the
revolutionary patter to mean direct revolutionary action to put a
workers’ dictatorship into governmental power. But it does not mean
that in the logging camps. It means direct action by the camp crew
and not action according to the decision of the I. W. W.
headquarters.

Are Fundamental Democrats.

Fundamentally the I. W. W. members are democrats like the rest


of us. They have no far political vision, and they wish to ameliorate
the condition in life of workingmen, but they could be trusted in the
final analysis not to follow any doctrinaire revolutionist who had
thought it all out for them and told them to come along. Lenine could
do that with the Russian workers. But no one could do it with
American workers. And the membership of the I. W. W., particularly
in the woods, is largely American.
The I. W. W. has its ups and downs, and just now it is down. But
it will not go out of existence and disappear because it stands for an
idea, industrial unionism. There are other labor organizations, such
as the Automobile Workers, which also stand for industrial
unionism, but the I. W. W. has proclaimed it loudest, though it has
perhaps done less effective organizing than some of the others.
Industrial unionism is essentially inimical to the craft unionism
upon which the American Federation of Labor is built. The
individual unions in the A. F. of L. could unite along industrial lines,
and some have, but the results have not been sufficiently striking to
remove from the I. W. W. further excuse for existence.

Not Essentially Revolutionary.

There is nothing essentially revolutionary in industrial


unionism, though the I. W. W. tries to make it so, concluding its well
known preamble with the sentence: “By organizing industrially we
are forming the structure of the new society within the shell of the
old.” But that is largely rhetoric. In the body of the preamble is
written: “We find that the centring of the management of industries
into fewer and fewer hands makes the trade unions unable to cope
with the ever-growing power of the employing class.” All industrial
unionists are of this point of view. Their position was well described
to me by William A. Logan, President of the Automobile Workers,
who is not a member of the I. W. W.
“Industrial unionism is no one’s invention,” he said. “It naturally
follows the combination of manufacturers in an industry.
Manufacturers absorb industries which furnish them, so labor does
the same thing. The combinations of industries in large plants has so
highly specialized the work that no one workman need be a rounded
mechanic. Men can also be shifted easily from one machine to
another. Common and semi-skilled labor has almost entirely taken
the place of skilled labor in industry. I used to be an auto-fitter.
There is now no such job. The manufacture of even such a finished
article as an automobile has been specialized to a point where one
man need know very little. He may have merely to start a nut. So all
the men in the industry are on the same footing. There is no longer
point in splitting them into crafts. The logical way to organize them
is industrially.”

Merely New to United States.

That is all there is to industrial unionism. It is comparatively


new to America, but it is an old story in Europe. To organize
industrially is just as democratic as to organize by crafts. It all
depends upon what is done with the organization once it is formed.
Industrial unionism only becomes revolutionarily syndicalistic when
a union of industrial unions announces it is going to take over the
Government in the name of its syndicalist workers.
The I. W. W. says, “The army of production must be organized
not only for the everyday struggle with capitalists but also to carry on
production when capitalism shall have been overthrown.”
The less revolutionary automobile workers, whose correct title is
United Automobile, Aircraft and Vehicle Workers of America, say
more conservatively: “We know that the workers will never know
how to manage the State if they should gain that responsibility
through political action, until they learn how to act collectively in
getting some of their immediate needs satisfied.”

Nothing to Fear.

The I. W. W. foresees the uniting of all the different industrial


unions in one big union. It says, “One union—one label—one enemy.”
The automobile workers say more modestly, “One union, one
industry.”
So the industrial union may, or may not, be used with
revolutionary intent. Of itself it is nothing to be afraid of.
Practically industrial unionism has between it and success what
even the comparatively mild automobile workers refer to as the
power of “Czar Gompers and his Grand Dukes.”
Theoretically the A. F. of L. is not opposed to industrial
unionism. Any of the crafts may join forces. But practically the A. F.
of L. machine prevents it.
“PROLETARIAT OF AMERICA” JUST GOES
AND GETS JOB, WORLD INVESTIGATOR
FINDS
By Arno Dosch-Fleurot.
Copyright, 1921, by the Press Publishing Co. (The New York World).
At Akron, O., where the rubber industry swelled to enormous
proportions in the last few years, business dropped like a skyrocket
recently and there were reports of tens of thousands of men thrown
out of work. So I went to Akron to see how great were the sufferings
of the “proletariat.”
Here, at least, I thought I should find a mass of unskilled labor
and a proletarian class consciousness such as I have been in the habit
of associating with big industry in Europe.
I found Akron pretty well shut down, but there was no
proletariat about. There were no bread lines, no soup kitchens. Still
there was no question but that there were some 50,000 fewer men
working in the small city than there had been a short time before.
Where were they?
They had gone home. They had acquired no stake in Akron.
Most of them were from West Virginia. They were migratory
workers, and when they were not wanted conveniently disappeared.
They went to other towns, other industries, back to the land. Broadly
they were a migratory class, but they had no consciousness of class.
To-day they were seeking the highest pay in the factories, to-morrow
they will be tilling the soil. To a would-be proletarian leader they
must be exasperatingly elusive.
I found the manufacturers of Akron deeply grateful to them.
They came when they were wanted and took themselves away when
they were no longer wanted. Without them it would have been
impossible to build industries so rapidly to meet the demands of a
day, and if they did not take themselves off when the slump came
they would create a disagreeable responsibility for the manufacturer
who got them together. It is a situation that is purely American and
would leave bewildered any one who tried to fix European ideas of
industrial organization upon American institutions.

No Upheaval When Labor Turnover Makes Jobs Vacant

At the plant of the Goodyear Tire and Rubber Company in Akron


I was told that the plant had been reduced from 30,000 men to
6,000 men in less than six months without turning men off
wholesale. The labor turnover did the trick. The plant stopped taking
on new men several months ago, when it began to look as if the
strong demand for tires was not going to hold. Each week thereafter
some of the migratory workers left. Normally they would have been
replaced by new migratory workers who presented themselves for
jobs, but in this way each week the payroll decreased automatically.
Week after week the usual number of men called for their time and
struck out, some because it was summer and their native mountains
called them, some to wander further afield into other industrial
towns. This went on all summer and fall and when, in November, it
became necessary, the management thought, to curtail production
sharply there were only 14,000 instead of 30,000 in the plant. The
rest had disappeared in the normal labor turnover. In the other
rubber plants in Akron the same process went on, so it was not a case
of turning tens of thousands of men into the streets when the real
slump came.
Much the same thing happened in Detroit. Last year it had more
than 100,000 more people than it could properly house. These
people had been drawn into Detroit by the high wages. Handy men
with intelligence were getting $15 to $30 and more a day. Then came
the slump in the automobile market. Beginning last May, the
demand for labor in Detroit began to decrease, factories took on
fewer men, but the city did not become crowded with idle men. For a
certain number took their time each week and moved on. The
overpopulation began to disappear. Detroit as a working man’s
bonanza was working out. Coming eastward in November from the
Pacific Coast, I encountered everywhere men with a few hundred
dollars in their pockets, “easy money,” made in Detroit, looking now
for something else. By the time I reached Detroit I found the
factories had 150,000 less workmen than they had four months
before and there was no idle “proletariat” standing about.

Not Possible in Europe.

It is only in wonderfully rich America such things can happen.


Here alone we dare organize industry on this bonanza scale. In
Europe the big industrials know that if they build in this rapid
fashion they must be prepared for the slump. The soil will not
reabsorb the migratory workers as it has done for Akron and Detroit.
In Europe the workers belong to a proletariat divorced from the soil,
descendants of a long line of workmen. They are also class conscious
and they do not conveniently disappear in the labor turnover.
Thanks to the different state of affairs in America the present
readjustment in the country is going on with little difficulty from the
side of labor. In Europe, where there is a process of social revolution,
there can be no thought of a readjustment of any kind without first
finding out what effect it is going to have on the working classes. But
here there is no proletariat, no hard and fast working classes, hence
no class consciousness.
I have found recently in my travels about the country that all
kinds of people are agreed that prices, rents, wages, everything must
come down to somewhere near what they were. Before talking to
labor leaders I find the same reasonableness. This would be
impossible if there were any sentiment for class war.
Now is the time to test how much of the social turmoil in Europe
has been communicated to us. Flush times are passing and whatever
discontent there is is sure to show itself. I may be looking for
something too precise, but I do not find it. There is the usual
discontent over the struggle for existence, but it is not class
conscious, as the phrase is used in revolutionary circles abroad. The
situation has not even increased the following of the I. W. W. or of
the industrial union movement. It would seem like a propitious
moment to make a drive, a campaign of instruction, in the effort to
convince workmen that industrial unionism is their way to economic
freedom. But I see very small signs of such activity.
In Eastern Europe in its present frame of mind a readjustment
could not take place without workmen seizing rifles and machine
guns and making armed demands. Such doings are not in the
American picture.

Workers Are Not Organized.

One reason may be that the portion of the working classes most
hit is not organized. Craft unionism has not kept pace with the
growth of industry. The important centres of diversified industry, as
well as what the Germans call the heavy industries, are not
unionized. In the Pittsburgh district there are approximately
400,000 workmen and whatever organization exists among them is
too small to count. No big manufacturing centre in America is now
union. Chicago, for instance, is industrially open shop. So is Detroit
or any other city where industry has had rapid growth. It amused me
in asking about the open-shop movement to see the eagerness with
which I always was informed that the open-shop principle had
always maintained in whatever community I might be asking about.
The truth is, of course, that the big industries have been able to
prevent unionizing by keeping a steady flow of immigrants coming
into the country and they were clever enough to take them from the
farms in Europe, so they did not bring any class consciousness with
them. Ever since the famous Homestead strikes the steel industry
has been non-union. It was only when the flow of immigrants was
dammed by the war that a chance to unionize it came. It was then
that John Fitzpatrick and William Z. Foster began. But they tried out
organizing industrially first in the Chicago stockyards, and the steel
manufacturers watched them from afar, so, as one steel man said to
me in Pittsburgh, “We saw them coming and we were ready for
them.”
What struck me as an interesting comment on the unionizing of
factory workers was made to me in Detroit by Mr. C. M. Culver,
director of the Employers’ Association, an institution which handles
the labor problem for its members. He said:
“When employers do not combine to hold down wages,
unionism does not grow. When employers are competing for
workmen, as they have been doing here in Detroit, when they are too
busy turning out machines, when the inventive minds are just boiling
and the native American genius is concentrated on getting results,
men do not join unions.”
Unionism certainly made very little headway in Detroit. The A.
F. of L. played a very small role there and the automobile workers
had succeeded in enrolling less than one-twentieth of the men who
were eligible to this industrial union. It is significant, however, that
the automobile workers, even with their small membership, have
their importance in the industry, and the manufacturers consider
their growth alone a possible menace. It shows the power that would
pass into the hands of the factory worker if industrial unionism ever
gets a hold on American industry.
In Detroit the percentage of foreign or foreign-born among the
workers is about 70 per cent. In Pittsburgh it is even higher.
Manufacturers in both places say they do not fear labor organization
as long as this percentage persists. Labor organizations built among
the foreign workers do not last. They can be organized quickly, as
William Z. Foster found when he organized the steel strike in 1919.
They give their money freely and enthusiastically for organization,
but they expect quick results and do not stand up under adversity. I
have just passed through the steel region in Ohio and Pittsburgh
where Foster organized most successfully a year ago and there is
hardly a trace of his work to be found. With difficulty I found the
emaciated skeletons of the flourishing unions Foster developed in a
few months.
After visiting the steel towns and the modern factory cities I
agree with the I. W. W. that American industry is not organized.
Labor, as distinguished from industry, is organized, but the factories,
with their hundreds of thousands—added together, their millions—of
unskilled and semi-skilled labor, are quite unorganized. The A. F. of
L. has not interested itself in them, and the I. W. W. has tried to do it
on so pretentiously revolutionary a scale that it has not succeeded.
The field is open. The American field of industry is practically
unhampered by the prejudices or the hard conditions of Europe. The
European-trained agitators have sown the American industrial field
time and again with their European-born ideas, but they have not
yielded a crop.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like