Debugging with gdb 9th Edition Richard Stallman All Chapters Instant Download
Debugging with gdb 9th Edition Richard Stallman All Chapters Instant Download
Debugging with gdb 9th Edition Richard Stallman All Chapters Instant Download
https://ebookfinal.com
https://ebookfinal.com/download/debugging-with-
gdb-9th-edition-richard-stallman/
https://ebookfinal.com/download/debugging-with-gdb-v8-3-1-10th-
edition-richard-stallman/
ebookfinal.com
https://ebookfinal.com/download/texas-politics-9th-edition-richard-h-
kraemer/
ebookfinal.com
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
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
https://ebookfinal.com/download/social-work-with-groups-a-
comprehensive-worktext-9th-edition-edition-charles-zastrow/
ebookfinal.com
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
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
3 gdb Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.1 Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.2 Command Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
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
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
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.
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
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) 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>)
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
-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.
-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.
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.
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).
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;
}
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
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:
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
Language: English
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.
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:
❧
ARNO DOSCH-FLEUROT
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.”
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.
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.
No Consistent Idea.
Absurdity of Label.
Is “Job-Controlled.”
Nothing to Fear.
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.
ebookfinal.com