(Machine Code): Document possible problems with locations in
[deliverable/binutils-gdb.git] / gdb / doc / gdb.texinfo
CommitLineData
c906108c 1\input texinfo @c -*-texinfo-*-
b6ba6518 2@c Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
7d51c7de 3@c 1999, 2000, 2001, 2002, 2003, 2004, 2005
c906108c
SS
4@c Free Software Foundation, Inc.
5@c
5d161b24 6@c %**start of header
c906108c
SS
7@c makeinfo ignores cmds prev to setfilename, so its arg cannot make use
8@c of @set vars. However, you can override filename with makeinfo -o.
9@setfilename gdb.info
10@c
11@include gdb-cfg.texi
12@c
c906108c 13@settitle Debugging with @value{GDBN}
c906108c
SS
14@setchapternewpage odd
15@c %**end of header
16
17@iftex
18@c @smallbook
19@c @cropmarks
20@end iftex
21
22@finalout
23@syncodeindex ky cp
24
41afff9a 25@c readline appendices use @vindex, @findex and @ftable,
48e934c6 26@c annotate.texi and gdbmi use @findex.
c906108c 27@syncodeindex vr cp
41afff9a 28@syncodeindex fn cp
c906108c
SS
29
30@c !!set GDB manual's edition---not the same as GDB version!
9fe8321b 31@c This is updated by GNU Press.
e9c75b65 32@set EDITION Ninth
c906108c 33
87885426
FN
34@c !!set GDB edit command default editor
35@set EDITOR /bin/ex
c906108c 36
6c0e9fb3 37@c THIS MANUAL REQUIRES TEXINFO 4.0 OR LATER.
c906108c 38
c906108c 39@c This is a dir.info fragment to support semi-automated addition of
6d2ebf8b 40@c manuals to an info tree.
03727ca6 41@dircategory Software development
96a2c332 42@direntry
03727ca6 43* Gdb: (gdb). The GNU debugger.
96a2c332
SS
44@end direntry
45
c906108c
SS
46@ifinfo
47This file documents the @sc{gnu} debugger @value{GDBN}.
48
49
9fe8321b
AC
50This is the @value{EDITION} Edition, of @cite{Debugging with
51@value{GDBN}: the @sc{gnu} Source-Level Debugger} for @value{GDBN}
52Version @value{GDBVN}.
c906108c 53
8a037dd7 54Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,@*
7d51c7de
BR
55 1999, 2000, 2001, 2002, 2003, 2004, 2005@*
56 Free Software Foundation, Inc.
c906108c 57
e9c75b65
EZ
58Permission is granted to copy, distribute and/or modify this document
59under the terms of the GNU Free Documentation License, Version 1.1 or
60any later version published by the Free Software Foundation; with the
959acfd1
EZ
61Invariant Sections being ``Free Software'' and ``Free Software Needs
62Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
63and with the Back-Cover Texts as in (a) below.
c906108c 64
6826cf00
EZ
65(a) The Free Software Foundation's Back-Cover Text is: ``You have
66freedom to copy and modify this GNU Manual, like GNU software. Copies
67published by the Free Software Foundation raise funds for GNU
68development.''
c906108c
SS
69@end ifinfo
70
71@titlepage
72@title Debugging with @value{GDBN}
73@subtitle The @sc{gnu} Source-Level Debugger
c906108c 74@sp 1
c906108c 75@subtitle @value{EDITION} Edition, for @value{GDBN} version @value{GDBVN}
9e9c5ae7 76@author Richard Stallman, Roland Pesch, Stan Shebs, et al.
c906108c 77@page
c906108c
SS
78@tex
79{\parskip=0pt
53a5351d 80\hfill (Send bugs and comments on @value{GDBN} to bug-gdb\@gnu.org.)\par
c906108c
SS
81\hfill {\it Debugging with @value{GDBN}}\par
82\hfill \TeX{}info \texinfoversion\par
83}
84@end tex
53a5351d 85
c906108c 86@vskip 0pt plus 1filll
8a037dd7 87Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
7d51c7de
BR
881996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
89Free Software Foundation, Inc.
c906108c 90@sp 2
c906108c
SS
91Published by the Free Software Foundation @*
9259 Temple Place - Suite 330, @*
93Boston, MA 02111-1307 USA @*
6d2ebf8b 94ISBN 1-882114-77-9 @*
e9c75b65
EZ
95
96Permission is granted to copy, distribute and/or modify this document
97under the terms of the GNU Free Documentation License, Version 1.1 or
98any later version published by the Free Software Foundation; with the
959acfd1
EZ
99Invariant Sections being ``Free Software'' and ``Free Software Needs
100Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
101and with the Back-Cover Texts as in (a) below.
e9c75b65 102
6826cf00
EZ
103(a) The Free Software Foundation's Back-Cover Text is: ``You have
104freedom to copy and modify this GNU Manual, like GNU software. Copies
105published by the Free Software Foundation raise funds for GNU
106development.''
c906108c
SS
107@end titlepage
108@page
109
6c0e9fb3 110@ifnottex
6d2ebf8b
SS
111@node Top, Summary, (dir), (dir)
112
c906108c
SS
113@top Debugging with @value{GDBN}
114
115This file describes @value{GDBN}, the @sc{gnu} symbolic debugger.
116
9fe8321b 117This is the @value{EDITION} Edition, for @value{GDBN} Version
c906108c
SS
118@value{GDBVN}.
119
7d51c7de 120Copyright (C) 1988-2005 Free Software Foundation, Inc.
6d2ebf8b
SS
121
122@menu
123* Summary:: Summary of @value{GDBN}
124* Sample Session:: A sample @value{GDBN} session
125
126* Invocation:: Getting in and out of @value{GDBN}
127* Commands:: @value{GDBN} commands
128* Running:: Running programs under @value{GDBN}
129* Stopping:: Stopping and continuing
130* Stack:: Examining the stack
131* Source:: Examining source files
132* Data:: Examining data
e2e0bcd1 133* Macros:: Preprocessor Macros
b37052ae 134* Tracepoints:: Debugging remote targets non-intrusively
df0cd8c5 135* Overlays:: Debugging programs that use overlays
6d2ebf8b
SS
136
137* Languages:: Using @value{GDBN} with different languages
138
139* Symbols:: Examining the symbol table
140* Altering:: Altering execution
141* GDB Files:: @value{GDBN} files
142* Targets:: Specifying a debugging target
6b2f586d 143* Remote Debugging:: Debugging remote programs
6d2ebf8b
SS
144* Configurations:: Configuration-specific information
145* Controlling GDB:: Controlling @value{GDBN}
146* Sequences:: Canned sequences of commands
c4555f82 147* TUI:: @value{GDBN} Text User Interface
21c294e6 148* Interpreters:: Command Interpreters
6d2ebf8b
SS
149* Emacs:: Using @value{GDBN} under @sc{gnu} Emacs
150* Annotations:: @value{GDBN}'s annotation interface.
7162c0ca 151* GDB/MI:: @value{GDBN}'s Machine Interface.
6d2ebf8b
SS
152
153* GDB Bugs:: Reporting bugs in @value{GDBN}
154* Formatting Documentation:: How to format and print @value{GDBN} documentation
155
156* Command Line Editing:: Command Line Editing
157* Using History Interactively:: Using History Interactively
158* Installing GDB:: Installing GDB
eb12ee30 159* Maintenance Commands:: Maintenance Commands
e0ce93ac 160* Remote Protocol:: GDB Remote Serial Protocol
f418dd93 161* Agent Expressions:: The GDB Agent Expression Mechanism
aab4e0ec
AC
162* Copying:: GNU General Public License says
163 how you can copy and share GDB
6826cf00 164* GNU Free Documentation License:: The license for this documentation
6d2ebf8b
SS
165* Index:: Index
166@end menu
167
6c0e9fb3 168@end ifnottex
c906108c 169
449f3b6c 170@contents
449f3b6c 171
6d2ebf8b 172@node Summary
c906108c
SS
173@unnumbered Summary of @value{GDBN}
174
175The purpose of a debugger such as @value{GDBN} is to allow you to see what is
176going on ``inside'' another program while it executes---or what another
177program was doing at the moment it crashed.
178
179@value{GDBN} can do four main kinds of things (plus other things in support of
180these) to help you catch bugs in the act:
181
182@itemize @bullet
183@item
184Start your program, specifying anything that might affect its behavior.
185
186@item
187Make your program stop on specified conditions.
188
189@item
190Examine what has happened, when your program has stopped.
191
192@item
193Change things in your program, so you can experiment with correcting the
194effects of one bug and go on to learn about another.
195@end itemize
196
49efadf5 197You can use @value{GDBN} to debug programs written in C and C@t{++}.
9c16f35a 198For more information, see @ref{Supported languages,,Supported languages}.
c906108c
SS
199For more information, see @ref{C,,C and C++}.
200
cce74817 201@cindex Modula-2
e632838e
AC
202Support for Modula-2 is partial. For information on Modula-2, see
203@ref{Modula-2,,Modula-2}.
c906108c 204
cce74817
JM
205@cindex Pascal
206Debugging Pascal programs which use sets, subranges, file variables, or
207nested functions does not currently work. @value{GDBN} does not support
208entering expressions, printing values, or similar features using Pascal
209syntax.
c906108c 210
c906108c
SS
211@cindex Fortran
212@value{GDBN} can be used to debug programs written in Fortran, although
53a5351d 213it may be necessary to refer to some variables with a trailing
cce74817 214underscore.
c906108c 215
b37303ee
AF
216@value{GDBN} can be used to debug programs written in Objective-C,
217using either the Apple/NeXT or the GNU Objective-C runtime.
218
c906108c
SS
219@menu
220* Free Software:: Freely redistributable software
221* Contributors:: Contributors to GDB
222@end menu
223
6d2ebf8b 224@node Free Software
c906108c
SS
225@unnumberedsec Free software
226
5d161b24 227@value{GDBN} is @dfn{free software}, protected by the @sc{gnu}
c906108c
SS
228General Public License
229(GPL). The GPL gives you the freedom to copy or adapt a licensed
230program---but every person getting a copy also gets with it the
231freedom to modify that copy (which means that they must get access to
232the source code), and the freedom to distribute further copies.
233Typical software companies use copyrights to limit your freedoms; the
234Free Software Foundation uses the GPL to preserve these freedoms.
235
236Fundamentally, the General Public License is a license which says that
237you have these freedoms and that you cannot take these freedoms away
238from anyone else.
239
2666264b 240@unnumberedsec Free Software Needs Free Documentation
959acfd1
EZ
241
242The biggest deficiency in the free software community today is not in
243the software---it is the lack of good free documentation that we can
244include with the free software. Many of our most important
245programs do not come with free reference manuals and free introductory
246texts. Documentation is an essential part of any software package;
247when an important free software package does not come with a free
248manual and a free tutorial, that is a major gap. We have many such
249gaps today.
250
251Consider Perl, for instance. The tutorial manuals that people
252normally use are non-free. How did this come about? Because the
253authors of those manuals published them with restrictive terms---no
254copying, no modification, source files not available---which exclude
255them from the free software world.
256
257That wasn't the first time this sort of thing happened, and it was far
258from the last. Many times we have heard a GNU user eagerly describe a
259manual that he is writing, his intended contribution to the community,
260only to learn that he had ruined everything by signing a publication
261contract to make it non-free.
262
263Free documentation, like free software, is a matter of freedom, not
264price. The problem with the non-free manual is not that publishers
265charge a price for printed copies---that in itself is fine. (The Free
266Software Foundation sells printed copies of manuals, too.) The
267problem is the restrictions on the use of the manual. Free manuals
268are available in source code form, and give you permission to copy and
269modify. Non-free manuals do not allow this.
270
271The criteria of freedom for a free manual are roughly the same as for
272free software. Redistribution (including the normal kinds of
273commercial redistribution) must be permitted, so that the manual can
274accompany every copy of the program, both on-line and on paper.
275
276Permission for modification of the technical content is crucial too.
277When people modify the software, adding or changing features, if they
278are conscientious they will change the manual too---so they can
279provide accurate and clear documentation for the modified program. A
280manual that leaves you no choice but to write a new manual to document
281a changed version of the program is not really available to our
282community.
283
284Some kinds of limits on the way modification is handled are
285acceptable. For example, requirements to preserve the original
286author's copyright notice, the distribution terms, or the list of
287authors, are ok. It is also no problem to require modified versions
288to include notice that they were modified. Even entire sections that
289may not be deleted or changed are acceptable, as long as they deal
290with nontechnical topics (like this one). These kinds of restrictions
291are acceptable because they don't obstruct the community's normal use
292of the manual.
293
294However, it must be possible to modify all the @emph{technical}
295content of the manual, and then distribute the result in all the usual
296media, through all the usual channels. Otherwise, the restrictions
297obstruct the use of the manual, it is not free, and we need another
298manual to replace it.
299
300Please spread the word about this issue. Our community continues to
301lose manuals to proprietary publishing. If we spread the word that
302free software needs free reference manuals and free tutorials, perhaps
303the next person who wants to contribute by writing documentation will
304realize, before it is too late, that only free manuals contribute to
305the free software community.
306
307If you are writing documentation, please insist on publishing it under
308the GNU Free Documentation License or another free documentation
309license. Remember that this decision requires your approval---you
310don't have to let the publisher decide. Some commercial publishers
311will use a free license if you insist, but they will not propose the
312option; it is up to you to raise the issue and say firmly that this is
313what you want. If the publisher you are dealing with refuses, please
314try other publishers. If you're not sure whether a proposed license
42584a72 315is free, write to @email{licensing@@gnu.org}.
959acfd1
EZ
316
317You can encourage commercial publishers to sell more free, copylefted
318manuals and tutorials by buying them, and particularly by buying
319copies from the publishers that paid for their writing or for major
320improvements. Meanwhile, try to avoid buying non-free documentation
321at all. Check the distribution terms of a manual before you buy it,
322and insist that whoever seeks your business must respect your freedom.
72c9928d
EZ
323Check the history of the book, and try to reward the publishers that
324have paid or pay the authors to work on it.
959acfd1
EZ
325
326The Free Software Foundation maintains a list of free documentation
327published by other publishers, at
328@url{http://www.fsf.org/doc/other-free-books.html}.
329
6d2ebf8b 330@node Contributors
96a2c332
SS
331@unnumberedsec Contributors to @value{GDBN}
332
333Richard Stallman was the original author of @value{GDBN}, and of many
334other @sc{gnu} programs. Many others have contributed to its
335development. This section attempts to credit major contributors. One
336of the virtues of free software is that everyone is free to contribute
337to it; with regret, we cannot actually acknowledge everyone here. The
338file @file{ChangeLog} in the @value{GDBN} distribution approximates a
c906108c
SS
339blow-by-blow account.
340
341Changes much prior to version 2.0 are lost in the mists of time.
342
343@quotation
344@emph{Plea:} Additions to this section are particularly welcome. If you
345or your friends (or enemies, to be evenhanded) have been unfairly
346omitted from this list, we would like to add your names!
347@end quotation
348
349So that they may not regard their many labors as thankless, we
350particularly thank those who shepherded @value{GDBN} through major
351releases:
faae5abe 352Andrew Cagney (releases 6.1, 6.0, 5.3, 5.2, 5.1 and 5.0);
c906108c
SS
353Jim Blandy (release 4.18);
354Jason Molenda (release 4.17);
355Stan Shebs (release 4.14);
356Fred Fish (releases 4.16, 4.15, 4.13, 4.12, 4.11, 4.10, and 4.9);
357Stu Grossman and John Gilmore (releases 4.8, 4.7, 4.6, 4.5, and 4.4);
358John Gilmore (releases 4.3, 4.2, 4.1, 4.0, and 3.9);
359Jim Kingdon (releases 3.5, 3.4, and 3.3);
360and Randy Smith (releases 3.2, 3.1, and 3.0).
361
362Richard Stallman, assisted at various times by Peter TerMaat, Chris
363Hanson, and Richard Mlynarik, handled releases through 2.8.
364
b37052ae
EZ
365Michael Tiemann is the author of most of the @sc{gnu} C@t{++} support
366in @value{GDBN}, with significant additional contributions from Per
367Bothner and Daniel Berlin. James Clark wrote the @sc{gnu} C@t{++}
368demangler. Early work on C@t{++} was by Peter TerMaat (who also did
369much general update work leading to release 3.0).
c906108c 370
b37052ae 371@value{GDBN} uses the BFD subroutine library to examine multiple
c906108c
SS
372object-file formats; BFD was a joint project of David V.
373Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.
374
375David Johnson wrote the original COFF support; Pace Willison did
376the original support for encapsulated COFF.
377
0179ffac 378Brent Benson of Harris Computer Systems contributed DWARF 2 support.
c906108c
SS
379
380Adam de Boor and Bradley Davis contributed the ISI Optimum V support.
381Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS
382support.
383Jean-Daniel Fekete contributed Sun 386i support.
384Chris Hanson improved the HP9000 support.
385Noboyuki Hikichi and Tomoyuki Hasei contributed Sony/News OS 3 support.
386David Johnson contributed Encore Umax support.
387Jyrki Kuoppala contributed Altos 3068 support.
388Jeff Law contributed HP PA and SOM support.
389Keith Packard contributed NS32K support.
390Doug Rabson contributed Acorn Risc Machine support.
391Bob Rusk contributed Harris Nighthawk CX-UX support.
392Chris Smith contributed Convex support (and Fortran debugging).
393Jonathan Stone contributed Pyramid support.
394Michael Tiemann contributed SPARC support.
395Tim Tucker contributed support for the Gould NP1 and Gould Powernode.
396Pace Willison contributed Intel 386 support.
397Jay Vosburgh contributed Symmetry support.
a37295f9 398Marko Mlinar contributed OpenRISC 1000 support.
c906108c 399
1104b9e7 400Andreas Schwab contributed M68K @sc{gnu}/Linux support.
c906108c
SS
401
402Rich Schaefer and Peter Schauer helped with support of SunOS shared
403libraries.
404
405Jay Fenlason and Roland McGrath ensured that @value{GDBN} and GAS agree
406about several machine instruction sets.
407
408Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped develop
409remote debugging. Intel Corporation, Wind River Systems, AMD, and ARM
410contributed remote debugging modules for the i960, VxWorks, A29K UDI,
411and RDI targets, respectively.
412
413Brian Fox is the author of the readline libraries providing
414command-line editing and command history.
415
7a292a7a
SS
416Andrew Beers of SUNY Buffalo wrote the language-switching code, the
417Modula-2 support, and contributed the Languages chapter of this manual.
c906108c 418
5d161b24 419Fred Fish wrote most of the support for Unix System Vr4.
b37052ae 420He also enhanced the command-completion support to cover C@t{++} overloaded
c906108c 421symbols.
c906108c 422
f24c5e49
KI
423Hitachi America (now Renesas America), Ltd. sponsored the support for
424H8/300, H8/500, and Super-H processors.
c906108c
SS
425
426NEC sponsored the support for the v850, Vr4xxx, and Vr5xxx processors.
427
f24c5e49
KI
428Mitsubishi (now Renesas) sponsored the support for D10V, D30V, and M32R/D
429processors.
c906108c
SS
430
431Toshiba sponsored the support for the TX39 Mips processor.
432
433Matsushita sponsored the support for the MN10200 and MN10300 processors.
434
96a2c332 435Fujitsu sponsored the support for SPARClite and FR30 processors.
c906108c
SS
436
437Kung Hsu, Jeff Law, and Rick Sladkey added support for hardware
438watchpoints.
439
440Michael Snyder added support for tracepoints.
441
442Stu Grossman wrote gdbserver.
443
444Jim Kingdon, Peter Schauer, Ian Taylor, and Stu Grossman made
96a2c332 445nearly innumerable bug fixes and cleanups throughout @value{GDBN}.
c906108c
SS
446
447The following people at the Hewlett-Packard Company contributed
448support for the PA-RISC 2.0 architecture, HP-UX 10.20, 10.30, and 11.0
b37052ae 449(narrow mode), HP's implementation of kernel threads, HP's aC@t{++}
d0d5df6f
AC
450compiler, and the Text User Interface (nee Terminal User Interface):
451Ben Krepp, Richard Title, John Bishop, Susan Macchia, Kathy Mann,
452Satish Pai, India Paul, Steve Rehrauer, and Elena Zannoni. Kim Haase
453provided HP-specific information in this manual.
c906108c 454
b37052ae
EZ
455DJ Delorie ported @value{GDBN} to MS-DOS, for the DJGPP project.
456Robert Hoehne made significant contributions to the DJGPP port.
457
96a2c332
SS
458Cygnus Solutions has sponsored @value{GDBN} maintenance and much of its
459development since 1991. Cygnus engineers who have worked on @value{GDBN}
2df3850c
JM
460fulltime include Mark Alexander, Jim Blandy, Per Bothner, Kevin
461Buettner, Edith Epstein, Chris Faylor, Fred Fish, Martin Hunt, Jim
462Ingham, John Gilmore, Stu Grossman, Kung Hsu, Jim Kingdon, John Metzler,
463Fernando Nasser, Geoffrey Noer, Dawn Perchik, Rich Pixley, Zdenek
464Radouch, Keith Seitz, Stan Shebs, David Taylor, and Elena Zannoni. In
465addition, Dave Brolley, Ian Carmichael, Steve Chamberlain, Nick Clifton,
466JT Conklin, Stan Cox, DJ Delorie, Ulrich Drepper, Frank Eigler, Doug
467Evans, Sean Fagan, David Henkel-Wallace, Richard Henderson, Jeff
468Holcomb, Jeff Law, Jim Lemke, Tom Lord, Bob Manson, Michael Meissner,
469Jason Merrill, Catherine Moore, Drew Moseley, Ken Raeburn, Gavin
470Romig-Koch, Rob Savoye, Jamie Smith, Mike Stump, Ian Taylor, Angela
471Thomas, Michael Tiemann, Tom Tromey, Ron Unrau, Jim Wilson, and David
472Zuhn have made contributions both large and small.
c906108c 473
ffed4509
AC
474Andrew Cagney, Fernando Nasser, and Elena Zannoni, while working for
475Cygnus Solutions, implemented the original @sc{gdb/mi} interface.
476
e2e0bcd1
JB
477Jim Blandy added support for preprocessor macros, while working for Red
478Hat.
c906108c 479
a9967aef
AC
480Andrew Cagney designed @value{GDBN}'s architecture vector. Many
481people including Andrew Cagney, Stephane Carrez, Randolph Chung, Nick
482Duffek, Richard Henderson, Mark Kettenis, Grace Sainsbury, Kei
483Sakamoto, Yoshinori Sato, Michael Snyder, Andreas Schwab, Jason
484Thorpe, Corinna Vinschen, Ulrich Weigand, and Elena Zannoni, helped
485with the migration of old architectures to this new framework.
486
6d2ebf8b 487@node Sample Session
c906108c
SS
488@chapter A Sample @value{GDBN} Session
489
490You can use this manual at your leisure to read all about @value{GDBN}.
491However, a handful of commands are enough to get started using the
492debugger. This chapter illustrates those commands.
493
494@iftex
495In this sample session, we emphasize user input like this: @b{input},
496to make it easier to pick out from the surrounding output.
497@end iftex
498
499@c FIXME: this example may not be appropriate for some configs, where
500@c FIXME...primary interest is in remote use.
501
502One of the preliminary versions of @sc{gnu} @code{m4} (a generic macro
503processor) exhibits the following bug: sometimes, when we change its
504quote strings from the default, the commands used to capture one macro
505definition within another stop working. In the following short @code{m4}
506session, we define a macro @code{foo} which expands to @code{0000}; we
507then use the @code{m4} built-in @code{defn} to define @code{bar} as the
508same thing. However, when we change the open quote string to
509@code{<QUOTE>} and the close quote string to @code{<UNQUOTE>}, the same
510procedure fails to define a new synonym @code{baz}:
511
512@smallexample
513$ @b{cd gnu/m4}
514$ @b{./m4}
515@b{define(foo,0000)}
516
517@b{foo}
5180000
519@b{define(bar,defn(`foo'))}
520
521@b{bar}
5220000
523@b{changequote(<QUOTE>,<UNQUOTE>)}
524
525@b{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
526@b{baz}
527@b{C-d}
528m4: End of input: 0: fatal error: EOF in string
529@end smallexample
530
531@noindent
532Let us use @value{GDBN} to try to see what is going on.
533
c906108c
SS
534@smallexample
535$ @b{@value{GDBP} m4}
536@c FIXME: this falsifies the exact text played out, to permit smallbook
537@c FIXME... format to come out better.
538@value{GDBN} is free software and you are welcome to distribute copies
5d161b24 539 of it under certain conditions; type "show copying" to see
c906108c 540 the conditions.
5d161b24 541There is absolutely no warranty for @value{GDBN}; type "show warranty"
c906108c
SS
542 for details.
543
544@value{GDBN} @value{GDBVN}, Copyright 1999 Free Software Foundation, Inc...
545(@value{GDBP})
546@end smallexample
c906108c
SS
547
548@noindent
549@value{GDBN} reads only enough symbol data to know where to find the
550rest when needed; as a result, the first prompt comes up very quickly.
551We now tell @value{GDBN} to use a narrower display width than usual, so
552that examples fit in this manual.
553
554@smallexample
555(@value{GDBP}) @b{set width 70}
556@end smallexample
557
558@noindent
559We need to see how the @code{m4} built-in @code{changequote} works.
560Having looked at the source, we know the relevant subroutine is
561@code{m4_changequote}, so we set a breakpoint there with the @value{GDBN}
562@code{break} command.
563
564@smallexample
565(@value{GDBP}) @b{break m4_changequote}
566Breakpoint 1 at 0x62f4: file builtin.c, line 879.
567@end smallexample
568
569@noindent
570Using the @code{run} command, we start @code{m4} running under @value{GDBN}
571control; as long as control does not reach the @code{m4_changequote}
572subroutine, the program runs as usual:
573
574@smallexample
575(@value{GDBP}) @b{run}
576Starting program: /work/Editorial/gdb/gnu/m4/m4
577@b{define(foo,0000)}
578
579@b{foo}
5800000
581@end smallexample
582
583@noindent
584To trigger the breakpoint, we call @code{changequote}. @value{GDBN}
585suspends execution of @code{m4}, displaying information about the
586context where it stops.
587
588@smallexample
589@b{changequote(<QUOTE>,<UNQUOTE>)}
590
5d161b24 591Breakpoint 1, m4_changequote (argc=3, argv=0x33c70)
c906108c
SS
592 at builtin.c:879
593879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3))
594@end smallexample
595
596@noindent
597Now we use the command @code{n} (@code{next}) to advance execution to
598the next line of the current function.
599
600@smallexample
601(@value{GDBP}) @b{n}
602882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\
603 : nil,
604@end smallexample
605
606@noindent
607@code{set_quotes} looks like a promising subroutine. We can go into it
608by using the command @code{s} (@code{step}) instead of @code{next}.
609@code{step} goes to the next line to be executed in @emph{any}
610subroutine, so it steps into @code{set_quotes}.
611
612@smallexample
613(@value{GDBP}) @b{s}
614set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
615 at input.c:530
616530 if (lquote != def_lquote)
617@end smallexample
618
619@noindent
620The display that shows the subroutine where @code{m4} is now
621suspended (and its arguments) is called a stack frame display. It
622shows a summary of the stack. We can use the @code{backtrace}
623command (which can also be spelled @code{bt}), to see where we are
624in the stack as a whole: the @code{backtrace} command displays a
625stack frame for each active subroutine.
626
627@smallexample
628(@value{GDBP}) @b{bt}
629#0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
630 at input.c:530
5d161b24 631#1 0x6344 in m4_changequote (argc=3, argv=0x33c70)
c906108c
SS
632 at builtin.c:882
633#2 0x8174 in expand_macro (sym=0x33320) at macro.c:242
634#3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
635 at macro.c:71
636#4 0x79dc in expand_input () at macro.c:40
637#5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
638@end smallexample
639
640@noindent
641We step through a few more lines to see what happens. The first two
642times, we can use @samp{s}; the next two times we use @code{n} to avoid
643falling into the @code{xstrdup} subroutine.
644
645@smallexample
646(@value{GDBP}) @b{s}
6470x3b5c 532 if (rquote != def_rquote)
648(@value{GDBP}) @b{s}
6490x3b80 535 lquote = (lq == nil || *lq == '\0') ? \
650def_lquote : xstrdup(lq);
651(@value{GDBP}) @b{n}
652536 rquote = (rq == nil || *rq == '\0') ? def_rquote\
653 : xstrdup(rq);
654(@value{GDBP}) @b{n}
655538 len_lquote = strlen(rquote);
656@end smallexample
657
658@noindent
659The last line displayed looks a little odd; we can examine the variables
660@code{lquote} and @code{rquote} to see if they are in fact the new left
661and right quotes we specified. We use the command @code{p}
662(@code{print}) to see their values.
663
664@smallexample
665(@value{GDBP}) @b{p lquote}
666$1 = 0x35d40 "<QUOTE>"
667(@value{GDBP}) @b{p rquote}
668$2 = 0x35d50 "<UNQUOTE>"
669@end smallexample
670
671@noindent
672@code{lquote} and @code{rquote} are indeed the new left and right quotes.
673To look at some context, we can display ten lines of source
674surrounding the current line with the @code{l} (@code{list}) command.
675
676@smallexample
677(@value{GDBP}) @b{l}
678533 xfree(rquote);
679534
680535 lquote = (lq == nil || *lq == '\0') ? def_lquote\
681 : xstrdup (lq);
682536 rquote = (rq == nil || *rq == '\0') ? def_rquote\
683 : xstrdup (rq);
684537
685538 len_lquote = strlen(rquote);
686539 len_rquote = strlen(lquote);
687540 @}
688541
689542 void
690@end smallexample
691
692@noindent
693Let us step past the two lines that set @code{len_lquote} and
694@code{len_rquote}, and then examine the values of those variables.
695
696@smallexample
697(@value{GDBP}) @b{n}
698539 len_rquote = strlen(lquote);
699(@value{GDBP}) @b{n}
700540 @}
701(@value{GDBP}) @b{p len_lquote}
702$3 = 9
703(@value{GDBP}) @b{p len_rquote}
704$4 = 7
705@end smallexample
706
707@noindent
708That certainly looks wrong, assuming @code{len_lquote} and
709@code{len_rquote} are meant to be the lengths of @code{lquote} and
710@code{rquote} respectively. We can set them to better values using
711the @code{p} command, since it can print the value of
712any expression---and that expression can include subroutine calls and
713assignments.
714
715@smallexample
716(@value{GDBP}) @b{p len_lquote=strlen(lquote)}
717$5 = 7
718(@value{GDBP}) @b{p len_rquote=strlen(rquote)}
719$6 = 9
720@end smallexample
721
722@noindent
723Is that enough to fix the problem of using the new quotes with the
724@code{m4} built-in @code{defn}? We can allow @code{m4} to continue
725executing with the @code{c} (@code{continue}) command, and then try the
726example that caused trouble initially:
727
728@smallexample
729(@value{GDBP}) @b{c}
730Continuing.
731
732@b{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
733
734baz
7350000
736@end smallexample
737
738@noindent
739Success! The new quotes now work just as well as the default ones. The
740problem seems to have been just the two typos defining the wrong
741lengths. We allow @code{m4} exit by giving it an EOF as input:
742
743@smallexample
744@b{C-d}
745Program exited normally.
746@end smallexample
747
748@noindent
749The message @samp{Program exited normally.} is from @value{GDBN}; it
750indicates @code{m4} has finished executing. We can end our @value{GDBN}
751session with the @value{GDBN} @code{quit} command.
752
753@smallexample
754(@value{GDBP}) @b{quit}
755@end smallexample
c906108c 756
6d2ebf8b 757@node Invocation
c906108c
SS
758@chapter Getting In and Out of @value{GDBN}
759
760This chapter discusses how to start @value{GDBN}, and how to get out of it.
5d161b24 761The essentials are:
c906108c 762@itemize @bullet
5d161b24 763@item
53a5351d 764type @samp{@value{GDBP}} to start @value{GDBN}.
5d161b24 765@item
c906108c
SS
766type @kbd{quit} or @kbd{C-d} to exit.
767@end itemize
768
769@menu
770* Invoking GDB:: How to start @value{GDBN}
771* Quitting GDB:: How to quit @value{GDBN}
772* Shell Commands:: How to use shell commands inside @value{GDBN}
0fac0b41 773* Logging output:: How to log @value{GDBN}'s output to a file
c906108c
SS
774@end menu
775
6d2ebf8b 776@node Invoking GDB
c906108c
SS
777@section Invoking @value{GDBN}
778
c906108c
SS
779Invoke @value{GDBN} by running the program @code{@value{GDBP}}. Once started,
780@value{GDBN} reads commands from the terminal until you tell it to exit.
781
782You can also run @code{@value{GDBP}} with a variety of arguments and options,
783to specify more of your debugging environment at the outset.
784
c906108c
SS
785The command-line options described here are designed
786to cover a variety of situations; in some environments, some of these
5d161b24 787options may effectively be unavailable.
c906108c
SS
788
789The most usual way to start @value{GDBN} is with one argument,
790specifying an executable program:
791
474c8240 792@smallexample
c906108c 793@value{GDBP} @var{program}
474c8240 794@end smallexample
c906108c 795
c906108c
SS
796@noindent
797You can also start with both an executable program and a core file
798specified:
799
474c8240 800@smallexample
c906108c 801@value{GDBP} @var{program} @var{core}
474c8240 802@end smallexample
c906108c
SS
803
804You can, instead, specify a process ID as a second argument, if you want
805to debug a running process:
806
474c8240 807@smallexample
c906108c 808@value{GDBP} @var{program} 1234
474c8240 809@end smallexample
c906108c
SS
810
811@noindent
812would attach @value{GDBN} to process @code{1234} (unless you also have a file
813named @file{1234}; @value{GDBN} does check for a core file first).
814
c906108c 815Taking advantage of the second command-line argument requires a fairly
2df3850c
JM
816complete operating system; when you use @value{GDBN} as a remote
817debugger attached to a bare board, there may not be any notion of
818``process'', and there is often no way to get a core dump. @value{GDBN}
819will warn you if it is unable to attach or to read core dumps.
c906108c 820
aa26fa3a
TT
821You can optionally have @code{@value{GDBP}} pass any arguments after the
822executable file to the inferior using @code{--args}. This option stops
823option processing.
474c8240 824@smallexample
aa26fa3a 825gdb --args gcc -O2 -c foo.c
474c8240 826@end smallexample
aa26fa3a
TT
827This will cause @code{@value{GDBP}} to debug @code{gcc}, and to set
828@code{gcc}'s command-line arguments (@pxref{Arguments}) to @samp{-O2 -c foo.c}.
829
96a2c332 830You can run @code{@value{GDBP}} without printing the front material, which describes
c906108c
SS
831@value{GDBN}'s non-warranty, by specifying @code{-silent}:
832
833@smallexample
834@value{GDBP} -silent
835@end smallexample
836
837@noindent
838You can further control how @value{GDBN} starts up by using command-line
839options. @value{GDBN} itself can remind you of the options available.
840
841@noindent
842Type
843
474c8240 844@smallexample
c906108c 845@value{GDBP} -help
474c8240 846@end smallexample
c906108c
SS
847
848@noindent
849to display all available options and briefly describe their use
850(@samp{@value{GDBP} -h} is a shorter equivalent).
851
852All options and command line arguments you give are processed
853in sequential order. The order makes a difference when the
854@samp{-x} option is used.
855
856
857@menu
c906108c
SS
858* File Options:: Choosing files
859* Mode Options:: Choosing modes
6fc08d32 860* Startup:: What @value{GDBN} does during startup
c906108c
SS
861@end menu
862
6d2ebf8b 863@node File Options
c906108c
SS
864@subsection Choosing files
865
2df3850c 866When @value{GDBN} starts, it reads any arguments other than options as
c906108c
SS
867specifying an executable file and core file (or process ID). This is
868the same as if the arguments were specified by the @samp{-se} and
19837790
MS
869@samp{-c} (or @samp{-p} options respectively. (@value{GDBN} reads the
870first argument that does not have an associated option flag as
871equivalent to the @samp{-se} option followed by that argument; and the
872second argument that does not have an associated option flag, if any, as
873equivalent to the @samp{-c}/@samp{-p} option followed by that argument.)
874If the second argument begins with a decimal digit, @value{GDBN} will
875first attempt to attach to it as a process, and if that fails, attempt
876to open it as a corefile. If you have a corefile whose name begins with
b383017d 877a digit, you can prevent @value{GDBN} from treating it as a pid by
79f12247 878prefixing it with @file{./}, eg. @file{./12345}.
7a292a7a
SS
879
880If @value{GDBN} has not been configured to included core file support,
881such as for most embedded targets, then it will complain about a second
882argument and ignore it.
c906108c
SS
883
884Many options have both long and short forms; both are shown in the
885following list. @value{GDBN} also recognizes the long forms if you truncate
886them, so long as enough of the option is present to be unambiguous.
887(If you prefer, you can flag option arguments with @samp{--} rather
888than @samp{-}, though we illustrate the more usual convention.)
889
d700128c
EZ
890@c NOTE: the @cindex entries here use double dashes ON PURPOSE. This
891@c way, both those who look for -foo and --foo in the index, will find
892@c it.
893
c906108c
SS
894@table @code
895@item -symbols @var{file}
896@itemx -s @var{file}
d700128c
EZ
897@cindex @code{--symbols}
898@cindex @code{-s}
c906108c
SS
899Read symbol table from file @var{file}.
900
901@item -exec @var{file}
902@itemx -e @var{file}
d700128c
EZ
903@cindex @code{--exec}
904@cindex @code{-e}
7a292a7a
SS
905Use file @var{file} as the executable file to execute when appropriate,
906and for examining pure data in conjunction with a core dump.
c906108c
SS
907
908@item -se @var{file}
d700128c 909@cindex @code{--se}
c906108c
SS
910Read symbol table from file @var{file} and use it as the executable
911file.
912
c906108c
SS
913@item -core @var{file}
914@itemx -c @var{file}
d700128c
EZ
915@cindex @code{--core}
916@cindex @code{-c}
b383017d 917Use file @var{file} as a core dump to examine.
c906108c
SS
918
919@item -c @var{number}
19837790
MS
920@item -pid @var{number}
921@itemx -p @var{number}
922@cindex @code{--pid}
923@cindex @code{-p}
924Connect to process ID @var{number}, as with the @code{attach} command.
925If there is no such process, @value{GDBN} will attempt to open a core
926file named @var{number}.
c906108c
SS
927
928@item -command @var{file}
929@itemx -x @var{file}
d700128c
EZ
930@cindex @code{--command}
931@cindex @code{-x}
c906108c
SS
932Execute @value{GDBN} commands from file @var{file}. @xref{Command
933Files,, Command files}.
934
935@item -directory @var{directory}
936@itemx -d @var{directory}
d700128c
EZ
937@cindex @code{--directory}
938@cindex @code{-d}
c906108c
SS
939Add @var{directory} to the path to search for source files.
940
c906108c
SS
941@item -m
942@itemx -mapped
d700128c
EZ
943@cindex @code{--mapped}
944@cindex @code{-m}
c906108c
SS
945@emph{Warning: this option depends on operating system facilities that are not
946supported on all systems.}@*
947If memory-mapped files are available on your system through the @code{mmap}
5d161b24 948system call, you can use this option
c906108c
SS
949to have @value{GDBN} write the symbols from your
950program into a reusable file in the current directory. If the program you are debugging is
96a2c332 951called @file{/tmp/fred}, the mapped symbol file is @file{/tmp/fred.syms}.
c906108c
SS
952Future @value{GDBN} debugging sessions notice the presence of this file,
953and can quickly map in symbol information from it, rather than reading
954the symbol table from the executable program.
955
956The @file{.syms} file is specific to the host machine where @value{GDBN}
957is run. It holds an exact image of the internal @value{GDBN} symbol
958table. It cannot be shared across multiple host platforms.
c906108c 959
c906108c
SS
960@item -r
961@itemx -readnow
d700128c
EZ
962@cindex @code{--readnow}
963@cindex @code{-r}
c906108c
SS
964Read each symbol file's entire symbol table immediately, rather than
965the default, which is to read it incrementally as it is needed.
966This makes startup slower, but makes future operations faster.
53a5351d 967
c906108c
SS
968@end table
969
2df3850c 970You typically combine the @code{-mapped} and @code{-readnow} options in
c906108c 971order to build a @file{.syms} file that contains complete symbol
2df3850c
JM
972information. (@xref{Files,,Commands to specify files}, for information
973on @file{.syms} files.) A simple @value{GDBN} invocation to do nothing
974but build a @file{.syms} file for future use is:
c906108c 975
474c8240 976@smallexample
2df3850c 977gdb -batch -nx -mapped -readnow programname
474c8240 978@end smallexample
c906108c 979
6d2ebf8b 980@node Mode Options
c906108c
SS
981@subsection Choosing modes
982
983You can run @value{GDBN} in various alternative modes---for example, in
984batch mode or quiet mode.
985
986@table @code
987@item -nx
988@itemx -n
d700128c
EZ
989@cindex @code{--nx}
990@cindex @code{-n}
96565e91 991Do not execute commands found in any initialization files. Normally,
2df3850c
JM
992@value{GDBN} executes the commands in these files after all the command
993options and arguments have been processed. @xref{Command Files,,Command
994files}.
c906108c
SS
995
996@item -quiet
d700128c 997@itemx -silent
c906108c 998@itemx -q
d700128c
EZ
999@cindex @code{--quiet}
1000@cindex @code{--silent}
1001@cindex @code{-q}
c906108c
SS
1002``Quiet''. Do not print the introductory and copyright messages. These
1003messages are also suppressed in batch mode.
1004
1005@item -batch
d700128c 1006@cindex @code{--batch}
c906108c
SS
1007Run in batch mode. Exit with status @code{0} after processing all the
1008command files specified with @samp{-x} (and all commands from
1009initialization files, if not inhibited with @samp{-n}). Exit with
1010nonzero status if an error occurs in executing the @value{GDBN} commands
1011in the command files.
1012
2df3850c
JM
1013Batch mode may be useful for running @value{GDBN} as a filter, for
1014example to download and run a program on another computer; in order to
1015make this more useful, the message
c906108c 1016
474c8240 1017@smallexample
c906108c 1018Program exited normally.
474c8240 1019@end smallexample
c906108c
SS
1020
1021@noindent
2df3850c
JM
1022(which is ordinarily issued whenever a program running under
1023@value{GDBN} control terminates) is not issued when running in batch
1024mode.
1025
1026@item -nowindows
1027@itemx -nw
d700128c
EZ
1028@cindex @code{--nowindows}
1029@cindex @code{-nw}
2df3850c 1030``No windows''. If @value{GDBN} comes with a graphical user interface
96a2c332 1031(GUI) built in, then this option tells @value{GDBN} to only use the command-line
2df3850c
JM
1032interface. If no GUI is available, this option has no effect.
1033
1034@item -windows
1035@itemx -w
d700128c
EZ
1036@cindex @code{--windows}
1037@cindex @code{-w}
2df3850c
JM
1038If @value{GDBN} includes a GUI, then this option requires it to be
1039used if possible.
c906108c
SS
1040
1041@item -cd @var{directory}
d700128c 1042@cindex @code{--cd}
c906108c
SS
1043Run @value{GDBN} using @var{directory} as its working directory,
1044instead of the current directory.
1045
c906108c
SS
1046@item -fullname
1047@itemx -f
d700128c
EZ
1048@cindex @code{--fullname}
1049@cindex @code{-f}
7a292a7a
SS
1050@sc{gnu} Emacs sets this option when it runs @value{GDBN} as a
1051subprocess. It tells @value{GDBN} to output the full file name and line
1052number in a standard, recognizable fashion each time a stack frame is
1053displayed (which includes each time your program stops). This
1054recognizable format looks like two @samp{\032} characters, followed by
1055the file name, line number and character position separated by colons,
1056and a newline. The Emacs-to-@value{GDBN} interface program uses the two
1057@samp{\032} characters as a signal to display the source code for the
1058frame.
c906108c 1059
d700128c
EZ
1060@item -epoch
1061@cindex @code{--epoch}
1062The Epoch Emacs-@value{GDBN} interface sets this option when it runs
1063@value{GDBN} as a subprocess. It tells @value{GDBN} to modify its print
1064routines so as to allow Epoch to display values of expressions in a
1065separate window.
1066
1067@item -annotate @var{level}
1068@cindex @code{--annotate}
1069This option sets the @dfn{annotation level} inside @value{GDBN}. Its
1070effect is identical to using @samp{set annotate @var{level}}
086432e2
AC
1071(@pxref{Annotations}). The annotation @var{level} controls how much
1072information @value{GDBN} prints together with its prompt, values of
1073expressions, source lines, and other types of output. Level 0 is the
1074normal, level 1 is for use when @value{GDBN} is run as a subprocess of
1075@sc{gnu} Emacs, level 3 is the maximum annotation suitable for programs
1076that control @value{GDBN}, and level 2 has been deprecated.
1077
1078The annotation mechanism has largely been superseeded by @sc{gdb/mi}
1079(@pxref{GDB/MI}).
d700128c 1080
aa26fa3a
TT
1081@item --args
1082@cindex @code{--args}
1083Change interpretation of command line so that arguments following the
1084executable file are passed as command line arguments to the inferior.
1085This option stops option processing.
1086
2df3850c
JM
1087@item -baud @var{bps}
1088@itemx -b @var{bps}
d700128c
EZ
1089@cindex @code{--baud}
1090@cindex @code{-b}
c906108c
SS
1091Set the line speed (baud rate or bits per second) of any serial
1092interface used by @value{GDBN} for remote debugging.
c906108c 1093
f47b1503
AS
1094@item -l @var{timeout}
1095@cindex @code{-l}
1096Set the timeout (in seconds) of any communication used by @value{GDBN}
1097for remote debugging.
1098
c906108c 1099@item -tty @var{device}
d700128c
EZ
1100@itemx -t @var{device}
1101@cindex @code{--tty}
1102@cindex @code{-t}
c906108c
SS
1103Run using @var{device} for your program's standard input and output.
1104@c FIXME: kingdon thinks there is more to -tty. Investigate.
c906108c 1105
53a5351d 1106@c resolve the situation of these eventually
c4555f82
SC
1107@item -tui
1108@cindex @code{--tui}
d0d5df6f
AC
1109Activate the @dfn{Text User Interface} when starting. The Text User
1110Interface manages several text windows on the terminal, showing
1111source, assembly, registers and @value{GDBN} command outputs
1112(@pxref{TUI, ,@value{GDBN} Text User Interface}). Alternatively, the
1113Text User Interface can be enabled by invoking the program
1114@samp{gdbtui}. Do not use this option if you run @value{GDBN} from
1115Emacs (@pxref{Emacs, ,Using @value{GDBN} under @sc{gnu} Emacs}).
53a5351d
JM
1116
1117@c @item -xdb
d700128c 1118@c @cindex @code{--xdb}
53a5351d
JM
1119@c Run in XDB compatibility mode, allowing the use of certain XDB commands.
1120@c For information, see the file @file{xdb_trans.html}, which is usually
1121@c installed in the directory @code{/opt/langtools/wdb/doc} on HP-UX
1122@c systems.
1123
d700128c
EZ
1124@item -interpreter @var{interp}
1125@cindex @code{--interpreter}
1126Use the interpreter @var{interp} for interface with the controlling
1127program or device. This option is meant to be set by programs which
94bbb2c0 1128communicate with @value{GDBN} using it as a back end.
21c294e6 1129@xref{Interpreters, , Command Interpreters}.
94bbb2c0 1130
da0f9dcd 1131@samp{--interpreter=mi} (or @samp{--interpreter=mi2}) causes
2fcf52f0 1132@value{GDBN} to use the @dfn{@sc{gdb/mi} interface} (@pxref{GDB/MI, ,
6b5e8c01 1133The @sc{gdb/mi} Interface}) included since @value{GDBN} version 6.0. The
6c74ac8b
AC
1134previous @sc{gdb/mi} interface, included in @value{GDBN} version 5.3 and
1135selected with @samp{--interpreter=mi1}, is deprecated. Earlier
1136@sc{gdb/mi} interfaces are no longer supported.
d700128c
EZ
1137
1138@item -write
1139@cindex @code{--write}
1140Open the executable and core files for both reading and writing. This
1141is equivalent to the @samp{set write on} command inside @value{GDBN}
1142(@pxref{Patching}).
1143
1144@item -statistics
1145@cindex @code{--statistics}
1146This option causes @value{GDBN} to print statistics about time and
1147memory usage after it completes each command and returns to the prompt.
1148
1149@item -version
1150@cindex @code{--version}
1151This option causes @value{GDBN} to print its version number and
1152no-warranty blurb, and exit.
1153
c906108c
SS
1154@end table
1155
6fc08d32
EZ
1156@node Startup
1157@subsection What @value{GDBN} does during startup
1158@cindex @value{GDBN} startup
1159
1160Here's the description of what @value{GDBN} does during session startup:
1161
1162@enumerate
1163@item
1164Sets up the command interpreter as specified by the command line
1165(@pxref{Mode Options, interpreter}).
1166
1167@item
1168@cindex init file
1169Reads the @dfn{init file} (if any) in your home directory@footnote{On
1170DOS/Windows systems, the home directory is the one pointed to by the
1171@code{HOME} environment variable.} and executes all the commands in
1172that file.
1173
1174@item
1175Processes command line options and operands.
1176
1177@item
1178Reads and executes the commands from init file (if any) in the current
119b882a
EZ
1179working directory. This is only done if the current directory is
1180different from your home directory. Thus, you can have more than one
1181init file, one generic in your home directory, and another, specific
1182to the program you are debugging, in the directory where you invoke
6fc08d32
EZ
1183@value{GDBN}.
1184
1185@item
1186Reads command files specified by the @samp{-x} option. @xref{Command
1187Files}, for more details about @value{GDBN} command files.
1188
1189@item
1190Reads the command history recorded in the @dfn{history file}.
1191@xref{History}, for more details about the command history and the
1192files where @value{GDBN} records it.
1193@end enumerate
1194
1195Init files use the same syntax as @dfn{command files} (@pxref{Command
1196Files}) and are processed by @value{GDBN} in the same way. The init
1197file in your home directory can set options (such as @samp{set
1198complaints}) that affect subsequent processing of command line options
1199and operands. Init files are not executed if you use the @samp{-nx}
1200option (@pxref{Mode Options, ,Choosing modes}).
1201
1202@cindex init file name
1203@cindex @file{.gdbinit}
119b882a 1204The @value{GDBN} init files are normally called @file{.gdbinit}.
6fc08d32
EZ
1205On some configurations of @value{GDBN}, the init file is known by a
1206different name (these are typically environments where a specialized
1207form of @value{GDBN} may need to coexist with other forms, hence a
1208different name for the specialized version's init file). These are the
1209environments with special init file names:
1210
6fc08d32 1211@itemize @bullet
119b882a
EZ
1212@cindex @file{gdb.ini}
1213@item
1214The DJGPP port of @value{GDBN} uses the name @file{gdb.ini}, due to
1215the limitations of file names imposed by DOS filesystems. The Windows
1216ports of @value{GDBN} use the standard name, but if they find a
1217@file{gdb.ini} file, they warn you about that and suggest to rename
1218the file to the standard name.
1219
1220@cindex @file{.vxgdbinit}
6fc08d32
EZ
1221@item
1222VxWorks (Wind River Systems real-time OS): @file{.vxgdbinit}
1223
1224@cindex @file{.os68gdbinit}
1225@item
1226OS68K (Enea Data Systems real-time OS): @file{.os68gdbinit}
1227
1228@cindex @file{.esgdbinit}
1229@item
1230ES-1800 (Ericsson Telecom AB M68000 emulator): @file{.esgdbinit}
1231
1232@item
1233CISCO 68k: @file{.cisco-gdbinit}
1234@end itemize
1235
1236
6d2ebf8b 1237@node Quitting GDB
c906108c
SS
1238@section Quitting @value{GDBN}
1239@cindex exiting @value{GDBN}
1240@cindex leaving @value{GDBN}
1241
1242@table @code
1243@kindex quit @r{[}@var{expression}@r{]}
41afff9a 1244@kindex q @r{(@code{quit})}
96a2c332
SS
1245@item quit @r{[}@var{expression}@r{]}
1246@itemx q
1247To exit @value{GDBN}, use the @code{quit} command (abbreviated
1248@code{q}), or type an end-of-file character (usually @kbd{C-d}). If you
1249do not supply @var{expression}, @value{GDBN} will terminate normally;
1250otherwise it will terminate using the result of @var{expression} as the
1251error code.
c906108c
SS
1252@end table
1253
1254@cindex interrupt
1255An interrupt (often @kbd{C-c}) does not exit from @value{GDBN}, but rather
1256terminates the action of any @value{GDBN} command that is in progress and
1257returns to @value{GDBN} command level. It is safe to type the interrupt
1258character at any time because @value{GDBN} does not allow it to take effect
1259until a time when it is safe.
1260
c906108c
SS
1261If you have been using @value{GDBN} to control an attached process or
1262device, you can release it with the @code{detach} command
1263(@pxref{Attach, ,Debugging an already-running process}).
c906108c 1264
6d2ebf8b 1265@node Shell Commands
c906108c
SS
1266@section Shell commands
1267
1268If you need to execute occasional shell commands during your
1269debugging session, there is no need to leave or suspend @value{GDBN}; you can
1270just use the @code{shell} command.
1271
1272@table @code
1273@kindex shell
1274@cindex shell escape
1275@item shell @var{command string}
1276Invoke a standard shell to execute @var{command string}.
c906108c 1277If it exists, the environment variable @code{SHELL} determines which
d4f3574e
SS
1278shell to run. Otherwise @value{GDBN} uses the default shell
1279(@file{/bin/sh} on Unix systems, @file{COMMAND.COM} on MS-DOS, etc.).
c906108c
SS
1280@end table
1281
1282The utility @code{make} is often needed in development environments.
1283You do not have to use the @code{shell} command for this purpose in
1284@value{GDBN}:
1285
1286@table @code
1287@kindex make
1288@cindex calling make
1289@item make @var{make-args}
1290Execute the @code{make} program with the specified
1291arguments. This is equivalent to @samp{shell make @var{make-args}}.
1292@end table
1293
0fac0b41
DJ
1294@node Logging output
1295@section Logging output
1296@cindex logging @value{GDBN} output
9c16f35a 1297@cindex save @value{GDBN} output to a file
0fac0b41
DJ
1298
1299You may want to save the output of @value{GDBN} commands to a file.
1300There are several commands to control @value{GDBN}'s logging.
1301
1302@table @code
1303@kindex set logging
1304@item set logging on
1305Enable logging.
1306@item set logging off
1307Disable logging.
9c16f35a 1308@cindex logging file name
0fac0b41
DJ
1309@item set logging file @var{file}
1310Change the name of the current logfile. The default logfile is @file{gdb.txt}.
1311@item set logging overwrite [on|off]
1312By default, @value{GDBN} will append to the logfile. Set @code{overwrite} if
1313you want @code{set logging on} to overwrite the logfile instead.
1314@item set logging redirect [on|off]
1315By default, @value{GDBN} output will go to both the terminal and the logfile.
1316Set @code{redirect} if you want output to go only to the log file.
1317@kindex show logging
1318@item show logging
1319Show the current values of the logging settings.
1320@end table
1321
6d2ebf8b 1322@node Commands
c906108c
SS
1323@chapter @value{GDBN} Commands
1324
1325You can abbreviate a @value{GDBN} command to the first few letters of the command
1326name, if that abbreviation is unambiguous; and you can repeat certain
1327@value{GDBN} commands by typing just @key{RET}. You can also use the @key{TAB}
1328key to get @value{GDBN} to fill out the rest of a word in a command (or to
1329show you the alternatives available, if there is more than one possibility).
1330
1331@menu
1332* Command Syntax:: How to give commands to @value{GDBN}
1333* Completion:: Command completion
1334* Help:: How to ask @value{GDBN} for help
1335@end menu
1336
6d2ebf8b 1337@node Command Syntax
c906108c
SS
1338@section Command syntax
1339
1340A @value{GDBN} command is a single line of input. There is no limit on
1341how long it can be. It starts with a command name, which is followed by
1342arguments whose meaning depends on the command name. For example, the
1343command @code{step} accepts an argument which is the number of times to
1344step, as in @samp{step 5}. You can also use the @code{step} command
96a2c332 1345with no arguments. Some commands do not allow any arguments.
c906108c
SS
1346
1347@cindex abbreviation
1348@value{GDBN} command names may always be truncated if that abbreviation is
1349unambiguous. Other possible command abbreviations are listed in the
1350documentation for individual commands. In some cases, even ambiguous
1351abbreviations are allowed; for example, @code{s} is specially defined as
1352equivalent to @code{step} even though there are other commands whose
1353names start with @code{s}. You can test abbreviations by using them as
1354arguments to the @code{help} command.
1355
1356@cindex repeating commands
41afff9a 1357@kindex RET @r{(repeat last command)}
c906108c 1358A blank line as input to @value{GDBN} (typing just @key{RET}) means to
96a2c332 1359repeat the previous command. Certain commands (for example, @code{run})
c906108c
SS
1360will not repeat this way; these are commands whose unintentional
1361repetition might cause trouble and which you are unlikely to want to
c45da7e6
EZ
1362repeat. User-defined commands can disable this feature; see
1363@ref{Define, dont-repeat}.
c906108c
SS
1364
1365The @code{list} and @code{x} commands, when you repeat them with
1366@key{RET}, construct new arguments rather than repeating
1367exactly as typed. This permits easy scanning of source or memory.
1368
1369@value{GDBN} can also use @key{RET} in another way: to partition lengthy
1370output, in a way similar to the common utility @code{more}
1371(@pxref{Screen Size,,Screen size}). Since it is easy to press one
1372@key{RET} too many in this situation, @value{GDBN} disables command
1373repetition after any command that generates this sort of display.
1374
41afff9a 1375@kindex # @r{(a comment)}
c906108c
SS
1376@cindex comment
1377Any text from a @kbd{#} to the end of the line is a comment; it does
1378nothing. This is useful mainly in command files (@pxref{Command
1379Files,,Command files}).
1380
88118b3a
TT
1381@cindex repeating command sequences
1382@kindex C-o @r{(operate-and-get-next)}
1383The @kbd{C-o} binding is useful for repeating a complex sequence of
1384commands. This command accepts the current line, like @kbd{RET}, and
1385then fetches the next line relative to the current line from the history
1386for editing.
1387
6d2ebf8b 1388@node Completion
c906108c
SS
1389@section Command completion
1390
1391@cindex completion
1392@cindex word completion
1393@value{GDBN} can fill in the rest of a word in a command for you, if there is
1394only one possibility; it can also show you what the valid possibilities
1395are for the next word in a command, at any time. This works for @value{GDBN}
1396commands, @value{GDBN} subcommands, and the names of symbols in your program.
1397
1398Press the @key{TAB} key whenever you want @value{GDBN} to fill out the rest
1399of a word. If there is only one possibility, @value{GDBN} fills in the
1400word, and waits for you to finish the command (or press @key{RET} to
1401enter it). For example, if you type
1402
1403@c FIXME "@key" does not distinguish its argument sufficiently to permit
1404@c complete accuracy in these examples; space introduced for clarity.
1405@c If texinfo enhancements make it unnecessary, it would be nice to
1406@c replace " @key" by "@key" in the following...
474c8240 1407@smallexample
c906108c 1408(@value{GDBP}) info bre @key{TAB}
474c8240 1409@end smallexample
c906108c
SS
1410
1411@noindent
1412@value{GDBN} fills in the rest of the word @samp{breakpoints}, since that is
1413the only @code{info} subcommand beginning with @samp{bre}:
1414
474c8240 1415@smallexample
c906108c 1416(@value{GDBP}) info breakpoints
474c8240 1417@end smallexample
c906108c
SS
1418
1419@noindent
1420You can either press @key{RET} at this point, to run the @code{info
1421breakpoints} command, or backspace and enter something else, if
1422@samp{breakpoints} does not look like the command you expected. (If you
1423were sure you wanted @code{info breakpoints} in the first place, you
1424might as well just type @key{RET} immediately after @samp{info bre},
1425to exploit command abbreviations rather than command completion).
1426
1427If there is more than one possibility for the next word when you press
1428@key{TAB}, @value{GDBN} sounds a bell. You can either supply more
1429characters and try again, or just press @key{TAB} a second time;
1430@value{GDBN} displays all the possible completions for that word. For
1431example, you might want to set a breakpoint on a subroutine whose name
1432begins with @samp{make_}, but when you type @kbd{b make_@key{TAB}} @value{GDBN}
1433just sounds the bell. Typing @key{TAB} again displays all the
1434function names in your program that begin with those characters, for
1435example:
1436
474c8240 1437@smallexample
c906108c
SS
1438(@value{GDBP}) b make_ @key{TAB}
1439@exdent @value{GDBN} sounds bell; press @key{TAB} again, to see:
5d161b24
DB
1440make_a_section_from_file make_environ
1441make_abs_section make_function_type
1442make_blockvector make_pointer_type
1443make_cleanup make_reference_type
c906108c
SS
1444make_command make_symbol_completion_list
1445(@value{GDBP}) b make_
474c8240 1446@end smallexample
c906108c
SS
1447
1448@noindent
1449After displaying the available possibilities, @value{GDBN} copies your
1450partial input (@samp{b make_} in the example) so you can finish the
1451command.
1452
1453If you just want to see the list of alternatives in the first place, you
b37052ae 1454can press @kbd{M-?} rather than pressing @key{TAB} twice. @kbd{M-?}
7a292a7a 1455means @kbd{@key{META} ?}. You can type this either by holding down a
c906108c 1456key designated as the @key{META} shift on your keyboard (if there is
7a292a7a 1457one) while typing @kbd{?}, or as @key{ESC} followed by @kbd{?}.
c906108c
SS
1458
1459@cindex quotes in commands
1460@cindex completion of quoted strings
1461Sometimes the string you need, while logically a ``word'', may contain
7a292a7a
SS
1462parentheses or other characters that @value{GDBN} normally excludes from
1463its notion of a word. To permit word completion to work in this
1464situation, you may enclose words in @code{'} (single quote marks) in
1465@value{GDBN} commands.
c906108c 1466
c906108c 1467The most likely situation where you might need this is in typing the
b37052ae
EZ
1468name of a C@t{++} function. This is because C@t{++} allows function
1469overloading (multiple definitions of the same function, distinguished
1470by argument type). For example, when you want to set a breakpoint you
1471may need to distinguish whether you mean the version of @code{name}
1472that takes an @code{int} parameter, @code{name(int)}, or the version
1473that takes a @code{float} parameter, @code{name(float)}. To use the
1474word-completion facilities in this situation, type a single quote
1475@code{'} at the beginning of the function name. This alerts
1476@value{GDBN} that it may need to consider more information than usual
1477when you press @key{TAB} or @kbd{M-?} to request word completion:
c906108c 1478
474c8240 1479@smallexample
96a2c332 1480(@value{GDBP}) b 'bubble( @kbd{M-?}
c906108c
SS
1481bubble(double,double) bubble(int,int)
1482(@value{GDBP}) b 'bubble(
474c8240 1483@end smallexample
c906108c
SS
1484
1485In some cases, @value{GDBN} can tell that completing a name requires using
1486quotes. When this happens, @value{GDBN} inserts the quote for you (while
1487completing as much as it can) if you do not type the quote in the first
1488place:
1489
474c8240 1490@smallexample
c906108c
SS
1491(@value{GDBP}) b bub @key{TAB}
1492@exdent @value{GDBN} alters your input line to the following, and rings a bell:
1493(@value{GDBP}) b 'bubble(
474c8240 1494@end smallexample
c906108c
SS
1495
1496@noindent
1497In general, @value{GDBN} can tell that a quote is needed (and inserts it) if
1498you have not yet started typing the argument list when you ask for
1499completion on an overloaded symbol.
1500
d4f3574e 1501For more information about overloaded functions, see @ref{C plus plus
b37052ae 1502expressions, ,C@t{++} expressions}. You can use the command @code{set
c906108c 1503overload-resolution off} to disable overload resolution;
b37052ae 1504see @ref{Debugging C plus plus, ,@value{GDBN} features for C@t{++}}.
c906108c
SS
1505
1506
6d2ebf8b 1507@node Help
c906108c
SS
1508@section Getting help
1509@cindex online documentation
1510@kindex help
1511
5d161b24 1512You can always ask @value{GDBN} itself for information on its commands,
c906108c
SS
1513using the command @code{help}.
1514
1515@table @code
41afff9a 1516@kindex h @r{(@code{help})}
c906108c
SS
1517@item help
1518@itemx h
1519You can use @code{help} (abbreviated @code{h}) with no arguments to
1520display a short list of named classes of commands:
1521
1522@smallexample
1523(@value{GDBP}) help
1524List of classes of commands:
1525
2df3850c 1526aliases -- Aliases of other commands
c906108c 1527breakpoints -- Making program stop at certain points
2df3850c 1528data -- Examining data
c906108c 1529files -- Specifying and examining files
2df3850c
JM
1530internals -- Maintenance commands
1531obscure -- Obscure features
1532running -- Running the program
1533stack -- Examining the stack
c906108c
SS
1534status -- Status inquiries
1535support -- Support facilities
96a2c332
SS
1536tracepoints -- Tracing of program execution without@*
1537 stopping the program
c906108c 1538user-defined -- User-defined commands
c906108c 1539
5d161b24 1540Type "help" followed by a class name for a list of
c906108c 1541commands in that class.
5d161b24 1542Type "help" followed by command name for full
c906108c
SS
1543documentation.
1544Command name abbreviations are allowed if unambiguous.
1545(@value{GDBP})
1546@end smallexample
96a2c332 1547@c the above line break eliminates huge line overfull...
c906108c
SS
1548
1549@item help @var{class}
1550Using one of the general help classes as an argument, you can get a
1551list of the individual commands in that class. For example, here is the
1552help display for the class @code{status}:
1553
1554@smallexample
1555(@value{GDBP}) help status
1556Status inquiries.
1557
1558List of commands:
1559
1560@c Line break in "show" line falsifies real output, but needed
1561@c to fit in smallbook page size.
2df3850c
JM
1562info -- Generic command for showing things
1563 about the program being debugged
1564show -- Generic command for showing things
1565 about the debugger
c906108c 1566
5d161b24 1567Type "help" followed by command name for full
c906108c
SS
1568documentation.
1569Command name abbreviations are allowed if unambiguous.
1570(@value{GDBP})
1571@end smallexample
1572
1573@item help @var{command}
1574With a command name as @code{help} argument, @value{GDBN} displays a
1575short paragraph on how to use that command.
1576
6837a0a2
DB
1577@kindex apropos
1578@item apropos @var{args}
09d4efe1 1579The @code{apropos} command searches through all of the @value{GDBN}
6837a0a2
DB
1580commands, and their documentation, for the regular expression specified in
1581@var{args}. It prints out all matches found. For example:
1582
1583@smallexample
1584apropos reload
1585@end smallexample
1586
b37052ae
EZ
1587@noindent
1588results in:
6837a0a2
DB
1589
1590@smallexample
6d2ebf8b
SS
1591@c @group
1592set symbol-reloading -- Set dynamic symbol table reloading
1593 multiple times in one run
1594show symbol-reloading -- Show dynamic symbol table reloading
1595 multiple times in one run
1596@c @end group
6837a0a2
DB
1597@end smallexample
1598
c906108c
SS
1599@kindex complete
1600@item complete @var{args}
1601The @code{complete @var{args}} command lists all the possible completions
1602for the beginning of a command. Use @var{args} to specify the beginning of the
1603command you want completed. For example:
1604
1605@smallexample
1606complete i
1607@end smallexample
1608
1609@noindent results in:
1610
1611@smallexample
1612@group
2df3850c
JM
1613if
1614ignore
c906108c
SS
1615info
1616inspect
c906108c
SS
1617@end group
1618@end smallexample
1619
1620@noindent This is intended for use by @sc{gnu} Emacs.
1621@end table
1622
1623In addition to @code{help}, you can use the @value{GDBN} commands @code{info}
1624and @code{show} to inquire about the state of your program, or the state
1625of @value{GDBN} itself. Each command supports many topics of inquiry; this
1626manual introduces each of them in the appropriate context. The listings
1627under @code{info} and under @code{show} in the Index point to
1628all the sub-commands. @xref{Index}.
1629
1630@c @group
1631@table @code
1632@kindex info
41afff9a 1633@kindex i @r{(@code{info})}
c906108c
SS
1634@item info
1635This command (abbreviated @code{i}) is for describing the state of your
1636program. For example, you can list the arguments given to your program
1637with @code{info args}, list the registers currently in use with @code{info
1638registers}, or list the breakpoints you have set with @code{info breakpoints}.
1639You can get a complete list of the @code{info} sub-commands with
1640@w{@code{help info}}.
1641
1642@kindex set
1643@item set
5d161b24 1644You can assign the result of an expression to an environment variable with
c906108c
SS
1645@code{set}. For example, you can set the @value{GDBN} prompt to a $-sign with
1646@code{set prompt $}.
1647
1648@kindex show
1649@item show
5d161b24 1650In contrast to @code{info}, @code{show} is for describing the state of
c906108c
SS
1651@value{GDBN} itself.
1652You can change most of the things you can @code{show}, by using the
1653related command @code{set}; for example, you can control what number
1654system is used for displays with @code{set radix}, or simply inquire
1655which is currently in use with @code{show radix}.
1656
1657@kindex info set
1658To display all the settable parameters and their current
1659values, you can use @code{show} with no arguments; you may also use
1660@code{info set}. Both commands produce the same display.
1661@c FIXME: "info set" violates the rule that "info" is for state of
1662@c FIXME...program. Ck w/ GNU: "info set" to be called something else,
1663@c FIXME...or change desc of rule---eg "state of prog and debugging session"?
1664@end table
1665@c @end group
1666
1667Here are three miscellaneous @code{show} subcommands, all of which are
1668exceptional in lacking corresponding @code{set} commands:
1669
1670@table @code
1671@kindex show version
9c16f35a 1672@cindex @value{GDBN} version number
c906108c
SS
1673@item show version
1674Show what version of @value{GDBN} is running. You should include this
2df3850c
JM
1675information in @value{GDBN} bug-reports. If multiple versions of
1676@value{GDBN} are in use at your site, you may need to determine which
1677version of @value{GDBN} you are running; as @value{GDBN} evolves, new
1678commands are introduced, and old ones may wither away. Also, many
1679system vendors ship variant versions of @value{GDBN}, and there are
96a2c332 1680variant versions of @value{GDBN} in @sc{gnu}/Linux distributions as well.
2df3850c
JM
1681The version number is the same as the one announced when you start
1682@value{GDBN}.
c906108c
SS
1683
1684@kindex show copying
09d4efe1 1685@kindex info copying
9c16f35a 1686@cindex display @value{GDBN} copyright
c906108c 1687@item show copying
09d4efe1 1688@itemx info copying
c906108c
SS
1689Display information about permission for copying @value{GDBN}.
1690
1691@kindex show warranty
09d4efe1 1692@kindex info warranty
c906108c 1693@item show warranty
09d4efe1 1694@itemx info warranty
2df3850c 1695Display the @sc{gnu} ``NO WARRANTY'' statement, or a warranty,
96a2c332 1696if your version of @value{GDBN} comes with one.
2df3850c 1697
c906108c
SS
1698@end table
1699
6d2ebf8b 1700@node Running
c906108c
SS
1701@chapter Running Programs Under @value{GDBN}
1702
1703When you run a program under @value{GDBN}, you must first generate
1704debugging information when you compile it.
7a292a7a
SS
1705
1706You may start @value{GDBN} with its arguments, if any, in an environment
1707of your choice. If you are doing native debugging, you may redirect
1708your program's input and output, debug an already running process, or
1709kill a child process.
c906108c
SS
1710
1711@menu
1712* Compilation:: Compiling for debugging
1713* Starting:: Starting your program
c906108c
SS
1714* Arguments:: Your program's arguments
1715* Environment:: Your program's environment
c906108c
SS
1716
1717* Working Directory:: Your program's working directory
1718* Input/Output:: Your program's input and output
1719* Attach:: Debugging an already-running process
1720* Kill Process:: Killing the child process
c906108c
SS
1721
1722* Threads:: Debugging programs with multiple threads
1723* Processes:: Debugging programs with multiple processes
1724@end menu
1725
6d2ebf8b 1726@node Compilation
c906108c
SS
1727@section Compiling for debugging
1728
1729In order to debug a program effectively, you need to generate
1730debugging information when you compile it. This debugging information
1731is stored in the object file; it describes the data type of each
1732variable or function and the correspondence between source line numbers
1733and addresses in the executable code.
1734
1735To request debugging information, specify the @samp{-g} option when you run
1736the compiler.
1737
514c4d71
EZ
1738Programs that are to be shipped to your customers are compiled with
1739optimizations, using the @samp{-O} compiler option. However, many
1740compilers are unable to handle the @samp{-g} and @samp{-O} options
1741together. Using those compilers, you cannot generate optimized
c906108c
SS
1742executables containing debugging information.
1743
514c4d71 1744@value{NGCC}, the @sc{gnu} C/C@t{++} compiler, supports @samp{-g} with or
53a5351d
JM
1745without @samp{-O}, making it possible to debug optimized code. We
1746recommend that you @emph{always} use @samp{-g} whenever you compile a
1747program. You may think your program is correct, but there is no sense
1748in pushing your luck.
c906108c
SS
1749
1750@cindex optimized code, debugging
1751@cindex debugging optimized code
1752When you debug a program compiled with @samp{-g -O}, remember that the
1753optimizer is rearranging your code; the debugger shows you what is
1754really there. Do not be too surprised when the execution path does not
1755exactly match your source file! An extreme example: if you define a
1756variable, but never use it, @value{GDBN} never sees that
1757variable---because the compiler optimizes it out of existence.
1758
1759Some things do not work as well with @samp{-g -O} as with just
1760@samp{-g}, particularly on machines with instruction scheduling. If in
1761doubt, recompile with @samp{-g} alone, and if this fixes the problem,
1762please report it to us as a bug (including a test case!).
15387254 1763@xref{Variables}, for more information about debugging optimized code.
c906108c
SS
1764
1765Older versions of the @sc{gnu} C compiler permitted a variant option
1766@w{@samp{-gg}} for debugging information. @value{GDBN} no longer supports this
1767format; if your @sc{gnu} C compiler has this option, do not use it.
1768
514c4d71
EZ
1769@value{GDBN} knows about preprocessor macros and can show you their
1770expansion (@pxref{Macros}). Most compilers do not include information
1771about preprocessor macros in the debugging information if you specify
1772the @option{-g} flag alone, because this information is rather large.
1773Version 3.1 and later of @value{NGCC}, the @sc{gnu} C compiler,
1774provides macro information if you specify the options
1775@option{-gdwarf-2} and @option{-g3}; the former option requests
1776debugging information in the Dwarf 2 format, and the latter requests
1777``extra information''. In the future, we hope to find more compact
1778ways to represent macro information, so that it can be included with
1779@option{-g} alone.
1780
c906108c 1781@need 2000
6d2ebf8b 1782@node Starting
c906108c
SS
1783@section Starting your program
1784@cindex starting
1785@cindex running
1786
1787@table @code
1788@kindex run
41afff9a 1789@kindex r @r{(@code{run})}
c906108c
SS
1790@item run
1791@itemx r
7a292a7a
SS
1792Use the @code{run} command to start your program under @value{GDBN}.
1793You must first specify the program name (except on VxWorks) with an
1794argument to @value{GDBN} (@pxref{Invocation, ,Getting In and Out of
1795@value{GDBN}}), or by using the @code{file} or @code{exec-file} command
1796(@pxref{Files, ,Commands to specify files}).
c906108c
SS
1797
1798@end table
1799
c906108c
SS
1800If you are running your program in an execution environment that
1801supports processes, @code{run} creates an inferior process and makes
1802that process run your program. (In environments without processes,
1803@code{run} jumps to the start of your program.)
1804
1805The execution of a program is affected by certain information it
1806receives from its superior. @value{GDBN} provides ways to specify this
1807information, which you must do @emph{before} starting your program. (You
1808can change it after starting your program, but such changes only affect
1809your program the next time you start it.) This information may be
1810divided into four categories:
1811
1812@table @asis
1813@item The @emph{arguments.}
1814Specify the arguments to give your program as the arguments of the
1815@code{run} command. If a shell is available on your target, the shell
1816is used to pass the arguments, so that you may use normal conventions
1817(such as wildcard expansion or variable substitution) in describing
1818the arguments.
1819In Unix systems, you can control which shell is used with the
1820@code{SHELL} environment variable.
1821@xref{Arguments, ,Your program's arguments}.
1822
1823@item The @emph{environment.}
1824Your program normally inherits its environment from @value{GDBN}, but you can
1825use the @value{GDBN} commands @code{set environment} and @code{unset
1826environment} to change parts of the environment that affect
1827your program. @xref{Environment, ,Your program's environment}.
1828
1829@item The @emph{working directory.}
1830Your program inherits its working directory from @value{GDBN}. You can set
1831the @value{GDBN} working directory with the @code{cd} command in @value{GDBN}.
1832@xref{Working Directory, ,Your program's working directory}.
1833
1834@item The @emph{standard input and output.}
1835Your program normally uses the same device for standard input and
1836standard output as @value{GDBN} is using. You can redirect input and output
1837in the @code{run} command line, or you can use the @code{tty} command to
1838set a different device for your program.
1839@xref{Input/Output, ,Your program's input and output}.
1840
1841@cindex pipes
1842@emph{Warning:} While input and output redirection work, you cannot use
1843pipes to pass the output of the program you are debugging to another
1844program; if you attempt this, @value{GDBN} is likely to wind up debugging the
1845wrong program.
1846@end table
c906108c
SS
1847
1848When you issue the @code{run} command, your program begins to execute
1849immediately. @xref{Stopping, ,Stopping and continuing}, for discussion
1850of how to arrange for your program to stop. Once your program has
1851stopped, you may call functions in your program, using the @code{print}
1852or @code{call} commands. @xref{Data, ,Examining Data}.
1853
1854If the modification time of your symbol file has changed since the last
1855time @value{GDBN} read its symbols, @value{GDBN} discards its symbol
1856table, and reads it again. When it does this, @value{GDBN} tries to retain
1857your current breakpoints.
1858
4e8b0763
JB
1859@table @code
1860@kindex start
1861@item start
1862@cindex run to main procedure
1863The name of the main procedure can vary from language to language.
1864With C or C@t{++}, the main procedure name is always @code{main}, but
1865other languages such as Ada do not require a specific name for their
1866main procedure. The debugger provides a convenient way to start the
1867execution of the program and to stop at the beginning of the main
1868procedure, depending on the language used.
1869
1870The @samp{start} command does the equivalent of setting a temporary
1871breakpoint at the beginning of the main procedure and then invoking
1872the @samp{run} command.
1873
f018e82f
EZ
1874@cindex elaboration phase
1875Some programs contain an @dfn{elaboration} phase where some startup code is
1876executed before the main procedure is called. This depends on the
1877languages used to write your program. In C@t{++}, for instance,
4e8b0763
JB
1878constructors for static and global objects are executed before
1879@code{main} is called. It is therefore possible that the debugger stops
1880before reaching the main procedure. However, the temporary breakpoint
1881will remain to halt execution.
1882
1883Specify the arguments to give to your program as arguments to the
1884@samp{start} command. These arguments will be given verbatim to the
1885underlying @samp{run} command. Note that the same arguments will be
1886reused if no argument is provided during subsequent calls to
1887@samp{start} or @samp{run}.
1888
1889It is sometimes necessary to debug the program during elaboration. In
1890these cases, using the @code{start} command would stop the execution of
1891your program too late, as the program would have already completed the
1892elaboration phase. Under these circumstances, insert breakpoints in your
1893elaboration code before running your program.
1894@end table
1895
6d2ebf8b 1896@node Arguments
c906108c
SS
1897@section Your program's arguments
1898
1899@cindex arguments (to your program)
1900The arguments to your program can be specified by the arguments of the
5d161b24 1901@code{run} command.
c906108c
SS
1902They are passed to a shell, which expands wildcard characters and
1903performs redirection of I/O, and thence to your program. Your
1904@code{SHELL} environment variable (if it exists) specifies what shell
1905@value{GDBN} uses. If you do not define @code{SHELL}, @value{GDBN} uses
d4f3574e
SS
1906the default shell (@file{/bin/sh} on Unix).
1907
1908On non-Unix systems, the program is usually invoked directly by
1909@value{GDBN}, which emulates I/O redirection via the appropriate system
1910calls, and the wildcard characters are expanded by the startup code of
1911the program, not by the shell.
c906108c
SS
1912
1913@code{run} with no arguments uses the same arguments used by the previous
1914@code{run}, or those set by the @code{set args} command.
1915
c906108c 1916@table @code
41afff9a 1917@kindex set args
c906108c
SS
1918@item set args
1919Specify the arguments to be used the next time your program is run. If
1920@code{set args} has no arguments, @code{run} executes your program
1921with no arguments. Once you have run your program with arguments,
1922using @code{set args} before the next @code{run} is the only way to run
1923it again without arguments.
1924
1925@kindex show args
1926@item show args
1927Show the arguments to give your program when it is started.
1928@end table
1929
6d2ebf8b 1930@node Environment
c906108c
SS
1931@section Your program's environment
1932
1933@cindex environment (of your program)
1934The @dfn{environment} consists of a set of environment variables and
1935their values. Environment variables conventionally record such things as
1936your user name, your home directory, your terminal type, and your search
1937path for programs to run. Usually you set up environment variables with
1938the shell and they are inherited by all the other programs you run. When
1939debugging, it can be useful to try running your program with a modified
1940environment without having to start @value{GDBN} over again.
1941
1942@table @code
1943@kindex path
1944@item path @var{directory}
1945Add @var{directory} to the front of the @code{PATH} environment variable
17cc6a06
EZ
1946(the search path for executables) that will be passed to your program.
1947The value of @code{PATH} used by @value{GDBN} does not change.
d4f3574e
SS
1948You may specify several directory names, separated by whitespace or by a
1949system-dependent separator character (@samp{:} on Unix, @samp{;} on
1950MS-DOS and MS-Windows). If @var{directory} is already in the path, it
1951is moved to the front, so it is searched sooner.
c906108c
SS
1952
1953You can use the string @samp{$cwd} to refer to whatever is the current
1954working directory at the time @value{GDBN} searches the path. If you
1955use @samp{.} instead, it refers to the directory where you executed the
1956@code{path} command. @value{GDBN} replaces @samp{.} in the
1957@var{directory} argument (with the current path) before adding
1958@var{directory} to the search path.
1959@c 'path' is explicitly nonrepeatable, but RMS points out it is silly to
1960@c document that, since repeating it would be a no-op.
1961
1962@kindex show paths
1963@item show paths
1964Display the list of search paths for executables (the @code{PATH}
1965environment variable).
1966
1967@kindex show environment
1968@item show environment @r{[}@var{varname}@r{]}
1969Print the value of environment variable @var{varname} to be given to
1970your program when it starts. If you do not supply @var{varname},
1971print the names and values of all environment variables to be given to
1972your program. You can abbreviate @code{environment} as @code{env}.
1973
1974@kindex set environment
53a5351d 1975@item set environment @var{varname} @r{[}=@var{value}@r{]}
c906108c
SS
1976Set environment variable @var{varname} to @var{value}. The value
1977changes for your program only, not for @value{GDBN} itself. @var{value} may
1978be any string; the values of environment variables are just strings, and
1979any interpretation is supplied by your program itself. The @var{value}
1980parameter is optional; if it is eliminated, the variable is set to a
1981null value.
1982@c "any string" here does not include leading, trailing
1983@c blanks. Gnu asks: does anyone care?
1984
1985For example, this command:
1986
474c8240 1987@smallexample
c906108c 1988set env USER = foo
474c8240 1989@end smallexample
c906108c
SS
1990
1991@noindent
d4f3574e 1992tells the debugged program, when subsequently run, that its user is named
c906108c
SS
1993@samp{foo}. (The spaces around @samp{=} are used for clarity here; they
1994are not actually required.)
1995
1996@kindex unset environment
1997@item unset environment @var{varname}
1998Remove variable @var{varname} from the environment to be passed to your
1999program. This is different from @samp{set env @var{varname} =};
2000@code{unset environment} removes the variable from the environment,
2001rather than assigning it an empty value.
2002@end table
2003
d4f3574e
SS
2004@emph{Warning:} On Unix systems, @value{GDBN} runs your program using
2005the shell indicated
c906108c
SS
2006by your @code{SHELL} environment variable if it exists (or
2007@code{/bin/sh} if not). If your @code{SHELL} variable names a shell
2008that runs an initialization file---such as @file{.cshrc} for C-shell, or
2009@file{.bashrc} for BASH---any variables you set in that file affect
2010your program. You may wish to move setting of environment variables to
2011files that are only run when you sign on, such as @file{.login} or
2012@file{.profile}.
2013
6d2ebf8b 2014@node Working Directory
c906108c
SS
2015@section Your program's working directory
2016
2017@cindex working directory (of your program)
2018Each time you start your program with @code{run}, it inherits its
2019working directory from the current working directory of @value{GDBN}.
2020The @value{GDBN} working directory is initially whatever it inherited
2021from its parent process (typically the shell), but you can specify a new
2022working directory in @value{GDBN} with the @code{cd} command.
2023
2024The @value{GDBN} working directory also serves as a default for the commands
2025that specify files for @value{GDBN} to operate on. @xref{Files, ,Commands to
2026specify files}.
2027
2028@table @code
2029@kindex cd
721c2651 2030@cindex change working directory
c906108c
SS
2031@item cd @var{directory}
2032Set the @value{GDBN} working directory to @var{directory}.
2033
2034@kindex pwd
2035@item pwd
2036Print the @value{GDBN} working directory.
2037@end table
2038
60bf7e09
EZ
2039It is generally impossible to find the current working directory of
2040the process being debugged (since a program can change its directory
2041during its run). If you work on a system where @value{GDBN} is
2042configured with the @file{/proc} support, you can use the @code{info
2043proc} command (@pxref{SVR4 Process Information}) to find out the
2044current working directory of the debuggee.
2045
6d2ebf8b 2046@node Input/Output
c906108c
SS
2047@section Your program's input and output
2048
2049@cindex redirection
2050@cindex i/o
2051@cindex terminal
2052By default, the program you run under @value{GDBN} does input and output to
5d161b24 2053the same terminal that @value{GDBN} uses. @value{GDBN} switches the terminal
c906108c
SS
2054to its own terminal modes to interact with you, but it records the terminal
2055modes your program was using and switches back to them when you continue
2056running your program.
2057
2058@table @code
2059@kindex info terminal
2060@item info terminal
2061Displays information recorded by @value{GDBN} about the terminal modes your
2062program is using.
2063@end table
2064
2065You can redirect your program's input and/or output using shell
2066redirection with the @code{run} command. For example,
2067
474c8240 2068@smallexample
c906108c 2069run > outfile
474c8240 2070@end smallexample
c906108c
SS
2071
2072@noindent
2073starts your program, diverting its output to the file @file{outfile}.
2074
2075@kindex tty
2076@cindex controlling terminal
2077Another way to specify where your program should do input and output is
2078with the @code{tty} command. This command accepts a file name as
2079argument, and causes this file to be the default for future @code{run}
2080commands. It also resets the controlling terminal for the child
2081process, for future @code{run} commands. For example,
2082
474c8240 2083@smallexample
c906108c 2084tty /dev/ttyb
474c8240 2085@end smallexample
c906108c
SS
2086
2087@noindent
2088directs that processes started with subsequent @code{run} commands
2089default to do input and output on the terminal @file{/dev/ttyb} and have
2090that as their controlling terminal.
2091
2092An explicit redirection in @code{run} overrides the @code{tty} command's
2093effect on the input/output device, but not its effect on the controlling
2094terminal.
2095
2096When you use the @code{tty} command or redirect input in the @code{run}
2097command, only the input @emph{for your program} is affected. The input
2098for @value{GDBN} still comes from your terminal.
2099
6d2ebf8b 2100@node Attach
c906108c
SS
2101@section Debugging an already-running process
2102@kindex attach
2103@cindex attach
2104
2105@table @code
2106@item attach @var{process-id}
2107This command attaches to a running process---one that was started
2108outside @value{GDBN}. (@code{info files} shows your active
2109targets.) The command takes as argument a process ID. The usual way to
09d4efe1 2110find out the @var{process-id} of a Unix process is with the @code{ps} utility,
c906108c
SS
2111or with the @samp{jobs -l} shell command.
2112
2113@code{attach} does not repeat if you press @key{RET} a second time after
2114executing the command.
2115@end table
2116
2117To use @code{attach}, your program must be running in an environment
2118which supports processes; for example, @code{attach} does not work for
2119programs on bare-board targets that lack an operating system. You must
2120also have permission to send the process a signal.
2121
2122When you use @code{attach}, the debugger finds the program running in
2123the process first by looking in the current working directory, then (if
2124the program is not found) by using the source file search path
2125(@pxref{Source Path, ,Specifying source directories}). You can also use
2126the @code{file} command to load the program. @xref{Files, ,Commands to
2127Specify Files}.
2128
2129The first thing @value{GDBN} does after arranging to debug the specified
2130process is to stop it. You can examine and modify an attached process
53a5351d
JM
2131with all the @value{GDBN} commands that are ordinarily available when
2132you start processes with @code{run}. You can insert breakpoints; you
2133can step and continue; you can modify storage. If you would rather the
2134process continue running, you may use the @code{continue} command after
c906108c
SS
2135attaching @value{GDBN} to the process.
2136
2137@table @code
2138@kindex detach
2139@item detach
2140When you have finished debugging the attached process, you can use the
2141@code{detach} command to release it from @value{GDBN} control. Detaching
2142the process continues its execution. After the @code{detach} command,
2143that process and @value{GDBN} become completely independent once more, and you
2144are ready to @code{attach} another process or start one with @code{run}.
2145@code{detach} does not repeat if you press @key{RET} again after
2146executing the command.
2147@end table
2148
2149If you exit @value{GDBN} or use the @code{run} command while you have an
2150attached process, you kill that process. By default, @value{GDBN} asks
2151for confirmation if you try to do either of these things; you can
2152control whether or not you need to confirm by using the @code{set
2153confirm} command (@pxref{Messages/Warnings, ,Optional warnings and
2154messages}).
2155
6d2ebf8b 2156@node Kill Process
c906108c 2157@section Killing the child process
c906108c
SS
2158
2159@table @code
2160@kindex kill
2161@item kill
2162Kill the child process in which your program is running under @value{GDBN}.
2163@end table
2164
2165This command is useful if you wish to debug a core dump instead of a
2166running process. @value{GDBN} ignores any core dump file while your program
2167is running.
2168
2169On some operating systems, a program cannot be executed outside @value{GDBN}
2170while you have breakpoints set on it inside @value{GDBN}. You can use the
2171@code{kill} command in this situation to permit running your program
2172outside the debugger.
2173
2174The @code{kill} command is also useful if you wish to recompile and
2175relink your program, since on many systems it is impossible to modify an
2176executable file while it is running in a process. In this case, when you
2177next type @code{run}, @value{GDBN} notices that the file has changed, and
2178reads the symbol table again (while trying to preserve your current
2179breakpoint settings).
2180
6d2ebf8b 2181@node Threads
c906108c 2182@section Debugging programs with multiple threads
c906108c
SS
2183
2184@cindex threads of execution
2185@cindex multiple threads
2186@cindex switching threads
2187In some operating systems, such as HP-UX and Solaris, a single program
2188may have more than one @dfn{thread} of execution. The precise semantics
2189of threads differ from one operating system to another, but in general
2190the threads of a single program are akin to multiple processes---except
2191that they share one address space (that is, they can all examine and
2192modify the same variables). On the other hand, each thread has its own
2193registers and execution stack, and perhaps private memory.
2194
2195@value{GDBN} provides these facilities for debugging multi-thread
2196programs:
2197
2198@itemize @bullet
2199@item automatic notification of new threads
2200@item @samp{thread @var{threadno}}, a command to switch among threads
2201@item @samp{info threads}, a command to inquire about existing threads
5d161b24 2202@item @samp{thread apply [@var{threadno}] [@var{all}] @var{args}},
c906108c
SS
2203a command to apply a command to a list of threads
2204@item thread-specific breakpoints
2205@end itemize
2206
c906108c
SS
2207@quotation
2208@emph{Warning:} These facilities are not yet available on every
2209@value{GDBN} configuration where the operating system supports threads.
2210If your @value{GDBN} does not support threads, these commands have no
2211effect. For example, a system without thread support shows no output
2212from @samp{info threads}, and always rejects the @code{thread} command,
2213like this:
2214
2215@smallexample
2216(@value{GDBP}) info threads
2217(@value{GDBP}) thread 1
2218Thread ID 1 not known. Use the "info threads" command to
2219see the IDs of currently known threads.
2220@end smallexample
2221@c FIXME to implementors: how hard would it be to say "sorry, this GDB
2222@c doesn't support threads"?
2223@end quotation
c906108c
SS
2224
2225@cindex focus of debugging
2226@cindex current thread
2227The @value{GDBN} thread debugging facility allows you to observe all
2228threads while your program runs---but whenever @value{GDBN} takes
2229control, one thread in particular is always the focus of debugging.
2230This thread is called the @dfn{current thread}. Debugging commands show
2231program information from the perspective of the current thread.
2232
41afff9a 2233@cindex @code{New} @var{systag} message
c906108c
SS
2234@cindex thread identifier (system)
2235@c FIXME-implementors!! It would be more helpful if the [New...] message
2236@c included GDB's numeric thread handle, so you could just go to that
2237@c thread without first checking `info threads'.
2238Whenever @value{GDBN} detects a new thread in your program, it displays
2239the target system's identification for the thread with a message in the
2240form @samp{[New @var{systag}]}. @var{systag} is a thread identifier
2241whose form varies depending on the particular system. For example, on
2242LynxOS, you might see
2243
474c8240 2244@smallexample
c906108c 2245[New process 35 thread 27]
474c8240 2246@end smallexample
c906108c
SS
2247
2248@noindent
2249when @value{GDBN} notices a new thread. In contrast, on an SGI system,
2250the @var{systag} is simply something like @samp{process 368}, with no
2251further qualifier.
2252
2253@c FIXME!! (1) Does the [New...] message appear even for the very first
2254@c thread of a program, or does it only appear for the
6ca652b0 2255@c second---i.e.@: when it becomes obvious we have a multithread
c906108c
SS
2256@c program?
2257@c (2) *Is* there necessarily a first thread always? Or do some
2258@c multithread systems permit starting a program with multiple
5d161b24 2259@c threads ab initio?
c906108c
SS
2260
2261@cindex thread number
2262@cindex thread identifier (GDB)
2263For debugging purposes, @value{GDBN} associates its own thread
2264number---always a single integer---with each thread in your program.
2265
2266@table @code
2267@kindex info threads
2268@item info threads
2269Display a summary of all threads currently in your
2270program. @value{GDBN} displays for each thread (in this order):
2271
2272@enumerate
09d4efe1
EZ
2273@item
2274the thread number assigned by @value{GDBN}
c906108c 2275
09d4efe1
EZ
2276@item
2277the target system's thread identifier (@var{systag})
c906108c 2278
09d4efe1
EZ
2279@item
2280the current stack frame summary for that thread
c906108c
SS
2281@end enumerate
2282
2283@noindent
2284An asterisk @samp{*} to the left of the @value{GDBN} thread number
2285indicates the current thread.
2286
5d161b24 2287For example,
c906108c
SS
2288@end table
2289@c end table here to get a little more width for example
2290
2291@smallexample
2292(@value{GDBP}) info threads
2293 3 process 35 thread 27 0x34e5 in sigpause ()
2294 2 process 35 thread 23 0x34e5 in sigpause ()
2295* 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8)
2296 at threadtest.c:68
2297@end smallexample
53a5351d
JM
2298
2299On HP-UX systems:
c906108c 2300
4644b6e3
EZ
2301@cindex debugging multithreaded programs (on HP-UX)
2302@cindex thread identifier (GDB), on HP-UX
c906108c
SS
2303For debugging purposes, @value{GDBN} associates its own thread
2304number---a small integer assigned in thread-creation order---with each
2305thread in your program.
2306
41afff9a
EZ
2307@cindex @code{New} @var{systag} message, on HP-UX
2308@cindex thread identifier (system), on HP-UX
c906108c
SS
2309@c FIXME-implementors!! It would be more helpful if the [New...] message
2310@c included GDB's numeric thread handle, so you could just go to that
2311@c thread without first checking `info threads'.
2312Whenever @value{GDBN} detects a new thread in your program, it displays
2313both @value{GDBN}'s thread number and the target system's identification for the thread with a message in the
2314form @samp{[New @var{systag}]}. @var{systag} is a thread identifier
2315whose form varies depending on the particular system. For example, on
2316HP-UX, you see
2317
474c8240 2318@smallexample
c906108c 2319[New thread 2 (system thread 26594)]
474c8240 2320@end smallexample
c906108c
SS
2321
2322@noindent
5d161b24 2323when @value{GDBN} notices a new thread.
c906108c
SS
2324
2325@table @code
4644b6e3 2326@kindex info threads (HP-UX)
c906108c
SS
2327@item info threads
2328Display a summary of all threads currently in your
2329program. @value{GDBN} displays for each thread (in this order):
2330
2331@enumerate
2332@item the thread number assigned by @value{GDBN}
2333
2334@item the target system's thread identifier (@var{systag})
2335
2336@item the current stack frame summary for that thread
2337@end enumerate
2338
2339@noindent
2340An asterisk @samp{*} to the left of the @value{GDBN} thread number
2341indicates the current thread.
2342
5d161b24 2343For example,
c906108c
SS
2344@end table
2345@c end table here to get a little more width for example
2346
474c8240 2347@smallexample
c906108c 2348(@value{GDBP}) info threads
6d2ebf8b
SS
2349 * 3 system thread 26607 worker (wptr=0x7b09c318 "@@") \@*
2350 at quicksort.c:137
2351 2 system thread 26606 0x7b0030d8 in __ksleep () \@*
2352 from /usr/lib/libc.2
2353 1 system thread 27905 0x7b003498 in _brk () \@*
2354 from /usr/lib/libc.2
474c8240 2355@end smallexample
c906108c 2356
c45da7e6
EZ
2357On Solaris, you can display more information about user threads with a
2358Solaris-specific command:
2359
2360@table @code
2361@item maint info sol-threads
2362@kindex maint info sol-threads
2363@cindex thread info (Solaris)
2364Display info on Solaris user threads.
2365@end table
2366
c906108c
SS
2367@table @code
2368@kindex thread @var{threadno}
2369@item thread @var{threadno}
2370Make thread number @var{threadno} the current thread. The command
2371argument @var{threadno} is the internal @value{GDBN} thread number, as
2372shown in the first field of the @samp{info threads} display.
2373@value{GDBN} responds by displaying the system identifier of the thread
2374you selected, and its current stack frame summary:
2375
2376@smallexample
2377@c FIXME!! This example made up; find a @value{GDBN} w/threads and get real one
2378(@value{GDBP}) thread 2
c906108c 2379[Switching to process 35 thread 23]
c906108c
SS
23800x34e5 in sigpause ()
2381@end smallexample
2382
2383@noindent
2384As with the @samp{[New @dots{}]} message, the form of the text after
2385@samp{Switching to} depends on your system's conventions for identifying
5d161b24 2386threads.
c906108c 2387
9c16f35a 2388@kindex thread apply
638ac427 2389@cindex apply command to several threads
c906108c
SS
2390@item thread apply [@var{threadno}] [@var{all}] @var{args}
2391The @code{thread apply} command allows you to apply a command to one or
2392more threads. Specify the numbers of the threads that you want affected
2393with the command argument @var{threadno}. @var{threadno} is the internal
2394@value{GDBN} thread number, as shown in the first field of the @samp{info
5d161b24
DB
2395threads} display. To apply a command to all threads, use
2396@code{thread apply all} @var{args}.
c906108c
SS
2397@end table
2398
2399@cindex automatic thread selection
2400@cindex switching threads automatically
2401@cindex threads, automatic switching
2402Whenever @value{GDBN} stops your program, due to a breakpoint or a
2403signal, it automatically selects the thread where that breakpoint or
2404signal happened. @value{GDBN} alerts you to the context switch with a
2405message of the form @samp{[Switching to @var{systag}]} to identify the
2406thread.
2407
2408@xref{Thread Stops,,Stopping and starting multi-thread programs}, for
2409more information about how @value{GDBN} behaves when you stop and start
2410programs with multiple threads.
2411
2412@xref{Set Watchpoints,,Setting watchpoints}, for information about
2413watchpoints in programs with multiple threads.
c906108c 2414
6d2ebf8b 2415@node Processes
c906108c
SS
2416@section Debugging programs with multiple processes
2417
2418@cindex fork, debugging programs which call
2419@cindex multiple processes
2420@cindex processes, multiple
53a5351d
JM
2421On most systems, @value{GDBN} has no special support for debugging
2422programs which create additional processes using the @code{fork}
2423function. When a program forks, @value{GDBN} will continue to debug the
2424parent process and the child process will run unimpeded. If you have
2425set a breakpoint in any code which the child then executes, the child
2426will get a @code{SIGTRAP} signal which (unless it catches the signal)
2427will cause it to terminate.
c906108c
SS
2428
2429However, if you want to debug the child process there is a workaround
2430which isn't too painful. Put a call to @code{sleep} in the code which
2431the child process executes after the fork. It may be useful to sleep
2432only if a certain environment variable is set, or a certain file exists,
2433so that the delay need not occur when you don't want to run @value{GDBN}
2434on the child. While the child is sleeping, use the @code{ps} program to
2435get its process ID. Then tell @value{GDBN} (a new invocation of
2436@value{GDBN} if you are also debugging the parent process) to attach to
d4f3574e 2437the child process (@pxref{Attach}). From that point on you can debug
c906108c 2438the child process just like any other process which you attached to.
c906108c 2439
b51970ac
DJ
2440On some systems, @value{GDBN} provides support for debugging programs that
2441create additional processes using the @code{fork} or @code{vfork} functions.
2442Currently, the only platforms with this feature are HP-UX (11.x and later
2443only?) and GNU/Linux (kernel version 2.5.60 and later).
c906108c
SS
2444
2445By default, when a program forks, @value{GDBN} will continue to debug
2446the parent process and the child process will run unimpeded.
2447
2448If you want to follow the child process instead of the parent process,
2449use the command @w{@code{set follow-fork-mode}}.
2450
2451@table @code
2452@kindex set follow-fork-mode
2453@item set follow-fork-mode @var{mode}
2454Set the debugger response to a program call of @code{fork} or
2455@code{vfork}. A call to @code{fork} or @code{vfork} creates a new
9c16f35a 2456process. The @var{mode} argument can be:
c906108c
SS
2457
2458@table @code
2459@item parent
2460The original process is debugged after a fork. The child process runs
2df3850c 2461unimpeded. This is the default.
c906108c
SS
2462
2463@item child
2464The new process is debugged after a fork. The parent process runs
2465unimpeded.
2466
c906108c
SS
2467@end table
2468
9c16f35a 2469@kindex show follow-fork-mode
c906108c 2470@item show follow-fork-mode
2df3850c 2471Display the current debugger response to a @code{fork} or @code{vfork} call.
c906108c
SS
2472@end table
2473
2474If you ask to debug a child process and a @code{vfork} is followed by an
2475@code{exec}, @value{GDBN} executes the new target up to the first
2476breakpoint in the new target. If you have a breakpoint set on
2477@code{main} in your original program, the breakpoint will also be set on
2478the child process's @code{main}.
2479
2480When a child process is spawned by @code{vfork}, you cannot debug the
2481child or parent until an @code{exec} call completes.
2482
2483If you issue a @code{run} command to @value{GDBN} after an @code{exec}
2484call executes, the new target restarts. To restart the parent process,
2485use the @code{file} command with the parent executable name as its
2486argument.
2487
2488You can use the @code{catch} command to make @value{GDBN} stop whenever
2489a @code{fork}, @code{vfork}, or @code{exec} call is made. @xref{Set
2490Catchpoints, ,Setting catchpoints}.
c906108c 2491
6d2ebf8b 2492@node Stopping
c906108c
SS
2493@chapter Stopping and Continuing
2494
2495The principal purposes of using a debugger are so that you can stop your
2496program before it terminates; or so that, if your program runs into
2497trouble, you can investigate and find out why.
2498
7a292a7a
SS
2499Inside @value{GDBN}, your program may stop for any of several reasons,
2500such as a signal, a breakpoint, or reaching a new line after a
2501@value{GDBN} command such as @code{step}. You may then examine and
2502change variables, set new breakpoints or remove old ones, and then
2503continue execution. Usually, the messages shown by @value{GDBN} provide
2504ample explanation of the status of your program---but you can also
2505explicitly request this information at any time.
c906108c
SS
2506
2507@table @code
2508@kindex info program
2509@item info program
2510Display information about the status of your program: whether it is
7a292a7a 2511running or not, what process it is, and why it stopped.
c906108c
SS
2512@end table
2513
2514@menu
2515* Breakpoints:: Breakpoints, watchpoints, and catchpoints
2516* Continuing and Stepping:: Resuming execution
c906108c 2517* Signals:: Signals
c906108c 2518* Thread Stops:: Stopping and starting multi-thread programs
c906108c
SS
2519@end menu
2520
6d2ebf8b 2521@node Breakpoints
c906108c
SS
2522@section Breakpoints, watchpoints, and catchpoints
2523
2524@cindex breakpoints
2525A @dfn{breakpoint} makes your program stop whenever a certain point in
2526the program is reached. For each breakpoint, you can add conditions to
2527control in finer detail whether your program stops. You can set
2528breakpoints with the @code{break} command and its variants (@pxref{Set
2529Breaks, ,Setting breakpoints}), to specify the place where your program
2530should stop by line number, function name or exact address in the
2531program.
2532
09d4efe1
EZ
2533On some systems, you can set breakpoints in shared libraries before
2534the executable is run. There is a minor limitation on HP-UX systems:
2535you must wait until the executable is run in order to set breakpoints
2536in shared library routines that are not called directly by the program
2537(for example, routines that are arguments in a @code{pthread_create}
2538call).
c906108c
SS
2539
2540@cindex watchpoints
2541@cindex memory tracing
2542@cindex breakpoint on memory address
2543@cindex breakpoint on variable modification
2544A @dfn{watchpoint} is a special breakpoint that stops your program
2545when the value of an expression changes. You must use a different
2546command to set watchpoints (@pxref{Set Watchpoints, ,Setting
2547watchpoints}), but aside from that, you can manage a watchpoint like
2548any other breakpoint: you enable, disable, and delete both breakpoints
2549and watchpoints using the same commands.
2550
2551You can arrange to have values from your program displayed automatically
2552whenever @value{GDBN} stops at a breakpoint. @xref{Auto Display,,
2553Automatic display}.
2554
2555@cindex catchpoints
2556@cindex breakpoint on events
2557A @dfn{catchpoint} is another special breakpoint that stops your program
b37052ae 2558when a certain kind of event occurs, such as the throwing of a C@t{++}
c906108c
SS
2559exception or the loading of a library. As with watchpoints, you use a
2560different command to set a catchpoint (@pxref{Set Catchpoints, ,Setting
2561catchpoints}), but aside from that, you can manage a catchpoint like any
2562other breakpoint. (To stop when your program receives a signal, use the
d4f3574e 2563@code{handle} command; see @ref{Signals, ,Signals}.)
c906108c
SS
2564
2565@cindex breakpoint numbers
2566@cindex numbers for breakpoints
2567@value{GDBN} assigns a number to each breakpoint, watchpoint, or
2568catchpoint when you create it; these numbers are successive integers
2569starting with one. In many of the commands for controlling various
2570features of breakpoints you use the breakpoint number to say which
2571breakpoint you want to change. Each breakpoint may be @dfn{enabled} or
2572@dfn{disabled}; if disabled, it has no effect on your program until you
2573enable it again.
2574
c5394b80
JM
2575@cindex breakpoint ranges
2576@cindex ranges of breakpoints
2577Some @value{GDBN} commands accept a range of breakpoints on which to
2578operate. A breakpoint range is either a single breakpoint number, like
2579@samp{5}, or two such numbers, in increasing order, separated by a
2580hyphen, like @samp{5-7}. When a breakpoint range is given to a command,
2581all breakpoint in that range are operated on.
2582
c906108c
SS
2583@menu
2584* Set Breaks:: Setting breakpoints
2585* Set Watchpoints:: Setting watchpoints
2586* Set Catchpoints:: Setting catchpoints
2587* Delete Breaks:: Deleting breakpoints
2588* Disabling:: Disabling breakpoints
2589* Conditions:: Break conditions
2590* Break Commands:: Breakpoint command lists
c906108c 2591* Breakpoint Menus:: Breakpoint menus
d4f3574e 2592* Error in Breakpoints:: ``Cannot insert breakpoints''
e4d5f7e1 2593* Breakpoint related warnings:: ``Breakpoint address adjusted...''
c906108c
SS
2594@end menu
2595
6d2ebf8b 2596@node Set Breaks
c906108c
SS
2597@subsection Setting breakpoints
2598
5d161b24 2599@c FIXME LMB what does GDB do if no code on line of breakpt?
c906108c
SS
2600@c consider in particular declaration with/without initialization.
2601@c
2602@c FIXME 2 is there stuff on this already? break at fun start, already init?
2603
2604@kindex break
41afff9a
EZ
2605@kindex b @r{(@code{break})}
2606@vindex $bpnum@r{, convenience variable}
c906108c
SS
2607@cindex latest breakpoint
2608Breakpoints are set with the @code{break} command (abbreviated
5d161b24 2609@code{b}). The debugger convenience variable @samp{$bpnum} records the
f3b28801 2610number of the breakpoint you've set most recently; see @ref{Convenience
c906108c
SS
2611Vars,, Convenience variables}, for a discussion of what you can do with
2612convenience variables.
2613
2614You have several ways to say where the breakpoint should go.
2615
2616@table @code
2617@item break @var{function}
5d161b24 2618Set a breakpoint at entry to function @var{function}.
c906108c 2619When using source languages that permit overloading of symbols, such as
b37052ae 2620C@t{++}, @var{function} may refer to more than one possible place to break.
c906108c 2621@xref{Breakpoint Menus,,Breakpoint menus}, for a discussion of that situation.
c906108c
SS
2622
2623@item break +@var{offset}
2624@itemx break -@var{offset}
2625Set a breakpoint some number of lines forward or back from the position
d4f3574e 2626at which execution stopped in the currently selected @dfn{stack frame}.
2df3850c 2627(@xref{Frames, ,Frames}, for a description of stack frames.)
c906108c
SS
2628
2629@item break @var{linenum}
2630Set a breakpoint at line @var{linenum} in the current source file.
d4f3574e
SS
2631The current source file is the last file whose source text was printed.
2632The breakpoint will stop your program just before it executes any of the
c906108c
SS
2633code on that line.
2634
2635@item break @var{filename}:@var{linenum}
2636Set a breakpoint at line @var{linenum} in source file @var{filename}.
2637
2638@item break @var{filename}:@var{function}
2639Set a breakpoint at entry to function @var{function} found in file
2640@var{filename}. Specifying a file name as well as a function name is
2641superfluous except when multiple files contain similarly named
2642functions.
2643
2644@item break *@var{address}
2645Set a breakpoint at address @var{address}. You can use this to set
2646breakpoints in parts of your program which do not have debugging
2647information or source files.
2648
2649@item break
2650When called without any arguments, @code{break} sets a breakpoint at
2651the next instruction to be executed in the selected stack frame
2652(@pxref{Stack, ,Examining the Stack}). In any selected frame but the
2653innermost, this makes your program stop as soon as control
2654returns to that frame. This is similar to the effect of a
2655@code{finish} command in the frame inside the selected frame---except
2656that @code{finish} does not leave an active breakpoint. If you use
2657@code{break} without an argument in the innermost frame, @value{GDBN} stops
2658the next time it reaches the current location; this may be useful
2659inside loops.
2660
2661@value{GDBN} normally ignores breakpoints when it resumes execution, until at
2662least one instruction has been executed. If it did not do this, you
2663would be unable to proceed past a breakpoint without first disabling the
2664breakpoint. This rule applies whether or not the breakpoint already
2665existed when your program stopped.
2666
2667@item break @dots{} if @var{cond}
2668Set a breakpoint with condition @var{cond}; evaluate the expression
2669@var{cond} each time the breakpoint is reached, and stop only if the
2670value is nonzero---that is, if @var{cond} evaluates as true.
2671@samp{@dots{}} stands for one of the possible arguments described
2672above (or no argument) specifying where to break. @xref{Conditions,
2673,Break conditions}, for more information on breakpoint conditions.
2674
2675@kindex tbreak
2676@item tbreak @var{args}
2677Set a breakpoint enabled only for one stop. @var{args} are the
2678same as for the @code{break} command, and the breakpoint is set in the same
2679way, but the breakpoint is automatically deleted after the first time your
2680program stops there. @xref{Disabling, ,Disabling breakpoints}.
2681
c906108c 2682@kindex hbreak
ba04e063 2683@cindex hardware breakpoints
c906108c 2684@item hbreak @var{args}
d4f3574e
SS
2685Set a hardware-assisted breakpoint. @var{args} are the same as for the
2686@code{break} command and the breakpoint is set in the same way, but the
c906108c
SS
2687breakpoint requires hardware support and some target hardware may not
2688have this support. The main purpose of this is EPROM/ROM code
d4f3574e
SS
2689debugging, so you can set a breakpoint at an instruction without
2690changing the instruction. This can be used with the new trap-generation
09d4efe1 2691provided by SPARClite DSU and most x86-based targets. These targets
d4f3574e
SS
2692will generate traps when a program accesses some data or instruction
2693address that is assigned to the debug registers. However the hardware
2694breakpoint registers can take a limited number of breakpoints. For
2695example, on the DSU, only two data breakpoints can be set at a time, and
2696@value{GDBN} will reject this command if more than two are used. Delete
2697or disable unused hardware breakpoints before setting new ones
2698(@pxref{Disabling, ,Disabling}). @xref{Conditions, ,Break conditions}.
9c16f35a
EZ
2699For remote targets, you can restrict the number of hardware
2700breakpoints @value{GDBN} will use, see @ref{set remote
2701hardware-breakpoint-limit}.
501eef12 2702
c906108c
SS
2703
2704@kindex thbreak
2705@item thbreak @var{args}
2706Set a hardware-assisted breakpoint enabled only for one stop. @var{args}
2707are the same as for the @code{hbreak} command and the breakpoint is set in
5d161b24 2708the same way. However, like the @code{tbreak} command,
c906108c
SS
2709the breakpoint is automatically deleted after the
2710first time your program stops there. Also, like the @code{hbreak}
5d161b24
DB
2711command, the breakpoint requires hardware support and some target hardware
2712may not have this support. @xref{Disabling, ,Disabling breakpoints}.
d4f3574e 2713See also @ref{Conditions, ,Break conditions}.
c906108c
SS
2714
2715@kindex rbreak
2716@cindex regular expression
c45da7e6
EZ
2717@cindex breakpoints in functions matching a regexp
2718@cindex set breakpoints in many functions
c906108c 2719@item rbreak @var{regex}
c906108c 2720Set breakpoints on all functions matching the regular expression
11cf8741
JM
2721@var{regex}. This command sets an unconditional breakpoint on all
2722matches, printing a list of all breakpoints it set. Once these
2723breakpoints are set, they are treated just like the breakpoints set with
2724the @code{break} command. You can delete them, disable them, or make
2725them conditional the same way as any other breakpoint.
2726
2727The syntax of the regular expression is the standard one used with tools
2728like @file{grep}. Note that this is different from the syntax used by
2729shells, so for instance @code{foo*} matches all functions that include
2730an @code{fo} followed by zero or more @code{o}s. There is an implicit
2731@code{.*} leading and trailing the regular expression you supply, so to
2732match only functions that begin with @code{foo}, use @code{^foo}.
c906108c 2733
f7dc1244 2734@cindex non-member C@t{++} functions, set breakpoint in
b37052ae 2735When debugging C@t{++} programs, @code{rbreak} is useful for setting
c906108c
SS
2736breakpoints on overloaded functions that are not members of any special
2737classes.
c906108c 2738
f7dc1244
EZ
2739@cindex set breakpoints on all functions
2740The @code{rbreak} command can be used to set breakpoints in
2741@strong{all} the functions in a program, like this:
2742
2743@smallexample
2744(@value{GDBP}) rbreak .
2745@end smallexample
2746
c906108c
SS
2747@kindex info breakpoints
2748@cindex @code{$_} and @code{info breakpoints}
2749@item info breakpoints @r{[}@var{n}@r{]}
2750@itemx info break @r{[}@var{n}@r{]}
2751@itemx info watchpoints @r{[}@var{n}@r{]}
2752Print a table of all breakpoints, watchpoints, and catchpoints set and
2753not deleted, with the following columns for each breakpoint:
2754
2755@table @emph
2756@item Breakpoint Numbers
2757@item Type
2758Breakpoint, watchpoint, or catchpoint.
2759@item Disposition
2760Whether the breakpoint is marked to be disabled or deleted when hit.
2761@item Enabled or Disabled
2762Enabled breakpoints are marked with @samp{y}. @samp{n} marks breakpoints
2763that are not enabled.
2764@item Address
2650777c
JJ
2765Where the breakpoint is in your program, as a memory address. If the
2766breakpoint is pending (see below for details) on a future load of a shared library, the address
2767will be listed as @samp{<PENDING>}.
c906108c
SS
2768@item What
2769Where the breakpoint is in the source for your program, as a file and
2650777c
JJ
2770line number. For a pending breakpoint, the original string passed to
2771the breakpoint command will be listed as it cannot be resolved until
2772the appropriate shared library is loaded in the future.
c906108c
SS
2773@end table
2774
2775@noindent
2776If a breakpoint is conditional, @code{info break} shows the condition on
2777the line following the affected breakpoint; breakpoint commands, if any,
2650777c
JJ
2778are listed after that. A pending breakpoint is allowed to have a condition
2779specified for it. The condition is not parsed for validity until a shared
2780library is loaded that allows the pending breakpoint to resolve to a
2781valid location.
c906108c
SS
2782
2783@noindent
2784@code{info break} with a breakpoint
2785number @var{n} as argument lists only that breakpoint. The
2786convenience variable @code{$_} and the default examining-address for
2787the @code{x} command are set to the address of the last breakpoint
5d161b24 2788listed (@pxref{Memory, ,Examining memory}).
c906108c
SS
2789
2790@noindent
2791@code{info break} displays a count of the number of times the breakpoint
2792has been hit. This is especially useful in conjunction with the
2793@code{ignore} command. You can ignore a large number of breakpoint
2794hits, look at the breakpoint info to see how many times the breakpoint
2795was hit, and then run again, ignoring one less than that number. This
2796will get you quickly to the last hit of that breakpoint.
2797@end table
2798
2799@value{GDBN} allows you to set any number of breakpoints at the same place in
2800your program. There is nothing silly or meaningless about this. When
2801the breakpoints are conditional, this is even useful
2802(@pxref{Conditions, ,Break conditions}).
2803
2650777c 2804@cindex pending breakpoints
dd79a6cf
JJ
2805If a specified breakpoint location cannot be found, it may be due to the fact
2806that the location is in a shared library that is yet to be loaded. In such
2807a case, you may want @value{GDBN} to create a special breakpoint (known as
2808a @dfn{pending breakpoint}) that
2809attempts to resolve itself in the future when an appropriate shared library
2810gets loaded.
2811
2812Pending breakpoints are useful to set at the start of your
2650777c
JJ
2813@value{GDBN} session for locations that you know will be dynamically loaded
2814later by the program being debugged. When shared libraries are loaded,
dd79a6cf
JJ
2815a check is made to see if the load resolves any pending breakpoint locations.
2816If a pending breakpoint location gets resolved,
2817a regular breakpoint is created and the original pending breakpoint is removed.
2818
2819@value{GDBN} provides some additional commands for controlling pending
2820breakpoint support:
2821
2822@kindex set breakpoint pending
2823@kindex show breakpoint pending
2824@table @code
2825@item set breakpoint pending auto
2826This is the default behavior. When @value{GDBN} cannot find the breakpoint
2827location, it queries you whether a pending breakpoint should be created.
2828
2829@item set breakpoint pending on
2830This indicates that an unrecognized breakpoint location should automatically
2831result in a pending breakpoint being created.
2832
2833@item set breakpoint pending off
2834This indicates that pending breakpoints are not to be created. Any
2835unrecognized breakpoint location results in an error. This setting does
2836not affect any pending breakpoints previously created.
2837
2838@item show breakpoint pending
2839Show the current behavior setting for creating pending breakpoints.
2840@end table
2650777c 2841
649e03f6
RM
2842@cindex operations allowed on pending breakpoints
2843Normal breakpoint operations apply to pending breakpoints as well. You may
2844specify a condition for a pending breakpoint and/or commands to run when the
2650777c
JJ
2845breakpoint is reached. You can also enable or disable
2846the pending breakpoint. When you specify a condition for a pending breakpoint,
2847the parsing of the condition will be deferred until the point where the
2848pending breakpoint location is resolved. Disabling a pending breakpoint
2849tells @value{GDBN} to not attempt to resolve the breakpoint on any subsequent
2850shared library load. When a pending breakpoint is re-enabled,
649e03f6 2851@value{GDBN} checks to see if the location is already resolved.
2650777c
JJ
2852This is done because any number of shared library loads could have
2853occurred since the time the breakpoint was disabled and one or more
2854of these loads could resolve the location.
2855
c906108c
SS
2856@cindex negative breakpoint numbers
2857@cindex internal @value{GDBN} breakpoints
eb12ee30
AC
2858@value{GDBN} itself sometimes sets breakpoints in your program for
2859special purposes, such as proper handling of @code{longjmp} (in C
2860programs). These internal breakpoints are assigned negative numbers,
2861starting with @code{-1}; @samp{info breakpoints} does not display them.
c906108c 2862You can see these breakpoints with the @value{GDBN} maintenance command
eb12ee30 2863@samp{maint info breakpoints} (@pxref{maint info breakpoints}).
c906108c
SS
2864
2865
6d2ebf8b 2866@node Set Watchpoints
c906108c
SS
2867@subsection Setting watchpoints
2868
2869@cindex setting watchpoints
c906108c
SS
2870You can use a watchpoint to stop execution whenever the value of an
2871expression changes, without having to predict a particular place where
2872this may happen.
2873
82f2d802
EZ
2874@cindex software watchpoints
2875@cindex hardware watchpoints
c906108c 2876Depending on your system, watchpoints may be implemented in software or
2df3850c 2877hardware. @value{GDBN} does software watchpointing by single-stepping your
c906108c
SS
2878program and testing the variable's value each time, which is hundreds of
2879times slower than normal execution. (But this may still be worth it, to
2880catch errors where you have no clue what part of your program is the
2881culprit.)
2882
82f2d802
EZ
2883On some systems, such as HP-UX, @sc{gnu}/Linux and most other
2884x86-based targets, @value{GDBN} includes support for hardware
2885watchpoints, which do not slow down the running of your program.
c906108c
SS
2886
2887@table @code
2888@kindex watch
2889@item watch @var{expr}
2890Set a watchpoint for an expression. @value{GDBN} will break when @var{expr}
2891is written into by the program and its value changes.
2892
2893@kindex rwatch
2894@item rwatch @var{expr}
09d4efe1
EZ
2895Set a watchpoint that will break when the value of @var{expr} is read
2896by the program.
c906108c
SS
2897
2898@kindex awatch
2899@item awatch @var{expr}
09d4efe1
EZ
2900Set a watchpoint that will break when @var{expr} is either read from
2901or written into by the program.
c906108c
SS
2902
2903@kindex info watchpoints
2904@item info watchpoints
2905This command prints a list of watchpoints, breakpoints, and catchpoints;
09d4efe1 2906it is the same as @code{info break} (@pxref{Set Breaks}).
c906108c
SS
2907@end table
2908
2909@value{GDBN} sets a @dfn{hardware watchpoint} if possible. Hardware
2910watchpoints execute very quickly, and the debugger reports a change in
2911value at the exact instruction where the change occurs. If @value{GDBN}
2912cannot set a hardware watchpoint, it sets a software watchpoint, which
2913executes more slowly and reports the change in value at the next
82f2d802
EZ
2914@emph{statement}, not the instruction, after the change occurs.
2915
82f2d802
EZ
2916@cindex use only software watchpoints
2917You can force @value{GDBN} to use only software watchpoints with the
2918@kbd{set can-use-hw-watchpoints 0} command. With this variable set to
2919zero, @value{GDBN} will never try to use hardware watchpoints, even if
2920the underlying system supports them. (Note that hardware-assisted
2921watchpoints that were set @emph{before} setting
2922@code{can-use-hw-watchpoints} to zero will still use the hardware
2923mechanism of watching expressiion values.)
c906108c 2924
9c16f35a
EZ
2925@table @code
2926@item set can-use-hw-watchpoints
2927@kindex set can-use-hw-watchpoints
2928Set whether or not to use hardware watchpoints.
2929
2930@item show can-use-hw-watchpoints
2931@kindex show can-use-hw-watchpoints
2932Show the current mode of using hardware watchpoints.
2933@end table
2934
2935For remote targets, you can restrict the number of hardware
2936watchpoints @value{GDBN} will use, see @ref{set remote
2937hardware-breakpoint-limit}.
2938
c906108c
SS
2939When you issue the @code{watch} command, @value{GDBN} reports
2940
474c8240 2941@smallexample
c906108c 2942Hardware watchpoint @var{num}: @var{expr}
474c8240 2943@end smallexample
c906108c
SS
2944
2945@noindent
2946if it was able to set a hardware watchpoint.
2947
7be570e7
JM
2948Currently, the @code{awatch} and @code{rwatch} commands can only set
2949hardware watchpoints, because accesses to data that don't change the
2950value of the watched expression cannot be detected without examining
2951every instruction as it is being executed, and @value{GDBN} does not do
2952that currently. If @value{GDBN} finds that it is unable to set a
2953hardware breakpoint with the @code{awatch} or @code{rwatch} command, it
2954will print a message like this:
2955
2956@smallexample
2957Expression cannot be implemented with read/access watchpoint.
2958@end smallexample
2959
2960Sometimes, @value{GDBN} cannot set a hardware watchpoint because the
2961data type of the watched expression is wider than what a hardware
2962watchpoint on the target machine can handle. For example, some systems
2963can only watch regions that are up to 4 bytes wide; on such systems you
2964cannot set hardware watchpoints for an expression that yields a
2965double-precision floating-point number (which is typically 8 bytes
2966wide). As a work-around, it might be possible to break the large region
2967into a series of smaller ones and watch them with separate watchpoints.
2968
2969If you set too many hardware watchpoints, @value{GDBN} might be unable
2970to insert all of them when you resume the execution of your program.
2971Since the precise number of active watchpoints is unknown until such
2972time as the program is about to be resumed, @value{GDBN} might not be
2973able to warn you about this when you set the watchpoints, and the
2974warning will be printed only when the program is resumed:
2975
2976@smallexample
2977Hardware watchpoint @var{num}: Could not insert watchpoint
2978@end smallexample
2979
2980@noindent
2981If this happens, delete or disable some of the watchpoints.
2982
2983The SPARClite DSU will generate traps when a program accesses some data
2984or instruction address that is assigned to the debug registers. For the
2985data addresses, DSU facilitates the @code{watch} command. However the
2986hardware breakpoint registers can only take two data watchpoints, and
2987both watchpoints must be the same kind. For example, you can set two
2988watchpoints with @code{watch} commands, two with @code{rwatch} commands,
2989@strong{or} two with @code{awatch} commands, but you cannot set one
2990watchpoint with one command and the other with a different command.
c906108c
SS
2991@value{GDBN} will reject the command if you try to mix watchpoints.
2992Delete or disable unused watchpoint commands before setting new ones.
2993
2994If you call a function interactively using @code{print} or @code{call},
2df3850c 2995any watchpoints you have set will be inactive until @value{GDBN} reaches another
c906108c
SS
2996kind of breakpoint or the call completes.
2997
7be570e7
JM
2998@value{GDBN} automatically deletes watchpoints that watch local
2999(automatic) variables, or expressions that involve such variables, when
3000they go out of scope, that is, when the execution leaves the block in
3001which these variables were defined. In particular, when the program
3002being debugged terminates, @emph{all} local variables go out of scope,
3003and so only watchpoints that watch global variables remain set. If you
3004rerun the program, you will need to set all such watchpoints again. One
3005way of doing that would be to set a code breakpoint at the entry to the
3006@code{main} function and when it breaks, set all the watchpoints.
3007
c906108c
SS
3008@quotation
3009@cindex watchpoints and threads
3010@cindex threads and watchpoints
c906108c
SS
3011@emph{Warning:} In multi-thread programs, watchpoints have only limited
3012usefulness. With the current watchpoint implementation, @value{GDBN}
3013can only watch the value of an expression @emph{in a single thread}. If
3014you are confident that the expression can only change due to the current
3015thread's activity (and if you are also confident that no other thread
3016can become current), then you can use watchpoints as usual. However,
3017@value{GDBN} may not notice when a non-current thread's activity changes
3018the expression.
53a5351d 3019
d4f3574e 3020@c FIXME: this is almost identical to the previous paragraph.
53a5351d
JM
3021@emph{HP-UX Warning:} In multi-thread programs, software watchpoints
3022have only limited usefulness. If @value{GDBN} creates a software
3023watchpoint, it can only watch the value of an expression @emph{in a
3024single thread}. If you are confident that the expression can only
3025change due to the current thread's activity (and if you are also
3026confident that no other thread can become current), then you can use
3027software watchpoints as usual. However, @value{GDBN} may not notice
3028when a non-current thread's activity changes the expression. (Hardware
3029watchpoints, in contrast, watch an expression in all threads.)
c906108c 3030@end quotation
c906108c 3031
501eef12
AC
3032@xref{set remote hardware-watchpoint-limit}.
3033
6d2ebf8b 3034@node Set Catchpoints
c906108c 3035@subsection Setting catchpoints
d4f3574e 3036@cindex catchpoints, setting
c906108c
SS
3037@cindex exception handlers
3038@cindex event handling
3039
3040You can use @dfn{catchpoints} to cause the debugger to stop for certain
b37052ae 3041kinds of program events, such as C@t{++} exceptions or the loading of a
c906108c
SS
3042shared library. Use the @code{catch} command to set a catchpoint.
3043
3044@table @code
3045@kindex catch
3046@item catch @var{event}
3047Stop when @var{event} occurs. @var{event} can be any of the following:
3048@table @code
3049@item throw
4644b6e3 3050@cindex stop on C@t{++} exceptions
b37052ae 3051The throwing of a C@t{++} exception.
c906108c
SS
3052
3053@item catch
b37052ae 3054The catching of a C@t{++} exception.
c906108c
SS
3055
3056@item exec
4644b6e3 3057@cindex break on fork/exec
c906108c
SS
3058A call to @code{exec}. This is currently only available for HP-UX.
3059
3060@item fork
c906108c
SS
3061A call to @code{fork}. This is currently only available for HP-UX.
3062
3063@item vfork
c906108c
SS
3064A call to @code{vfork}. This is currently only available for HP-UX.
3065
3066@item load
3067@itemx load @var{libname}
4644b6e3 3068@cindex break on load/unload of shared library
c906108c
SS
3069The dynamic loading of any shared library, or the loading of the library
3070@var{libname}. This is currently only available for HP-UX.
3071
3072@item unload
3073@itemx unload @var{libname}
c906108c
SS
3074The unloading of any dynamically loaded shared library, or the unloading
3075of the library @var{libname}. This is currently only available for HP-UX.
3076@end table
3077
3078@item tcatch @var{event}
3079Set a catchpoint that is enabled only for one stop. The catchpoint is
3080automatically deleted after the first time the event is caught.
3081
3082@end table
3083
3084Use the @code{info break} command to list the current catchpoints.
3085
b37052ae 3086There are currently some limitations to C@t{++} exception handling
c906108c
SS
3087(@code{catch throw} and @code{catch catch}) in @value{GDBN}:
3088
3089@itemize @bullet
3090@item
3091If you call a function interactively, @value{GDBN} normally returns
3092control to you when the function has finished executing. If the call
3093raises an exception, however, the call may bypass the mechanism that
3094returns control to you and cause your program either to abort or to
3095simply continue running until it hits a breakpoint, catches a signal
3096that @value{GDBN} is listening for, or exits. This is the case even if
3097you set a catchpoint for the exception; catchpoints on exceptions are
3098disabled within interactive calls.
3099
3100@item
3101You cannot raise an exception interactively.
3102
3103@item
3104You cannot install an exception handler interactively.
3105@end itemize
3106
3107@cindex raise exceptions
3108Sometimes @code{catch} is not the best way to debug exception handling:
3109if you need to know exactly where an exception is raised, it is better to
3110stop @emph{before} the exception handler is called, since that way you
3111can see the stack before any unwinding takes place. If you set a
3112breakpoint in an exception handler instead, it may not be easy to find
3113out where the exception was raised.
3114
3115To stop just before an exception handler is called, you need some
b37052ae 3116knowledge of the implementation. In the case of @sc{gnu} C@t{++}, exceptions are
c906108c
SS
3117raised by calling a library function named @code{__raise_exception}
3118which has the following ANSI C interface:
3119
474c8240 3120@smallexample
c906108c 3121 /* @var{addr} is where the exception identifier is stored.
d4f3574e
SS
3122 @var{id} is the exception identifier. */
3123 void __raise_exception (void **addr, void *id);
474c8240 3124@end smallexample
c906108c
SS
3125
3126@noindent
3127To make the debugger catch all exceptions before any stack
3128unwinding takes place, set a breakpoint on @code{__raise_exception}
3129(@pxref{Breakpoints, ,Breakpoints; watchpoints; and exceptions}).
3130
3131With a conditional breakpoint (@pxref{Conditions, ,Break conditions})
3132that depends on the value of @var{id}, you can stop your program when
3133a specific exception is raised. You can use multiple conditional
3134breakpoints to stop your program when any of a number of exceptions are
3135raised.
3136
3137
6d2ebf8b 3138@node Delete Breaks
c906108c
SS
3139@subsection Deleting breakpoints
3140
3141@cindex clearing breakpoints, watchpoints, catchpoints
3142@cindex deleting breakpoints, watchpoints, catchpoints
3143It is often necessary to eliminate a breakpoint, watchpoint, or
3144catchpoint once it has done its job and you no longer want your program
3145to stop there. This is called @dfn{deleting} the breakpoint. A
3146breakpoint that has been deleted no longer exists; it is forgotten.
3147
3148With the @code{clear} command you can delete breakpoints according to
3149where they are in your program. With the @code{delete} command you can
3150delete individual breakpoints, watchpoints, or catchpoints by specifying
3151their breakpoint numbers.
3152
3153It is not necessary to delete a breakpoint to proceed past it. @value{GDBN}
3154automatically ignores breakpoints on the first instruction to be executed
3155when you continue execution without changing the execution address.
3156
3157@table @code
3158@kindex clear
3159@item clear
3160Delete any breakpoints at the next instruction to be executed in the
3161selected stack frame (@pxref{Selection, ,Selecting a frame}). When
3162the innermost frame is selected, this is a good way to delete a
3163breakpoint where your program just stopped.
3164
3165@item clear @var{function}
3166@itemx clear @var{filename}:@var{function}
09d4efe1 3167Delete any breakpoints set at entry to the named @var{function}.
c906108c
SS
3168
3169@item clear @var{linenum}
3170@itemx clear @var{filename}:@var{linenum}
09d4efe1
EZ
3171Delete any breakpoints set at or within the code of the specified
3172@var{linenum} of the specified @var{filename}.
c906108c
SS
3173
3174@cindex delete breakpoints
3175@kindex delete
41afff9a 3176@kindex d @r{(@code{delete})}
c5394b80
JM
3177@item delete @r{[}breakpoints@r{]} @r{[}@var{range}@dots{}@r{]}
3178Delete the breakpoints, watchpoints, or catchpoints of the breakpoint
3179ranges specified as arguments. If no argument is specified, delete all
c906108c
SS
3180breakpoints (@value{GDBN} asks confirmation, unless you have @code{set
3181confirm off}). You can abbreviate this command as @code{d}.
3182@end table
3183
6d2ebf8b 3184@node Disabling
c906108c
SS
3185@subsection Disabling breakpoints
3186
4644b6e3 3187@cindex enable/disable a breakpoint
c906108c
SS
3188Rather than deleting a breakpoint, watchpoint, or catchpoint, you might
3189prefer to @dfn{disable} it. This makes the breakpoint inoperative as if
3190it had been deleted, but remembers the information on the breakpoint so
3191that you can @dfn{enable} it again later.
3192
3193You disable and enable breakpoints, watchpoints, and catchpoints with
3194the @code{enable} and @code{disable} commands, optionally specifying one
3195or more breakpoint numbers as arguments. Use @code{info break} or
3196@code{info watch} to print a list of breakpoints, watchpoints, and
3197catchpoints if you do not know which numbers to use.
3198
3199A breakpoint, watchpoint, or catchpoint can have any of four different
3200states of enablement:
3201
3202@itemize @bullet
3203@item
3204Enabled. The breakpoint stops your program. A breakpoint set
3205with the @code{break} command starts out in this state.
3206@item
3207Disabled. The breakpoint has no effect on your program.
3208@item
3209Enabled once. The breakpoint stops your program, but then becomes
d4f3574e 3210disabled.
c906108c
SS
3211@item
3212Enabled for deletion. The breakpoint stops your program, but
d4f3574e
SS
3213immediately after it does so it is deleted permanently. A breakpoint
3214set with the @code{tbreak} command starts out in this state.
c906108c
SS
3215@end itemize
3216
3217You can use the following commands to enable or disable breakpoints,
3218watchpoints, and catchpoints:
3219
3220@table @code
c906108c 3221@kindex disable
41afff9a 3222@kindex dis @r{(@code{disable})}
c5394b80 3223@item disable @r{[}breakpoints@r{]} @r{[}@var{range}@dots{}@r{]}
c906108c
SS
3224Disable the specified breakpoints---or all breakpoints, if none are
3225listed. A disabled breakpoint has no effect but is not forgotten. All
3226options such as ignore-counts, conditions and commands are remembered in
3227case the breakpoint is enabled again later. You may abbreviate
3228@code{disable} as @code{dis}.
3229
c906108c 3230@kindex enable
c5394b80 3231@item enable @r{[}breakpoints@r{]} @r{[}@var{range}@dots{}@r{]}
c906108c
SS
3232Enable the specified breakpoints (or all defined breakpoints). They
3233become effective once again in stopping your program.
3234
c5394b80 3235@item enable @r{[}breakpoints@r{]} once @var{range}@dots{}
c906108c
SS
3236Enable the specified breakpoints temporarily. @value{GDBN} disables any
3237of these breakpoints immediately after stopping your program.
3238
c5394b80 3239@item enable @r{[}breakpoints@r{]} delete @var{range}@dots{}
c906108c
SS
3240Enable the specified breakpoints to work once, then die. @value{GDBN}
3241deletes any of these breakpoints as soon as your program stops there.
09d4efe1 3242Breakpoints set by the @code{tbreak} command start out in this state.
c906108c
SS
3243@end table
3244
d4f3574e
SS
3245@c FIXME: I think the following ``Except for [...] @code{tbreak}'' is
3246@c confusing: tbreak is also initially enabled.
c906108c
SS
3247Except for a breakpoint set with @code{tbreak} (@pxref{Set Breaks,
3248,Setting breakpoints}), breakpoints that you set are initially enabled;
3249subsequently, they become disabled or enabled only when you use one of
3250the commands above. (The command @code{until} can set and delete a
3251breakpoint of its own, but it does not change the state of your other
3252breakpoints; see @ref{Continuing and Stepping, ,Continuing and
3253stepping}.)
3254
6d2ebf8b 3255@node Conditions
c906108c
SS
3256@subsection Break conditions
3257@cindex conditional breakpoints
3258@cindex breakpoint conditions
3259
3260@c FIXME what is scope of break condition expr? Context where wanted?
5d161b24 3261@c in particular for a watchpoint?
c906108c
SS
3262The simplest sort of breakpoint breaks every time your program reaches a
3263specified place. You can also specify a @dfn{condition} for a
3264breakpoint. A condition is just a Boolean expression in your
3265programming language (@pxref{Expressions, ,Expressions}). A breakpoint with
3266a condition evaluates the expression each time your program reaches it,
3267and your program stops only if the condition is @emph{true}.
3268
3269This is the converse of using assertions for program validation; in that
3270situation, you want to stop when the assertion is violated---that is,
3271when the condition is false. In C, if you want to test an assertion expressed
3272by the condition @var{assert}, you should set the condition
3273@samp{! @var{assert}} on the appropriate breakpoint.
3274
3275Conditions are also accepted for watchpoints; you may not need them,
3276since a watchpoint is inspecting the value of an expression anyhow---but
3277it might be simpler, say, to just set a watchpoint on a variable name,
3278and specify a condition that tests whether the new value is an interesting
3279one.
3280
3281Break conditions can have side effects, and may even call functions in
3282your program. This can be useful, for example, to activate functions
3283that log program progress, or to use your own print functions to
3284format special data structures. The effects are completely predictable
3285unless there is another enabled breakpoint at the same address. (In
3286that case, @value{GDBN} might see the other breakpoint first and stop your
3287program without checking the condition of this one.) Note that
d4f3574e
SS
3288breakpoint commands are usually more convenient and flexible than break
3289conditions for the
c906108c
SS
3290purpose of performing side effects when a breakpoint is reached
3291(@pxref{Break Commands, ,Breakpoint command lists}).
3292
3293Break conditions can be specified when a breakpoint is set, by using
3294@samp{if} in the arguments to the @code{break} command. @xref{Set
3295Breaks, ,Setting breakpoints}. They can also be changed at any time
3296with the @code{condition} command.
53a5351d 3297
c906108c
SS
3298You can also use the @code{if} keyword with the @code{watch} command.
3299The @code{catch} command does not recognize the @code{if} keyword;
3300@code{condition} is the only way to impose a further condition on a
3301catchpoint.
c906108c
SS
3302
3303@table @code
3304@kindex condition
3305@item condition @var{bnum} @var{expression}
3306Specify @var{expression} as the break condition for breakpoint,
3307watchpoint, or catchpoint number @var{bnum}. After you set a condition,
3308breakpoint @var{bnum} stops your program only if the value of
3309@var{expression} is true (nonzero, in C). When you use
3310@code{condition}, @value{GDBN} checks @var{expression} immediately for
3311syntactic correctness, and to determine whether symbols in it have
d4f3574e
SS
3312referents in the context of your breakpoint. If @var{expression} uses
3313symbols not referenced in the context of the breakpoint, @value{GDBN}
3314prints an error message:
3315
474c8240 3316@smallexample
d4f3574e 3317No symbol "foo" in current context.
474c8240 3318@end smallexample
d4f3574e
SS
3319
3320@noindent
c906108c
SS
3321@value{GDBN} does
3322not actually evaluate @var{expression} at the time the @code{condition}
d4f3574e
SS
3323command (or a command that sets a breakpoint with a condition, like
3324@code{break if @dots{}}) is given, however. @xref{Expressions, ,Expressions}.
c906108c
SS
3325
3326@item condition @var{bnum}
3327Remove the condition from breakpoint number @var{bnum}. It becomes
3328an ordinary unconditional breakpoint.
3329@end table
3330
3331@cindex ignore count (of breakpoint)
3332A special case of a breakpoint condition is to stop only when the
3333breakpoint has been reached a certain number of times. This is so
3334useful that there is a special way to do it, using the @dfn{ignore
3335count} of the breakpoint. Every breakpoint has an ignore count, which
3336is an integer. Most of the time, the ignore count is zero, and
3337therefore has no effect. But if your program reaches a breakpoint whose
3338ignore count is positive, then instead of stopping, it just decrements
3339the ignore count by one and continues. As a result, if the ignore count
3340value is @var{n}, the breakpoint does not stop the next @var{n} times
3341your program reaches it.
3342
3343@table @code
3344@kindex ignore
3345@item ignore @var{bnum} @var{count}
3346Set the ignore count of breakpoint number @var{bnum} to @var{count}.
3347The next @var{count} times the breakpoint is reached, your program's
3348execution does not stop; other than to decrement the ignore count, @value{GDBN}
3349takes no action.
3350
3351To make the breakpoint stop the next time it is reached, specify
3352a count of zero.
3353
3354When you use @code{continue} to resume execution of your program from a
3355breakpoint, you can specify an ignore count directly as an argument to
3356@code{continue}, rather than using @code{ignore}. @xref{Continuing and
3357Stepping,,Continuing and stepping}.
3358
3359If a breakpoint has a positive ignore count and a condition, the
3360condition is not checked. Once the ignore count reaches zero,
3361@value{GDBN} resumes checking the condition.
3362
3363You could achieve the effect of the ignore count with a condition such
3364as @w{@samp{$foo-- <= 0}} using a debugger convenience variable that
3365is decremented each time. @xref{Convenience Vars, ,Convenience
3366variables}.
3367@end table
3368
3369Ignore counts apply to breakpoints, watchpoints, and catchpoints.
3370
3371
6d2ebf8b 3372@node Break Commands
c906108c
SS
3373@subsection Breakpoint command lists
3374
3375@cindex breakpoint commands
3376You can give any breakpoint (or watchpoint or catchpoint) a series of
3377commands to execute when your program stops due to that breakpoint. For
3378example, you might want to print the values of certain expressions, or
3379enable other breakpoints.
3380
3381@table @code
3382@kindex commands
3383@kindex end
3384@item commands @r{[}@var{bnum}@r{]}
3385@itemx @dots{} @var{command-list} @dots{}
3386@itemx end
3387Specify a list of commands for breakpoint number @var{bnum}. The commands
3388themselves appear on the following lines. Type a line containing just
3389@code{end} to terminate the commands.
3390
3391To remove all commands from a breakpoint, type @code{commands} and
3392follow it immediately with @code{end}; that is, give no commands.
3393
3394With no @var{bnum} argument, @code{commands} refers to the last
3395breakpoint, watchpoint, or catchpoint set (not to the breakpoint most
3396recently encountered).
3397@end table
3398
3399Pressing @key{RET} as a means of repeating the last @value{GDBN} command is
3400disabled within a @var{command-list}.
3401
3402You can use breakpoint commands to start your program up again. Simply
3403use the @code{continue} command, or @code{step}, or any other command
3404that resumes execution.
3405
3406Any other commands in the command list, after a command that resumes
3407execution, are ignored. This is because any time you resume execution
3408(even with a simple @code{next} or @code{step}), you may encounter
3409another breakpoint---which could have its own command list, leading to
3410ambiguities about which list to execute.
3411
3412@kindex silent
3413If the first command you specify in a command list is @code{silent}, the
3414usual message about stopping at a breakpoint is not printed. This may
3415be desirable for breakpoints that are to print a specific message and
3416then continue. If none of the remaining commands print anything, you
3417see no sign that the breakpoint was reached. @code{silent} is
3418meaningful only at the beginning of a breakpoint command list.
3419
3420The commands @code{echo}, @code{output}, and @code{printf} allow you to
3421print precisely controlled output, and are often useful in silent
3422breakpoints. @xref{Output, ,Commands for controlled output}.
3423
3424For example, here is how you could use breakpoint commands to print the
3425value of @code{x} at entry to @code{foo} whenever @code{x} is positive.
3426
474c8240 3427@smallexample
c906108c
SS
3428break foo if x>0
3429commands
3430silent
3431printf "x is %d\n",x
3432cont
3433end
474c8240 3434@end smallexample
c906108c
SS
3435
3436One application for breakpoint commands is to compensate for one bug so
3437you can test for another. Put a breakpoint just after the erroneous line
3438of code, give it a condition to detect the case in which something
3439erroneous has been done, and give it commands to assign correct values
3440to any variables that need them. End with the @code{continue} command
3441so that your program does not stop, and start with the @code{silent}
3442command so that no output is produced. Here is an example:
3443
474c8240 3444@smallexample
c906108c
SS
3445break 403
3446commands
3447silent
3448set x = y + 4
3449cont
3450end
474c8240 3451@end smallexample
c906108c 3452
6d2ebf8b 3453@node Breakpoint Menus
c906108c
SS
3454@subsection Breakpoint menus
3455@cindex overloading
3456@cindex symbol overloading
3457
b383017d 3458Some programming languages (notably C@t{++} and Objective-C) permit a
b37303ee 3459single function name
c906108c
SS
3460to be defined several times, for application in different contexts.
3461This is called @dfn{overloading}. When a function name is overloaded,
3462@samp{break @var{function}} is not enough to tell @value{GDBN} where you want
3463a breakpoint. If you realize this is a problem, you can use
3464something like @samp{break @var{function}(@var{types})} to specify which
3465particular version of the function you want. Otherwise, @value{GDBN} offers
3466you a menu of numbered choices for different possible breakpoints, and
3467waits for your selection with the prompt @samp{>}. The first two
3468options are always @samp{[0] cancel} and @samp{[1] all}. Typing @kbd{1}
3469sets a breakpoint at each definition of @var{function}, and typing
3470@kbd{0} aborts the @code{break} command without setting any new
3471breakpoints.
3472
3473For example, the following session excerpt shows an attempt to set a
3474breakpoint at the overloaded symbol @code{String::after}.
3475We choose three particular definitions of that function name:
3476
3477@c FIXME! This is likely to change to show arg type lists, at least
3478@smallexample
3479@group
3480(@value{GDBP}) b String::after
3481[0] cancel
3482[1] all
3483[2] file:String.cc; line number:867
3484[3] file:String.cc; line number:860
3485[4] file:String.cc; line number:875
3486[5] file:String.cc; line number:853
3487[6] file:String.cc; line number:846
3488[7] file:String.cc; line number:735
3489> 2 4 6
3490Breakpoint 1 at 0xb26c: file String.cc, line 867.
3491Breakpoint 2 at 0xb344: file String.cc, line 875.
3492Breakpoint 3 at 0xafcc: file String.cc, line 846.
3493Multiple breakpoints were set.
3494Use the "delete" command to delete unwanted
3495 breakpoints.
3496(@value{GDBP})
3497@end group
3498@end smallexample
c906108c
SS
3499
3500@c @ifclear BARETARGET
6d2ebf8b 3501@node Error in Breakpoints
d4f3574e 3502@subsection ``Cannot insert breakpoints''
c906108c
SS
3503@c
3504@c FIXME!! 14/6/95 Is there a real example of this? Let's use it.
3505@c
d4f3574e
SS
3506Under some operating systems, breakpoints cannot be used in a program if
3507any other process is running that program. In this situation,
5d161b24 3508attempting to run or continue a program with a breakpoint causes
d4f3574e
SS
3509@value{GDBN} to print an error message:
3510
474c8240 3511@smallexample
d4f3574e
SS
3512Cannot insert breakpoints.
3513The same program may be running in another process.
474c8240 3514@end smallexample
d4f3574e
SS
3515
3516When this happens, you have three ways to proceed:
3517
3518@enumerate
3519@item
3520Remove or disable the breakpoints, then continue.
3521
3522@item
5d161b24 3523Suspend @value{GDBN}, and copy the file containing your program to a new
d4f3574e 3524name. Resume @value{GDBN} and use the @code{exec-file} command to specify
5d161b24 3525that @value{GDBN} should run your program under that name.
d4f3574e
SS
3526Then start your program again.
3527
3528@item
3529Relink your program so that the text segment is nonsharable, using the
3530linker option @samp{-N}. The operating system limitation may not apply
3531to nonsharable executables.
3532@end enumerate
c906108c
SS
3533@c @end ifclear
3534
d4f3574e
SS
3535A similar message can be printed if you request too many active
3536hardware-assisted breakpoints and watchpoints:
3537
3538@c FIXME: the precise wording of this message may change; the relevant
3539@c source change is not committed yet (Sep 3, 1999).
3540@smallexample
3541Stopped; cannot insert breakpoints.
3542You may have requested too many hardware breakpoints and watchpoints.
3543@end smallexample
3544
3545@noindent
3546This message is printed when you attempt to resume the program, since
3547only then @value{GDBN} knows exactly how many hardware breakpoints and
3548watchpoints it needs to insert.
3549
3550When this message is printed, you need to disable or remove some of the
3551hardware-assisted breakpoints and watchpoints, and then continue.
3552
1485d690
KB
3553@node Breakpoint related warnings
3554@subsection ``Breakpoint address adjusted...''
3555@cindex breakpoint address adjusted
3556
3557Some processor architectures place constraints on the addresses at
3558which breakpoints may be placed. For architectures thus constrained,
3559@value{GDBN} will attempt to adjust the breakpoint's address to comply
3560with the constraints dictated by the architecture.
3561
3562One example of such an architecture is the Fujitsu FR-V. The FR-V is
3563a VLIW architecture in which a number of RISC-like instructions may be
3564bundled together for parallel execution. The FR-V architecture
3565constrains the location of a breakpoint instruction within such a
3566bundle to the instruction with the lowest address. @value{GDBN}
3567honors this constraint by adjusting a breakpoint's address to the
3568first in the bundle.
3569
3570It is not uncommon for optimized code to have bundles which contain
3571instructions from different source statements, thus it may happen that
3572a breakpoint's address will be adjusted from one source statement to
3573another. Since this adjustment may significantly alter @value{GDBN}'s
3574breakpoint related behavior from what the user expects, a warning is
3575printed when the breakpoint is first set and also when the breakpoint
3576is hit.
3577
3578A warning like the one below is printed when setting a breakpoint
3579that's been subject to address adjustment:
3580
3581@smallexample
3582warning: Breakpoint address adjusted from 0x00010414 to 0x00010410.
3583@end smallexample
3584
3585Such warnings are printed both for user settable and @value{GDBN}'s
3586internal breakpoints. If you see one of these warnings, you should
3587verify that a breakpoint set at the adjusted address will have the
3588desired affect. If not, the breakpoint in question may be removed and
b383017d 3589other breakpoints may be set which will have the desired behavior.
1485d690
KB
3590E.g., it may be sufficient to place the breakpoint at a later
3591instruction. A conditional breakpoint may also be useful in some
3592cases to prevent the breakpoint from triggering too often.
3593
3594@value{GDBN} will also issue a warning when stopping at one of these
3595adjusted breakpoints:
3596
3597@smallexample
3598warning: Breakpoint 1 address previously adjusted from 0x00010414
3599to 0x00010410.
3600@end smallexample
3601
3602When this warning is encountered, it may be too late to take remedial
3603action except in cases where the breakpoint is hit earlier or more
3604frequently than expected.
d4f3574e 3605
6d2ebf8b 3606@node Continuing and Stepping
c906108c
SS
3607@section Continuing and stepping
3608
3609@cindex stepping
3610@cindex continuing
3611@cindex resuming execution
3612@dfn{Continuing} means resuming program execution until your program
3613completes normally. In contrast, @dfn{stepping} means executing just
3614one more ``step'' of your program, where ``step'' may mean either one
3615line of source code, or one machine instruction (depending on what
7a292a7a
SS
3616particular command you use). Either when continuing or when stepping,
3617your program may stop even sooner, due to a breakpoint or a signal. (If
d4f3574e
SS
3618it stops due to a signal, you may want to use @code{handle}, or use
3619@samp{signal 0} to resume execution. @xref{Signals, ,Signals}.)
c906108c
SS
3620
3621@table @code
3622@kindex continue
41afff9a
EZ
3623@kindex c @r{(@code{continue})}
3624@kindex fg @r{(resume foreground execution)}
c906108c
SS
3625@item continue @r{[}@var{ignore-count}@r{]}
3626@itemx c @r{[}@var{ignore-count}@r{]}
3627@itemx fg @r{[}@var{ignore-count}@r{]}
3628Resume program execution, at the address where your program last stopped;
3629any breakpoints set at that address are bypassed. The optional argument
3630@var{ignore-count} allows you to specify a further number of times to
3631ignore a breakpoint at this location; its effect is like that of
3632@code{ignore} (@pxref{Conditions, ,Break conditions}).
3633
3634The argument @var{ignore-count} is meaningful only when your program
3635stopped due to a breakpoint. At other times, the argument to
3636@code{continue} is ignored.
3637
d4f3574e
SS
3638The synonyms @code{c} and @code{fg} (for @dfn{foreground}, as the
3639debugged program is deemed to be the foreground program) are provided
3640purely for convenience, and have exactly the same behavior as
3641@code{continue}.
c906108c
SS
3642@end table
3643
3644To resume execution at a different place, you can use @code{return}
3645(@pxref{Returning, ,Returning from a function}) to go back to the
3646calling function; or @code{jump} (@pxref{Jumping, ,Continuing at a
3647different address}) to go to an arbitrary location in your program.
3648
3649A typical technique for using stepping is to set a breakpoint
3650(@pxref{Breakpoints, ,Breakpoints; watchpoints; and catchpoints}) at the
3651beginning of the function or the section of your program where a problem
3652is believed to lie, run your program until it stops at that breakpoint,
3653and then step through the suspect area, examining the variables that are
3654interesting, until you see the problem happen.
3655
3656@table @code
3657@kindex step
41afff9a 3658@kindex s @r{(@code{step})}
c906108c
SS
3659@item step
3660Continue running your program until control reaches a different source
3661line, then stop it and return control to @value{GDBN}. This command is
3662abbreviated @code{s}.
3663
3664@quotation
3665@c "without debugging information" is imprecise; actually "without line
3666@c numbers in the debugging information". (gcc -g1 has debugging info but
3667@c not line numbers). But it seems complex to try to make that
3668@c distinction here.
3669@emph{Warning:} If you use the @code{step} command while control is
3670within a function that was compiled without debugging information,
3671execution proceeds until control reaches a function that does have
3672debugging information. Likewise, it will not step into a function which
3673is compiled without debugging information. To step through functions
3674without debugging information, use the @code{stepi} command, described
3675below.
3676@end quotation
3677
4a92d011
EZ
3678The @code{step} command only stops at the first instruction of a source
3679line. This prevents the multiple stops that could otherwise occur in
3680@code{switch} statements, @code{for} loops, etc. @code{step} continues
3681to stop if a function that has debugging information is called within
3682the line. In other words, @code{step} @emph{steps inside} any functions
3683called within the line.
c906108c 3684
d4f3574e
SS
3685Also, the @code{step} command only enters a function if there is line
3686number information for the function. Otherwise it acts like the
5d161b24 3687@code{next} command. This avoids problems when using @code{cc -gl}
c906108c 3688on MIPS machines. Previously, @code{step} entered subroutines if there
5d161b24 3689was any debugging information about the routine.
c906108c
SS
3690
3691@item step @var{count}
3692Continue running as in @code{step}, but do so @var{count} times. If a
7a292a7a
SS
3693breakpoint is reached, or a signal not related to stepping occurs before
3694@var{count} steps, stepping stops right away.
c906108c
SS
3695
3696@kindex next
41afff9a 3697@kindex n @r{(@code{next})}
c906108c
SS
3698@item next @r{[}@var{count}@r{]}
3699Continue to the next source line in the current (innermost) stack frame.
7a292a7a
SS
3700This is similar to @code{step}, but function calls that appear within
3701the line of code are executed without stopping. Execution stops when
3702control reaches a different line of code at the original stack level
3703that was executing when you gave the @code{next} command. This command
3704is abbreviated @code{n}.
c906108c
SS
3705
3706An argument @var{count} is a repeat count, as for @code{step}.
3707
3708
3709@c FIX ME!! Do we delete this, or is there a way it fits in with
3710@c the following paragraph? --- Vctoria
3711@c
3712@c @code{next} within a function that lacks debugging information acts like
3713@c @code{step}, but any function calls appearing within the code of the
3714@c function are executed without stopping.
3715
d4f3574e
SS
3716The @code{next} command only stops at the first instruction of a
3717source line. This prevents multiple stops that could otherwise occur in
4a92d011 3718@code{switch} statements, @code{for} loops, etc.
c906108c 3719
b90a5f51
CF
3720@kindex set step-mode
3721@item set step-mode
3722@cindex functions without line info, and stepping
3723@cindex stepping into functions with no line info
3724@itemx set step-mode on
4a92d011 3725The @code{set step-mode on} command causes the @code{step} command to
b90a5f51
CF
3726stop at the first instruction of a function which contains no debug line
3727information rather than stepping over it.
3728
4a92d011
EZ
3729This is useful in cases where you may be interested in inspecting the
3730machine instructions of a function which has no symbolic info and do not
3731want @value{GDBN} to automatically skip over this function.
b90a5f51
CF
3732
3733@item set step-mode off
4a92d011 3734Causes the @code{step} command to step over any functions which contains no
b90a5f51
CF
3735debug information. This is the default.
3736
9c16f35a
EZ
3737@item show step-mode
3738Show whether @value{GDBN} will stop in or step over functions without
3739source line debug information.
3740
c906108c
SS
3741@kindex finish
3742@item finish
3743Continue running until just after function in the selected stack frame
3744returns. Print the returned value (if any).
3745
3746Contrast this with the @code{return} command (@pxref{Returning,
3747,Returning from a function}).
3748
3749@kindex until
41afff9a 3750@kindex u @r{(@code{until})}
09d4efe1 3751@cindex run until specified location
c906108c
SS
3752@item until
3753@itemx u
3754Continue running until a source line past the current line, in the
3755current stack frame, is reached. This command is used to avoid single
3756stepping through a loop more than once. It is like the @code{next}
3757command, except that when @code{until} encounters a jump, it
3758automatically continues execution until the program counter is greater
3759than the address of the jump.
3760
3761This means that when you reach the end of a loop after single stepping
3762though it, @code{until} makes your program continue execution until it
3763exits the loop. In contrast, a @code{next} command at the end of a loop
3764simply steps back to the beginning of the loop, which forces you to step
3765through the next iteration.
3766
3767@code{until} always stops your program if it attempts to exit the current
3768stack frame.
3769
3770@code{until} may produce somewhat counterintuitive results if the order
3771of machine code does not match the order of the source lines. For
3772example, in the following excerpt from a debugging session, the @code{f}
3773(@code{frame}) command shows that execution is stopped at line
3774@code{206}; yet when we use @code{until}, we get to line @code{195}:
3775
474c8240 3776@smallexample
c906108c
SS
3777(@value{GDBP}) f
3778#0 main (argc=4, argv=0xf7fffae8) at m4.c:206
3779206 expand_input();
3780(@value{GDBP}) until
3781195 for ( ; argc > 0; NEXTARG) @{
474c8240 3782@end smallexample
c906108c
SS
3783
3784This happened because, for execution efficiency, the compiler had
3785generated code for the loop closure test at the end, rather than the
3786start, of the loop---even though the test in a C @code{for}-loop is
3787written before the body of the loop. The @code{until} command appeared
3788to step back to the beginning of the loop when it advanced to this
3789expression; however, it has not really gone to an earlier
3790statement---not in terms of the actual machine code.
3791
3792@code{until} with no argument works by means of single
3793instruction stepping, and hence is slower than @code{until} with an
3794argument.
3795
3796@item until @var{location}
3797@itemx u @var{location}
3798Continue running your program until either the specified location is
3799reached, or the current stack frame returns. @var{location} is any of
3800the forms of argument acceptable to @code{break} (@pxref{Set Breaks,
c60eb6f1
EZ
3801,Setting breakpoints}). This form of the command uses breakpoints, and
3802hence is quicker than @code{until} without an argument. The specified
3803location is actually reached only if it is in the current frame. This
3804implies that @code{until} can be used to skip over recursive function
3805invocations. For instance in the code below, if the current location is
3806line @code{96}, issuing @code{until 99} will execute the program up to
3807line @code{99} in the same invocation of factorial, i.e. after the inner
3808invocations have returned.
3809
3810@smallexample
381194 int factorial (int value)
381295 @{
381396 if (value > 1) @{
381497 value *= factorial (value - 1);
381598 @}
381699 return (value);
3817100 @}
3818@end smallexample
3819
3820
3821@kindex advance @var{location}
3822@itemx advance @var{location}
09d4efe1
EZ
3823Continue running the program up to the given @var{location}. An argument is
3824required, which should be of the same form as arguments for the @code{break}
c60eb6f1
EZ
3825command. Execution will also stop upon exit from the current stack
3826frame. This command is similar to @code{until}, but @code{advance} will
3827not skip over recursive function calls, and the target location doesn't
3828have to be in the same frame as the current one.
3829
c906108c
SS
3830
3831@kindex stepi
41afff9a 3832@kindex si @r{(@code{stepi})}
c906108c 3833@item stepi
96a2c332 3834@itemx stepi @var{arg}
c906108c
SS
3835@itemx si
3836Execute one machine instruction, then stop and return to the debugger.
3837
3838It is often useful to do @samp{display/i $pc} when stepping by machine
3839instructions. This makes @value{GDBN} automatically display the next
3840instruction to be executed, each time your program stops. @xref{Auto
3841Display,, Automatic display}.
3842
3843An argument is a repeat count, as in @code{step}.
3844
3845@need 750
3846@kindex nexti
41afff9a 3847@kindex ni @r{(@code{nexti})}
c906108c 3848@item nexti
96a2c332 3849@itemx nexti @var{arg}
c906108c
SS
3850@itemx ni
3851Execute one machine instruction, but if it is a function call,
3852proceed until the function returns.
3853
3854An argument is a repeat count, as in @code{next}.
3855@end table
3856
6d2ebf8b 3857@node Signals
c906108c
SS
3858@section Signals
3859@cindex signals
3860
3861A signal is an asynchronous event that can happen in a program. The
3862operating system defines the possible kinds of signals, and gives each
3863kind a name and a number. For example, in Unix @code{SIGINT} is the
d4f3574e 3864signal a program gets when you type an interrupt character (often @kbd{C-c});
c906108c
SS
3865@code{SIGSEGV} is the signal a program gets from referencing a place in
3866memory far away from all the areas in use; @code{SIGALRM} occurs when
3867the alarm clock timer goes off (which happens only if your program has
3868requested an alarm).
3869
3870@cindex fatal signals
3871Some signals, including @code{SIGALRM}, are a normal part of the
3872functioning of your program. Others, such as @code{SIGSEGV}, indicate
d4f3574e 3873errors; these signals are @dfn{fatal} (they kill your program immediately) if the
c906108c
SS
3874program has not specified in advance some other way to handle the signal.
3875@code{SIGINT} does not indicate an error in your program, but it is normally
3876fatal so it can carry out the purpose of the interrupt: to kill the program.
3877
3878@value{GDBN} has the ability to detect any occurrence of a signal in your
3879program. You can tell @value{GDBN} in advance what to do for each kind of
3880signal.
3881
3882@cindex handling signals
24f93129
EZ
3883Normally, @value{GDBN} is set up to let the non-erroneous signals like
3884@code{SIGALRM} be silently passed to your program
3885(so as not to interfere with their role in the program's functioning)
c906108c
SS
3886but to stop your program immediately whenever an error signal happens.
3887You can change these settings with the @code{handle} command.
3888
3889@table @code
3890@kindex info signals
09d4efe1 3891@kindex info handle
c906108c 3892@item info signals
96a2c332 3893@itemx info handle
c906108c
SS
3894Print a table of all the kinds of signals and how @value{GDBN} has been told to
3895handle each one. You can use this to see the signal numbers of all
3896the defined types of signals.
3897
d4f3574e 3898@code{info handle} is an alias for @code{info signals}.
c906108c
SS
3899
3900@kindex handle
3901@item handle @var{signal} @var{keywords}@dots{}
5ece1a18
EZ
3902Change the way @value{GDBN} handles signal @var{signal}. @var{signal}
3903can be the number of a signal or its name (with or without the
24f93129 3904@samp{SIG} at the beginning); a list of signal numbers of the form
5ece1a18
EZ
3905@samp{@var{low}-@var{high}}; or the word @samp{all}, meaning all the
3906known signals. The @var{keywords} say what change to make.
c906108c
SS
3907@end table
3908
3909@c @group
3910The keywords allowed by the @code{handle} command can be abbreviated.
3911Their full names are:
3912
3913@table @code
3914@item nostop
3915@value{GDBN} should not stop your program when this signal happens. It may
3916still print a message telling you that the signal has come in.
3917
3918@item stop
3919@value{GDBN} should stop your program when this signal happens. This implies
3920the @code{print} keyword as well.
3921
3922@item print
3923@value{GDBN} should print a message when this signal happens.
3924
3925@item noprint
3926@value{GDBN} should not mention the occurrence of the signal at all. This
3927implies the @code{nostop} keyword as well.
3928
3929@item pass
5ece1a18 3930@itemx noignore
c906108c
SS
3931@value{GDBN} should allow your program to see this signal; your program
3932can handle the signal, or else it may terminate if the signal is fatal
5ece1a18 3933and not handled. @code{pass} and @code{noignore} are synonyms.
c906108c
SS
3934
3935@item nopass
5ece1a18 3936@itemx ignore
c906108c 3937@value{GDBN} should not allow your program to see this signal.
5ece1a18 3938@code{nopass} and @code{ignore} are synonyms.
c906108c
SS
3939@end table
3940@c @end group
3941
d4f3574e
SS
3942When a signal stops your program, the signal is not visible to the
3943program until you
c906108c
SS
3944continue. Your program sees the signal then, if @code{pass} is in
3945effect for the signal in question @emph{at that time}. In other words,
3946after @value{GDBN} reports a signal, you can use the @code{handle}
3947command with @code{pass} or @code{nopass} to control whether your
3948program sees that signal when you continue.
3949
24f93129
EZ
3950The default is set to @code{nostop}, @code{noprint}, @code{pass} for
3951non-erroneous signals such as @code{SIGALRM}, @code{SIGWINCH} and
3952@code{SIGCHLD}, and to @code{stop}, @code{print}, @code{pass} for the
3953erroneous signals.
3954
c906108c
SS
3955You can also use the @code{signal} command to prevent your program from
3956seeing a signal, or cause it to see a signal it normally would not see,
3957or to give it any signal at any time. For example, if your program stopped
3958due to some sort of memory reference error, you might store correct
3959values into the erroneous variables and continue, hoping to see more
3960execution; but your program would probably terminate immediately as
3961a result of the fatal signal once it saw the signal. To prevent this,
3962you can continue with @samp{signal 0}. @xref{Signaling, ,Giving your
5d161b24 3963program a signal}.
c906108c 3964
6d2ebf8b 3965@node Thread Stops
c906108c
SS
3966@section Stopping and starting multi-thread programs
3967
3968When your program has multiple threads (@pxref{Threads,, Debugging
3969programs with multiple threads}), you can choose whether to set
3970breakpoints on all threads, or on a particular thread.
3971
3972@table @code
3973@cindex breakpoints and threads
3974@cindex thread breakpoints
3975@kindex break @dots{} thread @var{threadno}
3976@item break @var{linespec} thread @var{threadno}
3977@itemx break @var{linespec} thread @var{threadno} if @dots{}
3978@var{linespec} specifies source lines; there are several ways of
3979writing them, but the effect is always to specify some source line.
3980
3981Use the qualifier @samp{thread @var{threadno}} with a breakpoint command
3982to specify that you only want @value{GDBN} to stop the program when a
3983particular thread reaches this breakpoint. @var{threadno} is one of the
3984numeric thread identifiers assigned by @value{GDBN}, shown in the first
3985column of the @samp{info threads} display.
3986
3987If you do not specify @samp{thread @var{threadno}} when you set a
3988breakpoint, the breakpoint applies to @emph{all} threads of your
3989program.
3990
3991You can use the @code{thread} qualifier on conditional breakpoints as
3992well; in this case, place @samp{thread @var{threadno}} before the
3993breakpoint condition, like this:
3994
3995@smallexample
2df3850c 3996(@value{GDBP}) break frik.c:13 thread 28 if bartab > lim
c906108c
SS
3997@end smallexample
3998
3999@end table
4000
4001@cindex stopped threads
4002@cindex threads, stopped
4003Whenever your program stops under @value{GDBN} for any reason,
4004@emph{all} threads of execution stop, not just the current thread. This
4005allows you to examine the overall state of the program, including
4006switching between threads, without worrying that things may change
4007underfoot.
4008
36d86913
MC
4009@cindex thread breakpoints and system calls
4010@cindex system calls and thread breakpoints
4011@cindex premature return from system calls
4012There is an unfortunate side effect. If one thread stops for a
4013breakpoint, or for some other reason, and another thread is blocked in a
4014system call, then the system call may return prematurely. This is a
4015consequence of the interaction between multiple threads and the signals
4016that @value{GDBN} uses to implement breakpoints and other events that
4017stop execution.
4018
4019To handle this problem, your program should check the return value of
4020each system call and react appropriately. This is good programming
4021style anyways.
4022
4023For example, do not write code like this:
4024
4025@smallexample
4026 sleep (10);
4027@end smallexample
4028
4029The call to @code{sleep} will return early if a different thread stops
4030at a breakpoint or for some other reason.
4031
4032Instead, write this:
4033
4034@smallexample
4035 int unslept = 10;
4036 while (unslept > 0)
4037 unslept = sleep (unslept);
4038@end smallexample
4039
4040A system call is allowed to return early, so the system is still
4041conforming to its specification. But @value{GDBN} does cause your
4042multi-threaded program to behave differently than it would without
4043@value{GDBN}.
4044
4045Also, @value{GDBN} uses internal breakpoints in the thread library to
4046monitor certain events such as thread creation and thread destruction.
4047When such an event happens, a system call in another thread may return
4048prematurely, even though your program does not appear to stop.
4049
c906108c
SS
4050@cindex continuing threads
4051@cindex threads, continuing
4052Conversely, whenever you restart the program, @emph{all} threads start
4053executing. @emph{This is true even when single-stepping} with commands
5d161b24 4054like @code{step} or @code{next}.
c906108c
SS
4055
4056In particular, @value{GDBN} cannot single-step all threads in lockstep.
4057Since thread scheduling is up to your debugging target's operating
4058system (not controlled by @value{GDBN}), other threads may
4059execute more than one statement while the current thread completes a
4060single step. Moreover, in general other threads stop in the middle of a
4061statement, rather than at a clean statement boundary, when the program
4062stops.
4063
4064You might even find your program stopped in another thread after
4065continuing or even single-stepping. This happens whenever some other
4066thread runs into a breakpoint, a signal, or an exception before the
4067first thread completes whatever you requested.
4068
4069On some OSes, you can lock the OS scheduler and thus allow only a single
4070thread to run.
4071
4072@table @code
4073@item set scheduler-locking @var{mode}
9c16f35a
EZ
4074@cindex scheduler locking mode
4075@cindex lock scheduler
c906108c
SS
4076Set the scheduler locking mode. If it is @code{off}, then there is no
4077locking and any thread may run at any time. If @code{on}, then only the
4078current thread may run when the inferior is resumed. The @code{step}
4079mode optimizes for single-stepping. It stops other threads from
4080``seizing the prompt'' by preempting the current thread while you are
4081stepping. Other threads will only rarely (or never) get a chance to run
d4f3574e 4082when you step. They are more likely to run when you @samp{next} over a
c906108c 4083function call, and they are completely free to run when you use commands
d4f3574e 4084like @samp{continue}, @samp{until}, or @samp{finish}. However, unless another
c906108c 4085thread hits a breakpoint during its timeslice, they will never steal the
2df3850c 4086@value{GDBN} prompt away from the thread that you are debugging.
c906108c
SS
4087
4088@item show scheduler-locking
4089Display the current scheduler locking mode.
4090@end table
4091
c906108c 4092
6d2ebf8b 4093@node Stack
c906108c
SS
4094@chapter Examining the Stack
4095
4096When your program has stopped, the first thing you need to know is where it
4097stopped and how it got there.
4098
4099@cindex call stack
5d161b24
DB
4100Each time your program performs a function call, information about the call
4101is generated.
4102That information includes the location of the call in your program,
4103the arguments of the call,
c906108c 4104and the local variables of the function being called.
5d161b24 4105The information is saved in a block of data called a @dfn{stack frame}.
c906108c
SS
4106The stack frames are allocated in a region of memory called the @dfn{call
4107stack}.
4108
4109When your program stops, the @value{GDBN} commands for examining the
4110stack allow you to see all of this information.
4111
4112@cindex selected frame
4113One of the stack frames is @dfn{selected} by @value{GDBN} and many
4114@value{GDBN} commands refer implicitly to the selected frame. In
4115particular, whenever you ask @value{GDBN} for the value of a variable in
4116your program, the value is found in the selected frame. There are
4117special @value{GDBN} commands to select whichever frame you are
4118interested in. @xref{Selection, ,Selecting a frame}.
4119
4120When your program stops, @value{GDBN} automatically selects the
5d161b24 4121currently executing frame and describes it briefly, similar to the
c906108c
SS
4122@code{frame} command (@pxref{Frame Info, ,Information about a frame}).
4123
4124@menu
4125* Frames:: Stack frames
4126* Backtrace:: Backtraces
4127* Selection:: Selecting a frame
4128* Frame Info:: Information on a frame
c906108c
SS
4129
4130@end menu
4131
6d2ebf8b 4132@node Frames
c906108c
SS
4133@section Stack frames
4134
d4f3574e 4135@cindex frame, definition
c906108c
SS
4136@cindex stack frame
4137The call stack is divided up into contiguous pieces called @dfn{stack
4138frames}, or @dfn{frames} for short; each frame is the data associated
4139with one call to one function. The frame contains the arguments given
4140to the function, the function's local variables, and the address at
4141which the function is executing.
4142
4143@cindex initial frame
4144@cindex outermost frame
4145@cindex innermost frame
4146When your program is started, the stack has only one frame, that of the
4147function @code{main}. This is called the @dfn{initial} frame or the
4148@dfn{outermost} frame. Each time a function is called, a new frame is
4149made. Each time a function returns, the frame for that function invocation
4150is eliminated. If a function is recursive, there can be many frames for
4151the same function. The frame for the function in which execution is
4152actually occurring is called the @dfn{innermost} frame. This is the most
4153recently created of all the stack frames that still exist.
4154
4155@cindex frame pointer
4156Inside your program, stack frames are identified by their addresses. A
4157stack frame consists of many bytes, each of which has its own address; each
4158kind of computer has a convention for choosing one byte whose
4159address serves as the address of the frame. Usually this address is kept
e09f16f9
EZ
4160in a register called the @dfn{frame pointer register}
4161(@pxref{Registers, $fp}) while execution is going on in that frame.
c906108c
SS
4162
4163@cindex frame number
4164@value{GDBN} assigns numbers to all existing stack frames, starting with
4165zero for the innermost frame, one for the frame that called it,
4166and so on upward. These numbers do not really exist in your program;
4167they are assigned by @value{GDBN} to give you a way of designating stack
4168frames in @value{GDBN} commands.
4169
6d2ebf8b
SS
4170@c The -fomit-frame-pointer below perennially causes hbox overflow
4171@c underflow problems.
c906108c
SS
4172@cindex frameless execution
4173Some compilers provide a way to compile functions so that they operate
6d2ebf8b 4174without stack frames. (For example, the @value{GCC} option
474c8240 4175@smallexample
6d2ebf8b 4176@samp{-fomit-frame-pointer}
474c8240 4177@end smallexample
6d2ebf8b 4178generates functions without a frame.)
c906108c
SS
4179This is occasionally done with heavily used library functions to save
4180the frame setup time. @value{GDBN} has limited facilities for dealing
4181with these function invocations. If the innermost function invocation
4182has no stack frame, @value{GDBN} nevertheless regards it as though
4183it had a separate frame, which is numbered zero as usual, allowing
4184correct tracing of the function call chain. However, @value{GDBN} has
4185no provision for frameless functions elsewhere in the stack.
4186
4187@table @code
d4f3574e 4188@kindex frame@r{, command}
41afff9a 4189@cindex current stack frame
c906108c 4190@item frame @var{args}
5d161b24 4191The @code{frame} command allows you to move from one stack frame to another,
c906108c 4192and to print the stack frame you select. @var{args} may be either the
5d161b24
DB
4193address of the frame or the stack frame number. Without an argument,
4194@code{frame} prints the current stack frame.
c906108c
SS
4195
4196@kindex select-frame
41afff9a 4197@cindex selecting frame silently
c906108c
SS
4198@item select-frame
4199The @code{select-frame} command allows you to move from one stack frame
4200to another without printing the frame. This is the silent version of
4201@code{frame}.
4202@end table
4203
6d2ebf8b 4204@node Backtrace
c906108c
SS
4205@section Backtraces
4206
09d4efe1
EZ
4207@cindex traceback
4208@cindex call stack traces
c906108c
SS
4209A backtrace is a summary of how your program got where it is. It shows one
4210line per frame, for many frames, starting with the currently executing
4211frame (frame zero), followed by its caller (frame one), and on up the
4212stack.
4213
4214@table @code
4215@kindex backtrace
41afff9a 4216@kindex bt @r{(@code{backtrace})}
c906108c
SS
4217@item backtrace
4218@itemx bt
4219Print a backtrace of the entire stack: one line per frame for all
4220frames in the stack.
4221
4222You can stop the backtrace at any time by typing the system interrupt
4223character, normally @kbd{C-c}.
4224
4225@item backtrace @var{n}
4226@itemx bt @var{n}
4227Similar, but print only the innermost @var{n} frames.
4228
4229@item backtrace -@var{n}
4230@itemx bt -@var{n}
4231Similar, but print only the outermost @var{n} frames.
0f061b69
NR
4232
4233@item backtrace full
4234Print the values of the local variables also.
4235@itemx bt full
c906108c
SS
4236@end table
4237
4238@kindex where
4239@kindex info stack
c906108c
SS
4240The names @code{where} and @code{info stack} (abbreviated @code{info s})
4241are additional aliases for @code{backtrace}.
4242
4243Each line in the backtrace shows the frame number and the function name.
4244The program counter value is also shown---unless you use @code{set
4245print address off}. The backtrace also shows the source file name and
4246line number, as well as the arguments to the function. The program
4247counter value is omitted if it is at the beginning of the code for that
4248line number.
4249
4250Here is an example of a backtrace. It was made with the command
4251@samp{bt 3}, so it shows the innermost three frames.
4252
4253@smallexample
4254@group
5d161b24 4255#0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
c906108c
SS
4256 at builtin.c:993
4257#1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242
4258#2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
4259 at macro.c:71
4260(More stack frames follow...)
4261@end group
4262@end smallexample
4263
4264@noindent
4265The display for frame zero does not begin with a program counter
4266value, indicating that your program has stopped at the beginning of the
4267code for line @code{993} of @code{builtin.c}.
4268
18999be5
EZ
4269@cindex value optimized out, in backtrace
4270@cindex function call arguments, optimized out
4271If your program was compiled with optimizations, some compilers will
4272optimize away arguments passed to functions if those arguments are
4273never used after the call. Such optimizations generate code that
4274passes arguments through registers, but doesn't store those arguments
4275in the stack frame. @value{GDBN} has no way of displaying such
4276arguments in stack frames other than the innermost one. Here's what
4277such a backtrace might look like:
4278
4279@smallexample
4280@group
4281#0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
4282 at builtin.c:993
4283#1 0x6e38 in expand_macro (sym=<value optimized out>) at macro.c:242
4284#2 0x6840 in expand_token (obs=0x0, t=<value optimized out>, td=0xf7fffb08)
4285 at macro.c:71
4286(More stack frames follow...)
4287@end group
4288@end smallexample
4289
4290@noindent
4291The values of arguments that were not saved in their stack frames are
4292shown as @samp{<value optimized out>}.
4293
4294If you need to display the values of such optimized-out arguments,
4295either deduce that from other variables whose values depend on the one
4296you are interested in, or recompile without optimizations.
4297
a8f24a35
EZ
4298@cindex backtrace beyond @code{main} function
4299@cindex program entry point
4300@cindex startup code, and backtrace
25d29d70
AC
4301Most programs have a standard user entry point---a place where system
4302libraries and startup code transition into user code. For C this is
4303@code{main}. When @value{GDBN} finds the entry function in a backtrace
4304it will terminate the backtrace, to avoid tracing into highly
4305system-specific (and generally uninteresting) code.
4306
4307If you need to examine the startup code, or limit the number of levels
4308in a backtrace, you can change this behavior:
95f90d25
DJ
4309
4310@table @code
25d29d70
AC
4311@item set backtrace past-main
4312@itemx set backtrace past-main on
4644b6e3 4313@kindex set backtrace
25d29d70
AC
4314Backtraces will continue past the user entry point.
4315
4316@item set backtrace past-main off
95f90d25
DJ
4317Backtraces will stop when they encounter the user entry point. This is the
4318default.
4319
25d29d70 4320@item show backtrace past-main
4644b6e3 4321@kindex show backtrace
25d29d70
AC
4322Display the current user entry point backtrace policy.
4323
2315ffec
RC
4324@item set backtrace past-entry
4325@itemx set backtrace past-entry on
a8f24a35 4326Backtraces will continue past the internal entry point of an application.
2315ffec
RC
4327This entry point is encoded by the linker when the application is built,
4328and is likely before the user entry point @code{main} (or equivalent) is called.
4329
4330@item set backtrace past-entry off
4331Backtraces will stop when they encouter the internal entry point of an
4332application. This is the default.
4333
4334@item show backtrace past-entry
4335Display the current internal entry point backtrace policy.
4336
25d29d70
AC
4337@item set backtrace limit @var{n}
4338@itemx set backtrace limit 0
4339@cindex backtrace limit
4340Limit the backtrace to @var{n} levels. A value of zero means
4341unlimited.
95f90d25 4342
25d29d70
AC
4343@item show backtrace limit
4344Display the current limit on backtrace levels.
95f90d25
DJ
4345@end table
4346
6d2ebf8b 4347@node Selection
c906108c
SS
4348@section Selecting a frame
4349
4350Most commands for examining the stack and other data in your program work on
4351whichever stack frame is selected at the moment. Here are the commands for
4352selecting a stack frame; all of them finish by printing a brief description
4353of the stack frame just selected.
4354
4355@table @code
d4f3574e 4356@kindex frame@r{, selecting}
41afff9a 4357@kindex f @r{(@code{frame})}
c906108c
SS
4358@item frame @var{n}
4359@itemx f @var{n}
4360Select frame number @var{n}. Recall that frame zero is the innermost
4361(currently executing) frame, frame one is the frame that called the
4362innermost one, and so on. The highest-numbered frame is the one for
4363@code{main}.
4364
4365@item frame @var{addr}
4366@itemx f @var{addr}
4367Select the frame at address @var{addr}. This is useful mainly if the
4368chaining of stack frames has been damaged by a bug, making it
4369impossible for @value{GDBN} to assign numbers properly to all frames. In
4370addition, this can be useful when your program has multiple stacks and
4371switches between them.
4372
c906108c
SS
4373On the SPARC architecture, @code{frame} needs two addresses to
4374select an arbitrary frame: a frame pointer and a stack pointer.
4375
4376On the MIPS and Alpha architecture, it needs two addresses: a stack
4377pointer and a program counter.
4378
4379On the 29k architecture, it needs three addresses: a register stack
4380pointer, a program counter, and a memory stack pointer.
4381@c note to future updaters: this is conditioned on a flag
4382@c SETUP_ARBITRARY_FRAME in the tm-*.h files. The above is up to date
4383@c as of 27 Jan 1994.
c906108c
SS
4384
4385@kindex up
4386@item up @var{n}
4387Move @var{n} frames up the stack. For positive numbers @var{n}, this
4388advances toward the outermost frame, to higher frame numbers, to frames
4389that have existed longer. @var{n} defaults to one.
4390
4391@kindex down
41afff9a 4392@kindex do @r{(@code{down})}
c906108c
SS
4393@item down @var{n}
4394Move @var{n} frames down the stack. For positive numbers @var{n}, this
4395advances toward the innermost frame, to lower frame numbers, to frames
4396that were created more recently. @var{n} defaults to one. You may
4397abbreviate @code{down} as @code{do}.
4398@end table
4399
4400All of these commands end by printing two lines of output describing the
4401frame. The first line shows the frame number, the function name, the
4402arguments, and the source file and line number of execution in that
5d161b24 4403frame. The second line shows the text of that source line.
c906108c
SS
4404
4405@need 1000
4406For example:
4407
4408@smallexample
4409@group
4410(@value{GDBP}) up
4411#1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc)
4412 at env.c:10
441310 read_input_file (argv[i]);
4414@end group
4415@end smallexample
4416
4417After such a printout, the @code{list} command with no arguments
4418prints ten lines centered on the point of execution in the frame.
87885426
FN
4419You can also edit the program at the point of execution with your favorite
4420editing program by typing @code{edit}.
4421@xref{List, ,Printing source lines},
4422for details.
c906108c
SS
4423
4424@table @code
4425@kindex down-silently
4426@kindex up-silently
4427@item up-silently @var{n}
4428@itemx down-silently @var{n}
4429These two commands are variants of @code{up} and @code{down},
4430respectively; they differ in that they do their work silently, without
4431causing display of the new frame. They are intended primarily for use
4432in @value{GDBN} command scripts, where the output might be unnecessary and
4433distracting.
4434@end table
4435
6d2ebf8b 4436@node Frame Info
c906108c
SS
4437@section Information about a frame
4438
4439There are several other commands to print information about the selected
4440stack frame.
4441
4442@table @code
4443@item frame
4444@itemx f
4445When used without any argument, this command does not change which
4446frame is selected, but prints a brief description of the currently
4447selected stack frame. It can be abbreviated @code{f}. With an
4448argument, this command is used to select a stack frame.
4449@xref{Selection, ,Selecting a frame}.
4450
4451@kindex info frame
41afff9a 4452@kindex info f @r{(@code{info frame})}
c906108c
SS
4453@item info frame
4454@itemx info f
4455This command prints a verbose description of the selected stack frame,
4456including:
4457
4458@itemize @bullet
5d161b24
DB
4459@item
4460the address of the frame
c906108c
SS
4461@item
4462the address of the next frame down (called by this frame)
4463@item
4464the address of the next frame up (caller of this frame)
4465@item
4466the language in which the source code corresponding to this frame is written
4467@item
4468the address of the frame's arguments
4469@item
d4f3574e
SS
4470the address of the frame's local variables
4471@item
c906108c
SS
4472the program counter saved in it (the address of execution in the caller frame)
4473@item
4474which registers were saved in the frame
4475@end itemize
4476
4477@noindent The verbose description is useful when
4478something has gone wrong that has made the stack format fail to fit
4479the usual conventions.
4480
4481@item info frame @var{addr}
4482@itemx info f @var{addr}
4483Print a verbose description of the frame at address @var{addr}, without
4484selecting that frame. The selected frame remains unchanged by this
4485command. This requires the same kind of address (more than one for some
4486architectures) that you specify in the @code{frame} command.
4487@xref{Selection, ,Selecting a frame}.
4488
4489@kindex info args
4490@item info args
4491Print the arguments of the selected frame, each on a separate line.
4492
4493@item info locals
4494@kindex info locals
4495Print the local variables of the selected frame, each on a separate
4496line. These are all variables (declared either static or automatic)
4497accessible at the point of execution of the selected frame.
4498
c906108c 4499@kindex info catch
d4f3574e
SS
4500@cindex catch exceptions, list active handlers
4501@cindex exception handlers, how to list
c906108c
SS
4502@item info catch
4503Print a list of all the exception handlers that are active in the
4504current stack frame at the current point of execution. To see other
4505exception handlers, visit the associated frame (using the @code{up},
4506@code{down}, or @code{frame} commands); then type @code{info catch}.
4507@xref{Set Catchpoints, , Setting catchpoints}.
53a5351d 4508
c906108c
SS
4509@end table
4510
c906108c 4511
6d2ebf8b 4512@node Source
c906108c
SS
4513@chapter Examining Source Files
4514
4515@value{GDBN} can print parts of your program's source, since the debugging
4516information recorded in the program tells @value{GDBN} what source files were
4517used to build it. When your program stops, @value{GDBN} spontaneously prints
4518the line where it stopped. Likewise, when you select a stack frame
4519(@pxref{Selection, ,Selecting a frame}), @value{GDBN} prints the line where
4520execution in that frame has stopped. You can print other portions of
4521source files by explicit command.
4522
7a292a7a 4523If you use @value{GDBN} through its @sc{gnu} Emacs interface, you may
d4f3574e 4524prefer to use Emacs facilities to view source; see @ref{Emacs, ,Using
7a292a7a 4525@value{GDBN} under @sc{gnu} Emacs}.
c906108c
SS
4526
4527@menu
4528* List:: Printing source lines
87885426 4529* Edit:: Editing source files
c906108c 4530* Search:: Searching source files
c906108c
SS
4531* Source Path:: Specifying source directories
4532* Machine Code:: Source and machine code
4533@end menu
4534
6d2ebf8b 4535@node List
c906108c
SS
4536@section Printing source lines
4537
4538@kindex list
41afff9a 4539@kindex l @r{(@code{list})}
c906108c 4540To print lines from a source file, use the @code{list} command
5d161b24 4541(abbreviated @code{l}). By default, ten lines are printed.
c906108c
SS
4542There are several ways to specify what part of the file you want to print.
4543
4544Here are the forms of the @code{list} command most commonly used:
4545
4546@table @code
4547@item list @var{linenum}
4548Print lines centered around line number @var{linenum} in the
4549current source file.
4550
4551@item list @var{function}
4552Print lines centered around the beginning of function
4553@var{function}.
4554
4555@item list
4556Print more lines. If the last lines printed were printed with a
4557@code{list} command, this prints lines following the last lines
4558printed; however, if the last line printed was a solitary line printed
4559as part of displaying a stack frame (@pxref{Stack, ,Examining the
4560Stack}), this prints lines centered around that line.
4561
4562@item list -
4563Print lines just before the lines last printed.
4564@end table
4565
9c16f35a 4566@cindex @code{list}, how many lines to display
c906108c
SS
4567By default, @value{GDBN} prints ten source lines with any of these forms of
4568the @code{list} command. You can change this using @code{set listsize}:
4569
4570@table @code
4571@kindex set listsize
4572@item set listsize @var{count}
4573Make the @code{list} command display @var{count} source lines (unless
4574the @code{list} argument explicitly specifies some other number).
4575
4576@kindex show listsize
4577@item show listsize
4578Display the number of lines that @code{list} prints.
4579@end table
4580
4581Repeating a @code{list} command with @key{RET} discards the argument,
4582so it is equivalent to typing just @code{list}. This is more useful
4583than listing the same lines again. An exception is made for an
4584argument of @samp{-}; that argument is preserved in repetition so that
4585each repetition moves up in the source file.
4586
4587@cindex linespec
4588In general, the @code{list} command expects you to supply zero, one or two
4589@dfn{linespecs}. Linespecs specify source lines; there are several ways
d4f3574e 4590of writing them, but the effect is always to specify some source line.
c906108c
SS
4591Here is a complete description of the possible arguments for @code{list}:
4592
4593@table @code
4594@item list @var{linespec}
4595Print lines centered around the line specified by @var{linespec}.
4596
4597@item list @var{first},@var{last}
4598Print lines from @var{first} to @var{last}. Both arguments are
4599linespecs.
4600
4601@item list ,@var{last}
4602Print lines ending with @var{last}.
4603
4604@item list @var{first},
4605Print lines starting with @var{first}.
4606
4607@item list +
4608Print lines just after the lines last printed.
4609
4610@item list -
4611Print lines just before the lines last printed.
4612
4613@item list
4614As described in the preceding table.
4615@end table
4616
4617Here are the ways of specifying a single source line---all the
4618kinds of linespec.
4619
4620@table @code
4621@item @var{number}
4622Specifies line @var{number} of the current source file.
4623When a @code{list} command has two linespecs, this refers to
4624the same source file as the first linespec.
4625
4626@item +@var{offset}
4627Specifies the line @var{offset} lines after the last line printed.
4628When used as the second linespec in a @code{list} command that has
4629two, this specifies the line @var{offset} lines down from the
4630first linespec.
4631
4632@item -@var{offset}
4633Specifies the line @var{offset} lines before the last line printed.
4634
4635@item @var{filename}:@var{number}
4636Specifies line @var{number} in the source file @var{filename}.
4637
4638@item @var{function}
4639Specifies the line that begins the body of the function @var{function}.
4640For example: in C, this is the line with the open brace.
4641
4642@item @var{filename}:@var{function}
4643Specifies the line of the open-brace that begins the body of the
4644function @var{function} in the file @var{filename}. You only need the
4645file name with a function name to avoid ambiguity when there are
4646identically named functions in different source files.
4647
4648@item *@var{address}
4649Specifies the line containing the program address @var{address}.
4650@var{address} may be any expression.
4651@end table
4652
87885426
FN
4653@node Edit
4654@section Editing source files
4655@cindex editing source files
4656
4657@kindex edit
4658@kindex e @r{(@code{edit})}
4659To edit the lines in a source file, use the @code{edit} command.
4660The editing program of your choice
4661is invoked with the current line set to
4662the active line in the program.
4663Alternatively, there are several ways to specify what part of the file you
4664want to print if you want to see other parts of the program.
4665
4666Here are the forms of the @code{edit} command most commonly used:
4667
4668@table @code
4669@item edit
4670Edit the current source file at the active line number in the program.
4671
4672@item edit @var{number}
4673Edit the current source file with @var{number} as the active line number.
4674
4675@item edit @var{function}
4676Edit the file containing @var{function} at the beginning of its definition.
4677
4678@item edit @var{filename}:@var{number}
4679Specifies line @var{number} in the source file @var{filename}.
4680
4681@item edit @var{filename}:@var{function}
4682Specifies the line that begins the body of the
4683function @var{function} in the file @var{filename}. You only need the
4684file name with a function name to avoid ambiguity when there are
4685identically named functions in different source files.
4686
4687@item edit *@var{address}
4688Specifies the line containing the program address @var{address}.
4689@var{address} may be any expression.
4690@end table
4691
4692@subsection Choosing your editor
4693You can customize @value{GDBN} to use any editor you want
4694@footnote{
4695The only restriction is that your editor (say @code{ex}), recognizes the
4696following command-line syntax:
10998722 4697@smallexample
87885426 4698ex +@var{number} file
10998722 4699@end smallexample
15387254
EZ
4700The optional numeric value +@var{number} specifies the number of the line in
4701the file where to start editing.}.
4702By default, it is @file{@value{EDITOR}}, but you can change this
10998722
AC
4703by setting the environment variable @code{EDITOR} before using
4704@value{GDBN}. For example, to configure @value{GDBN} to use the
4705@code{vi} editor, you could use these commands with the @code{sh} shell:
4706@smallexample
87885426
FN
4707EDITOR=/usr/bin/vi
4708export EDITOR
15387254 4709gdb @dots{}
10998722 4710@end smallexample
87885426 4711or in the @code{csh} shell,
10998722 4712@smallexample
87885426 4713setenv EDITOR /usr/bin/vi
15387254 4714gdb @dots{}
10998722 4715@end smallexample
87885426 4716
6d2ebf8b 4717@node Search
c906108c 4718@section Searching source files
15387254 4719@cindex searching source files
c906108c
SS
4720
4721There are two commands for searching through the current source file for a
4722regular expression.
4723
4724@table @code
4725@kindex search
4726@kindex forward-search
4727@item forward-search @var{regexp}
4728@itemx search @var{regexp}
4729The command @samp{forward-search @var{regexp}} checks each line,
4730starting with the one following the last line listed, for a match for
5d161b24 4731@var{regexp}. It lists the line that is found. You can use the
c906108c
SS
4732synonym @samp{search @var{regexp}} or abbreviate the command name as
4733@code{fo}.
4734
09d4efe1 4735@kindex reverse-search
c906108c
SS
4736@item reverse-search @var{regexp}
4737The command @samp{reverse-search @var{regexp}} checks each line, starting
4738with the one before the last line listed and going backward, for a match
4739for @var{regexp}. It lists the line that is found. You can abbreviate
4740this command as @code{rev}.
4741@end table
c906108c 4742
6d2ebf8b 4743@node Source Path
c906108c
SS
4744@section Specifying source directories
4745
4746@cindex source path
4747@cindex directories for source files
4748Executable programs sometimes do not record the directories of the source
4749files from which they were compiled, just the names. Even when they do,
4750the directories could be moved between the compilation and your debugging
4751session. @value{GDBN} has a list of directories to search for source files;
4752this is called the @dfn{source path}. Each time @value{GDBN} wants a source file,
4753it tries all the directories in the list, in the order they are present
0b66e38c
EZ
4754in the list, until it finds a file with the desired name.
4755
4756For example, suppose an executable references the file
4757@file{/usr/src/foo-1.0/lib/foo.c}, and our source path is
4758@file{/mnt/cross}. The file is first looked up literally; if this
4759fails, @file{/mnt/cross/usr/src/foo-1.0/lib/foo.c} is tried; if this
4760fails, @file{/mnt/cross/foo.c} is opened; if this fails, an error
4761message is printed. @value{GDBN} does not look up the parts of the
4762source file name, such as @file{/mnt/cross/src/foo-1.0/lib/foo.c}.
4763Likewise, the subdirectories of the source path are not searched: if
4764the source path is @file{/mnt/cross}, and the binary refers to
4765@file{foo.c}, @value{GDBN} would not find it under
4766@file{/mnt/cross/usr/src/foo-1.0/lib}.
4767
4768Plain file names, relative file names with leading directories, file
4769names containing dots, etc.@: are all treated as described above; for
4770instance, if the source path is @file{/mnt/cross}, and the source file
4771is recorded as @file{../lib/foo.c}, @value{GDBN} would first try
4772@file{../lib/foo.c}, then @file{/mnt/cross/../lib/foo.c}, and after
4773that---@file{/mnt/cross/foo.c}.
4774
4775Note that the executable search path is @emph{not} used to locate the
4776source files. Neither is the current working directory, unless it
4777happens to be in the source path.
c906108c
SS
4778
4779Whenever you reset or rearrange the source path, @value{GDBN} clears out
4780any information it has cached about where source files are found and where
4781each line is in the file.
4782
4783@kindex directory
4784@kindex dir
d4f3574e
SS
4785When you start @value{GDBN}, its source path includes only @samp{cdir}
4786and @samp{cwd}, in that order.
c906108c
SS
4787To add other directories, use the @code{directory} command.
4788
4789@table @code
4790@item directory @var{dirname} @dots{}
4791@item dir @var{dirname} @dots{}
4792Add directory @var{dirname} to the front of the source path. Several
d4f3574e
SS
4793directory names may be given to this command, separated by @samp{:}
4794(@samp{;} on MS-DOS and MS-Windows, where @samp{:} usually appears as
4795part of absolute file names) or
c906108c
SS
4796whitespace. You may specify a directory that is already in the source
4797path; this moves it forward, so @value{GDBN} searches it sooner.
4798
4799@kindex cdir
4800@kindex cwd
41afff9a
EZ
4801@vindex $cdir@r{, convenience variable}
4802@vindex $cwdr@r{, convenience variable}
c906108c
SS
4803@cindex compilation directory
4804@cindex current directory
4805@cindex working directory
4806@cindex directory, current
4807@cindex directory, compilation
4808You can use the string @samp{$cdir} to refer to the compilation
4809directory (if one is recorded), and @samp{$cwd} to refer to the current
4810working directory. @samp{$cwd} is not the same as @samp{.}---the former
4811tracks the current working directory as it changes during your @value{GDBN}
4812session, while the latter is immediately expanded to the current
4813directory at the time you add an entry to the source path.
4814
4815@item directory
4816Reset the source path to empty again. This requires confirmation.
4817
4818@c RET-repeat for @code{directory} is explicitly disabled, but since
4819@c repeating it would be a no-op we do not say that. (thanks to RMS)
4820
4821@item show directories
4822@kindex show directories
4823Print the source path: show which directories it contains.
4824@end table
4825
4826If your source path is cluttered with directories that are no longer of
4827interest, @value{GDBN} may sometimes cause confusion by finding the wrong
4828versions of source. You can correct the situation as follows:
4829
4830@enumerate
4831@item
4832Use @code{directory} with no argument to reset the source path to empty.
4833
4834@item
4835Use @code{directory} with suitable arguments to reinstall the
4836directories you want in the source path. You can add all the
4837directories in one command.
4838@end enumerate
4839
6d2ebf8b 4840@node Machine Code
c906108c 4841@section Source and machine code
15387254 4842@cindex source line and its code address
c906108c
SS
4843
4844You can use the command @code{info line} to map source lines to program
4845addresses (and vice versa), and the command @code{disassemble} to display
4846a range of addresses as machine instructions. When run under @sc{gnu} Emacs
d4f3574e 4847mode, the @code{info line} command causes the arrow to point to the
5d161b24 4848line specified. Also, @code{info line} prints addresses in symbolic form as
c906108c
SS
4849well as hex.
4850
4851@table @code
4852@kindex info line
4853@item info line @var{linespec}
4854Print the starting and ending addresses of the compiled code for
4855source line @var{linespec}. You can specify source lines in any of
4856the ways understood by the @code{list} command (@pxref{List, ,Printing
4857source lines}).
4858@end table
4859
4860For example, we can use @code{info line} to discover the location of
4861the object code for the first line of function
4862@code{m4_changequote}:
4863
d4f3574e
SS
4864@c FIXME: I think this example should also show the addresses in
4865@c symbolic form, as they usually would be displayed.
c906108c 4866@smallexample
96a2c332 4867(@value{GDBP}) info line m4_changequote
c906108c
SS
4868Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350.
4869@end smallexample
4870
4871@noindent
15387254 4872@cindex code address and its source line
c906108c
SS
4873We can also inquire (using @code{*@var{addr}} as the form for
4874@var{linespec}) what source line covers a particular address:
4875@smallexample
4876(@value{GDBP}) info line *0x63ff
4877Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404.
4878@end smallexample
4879
4880@cindex @code{$_} and @code{info line}
15387254 4881@cindex @code{x} command, default address
41afff9a 4882@kindex x@r{(examine), and} info line
c906108c
SS
4883After @code{info line}, the default address for the @code{x} command
4884is changed to the starting address of the line, so that @samp{x/i} is
4885sufficient to begin examining the machine code (@pxref{Memory,
4886,Examining memory}). Also, this address is saved as the value of the
4887convenience variable @code{$_} (@pxref{Convenience Vars, ,Convenience
4888variables}).
4889
4890@table @code
4891@kindex disassemble
4892@cindex assembly instructions
4893@cindex instructions, assembly
4894@cindex machine instructions
4895@cindex listing machine instructions
4896@item disassemble
4897This specialized command dumps a range of memory as machine
4898instructions. The default memory range is the function surrounding the
4899program counter of the selected frame. A single argument to this
4900command is a program counter value; @value{GDBN} dumps the function
4901surrounding this value. Two arguments specify a range of addresses
4902(first inclusive, second exclusive) to dump.
4903@end table
4904
c906108c
SS
4905The following example shows the disassembly of a range of addresses of
4906HP PA-RISC 2.0 code:
4907
4908@smallexample
4909(@value{GDBP}) disas 0x32c4 0x32e4
4910Dump of assembler code from 0x32c4 to 0x32e4:
49110x32c4 <main+204>: addil 0,dp
49120x32c8 <main+208>: ldw 0x22c(sr0,r1),r26
49130x32cc <main+212>: ldil 0x3000,r31
49140x32d0 <main+216>: ble 0x3f8(sr4,r31)
49150x32d4 <main+220>: ldo 0(r31),rp
49160x32d8 <main+224>: addil -0x800,dp
49170x32dc <main+228>: ldo 0x588(r1),r26
49180x32e0 <main+232>: ldil 0x3000,r31
4919End of assembler dump.
4920@end smallexample
c906108c
SS
4921
4922Some architectures have more than one commonly-used set of instruction
4923mnemonics or other syntax.
4924
76d17f34
EZ
4925For programs that were dynamically linked and use shared libraries,
4926instructions that call functions or branch to locations in the shared
4927libraries might show a seemingly bogus location---it's actually a
4928location of the relocation table. On some architectures, @value{GDBN}
4929might be able to resolve these to actual function names.
4930
c906108c 4931@table @code
d4f3574e 4932@kindex set disassembly-flavor
d4f3574e
SS
4933@cindex Intel disassembly flavor
4934@cindex AT&T disassembly flavor
4935@item set disassembly-flavor @var{instruction-set}
c906108c
SS
4936Select the instruction set to use when disassembling the
4937program via the @code{disassemble} or @code{x/i} commands.
4938
4939Currently this command is only defined for the Intel x86 family. You
d4f3574e
SS
4940can set @var{instruction-set} to either @code{intel} or @code{att}.
4941The default is @code{att}, the AT&T flavor used by default by Unix
4942assemblers for x86-based targets.
9c16f35a
EZ
4943
4944@kindex show disassembly-flavor
4945@item show disassembly-flavor
4946Show the current setting of the disassembly flavor.
c906108c
SS
4947@end table
4948
4949
6d2ebf8b 4950@node Data
c906108c
SS
4951@chapter Examining Data
4952
4953@cindex printing data
4954@cindex examining data
4955@kindex print
4956@kindex inspect
4957@c "inspect" is not quite a synonym if you are using Epoch, which we do not
4958@c document because it is nonstandard... Under Epoch it displays in a
4959@c different window or something like that.
4960The usual way to examine data in your program is with the @code{print}
7a292a7a
SS
4961command (abbreviated @code{p}), or its synonym @code{inspect}. It
4962evaluates and prints the value of an expression of the language your
4963program is written in (@pxref{Languages, ,Using @value{GDBN} with
4964Different Languages}).
c906108c
SS
4965
4966@table @code
d4f3574e
SS
4967@item print @var{expr}
4968@itemx print /@var{f} @var{expr}
4969@var{expr} is an expression (in the source language). By default the
4970value of @var{expr} is printed in a format appropriate to its data type;
c906108c 4971you can choose a different format by specifying @samp{/@var{f}}, where
d4f3574e 4972@var{f} is a letter specifying the format; see @ref{Output Formats,,Output
c906108c
SS
4973formats}.
4974
4975@item print
4976@itemx print /@var{f}
15387254 4977@cindex reprint the last value
d4f3574e 4978If you omit @var{expr}, @value{GDBN} displays the last value again (from the
c906108c
SS
4979@dfn{value history}; @pxref{Value History, ,Value history}). This allows you to
4980conveniently inspect the same value in an alternative format.
4981@end table
4982
4983A more low-level way of examining data is with the @code{x} command.
4984It examines data in memory at a specified address and prints it in a
4985specified format. @xref{Memory, ,Examining memory}.
4986
7a292a7a 4987If you are interested in information about types, or about how the
d4f3574e
SS
4988fields of a struct or a class are declared, use the @code{ptype @var{exp}}
4989command rather than @code{print}. @xref{Symbols, ,Examining the Symbol
7a292a7a 4990Table}.
c906108c
SS
4991
4992@menu
4993* Expressions:: Expressions
4994* Variables:: Program variables
4995* Arrays:: Artificial arrays
4996* Output Formats:: Output formats
4997* Memory:: Examining memory
4998* Auto Display:: Automatic display
4999* Print Settings:: Print settings
5000* Value History:: Value history
5001* Convenience Vars:: Convenience variables
5002* Registers:: Registers
c906108c 5003* Floating Point Hardware:: Floating point hardware
53c69bd7 5004* Vector Unit:: Vector Unit
721c2651 5005* OS Information:: Auxiliary data provided by operating system
29e57380 5006* Memory Region Attributes:: Memory region attributes
16d9dec6 5007* Dump/Restore Files:: Copy between memory and a file
384ee23f 5008* Core File Generation:: Cause a program dump its core
a0eb71c5
KB
5009* Character Sets:: Debugging programs that use a different
5010 character set than GDB does
09d4efe1 5011* Caching Remote Data:: Data caching for remote targets
c906108c
SS
5012@end menu
5013
6d2ebf8b 5014@node Expressions
c906108c
SS
5015@section Expressions
5016
5017@cindex expressions
5018@code{print} and many other @value{GDBN} commands accept an expression and
5019compute its value. Any kind of constant, variable or operator defined
5020by the programming language you are using is valid in an expression in
e2e0bcd1
JB
5021@value{GDBN}. This includes conditional expressions, function calls,
5022casts, and string constants. It also includes preprocessor macros, if
5023you compiled your program to include this information; see
5024@ref{Compilation}.
c906108c 5025
15387254 5026@cindex arrays in expressions
d4f3574e
SS
5027@value{GDBN} supports array constants in expressions input by
5028the user. The syntax is @{@var{element}, @var{element}@dots{}@}. For example,
5d161b24 5029you can use the command @code{print @{1, 2, 3@}} to build up an array in
d4f3574e 5030memory that is @code{malloc}ed in the target program.
c906108c 5031
c906108c
SS
5032Because C is so widespread, most of the expressions shown in examples in
5033this manual are in C. @xref{Languages, , Using @value{GDBN} with Different
5034Languages}, for information on how to use expressions in other
5035languages.
5036
5037In this section, we discuss operators that you can use in @value{GDBN}
5038expressions regardless of your programming language.
5039
15387254 5040@cindex casts, in expressions
c906108c
SS
5041Casts are supported in all languages, not just in C, because it is so
5042useful to cast a number into a pointer in order to examine a structure
5043at that address in memory.
5044@c FIXME: casts supported---Mod2 true?
c906108c
SS
5045
5046@value{GDBN} supports these operators, in addition to those common
5047to programming languages:
5048
5049@table @code
5050@item @@
5051@samp{@@} is a binary operator for treating parts of memory as arrays.
5052@xref{Arrays, ,Artificial arrays}, for more information.
5053
5054@item ::
5055@samp{::} allows you to specify a variable in terms of the file or
5056function where it is defined. @xref{Variables, ,Program variables}.
5057
5058@cindex @{@var{type}@}
5059@cindex type casting memory
5060@cindex memory, viewing as typed object
5061@cindex casts, to view memory
5062@item @{@var{type}@} @var{addr}
5063Refers to an object of type @var{type} stored at address @var{addr} in
5064memory. @var{addr} may be any expression whose value is an integer or
5065pointer (but parentheses are required around binary operators, just as in
5066a cast). This construct is allowed regardless of what kind of data is
5067normally supposed to reside at @var{addr}.
5068@end table
5069
6d2ebf8b 5070@node Variables
c906108c
SS
5071@section Program variables
5072
5073The most common kind of expression to use is the name of a variable
5074in your program.
5075
5076Variables in expressions are understood in the selected stack frame
5077(@pxref{Selection, ,Selecting a frame}); they must be either:
5078
5079@itemize @bullet
5080@item
5081global (or file-static)
5082@end itemize
5083
5d161b24 5084@noindent or
c906108c
SS
5085
5086@itemize @bullet
5087@item
5088visible according to the scope rules of the
5089programming language from the point of execution in that frame
5d161b24 5090@end itemize
c906108c
SS
5091
5092@noindent This means that in the function
5093
474c8240 5094@smallexample
c906108c
SS
5095foo (a)
5096 int a;
5097@{
5098 bar (a);
5099 @{
5100 int b = test ();
5101 bar (b);
5102 @}
5103@}
474c8240 5104@end smallexample
c906108c
SS
5105
5106@noindent
5107you can examine and use the variable @code{a} whenever your program is
5108executing within the function @code{foo}, but you can only use or
5109examine the variable @code{b} while your program is executing inside
5110the block where @code{b} is declared.
5111
5112@cindex variable name conflict
5113There is an exception: you can refer to a variable or function whose
5114scope is a single source file even if the current execution point is not
5115in this file. But it is possible to have more than one such variable or
5116function with the same name (in different source files). If that
5117happens, referring to that name has unpredictable effects. If you wish,
5118you can specify a static variable in a particular function or file,
15387254 5119using the colon-colon (@code{::}) notation:
c906108c 5120
d4f3574e 5121@cindex colon-colon, context for variables/functions
c906108c
SS
5122@iftex
5123@c info cannot cope with a :: index entry, but why deprive hard copy readers?
41afff9a 5124@cindex @code{::}, context for variables/functions
c906108c 5125@end iftex
474c8240 5126@smallexample
c906108c
SS
5127@var{file}::@var{variable}
5128@var{function}::@var{variable}
474c8240 5129@end smallexample
c906108c
SS
5130
5131@noindent
5132Here @var{file} or @var{function} is the name of the context for the
5133static @var{variable}. In the case of file names, you can use quotes to
5134make sure @value{GDBN} parses the file name as a single word---for example,
5135to print a global value of @code{x} defined in @file{f2.c}:
5136
474c8240 5137@smallexample
c906108c 5138(@value{GDBP}) p 'f2.c'::x
474c8240 5139@end smallexample
c906108c 5140
b37052ae 5141@cindex C@t{++} scope resolution
c906108c 5142This use of @samp{::} is very rarely in conflict with the very similar
b37052ae 5143use of the same notation in C@t{++}. @value{GDBN} also supports use of the C@t{++}
c906108c
SS
5144scope resolution operator in @value{GDBN} expressions.
5145@c FIXME: Um, so what happens in one of those rare cases where it's in
5146@c conflict?? --mew
c906108c
SS
5147
5148@cindex wrong values
5149@cindex variable values, wrong
15387254
EZ
5150@cindex function entry/exit, wrong values of variables
5151@cindex optimized code, wrong values of variables
c906108c
SS
5152@quotation
5153@emph{Warning:} Occasionally, a local variable may appear to have the
5154wrong value at certain points in a function---just after entry to a new
5155scope, and just before exit.
5156@end quotation
5157You may see this problem when you are stepping by machine instructions.
5158This is because, on most machines, it takes more than one instruction to
5159set up a stack frame (including local variable definitions); if you are
5160stepping by machine instructions, variables may appear to have the wrong
5161values until the stack frame is completely built. On exit, it usually
5162also takes more than one machine instruction to destroy a stack frame;
5163after you begin stepping through that group of instructions, local
5164variable definitions may be gone.
5165
5166This may also happen when the compiler does significant optimizations.
5167To be sure of always seeing accurate values, turn off all optimization
5168when compiling.
5169
d4f3574e
SS
5170@cindex ``No symbol "foo" in current context''
5171Another possible effect of compiler optimizations is to optimize
5172unused variables out of existence, or assign variables to registers (as
5173opposed to memory addresses). Depending on the support for such cases
5174offered by the debug info format used by the compiler, @value{GDBN}
5175might not be able to display values for such local variables. If that
5176happens, @value{GDBN} will print a message like this:
5177
474c8240 5178@smallexample
d4f3574e 5179No symbol "foo" in current context.
474c8240 5180@end smallexample
d4f3574e
SS
5181
5182To solve such problems, either recompile without optimizations, or use a
5183different debug info format, if the compiler supports several such
15387254 5184formats. For example, @value{NGCC}, the @sc{gnu} C/C@t{++} compiler,
0179ffac
DC
5185usually supports the @option{-gstabs+} option. @option{-gstabs+}
5186produces debug info in a format that is superior to formats such as
5187COFF. You may be able to use DWARF 2 (@option{-gdwarf-2}), which is also
5188an effective form for debug info. @xref{Debugging Options,,Options
5189for Debugging Your Program or @sc{gnu} CC, gcc.info, Using @sc{gnu} CC}.
15387254
EZ
5190@xref{C, , Debugging C++}, for more info about debug info formats
5191that are best suited to C@t{++} programs.
d4f3574e 5192
6d2ebf8b 5193@node Arrays
c906108c
SS
5194@section Artificial arrays
5195
5196@cindex artificial array
15387254 5197@cindex arrays
41afff9a 5198@kindex @@@r{, referencing memory as an array}
c906108c
SS
5199It is often useful to print out several successive objects of the
5200same type in memory; a section of an array, or an array of
5201dynamically determined size for which only a pointer exists in the
5202program.
5203
5204You can do this by referring to a contiguous span of memory as an
5205@dfn{artificial array}, using the binary operator @samp{@@}. The left
5206operand of @samp{@@} should be the first element of the desired array
5207and be an individual object. The right operand should be the desired length
5208of the array. The result is an array value whose elements are all of
5209the type of the left argument. The first element is actually the left
5210argument; the second element comes from bytes of memory immediately
5211following those that hold the first element, and so on. Here is an
5212example. If a program says
5213
474c8240 5214@smallexample
c906108c 5215int *array = (int *) malloc (len * sizeof (int));
474c8240 5216@end smallexample
c906108c
SS
5217
5218@noindent
5219you can print the contents of @code{array} with
5220
474c8240 5221@smallexample
c906108c 5222p *array@@len
474c8240 5223@end smallexample
c906108c
SS
5224
5225The left operand of @samp{@@} must reside in memory. Array values made
5226with @samp{@@} in this way behave just like other arrays in terms of
5227subscripting, and are coerced to pointers when used in expressions.
5228Artificial arrays most often appear in expressions via the value history
5229(@pxref{Value History, ,Value history}), after printing one out.
5230
5231Another way to create an artificial array is to use a cast.
5232This re-interprets a value as if it were an array.
5233The value need not be in memory:
474c8240 5234@smallexample
c906108c
SS
5235(@value{GDBP}) p/x (short[2])0x12345678
5236$1 = @{0x1234, 0x5678@}
474c8240 5237@end smallexample
c906108c
SS
5238
5239As a convenience, if you leave the array length out (as in
c3f6f71d 5240@samp{(@var{type}[])@var{value}}) @value{GDBN} calculates the size to fill
c906108c 5241the value (as @samp{sizeof(@var{value})/sizeof(@var{type})}:
474c8240 5242@smallexample
c906108c
SS
5243(@value{GDBP}) p/x (short[])0x12345678
5244$2 = @{0x1234, 0x5678@}
474c8240 5245@end smallexample
c906108c
SS
5246
5247Sometimes the artificial array mechanism is not quite enough; in
5248moderately complex data structures, the elements of interest may not
5249actually be adjacent---for example, if you are interested in the values
5250of pointers in an array. One useful work-around in this situation is
5251to use a convenience variable (@pxref{Convenience Vars, ,Convenience
5252variables}) as a counter in an expression that prints the first
5253interesting value, and then repeat that expression via @key{RET}. For
5254instance, suppose you have an array @code{dtab} of pointers to
5255structures, and you are interested in the values of a field @code{fv}
5256in each structure. Here is an example of what you might type:
5257
474c8240 5258@smallexample
c906108c
SS
5259set $i = 0
5260p dtab[$i++]->fv
5261@key{RET}
5262@key{RET}
5263@dots{}
474c8240 5264@end smallexample
c906108c 5265
6d2ebf8b 5266@node Output Formats
c906108c
SS
5267@section Output formats
5268
5269@cindex formatted output
5270@cindex output formats
5271By default, @value{GDBN} prints a value according to its data type. Sometimes
5272this is not what you want. For example, you might want to print a number
5273in hex, or a pointer in decimal. Or you might want to view data in memory
5274at a certain address as a character string or as an instruction. To do
5275these things, specify an @dfn{output format} when you print a value.
5276
5277The simplest use of output formats is to say how to print a value
5278already computed. This is done by starting the arguments of the
5279@code{print} command with a slash and a format letter. The format
5280letters supported are:
5281
5282@table @code
5283@item x
5284Regard the bits of the value as an integer, and print the integer in
5285hexadecimal.
5286
5287@item d
5288Print as integer in signed decimal.
5289
5290@item u
5291Print as integer in unsigned decimal.
5292
5293@item o
5294Print as integer in octal.
5295
5296@item t
5297Print as integer in binary. The letter @samp{t} stands for ``two''.
5298@footnote{@samp{b} cannot be used because these format letters are also
5299used with the @code{x} command, where @samp{b} stands for ``byte'';
d4f3574e 5300see @ref{Memory,,Examining memory}.}
c906108c
SS
5301
5302@item a
5303@cindex unknown address, locating
3d67e040 5304@cindex locate address
c906108c
SS
5305Print as an address, both absolute in hexadecimal and as an offset from
5306the nearest preceding symbol. You can use this format used to discover
5307where (in what function) an unknown address is located:
5308
474c8240 5309@smallexample
c906108c
SS
5310(@value{GDBP}) p/a 0x54320
5311$3 = 0x54320 <_initialize_vx+396>
474c8240 5312@end smallexample
c906108c 5313
3d67e040
EZ
5314@noindent
5315The command @code{info symbol 0x54320} yields similar results.
5316@xref{Symbols, info symbol}.
5317
c906108c 5318@item c
51274035
EZ
5319Regard as an integer and print it as a character constant. This
5320prints both the numerical value and its character representation. The
5321character representation is replaced with the octal escape @samp{\nnn}
5322for characters outside the 7-bit @sc{ascii} range.
c906108c
SS
5323
5324@item f
5325Regard the bits of the value as a floating point number and print
5326using typical floating point syntax.
5327@end table
5328
5329For example, to print the program counter in hex (@pxref{Registers}), type
5330
474c8240 5331@smallexample
c906108c 5332p/x $pc
474c8240 5333@end smallexample
c906108c
SS
5334
5335@noindent
5336Note that no space is required before the slash; this is because command
5337names in @value{GDBN} cannot contain a slash.
5338
5339To reprint the last value in the value history with a different format,
5340you can use the @code{print} command with just a format and no
5341expression. For example, @samp{p/x} reprints the last value in hex.
5342
6d2ebf8b 5343@node Memory
c906108c
SS
5344@section Examining memory
5345
5346You can use the command @code{x} (for ``examine'') to examine memory in
5347any of several formats, independently of your program's data types.
5348
5349@cindex examining memory
5350@table @code
41afff9a 5351@kindex x @r{(examine memory)}
c906108c
SS
5352@item x/@var{nfu} @var{addr}
5353@itemx x @var{addr}
5354@itemx x
5355Use the @code{x} command to examine memory.
5356@end table
5357
5358@var{n}, @var{f}, and @var{u} are all optional parameters that specify how
5359much memory to display and how to format it; @var{addr} is an
5360expression giving the address where you want to start displaying memory.
5361If you use defaults for @var{nfu}, you need not type the slash @samp{/}.
5362Several commands set convenient defaults for @var{addr}.
5363
5364@table @r
5365@item @var{n}, the repeat count
5366The repeat count is a decimal integer; the default is 1. It specifies
5367how much memory (counting by units @var{u}) to display.
5368@c This really is **decimal**; unaffected by 'set radix' as of GDB
5369@c 4.1.2.
5370
5371@item @var{f}, the display format
51274035
EZ
5372The display format is one of the formats used by @code{print}
5373(@samp{x}, @samp{d}, @samp{u}, @samp{o}, @samp{t}, @samp{a}, @samp{c},
5374@samp{f}), and in addition @samp{s} (for null-terminated strings) and
5375@samp{i} (for machine instructions). The default is @samp{x}
5376(hexadecimal) initially. The default changes each time you use either
5377@code{x} or @code{print}.
c906108c
SS
5378
5379@item @var{u}, the unit size
5380The unit size is any of
5381
5382@table @code
5383@item b
5384Bytes.
5385@item h
5386Halfwords (two bytes).
5387@item w
5388Words (four bytes). This is the initial default.
5389@item g
5390Giant words (eight bytes).
5391@end table
5392
5393Each time you specify a unit size with @code{x}, that size becomes the
5394default unit the next time you use @code{x}. (For the @samp{s} and
5395@samp{i} formats, the unit size is ignored and is normally not written.)
5396
5397@item @var{addr}, starting display address
5398@var{addr} is the address where you want @value{GDBN} to begin displaying
5399memory. The expression need not have a pointer value (though it may);
5400it is always interpreted as an integer address of a byte of memory.
5401@xref{Expressions, ,Expressions}, for more information on expressions. The default for
5402@var{addr} is usually just after the last address examined---but several
5403other commands also set the default address: @code{info breakpoints} (to
5404the address of the last breakpoint listed), @code{info line} (to the
5405starting address of a line), and @code{print} (if you use it to display
5406a value from memory).
5407@end table
5408
5409For example, @samp{x/3uh 0x54320} is a request to display three halfwords
5410(@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}),
5411starting at address @code{0x54320}. @samp{x/4xw $sp} prints the four
5412words (@samp{w}) of memory above the stack pointer (here, @samp{$sp};
d4f3574e 5413@pxref{Registers, ,Registers}) in hexadecimal (@samp{x}).
c906108c
SS
5414
5415Since the letters indicating unit sizes are all distinct from the
5416letters specifying output formats, you do not have to remember whether
5417unit size or format comes first; either order works. The output
5418specifications @samp{4xw} and @samp{4wx} mean exactly the same thing.
5419(However, the count @var{n} must come first; @samp{wx4} does not work.)
5420
5421Even though the unit size @var{u} is ignored for the formats @samp{s}
5422and @samp{i}, you might still want to use a count @var{n}; for example,
5423@samp{3i} specifies that you want to see three machine instructions,
5424including any operands. The command @code{disassemble} gives an
d4f3574e 5425alternative way of inspecting machine instructions; see @ref{Machine
c906108c
SS
5426Code,,Source and machine code}.
5427
5428All the defaults for the arguments to @code{x} are designed to make it
5429easy to continue scanning memory with minimal specifications each time
5430you use @code{x}. For example, after you have inspected three machine
5431instructions with @samp{x/3i @var{addr}}, you can inspect the next seven
5432with just @samp{x/7}. If you use @key{RET} to repeat the @code{x} command,
5433the repeat count @var{n} is used again; the other arguments default as
5434for successive uses of @code{x}.
5435
5436@cindex @code{$_}, @code{$__}, and value history
5437The addresses and contents printed by the @code{x} command are not saved
5438in the value history because there is often too much of them and they
5439would get in the way. Instead, @value{GDBN} makes these values available for
5440subsequent use in expressions as values of the convenience variables
5441@code{$_} and @code{$__}. After an @code{x} command, the last address
5442examined is available for use in expressions in the convenience variable
5443@code{$_}. The contents of that address, as examined, are available in
5444the convenience variable @code{$__}.
5445
5446If the @code{x} command has a repeat count, the address and contents saved
5447are from the last memory unit printed; this is not the same as the last
5448address printed if several units were printed on the last line of output.
5449
09d4efe1
EZ
5450@cindex remote memory comparison
5451@cindex verify remote memory image
5452When you are debugging a program running on a remote target machine
5453(@pxref{Remote}), you may wish to verify the program's image in the
5454remote machine's memory against the executable file you downloaded to
5455the target. The @code{compare-sections} command is provided for such
5456situations.
5457
5458@table @code
5459@kindex compare-sections
5460@item compare-sections @r{[}@var{section-name}@r{]}
5461Compare the data of a loadable section @var{section-name} in the
5462executable file of the program being debugged with the same section in
5463the remote machine's memory, and report any mismatches. With no
5464arguments, compares all loadable sections. This command's
5465availability depends on the target's support for the @code{"qCRC"}
5466remote request.
5467@end table
5468
6d2ebf8b 5469@node Auto Display
c906108c
SS
5470@section Automatic display
5471@cindex automatic display
5472@cindex display of expressions
5473
5474If you find that you want to print the value of an expression frequently
5475(to see how it changes), you might want to add it to the @dfn{automatic
5476display list} so that @value{GDBN} prints its value each time your program stops.
5477Each expression added to the list is given a number to identify it;
5478to remove an expression from the list, you specify that number.
5479The automatic display looks like this:
5480
474c8240 5481@smallexample
c906108c
SS
54822: foo = 38
54833: bar[5] = (struct hack *) 0x3804
474c8240 5484@end smallexample
c906108c
SS
5485
5486@noindent
5487This display shows item numbers, expressions and their current values. As with
5488displays you request manually using @code{x} or @code{print}, you can
5489specify the output format you prefer; in fact, @code{display} decides
5490whether to use @code{print} or @code{x} depending on how elaborate your
5491format specification is---it uses @code{x} if you specify a unit size,
5492or one of the two formats (@samp{i} and @samp{s}) that are only
5493supported by @code{x}; otherwise it uses @code{print}.
5494
5495@table @code
5496@kindex display
d4f3574e
SS
5497@item display @var{expr}
5498Add the expression @var{expr} to the list of expressions to display
c906108c
SS
5499each time your program stops. @xref{Expressions, ,Expressions}.
5500
5501@code{display} does not repeat if you press @key{RET} again after using it.
5502
d4f3574e 5503@item display/@var{fmt} @var{expr}
c906108c 5504For @var{fmt} specifying only a display format and not a size or
d4f3574e 5505count, add the expression @var{expr} to the auto-display list but
c906108c
SS
5506arrange to display it each time in the specified format @var{fmt}.
5507@xref{Output Formats,,Output formats}.
5508
5509@item display/@var{fmt} @var{addr}
5510For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a
5511number of units, add the expression @var{addr} as a memory address to
5512be examined each time your program stops. Examining means in effect
5513doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory, ,Examining memory}.
5514@end table
5515
5516For example, @samp{display/i $pc} can be helpful, to see the machine
5517instruction about to be executed each time execution stops (@samp{$pc}
d4f3574e 5518is a common name for the program counter; @pxref{Registers, ,Registers}).
c906108c
SS
5519
5520@table @code
5521@kindex delete display
5522@kindex undisplay
5523@item undisplay @var{dnums}@dots{}
5524@itemx delete display @var{dnums}@dots{}
5525Remove item numbers @var{dnums} from the list of expressions to display.
5526
5527@code{undisplay} does not repeat if you press @key{RET} after using it.
5528(Otherwise you would just get the error @samp{No display number @dots{}}.)
5529
5530@kindex disable display
5531@item disable display @var{dnums}@dots{}
5532Disable the display of item numbers @var{dnums}. A disabled display
5533item is not printed automatically, but is not forgotten. It may be
5534enabled again later.
5535
5536@kindex enable display
5537@item enable display @var{dnums}@dots{}
5538Enable display of item numbers @var{dnums}. It becomes effective once
5539again in auto display of its expression, until you specify otherwise.
5540
5541@item display
5542Display the current values of the expressions on the list, just as is
5543done when your program stops.
5544
5545@kindex info display
5546@item info display
5547Print the list of expressions previously set up to display
5548automatically, each one with its item number, but without showing the
5549values. This includes disabled expressions, which are marked as such.
5550It also includes expressions which would not be displayed right now
5551because they refer to automatic variables not currently available.
5552@end table
5553
15387254 5554@cindex display disabled out of scope
c906108c
SS
5555If a display expression refers to local variables, then it does not make
5556sense outside the lexical context for which it was set up. Such an
5557expression is disabled when execution enters a context where one of its
5558variables is not defined. For example, if you give the command
5559@code{display last_char} while inside a function with an argument
5560@code{last_char}, @value{GDBN} displays this argument while your program
5561continues to stop inside that function. When it stops elsewhere---where
5562there is no variable @code{last_char}---the display is disabled
5563automatically. The next time your program stops where @code{last_char}
5564is meaningful, you can enable the display expression once again.
5565
6d2ebf8b 5566@node Print Settings
c906108c
SS
5567@section Print settings
5568
5569@cindex format options
5570@cindex print settings
5571@value{GDBN} provides the following ways to control how arrays, structures,
5572and symbols are printed.
5573
5574@noindent
5575These settings are useful for debugging programs in any language:
5576
5577@table @code
4644b6e3 5578@kindex set print
c906108c
SS
5579@item set print address
5580@itemx set print address on
4644b6e3 5581@cindex print/don't print memory addresses
c906108c
SS
5582@value{GDBN} prints memory addresses showing the location of stack
5583traces, structure values, pointer values, breakpoints, and so forth,
5584even when it also displays the contents of those addresses. The default
5585is @code{on}. For example, this is what a stack frame display looks like with
5586@code{set print address on}:
5587
5588@smallexample
5589@group
5590(@value{GDBP}) f
5591#0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>")
5592 at input.c:530
5593530 if (lquote != def_lquote)
5594@end group
5595@end smallexample
5596
5597@item set print address off
5598Do not print addresses when displaying their contents. For example,
5599this is the same stack frame displayed with @code{set print address off}:
5600
5601@smallexample
5602@group
5603(@value{GDBP}) set print addr off
5604(@value{GDBP}) f
5605#0 set_quotes (lq="<<", rq=">>") at input.c:530
5606530 if (lquote != def_lquote)
5607@end group
5608@end smallexample
5609
5610You can use @samp{set print address off} to eliminate all machine
5611dependent displays from the @value{GDBN} interface. For example, with
5612@code{print address off}, you should get the same text for backtraces on
5613all machines---whether or not they involve pointer arguments.
5614
4644b6e3 5615@kindex show print
c906108c
SS
5616@item show print address
5617Show whether or not addresses are to be printed.
5618@end table
5619
5620When @value{GDBN} prints a symbolic address, it normally prints the
5621closest earlier symbol plus an offset. If that symbol does not uniquely
5622identify the address (for example, it is a name whose scope is a single
5623source file), you may need to clarify. One way to do this is with
5624@code{info line}, for example @samp{info line *0x4537}. Alternately,
5625you can set @value{GDBN} to print the source file and line number when
5626it prints a symbolic address:
5627
5628@table @code
c906108c 5629@item set print symbol-filename on
9c16f35a
EZ
5630@cindex source file and line of a symbol
5631@cindex symbol, source file and line
c906108c
SS
5632Tell @value{GDBN} to print the source file name and line number of a
5633symbol in the symbolic form of an address.
5634
5635@item set print symbol-filename off
5636Do not print source file name and line number of a symbol. This is the
5637default.
5638
c906108c
SS
5639@item show print symbol-filename
5640Show whether or not @value{GDBN} will print the source file name and
5641line number of a symbol in the symbolic form of an address.
5642@end table
5643
5644Another situation where it is helpful to show symbol filenames and line
5645numbers is when disassembling code; @value{GDBN} shows you the line
5646number and source file that corresponds to each instruction.
5647
5648Also, you may wish to see the symbolic form only if the address being
5649printed is reasonably close to the closest earlier symbol:
5650
5651@table @code
c906108c 5652@item set print max-symbolic-offset @var{max-offset}
4644b6e3 5653@cindex maximum value for offset of closest symbol
c906108c
SS
5654Tell @value{GDBN} to only display the symbolic form of an address if the
5655offset between the closest earlier symbol and the address is less than
5d161b24 5656@var{max-offset}. The default is 0, which tells @value{GDBN}
c906108c
SS
5657to always print the symbolic form of an address if any symbol precedes it.
5658
c906108c
SS
5659@item show print max-symbolic-offset
5660Ask how large the maximum offset is that @value{GDBN} prints in a
5661symbolic address.
5662@end table
5663
5664@cindex wild pointer, interpreting
5665@cindex pointer, finding referent
5666If you have a pointer and you are not sure where it points, try
5667@samp{set print symbol-filename on}. Then you can determine the name
5668and source file location of the variable where it points, using
5669@samp{p/a @var{pointer}}. This interprets the address in symbolic form.
5670For example, here @value{GDBN} shows that a variable @code{ptt} points
5671at another variable @code{t}, defined in @file{hi2.c}:
5672
474c8240 5673@smallexample
c906108c
SS
5674(@value{GDBP}) set print symbol-filename on
5675(@value{GDBP}) p/a ptt
5676$4 = 0xe008 <t in hi2.c>
474c8240 5677@end smallexample
c906108c
SS
5678
5679@quotation
5680@emph{Warning:} For pointers that point to a local variable, @samp{p/a}
5681does not show the symbol name and filename of the referent, even with
5682the appropriate @code{set print} options turned on.
5683@end quotation
5684
5685Other settings control how different kinds of objects are printed:
5686
5687@table @code
c906108c
SS
5688@item set print array
5689@itemx set print array on
4644b6e3 5690@cindex pretty print arrays
c906108c
SS
5691Pretty print arrays. This format is more convenient to read,
5692but uses more space. The default is off.
5693
5694@item set print array off
5695Return to compressed format for arrays.
5696
c906108c
SS
5697@item show print array
5698Show whether compressed or pretty format is selected for displaying
5699arrays.
5700
c906108c 5701@item set print elements @var{number-of-elements}
4644b6e3 5702@cindex number of array elements to print
9c16f35a 5703@cindex limit on number of printed array elements
c906108c
SS
5704Set a limit on how many elements of an array @value{GDBN} will print.
5705If @value{GDBN} is printing a large array, it stops printing after it has
5706printed the number of elements set by the @code{set print elements} command.
5707This limit also applies to the display of strings.
d4f3574e 5708When @value{GDBN} starts, this limit is set to 200.
c906108c
SS
5709Setting @var{number-of-elements} to zero means that the printing is unlimited.
5710
c906108c
SS
5711@item show print elements
5712Display the number of elements of a large array that @value{GDBN} will print.
5713If the number is 0, then the printing is unlimited.
5714
9c16f35a
EZ
5715@item set print repeats
5716@cindex repeated array elements
5717Set the threshold for suppressing display of repeated array
5718elelments. When the number of consecutive identical elements of an
5719array exceeds the threshold, @value{GDBN} prints the string
5720@code{"<repeats @var{n} times>"}, where @var{n} is the number of
5721identical repetitions, instead of displaying the identical elements
5722themselves. Setting the threshold to zero will cause all elements to
5723be individually printed. The default threshold is 10.
5724
5725@item show print repeats
5726Display the current threshold for printing repeated identical
5727elements.
5728
c906108c 5729@item set print null-stop
4644b6e3 5730@cindex @sc{null} elements in arrays
c906108c 5731Cause @value{GDBN} to stop printing the characters of an array when the first
d4f3574e 5732@sc{null} is encountered. This is useful when large arrays actually
c906108c 5733contain only short strings.
d4f3574e 5734The default is off.
c906108c 5735
9c16f35a
EZ
5736@item show print null-stop
5737Show whether @value{GDBN} stops printing an array on the first
5738@sc{null} character.
5739
c906108c 5740@item set print pretty on
9c16f35a
EZ
5741@cindex print structures in indented form
5742@cindex indentation in structure display
5d161b24 5743Cause @value{GDBN} to print structures in an indented format with one member
c906108c
SS
5744per line, like this:
5745
5746@smallexample
5747@group
5748$1 = @{
5749 next = 0x0,
5750 flags = @{
5751 sweet = 1,
5752 sour = 1
5753 @},
5754 meat = 0x54 "Pork"
5755@}
5756@end group
5757@end smallexample
5758
5759@item set print pretty off
5760Cause @value{GDBN} to print structures in a compact format, like this:
5761
5762@smallexample
5763@group
5764$1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, \
5765meat = 0x54 "Pork"@}
5766@end group
5767@end smallexample
5768
5769@noindent
5770This is the default format.
5771
c906108c
SS
5772@item show print pretty
5773Show which format @value{GDBN} is using to print structures.
5774
c906108c 5775@item set print sevenbit-strings on
4644b6e3
EZ
5776@cindex eight-bit characters in strings
5777@cindex octal escapes in strings
c906108c
SS
5778Print using only seven-bit characters; if this option is set,
5779@value{GDBN} displays any eight-bit characters (in strings or
5780character values) using the notation @code{\}@var{nnn}. This setting is
5781best if you are working in English (@sc{ascii}) and you use the
5782high-order bit of characters as a marker or ``meta'' bit.
5783
5784@item set print sevenbit-strings off
5785Print full eight-bit characters. This allows the use of more
5786international character sets, and is the default.
5787
c906108c
SS
5788@item show print sevenbit-strings
5789Show whether or not @value{GDBN} is printing only seven-bit characters.
5790
c906108c 5791@item set print union on
4644b6e3 5792@cindex unions in structures, printing
9c16f35a
EZ
5793Tell @value{GDBN} to print unions which are contained in structures
5794and other unions. This is the default setting.
c906108c
SS
5795
5796@item set print union off
9c16f35a
EZ
5797Tell @value{GDBN} not to print unions which are contained in
5798structures and other unions. @value{GDBN} will print @code{"@{...@}"}
5799instead.
c906108c 5800
c906108c
SS
5801@item show print union
5802Ask @value{GDBN} whether or not it will print unions which are contained in
9c16f35a 5803structures and other unions.
c906108c
SS
5804
5805For example, given the declarations
5806
5807@smallexample
5808typedef enum @{Tree, Bug@} Species;
5809typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms;
5d161b24 5810typedef enum @{Caterpillar, Cocoon, Butterfly@}
c906108c
SS
5811 Bug_forms;
5812
5813struct thing @{
5814 Species it;
5815 union @{
5816 Tree_forms tree;
5817 Bug_forms bug;
5818 @} form;
5819@};
5820
5821struct thing foo = @{Tree, @{Acorn@}@};
5822@end smallexample
5823
5824@noindent
5825with @code{set print union on} in effect @samp{p foo} would print
5826
5827@smallexample
5828$1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@}
5829@end smallexample
5830
5831@noindent
5832and with @code{set print union off} in effect it would print
5833
5834@smallexample
5835$1 = @{it = Tree, form = @{...@}@}
5836@end smallexample
9c16f35a
EZ
5837
5838@noindent
5839@code{set print union} affects programs written in C-like languages
5840and in Pascal.
c906108c
SS
5841@end table
5842
c906108c
SS
5843@need 1000
5844@noindent
b37052ae 5845These settings are of interest when debugging C@t{++} programs:
c906108c
SS
5846
5847@table @code
4644b6e3 5848@cindex demangling C@t{++} names
c906108c
SS
5849@item set print demangle
5850@itemx set print demangle on
b37052ae 5851Print C@t{++} names in their source form rather than in the encoded
c906108c 5852(``mangled'') form passed to the assembler and linker for type-safe
d4f3574e 5853linkage. The default is on.
c906108c 5854
c906108c 5855@item show print demangle
b37052ae 5856Show whether C@t{++} names are printed in mangled or demangled form.
c906108c 5857
c906108c
SS
5858@item set print asm-demangle
5859@itemx set print asm-demangle on
b37052ae 5860Print C@t{++} names in their source form rather than their mangled form, even
c906108c
SS
5861in assembler code printouts such as instruction disassemblies.
5862The default is off.
5863
c906108c 5864@item show print asm-demangle
b37052ae 5865Show whether C@t{++} names in assembly listings are printed in mangled
c906108c
SS
5866or demangled form.
5867
b37052ae
EZ
5868@cindex C@t{++} symbol decoding style
5869@cindex symbol decoding style, C@t{++}
a8f24a35 5870@kindex set demangle-style
c906108c
SS
5871@item set demangle-style @var{style}
5872Choose among several encoding schemes used by different compilers to
b37052ae 5873represent C@t{++} names. The choices for @var{style} are currently:
c906108c
SS
5874
5875@table @code
5876@item auto
5877Allow @value{GDBN} to choose a decoding style by inspecting your program.
5878
5879@item gnu
b37052ae 5880Decode based on the @sc{gnu} C@t{++} compiler (@code{g++}) encoding algorithm.
c906108c 5881This is the default.
c906108c
SS
5882
5883@item hp
b37052ae 5884Decode based on the HP ANSI C@t{++} (@code{aCC}) encoding algorithm.
c906108c
SS
5885
5886@item lucid
b37052ae 5887Decode based on the Lucid C@t{++} compiler (@code{lcc}) encoding algorithm.
c906108c
SS
5888
5889@item arm
b37052ae 5890Decode using the algorithm in the @cite{C@t{++} Annotated Reference Manual}.
c906108c
SS
5891@strong{Warning:} this setting alone is not sufficient to allow
5892debugging @code{cfront}-generated executables. @value{GDBN} would
5893require further enhancement to permit that.
5894
5895@end table
5896If you omit @var{style}, you will see a list of possible formats.
5897
c906108c 5898@item show demangle-style
b37052ae 5899Display the encoding style currently in use for decoding C@t{++} symbols.
c906108c 5900
c906108c
SS
5901@item set print object
5902@itemx set print object on
4644b6e3 5903@cindex derived type of an object, printing
9c16f35a 5904@cindex display derived types
c906108c
SS
5905When displaying a pointer to an object, identify the @emph{actual}
5906(derived) type of the object rather than the @emph{declared} type, using
5907the virtual function table.
5908
5909@item set print object off
5910Display only the declared type of objects, without reference to the
5911virtual function table. This is the default setting.
5912
c906108c
SS
5913@item show print object
5914Show whether actual, or declared, object types are displayed.
5915
c906108c
SS
5916@item set print static-members
5917@itemx set print static-members on
4644b6e3 5918@cindex static members of C@t{++} objects
b37052ae 5919Print static members when displaying a C@t{++} object. The default is on.
c906108c
SS
5920
5921@item set print static-members off
b37052ae 5922Do not print static members when displaying a C@t{++} object.
c906108c 5923
c906108c 5924@item show print static-members
9c16f35a
EZ
5925Show whether C@t{++} static members are printed or not.
5926
5927@item set print pascal_static-members
5928@itemx set print pascal_static-members on
5929@cindex static members of Pacal objects
5930@cindex Pacal objects, static members display
5931Print static members when displaying a Pascal object. The default is on.
5932
5933@item set print pascal_static-members off
5934Do not print static members when displaying a Pascal object.
5935
5936@item show print pascal_static-members
5937Show whether Pascal static members are printed or not.
c906108c
SS
5938
5939@c These don't work with HP ANSI C++ yet.
c906108c
SS
5940@item set print vtbl
5941@itemx set print vtbl on
4644b6e3 5942@cindex pretty print C@t{++} virtual function tables
9c16f35a
EZ
5943@cindex virtual functions (C@t{++}) display
5944@cindex VTBL display
b37052ae 5945Pretty print C@t{++} virtual function tables. The default is off.
c906108c 5946(The @code{vtbl} commands do not work on programs compiled with the HP
b37052ae 5947ANSI C@t{++} compiler (@code{aCC}).)
c906108c
SS
5948
5949@item set print vtbl off
b37052ae 5950Do not pretty print C@t{++} virtual function tables.
c906108c 5951
c906108c 5952@item show print vtbl
b37052ae 5953Show whether C@t{++} virtual function tables are pretty printed, or not.
c906108c 5954@end table
c906108c 5955
6d2ebf8b 5956@node Value History
c906108c
SS
5957@section Value history
5958
5959@cindex value history
9c16f35a 5960@cindex history of values printed by @value{GDBN}
5d161b24
DB
5961Values printed by the @code{print} command are saved in the @value{GDBN}
5962@dfn{value history}. This allows you to refer to them in other expressions.
5963Values are kept until the symbol table is re-read or discarded
5964(for example with the @code{file} or @code{symbol-file} commands).
5965When the symbol table changes, the value history is discarded,
5966since the values may contain pointers back to the types defined in the
c906108c
SS
5967symbol table.
5968
5969@cindex @code{$}
5970@cindex @code{$$}
5971@cindex history number
5972The values printed are given @dfn{history numbers} by which you can
5973refer to them. These are successive integers starting with one.
5974@code{print} shows you the history number assigned to a value by
5975printing @samp{$@var{num} = } before the value; here @var{num} is the
5976history number.
5977
5978To refer to any previous value, use @samp{$} followed by the value's
5979history number. The way @code{print} labels its output is designed to
5980remind you of this. Just @code{$} refers to the most recent value in
5981the history, and @code{$$} refers to the value before that.
5982@code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2}
5983is the value just prior to @code{$$}, @code{$$1} is equivalent to
5984@code{$$}, and @code{$$0} is equivalent to @code{$}.
5985
5986For example, suppose you have just printed a pointer to a structure and
5987want to see the contents of the structure. It suffices to type
5988
474c8240 5989@smallexample
c906108c 5990p *$
474c8240 5991@end smallexample
c906108c
SS
5992
5993If you have a chain of structures where the component @code{next} points
5994to the next one, you can print the contents of the next one with this:
5995
474c8240 5996@smallexample
c906108c 5997p *$.next
474c8240 5998@end smallexample
c906108c
SS
5999
6000@noindent
6001You can print successive links in the chain by repeating this
6002command---which you can do by just typing @key{RET}.
6003
6004Note that the history records values, not expressions. If the value of
6005@code{x} is 4 and you type these commands:
6006
474c8240 6007@smallexample
c906108c
SS
6008print x
6009set x=5
474c8240 6010@end smallexample
c906108c
SS
6011
6012@noindent
6013then the value recorded in the value history by the @code{print} command
6014remains 4 even though the value of @code{x} has changed.
6015
6016@table @code
6017@kindex show values
6018@item show values
6019Print the last ten values in the value history, with their item numbers.
6020This is like @samp{p@ $$9} repeated ten times, except that @code{show
6021values} does not change the history.
6022
6023@item show values @var{n}
6024Print ten history values centered on history item number @var{n}.
6025
6026@item show values +
6027Print ten history values just after the values last printed. If no more
6028values are available, @code{show values +} produces no display.
6029@end table
6030
6031Pressing @key{RET} to repeat @code{show values @var{n}} has exactly the
6032same effect as @samp{show values +}.
6033
6d2ebf8b 6034@node Convenience Vars
c906108c
SS
6035@section Convenience variables
6036
6037@cindex convenience variables
9c16f35a 6038@cindex user-defined variables
c906108c
SS
6039@value{GDBN} provides @dfn{convenience variables} that you can use within
6040@value{GDBN} to hold on to a value and refer to it later. These variables
6041exist entirely within @value{GDBN}; they are not part of your program, and
6042setting a convenience variable has no direct effect on further execution
6043of your program. That is why you can use them freely.
6044
6045Convenience variables are prefixed with @samp{$}. Any name preceded by
6046@samp{$} can be used for a convenience variable, unless it is one of
d4f3574e 6047the predefined machine-specific register names (@pxref{Registers, ,Registers}).
c906108c
SS
6048(Value history references, in contrast, are @emph{numbers} preceded
6049by @samp{$}. @xref{Value History, ,Value history}.)
6050
6051You can save a value in a convenience variable with an assignment
6052expression, just as you would set a variable in your program.
6053For example:
6054
474c8240 6055@smallexample
c906108c 6056set $foo = *object_ptr
474c8240 6057@end smallexample
c906108c
SS
6058
6059@noindent
6060would save in @code{$foo} the value contained in the object pointed to by
6061@code{object_ptr}.
6062
6063Using a convenience variable for the first time creates it, but its
6064value is @code{void} until you assign a new value. You can alter the
6065value with another assignment at any time.
6066
6067Convenience variables have no fixed types. You can assign a convenience
6068variable any type of value, including structures and arrays, even if
6069that variable already has a value of a different type. The convenience
6070variable, when used as an expression, has the type of its current value.
6071
6072@table @code
6073@kindex show convenience
9c16f35a 6074@cindex show all user variables
c906108c
SS
6075@item show convenience
6076Print a list of convenience variables used so far, and their values.
d4f3574e 6077Abbreviated @code{show conv}.
c906108c
SS
6078@end table
6079
6080One of the ways to use a convenience variable is as a counter to be
6081incremented or a pointer to be advanced. For example, to print
6082a field from successive elements of an array of structures:
6083
474c8240 6084@smallexample
c906108c
SS
6085set $i = 0
6086print bar[$i++]->contents
474c8240 6087@end smallexample
c906108c 6088
d4f3574e
SS
6089@noindent
6090Repeat that command by typing @key{RET}.
c906108c
SS
6091
6092Some convenience variables are created automatically by @value{GDBN} and given
6093values likely to be useful.
6094
6095@table @code
41afff9a 6096@vindex $_@r{, convenience variable}
c906108c
SS
6097@item $_
6098The variable @code{$_} is automatically set by the @code{x} command to
6099the last address examined (@pxref{Memory, ,Examining memory}). Other
6100commands which provide a default address for @code{x} to examine also
6101set @code{$_} to that address; these commands include @code{info line}
6102and @code{info breakpoint}. The type of @code{$_} is @code{void *}
6103except when set by the @code{x} command, in which case it is a pointer
6104to the type of @code{$__}.
6105
41afff9a 6106@vindex $__@r{, convenience variable}
c906108c
SS
6107@item $__
6108The variable @code{$__} is automatically set by the @code{x} command
6109to the value found in the last address examined. Its type is chosen
6110to match the format in which the data was printed.
6111
6112@item $_exitcode
41afff9a 6113@vindex $_exitcode@r{, convenience variable}
c906108c
SS
6114The variable @code{$_exitcode} is automatically set to the exit code when
6115the program being debugged terminates.
6116@end table
6117
53a5351d
JM
6118On HP-UX systems, if you refer to a function or variable name that
6119begins with a dollar sign, @value{GDBN} searches for a user or system
6120name first, before it searches for a convenience variable.
c906108c 6121
6d2ebf8b 6122@node Registers
c906108c
SS
6123@section Registers
6124
6125@cindex registers
6126You can refer to machine register contents, in expressions, as variables
6127with names starting with @samp{$}. The names of registers are different
6128for each machine; use @code{info registers} to see the names used on
6129your machine.
6130
6131@table @code
6132@kindex info registers
6133@item info registers
6134Print the names and values of all registers except floating-point
c85508ee 6135and vector registers (in the selected stack frame).
c906108c
SS
6136
6137@kindex info all-registers
6138@cindex floating point registers
6139@item info all-registers
6140Print the names and values of all registers, including floating-point
c85508ee 6141and vector registers (in the selected stack frame).
c906108c
SS
6142
6143@item info registers @var{regname} @dots{}
6144Print the @dfn{relativized} value of each specified register @var{regname}.
5d161b24
DB
6145As discussed in detail below, register values are normally relative to
6146the selected stack frame. @var{regname} may be any register name valid on
c906108c
SS
6147the machine you are using, with or without the initial @samp{$}.
6148@end table
6149
e09f16f9
EZ
6150@cindex stack pointer register
6151@cindex program counter register
6152@cindex process status register
6153@cindex frame pointer register
6154@cindex standard registers
c906108c
SS
6155@value{GDBN} has four ``standard'' register names that are available (in
6156expressions) on most machines---whenever they do not conflict with an
6157architecture's canonical mnemonics for registers. The register names
6158@code{$pc} and @code{$sp} are used for the program counter register and
6159the stack pointer. @code{$fp} is used for a register that contains a
6160pointer to the current stack frame, and @code{$ps} is used for a
6161register that contains the processor status. For example,
6162you could print the program counter in hex with
6163
474c8240 6164@smallexample
c906108c 6165p/x $pc
474c8240 6166@end smallexample
c906108c
SS
6167
6168@noindent
6169or print the instruction to be executed next with
6170
474c8240 6171@smallexample
c906108c 6172x/i $pc
474c8240 6173@end smallexample
c906108c
SS
6174
6175@noindent
6176or add four to the stack pointer@footnote{This is a way of removing
6177one word from the stack, on machines where stacks grow downward in
6178memory (most machines, nowadays). This assumes that the innermost
6179stack frame is selected; setting @code{$sp} is not allowed when other
6180stack frames are selected. To pop entire frames off the stack,
6181regardless of machine architecture, use @code{return};
d4f3574e 6182see @ref{Returning, ,Returning from a function}.} with
c906108c 6183
474c8240 6184@smallexample
c906108c 6185set $sp += 4
474c8240 6186@end smallexample
c906108c
SS
6187
6188Whenever possible, these four standard register names are available on
6189your machine even though the machine has different canonical mnemonics,
6190so long as there is no conflict. The @code{info registers} command
6191shows the canonical names. For example, on the SPARC, @code{info
6192registers} displays the processor status register as @code{$psr} but you
d4f3574e
SS
6193can also refer to it as @code{$ps}; and on x86-based machines @code{$ps}
6194is an alias for the @sc{eflags} register.
c906108c
SS
6195
6196@value{GDBN} always considers the contents of an ordinary register as an
6197integer when the register is examined in this way. Some machines have
6198special registers which can hold nothing but floating point; these
6199registers are considered to have floating point values. There is no way
6200to refer to the contents of an ordinary register as floating point value
6201(although you can @emph{print} it as a floating point value with
6202@samp{print/f $@var{regname}}).
6203
6204Some registers have distinct ``raw'' and ``virtual'' data formats. This
6205means that the data format in which the register contents are saved by
6206the operating system is not the same one that your program normally
6207sees. For example, the registers of the 68881 floating point
6208coprocessor are always saved in ``extended'' (raw) format, but all C
6209programs expect to work with ``double'' (virtual) format. In such
5d161b24 6210cases, @value{GDBN} normally works with the virtual format only (the format
c906108c
SS
6211that makes sense for your program), but the @code{info registers} command
6212prints the data in both formats.
6213
6214Normally, register values are relative to the selected stack frame
6215(@pxref{Selection, ,Selecting a frame}). This means that you get the
6216value that the register would contain if all stack frames farther in
6217were exited and their saved registers restored. In order to see the
6218true contents of hardware registers, you must select the innermost
6219frame (with @samp{frame 0}).
6220
6221However, @value{GDBN} must deduce where registers are saved, from the machine
6222code generated by your compiler. If some registers are not saved, or if
6223@value{GDBN} is unable to locate the saved registers, the selected stack
6224frame makes no difference.
6225
6d2ebf8b 6226@node Floating Point Hardware
c906108c
SS
6227@section Floating point hardware
6228@cindex floating point
6229
6230Depending on the configuration, @value{GDBN} may be able to give
6231you more information about the status of the floating point hardware.
6232
6233@table @code
6234@kindex info float
6235@item info float
6236Display hardware-dependent information about the floating
6237point unit. The exact contents and layout vary depending on the
6238floating point chip. Currently, @samp{info float} is supported on
6239the ARM and x86 machines.
6240@end table
c906108c 6241
e76f1f2e
AC
6242@node Vector Unit
6243@section Vector Unit
6244@cindex vector unit
6245
6246Depending on the configuration, @value{GDBN} may be able to give you
6247more information about the status of the vector unit.
6248
6249@table @code
6250@kindex info vector
6251@item info vector
6252Display information about the vector unit. The exact contents and
6253layout vary depending on the hardware.
6254@end table
6255
721c2651
EZ
6256@node OS Information
6257@section Operating system auxiliary information
6258@cindex OS information
6259
6260@value{GDBN} provides interfaces to useful OS facilities that can help
6261you debug your program.
6262
6263@cindex @code{ptrace} system call
6264@cindex @code{struct user} contents
6265When @value{GDBN} runs on a @dfn{Posix system} (such as GNU or Unix
6266machines), it interfaces with the inferior via the @code{ptrace}
6267system call. The operating system creates a special sata structure,
6268called @code{struct user}, for this interface. You can use the
6269command @code{info udot} to display the contents of this data
6270structure.
6271
6272@table @code
6273@item info udot
6274@kindex info udot
6275Display the contents of the @code{struct user} maintained by the OS
6276kernel for the program being debugged. @value{GDBN} displays the
6277contents of @code{struct user} as a list of hex numbers, similar to
6278the @code{examine} command.
6279@end table
6280
b383017d
RM
6281@cindex auxiliary vector
6282@cindex vector, auxiliary
b383017d
RM
6283Some operating systems supply an @dfn{auxiliary vector} to programs at
6284startup. This is akin to the arguments and environment that you
6285specify for a program, but contains a system-dependent variety of
6286binary values that tell system libraries important details about the
6287hardware, operating system, and process. Each value's purpose is
6288identified by an integer tag; the meanings are well-known but system-specific.
6289Depending on the configuration and operating system facilities,
9c16f35a
EZ
6290@value{GDBN} may be able to show you this information. For remote
6291targets, this functionality may further depend on the remote stub's
6292support of the @samp{qPart:auxv:read} packet, see @ref{Remote
6293configuration, auxiliary vector}.
b383017d
RM
6294
6295@table @code
6296@kindex info auxv
6297@item info auxv
6298Display the auxiliary vector of the inferior, which can be either a
e4937fc1 6299live process or a core dump file. @value{GDBN} prints each tag value
b383017d
RM
6300numerically, and also shows names and text descriptions for recognized
6301tags. Some values in the vector are numbers, some bit masks, and some
e4937fc1 6302pointers to strings or other data. @value{GDBN} displays each value in the
b383017d
RM
6303most appropriate form for a recognized tag, and in hexadecimal for
6304an unrecognized tag.
6305@end table
6306
721c2651 6307
29e57380 6308@node Memory Region Attributes
b383017d 6309@section Memory region attributes
29e57380
C
6310@cindex memory region attributes
6311
b383017d
RM
6312@dfn{Memory region attributes} allow you to describe special handling
6313required by regions of your target's memory. @value{GDBN} uses attributes
29e57380
C
6314to determine whether to allow certain types of memory accesses; whether to
6315use specific width accesses; and whether to cache target memory.
6316
6317Defined memory regions can be individually enabled and disabled. When a
6318memory region is disabled, @value{GDBN} uses the default attributes when
6319accessing memory in that region. Similarly, if no memory regions have
6320been defined, @value{GDBN} uses the default attributes when accessing
6321all memory.
6322
b383017d 6323When a memory region is defined, it is given a number to identify it;
29e57380
C
6324to enable, disable, or remove a memory region, you specify that number.
6325
6326@table @code
6327@kindex mem
bfac230e 6328@item mem @var{lower} @var{upper} @var{attributes}@dots{}
09d4efe1
EZ
6329Define a memory region bounded by @var{lower} and @var{upper} with
6330attributes @var{attributes}@dots{}, and add it to the list of regions
6331monitored by @value{GDBN}. Note that @var{upper} == 0 is a special
6332case: it is treated as the the target's maximum memory address.
bfac230e 6333(0xffff on 16 bit targets, 0xffffffff on 32 bit targets, etc.)
29e57380
C
6334
6335@kindex delete mem
6336@item delete mem @var{nums}@dots{}
09d4efe1
EZ
6337Remove memory regions @var{nums}@dots{} from the list of regions
6338monitored by @value{GDBN}.
29e57380
C
6339
6340@kindex disable mem
6341@item disable mem @var{nums}@dots{}
09d4efe1 6342Disable monitoring of memory regions @var{nums}@dots{}.
b383017d 6343A disabled memory region is not forgotten.
29e57380
C
6344It may be enabled again later.
6345
6346@kindex enable mem
6347@item enable mem @var{nums}@dots{}
09d4efe1 6348Enable monitoring of memory regions @var{nums}@dots{}.
29e57380
C
6349
6350@kindex info mem
6351@item info mem
6352Print a table of all defined memory regions, with the following columns
09d4efe1 6353for each region:
29e57380
C
6354
6355@table @emph
6356@item Memory Region Number
6357@item Enabled or Disabled.
b383017d 6358Enabled memory regions are marked with @samp{y}.
29e57380
C
6359Disabled memory regions are marked with @samp{n}.
6360
6361@item Lo Address
6362The address defining the inclusive lower bound of the memory region.
6363
6364@item Hi Address
6365The address defining the exclusive upper bound of the memory region.
6366
6367@item Attributes
6368The list of attributes set for this memory region.
6369@end table
6370@end table
6371
6372
6373@subsection Attributes
6374
b383017d 6375@subsubsection Memory Access Mode
29e57380
C
6376The access mode attributes set whether @value{GDBN} may make read or
6377write accesses to a memory region.
6378
6379While these attributes prevent @value{GDBN} from performing invalid
6380memory accesses, they do nothing to prevent the target system, I/O DMA,
6381etc. from accessing memory.
6382
6383@table @code
6384@item ro
6385Memory is read only.
6386@item wo
6387Memory is write only.
6388@item rw
6ca652b0 6389Memory is read/write. This is the default.
29e57380
C
6390@end table
6391
6392@subsubsection Memory Access Size
6393The acccess size attributes tells @value{GDBN} to use specific sized
6394accesses in the memory region. Often memory mapped device registers
6395require specific sized accesses. If no access size attribute is
6396specified, @value{GDBN} may use accesses of any size.
6397
6398@table @code
6399@item 8
6400Use 8 bit memory accesses.
6401@item 16
6402Use 16 bit memory accesses.
6403@item 32
6404Use 32 bit memory accesses.
6405@item 64
6406Use 64 bit memory accesses.
6407@end table
6408
6409@c @subsubsection Hardware/Software Breakpoints
6410@c The hardware/software breakpoint attributes set whether @value{GDBN}
6411@c will use hardware or software breakpoints for the internal breakpoints
6412@c used by the step, next, finish, until, etc. commands.
6413@c
6414@c @table @code
6415@c @item hwbreak
b383017d 6416@c Always use hardware breakpoints
29e57380
C
6417@c @item swbreak (default)
6418@c @end table
6419
6420@subsubsection Data Cache
6421The data cache attributes set whether @value{GDBN} will cache target
6422memory. While this generally improves performance by reducing debug
6423protocol overhead, it can lead to incorrect results because @value{GDBN}
6424does not know about volatile variables or memory mapped device
6425registers.
6426
6427@table @code
6428@item cache
b383017d 6429Enable @value{GDBN} to cache target memory.
6ca652b0
EZ
6430@item nocache
6431Disable @value{GDBN} from caching target memory. This is the default.
29e57380
C
6432@end table
6433
6434@c @subsubsection Memory Write Verification
b383017d 6435@c The memory write verification attributes set whether @value{GDBN}
29e57380
C
6436@c will re-reads data after each write to verify the write was successful.
6437@c
6438@c @table @code
6439@c @item verify
6440@c @item noverify (default)
6441@c @end table
6442
16d9dec6
MS
6443@node Dump/Restore Files
6444@section Copy between memory and a file
6445@cindex dump/restore files
6446@cindex append data to a file
6447@cindex dump data to a file
6448@cindex restore data from a file
16d9dec6 6449
df5215a6
JB
6450You can use the commands @code{dump}, @code{append}, and
6451@code{restore} to copy data between target memory and a file. The
6452@code{dump} and @code{append} commands write data to a file, and the
6453@code{restore} command reads data from a file back into the inferior's
6454memory. Files may be in binary, Motorola S-record, Intel hex, or
6455Tektronix Hex format; however, @value{GDBN} can only append to binary
6456files.
6457
6458@table @code
6459
6460@kindex dump
6461@item dump @r{[}@var{format}@r{]} memory @var{filename} @var{start_addr} @var{end_addr}
6462@itemx dump @r{[}@var{format}@r{]} value @var{filename} @var{expr}
6463Dump the contents of memory from @var{start_addr} to @var{end_addr},
6464or the value of @var{expr}, to @var{filename} in the given format.
16d9dec6 6465
df5215a6 6466The @var{format} parameter may be any one of:
16d9dec6 6467@table @code
df5215a6
JB
6468@item binary
6469Raw binary form.
6470@item ihex
6471Intel hex format.
6472@item srec
6473Motorola S-record format.
6474@item tekhex
6475Tektronix Hex format.
6476@end table
6477
6478@value{GDBN} uses the same definitions of these formats as the
6479@sc{gnu} binary utilities, like @samp{objdump} and @samp{objcopy}. If
6480@var{format} is omitted, @value{GDBN} dumps the data in raw binary
6481form.
6482
6483@kindex append
6484@item append @r{[}binary@r{]} memory @var{filename} @var{start_addr} @var{end_addr}
6485@itemx append @r{[}binary@r{]} value @var{filename} @var{expr}
6486Append the contents of memory from @var{start_addr} to @var{end_addr},
09d4efe1 6487or the value of @var{expr}, to the file @var{filename}, in raw binary form.
df5215a6
JB
6488(@value{GDBN} can only append data to files in raw binary form.)
6489
6490@kindex restore
6491@item restore @var{filename} @r{[}binary@r{]} @var{bias} @var{start} @var{end}
6492Restore the contents of file @var{filename} into memory. The
6493@code{restore} command can automatically recognize any known @sc{bfd}
6494file format, except for raw binary. To restore a raw binary file you
6495must specify the optional keyword @code{binary} after the filename.
16d9dec6 6496
b383017d 6497If @var{bias} is non-zero, its value will be added to the addresses
16d9dec6
MS
6498contained in the file. Binary files always start at address zero, so
6499they will be restored at address @var{bias}. Other bfd files have
6500a built-in location; they will be restored at offset @var{bias}
6501from that location.
6502
6503If @var{start} and/or @var{end} are non-zero, then only data between
6504file offset @var{start} and file offset @var{end} will be restored.
b383017d 6505These offsets are relative to the addresses in the file, before
16d9dec6
MS
6506the @var{bias} argument is applied.
6507
6508@end table
6509
384ee23f
EZ
6510@node Core File Generation
6511@section How to Produce a Core File from Your Program
6512@cindex dump core from inferior
6513
6514A @dfn{core file} or @dfn{core dump} is a file that records the memory
6515image of a running process and its process status (register values
6516etc.). Its primary use is post-mortem debugging of a program that
6517crashed while it ran outside a debugger. A program that crashes
6518automatically produces a core file, unless this feature is disabled by
6519the user. @xref{Files}, for information on invoking @value{GDBN} in
6520the post-mortem debugging mode.
6521
6522Occasionally, you may wish to produce a core file of the program you
6523are debugging in order to preserve a snapshot of its state.
6524@value{GDBN} has a special command for that.
6525
6526@table @code
6527@kindex gcore
6528@kindex generate-core-file
6529@item generate-core-file [@var{file}]
6530@itemx gcore [@var{file}]
6531Produce a core dump of the inferior process. The optional argument
6532@var{file} specifies the file name where to put the core dump. If not
6533specified, the file name defaults to @file{core.@var{pid}}, where
6534@var{pid} is the inferior process ID.
6535
6536Note that this command is implemented only for some systems (as of
6537this writing, @sc{gnu}/Linux, FreeBSD, Solaris, Unixware, and S390).
6538@end table
6539
a0eb71c5
KB
6540@node Character Sets
6541@section Character Sets
6542@cindex character sets
6543@cindex charset
6544@cindex translating between character sets
6545@cindex host character set
6546@cindex target character set
6547
6548If the program you are debugging uses a different character set to
6549represent characters and strings than the one @value{GDBN} uses itself,
6550@value{GDBN} can automatically translate between the character sets for
6551you. The character set @value{GDBN} uses we call the @dfn{host
6552character set}; the one the inferior program uses we call the
6553@dfn{target character set}.
6554
6555For example, if you are running @value{GDBN} on a @sc{gnu}/Linux system, which
6556uses the ISO Latin 1 character set, but you are using @value{GDBN}'s
6557remote protocol (@pxref{Remote,Remote Debugging}) to debug a program
6558running on an IBM mainframe, which uses the @sc{ebcdic} character set,
6559then the host character set is Latin-1, and the target character set is
6560@sc{ebcdic}. If you give @value{GDBN} the command @code{set
e33d66ec 6561target-charset EBCDIC-US}, then @value{GDBN} translates between
a0eb71c5
KB
6562@sc{ebcdic} and Latin 1 as you print character or string values, or use
6563character and string literals in expressions.
6564
6565@value{GDBN} has no way to automatically recognize which character set
6566the inferior program uses; you must tell it, using the @code{set
6567target-charset} command, described below.
6568
6569Here are the commands for controlling @value{GDBN}'s character set
6570support:
6571
6572@table @code
6573@item set target-charset @var{charset}
6574@kindex set target-charset
6575Set the current target character set to @var{charset}. We list the
e33d66ec
EZ
6576character set names @value{GDBN} recognizes below, but if you type
6577@code{set target-charset} followed by @key{TAB}@key{TAB}, @value{GDBN} will
6578list the target character sets it supports.
a0eb71c5
KB
6579@end table
6580
6581@table @code
6582@item set host-charset @var{charset}
6583@kindex set host-charset
6584Set the current host character set to @var{charset}.
6585
6586By default, @value{GDBN} uses a host character set appropriate to the
6587system it is running on; you can override that default using the
6588@code{set host-charset} command.
6589
6590@value{GDBN} can only use certain character sets as its host character
6591set. We list the character set names @value{GDBN} recognizes below, and
e33d66ec
EZ
6592indicate which can be host character sets, but if you type
6593@code{set target-charset} followed by @key{TAB}@key{TAB}, @value{GDBN} will
6594list the host character sets it supports.
a0eb71c5
KB
6595
6596@item set charset @var{charset}
6597@kindex set charset
e33d66ec
EZ
6598Set the current host and target character sets to @var{charset}. As
6599above, if you type @code{set charset} followed by @key{TAB}@key{TAB},
6600@value{GDBN} will list the name of the character sets that can be used
6601for both host and target.
6602
a0eb71c5
KB
6603
6604@item show charset
a0eb71c5 6605@kindex show charset
b383017d 6606Show the names of the current host and target charsets.
e33d66ec
EZ
6607
6608@itemx show host-charset
a0eb71c5 6609@kindex show host-charset
b383017d 6610Show the name of the current host charset.
e33d66ec
EZ
6611
6612@itemx show target-charset
a0eb71c5 6613@kindex show target-charset
b383017d 6614Show the name of the current target charset.
a0eb71c5
KB
6615
6616@end table
6617
6618@value{GDBN} currently includes support for the following character
6619sets:
6620
6621@table @code
6622
6623@item ASCII
6624@cindex ASCII character set
6625Seven-bit U.S. @sc{ascii}. @value{GDBN} can use this as its host
6626character set.
6627
6628@item ISO-8859-1
6629@cindex ISO 8859-1 character set
6630@cindex ISO Latin 1 character set
e33d66ec 6631The ISO Latin 1 character set. This extends @sc{ascii} with accented
a0eb71c5
KB
6632characters needed for French, German, and Spanish. @value{GDBN} can use
6633this as its host character set.
6634
6635@item EBCDIC-US
6636@itemx IBM1047
6637@cindex EBCDIC character set
6638@cindex IBM1047 character set
6639Variants of the @sc{ebcdic} character set, used on some of IBM's
6640mainframe operating systems. (@sc{gnu}/Linux on the S/390 uses U.S. @sc{ascii}.)
6641@value{GDBN} cannot use these as its host character set.
6642
6643@end table
6644
6645Note that these are all single-byte character sets. More work inside
6646GDB is needed to support multi-byte or variable-width character
6647encodings, like the UTF-8 and UCS-2 encodings of Unicode.
6648
6649Here is an example of @value{GDBN}'s character set support in action.
6650Assume that the following source code has been placed in the file
6651@file{charset-test.c}:
6652
6653@smallexample
6654#include <stdio.h>
6655
6656char ascii_hello[]
6657 = @{72, 101, 108, 108, 111, 44, 32, 119,
6658 111, 114, 108, 100, 33, 10, 0@};
6659char ibm1047_hello[]
6660 = @{200, 133, 147, 147, 150, 107, 64, 166,
6661 150, 153, 147, 132, 90, 37, 0@};
6662
6663main ()
6664@{
6665 printf ("Hello, world!\n");
6666@}
10998722 6667@end smallexample
a0eb71c5
KB
6668
6669In this program, @code{ascii_hello} and @code{ibm1047_hello} are arrays
6670containing the string @samp{Hello, world!} followed by a newline,
6671encoded in the @sc{ascii} and @sc{ibm1047} character sets.
6672
6673We compile the program, and invoke the debugger on it:
6674
6675@smallexample
6676$ gcc -g charset-test.c -o charset-test
6677$ gdb -nw charset-test
6678GNU gdb 2001-12-19-cvs
6679Copyright 2001 Free Software Foundation, Inc.
6680@dots{}
f7dc1244 6681(@value{GDBP})
10998722 6682@end smallexample
a0eb71c5
KB
6683
6684We can use the @code{show charset} command to see what character sets
6685@value{GDBN} is currently using to interpret and display characters and
6686strings:
6687
6688@smallexample
f7dc1244 6689(@value{GDBP}) show charset
e33d66ec 6690The current host and target character set is `ISO-8859-1'.
f7dc1244 6691(@value{GDBP})
10998722 6692@end smallexample
a0eb71c5
KB
6693
6694For the sake of printing this manual, let's use @sc{ascii} as our
6695initial character set:
6696@smallexample
f7dc1244
EZ
6697(@value{GDBP}) set charset ASCII
6698(@value{GDBP}) show charset
e33d66ec 6699The current host and target character set is `ASCII'.
f7dc1244 6700(@value{GDBP})
10998722 6701@end smallexample
a0eb71c5
KB
6702
6703Let's assume that @sc{ascii} is indeed the correct character set for our
6704host system --- in other words, let's assume that if @value{GDBN} prints
6705characters using the @sc{ascii} character set, our terminal will display
6706them properly. Since our current target character set is also
6707@sc{ascii}, the contents of @code{ascii_hello} print legibly:
6708
6709@smallexample
f7dc1244 6710(@value{GDBP}) print ascii_hello
a0eb71c5 6711$1 = 0x401698 "Hello, world!\n"
f7dc1244 6712(@value{GDBP}) print ascii_hello[0]
a0eb71c5 6713$2 = 72 'H'
f7dc1244 6714(@value{GDBP})
10998722 6715@end smallexample
a0eb71c5
KB
6716
6717@value{GDBN} uses the target character set for character and string
6718literals you use in expressions:
6719
6720@smallexample
f7dc1244 6721(@value{GDBP}) print '+'
a0eb71c5 6722$3 = 43 '+'
f7dc1244 6723(@value{GDBP})
10998722 6724@end smallexample
a0eb71c5
KB
6725
6726The @sc{ascii} character set uses the number 43 to encode the @samp{+}
6727character.
6728
6729@value{GDBN} relies on the user to tell it which character set the
6730target program uses. If we print @code{ibm1047_hello} while our target
6731character set is still @sc{ascii}, we get jibberish:
6732
6733@smallexample
f7dc1244 6734(@value{GDBP}) print ibm1047_hello
a0eb71c5 6735$4 = 0x4016a8 "\310\205\223\223\226k@@\246\226\231\223\204Z%"
f7dc1244 6736(@value{GDBP}) print ibm1047_hello[0]
a0eb71c5 6737$5 = 200 '\310'
f7dc1244 6738(@value{GDBP})
10998722 6739@end smallexample
a0eb71c5 6740
e33d66ec 6741If we invoke the @code{set target-charset} followed by @key{TAB}@key{TAB},
a0eb71c5
KB
6742@value{GDBN} tells us the character sets it supports:
6743
6744@smallexample
f7dc1244 6745(@value{GDBP}) set target-charset
b383017d 6746ASCII EBCDIC-US IBM1047 ISO-8859-1
f7dc1244 6747(@value{GDBP}) set target-charset
10998722 6748@end smallexample
a0eb71c5
KB
6749
6750We can select @sc{ibm1047} as our target character set, and examine the
6751program's strings again. Now the @sc{ascii} string is wrong, but
6752@value{GDBN} translates the contents of @code{ibm1047_hello} from the
6753target character set, @sc{ibm1047}, to the host character set,
6754@sc{ascii}, and they display correctly:
6755
6756@smallexample
f7dc1244
EZ
6757(@value{GDBP}) set target-charset IBM1047
6758(@value{GDBP}) show charset
e33d66ec
EZ
6759The current host character set is `ASCII'.
6760The current target character set is `IBM1047'.
f7dc1244 6761(@value{GDBP}) print ascii_hello
a0eb71c5 6762$6 = 0x401698 "\110\145%%?\054\040\167?\162%\144\041\012"
f7dc1244 6763(@value{GDBP}) print ascii_hello[0]
a0eb71c5 6764$7 = 72 '\110'
f7dc1244 6765(@value{GDBP}) print ibm1047_hello
a0eb71c5 6766$8 = 0x4016a8 "Hello, world!\n"
f7dc1244 6767(@value{GDBP}) print ibm1047_hello[0]
a0eb71c5 6768$9 = 200 'H'
f7dc1244 6769(@value{GDBP})
10998722 6770@end smallexample
a0eb71c5
KB
6771
6772As above, @value{GDBN} uses the target character set for character and
6773string literals you use in expressions:
6774
6775@smallexample
f7dc1244 6776(@value{GDBP}) print '+'
a0eb71c5 6777$10 = 78 '+'
f7dc1244 6778(@value{GDBP})
10998722 6779@end smallexample
a0eb71c5 6780
e33d66ec 6781The @sc{ibm1047} character set uses the number 78 to encode the @samp{+}
a0eb71c5
KB
6782character.
6783
09d4efe1
EZ
6784@node Caching Remote Data
6785@section Caching Data of Remote Targets
6786@cindex caching data of remote targets
6787
6788@value{GDBN} can cache data exchanged between the debugger and a
6789remote target (@pxref{Remote}). Such caching generally improves
6790performance, because it reduces the overhead of the remote protocol by
6791bundling memory reads and writes into large chunks. Unfortunately,
6792@value{GDBN} does not currently know anything about volatile
6793registers, and thus data caching will produce incorrect results when
6794volatile registers are in use.
6795
6796@table @code
6797@kindex set remotecache
6798@item set remotecache on
6799@itemx set remotecache off
6800Set caching state for remote targets. When @code{ON}, use data
6801caching. By default, this option is @code{OFF}.
6802
6803@kindex show remotecache
6804@item show remotecache
6805Show the current state of data caching for remote targets.
6806
6807@kindex info dcache
6808@item info dcache
6809Print the information about the data cache performance. The
6810information displayed includes: the dcache width and depth; and for
6811each cache line, how many times it was referenced, and its data and
6812state (dirty, bad, ok, etc.). This command is useful for debugging
6813the data cache operation.
6814@end table
6815
a0eb71c5 6816
e2e0bcd1
JB
6817@node Macros
6818@chapter C Preprocessor Macros
6819
49efadf5 6820Some languages, such as C and C@t{++}, provide a way to define and invoke
e2e0bcd1
JB
6821``preprocessor macros'' which expand into strings of tokens.
6822@value{GDBN} can evaluate expressions containing macro invocations, show
6823the result of macro expansion, and show a macro's definition, including
6824where it was defined.
6825
6826You may need to compile your program specially to provide @value{GDBN}
6827with information about preprocessor macros. Most compilers do not
6828include macros in their debugging information, even when you compile
6829with the @option{-g} flag. @xref{Compilation}.
6830
6831A program may define a macro at one point, remove that definition later,
6832and then provide a different definition after that. Thus, at different
6833points in the program, a macro may have different definitions, or have
6834no definition at all. If there is a current stack frame, @value{GDBN}
6835uses the macros in scope at that frame's source code line. Otherwise,
6836@value{GDBN} uses the macros in scope at the current listing location;
6837see @ref{List}.
6838
6839At the moment, @value{GDBN} does not support the @code{##}
6840token-splicing operator, the @code{#} stringification operator, or
6841variable-arity macros.
6842
6843Whenever @value{GDBN} evaluates an expression, it always expands any
6844macro invocations present in the expression. @value{GDBN} also provides
6845the following commands for working with macros explicitly.
6846
6847@table @code
6848
6849@kindex macro expand
6850@cindex macro expansion, showing the results of preprocessor
6851@cindex preprocessor macro expansion, showing the results of
6852@cindex expanding preprocessor macros
6853@item macro expand @var{expression}
6854@itemx macro exp @var{expression}
6855Show the results of expanding all preprocessor macro invocations in
6856@var{expression}. Since @value{GDBN} simply expands macros, but does
6857not parse the result, @var{expression} need not be a valid expression;
6858it can be any string of tokens.
6859
09d4efe1 6860@kindex macro exp1
e2e0bcd1
JB
6861@item macro expand-once @var{expression}
6862@itemx macro exp1 @var{expression}
4644b6e3 6863@cindex expand macro once
e2e0bcd1
JB
6864@i{(This command is not yet implemented.)} Show the results of
6865expanding those preprocessor macro invocations that appear explicitly in
6866@var{expression}. Macro invocations appearing in that expansion are
6867left unchanged. This command allows you to see the effect of a
6868particular macro more clearly, without being confused by further
6869expansions. Since @value{GDBN} simply expands macros, but does not
6870parse the result, @var{expression} need not be a valid expression; it
6871can be any string of tokens.
6872
475b0867 6873@kindex info macro
e2e0bcd1
JB
6874@cindex macro definition, showing
6875@cindex definition, showing a macro's
475b0867 6876@item info macro @var{macro}
e2e0bcd1
JB
6877Show the definition of the macro named @var{macro}, and describe the
6878source location where that definition was established.
6879
6880@kindex macro define
6881@cindex user-defined macros
6882@cindex defining macros interactively
6883@cindex macros, user-defined
6884@item macro define @var{macro} @var{replacement-list}
6885@itemx macro define @var{macro}(@var{arglist}) @var{replacement-list}
6886@i{(This command is not yet implemented.)} Introduce a definition for a
6887preprocessor macro named @var{macro}, invocations of which are replaced
6888by the tokens given in @var{replacement-list}. The first form of this
6889command defines an ``object-like'' macro, which takes no arguments; the
6890second form defines a ``function-like'' macro, which takes the arguments
6891given in @var{arglist}.
6892
6893A definition introduced by this command is in scope in every expression
6894evaluated in @value{GDBN}, until it is removed with the @command{macro
6895undef} command, described below. The definition overrides all
6896definitions for @var{macro} present in the program being debugged, as
6897well as any previous user-supplied definition.
6898
6899@kindex macro undef
6900@item macro undef @var{macro}
6901@i{(This command is not yet implemented.)} Remove any user-supplied
6902definition for the macro named @var{macro}. This command only affects
6903definitions provided with the @command{macro define} command, described
6904above; it cannot remove definitions present in the program being
6905debugged.
6906
09d4efe1
EZ
6907@kindex macro list
6908@item macro list
6909@i{(This command is not yet implemented.)} List all the macros
6910defined using the @code{macro define} command.
e2e0bcd1
JB
6911@end table
6912
6913@cindex macros, example of debugging with
6914Here is a transcript showing the above commands in action. First, we
6915show our source files:
6916
6917@smallexample
6918$ cat sample.c
6919#include <stdio.h>
6920#include "sample.h"
6921
6922#define M 42
6923#define ADD(x) (M + x)
6924
6925main ()
6926@{
6927#define N 28
6928 printf ("Hello, world!\n");
6929#undef N
6930 printf ("We're so creative.\n");
6931#define N 1729
6932 printf ("Goodbye, world!\n");
6933@}
6934$ cat sample.h
6935#define Q <
6936$
6937@end smallexample
6938
6939Now, we compile the program using the @sc{gnu} C compiler, @value{NGCC}.
6940We pass the @option{-gdwarf-2} and @option{-g3} flags to ensure the
6941compiler includes information about preprocessor macros in the debugging
6942information.
6943
6944@smallexample
6945$ gcc -gdwarf-2 -g3 sample.c -o sample
6946$
6947@end smallexample
6948
6949Now, we start @value{GDBN} on our sample program:
6950
6951@smallexample
6952$ gdb -nw sample
6953GNU gdb 2002-05-06-cvs
6954Copyright 2002 Free Software Foundation, Inc.
6955GDB is free software, @dots{}
f7dc1244 6956(@value{GDBP})
e2e0bcd1
JB
6957@end smallexample
6958
6959We can expand macros and examine their definitions, even when the
6960program is not running. @value{GDBN} uses the current listing position
6961to decide which macro definitions are in scope:
6962
6963@smallexample
f7dc1244 6964(@value{GDBP}) list main
e2e0bcd1
JB
69653
69664 #define M 42
69675 #define ADD(x) (M + x)
69686
69697 main ()
69708 @{
69719 #define N 28
697210 printf ("Hello, world!\n");
697311 #undef N
697412 printf ("We're so creative.\n");
f7dc1244 6975(@value{GDBP}) info macro ADD
e2e0bcd1
JB
6976Defined at /home/jimb/gdb/macros/play/sample.c:5
6977#define ADD(x) (M + x)
f7dc1244 6978(@value{GDBP}) info macro Q
e2e0bcd1
JB
6979Defined at /home/jimb/gdb/macros/play/sample.h:1
6980 included at /home/jimb/gdb/macros/play/sample.c:2
6981#define Q <
f7dc1244 6982(@value{GDBP}) macro expand ADD(1)
e2e0bcd1 6983expands to: (42 + 1)
f7dc1244 6984(@value{GDBP}) macro expand-once ADD(1)
e2e0bcd1 6985expands to: once (M + 1)
f7dc1244 6986(@value{GDBP})
e2e0bcd1
JB
6987@end smallexample
6988
6989In the example above, note that @command{macro expand-once} expands only
6990the macro invocation explicit in the original text --- the invocation of
6991@code{ADD} --- but does not expand the invocation of the macro @code{M},
6992which was introduced by @code{ADD}.
6993
6994Once the program is running, GDB uses the macro definitions in force at
6995the source line of the current stack frame:
6996
6997@smallexample
f7dc1244 6998(@value{GDBP}) break main
e2e0bcd1 6999Breakpoint 1 at 0x8048370: file sample.c, line 10.
f7dc1244 7000(@value{GDBP}) run
b383017d 7001Starting program: /home/jimb/gdb/macros/play/sample
e2e0bcd1
JB
7002
7003Breakpoint 1, main () at sample.c:10
700410 printf ("Hello, world!\n");
f7dc1244 7005(@value{GDBP})
e2e0bcd1
JB
7006@end smallexample
7007
7008At line 10, the definition of the macro @code{N} at line 9 is in force:
7009
7010@smallexample
f7dc1244 7011(@value{GDBP}) info macro N
e2e0bcd1
JB
7012Defined at /home/jimb/gdb/macros/play/sample.c:9
7013#define N 28
f7dc1244 7014(@value{GDBP}) macro expand N Q M
e2e0bcd1 7015expands to: 28 < 42
f7dc1244 7016(@value{GDBP}) print N Q M
e2e0bcd1 7017$1 = 1
f7dc1244 7018(@value{GDBP})
e2e0bcd1
JB
7019@end smallexample
7020
7021As we step over directives that remove @code{N}'s definition, and then
7022give it a new definition, @value{GDBN} finds the definition (or lack
7023thereof) in force at each point:
7024
7025@smallexample
f7dc1244 7026(@value{GDBP}) next
e2e0bcd1
JB
7027Hello, world!
702812 printf ("We're so creative.\n");
f7dc1244 7029(@value{GDBP}) info macro N
e2e0bcd1
JB
7030The symbol `N' has no definition as a C/C++ preprocessor macro
7031at /home/jimb/gdb/macros/play/sample.c:12
f7dc1244 7032(@value{GDBP}) next
e2e0bcd1
JB
7033We're so creative.
703414 printf ("Goodbye, world!\n");
f7dc1244 7035(@value{GDBP}) info macro N
e2e0bcd1
JB
7036Defined at /home/jimb/gdb/macros/play/sample.c:13
7037#define N 1729
f7dc1244 7038(@value{GDBP}) macro expand N Q M
e2e0bcd1 7039expands to: 1729 < 42
f7dc1244 7040(@value{GDBP}) print N Q M
e2e0bcd1 7041$2 = 0
f7dc1244 7042(@value{GDBP})
e2e0bcd1
JB
7043@end smallexample
7044
7045
b37052ae
EZ
7046@node Tracepoints
7047@chapter Tracepoints
7048@c This chapter is based on the documentation written by Michael
7049@c Snyder, David Taylor, Jim Blandy, and Elena Zannoni.
7050
7051@cindex tracepoints
7052In some applications, it is not feasible for the debugger to interrupt
7053the program's execution long enough for the developer to learn
7054anything helpful about its behavior. If the program's correctness
7055depends on its real-time behavior, delays introduced by a debugger
7056might cause the program to change its behavior drastically, or perhaps
7057fail, even when the code itself is correct. It is useful to be able
7058to observe the program's behavior without interrupting it.
7059
7060Using @value{GDBN}'s @code{trace} and @code{collect} commands, you can
7061specify locations in the program, called @dfn{tracepoints}, and
7062arbitrary expressions to evaluate when those tracepoints are reached.
7063Later, using the @code{tfind} command, you can examine the values
7064those expressions had when the program hit the tracepoints. The
7065expressions may also denote objects in memory---structures or arrays,
7066for example---whose values @value{GDBN} should record; while visiting
7067a particular tracepoint, you may inspect those objects as if they were
7068in memory at that moment. However, because @value{GDBN} records these
7069values without interacting with you, it can do so quickly and
7070unobtrusively, hopefully not disturbing the program's behavior.
7071
7072The tracepoint facility is currently available only for remote
2c0069bb
EZ
7073targets. @xref{Targets}. In addition, your remote target must know how
7074to collect trace data. This functionality is implemented in the remote
7075stub; however, none of the stubs distributed with @value{GDBN} support
7076tracepoints as of this writing.
b37052ae
EZ
7077
7078This chapter describes the tracepoint commands and features.
7079
7080@menu
b383017d
RM
7081* Set Tracepoints::
7082* Analyze Collected Data::
7083* Tracepoint Variables::
b37052ae
EZ
7084@end menu
7085
7086@node Set Tracepoints
7087@section Commands to Set Tracepoints
7088
7089Before running such a @dfn{trace experiment}, an arbitrary number of
7090tracepoints can be set. Like a breakpoint (@pxref{Set Breaks}), a
7091tracepoint has a number assigned to it by @value{GDBN}. Like with
7092breakpoints, tracepoint numbers are successive integers starting from
7093one. Many of the commands associated with tracepoints take the
7094tracepoint number as their argument, to identify which tracepoint to
7095work on.
7096
7097For each tracepoint, you can specify, in advance, some arbitrary set
7098of data that you want the target to collect in the trace buffer when
7099it hits that tracepoint. The collected data can include registers,
7100local variables, or global data. Later, you can use @value{GDBN}
7101commands to examine the values these data had at the time the
7102tracepoint was hit.
7103
7104This section describes commands to set tracepoints and associated
7105conditions and actions.
7106
7107@menu
b383017d
RM
7108* Create and Delete Tracepoints::
7109* Enable and Disable Tracepoints::
7110* Tracepoint Passcounts::
7111* Tracepoint Actions::
7112* Listing Tracepoints::
7113* Starting and Stopping Trace Experiment::
b37052ae
EZ
7114@end menu
7115
7116@node Create and Delete Tracepoints
7117@subsection Create and Delete Tracepoints
7118
7119@table @code
7120@cindex set tracepoint
7121@kindex trace
7122@item trace
7123The @code{trace} command is very similar to the @code{break} command.
7124Its argument can be a source line, a function name, or an address in
7125the target program. @xref{Set Breaks}. The @code{trace} command
7126defines a tracepoint, which is a point in the target program where the
7127debugger will briefly stop, collect some data, and then allow the
7128program to continue. Setting a tracepoint or changing its commands
7129doesn't take effect until the next @code{tstart} command; thus, you
7130cannot change the tracepoint attributes once a trace experiment is
7131running.
7132
7133Here are some examples of using the @code{trace} command:
7134
7135@smallexample
7136(@value{GDBP}) @b{trace foo.c:121} // a source file and line number
7137
7138(@value{GDBP}) @b{trace +2} // 2 lines forward
7139
7140(@value{GDBP}) @b{trace my_function} // first source line of function
7141
7142(@value{GDBP}) @b{trace *my_function} // EXACT start address of function
7143
7144(@value{GDBP}) @b{trace *0x2117c4} // an address
7145@end smallexample
7146
7147@noindent
7148You can abbreviate @code{trace} as @code{tr}.
7149
7150@vindex $tpnum
7151@cindex last tracepoint number
7152@cindex recent tracepoint number
7153@cindex tracepoint number
7154The convenience variable @code{$tpnum} records the tracepoint number
7155of the most recently set tracepoint.
7156
7157@kindex delete tracepoint
7158@cindex tracepoint deletion
7159@item delete tracepoint @r{[}@var{num}@r{]}
7160Permanently delete one or more tracepoints. With no argument, the
7161default is to delete all tracepoints.
7162
7163Examples:
7164
7165@smallexample
7166(@value{GDBP}) @b{delete trace 1 2 3} // remove three tracepoints
7167
7168(@value{GDBP}) @b{delete trace} // remove all tracepoints
7169@end smallexample
7170
7171@noindent
7172You can abbreviate this command as @code{del tr}.
7173@end table
7174
7175@node Enable and Disable Tracepoints
7176@subsection Enable and Disable Tracepoints
7177
7178@table @code
7179@kindex disable tracepoint
7180@item disable tracepoint @r{[}@var{num}@r{]}
7181Disable tracepoint @var{num}, or all tracepoints if no argument
7182@var{num} is given. A disabled tracepoint will have no effect during
7183the next trace experiment, but it is not forgotten. You can re-enable
7184a disabled tracepoint using the @code{enable tracepoint} command.
7185
7186@kindex enable tracepoint
7187@item enable tracepoint @r{[}@var{num}@r{]}
7188Enable tracepoint @var{num}, or all tracepoints. The enabled
7189tracepoints will become effective the next time a trace experiment is
7190run.
7191@end table
7192
7193@node Tracepoint Passcounts
7194@subsection Tracepoint Passcounts
7195
7196@table @code
7197@kindex passcount
7198@cindex tracepoint pass count
7199@item passcount @r{[}@var{n} @r{[}@var{num}@r{]]}
7200Set the @dfn{passcount} of a tracepoint. The passcount is a way to
7201automatically stop a trace experiment. If a tracepoint's passcount is
7202@var{n}, then the trace experiment will be automatically stopped on
7203the @var{n}'th time that tracepoint is hit. If the tracepoint number
7204@var{num} is not specified, the @code{passcount} command sets the
7205passcount of the most recently defined tracepoint. If no passcount is
7206given, the trace experiment will run until stopped explicitly by the
7207user.
7208
7209Examples:
7210
7211@smallexample
b383017d 7212(@value{GDBP}) @b{passcount 5 2} // Stop on the 5th execution of
6826cf00 7213@exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// tracepoint 2}
b37052ae
EZ
7214
7215(@value{GDBP}) @b{passcount 12} // Stop on the 12th execution of the
6826cf00 7216@exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// most recently defined tracepoint.}
b37052ae
EZ
7217(@value{GDBP}) @b{trace foo}
7218(@value{GDBP}) @b{pass 3}
7219(@value{GDBP}) @b{trace bar}
7220(@value{GDBP}) @b{pass 2}
7221(@value{GDBP}) @b{trace baz}
7222(@value{GDBP}) @b{pass 1} // Stop tracing when foo has been
6826cf00
EZ
7223@exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// executed 3 times OR when bar has}
7224@exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// been executed 2 times}
7225@exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// OR when baz has been executed 1 time.}
b37052ae
EZ
7226@end smallexample
7227@end table
7228
7229@node Tracepoint Actions
7230@subsection Tracepoint Action Lists
7231
7232@table @code
7233@kindex actions
7234@cindex tracepoint actions
7235@item actions @r{[}@var{num}@r{]}
7236This command will prompt for a list of actions to be taken when the
7237tracepoint is hit. If the tracepoint number @var{num} is not
7238specified, this command sets the actions for the one that was most
7239recently defined (so that you can define a tracepoint and then say
7240@code{actions} without bothering about its number). You specify the
7241actions themselves on the following lines, one action at a time, and
7242terminate the actions list with a line containing just @code{end}. So
7243far, the only defined actions are @code{collect} and
7244@code{while-stepping}.
7245
7246@cindex remove actions from a tracepoint
7247To remove all actions from a tracepoint, type @samp{actions @var{num}}
7248and follow it immediately with @samp{end}.
7249
7250@smallexample
7251(@value{GDBP}) @b{collect @var{data}} // collect some data
7252
6826cf00 7253(@value{GDBP}) @b{while-stepping 5} // single-step 5 times, collect data
b37052ae 7254
6826cf00 7255(@value{GDBP}) @b{end} // signals the end of actions.
b37052ae
EZ
7256@end smallexample
7257
7258In the following example, the action list begins with @code{collect}
7259commands indicating the things to be collected when the tracepoint is
7260hit. Then, in order to single-step and collect additional data
7261following the tracepoint, a @code{while-stepping} command is used,
7262followed by the list of things to be collected while stepping. The
7263@code{while-stepping} command is terminated by its own separate
7264@code{end} command. Lastly, the action list is terminated by an
7265@code{end} command.
7266
7267@smallexample
7268(@value{GDBP}) @b{trace foo}
7269(@value{GDBP}) @b{actions}
7270Enter actions for tracepoint 1, one per line:
7271> collect bar,baz
7272> collect $regs
7273> while-stepping 12
7274 > collect $fp, $sp
7275 > end
7276end
7277@end smallexample
7278
7279@kindex collect @r{(tracepoints)}
7280@item collect @var{expr1}, @var{expr2}, @dots{}
7281Collect values of the given expressions when the tracepoint is hit.
7282This command accepts a comma-separated list of any valid expressions.
7283In addition to global, static, or local variables, the following
7284special arguments are supported:
7285
7286@table @code
7287@item $regs
7288collect all registers
7289
7290@item $args
7291collect all function arguments
7292
7293@item $locals
7294collect all local variables.
7295@end table
7296
7297You can give several consecutive @code{collect} commands, each one
7298with a single argument, or one @code{collect} command with several
7299arguments separated by commas: the effect is the same.
7300
f5c37c66
EZ
7301The command @code{info scope} (@pxref{Symbols, info scope}) is
7302particularly useful for figuring out what data to collect.
7303
b37052ae
EZ
7304@kindex while-stepping @r{(tracepoints)}
7305@item while-stepping @var{n}
7306Perform @var{n} single-step traces after the tracepoint, collecting
7307new data at each step. The @code{while-stepping} command is
7308followed by the list of what to collect while stepping (followed by
7309its own @code{end} command):
7310
7311@smallexample
7312> while-stepping 12
7313 > collect $regs, myglobal
7314 > end
7315>
7316@end smallexample
7317
7318@noindent
7319You may abbreviate @code{while-stepping} as @code{ws} or
7320@code{stepping}.
7321@end table
7322
7323@node Listing Tracepoints
7324@subsection Listing Tracepoints
7325
7326@table @code
7327@kindex info tracepoints
09d4efe1 7328@kindex info tp
b37052ae
EZ
7329@cindex information about tracepoints
7330@item info tracepoints @r{[}@var{num}@r{]}
8a037dd7 7331Display information about the tracepoint @var{num}. If you don't specify
798c8bc6 7332a tracepoint number, displays information about all the tracepoints
b37052ae
EZ
7333defined so far. For each tracepoint, the following information is
7334shown:
7335
7336@itemize @bullet
7337@item
7338its number
7339@item
7340whether it is enabled or disabled
7341@item
7342its address
7343@item
7344its passcount as given by the @code{passcount @var{n}} command
7345@item
7346its step count as given by the @code{while-stepping @var{n}} command
7347@item
7348where in the source files is the tracepoint set
7349@item
7350its action list as given by the @code{actions} command
7351@end itemize
7352
7353@smallexample
7354(@value{GDBP}) @b{info trace}
7355Num Enb Address PassC StepC What
73561 y 0x002117c4 0 0 <gdb_asm>
6826cf00
EZ
73572 y 0x0020dc64 0 0 in g_test at g_test.c:1375
73583 y 0x0020b1f4 0 0 in get_data at ../foo.c:41
b37052ae
EZ
7359(@value{GDBP})
7360@end smallexample
7361
7362@noindent
7363This command can be abbreviated @code{info tp}.
7364@end table
7365
7366@node Starting and Stopping Trace Experiment
7367@subsection Starting and Stopping Trace Experiment
7368
7369@table @code
7370@kindex tstart
7371@cindex start a new trace experiment
7372@cindex collected data discarded
7373@item tstart
7374This command takes no arguments. It starts the trace experiment, and
7375begins collecting data. This has the side effect of discarding all
7376the data collected in the trace buffer during the previous trace
7377experiment.
7378
7379@kindex tstop
7380@cindex stop a running trace experiment
7381@item tstop
7382This command takes no arguments. It ends the trace experiment, and
7383stops collecting data.
7384
68c71a2e 7385@strong{Note}: a trace experiment and data collection may stop
b37052ae
EZ
7386automatically if any tracepoint's passcount is reached
7387(@pxref{Tracepoint Passcounts}), or if the trace buffer becomes full.
7388
7389@kindex tstatus
7390@cindex status of trace data collection
7391@cindex trace experiment, status of
7392@item tstatus
7393This command displays the status of the current trace data
7394collection.
7395@end table
7396
7397Here is an example of the commands we described so far:
7398
7399@smallexample
7400(@value{GDBP}) @b{trace gdb_c_test}
7401(@value{GDBP}) @b{actions}
7402Enter actions for tracepoint #1, one per line.
7403> collect $regs,$locals,$args
7404> while-stepping 11
7405 > collect $regs
7406 > end
7407> end
7408(@value{GDBP}) @b{tstart}
7409 [time passes @dots{}]
7410(@value{GDBP}) @b{tstop}
7411@end smallexample
7412
7413
7414@node Analyze Collected Data
7415@section Using the collected data
7416
7417After the tracepoint experiment ends, you use @value{GDBN} commands
7418for examining the trace data. The basic idea is that each tracepoint
7419collects a trace @dfn{snapshot} every time it is hit and another
7420snapshot every time it single-steps. All these snapshots are
7421consecutively numbered from zero and go into a buffer, and you can
7422examine them later. The way you examine them is to @dfn{focus} on a
7423specific trace snapshot. When the remote stub is focused on a trace
7424snapshot, it will respond to all @value{GDBN} requests for memory and
7425registers by reading from the buffer which belongs to that snapshot,
7426rather than from @emph{real} memory or registers of the program being
7427debugged. This means that @strong{all} @value{GDBN} commands
7428(@code{print}, @code{info registers}, @code{backtrace}, etc.) will
7429behave as if we were currently debugging the program state as it was
7430when the tracepoint occurred. Any requests for data that are not in
7431the buffer will fail.
7432
7433@menu
7434* tfind:: How to select a trace snapshot
7435* tdump:: How to display all data for a snapshot
7436* save-tracepoints:: How to save tracepoints for a future run
7437@end menu
7438
7439@node tfind
7440@subsection @code{tfind @var{n}}
7441
7442@kindex tfind
7443@cindex select trace snapshot
7444@cindex find trace snapshot
7445The basic command for selecting a trace snapshot from the buffer is
7446@code{tfind @var{n}}, which finds trace snapshot number @var{n},
7447counting from zero. If no argument @var{n} is given, the next
7448snapshot is selected.
7449
7450Here are the various forms of using the @code{tfind} command.
7451
7452@table @code
7453@item tfind start
7454Find the first snapshot in the buffer. This is a synonym for
7455@code{tfind 0} (since 0 is the number of the first snapshot).
7456
7457@item tfind none
7458Stop debugging trace snapshots, resume @emph{live} debugging.
7459
7460@item tfind end
7461Same as @samp{tfind none}.
7462
7463@item tfind
7464No argument means find the next trace snapshot.
7465
7466@item tfind -
7467Find the previous trace snapshot before the current one. This permits
7468retracing earlier steps.
7469
7470@item tfind tracepoint @var{num}
7471Find the next snapshot associated with tracepoint @var{num}. Search
7472proceeds forward from the last examined trace snapshot. If no
7473argument @var{num} is given, it means find the next snapshot collected
7474for the same tracepoint as the current snapshot.
7475
7476@item tfind pc @var{addr}
7477Find the next snapshot associated with the value @var{addr} of the
7478program counter. Search proceeds forward from the last examined trace
7479snapshot. If no argument @var{addr} is given, it means find the next
7480snapshot with the same value of PC as the current snapshot.
7481
7482@item tfind outside @var{addr1}, @var{addr2}
7483Find the next snapshot whose PC is outside the given range of
7484addresses.
7485
7486@item tfind range @var{addr1}, @var{addr2}
7487Find the next snapshot whose PC is between @var{addr1} and
7488@var{addr2}. @c FIXME: Is the range inclusive or exclusive?
7489
7490@item tfind line @r{[}@var{file}:@r{]}@var{n}
7491Find the next snapshot associated with the source line @var{n}. If
7492the optional argument @var{file} is given, refer to line @var{n} in
7493that source file. Search proceeds forward from the last examined
7494trace snapshot. If no argument @var{n} is given, it means find the
7495next line other than the one currently being examined; thus saying
7496@code{tfind line} repeatedly can appear to have the same effect as
7497stepping from line to line in a @emph{live} debugging session.
7498@end table
7499
7500The default arguments for the @code{tfind} commands are specifically
7501designed to make it easy to scan through the trace buffer. For
7502instance, @code{tfind} with no argument selects the next trace
7503snapshot, and @code{tfind -} with no argument selects the previous
7504trace snapshot. So, by giving one @code{tfind} command, and then
7505simply hitting @key{RET} repeatedly you can examine all the trace
7506snapshots in order. Or, by saying @code{tfind -} and then hitting
7507@key{RET} repeatedly you can examine the snapshots in reverse order.
7508The @code{tfind line} command with no argument selects the snapshot
7509for the next source line executed. The @code{tfind pc} command with
7510no argument selects the next snapshot with the same program counter
7511(PC) as the current frame. The @code{tfind tracepoint} command with
7512no argument selects the next trace snapshot collected by the same
7513tracepoint as the current one.
7514
7515In addition to letting you scan through the trace buffer manually,
7516these commands make it easy to construct @value{GDBN} scripts that
7517scan through the trace buffer and print out whatever collected data
7518you are interested in. Thus, if we want to examine the PC, FP, and SP
7519registers from each trace frame in the buffer, we can say this:
7520
7521@smallexample
7522(@value{GDBP}) @b{tfind start}
7523(@value{GDBP}) @b{while ($trace_frame != -1)}
7524> printf "Frame %d, PC = %08X, SP = %08X, FP = %08X\n", \
7525 $trace_frame, $pc, $sp, $fp
7526> tfind
7527> end
7528
7529Frame 0, PC = 0020DC64, SP = 0030BF3C, FP = 0030BF44
7530Frame 1, PC = 0020DC6C, SP = 0030BF38, FP = 0030BF44
7531Frame 2, PC = 0020DC70, SP = 0030BF34, FP = 0030BF44
7532Frame 3, PC = 0020DC74, SP = 0030BF30, FP = 0030BF44
7533Frame 4, PC = 0020DC78, SP = 0030BF2C, FP = 0030BF44
7534Frame 5, PC = 0020DC7C, SP = 0030BF28, FP = 0030BF44
7535Frame 6, PC = 0020DC80, SP = 0030BF24, FP = 0030BF44
7536Frame 7, PC = 0020DC84, SP = 0030BF20, FP = 0030BF44
7537Frame 8, PC = 0020DC88, SP = 0030BF1C, FP = 0030BF44
7538Frame 9, PC = 0020DC8E, SP = 0030BF18, FP = 0030BF44
7539Frame 10, PC = 00203F6C, SP = 0030BE3C, FP = 0030BF14
7540@end smallexample
7541
7542Or, if we want to examine the variable @code{X} at each source line in
7543the buffer:
7544
7545@smallexample
7546(@value{GDBP}) @b{tfind start}
7547(@value{GDBP}) @b{while ($trace_frame != -1)}
7548> printf "Frame %d, X == %d\n", $trace_frame, X
7549> tfind line
7550> end
7551
7552Frame 0, X = 1
7553Frame 7, X = 2
7554Frame 13, X = 255
7555@end smallexample
7556
7557@node tdump
7558@subsection @code{tdump}
7559@kindex tdump
7560@cindex dump all data collected at tracepoint
7561@cindex tracepoint data, display
7562
7563This command takes no arguments. It prints all the data collected at
7564the current trace snapshot.
7565
7566@smallexample
7567(@value{GDBP}) @b{trace 444}
7568(@value{GDBP}) @b{actions}
7569Enter actions for tracepoint #2, one per line:
7570> collect $regs, $locals, $args, gdb_long_test
7571> end
7572
7573(@value{GDBP}) @b{tstart}
7574
7575(@value{GDBP}) @b{tfind line 444}
7576#0 gdb_test (p1=0x11, p2=0x22, p3=0x33, p4=0x44, p5=0x55, p6=0x66)
7577at gdb_test.c:444
7578444 printp( "%s: arguments = 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X\n", )
7579
7580(@value{GDBP}) @b{tdump}
7581Data collected at tracepoint 2, trace frame 1:
7582d0 0xc4aa0085 -995491707
7583d1 0x18 24
7584d2 0x80 128
7585d3 0x33 51
7586d4 0x71aea3d 119204413
7587d5 0x22 34
7588d6 0xe0 224
7589d7 0x380035 3670069
7590a0 0x19e24a 1696330
7591a1 0x3000668 50333288
7592a2 0x100 256
7593a3 0x322000 3284992
7594a4 0x3000698 50333336
7595a5 0x1ad3cc 1758156
7596fp 0x30bf3c 0x30bf3c
7597sp 0x30bf34 0x30bf34
7598ps 0x0 0
7599pc 0x20b2c8 0x20b2c8
7600fpcontrol 0x0 0
7601fpstatus 0x0 0
7602fpiaddr 0x0 0
7603p = 0x20e5b4 "gdb-test"
7604p1 = (void *) 0x11
7605p2 = (void *) 0x22
7606p3 = (void *) 0x33
7607p4 = (void *) 0x44
7608p5 = (void *) 0x55
7609p6 = (void *) 0x66
7610gdb_long_test = 17 '\021'
7611
7612(@value{GDBP})
7613@end smallexample
7614
7615@node save-tracepoints
7616@subsection @code{save-tracepoints @var{filename}}
7617@kindex save-tracepoints
7618@cindex save tracepoints for future sessions
7619
7620This command saves all current tracepoint definitions together with
7621their actions and passcounts, into a file @file{@var{filename}}
7622suitable for use in a later debugging session. To read the saved
7623tracepoint definitions, use the @code{source} command (@pxref{Command
7624Files}).
7625
7626@node Tracepoint Variables
7627@section Convenience Variables for Tracepoints
7628@cindex tracepoint variables
7629@cindex convenience variables for tracepoints
7630
7631@table @code
7632@vindex $trace_frame
7633@item (int) $trace_frame
7634The current trace snapshot (a.k.a.@: @dfn{frame}) number, or -1 if no
7635snapshot is selected.
7636
7637@vindex $tracepoint
7638@item (int) $tracepoint
7639The tracepoint for the current trace snapshot.
7640
7641@vindex $trace_line
7642@item (int) $trace_line
7643The line number for the current trace snapshot.
7644
7645@vindex $trace_file
7646@item (char []) $trace_file
7647The source file for the current trace snapshot.
7648
7649@vindex $trace_func
7650@item (char []) $trace_func
7651The name of the function containing @code{$tracepoint}.
7652@end table
7653
7654Note: @code{$trace_file} is not suitable for use in @code{printf},
7655use @code{output} instead.
7656
7657Here's a simple example of using these convenience variables for
7658stepping through all the trace snapshots and printing some of their
7659data.
7660
7661@smallexample
7662(@value{GDBP}) @b{tfind start}
7663
7664(@value{GDBP}) @b{while $trace_frame != -1}
7665> output $trace_file
7666> printf ", line %d (tracepoint #%d)\n", $trace_line, $tracepoint
7667> tfind
7668> end
7669@end smallexample
7670
df0cd8c5
JB
7671@node Overlays
7672@chapter Debugging Programs That Use Overlays
7673@cindex overlays
7674
7675If your program is too large to fit completely in your target system's
7676memory, you can sometimes use @dfn{overlays} to work around this
7677problem. @value{GDBN} provides some support for debugging programs that
7678use overlays.
7679
7680@menu
7681* How Overlays Work:: A general explanation of overlays.
7682* Overlay Commands:: Managing overlays in @value{GDBN}.
7683* Automatic Overlay Debugging:: @value{GDBN} can find out which overlays are
7684 mapped by asking the inferior.
7685* Overlay Sample Program:: A sample program using overlays.
7686@end menu
7687
7688@node How Overlays Work
7689@section How Overlays Work
7690@cindex mapped overlays
7691@cindex unmapped overlays
7692@cindex load address, overlay's
7693@cindex mapped address
7694@cindex overlay area
7695
7696Suppose you have a computer whose instruction address space is only 64
7697kilobytes long, but which has much more memory which can be accessed by
7698other means: special instructions, segment registers, or memory
7699management hardware, for example. Suppose further that you want to
7700adapt a program which is larger than 64 kilobytes to run on this system.
7701
7702One solution is to identify modules of your program which are relatively
7703independent, and need not call each other directly; call these modules
7704@dfn{overlays}. Separate the overlays from the main program, and place
7705their machine code in the larger memory. Place your main program in
7706instruction memory, but leave at least enough space there to hold the
7707largest overlay as well.
7708
7709Now, to call a function located in an overlay, you must first copy that
7710overlay's machine code from the large memory into the space set aside
7711for it in the instruction memory, and then jump to its entry point
7712there.
7713
c928edc0
AC
7714@c NB: In the below the mapped area's size is greater or equal to the
7715@c size of all overlays. This is intentional to remind the developer
7716@c that overlays don't necessarily need to be the same size.
7717
474c8240 7718@smallexample
df0cd8c5 7719@group
c928edc0
AC
7720 Data Instruction Larger
7721Address Space Address Space Address Space
7722+-----------+ +-----------+ +-----------+
7723| | | | | |
7724+-----------+ +-----------+ +-----------+<-- overlay 1
7725| program | | main | .----| overlay 1 | load address
7726| variables | | program | | +-----------+
7727| and heap | | | | | |
7728+-----------+ | | | +-----------+<-- overlay 2
7729| | +-----------+ | | | load address
7730+-----------+ | | | .-| overlay 2 |
7731 | | | | | |
7732 mapped --->+-----------+ | | +-----------+
7733 address | | | | | |
7734 | overlay | <-' | | |
7735 | area | <---' +-----------+<-- overlay 3
7736 | | <---. | | load address
7737 +-----------+ `--| overlay 3 |
7738 | | | |
7739 +-----------+ | |
7740 +-----------+
7741 | |
7742 +-----------+
7743
7744 @anchor{A code overlay}A code overlay
df0cd8c5 7745@end group
474c8240 7746@end smallexample
df0cd8c5 7747
c928edc0
AC
7748The diagram (@pxref{A code overlay}) shows a system with separate data
7749and instruction address spaces. To map an overlay, the program copies
7750its code from the larger address space to the instruction address space.
7751Since the overlays shown here all use the same mapped address, only one
7752may be mapped at a time. For a system with a single address space for
7753data and instructions, the diagram would be similar, except that the
7754program variables and heap would share an address space with the main
7755program and the overlay area.
df0cd8c5
JB
7756
7757An overlay loaded into instruction memory and ready for use is called a
7758@dfn{mapped} overlay; its @dfn{mapped address} is its address in the
7759instruction memory. An overlay not present (or only partially present)
7760in instruction memory is called @dfn{unmapped}; its @dfn{load address}
7761is its address in the larger memory. The mapped address is also called
7762the @dfn{virtual memory address}, or @dfn{VMA}; the load address is also
7763called the @dfn{load memory address}, or @dfn{LMA}.
7764
7765Unfortunately, overlays are not a completely transparent way to adapt a
7766program to limited instruction memory. They introduce a new set of
7767global constraints you must keep in mind as you design your program:
7768
7769@itemize @bullet
7770
7771@item
7772Before calling or returning to a function in an overlay, your program
7773must make sure that overlay is actually mapped. Otherwise, the call or
7774return will transfer control to the right address, but in the wrong
7775overlay, and your program will probably crash.
7776
7777@item
7778If the process of mapping an overlay is expensive on your system, you
7779will need to choose your overlays carefully to minimize their effect on
7780your program's performance.
7781
7782@item
7783The executable file you load onto your system must contain each
7784overlay's instructions, appearing at the overlay's load address, not its
7785mapped address. However, each overlay's instructions must be relocated
7786and its symbols defined as if the overlay were at its mapped address.
7787You can use GNU linker scripts to specify different load and relocation
7788addresses for pieces of your program; see @ref{Overlay Description,,,
7789ld.info, Using ld: the GNU linker}.
7790
7791@item
7792The procedure for loading executable files onto your system must be able
7793to load their contents into the larger address space as well as the
7794instruction and data spaces.
7795
7796@end itemize
7797
7798The overlay system described above is rather simple, and could be
7799improved in many ways:
7800
7801@itemize @bullet
7802
7803@item
7804If your system has suitable bank switch registers or memory management
7805hardware, you could use those facilities to make an overlay's load area
7806contents simply appear at their mapped address in instruction space.
7807This would probably be faster than copying the overlay to its mapped
7808area in the usual way.
7809
7810@item
7811If your overlays are small enough, you could set aside more than one
7812overlay area, and have more than one overlay mapped at a time.
7813
7814@item
7815You can use overlays to manage data, as well as instructions. In
7816general, data overlays are even less transparent to your design than
7817code overlays: whereas code overlays only require care when you call or
7818return to functions, data overlays require care every time you access
7819the data. Also, if you change the contents of a data overlay, you
7820must copy its contents back out to its load address before you can copy a
7821different data overlay into the same mapped area.
7822
7823@end itemize
7824
7825
7826@node Overlay Commands
7827@section Overlay Commands
7828
7829To use @value{GDBN}'s overlay support, each overlay in your program must
7830correspond to a separate section of the executable file. The section's
7831virtual memory address and load memory address must be the overlay's
7832mapped and load addresses. Identifying overlays with sections allows
7833@value{GDBN} to determine the appropriate address of a function or
7834variable, depending on whether the overlay is mapped or not.
7835
7836@value{GDBN}'s overlay commands all start with the word @code{overlay};
7837you can abbreviate this as @code{ov} or @code{ovly}. The commands are:
7838
7839@table @code
7840@item overlay off
4644b6e3 7841@kindex overlay
df0cd8c5
JB
7842Disable @value{GDBN}'s overlay support. When overlay support is
7843disabled, @value{GDBN} assumes that all functions and variables are
7844always present at their mapped addresses. By default, @value{GDBN}'s
7845overlay support is disabled.
7846
7847@item overlay manual
df0cd8c5
JB
7848@cindex manual overlay debugging
7849Enable @dfn{manual} overlay debugging. In this mode, @value{GDBN}
7850relies on you to tell it which overlays are mapped, and which are not,
7851using the @code{overlay map-overlay} and @code{overlay unmap-overlay}
7852commands described below.
7853
7854@item overlay map-overlay @var{overlay}
7855@itemx overlay map @var{overlay}
df0cd8c5
JB
7856@cindex map an overlay
7857Tell @value{GDBN} that @var{overlay} is now mapped; @var{overlay} must
7858be the name of the object file section containing the overlay. When an
7859overlay is mapped, @value{GDBN} assumes it can find the overlay's
7860functions and variables at their mapped addresses. @value{GDBN} assumes
7861that any other overlays whose mapped ranges overlap that of
7862@var{overlay} are now unmapped.
7863
7864@item overlay unmap-overlay @var{overlay}
7865@itemx overlay unmap @var{overlay}
df0cd8c5
JB
7866@cindex unmap an overlay
7867Tell @value{GDBN} that @var{overlay} is no longer mapped; @var{overlay}
7868must be the name of the object file section containing the overlay.
7869When an overlay is unmapped, @value{GDBN} assumes it can find the
7870overlay's functions and variables at their load addresses.
7871
7872@item overlay auto
df0cd8c5
JB
7873Enable @dfn{automatic} overlay debugging. In this mode, @value{GDBN}
7874consults a data structure the overlay manager maintains in the inferior
7875to see which overlays are mapped. For details, see @ref{Automatic
7876Overlay Debugging}.
7877
7878@item overlay load-target
7879@itemx overlay load
df0cd8c5
JB
7880@cindex reloading the overlay table
7881Re-read the overlay table from the inferior. Normally, @value{GDBN}
7882re-reads the table @value{GDBN} automatically each time the inferior
7883stops, so this command should only be necessary if you have changed the
7884overlay mapping yourself using @value{GDBN}. This command is only
7885useful when using automatic overlay debugging.
7886
7887@item overlay list-overlays
7888@itemx overlay list
7889@cindex listing mapped overlays
7890Display a list of the overlays currently mapped, along with their mapped
7891addresses, load addresses, and sizes.
7892
7893@end table
7894
7895Normally, when @value{GDBN} prints a code address, it includes the name
7896of the function the address falls in:
7897
474c8240 7898@smallexample
f7dc1244 7899(@value{GDBP}) print main
df0cd8c5 7900$3 = @{int ()@} 0x11a0 <main>
474c8240 7901@end smallexample
df0cd8c5
JB
7902@noindent
7903When overlay debugging is enabled, @value{GDBN} recognizes code in
7904unmapped overlays, and prints the names of unmapped functions with
7905asterisks around them. For example, if @code{foo} is a function in an
7906unmapped overlay, @value{GDBN} prints it this way:
7907
474c8240 7908@smallexample
f7dc1244 7909(@value{GDBP}) overlay list
df0cd8c5 7910No sections are mapped.
f7dc1244 7911(@value{GDBP}) print foo
df0cd8c5 7912$5 = @{int (int)@} 0x100000 <*foo*>
474c8240 7913@end smallexample
df0cd8c5
JB
7914@noindent
7915When @code{foo}'s overlay is mapped, @value{GDBN} prints the function's
7916name normally:
7917
474c8240 7918@smallexample
f7dc1244 7919(@value{GDBP}) overlay list
b383017d 7920Section .ov.foo.text, loaded at 0x100000 - 0x100034,
df0cd8c5 7921 mapped at 0x1016 - 0x104a
f7dc1244 7922(@value{GDBP}) print foo
df0cd8c5 7923$6 = @{int (int)@} 0x1016 <foo>
474c8240 7924@end smallexample
df0cd8c5
JB
7925
7926When overlay debugging is enabled, @value{GDBN} can find the correct
7927address for functions and variables in an overlay, whether or not the
7928overlay is mapped. This allows most @value{GDBN} commands, like
7929@code{break} and @code{disassemble}, to work normally, even on unmapped
7930code. However, @value{GDBN}'s breakpoint support has some limitations:
7931
7932@itemize @bullet
7933@item
7934@cindex breakpoints in overlays
7935@cindex overlays, setting breakpoints in
7936You can set breakpoints in functions in unmapped overlays, as long as
7937@value{GDBN} can write to the overlay at its load address.
7938@item
7939@value{GDBN} can not set hardware or simulator-based breakpoints in
7940unmapped overlays. However, if you set a breakpoint at the end of your
7941overlay manager (and tell @value{GDBN} which overlays are now mapped, if
7942you are using manual overlay management), @value{GDBN} will re-set its
7943breakpoints properly.
7944@end itemize
7945
7946
7947@node Automatic Overlay Debugging
7948@section Automatic Overlay Debugging
7949@cindex automatic overlay debugging
7950
7951@value{GDBN} can automatically track which overlays are mapped and which
7952are not, given some simple co-operation from the overlay manager in the
7953inferior. If you enable automatic overlay debugging with the
7954@code{overlay auto} command (@pxref{Overlay Commands}), @value{GDBN}
7955looks in the inferior's memory for certain variables describing the
7956current state of the overlays.
7957
7958Here are the variables your overlay manager must define to support
7959@value{GDBN}'s automatic overlay debugging:
7960
7961@table @asis
7962
7963@item @code{_ovly_table}:
7964This variable must be an array of the following structures:
7965
474c8240 7966@smallexample
df0cd8c5
JB
7967struct
7968@{
7969 /* The overlay's mapped address. */
7970 unsigned long vma;
7971
7972 /* The size of the overlay, in bytes. */
7973 unsigned long size;
7974
7975 /* The overlay's load address. */
7976 unsigned long lma;
7977
7978 /* Non-zero if the overlay is currently mapped;
7979 zero otherwise. */
7980 unsigned long mapped;
7981@}
474c8240 7982@end smallexample
df0cd8c5
JB
7983
7984@item @code{_novlys}:
7985This variable must be a four-byte signed integer, holding the total
7986number of elements in @code{_ovly_table}.
7987
7988@end table
7989
7990To decide whether a particular overlay is mapped or not, @value{GDBN}
7991looks for an entry in @w{@code{_ovly_table}} whose @code{vma} and
7992@code{lma} members equal the VMA and LMA of the overlay's section in the
7993executable file. When @value{GDBN} finds a matching entry, it consults
7994the entry's @code{mapped} member to determine whether the overlay is
7995currently mapped.
7996
81d46470 7997In addition, your overlay manager may define a function called
def71bfa 7998@code{_ovly_debug_event}. If this function is defined, @value{GDBN}
81d46470
MS
7999will silently set a breakpoint there. If the overlay manager then
8000calls this function whenever it has changed the overlay table, this
8001will enable @value{GDBN} to accurately keep track of which overlays
8002are in program memory, and update any breakpoints that may be set
b383017d 8003in overlays. This will allow breakpoints to work even if the
81d46470
MS
8004overlays are kept in ROM or other non-writable memory while they
8005are not being executed.
df0cd8c5
JB
8006
8007@node Overlay Sample Program
8008@section Overlay Sample Program
8009@cindex overlay example program
8010
8011When linking a program which uses overlays, you must place the overlays
8012at their load addresses, while relocating them to run at their mapped
8013addresses. To do this, you must write a linker script (@pxref{Overlay
8014Description,,, ld.info, Using ld: the GNU linker}). Unfortunately,
8015since linker scripts are specific to a particular host system, target
8016architecture, and target memory layout, this manual cannot provide
8017portable sample code demonstrating @value{GDBN}'s overlay support.
8018
8019However, the @value{GDBN} source distribution does contain an overlaid
8020program, with linker scripts for a few systems, as part of its test
8021suite. The program consists of the following files from
8022@file{gdb/testsuite/gdb.base}:
8023
8024@table @file
8025@item overlays.c
8026The main program file.
8027@item ovlymgr.c
8028A simple overlay manager, used by @file{overlays.c}.
8029@item foo.c
8030@itemx bar.c
8031@itemx baz.c
8032@itemx grbx.c
8033Overlay modules, loaded and used by @file{overlays.c}.
8034@item d10v.ld
8035@itemx m32r.ld
8036Linker scripts for linking the test program on the @code{d10v-elf}
8037and @code{m32r-elf} targets.
8038@end table
8039
8040You can build the test program using the @code{d10v-elf} GCC
8041cross-compiler like this:
8042
474c8240 8043@smallexample
df0cd8c5
JB
8044$ d10v-elf-gcc -g -c overlays.c
8045$ d10v-elf-gcc -g -c ovlymgr.c
8046$ d10v-elf-gcc -g -c foo.c
8047$ d10v-elf-gcc -g -c bar.c
8048$ d10v-elf-gcc -g -c baz.c
8049$ d10v-elf-gcc -g -c grbx.c
8050$ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \
8051 baz.o grbx.o -Wl,-Td10v.ld -o overlays
474c8240 8052@end smallexample
df0cd8c5
JB
8053
8054The build process is identical for any other architecture, except that
8055you must substitute the appropriate compiler and linker script for the
8056target system for @code{d10v-elf-gcc} and @code{d10v.ld}.
8057
8058
6d2ebf8b 8059@node Languages
c906108c
SS
8060@chapter Using @value{GDBN} with Different Languages
8061@cindex languages
8062
c906108c
SS
8063Although programming languages generally have common aspects, they are
8064rarely expressed in the same manner. For instance, in ANSI C,
8065dereferencing a pointer @code{p} is accomplished by @code{*p}, but in
8066Modula-2, it is accomplished by @code{p^}. Values can also be
5d161b24 8067represented (and displayed) differently. Hex numbers in C appear as
c906108c 8068@samp{0x1ae}, while in Modula-2 they appear as @samp{1AEH}.
c906108c
SS
8069
8070@cindex working language
8071Language-specific information is built into @value{GDBN} for some languages,
8072allowing you to express operations like the above in your program's
8073native language, and allowing @value{GDBN} to output values in a manner
8074consistent with the syntax of your program's native language. The
8075language you use to build expressions is called the @dfn{working
8076language}.
8077
8078@menu
8079* Setting:: Switching between source languages
8080* Show:: Displaying the language
c906108c 8081* Checks:: Type and range checks
9c16f35a 8082* Supported languages:: Supported languages
4e562065 8083* Unsupported languages:: Unsupported languages
c906108c
SS
8084@end menu
8085
6d2ebf8b 8086@node Setting
c906108c
SS
8087@section Switching between source languages
8088
8089There are two ways to control the working language---either have @value{GDBN}
8090set it automatically, or select it manually yourself. You can use the
8091@code{set language} command for either purpose. On startup, @value{GDBN}
8092defaults to setting the language automatically. The working language is
8093used to determine how expressions you type are interpreted, how values
8094are printed, etc.
8095
8096In addition to the working language, every source file that
8097@value{GDBN} knows about has its own working language. For some object
8098file formats, the compiler might indicate which language a particular
8099source file is in. However, most of the time @value{GDBN} infers the
8100language from the name of the file. The language of a source file
b37052ae 8101controls whether C@t{++} names are demangled---this way @code{backtrace} can
c906108c 8102show each frame appropriately for its own language. There is no way to
d4f3574e
SS
8103set the language of a source file from within @value{GDBN}, but you can
8104set the language associated with a filename extension. @xref{Show, ,
8105Displaying the language}.
c906108c
SS
8106
8107This is most commonly a problem when you use a program, such
5d161b24 8108as @code{cfront} or @code{f2c}, that generates C but is written in
c906108c
SS
8109another language. In that case, make the
8110program use @code{#line} directives in its C output; that way
8111@value{GDBN} will know the correct language of the source code of the original
8112program, and will display that source code, not the generated C code.
8113
8114@menu
8115* Filenames:: Filename extensions and languages.
8116* Manually:: Setting the working language manually
8117* Automatically:: Having @value{GDBN} infer the source language
8118@end menu
8119
6d2ebf8b 8120@node Filenames
c906108c
SS
8121@subsection List of filename extensions and languages
8122
8123If a source file name ends in one of the following extensions, then
8124@value{GDBN} infers that its language is the one indicated.
8125
8126@table @file
e07c999f
PH
8127@item .ada
8128@itemx .ads
8129@itemx .adb
8130@itemx .a
8131Ada source file.
c906108c
SS
8132
8133@item .c
8134C source file
8135
8136@item .C
8137@itemx .cc
8138@itemx .cp
8139@itemx .cpp
8140@itemx .cxx
8141@itemx .c++
b37052ae 8142C@t{++} source file
c906108c 8143
b37303ee
AF
8144@item .m
8145Objective-C source file
8146
c906108c
SS
8147@item .f
8148@itemx .F
8149Fortran source file
8150
c906108c
SS
8151@item .mod
8152Modula-2 source file
c906108c
SS
8153
8154@item .s
8155@itemx .S
8156Assembler source file. This actually behaves almost like C, but
8157@value{GDBN} does not skip over function prologues when stepping.
8158@end table
8159
8160In addition, you may set the language associated with a filename
8161extension. @xref{Show, , Displaying the language}.
8162
6d2ebf8b 8163@node Manually
c906108c
SS
8164@subsection Setting the working language
8165
8166If you allow @value{GDBN} to set the language automatically,
8167expressions are interpreted the same way in your debugging session and
8168your program.
8169
8170@kindex set language
8171If you wish, you may set the language manually. To do this, issue the
8172command @samp{set language @var{lang}}, where @var{lang} is the name of
5d161b24 8173a language, such as
c906108c 8174@code{c} or @code{modula-2}.
c906108c
SS
8175For a list of the supported languages, type @samp{set language}.
8176
c906108c
SS
8177Setting the language manually prevents @value{GDBN} from updating the working
8178language automatically. This can lead to confusion if you try
8179to debug a program when the working language is not the same as the
8180source language, when an expression is acceptable to both
8181languages---but means different things. For instance, if the current
8182source file were written in C, and @value{GDBN} was parsing Modula-2, a
8183command such as:
8184
474c8240 8185@smallexample
c906108c 8186print a = b + c
474c8240 8187@end smallexample
c906108c
SS
8188
8189@noindent
8190might not have the effect you intended. In C, this means to add
8191@code{b} and @code{c} and place the result in @code{a}. The result
8192printed would be the value of @code{a}. In Modula-2, this means to compare
8193@code{a} to the result of @code{b+c}, yielding a @code{BOOLEAN} value.
c906108c 8194
6d2ebf8b 8195@node Automatically
c906108c
SS
8196@subsection Having @value{GDBN} infer the source language
8197
8198To have @value{GDBN} set the working language automatically, use
8199@samp{set language local} or @samp{set language auto}. @value{GDBN}
8200then infers the working language. That is, when your program stops in a
8201frame (usually by encountering a breakpoint), @value{GDBN} sets the
8202working language to the language recorded for the function in that
8203frame. If the language for a frame is unknown (that is, if the function
8204or block corresponding to the frame was defined in a source file that
8205does not have a recognized extension), the current working language is
8206not changed, and @value{GDBN} issues a warning.
8207
8208This may not seem necessary for most programs, which are written
8209entirely in one source language. However, program modules and libraries
8210written in one source language can be used by a main program written in
8211a different source language. Using @samp{set language auto} in this
8212case frees you from having to set the working language manually.
8213
6d2ebf8b 8214@node Show
c906108c 8215@section Displaying the language
c906108c
SS
8216
8217The following commands help you find out which language is the
8218working language, and also what language source files were written in.
8219
c906108c
SS
8220@table @code
8221@item show language
9c16f35a 8222@kindex show language
c906108c
SS
8223Display the current working language. This is the
8224language you can use with commands such as @code{print} to
8225build and compute expressions that may involve variables in your program.
8226
8227@item info frame
4644b6e3 8228@kindex info frame@r{, show the source language}
5d161b24 8229Display the source language for this frame. This language becomes the
c906108c 8230working language if you use an identifier from this frame.
5d161b24 8231@xref{Frame Info, ,Information about a frame}, to identify the other
c906108c
SS
8232information listed here.
8233
8234@item info source
4644b6e3 8235@kindex info source@r{, show the source language}
c906108c 8236Display the source language of this source file.
5d161b24 8237@xref{Symbols, ,Examining the Symbol Table}, to identify the other
c906108c
SS
8238information listed here.
8239@end table
8240
8241In unusual circumstances, you may have source files with extensions
8242not in the standard list. You can then set the extension associated
8243with a language explicitly:
8244
c906108c 8245@table @code
09d4efe1 8246@item set extension-language @var{ext} @var{language}
9c16f35a 8247@kindex set extension-language
09d4efe1
EZ
8248Tell @value{GDBN} that source files with extension @var{ext} are to be
8249assumed as written in the source language @var{language}.
c906108c
SS
8250
8251@item info extensions
9c16f35a 8252@kindex info extensions
c906108c
SS
8253List all the filename extensions and the associated languages.
8254@end table
8255
6d2ebf8b 8256@node Checks
c906108c
SS
8257@section Type and range checking
8258
8259@quotation
8260@emph{Warning:} In this release, the @value{GDBN} commands for type and range
8261checking are included, but they do not yet have any effect. This
8262section documents the intended facilities.
8263@end quotation
8264@c FIXME remove warning when type/range code added
8265
8266Some languages are designed to guard you against making seemingly common
8267errors through a series of compile- and run-time checks. These include
8268checking the type of arguments to functions and operators, and making
8269sure mathematical overflows are caught at run time. Checks such as
8270these help to ensure a program's correctness once it has been compiled
8271by eliminating type mismatches, and providing active checks for range
8272errors when your program is running.
8273
8274@value{GDBN} can check for conditions like the above if you wish.
9c16f35a
EZ
8275Although @value{GDBN} does not check the statements in your program,
8276it can check expressions entered directly into @value{GDBN} for
8277evaluation via the @code{print} command, for example. As with the
8278working language, @value{GDBN} can also decide whether or not to check
8279automatically based on your program's source language.
8280@xref{Supported languages, ,Supported languages}, for the default
8281settings of supported languages.
c906108c
SS
8282
8283@menu
8284* Type Checking:: An overview of type checking
8285* Range Checking:: An overview of range checking
8286@end menu
8287
8288@cindex type checking
8289@cindex checks, type
6d2ebf8b 8290@node Type Checking
c906108c
SS
8291@subsection An overview of type checking
8292
8293Some languages, such as Modula-2, are strongly typed, meaning that the
8294arguments to operators and functions have to be of the correct type,
8295otherwise an error occurs. These checks prevent type mismatch
8296errors from ever causing any run-time problems. For example,
8297
8298@smallexample
82991 + 2 @result{} 3
8300@exdent but
8301@error{} 1 + 2.3
8302@end smallexample
8303
8304The second example fails because the @code{CARDINAL} 1 is not
8305type-compatible with the @code{REAL} 2.3.
8306
5d161b24
DB
8307For the expressions you use in @value{GDBN} commands, you can tell the
8308@value{GDBN} type checker to skip checking;
8309to treat any mismatches as errors and abandon the expression;
8310or to only issue warnings when type mismatches occur,
c906108c
SS
8311but evaluate the expression anyway. When you choose the last of
8312these, @value{GDBN} evaluates expressions like the second example above, but
8313also issues a warning.
8314
5d161b24
DB
8315Even if you turn type checking off, there may be other reasons
8316related to type that prevent @value{GDBN} from evaluating an expression.
8317For instance, @value{GDBN} does not know how to add an @code{int} and
8318a @code{struct foo}. These particular type errors have nothing to do
8319with the language in use, and usually arise from expressions, such as
c906108c
SS
8320the one described above, which make little sense to evaluate anyway.
8321
8322Each language defines to what degree it is strict about type. For
8323instance, both Modula-2 and C require the arguments to arithmetical
8324operators to be numbers. In C, enumerated types and pointers can be
8325represented as numbers, so that they are valid arguments to mathematical
9c16f35a 8326operators. @xref{Supported languages, ,Supported languages}, for further
c906108c
SS
8327details on specific languages.
8328
8329@value{GDBN} provides some additional commands for controlling the type checker:
8330
c906108c
SS
8331@kindex set check type
8332@kindex show check type
8333@table @code
8334@item set check type auto
8335Set type checking on or off based on the current working language.
9c16f35a 8336@xref{Supported languages, ,Supported languages}, for the default settings for
c906108c
SS
8337each language.
8338
8339@item set check type on
8340@itemx set check type off
8341Set type checking on or off, overriding the default setting for the
8342current working language. Issue a warning if the setting does not
8343match the language default. If any type mismatches occur in
d4f3574e 8344evaluating an expression while type checking is on, @value{GDBN} prints a
c906108c
SS
8345message and aborts evaluation of the expression.
8346
8347@item set check type warn
8348Cause the type checker to issue warnings, but to always attempt to
8349evaluate the expression. Evaluating the expression may still
8350be impossible for other reasons. For example, @value{GDBN} cannot add
8351numbers and structures.
8352
8353@item show type
5d161b24 8354Show the current setting of the type checker, and whether or not @value{GDBN}
c906108c
SS
8355is setting it automatically.
8356@end table
8357
8358@cindex range checking
8359@cindex checks, range
6d2ebf8b 8360@node Range Checking
c906108c
SS
8361@subsection An overview of range checking
8362
8363In some languages (such as Modula-2), it is an error to exceed the
8364bounds of a type; this is enforced with run-time checks. Such range
8365checking is meant to ensure program correctness by making sure
8366computations do not overflow, or indices on an array element access do
8367not exceed the bounds of the array.
8368
8369For expressions you use in @value{GDBN} commands, you can tell
8370@value{GDBN} to treat range errors in one of three ways: ignore them,
8371always treat them as errors and abandon the expression, or issue
8372warnings but evaluate the expression anyway.
8373
8374A range error can result from numerical overflow, from exceeding an
8375array index bound, or when you type a constant that is not a member
8376of any type. Some languages, however, do not treat overflows as an
8377error. In many implementations of C, mathematical overflow causes the
8378result to ``wrap around'' to lower values---for example, if @var{m} is
8379the largest integer value, and @var{s} is the smallest, then
8380
474c8240 8381@smallexample
c906108c 8382@var{m} + 1 @result{} @var{s}
474c8240 8383@end smallexample
c906108c
SS
8384
8385This, too, is specific to individual languages, and in some cases
9c16f35a 8386specific to individual compilers or machines. @xref{Supported languages, ,
c906108c
SS
8387Supported languages}, for further details on specific languages.
8388
8389@value{GDBN} provides some additional commands for controlling the range checker:
8390
c906108c
SS
8391@kindex set check range
8392@kindex show check range
8393@table @code
8394@item set check range auto
8395Set range checking on or off based on the current working language.
9c16f35a 8396@xref{Supported languages, ,Supported languages}, for the default settings for
c906108c
SS
8397each language.
8398
8399@item set check range on
8400@itemx set check range off
8401Set range checking on or off, overriding the default setting for the
8402current working language. A warning is issued if the setting does not
c3f6f71d
JM
8403match the language default. If a range error occurs and range checking is on,
8404then a message is printed and evaluation of the expression is aborted.
c906108c
SS
8405
8406@item set check range warn
8407Output messages when the @value{GDBN} range checker detects a range error,
8408but attempt to evaluate the expression anyway. Evaluating the
8409expression may still be impossible for other reasons, such as accessing
8410memory that the process does not own (a typical example from many Unix
8411systems).
8412
8413@item show range
8414Show the current setting of the range checker, and whether or not it is
8415being set automatically by @value{GDBN}.
8416@end table
c906108c 8417
9c16f35a 8418@node Supported languages
c906108c 8419@section Supported languages
c906108c 8420
9c16f35a
EZ
8421@value{GDBN} supports C, C@t{++}, Objective-C, Fortran, Java, Pascal,
8422assembly, Modula-2, and Ada.
cce74817 8423@c This is false ...
c906108c
SS
8424Some @value{GDBN} features may be used in expressions regardless of the
8425language you use: the @value{GDBN} @code{@@} and @code{::} operators,
8426and the @samp{@{type@}addr} construct (@pxref{Expressions,
8427,Expressions}) can be used with the constructs of any supported
8428language.
8429
8430The following sections detail to what degree each source language is
8431supported by @value{GDBN}. These sections are not meant to be language
8432tutorials or references, but serve only as a reference guide to what the
8433@value{GDBN} expression parser accepts, and what input and output
8434formats should look like for different languages. There are many good
8435books written on each of these languages; please look to these for a
8436language reference or tutorial.
8437
c906108c 8438@menu
b37303ee 8439* C:: C and C@t{++}
b383017d 8440* Objective-C:: Objective-C
09d4efe1 8441* Fortran:: Fortran
9c16f35a 8442* Pascal:: Pascal
b37303ee 8443* Modula-2:: Modula-2
e07c999f 8444* Ada:: Ada
c906108c
SS
8445@end menu
8446
6d2ebf8b 8447@node C
b37052ae 8448@subsection C and C@t{++}
7a292a7a 8449
b37052ae
EZ
8450@cindex C and C@t{++}
8451@cindex expressions in C or C@t{++}
c906108c 8452
b37052ae 8453Since C and C@t{++} are so closely related, many features of @value{GDBN} apply
c906108c
SS
8454to both languages. Whenever this is the case, we discuss those languages
8455together.
8456
41afff9a
EZ
8457@cindex C@t{++}
8458@cindex @code{g++}, @sc{gnu} C@t{++} compiler
b37052ae
EZ
8459@cindex @sc{gnu} C@t{++}
8460The C@t{++} debugging facilities are jointly implemented by the C@t{++}
8461compiler and @value{GDBN}. Therefore, to debug your C@t{++} code
8462effectively, you must compile your C@t{++} programs with a supported
8463C@t{++} compiler, such as @sc{gnu} @code{g++}, or the HP ANSI C@t{++}
c906108c
SS
8464compiler (@code{aCC}).
8465
0179ffac
DC
8466For best results when using @sc{gnu} C@t{++}, use the DWARF 2 debugging
8467format; if it doesn't work on your system, try the stabs+ debugging
8468format. You can select those formats explicitly with the @code{g++}
8469command-line options @option{-gdwarf-2} and @option{-gstabs+}.
8470@xref{Debugging Options,,Options for Debugging Your Program or @sc{gnu}
8471CC, gcc.info, Using @sc{gnu} CC}.
c906108c 8472
c906108c 8473@menu
b37052ae
EZ
8474* C Operators:: C and C@t{++} operators
8475* C Constants:: C and C@t{++} constants
8476* C plus plus expressions:: C@t{++} expressions
8477* C Defaults:: Default settings for C and C@t{++}
8478* C Checks:: C and C@t{++} type and range checks
c906108c 8479* Debugging C:: @value{GDBN} and C
b37052ae 8480* Debugging C plus plus:: @value{GDBN} features for C@t{++}
c906108c 8481@end menu
c906108c 8482
6d2ebf8b 8483@node C Operators
b37052ae 8484@subsubsection C and C@t{++} operators
7a292a7a 8485
b37052ae 8486@cindex C and C@t{++} operators
c906108c
SS
8487
8488Operators must be defined on values of specific types. For instance,
8489@code{+} is defined on numbers, but not on structures. Operators are
5d161b24 8490often defined on groups of types.
c906108c 8491
b37052ae 8492For the purposes of C and C@t{++}, the following definitions hold:
c906108c
SS
8493
8494@itemize @bullet
53a5351d 8495
c906108c 8496@item
c906108c 8497@emph{Integral types} include @code{int} with any of its storage-class
b37052ae 8498specifiers; @code{char}; @code{enum}; and, for C@t{++}, @code{bool}.
c906108c
SS
8499
8500@item
d4f3574e
SS
8501@emph{Floating-point types} include @code{float}, @code{double}, and
8502@code{long double} (if supported by the target platform).
c906108c
SS
8503
8504@item
53a5351d 8505@emph{Pointer types} include all types defined as @code{(@var{type} *)}.
c906108c
SS
8506
8507@item
8508@emph{Scalar types} include all of the above.
53a5351d 8509
c906108c
SS
8510@end itemize
8511
8512@noindent
8513The following operators are supported. They are listed here
8514in order of increasing precedence:
8515
8516@table @code
8517@item ,
8518The comma or sequencing operator. Expressions in a comma-separated list
8519are evaluated from left to right, with the result of the entire
8520expression being the last expression evaluated.
8521
8522@item =
8523Assignment. The value of an assignment expression is the value
8524assigned. Defined on scalar types.
8525
8526@item @var{op}=
8527Used in an expression of the form @w{@code{@var{a} @var{op}= @var{b}}},
8528and translated to @w{@code{@var{a} = @var{a op b}}}.
d4f3574e 8529@w{@code{@var{op}=}} and @code{=} have the same precedence.
c906108c
SS
8530@var{op} is any one of the operators @code{|}, @code{^}, @code{&},
8531@code{<<}, @code{>>}, @code{+}, @code{-}, @code{*}, @code{/}, @code{%}.
8532
8533@item ?:
8534The ternary operator. @code{@var{a} ? @var{b} : @var{c}} can be thought
8535of as: if @var{a} then @var{b} else @var{c}. @var{a} should be of an
8536integral type.
8537
8538@item ||
8539Logical @sc{or}. Defined on integral types.
8540
8541@item &&
8542Logical @sc{and}. Defined on integral types.
8543
8544@item |
8545Bitwise @sc{or}. Defined on integral types.
8546
8547@item ^
8548Bitwise exclusive-@sc{or}. Defined on integral types.
8549
8550@item &
8551Bitwise @sc{and}. Defined on integral types.
8552
8553@item ==@r{, }!=
8554Equality and inequality. Defined on scalar types. The value of these
8555expressions is 0 for false and non-zero for true.
8556
8557@item <@r{, }>@r{, }<=@r{, }>=
8558Less than, greater than, less than or equal, greater than or equal.
8559Defined on scalar types. The value of these expressions is 0 for false
8560and non-zero for true.
8561
8562@item <<@r{, }>>
8563left shift, and right shift. Defined on integral types.
8564
8565@item @@
8566The @value{GDBN} ``artificial array'' operator (@pxref{Expressions, ,Expressions}).
8567
8568@item +@r{, }-
8569Addition and subtraction. Defined on integral types, floating-point types and
8570pointer types.
8571
8572@item *@r{, }/@r{, }%
8573Multiplication, division, and modulus. Multiplication and division are
8574defined on integral and floating-point types. Modulus is defined on
8575integral types.
8576
8577@item ++@r{, }--
8578Increment and decrement. When appearing before a variable, the
8579operation is performed before the variable is used in an expression;
8580when appearing after it, the variable's value is used before the
8581operation takes place.
8582
8583@item *
8584Pointer dereferencing. Defined on pointer types. Same precedence as
8585@code{++}.
8586
8587@item &
8588Address operator. Defined on variables. Same precedence as @code{++}.
8589
b37052ae
EZ
8590For debugging C@t{++}, @value{GDBN} implements a use of @samp{&} beyond what is
8591allowed in the C@t{++} language itself: you can use @samp{&(&@var{ref})}
c906108c 8592(or, if you prefer, simply @samp{&&@var{ref}}) to examine the address
b37052ae 8593where a C@t{++} reference variable (declared with @samp{&@var{ref}}) is
c906108c 8594stored.
c906108c
SS
8595
8596@item -
8597Negative. Defined on integral and floating-point types. Same
8598precedence as @code{++}.
8599
8600@item !
8601Logical negation. Defined on integral types. Same precedence as
8602@code{++}.
8603
8604@item ~
8605Bitwise complement operator. Defined on integral types. Same precedence as
8606@code{++}.
8607
8608
8609@item .@r{, }->
8610Structure member, and pointer-to-structure member. For convenience,
8611@value{GDBN} regards the two as equivalent, choosing whether to dereference a
8612pointer based on the stored type information.
8613Defined on @code{struct} and @code{union} data.
8614
c906108c
SS
8615@item .*@r{, }->*
8616Dereferences of pointers to members.
c906108c
SS
8617
8618@item []
8619Array indexing. @code{@var{a}[@var{i}]} is defined as
8620@code{*(@var{a}+@var{i})}. Same precedence as @code{->}.
8621
8622@item ()
8623Function parameter list. Same precedence as @code{->}.
8624
c906108c 8625@item ::
b37052ae 8626C@t{++} scope resolution operator. Defined on @code{struct}, @code{union},
7a292a7a 8627and @code{class} types.
c906108c
SS
8628
8629@item ::
7a292a7a
SS
8630Doubled colons also represent the @value{GDBN} scope operator
8631(@pxref{Expressions, ,Expressions}). Same precedence as @code{::},
8632above.
c906108c
SS
8633@end table
8634
c906108c
SS
8635If an operator is redefined in the user code, @value{GDBN} usually
8636attempts to invoke the redefined version instead of using the operator's
8637predefined meaning.
c906108c 8638
c906108c 8639@menu
5d161b24 8640* C Constants::
c906108c
SS
8641@end menu
8642
6d2ebf8b 8643@node C Constants
b37052ae 8644@subsubsection C and C@t{++} constants
c906108c 8645
b37052ae 8646@cindex C and C@t{++} constants
c906108c 8647
b37052ae 8648@value{GDBN} allows you to express the constants of C and C@t{++} in the
c906108c 8649following ways:
c906108c
SS
8650
8651@itemize @bullet
8652@item
8653Integer constants are a sequence of digits. Octal constants are
6ca652b0
EZ
8654specified by a leading @samp{0} (i.e.@: zero), and hexadecimal constants
8655by a leading @samp{0x} or @samp{0X}. Constants may also end with a letter
c906108c
SS
8656@samp{l}, specifying that the constant should be treated as a
8657@code{long} value.
8658
8659@item
8660Floating point constants are a sequence of digits, followed by a decimal
8661point, followed by a sequence of digits, and optionally followed by an
8662exponent. An exponent is of the form:
8663@samp{@w{e@r{[[}+@r{]|}-@r{]}@var{nnn}}}, where @var{nnn} is another
8664sequence of digits. The @samp{+} is optional for positive exponents.
d4f3574e
SS
8665A floating-point constant may also end with a letter @samp{f} or
8666@samp{F}, specifying that the constant should be treated as being of
8667the @code{float} (as opposed to the default @code{double}) type; or with
8668a letter @samp{l} or @samp{L}, which specifies a @code{long double}
8669constant.
c906108c
SS
8670
8671@item
8672Enumerated constants consist of enumerated identifiers, or their
8673integral equivalents.
8674
8675@item
8676Character constants are a single character surrounded by single quotes
8677(@code{'}), or a number---the ordinal value of the corresponding character
d4f3574e 8678(usually its @sc{ascii} value). Within quotes, the single character may
c906108c
SS
8679be represented by a letter or by @dfn{escape sequences}, which are of
8680the form @samp{\@var{nnn}}, where @var{nnn} is the octal representation
8681of the character's ordinal value; or of the form @samp{\@var{x}}, where
8682@samp{@var{x}} is a predefined special character---for example,
8683@samp{\n} for newline.
8684
8685@item
96a2c332
SS
8686String constants are a sequence of character constants surrounded by
8687double quotes (@code{"}). Any valid character constant (as described
8688above) may appear. Double quotes within the string must be preceded by
8689a backslash, so for instance @samp{"a\"b'c"} is a string of five
8690characters.
c906108c
SS
8691
8692@item
8693Pointer constants are an integral value. You can also write pointers
8694to constants using the C operator @samp{&}.
8695
8696@item
8697Array constants are comma-separated lists surrounded by braces @samp{@{}
8698and @samp{@}}; for example, @samp{@{1,2,3@}} is a three-element array of
8699integers, @samp{@{@{1,2@}, @{3,4@}, @{5,6@}@}} is a three-by-two array,
8700and @samp{@{&"hi", &"there", &"fred"@}} is a three-element array of pointers.
8701@end itemize
8702
c906108c 8703@menu
5d161b24
DB
8704* C plus plus expressions::
8705* C Defaults::
8706* C Checks::
c906108c 8707
5d161b24 8708* Debugging C::
c906108c
SS
8709@end menu
8710
6d2ebf8b 8711@node C plus plus expressions
b37052ae
EZ
8712@subsubsection C@t{++} expressions
8713
8714@cindex expressions in C@t{++}
8715@value{GDBN} expression handling can interpret most C@t{++} expressions.
8716
0179ffac
DC
8717@cindex debugging C@t{++} programs
8718@cindex C@t{++} compilers
8719@cindex debug formats and C@t{++}
8720@cindex @value{NGCC} and C@t{++}
c906108c 8721@quotation
b37052ae 8722@emph{Warning:} @value{GDBN} can only debug C@t{++} code if you use the
0179ffac
DC
8723proper compiler and the proper debug format. Currently, @value{GDBN}
8724works best when debugging C@t{++} code that is compiled with
8725@value{NGCC} 2.95.3 or with @value{NGCC} 3.1 or newer, using the options
8726@option{-gdwarf-2} or @option{-gstabs+}. DWARF 2 is preferred over
8727stabs+. Most configurations of @value{NGCC} emit either DWARF 2 or
8728stabs+ as their default debug format, so you usually don't need to
8729specify a debug format explicitly. Other compilers and/or debug formats
8730are likely to work badly or not at all when using @value{GDBN} to debug
8731C@t{++} code.
c906108c 8732@end quotation
c906108c
SS
8733
8734@enumerate
8735
8736@cindex member functions
8737@item
8738Member function calls are allowed; you can use expressions like
8739
474c8240 8740@smallexample
c906108c 8741count = aml->GetOriginal(x, y)
474c8240 8742@end smallexample
c906108c 8743
41afff9a 8744@vindex this@r{, inside C@t{++} member functions}
b37052ae 8745@cindex namespace in C@t{++}
c906108c
SS
8746@item
8747While a member function is active (in the selected stack frame), your
8748expressions have the same namespace available as the member function;
8749that is, @value{GDBN} allows implicit references to the class instance
b37052ae 8750pointer @code{this} following the same rules as C@t{++}.
c906108c 8751
c906108c 8752@cindex call overloaded functions
d4f3574e 8753@cindex overloaded functions, calling
b37052ae 8754@cindex type conversions in C@t{++}
c906108c
SS
8755@item
8756You can call overloaded functions; @value{GDBN} resolves the function
d4f3574e 8757call to the right definition, with some restrictions. @value{GDBN} does not
c906108c
SS
8758perform overload resolution involving user-defined type conversions,
8759calls to constructors, or instantiations of templates that do not exist
8760in the program. It also cannot handle ellipsis argument lists or
8761default arguments.
8762
8763It does perform integral conversions and promotions, floating-point
8764promotions, arithmetic conversions, pointer conversions, conversions of
8765class objects to base classes, and standard conversions such as those of
8766functions or arrays to pointers; it requires an exact match on the
8767number of function arguments.
8768
8769Overload resolution is always performed, unless you have specified
8770@code{set overload-resolution off}. @xref{Debugging C plus plus,
b37052ae 8771,@value{GDBN} features for C@t{++}}.
c906108c 8772
d4f3574e 8773You must specify @code{set overload-resolution off} in order to use an
c906108c
SS
8774explicit function signature to call an overloaded function, as in
8775@smallexample
8776p 'foo(char,int)'('x', 13)
8777@end smallexample
d4f3574e 8778
c906108c 8779The @value{GDBN} command-completion facility can simplify this;
d4f3574e 8780see @ref{Completion, ,Command completion}.
c906108c 8781
c906108c
SS
8782@cindex reference declarations
8783@item
b37052ae
EZ
8784@value{GDBN} understands variables declared as C@t{++} references; you can use
8785them in expressions just as you do in C@t{++} source---they are automatically
c906108c
SS
8786dereferenced.
8787
8788In the parameter list shown when @value{GDBN} displays a frame, the values of
8789reference variables are not displayed (unlike other variables); this
8790avoids clutter, since references are often used for large structures.
8791The @emph{address} of a reference variable is always shown, unless
8792you have specified @samp{set print address off}.
8793
8794@item
b37052ae 8795@value{GDBN} supports the C@t{++} name resolution operator @code{::}---your
c906108c
SS
8796expressions can use it just as expressions in your program do. Since
8797one scope may be defined in another, you can use @code{::} repeatedly if
8798necessary, for example in an expression like
8799@samp{@var{scope1}::@var{scope2}::@var{name}}. @value{GDBN} also allows
b37052ae 8800resolving name scope by reference to source files, in both C and C@t{++}
c906108c
SS
8801debugging (@pxref{Variables, ,Program variables}).
8802@end enumerate
8803
b37052ae 8804In addition, when used with HP's C@t{++} compiler, @value{GDBN} supports
53a5351d
JM
8805calling virtual functions correctly, printing out virtual bases of
8806objects, calling functions in a base subobject, casting objects, and
8807invoking user-defined operators.
c906108c 8808
6d2ebf8b 8809@node C Defaults
b37052ae 8810@subsubsection C and C@t{++} defaults
7a292a7a 8811
b37052ae 8812@cindex C and C@t{++} defaults
c906108c 8813
c906108c
SS
8814If you allow @value{GDBN} to set type and range checking automatically, they
8815both default to @code{off} whenever the working language changes to
b37052ae 8816C or C@t{++}. This happens regardless of whether you or @value{GDBN}
c906108c 8817selects the working language.
c906108c
SS
8818
8819If you allow @value{GDBN} to set the language automatically, it
8820recognizes source files whose names end with @file{.c}, @file{.C}, or
8821@file{.cc}, etc, and when @value{GDBN} enters code compiled from one of
b37052ae 8822these files, it sets the working language to C or C@t{++}.
c906108c
SS
8823@xref{Automatically, ,Having @value{GDBN} infer the source language},
8824for further details.
8825
c906108c
SS
8826@c Type checking is (a) primarily motivated by Modula-2, and (b)
8827@c unimplemented. If (b) changes, it might make sense to let this node
8828@c appear even if Mod-2 does not, but meanwhile ignore it. roland 16jul93.
7a292a7a 8829
6d2ebf8b 8830@node C Checks
b37052ae 8831@subsubsection C and C@t{++} type and range checks
7a292a7a 8832
b37052ae 8833@cindex C and C@t{++} checks
c906108c 8834
b37052ae 8835By default, when @value{GDBN} parses C or C@t{++} expressions, type checking
c906108c
SS
8836is not used. However, if you turn type checking on, @value{GDBN}
8837considers two variables type equivalent if:
8838
8839@itemize @bullet
8840@item
8841The two variables are structured and have the same structure, union, or
8842enumerated tag.
8843
8844@item
8845The two variables have the same type name, or types that have been
8846declared equivalent through @code{typedef}.
8847
8848@ignore
8849@c leaving this out because neither J Gilmore nor R Pesch understand it.
8850@c FIXME--beers?
8851@item
8852The two @code{struct}, @code{union}, or @code{enum} variables are
8853declared in the same declaration. (Note: this may not be true for all C
8854compilers.)
8855@end ignore
8856@end itemize
8857
8858Range checking, if turned on, is done on mathematical operations. Array
8859indices are not checked, since they are often used to index a pointer
8860that is not itself an array.
c906108c 8861
6d2ebf8b 8862@node Debugging C
c906108c 8863@subsubsection @value{GDBN} and C
c906108c
SS
8864
8865The @code{set print union} and @code{show print union} commands apply to
8866the @code{union} type. When set to @samp{on}, any @code{union} that is
7a292a7a
SS
8867inside a @code{struct} or @code{class} is also printed. Otherwise, it
8868appears as @samp{@{...@}}.
c906108c
SS
8869
8870The @code{@@} operator aids in the debugging of dynamic arrays, formed
8871with pointers and a memory allocation function. @xref{Expressions,
8872,Expressions}.
8873
c906108c 8874@menu
5d161b24 8875* Debugging C plus plus::
c906108c
SS
8876@end menu
8877
6d2ebf8b 8878@node Debugging C plus plus
b37052ae 8879@subsubsection @value{GDBN} features for C@t{++}
c906108c 8880
b37052ae 8881@cindex commands for C@t{++}
7a292a7a 8882
b37052ae
EZ
8883Some @value{GDBN} commands are particularly useful with C@t{++}, and some are
8884designed specifically for use with C@t{++}. Here is a summary:
c906108c
SS
8885
8886@table @code
8887@cindex break in overloaded functions
8888@item @r{breakpoint menus}
8889When you want a breakpoint in a function whose name is overloaded,
8890@value{GDBN} breakpoint menus help you specify which function definition
8891you want. @xref{Breakpoint Menus,,Breakpoint menus}.
8892
b37052ae 8893@cindex overloading in C@t{++}
c906108c
SS
8894@item rbreak @var{regex}
8895Setting breakpoints using regular expressions is helpful for setting
8896breakpoints on overloaded functions that are not members of any special
8897classes.
8898@xref{Set Breaks, ,Setting breakpoints}.
8899
b37052ae 8900@cindex C@t{++} exception handling
c906108c
SS
8901@item catch throw
8902@itemx catch catch
b37052ae 8903Debug C@t{++} exception handling using these commands. @xref{Set
c906108c
SS
8904Catchpoints, , Setting catchpoints}.
8905
8906@cindex inheritance
8907@item ptype @var{typename}
8908Print inheritance relationships as well as other information for type
8909@var{typename}.
8910@xref{Symbols, ,Examining the Symbol Table}.
8911
b37052ae 8912@cindex C@t{++} symbol display
c906108c
SS
8913@item set print demangle
8914@itemx show print demangle
8915@itemx set print asm-demangle
8916@itemx show print asm-demangle
b37052ae
EZ
8917Control whether C@t{++} symbols display in their source form, both when
8918displaying code as C@t{++} source and when displaying disassemblies.
c906108c
SS
8919@xref{Print Settings, ,Print settings}.
8920
8921@item set print object
8922@itemx show print object
8923Choose whether to print derived (actual) or declared types of objects.
8924@xref{Print Settings, ,Print settings}.
8925
8926@item set print vtbl
8927@itemx show print vtbl
8928Control the format for printing virtual function tables.
8929@xref{Print Settings, ,Print settings}.
c906108c 8930(The @code{vtbl} commands do not work on programs compiled with the HP
b37052ae 8931ANSI C@t{++} compiler (@code{aCC}).)
c906108c
SS
8932
8933@kindex set overload-resolution
d4f3574e 8934@cindex overloaded functions, overload resolution
c906108c 8935@item set overload-resolution on
b37052ae 8936Enable overload resolution for C@t{++} expression evaluation. The default
c906108c
SS
8937is on. For overloaded functions, @value{GDBN} evaluates the arguments
8938and searches for a function whose signature matches the argument types,
b37052ae 8939using the standard C@t{++} conversion rules (see @ref{C plus plus expressions, ,C@t{++}
d4f3574e 8940expressions}, for details). If it cannot find a match, it emits a
c906108c
SS
8941message.
8942
8943@item set overload-resolution off
b37052ae 8944Disable overload resolution for C@t{++} expression evaluation. For
c906108c
SS
8945overloaded functions that are not class member functions, @value{GDBN}
8946chooses the first function of the specified name that it finds in the
8947symbol table, whether or not its arguments are of the correct type. For
8948overloaded functions that are class member functions, @value{GDBN}
8949searches for a function whose signature @emph{exactly} matches the
8950argument types.
c906108c 8951
9c16f35a
EZ
8952@kindex show overload-resolution
8953@item show overload-resolution
8954Show the current setting of overload resolution.
8955
c906108c
SS
8956@item @r{Overloaded symbol names}
8957You can specify a particular definition of an overloaded symbol, using
b37052ae 8958the same notation that is used to declare such symbols in C@t{++}: type
c906108c
SS
8959@code{@var{symbol}(@var{types})} rather than just @var{symbol}. You can
8960also use the @value{GDBN} command-line word completion facilities to list the
8961available choices, or to finish the type list for you.
8962@xref{Completion,, Command completion}, for details on how to do this.
8963@end table
c906108c 8964
b37303ee
AF
8965@node Objective-C
8966@subsection Objective-C
8967
8968@cindex Objective-C
8969This section provides information about some commands and command
721c2651
EZ
8970options that are useful for debugging Objective-C code. See also
8971@ref{Symbols, info classes}, and @ref{Symbols, info selectors}, for a
8972few more commands specific to Objective-C support.
b37303ee
AF
8973
8974@menu
b383017d
RM
8975* Method Names in Commands::
8976* The Print Command with Objective-C::
b37303ee
AF
8977@end menu
8978
8979@node Method Names in Commands, The Print Command with Objective-C, Objective-C, Objective-C
8980@subsubsection Method Names in Commands
8981
8982The following commands have been extended to accept Objective-C method
8983names as line specifications:
8984
8985@kindex clear@r{, and Objective-C}
8986@kindex break@r{, and Objective-C}
8987@kindex info line@r{, and Objective-C}
8988@kindex jump@r{, and Objective-C}
8989@kindex list@r{, and Objective-C}
8990@itemize
8991@item @code{clear}
8992@item @code{break}
8993@item @code{info line}
8994@item @code{jump}
8995@item @code{list}
8996@end itemize
8997
8998A fully qualified Objective-C method name is specified as
8999
9000@smallexample
9001-[@var{Class} @var{methodName}]
9002@end smallexample
9003
c552b3bb
JM
9004where the minus sign is used to indicate an instance method and a
9005plus sign (not shown) is used to indicate a class method. The class
9006name @var{Class} and method name @var{methodName} are enclosed in
9007brackets, similar to the way messages are specified in Objective-C
9008source code. For example, to set a breakpoint at the @code{create}
9009instance method of class @code{Fruit} in the program currently being
9010debugged, enter:
b37303ee
AF
9011
9012@smallexample
9013break -[Fruit create]
9014@end smallexample
9015
9016To list ten program lines around the @code{initialize} class method,
9017enter:
9018
9019@smallexample
9020list +[NSText initialize]
9021@end smallexample
9022
c552b3bb
JM
9023In the current version of @value{GDBN}, the plus or minus sign is
9024required. In future versions of @value{GDBN}, the plus or minus
9025sign will be optional, but you can use it to narrow the search. It
9026is also possible to specify just a method name:
b37303ee
AF
9027
9028@smallexample
9029break create
9030@end smallexample
9031
9032You must specify the complete method name, including any colons. If
9033your program's source files contain more than one @code{create} method,
9034you'll be presented with a numbered list of classes that implement that
9035method. Indicate your choice by number, or type @samp{0} to exit if
9036none apply.
9037
9038As another example, to clear a breakpoint established at the
9039@code{makeKeyAndOrderFront:} method of the @code{NSWindow} class, enter:
9040
9041@smallexample
9042clear -[NSWindow makeKeyAndOrderFront:]
9043@end smallexample
9044
9045@node The Print Command with Objective-C
9046@subsubsection The Print Command With Objective-C
721c2651 9047@cindex Objective-C, print objects
c552b3bb
JM
9048@kindex print-object
9049@kindex po @r{(@code{print-object})}
b37303ee 9050
c552b3bb 9051The print command has also been extended to accept methods. For example:
b37303ee
AF
9052
9053@smallexample
c552b3bb 9054print -[@var{object} hash]
b37303ee
AF
9055@end smallexample
9056
9057@cindex print an Objective-C object description
c552b3bb
JM
9058@cindex @code{_NSPrintForDebugger}, and printing Objective-C objects
9059@noindent
9060will tell @value{GDBN} to send the @code{hash} message to @var{object}
9061and print the result. Also, an additional command has been added,
9062@code{print-object} or @code{po} for short, which is meant to print
9063the description of an object. However, this command may only work
9064with certain Objective-C libraries that have a particular hook
9065function, @code{_NSPrintForDebugger}, defined.
b37303ee 9066
09d4efe1
EZ
9067@node Fortran
9068@subsection Fortran
9069@cindex Fortran-specific support in @value{GDBN}
9070
9071@table @code
9072@cindex @code{COMMON} blocks, Fortran
9073@kindex info common
9074@item info common @r{[}@var{common-name}@r{]}
9075This command prints the values contained in the Fortran @code{COMMON}
9076block whose name is @var{common-name}. With no argument, the names of
9077all @code{COMMON} blocks visible at current program location are
9078printed.
9079@end table
9080
a8f24a35
EZ
9081Fortran symbols are usually case-insensitive, so @value{GDBN} by
9082default uses case-insensitive matches for Fortran symbols. You can
9083change that with the @samp{set case-insensitive} command, see
9084@ref{Symbols}, for the details.
9085
9c16f35a
EZ
9086@node Pascal
9087@subsection Pascal
9088
9089@cindex Pascal support in @value{GDBN}, limitations
9090Debugging Pascal programs which use sets, subranges, file variables, or
9091nested functions does not currently work. @value{GDBN} does not support
9092entering expressions, printing values, or similar features using Pascal
9093syntax.
9094
9095The Pascal-specific command @code{set print pascal_static-members}
9096controls whether static members of Pascal objects are displayed.
9097@xref{Print Settings, pascal_static-members}.
9098
09d4efe1 9099@node Modula-2
c906108c 9100@subsection Modula-2
7a292a7a 9101
d4f3574e 9102@cindex Modula-2, @value{GDBN} support
c906108c
SS
9103
9104The extensions made to @value{GDBN} to support Modula-2 only support
9105output from the @sc{gnu} Modula-2 compiler (which is currently being
9106developed). Other Modula-2 compilers are not currently supported, and
9107attempting to debug executables produced by them is most likely
9108to give an error as @value{GDBN} reads in the executable's symbol
9109table.
9110
9111@cindex expressions in Modula-2
9112@menu
9113* M2 Operators:: Built-in operators
9114* Built-In Func/Proc:: Built-in functions and procedures
9115* M2 Constants:: Modula-2 constants
9116* M2 Defaults:: Default settings for Modula-2
9117* Deviations:: Deviations from standard Modula-2
9118* M2 Checks:: Modula-2 type and range checks
9119* M2 Scope:: The scope operators @code{::} and @code{.}
9120* GDB/M2:: @value{GDBN} and Modula-2
9121@end menu
9122
6d2ebf8b 9123@node M2 Operators
c906108c
SS
9124@subsubsection Operators
9125@cindex Modula-2 operators
9126
9127Operators must be defined on values of specific types. For instance,
9128@code{+} is defined on numbers, but not on structures. Operators are
9129often defined on groups of types. For the purposes of Modula-2, the
9130following definitions hold:
9131
9132@itemize @bullet
9133
9134@item
9135@emph{Integral types} consist of @code{INTEGER}, @code{CARDINAL}, and
9136their subranges.
9137
9138@item
9139@emph{Character types} consist of @code{CHAR} and its subranges.
9140
9141@item
9142@emph{Floating-point types} consist of @code{REAL}.
9143
9144@item
9145@emph{Pointer types} consist of anything declared as @code{POINTER TO
9146@var{type}}.
9147
9148@item
9149@emph{Scalar types} consist of all of the above.
9150
9151@item
9152@emph{Set types} consist of @code{SET} and @code{BITSET} types.
9153
9154@item
9155@emph{Boolean types} consist of @code{BOOLEAN}.
9156@end itemize
9157
9158@noindent
9159The following operators are supported, and appear in order of
9160increasing precedence:
9161
9162@table @code
9163@item ,
9164Function argument or array index separator.
9165
9166@item :=
9167Assignment. The value of @var{var} @code{:=} @var{value} is
9168@var{value}.
9169
9170@item <@r{, }>
9171Less than, greater than on integral, floating-point, or enumerated
9172types.
9173
9174@item <=@r{, }>=
96a2c332 9175Less than or equal to, greater than or equal to
c906108c
SS
9176on integral, floating-point and enumerated types, or set inclusion on
9177set types. Same precedence as @code{<}.
9178
9179@item =@r{, }<>@r{, }#
9180Equality and two ways of expressing inequality, valid on scalar types.
9181Same precedence as @code{<}. In @value{GDBN} scripts, only @code{<>} is
9182available for inequality, since @code{#} conflicts with the script
9183comment character.
9184
9185@item IN
9186Set membership. Defined on set types and the types of their members.
9187Same precedence as @code{<}.
9188
9189@item OR
9190Boolean disjunction. Defined on boolean types.
9191
9192@item AND@r{, }&
d4f3574e 9193Boolean conjunction. Defined on boolean types.
c906108c
SS
9194
9195@item @@
9196The @value{GDBN} ``artificial array'' operator (@pxref{Expressions, ,Expressions}).
9197
9198@item +@r{, }-
9199Addition and subtraction on integral and floating-point types, or union
9200and difference on set types.
9201
9202@item *
9203Multiplication on integral and floating-point types, or set intersection
9204on set types.
9205
9206@item /
9207Division on floating-point types, or symmetric set difference on set
9208types. Same precedence as @code{*}.
9209
9210@item DIV@r{, }MOD
9211Integer division and remainder. Defined on integral types. Same
9212precedence as @code{*}.
9213
9214@item -
9215Negative. Defined on @code{INTEGER} and @code{REAL} data.
9216
9217@item ^
9218Pointer dereferencing. Defined on pointer types.
9219
9220@item NOT
9221Boolean negation. Defined on boolean types. Same precedence as
9222@code{^}.
9223
9224@item .
9225@code{RECORD} field selector. Defined on @code{RECORD} data. Same
9226precedence as @code{^}.
9227
9228@item []
9229Array indexing. Defined on @code{ARRAY} data. Same precedence as @code{^}.
9230
9231@item ()
9232Procedure argument list. Defined on @code{PROCEDURE} objects. Same precedence
9233as @code{^}.
9234
9235@item ::@r{, }.
9236@value{GDBN} and Modula-2 scope operators.
9237@end table
9238
9239@quotation
9240@emph{Warning:} Sets and their operations are not yet supported, so @value{GDBN}
9241treats the use of the operator @code{IN}, or the use of operators
9242@code{+}, @code{-}, @code{*}, @code{/}, @code{=}, , @code{<>}, @code{#},
9243@code{<=}, and @code{>=} on sets as an error.
9244@end quotation
9245
cb51c4e0 9246
6d2ebf8b 9247@node Built-In Func/Proc
c906108c 9248@subsubsection Built-in functions and procedures
cb51c4e0 9249@cindex Modula-2 built-ins
c906108c
SS
9250
9251Modula-2 also makes available several built-in procedures and functions.
9252In describing these, the following metavariables are used:
9253
9254@table @var
9255
9256@item a
9257represents an @code{ARRAY} variable.
9258
9259@item c
9260represents a @code{CHAR} constant or variable.
9261
9262@item i
9263represents a variable or constant of integral type.
9264
9265@item m
9266represents an identifier that belongs to a set. Generally used in the
9267same function with the metavariable @var{s}. The type of @var{s} should
9268be @code{SET OF @var{mtype}} (where @var{mtype} is the type of @var{m}).
9269
9270@item n
9271represents a variable or constant of integral or floating-point type.
9272
9273@item r
9274represents a variable or constant of floating-point type.
9275
9276@item t
9277represents a type.
9278
9279@item v
9280represents a variable.
9281
9282@item x
9283represents a variable or constant of one of many types. See the
9284explanation of the function for details.
9285@end table
9286
9287All Modula-2 built-in procedures also return a result, described below.
9288
9289@table @code
9290@item ABS(@var{n})
9291Returns the absolute value of @var{n}.
9292
9293@item CAP(@var{c})
9294If @var{c} is a lower case letter, it returns its upper case
c3f6f71d 9295equivalent, otherwise it returns its argument.
c906108c
SS
9296
9297@item CHR(@var{i})
9298Returns the character whose ordinal value is @var{i}.
9299
9300@item DEC(@var{v})
c3f6f71d 9301Decrements the value in the variable @var{v} by one. Returns the new value.
c906108c
SS
9302
9303@item DEC(@var{v},@var{i})
9304Decrements the value in the variable @var{v} by @var{i}. Returns the
9305new value.
9306
9307@item EXCL(@var{m},@var{s})
9308Removes the element @var{m} from the set @var{s}. Returns the new
9309set.
9310
9311@item FLOAT(@var{i})
9312Returns the floating point equivalent of the integer @var{i}.
9313
9314@item HIGH(@var{a})
9315Returns the index of the last member of @var{a}.
9316
9317@item INC(@var{v})
c3f6f71d 9318Increments the value in the variable @var{v} by one. Returns the new value.
c906108c
SS
9319
9320@item INC(@var{v},@var{i})
9321Increments the value in the variable @var{v} by @var{i}. Returns the
9322new value.
9323
9324@item INCL(@var{m},@var{s})
9325Adds the element @var{m} to the set @var{s} if it is not already
9326there. Returns the new set.
9327
9328@item MAX(@var{t})
9329Returns the maximum value of the type @var{t}.
9330
9331@item MIN(@var{t})
9332Returns the minimum value of the type @var{t}.
9333
9334@item ODD(@var{i})
9335Returns boolean TRUE if @var{i} is an odd number.
9336
9337@item ORD(@var{x})
9338Returns the ordinal value of its argument. For example, the ordinal
c3f6f71d
JM
9339value of a character is its @sc{ascii} value (on machines supporting the
9340@sc{ascii} character set). @var{x} must be of an ordered type, which include
c906108c
SS
9341integral, character and enumerated types.
9342
9343@item SIZE(@var{x})
9344Returns the size of its argument. @var{x} can be a variable or a type.
9345
9346@item TRUNC(@var{r})
9347Returns the integral part of @var{r}.
9348
9349@item VAL(@var{t},@var{i})
9350Returns the member of the type @var{t} whose ordinal value is @var{i}.
9351@end table
9352
9353@quotation
9354@emph{Warning:} Sets and their operations are not yet supported, so
9355@value{GDBN} treats the use of procedures @code{INCL} and @code{EXCL} as
9356an error.
9357@end quotation
9358
9359@cindex Modula-2 constants
6d2ebf8b 9360@node M2 Constants
c906108c
SS
9361@subsubsection Constants
9362
9363@value{GDBN} allows you to express the constants of Modula-2 in the following
9364ways:
9365
9366@itemize @bullet
9367
9368@item
9369Integer constants are simply a sequence of digits. When used in an
9370expression, a constant is interpreted to be type-compatible with the
9371rest of the expression. Hexadecimal integers are specified by a
9372trailing @samp{H}, and octal integers by a trailing @samp{B}.
9373
9374@item
9375Floating point constants appear as a sequence of digits, followed by a
9376decimal point and another sequence of digits. An optional exponent can
9377then be specified, in the form @samp{E@r{[}+@r{|}-@r{]}@var{nnn}}, where
9378@samp{@r{[}+@r{|}-@r{]}@var{nnn}} is the desired exponent. All of the
9379digits of the floating point constant must be valid decimal (base 10)
9380digits.
9381
9382@item
9383Character constants consist of a single character enclosed by a pair of
9384like quotes, either single (@code{'}) or double (@code{"}). They may
c3f6f71d 9385also be expressed by their ordinal value (their @sc{ascii} value, usually)
c906108c
SS
9386followed by a @samp{C}.
9387
9388@item
9389String constants consist of a sequence of characters enclosed by a
9390pair of like quotes, either single (@code{'}) or double (@code{"}).
9391Escape sequences in the style of C are also allowed. @xref{C
b37052ae 9392Constants, ,C and C@t{++} constants}, for a brief explanation of escape
c906108c
SS
9393sequences.
9394
9395@item
9396Enumerated constants consist of an enumerated identifier.
9397
9398@item
9399Boolean constants consist of the identifiers @code{TRUE} and
9400@code{FALSE}.
9401
9402@item
9403Pointer constants consist of integral values only.
9404
9405@item
9406Set constants are not yet supported.
9407@end itemize
9408
6d2ebf8b 9409@node M2 Defaults
c906108c
SS
9410@subsubsection Modula-2 defaults
9411@cindex Modula-2 defaults
9412
9413If type and range checking are set automatically by @value{GDBN}, they
9414both default to @code{on} whenever the working language changes to
d4f3574e 9415Modula-2. This happens regardless of whether you or @value{GDBN}
c906108c
SS
9416selected the working language.
9417
9418If you allow @value{GDBN} to set the language automatically, then entering
9419code compiled from a file whose name ends with @file{.mod} sets the
d4f3574e 9420working language to Modula-2. @xref{Automatically, ,Having @value{GDBN} set
c906108c
SS
9421the language automatically}, for further details.
9422
6d2ebf8b 9423@node Deviations
c906108c
SS
9424@subsubsection Deviations from standard Modula-2
9425@cindex Modula-2, deviations from
9426
9427A few changes have been made to make Modula-2 programs easier to debug.
9428This is done primarily via loosening its type strictness:
9429
9430@itemize @bullet
9431@item
9432Unlike in standard Modula-2, pointer constants can be formed by
9433integers. This allows you to modify pointer variables during
9434debugging. (In standard Modula-2, the actual address contained in a
9435pointer variable is hidden from you; it can only be modified
9436through direct assignment to another pointer variable or expression that
9437returned a pointer.)
9438
9439@item
9440C escape sequences can be used in strings and characters to represent
9441non-printable characters. @value{GDBN} prints out strings with these
9442escape sequences embedded. Single non-printable characters are
9443printed using the @samp{CHR(@var{nnn})} format.
9444
9445@item
9446The assignment operator (@code{:=}) returns the value of its right-hand
9447argument.
9448
9449@item
9450All built-in procedures both modify @emph{and} return their argument.
9451@end itemize
9452
6d2ebf8b 9453@node M2 Checks
c906108c
SS
9454@subsubsection Modula-2 type and range checks
9455@cindex Modula-2 checks
9456
9457@quotation
9458@emph{Warning:} in this release, @value{GDBN} does not yet perform type or
9459range checking.
9460@end quotation
9461@c FIXME remove warning when type/range checks added
9462
9463@value{GDBN} considers two Modula-2 variables type equivalent if:
9464
9465@itemize @bullet
9466@item
9467They are of types that have been declared equivalent via a @code{TYPE
9468@var{t1} = @var{t2}} statement
9469
9470@item
9471They have been declared on the same line. (Note: This is true of the
9472@sc{gnu} Modula-2 compiler, but it may not be true of other compilers.)
9473@end itemize
9474
9475As long as type checking is enabled, any attempt to combine variables
9476whose types are not equivalent is an error.
9477
9478Range checking is done on all mathematical operations, assignment, array
9479index bounds, and all built-in functions and procedures.
9480
6d2ebf8b 9481@node M2 Scope
c906108c
SS
9482@subsubsection The scope operators @code{::} and @code{.}
9483@cindex scope
41afff9a 9484@cindex @code{.}, Modula-2 scope operator
c906108c
SS
9485@cindex colon, doubled as scope operator
9486@ifinfo
41afff9a 9487@vindex colon-colon@r{, in Modula-2}
c906108c
SS
9488@c Info cannot handle :: but TeX can.
9489@end ifinfo
9490@iftex
41afff9a 9491@vindex ::@r{, in Modula-2}
c906108c
SS
9492@end iftex
9493
9494There are a few subtle differences between the Modula-2 scope operator
9495(@code{.}) and the @value{GDBN} scope operator (@code{::}). The two have
9496similar syntax:
9497
474c8240 9498@smallexample
c906108c
SS
9499
9500@var{module} . @var{id}
9501@var{scope} :: @var{id}
474c8240 9502@end smallexample
c906108c
SS
9503
9504@noindent
9505where @var{scope} is the name of a module or a procedure,
9506@var{module} the name of a module, and @var{id} is any declared
9507identifier within your program, except another module.
9508
9509Using the @code{::} operator makes @value{GDBN} search the scope
9510specified by @var{scope} for the identifier @var{id}. If it is not
9511found in the specified scope, then @value{GDBN} searches all scopes
9512enclosing the one specified by @var{scope}.
9513
9514Using the @code{.} operator makes @value{GDBN} search the current scope for
9515the identifier specified by @var{id} that was imported from the
9516definition module specified by @var{module}. With this operator, it is
9517an error if the identifier @var{id} was not imported from definition
9518module @var{module}, or if @var{id} is not an identifier in
9519@var{module}.
9520
6d2ebf8b 9521@node GDB/M2
c906108c
SS
9522@subsubsection @value{GDBN} and Modula-2
9523
9524Some @value{GDBN} commands have little use when debugging Modula-2 programs.
9525Five subcommands of @code{set print} and @code{show print} apply
b37052ae 9526specifically to C and C@t{++}: @samp{vtbl}, @samp{demangle},
c906108c 9527@samp{asm-demangle}, @samp{object}, and @samp{union}. The first four
b37052ae 9528apply to C@t{++}, and the last to the C @code{union} type, which has no direct
c906108c
SS
9529analogue in Modula-2.
9530
9531The @code{@@} operator (@pxref{Expressions, ,Expressions}), while available
d4f3574e 9532with any language, is not useful with Modula-2. Its
c906108c 9533intent is to aid the debugging of @dfn{dynamic arrays}, which cannot be
b37052ae 9534created in Modula-2 as they can in C or C@t{++}. However, because an
c906108c 9535address can be specified by an integral constant, the construct
d4f3574e 9536@samp{@{@var{type}@}@var{adrexp}} is still useful.
c906108c
SS
9537
9538@cindex @code{#} in Modula-2
9539In @value{GDBN} scripts, the Modula-2 inequality operator @code{#} is
9540interpreted as the beginning of a comment. Use @code{<>} instead.
c906108c 9541
e07c999f
PH
9542@node Ada
9543@subsection Ada
9544@cindex Ada
9545
9546The extensions made to @value{GDBN} for Ada only support
9547output from the @sc{gnu} Ada (GNAT) compiler.
9548Other Ada compilers are not currently supported, and
9549attempting to debug executables produced by them is most likely
9550to be difficult.
9551
9552
9553@cindex expressions in Ada
9554@menu
9555* Ada Mode Intro:: General remarks on the Ada syntax
9556 and semantics supported by Ada mode
9557 in @value{GDBN}.
9558* Omissions from Ada:: Restrictions on the Ada expression syntax.
9559* Additions to Ada:: Extensions of the Ada expression syntax.
9560* Stopping Before Main Program:: Debugging the program during elaboration.
9561* Ada Glitches:: Known peculiarities of Ada mode.
9562@end menu
9563
9564@node Ada Mode Intro
9565@subsubsection Introduction
9566@cindex Ada mode, general
9567
9568The Ada mode of @value{GDBN} supports a fairly large subset of Ada expression
9569syntax, with some extensions.
9570The philosophy behind the design of this subset is
9571
9572@itemize @bullet
9573@item
9574That @value{GDBN} should provide basic literals and access to operations for
9575arithmetic, dereferencing, field selection, indexing, and subprogram calls,
9576leaving more sophisticated computations to subprograms written into the
9577program (which therefore may be called from @value{GDBN}).
9578
9579@item
9580That type safety and strict adherence to Ada language restrictions
9581are not particularly important to the @value{GDBN} user.
9582
9583@item
9584That brevity is important to the @value{GDBN} user.
9585@end itemize
9586
9587Thus, for brevity, the debugger acts as if there were
9588implicit @code{with} and @code{use} clauses in effect for all user-written
9589packages, making it unnecessary to fully qualify most names with
9590their packages, regardless of context. Where this causes ambiguity,
9591@value{GDBN} asks the user's intent.
9592
9593The debugger will start in Ada mode if it detects an Ada main program.
9594As for other languages, it will enter Ada mode when stopped in a program that
9595was translated from an Ada source file.
9596
9597While in Ada mode, you may use `@t{--}' for comments. This is useful
9598mostly for documenting command files. The standard @value{GDBN} comment
9599(@samp{#}) still works at the beginning of a line in Ada mode, but not in the
9600middle (to allow based literals).
9601
9602The debugger supports limited overloading. Given a subprogram call in which
9603the function symbol has multiple definitions, it will use the number of
9604actual parameters and some information about their types to attempt to narrow
9605the set of definitions. It also makes very limited use of context, preferring
9606procedures to functions in the context of the @code{call} command, and
9607functions to procedures elsewhere.
9608
9609@node Omissions from Ada
9610@subsubsection Omissions from Ada
9611@cindex Ada, omissions from
9612
9613Here are the notable omissions from the subset:
9614
9615@itemize @bullet
9616@item
9617Only a subset of the attributes are supported:
9618
9619@itemize @minus
9620@item
9621@t{'First}, @t{'Last}, and @t{'Length}
9622 on array objects (not on types and subtypes).
9623
9624@item
9625@t{'Min} and @t{'Max}.
9626
9627@item
9628@t{'Pos} and @t{'Val}.
9629
9630@item
9631@t{'Tag}.
9632
9633@item
9634@t{'Range} on array objects (not subtypes), but only as the right
9635operand of the membership (@code{in}) operator.
9636
9637@item
9638@t{'Access}, @t{'Unchecked_Access}, and
9639@t{'Unrestricted_Access} (a GNAT extension).
9640
9641@item
9642@t{'Address}.
9643@end itemize
9644
9645@item
9646The names in
9647@code{Characters.Latin_1} are not available and
9648concatenation is not implemented. Thus, escape characters in strings are
9649not currently available.
9650
9651@item
9652Equality tests (@samp{=} and @samp{/=}) on arrays test for bitwise
9653equality of representations. They will generally work correctly
9654for strings and arrays whose elements have integer or enumeration types.
9655They may not work correctly for arrays whose element
9656types have user-defined equality, for arrays of real values
9657(in particular, IEEE-conformant floating point, because of negative
9658zeroes and NaNs), and for arrays whose elements contain unused bits with
9659indeterminate values.
9660
9661@item
9662The other component-by-component array operations (@code{and}, @code{or},
9663@code{xor}, @code{not}, and relational tests other than equality)
9664are not implemented.
9665
9666@item
9667There are no record or array aggregates.
9668
9669@item
9670Calls to dispatching subprograms are not implemented.
9671
9672@item
9673The overloading algorithm is much more limited (i.e., less selective)
9674than that of real Ada. It makes only limited use of the context in which a subexpression
9675appears to resolve its meaning, and it is much looser in its rules for allowing
9676type matches. As a result, some function calls will be ambiguous, and the user
9677will be asked to choose the proper resolution.
9678
9679@item
9680The @code{new} operator is not implemented.
9681
9682@item
9683Entry calls are not implemented.
9684
9685@item
9686Aside from printing, arithmetic operations on the native VAX floating-point
9687formats are not supported.
9688
9689@item
9690It is not possible to slice a packed array.
9691@end itemize
9692
9693@node Additions to Ada
9694@subsubsection Additions to Ada
9695@cindex Ada, deviations from
9696
9697As it does for other languages, @value{GDBN} makes certain generic
9698extensions to Ada (@pxref{Expressions}):
9699
9700@itemize @bullet
9701@item
9702If the expression @var{E} is a variable residing in memory
9703(typically a local variable or array element) and @var{N} is
9704a positive integer, then @code{@var{E}@@@var{N}} displays the values of
9705@var{E} and the @var{N}-1 adjacent variables following it in memory as an array.
9706In Ada, this operator is generally not necessary, since its prime use
9707is in displaying parts of an array, and slicing will usually do this in Ada.
9708However, there are occasional uses when debugging programs
9709in which certain debugging information has been optimized away.
9710
9711@item
9712@code{@var{B}::@var{var}} means ``the variable named @var{var} that appears
9713in function or file @var{B}.'' When @var{B} is a file name, you must typically
9714surround it in single quotes.
9715
9716@item
9717The expression @code{@{@var{type}@} @var{addr}} means ``the variable of type
9718@var{type} that appears at address @var{addr}.''
9719
9720@item
9721A name starting with @samp{$} is a convenience variable
9722(@pxref{Convenience Vars}) or a machine register (@pxref{Registers}).
9723@end itemize
9724
9725In addition, @value{GDBN} provides a few other shortcuts and outright additions specific
9726to Ada:
9727
9728@itemize @bullet
9729@item
9730The assignment statement is allowed as an expression, returning
9731its right-hand operand as its value. Thus, you may enter
9732
9733@smallexample
9734set x := y + 3
9735print A(tmp := y + 1)
9736@end smallexample
9737
9738@item
9739The semicolon is allowed as an ``operator,'' returning as its value
9740the value of its right-hand operand.
9741This allows, for example,
9742complex conditional breaks:
9743
9744@smallexample
9745break f
9746condition 1 (report(i); k += 1; A(k) > 100)
9747@end smallexample
9748
9749@item
9750Rather than use catenation and symbolic character names to introduce special
9751characters into strings, one may instead use a special bracket notation,
9752which is also used to print strings. A sequence of characters of the form
9753@samp{["@var{XX}"]} within a string or character literal denotes the
9754(single) character whose numeric encoding is @var{XX} in hexadecimal. The
9755sequence of characters @samp{["""]} also denotes a single quotation mark
9756in strings. For example,
9757@smallexample
9758 "One line.["0a"]Next line.["0a"]"
9759@end smallexample
9760@noindent
9761contains an ASCII newline character (@code{Ada.Characters.Latin_1.LF}) after each
9762period.
9763
9764@item
9765The subtype used as a prefix for the attributes @t{'Pos}, @t{'Min}, and
9766@t{'Max} is optional (and is ignored in any case). For example, it is valid
9767to write
9768
9769@smallexample
9770print 'max(x, y)
9771@end smallexample
9772
9773@item
9774When printing arrays, @value{GDBN} uses positional notation when the
9775array has a lower bound of 1, and uses a modified named notation otherwise.
9776For example, a one-dimensional array of three integers with a lower bound of 3 might print as
9777
9778@smallexample
9779(3 => 10, 17, 1)
9780@end smallexample
9781
9782@noindent
9783That is, in contrast to valid Ada, only the first component has a @code{=>}
9784clause.
9785
9786@item
9787You may abbreviate attributes in expressions with any unique,
9788multi-character subsequence of
9789their names (an exact match gets preference).
9790For example, you may use @t{a'len}, @t{a'gth}, or @t{a'lh}
9791in place of @t{a'length}.
9792
9793@item
9794@cindex quoting Ada internal identifiers
9795Since Ada is case-insensitive, the debugger normally maps identifiers you type
9796to lower case. The GNAT compiler uses upper-case characters for
9797some of its internal identifiers, which are normally of no interest to users.
9798For the rare occasions when you actually have to look at them,
9799enclose them in angle brackets to avoid the lower-case mapping.
9800For example,
9801@smallexample
9802@value{GDBP} print <JMPBUF_SAVE>[0]
9803@end smallexample
9804
9805@item
9806Printing an object of class-wide type or dereferencing an
9807access-to-class-wide value will display all the components of the object's
9808specific type (as indicated by its run-time tag). Likewise, component
9809selection on such a value will operate on the specific type of the
9810object.
9811
9812@end itemize
9813
9814@node Stopping Before Main Program
9815@subsubsection Stopping at the Very Beginning
9816
9817@cindex breakpointing Ada elaboration code
9818It is sometimes necessary to debug the program during elaboration, and
9819before reaching the main procedure.
9820As defined in the Ada Reference
9821Manual, the elaboration code is invoked from a procedure called
9822@code{adainit}. To run your program up to the beginning of
9823elaboration, simply use the following two commands:
9824@code{tbreak adainit} and @code{run}.
9825
9826@node Ada Glitches
9827@subsubsection Known Peculiarities of Ada Mode
9828@cindex Ada, problems
9829
9830Besides the omissions listed previously (@pxref{Omissions from Ada}),
9831we know of several problems with and limitations of Ada mode in
9832@value{GDBN},
9833some of which will be fixed with planned future releases of the debugger
9834and the GNU Ada compiler.
9835
9836@itemize @bullet
9837@item
9838Currently, the debugger
9839has insufficient information to determine whether certain pointers represent
9840pointers to objects or the objects themselves.
9841Thus, the user may have to tack an extra @code{.all} after an expression
9842to get it printed properly.
9843
9844@item
9845Static constants that the compiler chooses not to materialize as objects in
9846storage are invisible to the debugger.
9847
9848@item
9849Named parameter associations in function argument lists are ignored (the
9850argument lists are treated as positional).
9851
9852@item
9853Many useful library packages are currently invisible to the debugger.
9854
9855@item
9856Fixed-point arithmetic, conversions, input, and output is carried out using
9857floating-point arithmetic, and may give results that only approximate those on
9858the host machine.
9859
9860@item
9861The type of the @t{'Address} attribute may not be @code{System.Address}.
9862
9863@item
9864The GNAT compiler never generates the prefix @code{Standard} for any of
9865the standard symbols defined by the Ada language. @value{GDBN} knows about
9866this: it will strip the prefix from names when you use it, and will never
9867look for a name you have so qualified among local symbols, nor match against
9868symbols in other packages or subprograms. If you have
9869defined entities anywhere in your program other than parameters and
9870local variables whose simple names match names in @code{Standard},
9871GNAT's lack of qualification here can cause confusion. When this happens,
9872you can usually resolve the confusion
9873by qualifying the problematic names with package
9874@code{Standard} explicitly.
9875@end itemize
9876
4e562065
JB
9877@node Unsupported languages
9878@section Unsupported languages
9879
9880@cindex unsupported languages
9881@cindex minimal language
9882In addition to the other fully-supported programming languages,
9883@value{GDBN} also provides a pseudo-language, called @code{minimal}.
9884It does not represent a real programming language, but provides a set
9885of capabilities close to what the C or assembly languages provide.
9886This should allow most simple operations to be performed while debugging
9887an application that uses a language currently not supported by @value{GDBN}.
9888
9889If the language is set to @code{auto}, @value{GDBN} will automatically
9890select this language if the current frame corresponds to an unsupported
9891language.
9892
6d2ebf8b 9893@node Symbols
c906108c
SS
9894@chapter Examining the Symbol Table
9895
d4f3574e 9896The commands described in this chapter allow you to inquire about the
c906108c
SS
9897symbols (names of variables, functions and types) defined in your
9898program. This information is inherent in the text of your program and
9899does not change as your program executes. @value{GDBN} finds it in your
9900program's symbol table, in the file indicated when you started @value{GDBN}
9901(@pxref{File Options, ,Choosing files}), or by one of the
9902file-management commands (@pxref{Files, ,Commands to specify files}).
9903
9904@cindex symbol names
9905@cindex names of symbols
9906@cindex quoting names
9907Occasionally, you may need to refer to symbols that contain unusual
9908characters, which @value{GDBN} ordinarily treats as word delimiters. The
9909most frequent case is in referring to static variables in other
9910source files (@pxref{Variables,,Program variables}). File names
9911are recorded in object files as debugging symbols, but @value{GDBN} would
9912ordinarily parse a typical file name, like @file{foo.c}, as the three words
9913@samp{foo} @samp{.} @samp{c}. To allow @value{GDBN} to recognize
9914@samp{foo.c} as a single symbol, enclose it in single quotes; for example,
9915
474c8240 9916@smallexample
c906108c 9917p 'foo.c'::x
474c8240 9918@end smallexample
c906108c
SS
9919
9920@noindent
9921looks up the value of @code{x} in the scope of the file @file{foo.c}.
9922
9923@table @code
a8f24a35
EZ
9924@cindex case-insensitive symbol names
9925@cindex case sensitivity in symbol names
9926@kindex set case-sensitive
9927@item set case-sensitive on
9928@itemx set case-sensitive off
9929@itemx set case-sensitive auto
9930Normally, when @value{GDBN} looks up symbols, it matches their names
9931with case sensitivity determined by the current source language.
9932Occasionally, you may wish to control that. The command @code{set
9933case-sensitive} lets you do that by specifying @code{on} for
9934case-sensitive matches or @code{off} for case-insensitive ones. If
9935you specify @code{auto}, case sensitivity is reset to the default
9936suitable for the source language. The default is case-sensitive
9937matches for all languages except for Fortran, for which the default is
9938case-insensitive matches.
9939
9c16f35a
EZ
9940@kindex show case-sensitive
9941@item show case-sensitive
a8f24a35
EZ
9942This command shows the current setting of case sensitivity for symbols
9943lookups.
9944
c906108c 9945@kindex info address
b37052ae 9946@cindex address of a symbol
c906108c
SS
9947@item info address @var{symbol}
9948Describe where the data for @var{symbol} is stored. For a register
9949variable, this says which register it is kept in. For a non-register
9950local variable, this prints the stack-frame offset at which the variable
9951is always stored.
9952
9953Note the contrast with @samp{print &@var{symbol}}, which does not work
9954at all for a register variable, and for a stack local variable prints
9955the exact address of the current instantiation of the variable.
9956
3d67e040 9957@kindex info symbol
b37052ae 9958@cindex symbol from address
9c16f35a 9959@cindex closest symbol and offset for an address
3d67e040
EZ
9960@item info symbol @var{addr}
9961Print the name of a symbol which is stored at the address @var{addr}.
9962If no symbol is stored exactly at @var{addr}, @value{GDBN} prints the
9963nearest symbol and an offset from it:
9964
474c8240 9965@smallexample
3d67e040
EZ
9966(@value{GDBP}) info symbol 0x54320
9967_initialize_vx + 396 in section .text
474c8240 9968@end smallexample
3d67e040
EZ
9969
9970@noindent
9971This is the opposite of the @code{info address} command. You can use
9972it to find out the name of a variable or a function given its address.
9973
c906108c 9974@kindex whatis
d4f3574e
SS
9975@item whatis @var{expr}
9976Print the data type of expression @var{expr}. @var{expr} is not
c906108c
SS
9977actually evaluated, and any side-effecting operations (such as
9978assignments or function calls) inside it do not take place.
9979@xref{Expressions, ,Expressions}.
9980
9981@item whatis
9982Print the data type of @code{$}, the last value in the value history.
9983
9984@kindex ptype
9985@item ptype @var{typename}
9986Print a description of data type @var{typename}. @var{typename} may be
7a292a7a
SS
9987the name of a type, or for C code it may have the form @samp{class
9988@var{class-name}}, @samp{struct @var{struct-tag}}, @samp{union
9989@var{union-tag}} or @samp{enum @var{enum-tag}}.
c906108c 9990
d4f3574e 9991@item ptype @var{expr}
c906108c 9992@itemx ptype
d4f3574e 9993Print a description of the type of expression @var{expr}. @code{ptype}
c906108c
SS
9994differs from @code{whatis} by printing a detailed description, instead
9995of just the name of the type.
9996
9997For example, for this variable declaration:
9998
474c8240 9999@smallexample
c906108c 10000struct complex @{double real; double imag;@} v;
474c8240 10001@end smallexample
c906108c
SS
10002
10003@noindent
10004the two commands give this output:
10005
474c8240 10006@smallexample
c906108c
SS
10007@group
10008(@value{GDBP}) whatis v
10009type = struct complex
10010(@value{GDBP}) ptype v
10011type = struct complex @{
10012 double real;
10013 double imag;
10014@}
10015@end group
474c8240 10016@end smallexample
c906108c
SS
10017
10018@noindent
10019As with @code{whatis}, using @code{ptype} without an argument refers to
10020the type of @code{$}, the last value in the value history.
10021
10022@kindex info types
10023@item info types @var{regexp}
10024@itemx info types
09d4efe1
EZ
10025Print a brief description of all types whose names match the regular
10026expression @var{regexp} (or all types in your program, if you supply
10027no argument). Each complete typename is matched as though it were a
10028complete line; thus, @samp{i type value} gives information on all
10029types in your program whose names include the string @code{value}, but
10030@samp{i type ^value$} gives information only on types whose complete
10031name is @code{value}.
c906108c
SS
10032
10033This command differs from @code{ptype} in two ways: first, like
10034@code{whatis}, it does not print a detailed description; second, it
10035lists all source files where a type is defined.
10036
b37052ae
EZ
10037@kindex info scope
10038@cindex local variables
09d4efe1 10039@item info scope @var{location}
b37052ae 10040List all the variables local to a particular scope. This command
09d4efe1
EZ
10041accepts a @var{location} argument---a function name, a source line, or
10042an address preceded by a @samp{*}, and prints all the variables local
10043to the scope defined by that location. For example:
b37052ae
EZ
10044
10045@smallexample
10046(@value{GDBP}) @b{info scope command_line_handler}
10047Scope for command_line_handler:
10048Symbol rl is an argument at stack/frame offset 8, length 4.
10049Symbol linebuffer is in static storage at address 0x150a18, length 4.
10050Symbol linelength is in static storage at address 0x150a1c, length 4.
10051Symbol p is a local variable in register $esi, length 4.
10052Symbol p1 is a local variable in register $ebx, length 4.
10053Symbol nline is a local variable in register $edx, length 4.
10054Symbol repeat is a local variable at frame offset -8, length 4.
10055@end smallexample
10056
f5c37c66
EZ
10057@noindent
10058This command is especially useful for determining what data to collect
10059during a @dfn{trace experiment}, see @ref{Tracepoint Actions,
10060collect}.
10061
c906108c
SS
10062@kindex info source
10063@item info source
919d772c
JB
10064Show information about the current source file---that is, the source file for
10065the function containing the current point of execution:
10066@itemize @bullet
10067@item
10068the name of the source file, and the directory containing it,
10069@item
10070the directory it was compiled in,
10071@item
10072its length, in lines,
10073@item
10074which programming language it is written in,
10075@item
10076whether the executable includes debugging information for that file, and
10077if so, what format the information is in (e.g., STABS, Dwarf 2, etc.), and
10078@item
10079whether the debugging information includes information about
10080preprocessor macros.
10081@end itemize
10082
c906108c
SS
10083
10084@kindex info sources
10085@item info sources
10086Print the names of all source files in your program for which there is
10087debugging information, organized into two lists: files whose symbols
10088have already been read, and files whose symbols will be read when needed.
10089
10090@kindex info functions
10091@item info functions
10092Print the names and data types of all defined functions.
10093
10094@item info functions @var{regexp}
10095Print the names and data types of all defined functions
10096whose names contain a match for regular expression @var{regexp}.
10097Thus, @samp{info fun step} finds all functions whose names
10098include @code{step}; @samp{info fun ^step} finds those whose names
b383017d
RM
10099start with @code{step}. If a function name contains characters
10100that conflict with the regular expression language (eg.
1c5dfdad 10101@samp{operator*()}), they may be quoted with a backslash.
c906108c
SS
10102
10103@kindex info variables
10104@item info variables
10105Print the names and data types of all variables that are declared
6ca652b0 10106outside of functions (i.e.@: excluding local variables).
c906108c
SS
10107
10108@item info variables @var{regexp}
10109Print the names and data types of all variables (except for local
10110variables) whose names contain a match for regular expression
10111@var{regexp}.
10112
b37303ee 10113@kindex info classes
721c2651 10114@cindex Objective-C, classes and selectors
b37303ee
AF
10115@item info classes
10116@itemx info classes @var{regexp}
10117Display all Objective-C classes in your program, or
10118(with the @var{regexp} argument) all those matching a particular regular
10119expression.
10120
10121@kindex info selectors
10122@item info selectors
10123@itemx info selectors @var{regexp}
10124Display all Objective-C selectors in your program, or
10125(with the @var{regexp} argument) all those matching a particular regular
10126expression.
10127
c906108c
SS
10128@ignore
10129This was never implemented.
10130@kindex info methods
10131@item info methods
10132@itemx info methods @var{regexp}
10133The @code{info methods} command permits the user to examine all defined
b37052ae
EZ
10134methods within C@t{++} program, or (with the @var{regexp} argument) a
10135specific set of methods found in the various C@t{++} classes. Many
10136C@t{++} classes provide a large number of methods. Thus, the output
c906108c
SS
10137from the @code{ptype} command can be overwhelming and hard to use. The
10138@code{info-methods} command filters the methods, printing only those
10139which match the regular-expression @var{regexp}.
10140@end ignore
10141
c906108c
SS
10142@cindex reloading symbols
10143Some systems allow individual object files that make up your program to
7a292a7a
SS
10144be replaced without stopping and restarting your program. For example,
10145in VxWorks you can simply recompile a defective object file and keep on
10146running. If you are running on one of these systems, you can allow
10147@value{GDBN} to reload the symbols for automatically relinked modules:
c906108c
SS
10148
10149@table @code
10150@kindex set symbol-reloading
10151@item set symbol-reloading on
10152Replace symbol definitions for the corresponding source file when an
10153object file with a particular name is seen again.
10154
10155@item set symbol-reloading off
6d2ebf8b
SS
10156Do not replace symbol definitions when encountering object files of the
10157same name more than once. This is the default state; if you are not
10158running on a system that permits automatic relinking of modules, you
10159should leave @code{symbol-reloading} off, since otherwise @value{GDBN}
10160may discard symbols when linking large programs, that may contain
10161several modules (from different directories or libraries) with the same
10162name.
c906108c
SS
10163
10164@kindex show symbol-reloading
10165@item show symbol-reloading
10166Show the current @code{on} or @code{off} setting.
10167@end table
c906108c 10168
9c16f35a 10169@cindex opaque data types
c906108c
SS
10170@kindex set opaque-type-resolution
10171@item set opaque-type-resolution on
10172Tell @value{GDBN} to resolve opaque types. An opaque type is a type
10173declared as a pointer to a @code{struct}, @code{class}, or
10174@code{union}---for example, @code{struct MyType *}---that is used in one
10175source file although the full declaration of @code{struct MyType} is in
10176another source file. The default is on.
10177
10178A change in the setting of this subcommand will not take effect until
10179the next time symbols for a file are loaded.
10180
10181@item set opaque-type-resolution off
10182Tell @value{GDBN} not to resolve opaque types. In this case, the type
10183is printed as follows:
10184@smallexample
10185@{<no data fields>@}
10186@end smallexample
10187
10188@kindex show opaque-type-resolution
10189@item show opaque-type-resolution
10190Show whether opaque types are resolved or not.
c906108c
SS
10191
10192@kindex maint print symbols
10193@cindex symbol dump
10194@kindex maint print psymbols
10195@cindex partial symbol dump
10196@item maint print symbols @var{filename}
10197@itemx maint print psymbols @var{filename}
10198@itemx maint print msymbols @var{filename}
10199Write a dump of debugging symbol data into the file @var{filename}.
10200These commands are used to debug the @value{GDBN} symbol-reading code. Only
10201symbols with debugging data are included. If you use @samp{maint print
10202symbols}, @value{GDBN} includes all the symbols for which it has already
10203collected full details: that is, @var{filename} reflects symbols for
10204only those files whose symbols @value{GDBN} has read. You can use the
10205command @code{info sources} to find out which files these are. If you
10206use @samp{maint print psymbols} instead, the dump shows information about
10207symbols that @value{GDBN} only knows partially---that is, symbols defined in
10208files that @value{GDBN} has skimmed, but not yet read completely. Finally,
10209@samp{maint print msymbols} dumps just the minimal symbol information
10210required for each object file from which @value{GDBN} has read some symbols.
10211@xref{Files, ,Commands to specify files}, for a discussion of how
10212@value{GDBN} reads symbols (in the description of @code{symbol-file}).
44ea7b70 10213
5e7b2f39
JB
10214@kindex maint info symtabs
10215@kindex maint info psymtabs
44ea7b70
JB
10216@cindex listing @value{GDBN}'s internal symbol tables
10217@cindex symbol tables, listing @value{GDBN}'s internal
10218@cindex full symbol tables, listing @value{GDBN}'s internal
10219@cindex partial symbol tables, listing @value{GDBN}'s internal
5e7b2f39
JB
10220@item maint info symtabs @r{[} @var{regexp} @r{]}
10221@itemx maint info psymtabs @r{[} @var{regexp} @r{]}
44ea7b70
JB
10222
10223List the @code{struct symtab} or @code{struct partial_symtab}
10224structures whose names match @var{regexp}. If @var{regexp} is not
10225given, list them all. The output includes expressions which you can
10226copy into a @value{GDBN} debugging this one to examine a particular
10227structure in more detail. For example:
10228
10229@smallexample
5e7b2f39 10230(@value{GDBP}) maint info psymtabs dwarf2read
44ea7b70
JB
10231@{ objfile /home/gnu/build/gdb/gdb
10232 ((struct objfile *) 0x82e69d0)
b383017d 10233 @{ psymtab /home/gnu/src/gdb/dwarf2read.c
44ea7b70
JB
10234 ((struct partial_symtab *) 0x8474b10)
10235 readin no
10236 fullname (null)
10237 text addresses 0x814d3c8 -- 0x8158074
10238 globals (* (struct partial_symbol **) 0x8507a08 @@ 9)
10239 statics (* (struct partial_symbol **) 0x40e95b78 @@ 2882)
10240 dependencies (none)
10241 @}
10242@}
5e7b2f39 10243(@value{GDBP}) maint info symtabs
44ea7b70
JB
10244(@value{GDBP})
10245@end smallexample
10246@noindent
10247We see that there is one partial symbol table whose filename contains
10248the string @samp{dwarf2read}, belonging to the @samp{gdb} executable;
10249and we see that @value{GDBN} has not read in any symtabs yet at all.
10250If we set a breakpoint on a function, that will cause @value{GDBN} to
10251read the symtab for the compilation unit containing that function:
10252
10253@smallexample
10254(@value{GDBP}) break dwarf2_psymtab_to_symtab
10255Breakpoint 1 at 0x814e5da: file /home/gnu/src/gdb/dwarf2read.c,
10256line 1574.
5e7b2f39 10257(@value{GDBP}) maint info symtabs
b383017d 10258@{ objfile /home/gnu/build/gdb/gdb
44ea7b70 10259 ((struct objfile *) 0x82e69d0)
b383017d 10260 @{ symtab /home/gnu/src/gdb/dwarf2read.c
44ea7b70
JB
10261 ((struct symtab *) 0x86c1f38)
10262 dirname (null)
10263 fullname (null)
10264 blockvector ((struct blockvector *) 0x86c1bd0) (primary)
10265 debugformat DWARF 2
10266 @}
10267@}
b383017d 10268(@value{GDBP})
44ea7b70 10269@end smallexample
c906108c
SS
10270@end table
10271
44ea7b70 10272
6d2ebf8b 10273@node Altering
c906108c
SS
10274@chapter Altering Execution
10275
10276Once you think you have found an error in your program, you might want to
10277find out for certain whether correcting the apparent error would lead to
10278correct results in the rest of the run. You can find the answer by
10279experiment, using the @value{GDBN} features for altering execution of the
10280program.
10281
10282For example, you can store new values into variables or memory
7a292a7a
SS
10283locations, give your program a signal, restart it at a different
10284address, or even return prematurely from a function.
c906108c
SS
10285
10286@menu
10287* Assignment:: Assignment to variables
10288* Jumping:: Continuing at a different address
c906108c 10289* Signaling:: Giving your program a signal
c906108c
SS
10290* Returning:: Returning from a function
10291* Calling:: Calling your program's functions
10292* Patching:: Patching your program
10293@end menu
10294
6d2ebf8b 10295@node Assignment
c906108c
SS
10296@section Assignment to variables
10297
10298@cindex assignment
10299@cindex setting variables
10300To alter the value of a variable, evaluate an assignment expression.
10301@xref{Expressions, ,Expressions}. For example,
10302
474c8240 10303@smallexample
c906108c 10304print x=4
474c8240 10305@end smallexample
c906108c
SS
10306
10307@noindent
10308stores the value 4 into the variable @code{x}, and then prints the
5d161b24 10309value of the assignment expression (which is 4).
c906108c
SS
10310@xref{Languages, ,Using @value{GDBN} with Different Languages}, for more
10311information on operators in supported languages.
c906108c
SS
10312
10313@kindex set variable
10314@cindex variables, setting
10315If you are not interested in seeing the value of the assignment, use the
10316@code{set} command instead of the @code{print} command. @code{set} is
10317really the same as @code{print} except that the expression's value is
10318not printed and is not put in the value history (@pxref{Value History,
10319,Value history}). The expression is evaluated only for its effects.
10320
c906108c
SS
10321If the beginning of the argument string of the @code{set} command
10322appears identical to a @code{set} subcommand, use the @code{set
10323variable} command instead of just @code{set}. This command is identical
10324to @code{set} except for its lack of subcommands. For example, if your
10325program has a variable @code{width}, you get an error if you try to set
10326a new value with just @samp{set width=13}, because @value{GDBN} has the
10327command @code{set width}:
10328
474c8240 10329@smallexample
c906108c
SS
10330(@value{GDBP}) whatis width
10331type = double
10332(@value{GDBP}) p width
10333$4 = 13
10334(@value{GDBP}) set width=47
10335Invalid syntax in expression.
474c8240 10336@end smallexample
c906108c
SS
10337
10338@noindent
10339The invalid expression, of course, is @samp{=47}. In
10340order to actually set the program's variable @code{width}, use
10341
474c8240 10342@smallexample
c906108c 10343(@value{GDBP}) set var width=47
474c8240 10344@end smallexample
53a5351d 10345
c906108c
SS
10346Because the @code{set} command has many subcommands that can conflict
10347with the names of program variables, it is a good idea to use the
10348@code{set variable} command instead of just @code{set}. For example, if
10349your program has a variable @code{g}, you run into problems if you try
10350to set a new value with just @samp{set g=4}, because @value{GDBN} has
10351the command @code{set gnutarget}, abbreviated @code{set g}:
10352
474c8240 10353@smallexample
c906108c
SS
10354@group
10355(@value{GDBP}) whatis g
10356type = double
10357(@value{GDBP}) p g
10358$1 = 1
10359(@value{GDBP}) set g=4
2df3850c 10360(@value{GDBP}) p g
c906108c
SS
10361$2 = 1
10362(@value{GDBP}) r
10363The program being debugged has been started already.
10364Start it from the beginning? (y or n) y
10365Starting program: /home/smith/cc_progs/a.out
6d2ebf8b
SS
10366"/home/smith/cc_progs/a.out": can't open to read symbols:
10367 Invalid bfd target.
c906108c
SS
10368(@value{GDBP}) show g
10369The current BFD target is "=4".
10370@end group
474c8240 10371@end smallexample
c906108c
SS
10372
10373@noindent
10374The program variable @code{g} did not change, and you silently set the
10375@code{gnutarget} to an invalid value. In order to set the variable
10376@code{g}, use
10377
474c8240 10378@smallexample
c906108c 10379(@value{GDBP}) set var g=4
474c8240 10380@end smallexample
c906108c
SS
10381
10382@value{GDBN} allows more implicit conversions in assignments than C; you can
10383freely store an integer value into a pointer variable or vice versa,
10384and you can convert any structure to any other structure that is the
10385same length or shorter.
10386@comment FIXME: how do structs align/pad in these conversions?
10387@comment /doc@cygnus.com 18dec1990
10388
10389To store values into arbitrary places in memory, use the @samp{@{@dots{}@}}
10390construct to generate a value of specified type at a specified address
10391(@pxref{Expressions, ,Expressions}). For example, @code{@{int@}0x83040} refers
10392to memory location @code{0x83040} as an integer (which implies a certain size
10393and representation in memory), and
10394
474c8240 10395@smallexample
c906108c 10396set @{int@}0x83040 = 4
474c8240 10397@end smallexample
c906108c
SS
10398
10399@noindent
10400stores the value 4 into that memory location.
10401
6d2ebf8b 10402@node Jumping
c906108c
SS
10403@section Continuing at a different address
10404
10405Ordinarily, when you continue your program, you do so at the place where
10406it stopped, with the @code{continue} command. You can instead continue at
10407an address of your own choosing, with the following commands:
10408
10409@table @code
10410@kindex jump
10411@item jump @var{linespec}
10412Resume execution at line @var{linespec}. Execution stops again
10413immediately if there is a breakpoint there. @xref{List, ,Printing
10414source lines}, for a description of the different forms of
10415@var{linespec}. It is common practice to use the @code{tbreak} command
10416in conjunction with @code{jump}. @xref{Set Breaks, ,Setting
10417breakpoints}.
10418
10419The @code{jump} command does not change the current stack frame, or
10420the stack pointer, or the contents of any memory location or any
10421register other than the program counter. If line @var{linespec} is in
10422a different function from the one currently executing, the results may
10423be bizarre if the two functions expect different patterns of arguments or
10424of local variables. For this reason, the @code{jump} command requests
10425confirmation if the specified line is not in the function currently
10426executing. However, even bizarre results are predictable if you are
10427well acquainted with the machine-language code of your program.
10428
10429@item jump *@var{address}
10430Resume execution at the instruction at address @var{address}.
10431@end table
10432
c906108c 10433@c Doesn't work on HP-UX; have to set $pcoqh and $pcoqt.
53a5351d
JM
10434On many systems, you can get much the same effect as the @code{jump}
10435command by storing a new value into the register @code{$pc}. The
10436difference is that this does not start your program running; it only
10437changes the address of where it @emph{will} run when you continue. For
10438example,
c906108c 10439
474c8240 10440@smallexample
c906108c 10441set $pc = 0x485
474c8240 10442@end smallexample
c906108c
SS
10443
10444@noindent
10445makes the next @code{continue} command or stepping command execute at
10446address @code{0x485}, rather than at the address where your program stopped.
10447@xref{Continuing and Stepping, ,Continuing and stepping}.
c906108c
SS
10448
10449The most common occasion to use the @code{jump} command is to back
10450up---perhaps with more breakpoints set---over a portion of a program
10451that has already executed, in order to examine its execution in more
10452detail.
10453
c906108c 10454@c @group
6d2ebf8b 10455@node Signaling
c906108c 10456@section Giving your program a signal
9c16f35a 10457@cindex deliver a signal to a program
c906108c
SS
10458
10459@table @code
10460@kindex signal
10461@item signal @var{signal}
10462Resume execution where your program stopped, but immediately give it the
10463signal @var{signal}. @var{signal} can be the name or the number of a
10464signal. For example, on many systems @code{signal 2} and @code{signal
10465SIGINT} are both ways of sending an interrupt signal.
10466
10467Alternatively, if @var{signal} is zero, continue execution without
10468giving a signal. This is useful when your program stopped on account of
10469a signal and would ordinary see the signal when resumed with the
10470@code{continue} command; @samp{signal 0} causes it to resume without a
10471signal.
10472
10473@code{signal} does not repeat when you press @key{RET} a second time
10474after executing the command.
10475@end table
10476@c @end group
10477
10478Invoking the @code{signal} command is not the same as invoking the
10479@code{kill} utility from the shell. Sending a signal with @code{kill}
10480causes @value{GDBN} to decide what to do with the signal depending on
10481the signal handling tables (@pxref{Signals}). The @code{signal} command
10482passes the signal directly to your program.
10483
c906108c 10484
6d2ebf8b 10485@node Returning
c906108c
SS
10486@section Returning from a function
10487
10488@table @code
10489@cindex returning from a function
10490@kindex return
10491@item return
10492@itemx return @var{expression}
10493You can cancel execution of a function call with the @code{return}
10494command. If you give an
10495@var{expression} argument, its value is used as the function's return
10496value.
10497@end table
10498
10499When you use @code{return}, @value{GDBN} discards the selected stack frame
10500(and all frames within it). You can think of this as making the
10501discarded frame return prematurely. If you wish to specify a value to
10502be returned, give that value as the argument to @code{return}.
10503
10504This pops the selected stack frame (@pxref{Selection, ,Selecting a
10505frame}), and any other frames inside of it, leaving its caller as the
10506innermost remaining frame. That frame becomes selected. The
10507specified value is stored in the registers used for returning values
10508of functions.
10509
10510The @code{return} command does not resume execution; it leaves the
10511program stopped in the state that would exist if the function had just
10512returned. In contrast, the @code{finish} command (@pxref{Continuing
10513and Stepping, ,Continuing and stepping}) resumes execution until the
10514selected stack frame returns naturally.
10515
6d2ebf8b 10516@node Calling
c906108c
SS
10517@section Calling program functions
10518
f8568604 10519@table @code
c906108c 10520@cindex calling functions
f8568604
EZ
10521@cindex inferior functions, calling
10522@item print @var{expr}
9c16f35a 10523Evaluate the expression @var{expr} and display the resuling value.
f8568604
EZ
10524@var{expr} may include calls to functions in the program being
10525debugged.
10526
c906108c 10527@kindex call
c906108c
SS
10528@item call @var{expr}
10529Evaluate the expression @var{expr} without displaying @code{void}
10530returned values.
c906108c
SS
10531
10532You can use this variant of the @code{print} command if you want to
f8568604
EZ
10533execute a function from your program that does not return anything
10534(a.k.a.@: @dfn{a void function}), but without cluttering the output
10535with @code{void} returned values that @value{GDBN} will otherwise
10536print. If the result is not void, it is printed and saved in the
10537value history.
10538@end table
10539
9c16f35a
EZ
10540It is possible for the function you call via the @code{print} or
10541@code{call} command to generate a signal (e.g., if there's a bug in
10542the function, or if you passed it incorrect arguments). What happens
10543in that case is controlled by the @code{set unwindonsignal} command.
10544
10545@table @code
10546@item set unwindonsignal
10547@kindex set unwindonsignal
10548@cindex unwind stack in called functions
10549@cindex call dummy stack unwinding
10550Set unwinding of the stack if a signal is received while in a function
10551that @value{GDBN} called in the program being debugged. If set to on,
10552@value{GDBN} unwinds the stack it created for the call and restores
10553the context to what it was before the call. If set to off (the
10554default), @value{GDBN} stops in the frame where the signal was
10555received.
10556
10557@item show unwindonsignal
10558@kindex show unwindonsignal
10559Show the current setting of stack unwinding in the functions called by
10560@value{GDBN}.
10561@end table
10562
f8568604
EZ
10563@cindex weak alias functions
10564Sometimes, a function you wish to call is actually a @dfn{weak alias}
10565for another function. In such case, @value{GDBN} might not pick up
10566the type information, including the types of the function arguments,
10567which causes @value{GDBN} to call the inferior function incorrectly.
10568As a result, the called function will function erroneously and may
10569even crash. A solution to that is to use the name of the aliased
10570function instead.
c906108c 10571
6d2ebf8b 10572@node Patching
c906108c 10573@section Patching programs
7a292a7a 10574
c906108c
SS
10575@cindex patching binaries
10576@cindex writing into executables
c906108c 10577@cindex writing into corefiles
c906108c 10578
7a292a7a
SS
10579By default, @value{GDBN} opens the file containing your program's
10580executable code (or the corefile) read-only. This prevents accidental
10581alterations to machine code; but it also prevents you from intentionally
10582patching your program's binary.
c906108c
SS
10583
10584If you'd like to be able to patch the binary, you can specify that
10585explicitly with the @code{set write} command. For example, you might
10586want to turn on internal debugging flags, or even to make emergency
10587repairs.
10588
10589@table @code
10590@kindex set write
10591@item set write on
10592@itemx set write off
7a292a7a
SS
10593If you specify @samp{set write on}, @value{GDBN} opens executable and
10594core files for both reading and writing; if you specify @samp{set write
c906108c
SS
10595off} (the default), @value{GDBN} opens them read-only.
10596
10597If you have already loaded a file, you must load it again (using the
7a292a7a
SS
10598@code{exec-file} or @code{core-file} command) after changing @code{set
10599write}, for your new setting to take effect.
c906108c
SS
10600
10601@item show write
10602@kindex show write
7a292a7a
SS
10603Display whether executable files and core files are opened for writing
10604as well as reading.
c906108c
SS
10605@end table
10606
6d2ebf8b 10607@node GDB Files
c906108c
SS
10608@chapter @value{GDBN} Files
10609
7a292a7a
SS
10610@value{GDBN} needs to know the file name of the program to be debugged,
10611both in order to read its symbol table and in order to start your
10612program. To debug a core dump of a previous run, you must also tell
10613@value{GDBN} the name of the core dump file.
c906108c
SS
10614
10615@menu
10616* Files:: Commands to specify files
5b5d99cf 10617* Separate Debug Files:: Debugging information in separate files
c906108c
SS
10618* Symbol Errors:: Errors reading symbol files
10619@end menu
10620
6d2ebf8b 10621@node Files
c906108c 10622@section Commands to specify files
c906108c 10623
7a292a7a 10624@cindex symbol table
c906108c 10625@cindex core dump file
7a292a7a
SS
10626
10627You may want to specify executable and core dump file names. The usual
10628way to do this is at start-up time, using the arguments to
10629@value{GDBN}'s start-up commands (@pxref{Invocation, , Getting In and
10630Out of @value{GDBN}}).
c906108c
SS
10631
10632Occasionally it is necessary to change to a different file during a
397ca115
EZ
10633@value{GDBN} session. Or you may run @value{GDBN} and forget to
10634specify a file you want to use. Or you are debugging a remote target
10635via @code{gdbserver} (@pxref{Server, file}). In these situations the
10636@value{GDBN} commands to specify new files are useful.
c906108c
SS
10637
10638@table @code
10639@cindex executable file
10640@kindex file
10641@item file @var{filename}
10642Use @var{filename} as the program to be debugged. It is read for its
10643symbols and for the contents of pure memory. It is also the program
10644executed when you use the @code{run} command. If you do not specify a
5d161b24
DB
10645directory and the file is not found in the @value{GDBN} working directory,
10646@value{GDBN} uses the environment variable @code{PATH} as a list of
10647directories to search, just as the shell does when looking for a program
10648to run. You can change the value of this variable, for both @value{GDBN}
c906108c
SS
10649and your program, using the @code{path} command.
10650
6d2ebf8b 10651On systems with memory-mapped files, an auxiliary file named
c906108c
SS
10652@file{@var{filename}.syms} may hold symbol table information for
10653@var{filename}. If so, @value{GDBN} maps in the symbol table from
10654@file{@var{filename}.syms}, starting up more quickly. See the
10655descriptions of the file options @samp{-mapped} and @samp{-readnow}
7b5ba0cc
EZ
10656(available on the command line, see @ref{File Options, , -readnow},
10657and with the commands @code{file}, @code{symbol-file}, or
10658@code{add-symbol-file}, described below), for more information.
c906108c 10659
fc8be69e
EZ
10660@cindex unlinked object files
10661@cindex patching object files
10662You can load unlinked object @file{.o} files into @value{GDBN} using
10663the @code{file} command. You will not be able to ``run'' an object
10664file, but you can disassemble functions and inspect variables. Also,
10665if the underlying BFD functionality supports it, you could use
10666@kbd{gdb -write} to patch object files using this technique. Note
10667that @value{GDBN} can neither interpret nor modify relocations in this
10668case, so branches and some initialized variables will appear to go to
10669the wrong place. But this feature is still handy from time to time.
10670
c906108c
SS
10671@item file
10672@code{file} with no argument makes @value{GDBN} discard any information it
10673has on both executable file and the symbol table.
10674
10675@kindex exec-file
10676@item exec-file @r{[} @var{filename} @r{]}
10677Specify that the program to be run (but not the symbol table) is found
10678in @var{filename}. @value{GDBN} searches the environment variable @code{PATH}
10679if necessary to locate your program. Omitting @var{filename} means to
10680discard information on the executable file.
10681
10682@kindex symbol-file
10683@item symbol-file @r{[} @var{filename} @r{]}
10684Read symbol table information from file @var{filename}. @code{PATH} is
10685searched when necessary. Use the @code{file} command to get both symbol
10686table and program to run from the same file.
10687
10688@code{symbol-file} with no argument clears out @value{GDBN} information on your
10689program's symbol table.
10690
5d161b24 10691The @code{symbol-file} command causes @value{GDBN} to forget the contents
c906108c
SS
10692of its convenience variables, the value history, and all breakpoints and
10693auto-display expressions. This is because they may contain pointers to
10694the internal data recording symbols and data types, which are part of
10695the old symbol table data being discarded inside @value{GDBN}.
10696
10697@code{symbol-file} does not repeat if you press @key{RET} again after
10698executing it once.
10699
10700When @value{GDBN} is configured for a particular environment, it
10701understands debugging information in whatever format is the standard
10702generated for that environment; you may use either a @sc{gnu} compiler, or
10703other compilers that adhere to the local conventions.
c906108c
SS
10704Best results are usually obtained from @sc{gnu} compilers; for example,
10705using @code{@value{GCC}} you can generate debugging information for
10706optimized code.
c906108c
SS
10707
10708For most kinds of object files, with the exception of old SVR3 systems
10709using COFF, the @code{symbol-file} command does not normally read the
10710symbol table in full right away. Instead, it scans the symbol table
10711quickly to find which source files and which symbols are present. The
10712details are read later, one source file at a time, as they are needed.
10713
10714The purpose of this two-stage reading strategy is to make @value{GDBN}
10715start up faster. For the most part, it is invisible except for
10716occasional pauses while the symbol table details for a particular source
10717file are being read. (The @code{set verbose} command can turn these
10718pauses into messages if desired. @xref{Messages/Warnings, ,Optional
10719warnings and messages}.)
10720
c906108c
SS
10721We have not implemented the two-stage strategy for COFF yet. When the
10722symbol table is stored in COFF format, @code{symbol-file} reads the
10723symbol table data in full right away. Note that ``stabs-in-COFF''
10724still does the two-stage strategy, since the debug info is actually
10725in stabs format.
10726
10727@kindex readnow
10728@cindex reading symbols immediately
10729@cindex symbols, reading immediately
10730@kindex mapped
10731@cindex memory-mapped symbol file
10732@cindex saving symbol table
10733@item symbol-file @var{filename} @r{[} -readnow @r{]} @r{[} -mapped @r{]}
10734@itemx file @var{filename} @r{[} -readnow @r{]} @r{[} -mapped @r{]}
10735You can override the @value{GDBN} two-stage strategy for reading symbol
10736tables by using the @samp{-readnow} option with any of the commands that
10737load symbol table information, if you want to be sure @value{GDBN} has the
5d161b24 10738entire symbol table available.
c906108c 10739
c906108c
SS
10740If memory-mapped files are available on your system through the
10741@code{mmap} system call, you can use another option, @samp{-mapped}, to
10742cause @value{GDBN} to write the symbols for your program into a reusable
10743file. Future @value{GDBN} debugging sessions map in symbol information
10744from this auxiliary symbol file (if the program has not changed), rather
10745than spending time reading the symbol table from the executable
10746program. Using the @samp{-mapped} option has the same effect as
10747starting @value{GDBN} with the @samp{-mapped} command-line option.
10748
10749You can use both options together, to make sure the auxiliary symbol
10750file has all the symbol information for your program.
10751
10752The auxiliary symbol file for a program called @var{myprog} is called
10753@samp{@var{myprog}.syms}. Once this file exists (so long as it is newer
10754than the corresponding executable), @value{GDBN} always attempts to use
10755it when you debug @var{myprog}; no special options or commands are
10756needed.
10757
10758The @file{.syms} file is specific to the host machine where you run
10759@value{GDBN}. It holds an exact image of the internal @value{GDBN}
10760symbol table. It cannot be shared across multiple host platforms.
c906108c
SS
10761
10762@c FIXME: for now no mention of directories, since this seems to be in
10763@c flux. 13mar1992 status is that in theory GDB would look either in
10764@c current dir or in same dir as myprog; but issues like competing
10765@c GDB's, or clutter in system dirs, mean that in practice right now
10766@c only current dir is used. FFish says maybe a special GDB hierarchy
10767@c (eg rooted in val of env var GDBSYMS) could exist for mappable symbol
10768@c files.
10769
c906108c 10770@kindex core-file
09d4efe1 10771@item core-file @r{[}@var{filename}@r{]}
4644b6e3 10772@itemx core
c906108c
SS
10773Specify the whereabouts of a core dump file to be used as the ``contents
10774of memory''. Traditionally, core files contain only some parts of the
10775address space of the process that generated them; @value{GDBN} can access the
10776executable file itself for other parts.
10777
10778@code{core-file} with no argument specifies that no core file is
10779to be used.
10780
10781Note that the core file is ignored when your program is actually running
7a292a7a
SS
10782under @value{GDBN}. So, if you have been running your program and you
10783wish to debug a core file instead, you must kill the subprocess in which
10784the program is running. To do this, use the @code{kill} command
c906108c 10785(@pxref{Kill Process, ,Killing the child process}).
c906108c 10786
c906108c
SS
10787@kindex add-symbol-file
10788@cindex dynamic linking
10789@item add-symbol-file @var{filename} @var{address}
10790@itemx add-symbol-file @var{filename} @var{address} @r{[} -readnow @r{]} @r{[} -mapped @r{]}
17d9d558 10791@itemx add-symbol-file @var{filename} @r{-s}@var{section} @var{address} @dots{}
96a2c332
SS
10792The @code{add-symbol-file} command reads additional symbol table
10793information from the file @var{filename}. You would use this command
10794when @var{filename} has been dynamically loaded (by some other means)
10795into the program that is running. @var{address} should be the memory
10796address at which the file has been loaded; @value{GDBN} cannot figure
d167840f
EZ
10797this out for itself. You can additionally specify an arbitrary number
10798of @samp{@r{-s}@var{section} @var{address}} pairs, to give an explicit
10799section name and base address for that section. You can specify any
10800@var{address} as an expression.
c906108c
SS
10801
10802The symbol table of the file @var{filename} is added to the symbol table
10803originally read with the @code{symbol-file} command. You can use the
96a2c332
SS
10804@code{add-symbol-file} command any number of times; the new symbol data
10805thus read keeps adding to the old. To discard all old symbol data
10806instead, use the @code{symbol-file} command without any arguments.
c906108c 10807
17d9d558
JB
10808@cindex relocatable object files, reading symbols from
10809@cindex object files, relocatable, reading symbols from
10810@cindex reading symbols from relocatable object files
10811@cindex symbols, reading from relocatable object files
10812@cindex @file{.o} files, reading symbols from
10813Although @var{filename} is typically a shared library file, an
10814executable file, or some other object file which has been fully
10815relocated for loading into a process, you can also load symbolic
10816information from relocatable @file{.o} files, as long as:
10817
10818@itemize @bullet
10819@item
10820the file's symbolic information refers only to linker symbols defined in
10821that file, not to symbols defined by other object files,
10822@item
10823every section the file's symbolic information refers to has actually
10824been loaded into the inferior, as it appears in the file, and
10825@item
10826you can determine the address at which every section was loaded, and
10827provide these to the @code{add-symbol-file} command.
10828@end itemize
10829
10830@noindent
10831Some embedded operating systems, like Sun Chorus and VxWorks, can load
10832relocatable files into an already running program; such systems
10833typically make the requirements above easy to meet. However, it's
10834important to recognize that many native systems use complex link
49efadf5 10835procedures (@code{.linkonce} section factoring and C@t{++} constructor table
17d9d558
JB
10836assembly, for example) that make the requirements difficult to meet. In
10837general, one cannot assume that using @code{add-symbol-file} to read a
10838relocatable object file's symbolic information will have the same effect
10839as linking the relocatable object file into the program in the normal
10840way.
10841
c906108c
SS
10842@code{add-symbol-file} does not repeat if you press @key{RET} after using it.
10843
10844You can use the @samp{-mapped} and @samp{-readnow} options just as with
10845the @code{symbol-file} command, to change how @value{GDBN} manages the symbol
10846table information for @var{filename}.
10847
c45da7e6
EZ
10848@kindex add-symbol-file-from-memory
10849@cindex @code{syscall DSO}
10850@cindex load symbols from memory
10851@item add-symbol-file-from-memory @var{address}
10852Load symbols from the given @var{address} in a dynamically loaded
10853object file whose image is mapped directly into the inferior's memory.
10854For example, the Linux kernel maps a @code{syscall DSO} into each
10855process's address space; this DSO provides kernel-specific code for
10856some system calls. The argument can be any expression whose
10857evaluation yields the address of the file's shared object file header.
10858For this command to work, you must have used @code{symbol-file} or
10859@code{exec-file} commands in advance.
10860
09d4efe1
EZ
10861@kindex add-shared-symbol-files
10862@kindex assf
10863@item add-shared-symbol-files @var{library-file}
10864@itemx assf @var{library-file}
10865The @code{add-shared-symbol-files} command can currently be used only
10866in the Cygwin build of @value{GDBN} on MS-Windows OS, where it is an
10867alias for the @code{dll-symbols} command (@pxref{Cygwin Native}).
10868@value{GDBN} automatically looks for shared libraries, however if
10869@value{GDBN} does not find yours, you can invoke
10870@code{add-shared-symbol-files}. It takes one argument: the shared
10871library's file name. @code{assf} is a shorthand alias for
10872@code{add-shared-symbol-files}.
c906108c 10873
c906108c 10874@kindex section
09d4efe1
EZ
10875@item section @var{section} @var{addr}
10876The @code{section} command changes the base address of the named
10877@var{section} of the exec file to @var{addr}. This can be used if the
10878exec file does not contain section addresses, (such as in the
10879@code{a.out} format), or when the addresses specified in the file
10880itself are wrong. Each section must be changed separately. The
10881@code{info files} command, described below, lists all the sections and
10882their addresses.
c906108c
SS
10883
10884@kindex info files
10885@kindex info target
10886@item info files
10887@itemx info target
7a292a7a
SS
10888@code{info files} and @code{info target} are synonymous; both print the
10889current target (@pxref{Targets, ,Specifying a Debugging Target}),
10890including the names of the executable and core dump files currently in
10891use by @value{GDBN}, and the files from which symbols were loaded. The
10892command @code{help target} lists all possible targets rather than
10893current ones.
10894
fe95c787
MS
10895@kindex maint info sections
10896@item maint info sections
10897Another command that can give you extra information about program sections
10898is @code{maint info sections}. In addition to the section information
10899displayed by @code{info files}, this command displays the flags and file
10900offset of each section in the executable and core dump files. In addition,
10901@code{maint info sections} provides the following command options (which
10902may be arbitrarily combined):
10903
10904@table @code
10905@item ALLOBJ
10906Display sections for all loaded object files, including shared libraries.
10907@item @var{sections}
6600abed 10908Display info only for named @var{sections}.
fe95c787
MS
10909@item @var{section-flags}
10910Display info only for sections for which @var{section-flags} are true.
10911The section flags that @value{GDBN} currently knows about are:
10912@table @code
10913@item ALLOC
10914Section will have space allocated in the process when loaded.
10915Set for all sections except those containing debug information.
10916@item LOAD
10917Section will be loaded from the file into the child process memory.
10918Set for pre-initialized code and data, clear for @code{.bss} sections.
10919@item RELOC
10920Section needs to be relocated before loading.
10921@item READONLY
10922Section cannot be modified by the child process.
10923@item CODE
10924Section contains executable code only.
6600abed 10925@item DATA
fe95c787
MS
10926Section contains data only (no executable code).
10927@item ROM
10928Section will reside in ROM.
10929@item CONSTRUCTOR
10930Section contains data for constructor/destructor lists.
10931@item HAS_CONTENTS
10932Section is not empty.
10933@item NEVER_LOAD
10934An instruction to the linker to not output the section.
10935@item COFF_SHARED_LIBRARY
10936A notification to the linker that the section contains
10937COFF shared library information.
10938@item IS_COMMON
10939Section contains common symbols.
10940@end table
10941@end table
6763aef9 10942@kindex set trust-readonly-sections
9c16f35a 10943@cindex read-only sections
6763aef9
MS
10944@item set trust-readonly-sections on
10945Tell @value{GDBN} that readonly sections in your object file
6ca652b0 10946really are read-only (i.e.@: that their contents will not change).
6763aef9
MS
10947In that case, @value{GDBN} can fetch values from these sections
10948out of the object file, rather than from the target program.
10949For some targets (notably embedded ones), this can be a significant
10950enhancement to debugging performance.
10951
10952The default is off.
10953
10954@item set trust-readonly-sections off
15110bc3 10955Tell @value{GDBN} not to trust readonly sections. This means that
6763aef9
MS
10956the contents of the section might change while the program is running,
10957and must therefore be fetched from the target when needed.
9c16f35a
EZ
10958
10959@item show trust-readonly-sections
10960Show the current setting of trusting readonly sections.
c906108c
SS
10961@end table
10962
10963All file-specifying commands allow both absolute and relative file names
10964as arguments. @value{GDBN} always converts the file name to an absolute file
10965name and remembers it that way.
10966
c906108c 10967@cindex shared libraries
9c16f35a
EZ
10968@value{GDBN} supports GNU/Linux, MS-Windows, HP-UX, SunOS, SVr4, Irix,
10969and IBM RS/6000 AIX shared libraries.
53a5351d 10970
c906108c
SS
10971@value{GDBN} automatically loads symbol definitions from shared libraries
10972when you use the @code{run} command, or when you examine a core file.
10973(Before you issue the @code{run} command, @value{GDBN} does not understand
10974references to a function in a shared library, however---unless you are
10975debugging a core file).
53a5351d
JM
10976
10977On HP-UX, if the program loads a library explicitly, @value{GDBN}
10978automatically loads the symbols at the time of the @code{shl_load} call.
10979
c906108c
SS
10980@c FIXME: some @value{GDBN} release may permit some refs to undef
10981@c FIXME...symbols---eg in a break cmd---assuming they are from a shared
10982@c FIXME...lib; check this from time to time when updating manual
10983
b7209cb4
FF
10984There are times, however, when you may wish to not automatically load
10985symbol definitions from shared libraries, such as when they are
10986particularly large or there are many of them.
10987
10988To control the automatic loading of shared library symbols, use the
10989commands:
10990
10991@table @code
10992@kindex set auto-solib-add
10993@item set auto-solib-add @var{mode}
10994If @var{mode} is @code{on}, symbols from all shared object libraries
10995will be loaded automatically when the inferior begins execution, you
10996attach to an independently started inferior, or when the dynamic linker
10997informs @value{GDBN} that a new library has been loaded. If @var{mode}
10998is @code{off}, symbols must be loaded manually, using the
10999@code{sharedlibrary} command. The default value is @code{on}.
11000
dcaf7c2c
EZ
11001@cindex memory used for symbol tables
11002If your program uses lots of shared libraries with debug info that
11003takes large amounts of memory, you can decrease the @value{GDBN}
11004memory footprint by preventing it from automatically loading the
11005symbols from shared libraries. To that end, type @kbd{set
11006auto-solib-add off} before running the inferior, then load each
11007library whose debug symbols you do need with @kbd{sharedlibrary
11008@var{regexp}}, where @var{regexp} is a regular expresion that matches
11009the libraries whose symbols you want to be loaded.
11010
b7209cb4
FF
11011@kindex show auto-solib-add
11012@item show auto-solib-add
11013Display the current autoloading mode.
11014@end table
11015
c45da7e6 11016@cindex load shared library
b7209cb4
FF
11017To explicitly load shared library symbols, use the @code{sharedlibrary}
11018command:
11019
c906108c
SS
11020@table @code
11021@kindex info sharedlibrary
11022@kindex info share
11023@item info share
11024@itemx info sharedlibrary
11025Print the names of the shared libraries which are currently loaded.
11026
11027@kindex sharedlibrary
11028@kindex share
11029@item sharedlibrary @var{regex}
11030@itemx share @var{regex}
c906108c
SS
11031Load shared object library symbols for files matching a
11032Unix regular expression.
11033As with files loaded automatically, it only loads shared libraries
11034required by your program for a core file or after typing @code{run}. If
11035@var{regex} is omitted all shared libraries required by your program are
11036loaded.
c45da7e6
EZ
11037
11038@item nosharedlibrary
11039@kindex nosharedlibrary
11040@cindex unload symbols from shared libraries
11041Unload all shared object library symbols. This discards all symbols
11042that have been loaded from all shared libraries. Symbols from shared
11043libraries that were loaded by explicit user requests are not
11044discarded.
c906108c
SS
11045@end table
11046
721c2651
EZ
11047Sometimes you may wish that @value{GDBN} stops and gives you control
11048when any of shared library events happen. Use the @code{set
11049stop-on-solib-events} command for this:
11050
11051@table @code
11052@item set stop-on-solib-events
11053@kindex set stop-on-solib-events
11054This command controls whether @value{GDBN} should give you control
11055when the dynamic linker notifies it about some shared library event.
11056The most common event of interest is loading or unloading of a new
11057shared library.
11058
11059@item show stop-on-solib-events
11060@kindex show stop-on-solib-events
11061Show whether @value{GDBN} stops and gives you control when shared
11062library events happen.
11063@end table
11064
f5ebfba0
DJ
11065Shared libraries are also supported in many cross or remote debugging
11066configurations. A copy of the target's libraries need to be present on the
11067host system; they need to be the same as the target libraries, although the
11068copies on the target can be stripped as long as the copies on the host are
11069not.
11070
59b7b46f
EZ
11071@cindex where to look for shared libraries
11072For remote debugging, you need to tell @value{GDBN} where the target
11073libraries are, so that it can load the correct copies---otherwise, it
11074may try to load the host's libraries. @value{GDBN} has two variables
11075to specify the search directories for target libraries.
f5ebfba0
DJ
11076
11077@table @code
59b7b46f 11078@cindex prefix for shared library file names
f5ebfba0
DJ
11079@kindex set solib-absolute-prefix
11080@item set solib-absolute-prefix @var{path}
11081If this variable is set, @var{path} will be used as a prefix for any
11082absolute shared library paths; many runtime loaders store the absolute
11083paths to the shared library in the target program's memory. If you use
11084@samp{solib-absolute-prefix} to find shared libraries, they need to be laid
11085out in the same way that they are on the target, with e.g.@: a
11086@file{/usr/lib} hierarchy under @var{path}.
11087
59b7b46f
EZ
11088@cindex default value of @samp{solib-absolute-prefix}
11089@cindex @samp{--with-sysroot}
f5ebfba0
DJ
11090You can set the default value of @samp{solib-absolute-prefix} by using the
11091configure-time @samp{--with-sysroot} option.
11092
11093@kindex show solib-absolute-prefix
11094@item show solib-absolute-prefix
11095Display the current shared library prefix.
11096
11097@kindex set solib-search-path
11098@item set solib-search-path @var{path}
11099If this variable is set, @var{path} is a colon-separated list of directories
11100to search for shared libraries. @samp{solib-search-path} is used after
11101@samp{solib-absolute-prefix} fails to locate the library, or if the path to
11102the library is relative instead of absolute. If you want to use
11103@samp{solib-search-path} instead of @samp{solib-absolute-prefix}, be sure to
11104set @samp{solib-absolute-prefix} to a nonexistant directory to prevent
11105@value{GDBN} from finding your host's libraries.
11106
11107@kindex show solib-search-path
11108@item show solib-search-path
11109Display the current shared library search path.
11110@end table
11111
5b5d99cf
JB
11112
11113@node Separate Debug Files
11114@section Debugging Information in Separate Files
11115@cindex separate debugging information files
11116@cindex debugging information in separate files
11117@cindex @file{.debug} subdirectories
11118@cindex debugging information directory, global
11119@cindex global debugging information directory
11120
11121@value{GDBN} allows you to put a program's debugging information in a
11122file separate from the executable itself, in a way that allows
11123@value{GDBN} to find and load the debugging information automatically.
11124Since debugging information can be very large --- sometimes larger
11125than the executable code itself --- some systems distribute debugging
11126information for their executables in separate files, which users can
11127install only when they need to debug a problem.
11128
11129If an executable's debugging information has been extracted to a
11130separate file, the executable should contain a @dfn{debug link} giving
11131the name of the debugging information file (with no directory
11132components), and a checksum of its contents. (The exact form of a
11133debug link is described below.) If the full name of the directory
11134containing the executable is @var{execdir}, and the executable has a
11135debug link that specifies the name @var{debugfile}, then @value{GDBN}
11136will automatically search for the debugging information file in three
11137places:
11138
11139@itemize @bullet
11140@item
11141the directory containing the executable file (that is, it will look
11142for a file named @file{@var{execdir}/@var{debugfile}},
11143@item
11144a subdirectory of that directory named @file{.debug} (that is, the
11145file @file{@var{execdir}/.debug/@var{debugfile}}, and
11146@item
11147a subdirectory of the global debug file directory that includes the
11148executable's full path, and the name from the link (that is, the file
11149@file{@var{globaldebugdir}/@var{execdir}/@var{debugfile}}, where
11150@var{globaldebugdir} is the global debug file directory, and
11151@var{execdir} has been turned into a relative path).
11152@end itemize
11153@noindent
11154@value{GDBN} checks under each of these names for a debugging
11155information file whose checksum matches that given in the link, and
11156reads the debugging information from the first one it finds.
11157
11158So, for example, if you ask @value{GDBN} to debug @file{/usr/bin/ls},
11159which has a link containing the name @file{ls.debug}, and the global
11160debug directory is @file{/usr/lib/debug}, then @value{GDBN} will look
11161for debug information in @file{/usr/bin/ls.debug},
11162@file{/usr/bin/.debug/ls.debug}, and
11163@file{/usr/lib/debug/usr/bin/ls.debug}.
11164
11165You can set the global debugging info directory's name, and view the
11166name @value{GDBN} is currently using.
11167
11168@table @code
11169
11170@kindex set debug-file-directory
11171@item set debug-file-directory @var{directory}
11172Set the directory which @value{GDBN} searches for separate debugging
11173information files to @var{directory}.
11174
11175@kindex show debug-file-directory
11176@item show debug-file-directory
11177Show the directory @value{GDBN} searches for separate debugging
11178information files.
11179
11180@end table
11181
11182@cindex @code{.gnu_debuglink} sections
11183@cindex debug links
11184A debug link is a special section of the executable file named
11185@code{.gnu_debuglink}. The section must contain:
11186
11187@itemize
11188@item
11189A filename, with any leading directory components removed, followed by
11190a zero byte,
11191@item
11192zero to three bytes of padding, as needed to reach the next four-byte
11193boundary within the section, and
11194@item
11195a four-byte CRC checksum, stored in the same endianness used for the
11196executable file itself. The checksum is computed on the debugging
11197information file's full contents by the function given below, passing
11198zero as the @var{crc} argument.
11199@end itemize
11200
11201Any executable file format can carry a debug link, as long as it can
11202contain a section named @code{.gnu_debuglink} with the contents
11203described above.
11204
11205The debugging information file itself should be an ordinary
11206executable, containing a full set of linker symbols, sections, and
11207debugging information. The sections of the debugging information file
11208should have the same names, addresses and sizes as the original file,
11209but they need not contain any data --- much like a @code{.bss} section
11210in an ordinary executable.
11211
11212As of December 2002, there is no standard GNU utility to produce
11213separated executable / debugging information file pairs. Ulrich
11214Drepper's @file{elfutils} package, starting with version 0.53,
11215contains a version of the @code{strip} command such that the command
11216@kbd{strip foo -f foo.debug} removes the debugging information from
11217the executable file @file{foo}, places it in the file
11218@file{foo.debug}, and leaves behind a debug link in @file{foo}.
11219
11220Since there are many different ways to compute CRC's (different
11221polynomials, reversals, byte ordering, etc.), the simplest way to
11222describe the CRC used in @code{.gnu_debuglink} sections is to give the
11223complete code for a function that computes it:
11224
4644b6e3 11225@kindex gnu_debuglink_crc32
5b5d99cf
JB
11226@smallexample
11227unsigned long
11228gnu_debuglink_crc32 (unsigned long crc,
11229 unsigned char *buf, size_t len)
11230@{
11231 static const unsigned long crc32_table[256] =
11232 @{
11233 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
11234 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
11235 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
11236 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
11237 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
11238 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
11239 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
11240 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
11241 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
11242 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
11243 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
11244 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
11245 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
11246 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
11247 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
11248 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
11249 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
11250 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
11251 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
11252 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
11253 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
11254 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
11255 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
11256 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
11257 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
11258 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
11259 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
11260 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
11261 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
11262 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
11263 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
11264 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
11265 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
11266 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
11267 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
11268 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
11269 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
11270 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
11271 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
11272 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
11273 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
11274 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
11275 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
11276 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
11277 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
11278 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
11279 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
11280 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
11281 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
11282 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
11283 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
11284 0x2d02ef8d
11285 @};
11286 unsigned char *end;
11287
11288 crc = ~crc & 0xffffffff;
11289 for (end = buf + len; buf < end; ++buf)
11290 crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
e7a3abfc 11291 return ~crc & 0xffffffff;
5b5d99cf
JB
11292@}
11293@end smallexample
11294
11295
6d2ebf8b 11296@node Symbol Errors
c906108c
SS
11297@section Errors reading symbol files
11298
11299While reading a symbol file, @value{GDBN} occasionally encounters problems,
11300such as symbol types it does not recognize, or known bugs in compiler
11301output. By default, @value{GDBN} does not notify you of such problems, since
11302they are relatively common and primarily of interest to people
11303debugging compilers. If you are interested in seeing information
11304about ill-constructed symbol tables, you can either ask @value{GDBN} to print
11305only one message about each such type of problem, no matter how many
11306times the problem occurs; or you can ask @value{GDBN} to print more messages,
11307to see how many times the problems occur, with the @code{set
11308complaints} command (@pxref{Messages/Warnings, ,Optional warnings and
11309messages}).
11310
11311The messages currently printed, and their meanings, include:
11312
11313@table @code
11314@item inner block not inside outer block in @var{symbol}
11315
11316The symbol information shows where symbol scopes begin and end
11317(such as at the start of a function or a block of statements). This
11318error indicates that an inner scope block is not fully contained
11319in its outer scope blocks.
11320
11321@value{GDBN} circumvents the problem by treating the inner block as if it had
11322the same scope as the outer block. In the error message, @var{symbol}
11323may be shown as ``@code{(don't know)}'' if the outer block is not a
11324function.
11325
11326@item block at @var{address} out of order
11327
11328The symbol information for symbol scope blocks should occur in
11329order of increasing addresses. This error indicates that it does not
11330do so.
11331
11332@value{GDBN} does not circumvent this problem, and has trouble
11333locating symbols in the source file whose symbols it is reading. (You
11334can often determine what source file is affected by specifying
11335@code{set verbose on}. @xref{Messages/Warnings, ,Optional warnings and
11336messages}.)
11337
11338@item bad block start address patched
11339
11340The symbol information for a symbol scope block has a start address
11341smaller than the address of the preceding source line. This is known
11342to occur in the SunOS 4.1.1 (and earlier) C compiler.
11343
11344@value{GDBN} circumvents the problem by treating the symbol scope block as
11345starting on the previous source line.
11346
11347@item bad string table offset in symbol @var{n}
11348
11349@cindex foo
11350Symbol number @var{n} contains a pointer into the string table which is
11351larger than the size of the string table.
11352
11353@value{GDBN} circumvents the problem by considering the symbol to have the
11354name @code{foo}, which may cause other problems if many symbols end up
11355with this name.
11356
11357@item unknown symbol type @code{0x@var{nn}}
11358
7a292a7a
SS
11359The symbol information contains new data types that @value{GDBN} does
11360not yet know how to read. @code{0x@var{nn}} is the symbol type of the
d4f3574e 11361uncomprehended information, in hexadecimal.
c906108c 11362
7a292a7a
SS
11363@value{GDBN} circumvents the error by ignoring this symbol information.
11364This usually allows you to debug your program, though certain symbols
c906108c 11365are not accessible. If you encounter such a problem and feel like
7a292a7a
SS
11366debugging it, you can debug @code{@value{GDBP}} with itself, breakpoint
11367on @code{complain}, then go up to the function @code{read_dbx_symtab}
11368and examine @code{*bufp} to see the symbol.
c906108c
SS
11369
11370@item stub type has NULL name
c906108c 11371
7a292a7a 11372@value{GDBN} could not find the full definition for a struct or class.
c906108c 11373
7a292a7a 11374@item const/volatile indicator missing (ok if using g++ v1.x), got@dots{}
b37052ae 11375The symbol information for a C@t{++} member function is missing some
7a292a7a
SS
11376information that recent versions of the compiler should have output for
11377it.
c906108c
SS
11378
11379@item info mismatch between compiler and debugger
11380
11381@value{GDBN} could not parse a type specification output by the compiler.
7a292a7a 11382
c906108c
SS
11383@end table
11384
6d2ebf8b 11385@node Targets
c906108c 11386@chapter Specifying a Debugging Target
7a292a7a 11387
c906108c 11388@cindex debugging target
c906108c 11389A @dfn{target} is the execution environment occupied by your program.
53a5351d
JM
11390
11391Often, @value{GDBN} runs in the same host environment as your program;
11392in that case, the debugging target is specified as a side effect when
11393you use the @code{file} or @code{core} commands. When you need more
c906108c
SS
11394flexibility---for example, running @value{GDBN} on a physically separate
11395host, or controlling a standalone system over a serial port or a
53a5351d
JM
11396realtime system over a TCP/IP connection---you can use the @code{target}
11397command to specify one of the target types configured for @value{GDBN}
11398(@pxref{Target Commands, ,Commands for managing targets}).
c906108c 11399
a8f24a35
EZ
11400@cindex target architecture
11401It is possible to build @value{GDBN} for several different @dfn{target
11402architectures}. When @value{GDBN} is built like that, you can choose
11403one of the available architectures with the @kbd{set architecture}
11404command.
11405
11406@table @code
11407@kindex set architecture
11408@kindex show architecture
11409@item set architecture @var{arch}
11410This command sets the current target architecture to @var{arch}. The
11411value of @var{arch} can be @code{"auto"}, in addition to one of the
11412supported architectures.
11413
11414@item show architecture
11415Show the current target architecture.
9c16f35a
EZ
11416
11417@item set processor
11418@itemx processor
11419@kindex set processor
11420@kindex show processor
11421These are alias commands for, respectively, @code{set architecture}
11422and @code{show architecture}.
a8f24a35
EZ
11423@end table
11424
c906108c
SS
11425@menu
11426* Active Targets:: Active targets
11427* Target Commands:: Commands for managing targets
c906108c
SS
11428* Byte Order:: Choosing target byte order
11429* Remote:: Remote debugging
96baa820 11430* KOD:: Kernel Object Display
c906108c
SS
11431
11432@end menu
11433
6d2ebf8b 11434@node Active Targets
c906108c 11435@section Active targets
7a292a7a 11436
c906108c
SS
11437@cindex stacking targets
11438@cindex active targets
11439@cindex multiple targets
11440
c906108c 11441There are three classes of targets: processes, core files, and
7a292a7a
SS
11442executable files. @value{GDBN} can work concurrently on up to three
11443active targets, one in each class. This allows you to (for example)
11444start a process and inspect its activity without abandoning your work on
11445a core file.
c906108c
SS
11446
11447For example, if you execute @samp{gdb a.out}, then the executable file
11448@code{a.out} is the only active target. If you designate a core file as
11449well---presumably from a prior run that crashed and coredumped---then
11450@value{GDBN} has two active targets and uses them in tandem, looking
11451first in the corefile target, then in the executable file, to satisfy
11452requests for memory addresses. (Typically, these two classes of target
11453are complementary, since core files contain only a program's
11454read-write memory---variables and so on---plus machine status, while
11455executable files contain only the program text and initialized data.)
c906108c
SS
11456
11457When you type @code{run}, your executable file becomes an active process
7a292a7a
SS
11458target as well. When a process target is active, all @value{GDBN}
11459commands requesting memory addresses refer to that target; addresses in
11460an active core file or executable file target are obscured while the
11461process target is active.
c906108c 11462
7a292a7a
SS
11463Use the @code{core-file} and @code{exec-file} commands to select a new
11464core file or executable target (@pxref{Files, ,Commands to specify
c906108c 11465files}). To specify as a target a process that is already running, use
7a292a7a
SS
11466the @code{attach} command (@pxref{Attach, ,Debugging an already-running
11467process}).
c906108c 11468
6d2ebf8b 11469@node Target Commands
c906108c
SS
11470@section Commands for managing targets
11471
11472@table @code
11473@item target @var{type} @var{parameters}
7a292a7a
SS
11474Connects the @value{GDBN} host environment to a target machine or
11475process. A target is typically a protocol for talking to debugging
11476facilities. You use the argument @var{type} to specify the type or
11477protocol of the target machine.
c906108c
SS
11478
11479Further @var{parameters} are interpreted by the target protocol, but
11480typically include things like device names or host names to connect
11481with, process numbers, and baud rates.
c906108c
SS
11482
11483The @code{target} command does not repeat if you press @key{RET} again
11484after executing the command.
11485
11486@kindex help target
11487@item help target
11488Displays the names of all targets available. To display targets
11489currently selected, use either @code{info target} or @code{info files}
11490(@pxref{Files, ,Commands to specify files}).
11491
11492@item help target @var{name}
11493Describe a particular target, including any parameters necessary to
11494select it.
11495
11496@kindex set gnutarget
11497@item set gnutarget @var{args}
5d161b24 11498@value{GDBN} uses its own library BFD to read your files. @value{GDBN}
c906108c 11499knows whether it is reading an @dfn{executable},
5d161b24
DB
11500a @dfn{core}, or a @dfn{.o} file; however, you can specify the file format
11501with the @code{set gnutarget} command. Unlike most @code{target} commands,
c906108c
SS
11502with @code{gnutarget} the @code{target} refers to a program, not a machine.
11503
d4f3574e 11504@quotation
c906108c
SS
11505@emph{Warning:} To specify a file format with @code{set gnutarget},
11506you must know the actual BFD name.
d4f3574e 11507@end quotation
c906108c 11508
d4f3574e
SS
11509@noindent
11510@xref{Files, , Commands to specify files}.
c906108c 11511
5d161b24 11512@kindex show gnutarget
c906108c
SS
11513@item show gnutarget
11514Use the @code{show gnutarget} command to display what file format
11515@code{gnutarget} is set to read. If you have not set @code{gnutarget},
11516@value{GDBN} will determine the file format for each file automatically,
11517and @code{show gnutarget} displays @samp{The current BDF target is "auto"}.
11518@end table
11519
4644b6e3 11520@cindex common targets
c906108c
SS
11521Here are some common targets (available, or not, depending on the GDB
11522configuration):
c906108c
SS
11523
11524@table @code
4644b6e3 11525@kindex target
c906108c 11526@item target exec @var{program}
4644b6e3 11527@cindex executable file target
c906108c
SS
11528An executable file. @samp{target exec @var{program}} is the same as
11529@samp{exec-file @var{program}}.
11530
c906108c 11531@item target core @var{filename}
4644b6e3 11532@cindex core dump file target
c906108c
SS
11533A core dump file. @samp{target core @var{filename}} is the same as
11534@samp{core-file @var{filename}}.
c906108c 11535
c906108c 11536@item target remote @var{dev}
4644b6e3 11537@cindex remote target
c906108c
SS
11538Remote serial target in GDB-specific protocol. The argument @var{dev}
11539specifies what serial device to use for the connection (e.g.
11540@file{/dev/ttya}). @xref{Remote, ,Remote debugging}. @code{target remote}
d4f3574e 11541supports the @code{load} command. This is only useful if you have
c906108c
SS
11542some other way of getting the stub to the target system, and you can put
11543it somewhere in memory where it won't get clobbered by the download.
11544
c906108c 11545@item target sim
4644b6e3 11546@cindex built-in simulator target
2df3850c 11547Builtin CPU simulator. @value{GDBN} includes simulators for most architectures.
104c1213 11548In general,
474c8240 11549@smallexample
104c1213
JM
11550 target sim
11551 load
11552 run
474c8240 11553@end smallexample
d4f3574e 11554@noindent
104c1213 11555works; however, you cannot assume that a specific memory map, device
d4f3574e 11556drivers, or even basic I/O is available, although some simulators do
104c1213
JM
11557provide these. For info about any processor-specific simulator details,
11558see the appropriate section in @ref{Embedded Processors, ,Embedded
11559Processors}.
11560
c906108c
SS
11561@end table
11562
104c1213 11563Some configurations may include these targets as well:
c906108c
SS
11564
11565@table @code
11566
c906108c 11567@item target nrom @var{dev}
4644b6e3 11568@cindex NetROM ROM emulator target
c906108c
SS
11569NetROM ROM emulator. This target only supports downloading.
11570
c906108c
SS
11571@end table
11572
5d161b24 11573Different targets are available on different configurations of @value{GDBN};
c906108c 11574your configuration may have more or fewer targets.
c906108c 11575
721c2651
EZ
11576Many remote targets require you to download the executable's code once
11577you've successfully established a connection. You may wish to control
11578various aspects of this process, such as the size of the data chunks
11579used by @value{GDBN} to download program parts to the remote target.
a8f24a35
EZ
11580
11581@table @code
11582@kindex set download-write-size
11583@item set download-write-size @var{size}
11584Set the write size used when downloading a program. Only used when
11585downloading a program onto a remote target. Specify zero or a
11586negative value to disable blocked writes. The actual size of each
11587transfer is also limited by the size of the target packet and the
11588memory cache.
11589
11590@kindex show download-write-size
11591@item show download-write-size
721c2651 11592@kindex show download-write-size
a8f24a35 11593Show the current value of the write size.
721c2651
EZ
11594
11595@item set hash
11596@kindex set hash@r{, for remote monitors}
11597@cindex hash mark while downloading
11598This command controls whether a hash mark @samp{#} is displayed while
11599downloading a file to the remote monitor. If on, a hash mark is
11600displayed after each S-record is successfully downloaded to the
11601monitor.
11602
11603@item show hash
11604@kindex show hash@r{, for remote monitors}
11605Show the current status of displaying the hash mark.
11606
11607@item set debug monitor
11608@kindex set debug monitor
11609@cindex display remote monitor communications
11610Enable or disable display of communications messages between
11611@value{GDBN} and the remote monitor.
11612
11613@item show debug monitor
11614@kindex show debug monitor
11615Show the current status of displaying communications between
11616@value{GDBN} and the remote monitor.
a8f24a35 11617@end table
c906108c
SS
11618
11619@table @code
11620
11621@kindex load @var{filename}
11622@item load @var{filename}
c906108c
SS
11623Depending on what remote debugging facilities are configured into
11624@value{GDBN}, the @code{load} command may be available. Where it exists, it
11625is meant to make @var{filename} (an executable) available for debugging
11626on the remote system---by downloading, or dynamic linking, for example.
11627@code{load} also records the @var{filename} symbol table in @value{GDBN}, like
11628the @code{add-symbol-file} command.
11629
11630If your @value{GDBN} does not have a @code{load} command, attempting to
11631execute it gets the error message ``@code{You can't do that when your
11632target is @dots{}}''
c906108c
SS
11633
11634The file is loaded at whatever address is specified in the executable.
11635For some object file formats, you can specify the load address when you
11636link the program; for other formats, like a.out, the object file format
11637specifies a fixed address.
11638@c FIXME! This would be a good place for an xref to the GNU linker doc.
11639
c906108c
SS
11640@code{load} does not repeat if you press @key{RET} again after using it.
11641@end table
11642
6d2ebf8b 11643@node Byte Order
c906108c 11644@section Choosing target byte order
7a292a7a 11645
c906108c
SS
11646@cindex choosing target byte order
11647@cindex target byte order
c906108c 11648
172c2a43 11649Some types of processors, such as the MIPS, PowerPC, and Renesas SH,
c906108c
SS
11650offer the ability to run either big-endian or little-endian byte
11651orders. Usually the executable or symbol will include a bit to
11652designate the endian-ness, and you will not need to worry about
11653which to use. However, you may still find it useful to adjust
d4f3574e 11654@value{GDBN}'s idea of processor endian-ness manually.
c906108c
SS
11655
11656@table @code
4644b6e3 11657@kindex set endian
c906108c
SS
11658@item set endian big
11659Instruct @value{GDBN} to assume the target is big-endian.
11660
c906108c
SS
11661@item set endian little
11662Instruct @value{GDBN} to assume the target is little-endian.
11663
c906108c
SS
11664@item set endian auto
11665Instruct @value{GDBN} to use the byte order associated with the
11666executable.
11667
11668@item show endian
11669Display @value{GDBN}'s current idea of the target byte order.
11670
11671@end table
11672
11673Note that these commands merely adjust interpretation of symbolic
11674data on the host, and that they have absolutely no effect on the
11675target system.
11676
6d2ebf8b 11677@node Remote
c906108c
SS
11678@section Remote debugging
11679@cindex remote debugging
11680
11681If you are trying to debug a program running on a machine that cannot run
5d161b24
DB
11682@value{GDBN} in the usual way, it is often useful to use remote debugging.
11683For example, you might use remote debugging on an operating system kernel,
c906108c
SS
11684or on a small system which does not have a general purpose operating system
11685powerful enough to run a full-featured debugger.
11686
11687Some configurations of @value{GDBN} have special serial or TCP/IP interfaces
11688to make this work with particular debugging targets. In addition,
5d161b24 11689@value{GDBN} comes with a generic serial protocol (specific to @value{GDBN},
c906108c
SS
11690but not specific to any particular target system) which you can use if you
11691write the remote stubs---the code that runs on the remote system to
11692communicate with @value{GDBN}.
11693
11694Other remote targets may be available in your
11695configuration of @value{GDBN}; use @code{help target} to list them.
c906108c 11696
c45da7e6
EZ
11697Once you've connected to the remote target, @value{GDBN} allows you to
11698send arbitrary commands to the remote monitor:
11699
11700@table @code
11701@item remote @var{command}
11702@kindex remote@r{, a command}
11703@cindex send command to remote monitor
11704Send an arbitrary @var{command} string to the remote monitor.
11705@end table
11706
11707
6f05cf9f
AC
11708@node KOD
11709@section Kernel Object Display
6f05cf9f 11710@cindex kernel object display
6f05cf9f
AC
11711@cindex KOD
11712
11713Some targets support kernel object display. Using this facility,
11714@value{GDBN} communicates specially with the underlying operating system
11715and can display information about operating system-level objects such as
11716mutexes and other synchronization objects. Exactly which objects can be
11717displayed is determined on a per-OS basis.
11718
3bbe9696 11719@kindex set os
6f05cf9f
AC
11720Use the @code{set os} command to set the operating system. This tells
11721@value{GDBN} which kernel object display module to initialize:
11722
474c8240 11723@smallexample
6f05cf9f 11724(@value{GDBP}) set os cisco
474c8240 11725@end smallexample
6f05cf9f 11726
3bbe9696
EZ
11727@kindex show os
11728The associated command @code{show os} displays the operating system
11729set with the @code{set os} command; if no operating system has been
11730set, @code{show os} will display an empty string @samp{""}.
11731
6f05cf9f
AC
11732If @code{set os} succeeds, @value{GDBN} will display some information
11733about the operating system, and will create a new @code{info} command
11734which can be used to query the target. The @code{info} command is named
11735after the operating system:
c906108c 11736
3bbe9696 11737@kindex info cisco
474c8240 11738@smallexample
6f05cf9f
AC
11739(@value{GDBP}) info cisco
11740List of Cisco Kernel Objects
11741Object Description
11742any Any and all objects
474c8240 11743@end smallexample
6f05cf9f
AC
11744
11745Further subcommands can be used to query about particular objects known
11746by the kernel.
11747
3bbe9696
EZ
11748There is currently no way to determine whether a given operating
11749system is supported other than to try setting it with @kbd{set os
11750@var{name}}, where @var{name} is the name of the operating system you
11751want to try.
6f05cf9f
AC
11752
11753
11754@node Remote Debugging
11755@chapter Debugging remote programs
11756
6b2f586d 11757@menu
07f31aa6 11758* Connecting:: Connecting to a remote target
6b2f586d
AC
11759* Server:: Using the gdbserver program
11760* NetWare:: Using the gdbserve.nlm program
501eef12 11761* Remote configuration:: Remote configuration
6b2f586d 11762* remote stub:: Implementing a remote stub
6b2f586d
AC
11763@end menu
11764
07f31aa6
DJ
11765@node Connecting
11766@section Connecting to a remote target
11767
11768On the @value{GDBN} host machine, you will need an unstripped copy of
11769your program, since @value{GDBN} needs symobl and debugging information.
11770Start up @value{GDBN} as usual, using the name of the local copy of your
11771program as the first argument.
11772
11773@cindex serial line, @code{target remote}
11774If you're using a serial line, you may want to give @value{GDBN} the
11775@w{@samp{--baud}} option, or use the @code{set remotebaud} command
9c16f35a
EZ
11776(@pxref{Remote configuration, set remotebaud}) before the
11777@code{target} command.
07f31aa6
DJ
11778
11779After that, use @code{target remote} to establish communications with
11780the target machine. Its argument specifies how to communicate---either
11781via a devicename attached to a direct serial line, or a TCP or UDP port
11782(possibly to a terminal server which in turn has a serial line to the
11783target). For example, to use a serial line connected to the device
11784named @file{/dev/ttyb}:
11785
11786@smallexample
11787target remote /dev/ttyb
11788@end smallexample
11789
11790@cindex TCP port, @code{target remote}
11791To use a TCP connection, use an argument of the form
11792@code{@var{host}:@var{port}} or @code{tcp:@var{host}:@var{port}}.
11793For example, to connect to port 2828 on a
11794terminal server named @code{manyfarms}:
11795
11796@smallexample
11797target remote manyfarms:2828
11798@end smallexample
11799
11800If your remote target is actually running on the same machine as
11801your debugger session (e.g.@: a simulator of your target running on
11802the same host), you can omit the hostname. For example, to connect
11803to port 1234 on your local machine:
11804
11805@smallexample
11806target remote :1234
11807@end smallexample
11808@noindent
11809
11810Note that the colon is still required here.
11811
11812@cindex UDP port, @code{target remote}
11813To use a UDP connection, use an argument of the form
11814@code{udp:@var{host}:@var{port}}. For example, to connect to UDP port 2828
11815on a terminal server named @code{manyfarms}:
11816
11817@smallexample
11818target remote udp:manyfarms:2828
11819@end smallexample
11820
11821When using a UDP connection for remote debugging, you should keep in mind
11822that the `U' stands for ``Unreliable''. UDP can silently drop packets on
11823busy or unreliable networks, which will cause havoc with your debugging
11824session.
11825
11826Now you can use all the usual commands to examine and change data and to
11827step and continue the remote program.
11828
11829@cindex interrupting remote programs
11830@cindex remote programs, interrupting
11831Whenever @value{GDBN} is waiting for the remote program, if you type the
11832interrupt character (often @key{C-C}), @value{GDBN} attempts to stop the
11833program. This may or may not succeed, depending in part on the hardware
11834and the serial drivers the remote system uses. If you type the
11835interrupt character once again, @value{GDBN} displays this prompt:
11836
11837@smallexample
11838Interrupted while waiting for the program.
11839Give up (and stop debugging it)? (y or n)
11840@end smallexample
11841
11842If you type @kbd{y}, @value{GDBN} abandons the remote debugging session.
11843(If you decide you want to try again later, you can use @samp{target
11844remote} again to connect once more.) If you type @kbd{n}, @value{GDBN}
11845goes back to waiting.
11846
11847@table @code
11848@kindex detach (remote)
11849@item detach
11850When you have finished debugging the remote program, you can use the
11851@code{detach} command to release it from @value{GDBN} control.
11852Detaching from the target normally resumes its execution, but the results
11853will depend on your particular remote stub. After the @code{detach}
11854command, @value{GDBN} is free to connect to another target.
11855
11856@kindex disconnect
11857@item disconnect
11858The @code{disconnect} command behaves like @code{detach}, except that
11859the target is generally not resumed. It will wait for @value{GDBN}
11860(this instance or another one) to connect and continue debugging. After
11861the @code{disconnect} command, @value{GDBN} is again free to connect to
11862another target.
09d4efe1
EZ
11863
11864@cindex send command to remote monitor
11865@kindex monitor
11866@item monitor @var{cmd}
11867This command allows you to send commands directly to the remote
11868monitor.
07f31aa6
DJ
11869@end table
11870
6f05cf9f
AC
11871@node Server
11872@section Using the @code{gdbserver} program
11873
11874@kindex gdbserver
11875@cindex remote connection without stubs
11876@code{gdbserver} is a control program for Unix-like systems, which
11877allows you to connect your program with a remote @value{GDBN} via
11878@code{target remote}---but without linking in the usual debugging stub.
11879
11880@code{gdbserver} is not a complete replacement for the debugging stubs,
11881because it requires essentially the same operating-system facilities
11882that @value{GDBN} itself does. In fact, a system that can run
11883@code{gdbserver} to connect to a remote @value{GDBN} could also run
11884@value{GDBN} locally! @code{gdbserver} is sometimes useful nevertheless,
11885because it is a much smaller program than @value{GDBN} itself. It is
11886also easier to port than all of @value{GDBN}, so you may be able to get
11887started more quickly on a new system by using @code{gdbserver}.
11888Finally, if you develop code for real-time systems, you may find that
11889the tradeoffs involved in real-time operation make it more convenient to
11890do as much development work as possible on another system, for example
11891by cross-compiling. You can use @code{gdbserver} to make a similar
11892choice for debugging.
11893
11894@value{GDBN} and @code{gdbserver} communicate via either a serial line
11895or a TCP connection, using the standard @value{GDBN} remote serial
11896protocol.
11897
11898@table @emph
11899@item On the target machine,
11900you need to have a copy of the program you want to debug.
11901@code{gdbserver} does not need your program's symbol table, so you can
11902strip the program if necessary to save space. @value{GDBN} on the host
11903system does all the symbol handling.
11904
11905To use the server, you must tell it how to communicate with @value{GDBN};
56460a61 11906the name of your program; and the arguments for your program. The usual
6f05cf9f
AC
11907syntax is:
11908
11909@smallexample
11910target> gdbserver @var{comm} @var{program} [ @var{args} @dots{} ]
11911@end smallexample
11912
11913@var{comm} is either a device name (to use a serial line) or a TCP
11914hostname and portnumber. For example, to debug Emacs with the argument
11915@samp{foo.txt} and communicate with @value{GDBN} over the serial port
11916@file{/dev/com1}:
11917
11918@smallexample
11919target> gdbserver /dev/com1 emacs foo.txt
11920@end smallexample
11921
11922@code{gdbserver} waits passively for the host @value{GDBN} to communicate
11923with it.
11924
11925To use a TCP connection instead of a serial line:
11926
11927@smallexample
11928target> gdbserver host:2345 emacs foo.txt
11929@end smallexample
11930
11931The only difference from the previous example is the first argument,
11932specifying that you are communicating with the host @value{GDBN} via
11933TCP. The @samp{host:2345} argument means that @code{gdbserver} is to
11934expect a TCP connection from machine @samp{host} to local TCP port 2345.
11935(Currently, the @samp{host} part is ignored.) You can choose any number
11936you want for the port number as long as it does not conflict with any
11937TCP ports already in use on the target system (for example, @code{23} is
11938reserved for @code{telnet}).@footnote{If you choose a port number that
11939conflicts with another service, @code{gdbserver} prints an error message
11940and exits.} You must use the same port number with the host @value{GDBN}
11941@code{target remote} command.
11942
56460a61
DJ
11943On some targets, @code{gdbserver} can also attach to running programs.
11944This is accomplished via the @code{--attach} argument. The syntax is:
11945
11946@smallexample
11947target> gdbserver @var{comm} --attach @var{pid}
11948@end smallexample
11949
11950@var{pid} is the process ID of a currently running process. It isn't necessary
11951to point @code{gdbserver} at a binary for the running process.
11952
b1fe9455
DJ
11953@pindex pidof
11954@cindex attach to a program by name
11955You can debug processes by name instead of process ID if your target has the
11956@code{pidof} utility:
11957
11958@smallexample
11959target> gdbserver @var{comm} --attach `pidof @var{PROGRAM}`
11960@end smallexample
11961
11962In case more than one copy of @var{PROGRAM} is running, or @var{PROGRAM}
11963has multiple threads, most versions of @code{pidof} support the
11964@code{-s} option to only return the first process ID.
11965
07f31aa6
DJ
11966@item On the host machine,
11967connect to your target (@pxref{Connecting,,Connecting to a remote target}).
6f05cf9f
AC
11968For TCP connections, you must start up @code{gdbserver} prior to using
11969the @code{target remote} command. Otherwise you may get an error whose
11970text depends on the host system, but which usually looks something like
07f31aa6 11971@samp{Connection refused}. You don't need to use the @code{load}
397ca115
EZ
11972command in @value{GDBN} when using @code{gdbserver}, since the program is
11973already on the target. However, if you want to load the symbols (as
11974you normally would), do that with the @code{file} command, and issue
11975it @emph{before} connecting to the server; otherwise, you will get an
11976error message saying @code{"Program is already running"}, since the
11977program is considered running after the connection.
07f31aa6 11978
6f05cf9f
AC
11979@end table
11980
11981@node NetWare
11982@section Using the @code{gdbserve.nlm} program
11983
11984@kindex gdbserve.nlm
11985@code{gdbserve.nlm} is a control program for NetWare systems, which
11986allows you to connect your program with a remote @value{GDBN} via
11987@code{target remote}.
11988
11989@value{GDBN} and @code{gdbserve.nlm} communicate via a serial line,
11990using the standard @value{GDBN} remote serial protocol.
11991
11992@table @emph
11993@item On the target machine,
11994you need to have a copy of the program you want to debug.
11995@code{gdbserve.nlm} does not need your program's symbol table, so you
11996can strip the program if necessary to save space. @value{GDBN} on the
11997host system does all the symbol handling.
11998
11999To use the server, you must tell it how to communicate with
12000@value{GDBN}; the name of your program; and the arguments for your
12001program. The syntax is:
12002
12003@smallexample
12004load gdbserve [ BOARD=@var{board} ] [ PORT=@var{port} ]
12005 [ BAUD=@var{baud} ] @var{program} [ @var{args} @dots{} ]
12006@end smallexample
12007
12008@var{board} and @var{port} specify the serial line; @var{baud} specifies
12009the baud rate used by the connection. @var{port} and @var{node} default
12010to 0, @var{baud} defaults to 9600@dmn{bps}.
12011
12012For example, to debug Emacs with the argument @samp{foo.txt}and
12013communicate with @value{GDBN} over serial port number 2 or board 1
12014using a 19200@dmn{bps} connection:
12015
12016@smallexample
12017load gdbserve BOARD=1 PORT=2 BAUD=19200 emacs foo.txt
12018@end smallexample
12019
07f31aa6
DJ
12020@item
12021On the @value{GDBN} host machine, connect to your target (@pxref{Connecting,,
12022Connecting to a remote target}).
6f05cf9f 12023
6f05cf9f
AC
12024@end table
12025
501eef12
AC
12026@node Remote configuration
12027@section Remote configuration
12028
9c16f35a
EZ
12029@kindex set remote
12030@kindex show remote
12031This section documents the configuration options available when
12032debugging remote programs. For the options related to the File I/O
12033extensions of the remote protocol, see @ref{The system call,
12034system-call-allowed}.
501eef12
AC
12035
12036@table @code
9c16f35a
EZ
12037@item set remoteaddresssize @var{bits}
12038@cindex adress size for remote targets
12039@cindex bits in remote address
12040Set the maximum size of address in a memory packet to the specified
12041number of bits. @value{GDBN} will mask off the address bits above
12042that number, when it passes addresses to the remote target. The
12043default value is the number of bits in the target's address.
12044
12045@item show remoteaddresssize
12046Show the current value of remote address size in bits.
12047
12048@item set remotebaud @var{n}
12049@cindex baud rate for remote targets
12050Set the baud rate for the remote serial I/O to @var{n} baud. The
12051value is used to set the speed of the serial port used for debugging
12052remote targets.
12053
12054@item show remotebaud
12055Show the current speed of the remote connection.
12056
12057@item set remotebreak
12058@cindex interrupt remote programs
12059@cindex BREAK signal instead of Ctrl-C
12060If set to on, @value{GDBN} sends a @code{BREAK} signal to the remote
12061when you press the @key{Ctrl-C} key to interrupt the program running
12062on the remote. If set to off, @value{GDBN} sends the @samp{Strl-C}
12063character instead. The default is off, since most remote systems
12064expect to see @samp{Ctrl-C} as the interrupt signal.
12065
12066@item show remotebreak
12067Show whether @value{GDBN} sends @code{BREAK} or @samp{Ctrl-C} to
12068interrupt the remote program.
12069
12070@item set remotedebug
12071@cindex debug remote protocol
12072@cindex remote protocol debugging
12073@cindex display remote packets
12074Control the debugging of the remote protocol. When enabled, each
12075packet sent to or received from the remote target is displayed. The
12076defaults is off.
12077
12078@item show remotedebug
12079Show the current setting of the remote protocol debugging.
12080
12081@item set remotedevice @var{device}
12082@cindex serial port name
12083Set the name of the serial port through which to communicate to the
12084remote target to @var{device}. This is the device used by
12085@value{GDBN} to open the serial communications line to the remote
12086target. There's no default, so you must set a valid port name for the
12087remote serial communications to work. (Some varieties of the
12088@code{target} command accept the port name as part of their
12089arguments.)
12090
12091@item show remotedevice
12092Show the current name of the serial port.
12093
12094@item set remotelogbase @var{base}
12095Set the base (a.k.a.@: radix) of logging serial protocol
12096communications to @var{base}. Supported values of @var{base} are:
12097@code{ascii}, @code{octal}, and @code{hex}. The default is
12098@code{ascii}.
12099
12100@item show remotelogbase
12101Show the current setting of the radix for logging remote serial
12102protocol.
12103
12104@item set remotelogfile @var{file}
12105@cindex record serial communications on file
12106Record remote serial communications on the named @var{file}. The
12107default is not to record at all.
12108
12109@item show remotelogfile.
12110Show the current setting of the file name on which to record the
12111serial communications.
12112
12113@item set remotetimeout @var{num}
12114@cindex timeout for serial communications
12115@cindex remote timeout
12116Set the timeout limit to wait for the remote target to respond to
12117@var{num} seconds. The default is 2 seconds.
12118
12119@item show remotetimeout
12120Show the current number of seconds to wait for the remote target
12121responses.
12122
12123@cindex limit hardware breakpoints and watchpoints
12124@cindex remote target, limit break- and watchpoints
501eef12
AC
12125@anchor{set remote hardware-watchpoint-limit}
12126@anchor{set remote hardware-breakpoint-limit}
12127@item set remote hardware-watchpoint-limit @var{limit}
12128@itemx set remote hardware-breakpoint-limit @var{limit}
12129Restrict @value{GDBN} to using @var{limit} remote hardware breakpoint or
12130watchpoints. A limit of -1, the default, is treated as unlimited.
9c16f35a
EZ
12131
12132@item set remote fetch-register-packet
12133@itemx set remote set-register-packet
12134@itemx set remote P-packet
12135@itemx set remote p-packet
12136@cindex P-packet
12137@cindex fetch registers from remote targets
12138@cindex set registers in remote targets
12139Determine whether @value{GDBN} can set and fetch registers from the
12140remote target using the @samp{P} packets. The default depends on the
12141remote stub's support of the @samp{P} packets (@value{GDBN} queries
12142the stub when this packet is first required).
12143
12144@item show remote fetch-register-packet
12145@itemx show remote set-register-packet
12146@itemx show remote P-packet
12147@itemx show remote p-packet
12148Show the current setting of using the @samp{P} packets for setting and
12149fetching registers from the remote target.
12150
12151@cindex binary downloads
12152@cindex X-packet
12153@item set remote binary-download-packet
12154@itemx set remote X-packet
12155Determine whether @value{GDBN} sends downloads in binary mode using
12156the @samp{X} packets. The default is on.
12157
12158@item show remote binary-download-packet
12159@itemx show remote X-packet
12160Show the current setting of using the @samp{X} packets for binary
12161downloads.
12162
12163@item set remote read-aux-vector-packet
12164@cindex auxiliary vector of remote target
12165@cindex @code{auxv}, and remote targets
12166Set the use of the remote protocol's @samp{qPart:auxv:read} (target
12167auxiliary vector read) request. This request is used to fetch the
721c2651
EZ
12168remote target's @dfn{auxiliary vector}, see @ref{OS Information,
12169Auxiliary Vector}. The default setting depends on the remote stub's
12170support of this request (@value{GDBN} queries the stub when this
12171request is first required). @xref{General Query Packets, qPart}, for
12172more information about this request.
9c16f35a
EZ
12173
12174@item show remote read-aux-vector-packet
12175Show the current setting of use of the @samp{qPart:auxv:read} request.
12176
12177@item set remote symbol-lookup-packet
12178@cindex remote symbol lookup request
12179Set the use of the remote protocol's @samp{qSymbol} (target symbol
12180lookup) request. This request is used to communicate symbol
12181information to the remote target, e.g., whenever a new shared library
12182is loaded by the remote (@pxref{Files, shared libraries}). The
12183default setting depends on the remote stub's support of this request
12184(@value{GDBN} queries the stub when this request is first required).
12185@xref{General Query Packets, qSymbol}, for more information about this
12186request.
12187
12188@item show remote symbol-lookup-packet
12189Show the current setting of use of the @samp{qSymbol} request.
12190
12191@item set remote verbose-resume-packet
12192@cindex resume remote target
12193@cindex signal thread, and remote targets
12194@cindex single-step thread, and remote targets
12195@cindex thread-specific operations on remote targets
12196Set the use of the remote protocol's @samp{vCont} (descriptive resume)
12197request. This request is used to resume specific threads in the
12198remote target, and to single-step or signal them. The default setting
12199depends on the remote stub's support of this request (@value{GDBN}
12200queries the stub when this request is first required). This setting
12201affects debugging of multithreaded programs: if @samp{vCont} cannot be
12202used, @value{GDBN} might be unable to single-step a specific thread,
12203especially under @code{set scheduler-locking off}; it is also
12204impossible to pause a specific thread. @xref{Packets, vCont}, for
12205more details.
12206
12207@item show remote verbose-resume-packet
12208Show the current setting of use of the @samp{vCont} request
12209
12210@item set remote software-breakpoint-packet
12211@itemx set remote hardware-breakpoint-packet
12212@itemx set remote write-watchpoint-packet
12213@itemx set remote read-watchpoint-packet
12214@itemx set remote access-watchpoint-packet
12215@itemx set remote Z-packet
12216@cindex Z-packet
12217@cindex remote hardware breakpoints and watchpoints
12218These commands enable or disable the use of @samp{Z} packets for
12219setting breakpoints and watchpoints in the remote target. The default
12220depends on the remote stub's support of the @samp{Z} packets
12221(@value{GDBN} queries the stub when each packet is first required).
12222The command @code{set remote Z-packet}, kept for back-compatibility,
12223turns on or off all the features that require the use of @samp{Z}
12224packets.
12225
12226@item show remote software-breakpoint-packet
12227@itemx show remote hardware-breakpoint-packet
12228@itemx show remote write-watchpoint-packet
12229@itemx show remote read-watchpoint-packet
12230@itemx show remote access-watchpoint-packet
12231@itemx show remote Z-packet
12232Show the current setting of @samp{Z} packets usage.
0abb7bc7
EZ
12233
12234@item set remote get-thread-local-storage-address
12235@kindex set remote get-thread-local-storage-address
12236@cindex thread local storage of remote targets
12237This command enables or disables the use of the @samp{qGetTLSAddr}
12238(Get Thread Local Storage Address) request packet. The default
12239depends on whether the remote stub supports this request.
12240@xref{General Query Packets, qGetTLSAddr}, for more details about this
12241packet.
12242
12243@item show remote get-thread-local-storage-address
12244@kindex show remote get-thread-local-storage-address
12245Show the current setting of @samp{qGetTLSAddr} packet usage.
501eef12
AC
12246@end table
12247
6f05cf9f
AC
12248@node remote stub
12249@section Implementing a remote stub
7a292a7a 12250
8e04817f
AC
12251@cindex debugging stub, example
12252@cindex remote stub, example
12253@cindex stub example, remote debugging
12254The stub files provided with @value{GDBN} implement the target side of the
12255communication protocol, and the @value{GDBN} side is implemented in the
12256@value{GDBN} source file @file{remote.c}. Normally, you can simply allow
12257these subroutines to communicate, and ignore the details. (If you're
12258implementing your own stub file, you can still ignore the details: start
12259with one of the existing stub files. @file{sparc-stub.c} is the best
12260organized, and therefore the easiest to read.)
12261
104c1213
JM
12262@cindex remote serial debugging, overview
12263To debug a program running on another machine (the debugging
12264@dfn{target} machine), you must first arrange for all the usual
12265prerequisites for the program to run by itself. For example, for a C
12266program, you need:
c906108c 12267
104c1213
JM
12268@enumerate
12269@item
12270A startup routine to set up the C runtime environment; these usually
12271have a name like @file{crt0}. The startup routine may be supplied by
12272your hardware supplier, or you may have to write your own.
96baa820 12273
5d161b24 12274@item
d4f3574e 12275A C subroutine library to support your program's
104c1213 12276subroutine calls, notably managing input and output.
96baa820 12277
104c1213
JM
12278@item
12279A way of getting your program to the other machine---for example, a
12280download program. These are often supplied by the hardware
12281manufacturer, but you may have to write your own from hardware
12282documentation.
12283@end enumerate
96baa820 12284
104c1213
JM
12285The next step is to arrange for your program to use a serial port to
12286communicate with the machine where @value{GDBN} is running (the @dfn{host}
12287machine). In general terms, the scheme looks like this:
96baa820 12288
104c1213
JM
12289@table @emph
12290@item On the host,
12291@value{GDBN} already understands how to use this protocol; when everything
12292else is set up, you can simply use the @samp{target remote} command
12293(@pxref{Targets,,Specifying a Debugging Target}).
12294
12295@item On the target,
12296you must link with your program a few special-purpose subroutines that
12297implement the @value{GDBN} remote serial protocol. The file containing these
12298subroutines is called a @dfn{debugging stub}.
12299
12300On certain remote targets, you can use an auxiliary program
12301@code{gdbserver} instead of linking a stub into your program.
12302@xref{Server,,Using the @code{gdbserver} program}, for details.
12303@end table
96baa820 12304
104c1213
JM
12305The debugging stub is specific to the architecture of the remote
12306machine; for example, use @file{sparc-stub.c} to debug programs on
12307@sc{sparc} boards.
96baa820 12308
104c1213
JM
12309@cindex remote serial stub list
12310These working remote stubs are distributed with @value{GDBN}:
96baa820 12311
104c1213
JM
12312@table @code
12313
12314@item i386-stub.c
41afff9a 12315@cindex @file{i386-stub.c}
104c1213
JM
12316@cindex Intel
12317@cindex i386
12318For Intel 386 and compatible architectures.
12319
12320@item m68k-stub.c
41afff9a 12321@cindex @file{m68k-stub.c}
104c1213
JM
12322@cindex Motorola 680x0
12323@cindex m680x0
12324For Motorola 680x0 architectures.
12325
12326@item sh-stub.c
41afff9a 12327@cindex @file{sh-stub.c}
172c2a43 12328@cindex Renesas
104c1213 12329@cindex SH
172c2a43 12330For Renesas SH architectures.
104c1213
JM
12331
12332@item sparc-stub.c
41afff9a 12333@cindex @file{sparc-stub.c}
104c1213
JM
12334@cindex Sparc
12335For @sc{sparc} architectures.
12336
12337@item sparcl-stub.c
41afff9a 12338@cindex @file{sparcl-stub.c}
104c1213
JM
12339@cindex Fujitsu
12340@cindex SparcLite
12341For Fujitsu @sc{sparclite} architectures.
12342
12343@end table
12344
12345The @file{README} file in the @value{GDBN} distribution may list other
12346recently added stubs.
12347
12348@menu
12349* Stub Contents:: What the stub can do for you
12350* Bootstrapping:: What you must do for the stub
12351* Debug Session:: Putting it all together
104c1213
JM
12352@end menu
12353
6d2ebf8b 12354@node Stub Contents
6f05cf9f 12355@subsection What the stub can do for you
104c1213
JM
12356
12357@cindex remote serial stub
12358The debugging stub for your architecture supplies these three
12359subroutines:
12360
12361@table @code
12362@item set_debug_traps
4644b6e3 12363@findex set_debug_traps
104c1213
JM
12364@cindex remote serial stub, initialization
12365This routine arranges for @code{handle_exception} to run when your
12366program stops. You must call this subroutine explicitly near the
12367beginning of your program.
12368
12369@item handle_exception
4644b6e3 12370@findex handle_exception
104c1213
JM
12371@cindex remote serial stub, main routine
12372This is the central workhorse, but your program never calls it
12373explicitly---the setup code arranges for @code{handle_exception} to
12374run when a trap is triggered.
12375
12376@code{handle_exception} takes control when your program stops during
12377execution (for example, on a breakpoint), and mediates communications
12378with @value{GDBN} on the host machine. This is where the communications
12379protocol is implemented; @code{handle_exception} acts as the @value{GDBN}
d4f3574e 12380representative on the target machine. It begins by sending summary
104c1213
JM
12381information on the state of your program, then continues to execute,
12382retrieving and transmitting any information @value{GDBN} needs, until you
12383execute a @value{GDBN} command that makes your program resume; at that point,
12384@code{handle_exception} returns control to your own code on the target
5d161b24 12385machine.
104c1213
JM
12386
12387@item breakpoint
12388@cindex @code{breakpoint} subroutine, remote
12389Use this auxiliary subroutine to make your program contain a
12390breakpoint. Depending on the particular situation, this may be the only
12391way for @value{GDBN} to get control. For instance, if your target
12392machine has some sort of interrupt button, you won't need to call this;
12393pressing the interrupt button transfers control to
12394@code{handle_exception}---in effect, to @value{GDBN}. On some machines,
12395simply receiving characters on the serial port may also trigger a trap;
12396again, in that situation, you don't need to call @code{breakpoint} from
12397your own program---simply running @samp{target remote} from the host
5d161b24 12398@value{GDBN} session gets control.
104c1213
JM
12399
12400Call @code{breakpoint} if none of these is true, or if you simply want
12401to make certain your program stops at a predetermined point for the
12402start of your debugging session.
12403@end table
12404
6d2ebf8b 12405@node Bootstrapping
6f05cf9f 12406@subsection What you must do for the stub
104c1213
JM
12407
12408@cindex remote stub, support routines
12409The debugging stubs that come with @value{GDBN} are set up for a particular
12410chip architecture, but they have no information about the rest of your
12411debugging target machine.
12412
12413First of all you need to tell the stub how to communicate with the
12414serial port.
12415
12416@table @code
12417@item int getDebugChar()
4644b6e3 12418@findex getDebugChar
104c1213
JM
12419Write this subroutine to read a single character from the serial port.
12420It may be identical to @code{getchar} for your target system; a
12421different name is used to allow you to distinguish the two if you wish.
12422
12423@item void putDebugChar(int)
4644b6e3 12424@findex putDebugChar
104c1213 12425Write this subroutine to write a single character to the serial port.
5d161b24 12426It may be identical to @code{putchar} for your target system; a
104c1213
JM
12427different name is used to allow you to distinguish the two if you wish.
12428@end table
12429
12430@cindex control C, and remote debugging
12431@cindex interrupting remote targets
12432If you want @value{GDBN} to be able to stop your program while it is
12433running, you need to use an interrupt-driven serial driver, and arrange
12434for it to stop when it receives a @code{^C} (@samp{\003}, the control-C
12435character). That is the character which @value{GDBN} uses to tell the
12436remote system to stop.
12437
12438Getting the debugging target to return the proper status to @value{GDBN}
12439probably requires changes to the standard stub; one quick and dirty way
12440is to just execute a breakpoint instruction (the ``dirty'' part is that
12441@value{GDBN} reports a @code{SIGTRAP} instead of a @code{SIGINT}).
12442
12443Other routines you need to supply are:
12444
12445@table @code
12446@item void exceptionHandler (int @var{exception_number}, void *@var{exception_address})
4644b6e3 12447@findex exceptionHandler
104c1213
JM
12448Write this function to install @var{exception_address} in the exception
12449handling tables. You need to do this because the stub does not have any
12450way of knowing what the exception handling tables on your target system
12451are like (for example, the processor's table might be in @sc{rom},
12452containing entries which point to a table in @sc{ram}).
12453@var{exception_number} is the exception number which should be changed;
12454its meaning is architecture-dependent (for example, different numbers
12455might represent divide by zero, misaligned access, etc). When this
12456exception occurs, control should be transferred directly to
12457@var{exception_address}, and the processor state (stack, registers,
12458and so on) should be just as it is when a processor exception occurs. So if
12459you want to use a jump instruction to reach @var{exception_address}, it
12460should be a simple jump, not a jump to subroutine.
12461
12462For the 386, @var{exception_address} should be installed as an interrupt
12463gate so that interrupts are masked while the handler runs. The gate
12464should be at privilege level 0 (the most privileged level). The
12465@sc{sparc} and 68k stubs are able to mask interrupts themselves without
12466help from @code{exceptionHandler}.
12467
12468@item void flush_i_cache()
4644b6e3 12469@findex flush_i_cache
d4f3574e 12470On @sc{sparc} and @sc{sparclite} only, write this subroutine to flush the
104c1213
JM
12471instruction cache, if any, on your target machine. If there is no
12472instruction cache, this subroutine may be a no-op.
12473
12474On target machines that have instruction caches, @value{GDBN} requires this
12475function to make certain that the state of your program is stable.
12476@end table
12477
12478@noindent
12479You must also make sure this library routine is available:
12480
12481@table @code
12482@item void *memset(void *, int, int)
4644b6e3 12483@findex memset
104c1213
JM
12484This is the standard library function @code{memset} that sets an area of
12485memory to a known value. If you have one of the free versions of
12486@code{libc.a}, @code{memset} can be found there; otherwise, you must
12487either obtain it from your hardware manufacturer, or write your own.
12488@end table
12489
12490If you do not use the GNU C compiler, you may need other standard
12491library subroutines as well; this varies from one stub to another,
12492but in general the stubs are likely to use any of the common library
d4f3574e 12493subroutines which @code{@value{GCC}} generates as inline code.
104c1213
JM
12494
12495
6d2ebf8b 12496@node Debug Session
6f05cf9f 12497@subsection Putting it all together
104c1213
JM
12498
12499@cindex remote serial debugging summary
12500In summary, when your program is ready to debug, you must follow these
12501steps.
12502
12503@enumerate
12504@item
6d2ebf8b 12505Make sure you have defined the supporting low-level routines
104c1213
JM
12506(@pxref{Bootstrapping,,What you must do for the stub}):
12507@display
12508@code{getDebugChar}, @code{putDebugChar},
12509@code{flush_i_cache}, @code{memset}, @code{exceptionHandler}.
12510@end display
12511
12512@item
12513Insert these lines near the top of your program:
12514
474c8240 12515@smallexample
104c1213
JM
12516set_debug_traps();
12517breakpoint();
474c8240 12518@end smallexample
104c1213
JM
12519
12520@item
12521For the 680x0 stub only, you need to provide a variable called
12522@code{exceptionHook}. Normally you just use:
12523
474c8240 12524@smallexample
104c1213 12525void (*exceptionHook)() = 0;
474c8240 12526@end smallexample
104c1213 12527
d4f3574e 12528@noindent
104c1213 12529but if before calling @code{set_debug_traps}, you set it to point to a
598ca718 12530function in your program, that function is called when
104c1213
JM
12531@code{@value{GDBN}} continues after stopping on a trap (for example, bus
12532error). The function indicated by @code{exceptionHook} is called with
12533one parameter: an @code{int} which is the exception number.
12534
12535@item
12536Compile and link together: your program, the @value{GDBN} debugging stub for
12537your target architecture, and the supporting subroutines.
12538
12539@item
12540Make sure you have a serial connection between your target machine and
12541the @value{GDBN} host, and identify the serial port on the host.
12542
12543@item
12544@c The "remote" target now provides a `load' command, so we should
12545@c document that. FIXME.
12546Download your program to your target machine (or get it there by
12547whatever means the manufacturer provides), and start it.
12548
12549@item
07f31aa6
DJ
12550Start @value{GDBN} on the host, and connect to the target
12551(@pxref{Connecting,,Connecting to a remote target}).
9db8d71f 12552
104c1213
JM
12553@end enumerate
12554
8e04817f
AC
12555@node Configurations
12556@chapter Configuration-Specific Information
104c1213 12557
8e04817f
AC
12558While nearly all @value{GDBN} commands are available for all native and
12559cross versions of the debugger, there are some exceptions. This chapter
12560describes things that are only available in certain configurations.
104c1213 12561
8e04817f
AC
12562There are three major categories of configurations: native
12563configurations, where the host and target are the same, embedded
12564operating system configurations, which are usually the same for several
12565different processor architectures, and bare embedded processors, which
12566are quite different from each other.
104c1213 12567
8e04817f
AC
12568@menu
12569* Native::
12570* Embedded OS::
12571* Embedded Processors::
12572* Architectures::
12573@end menu
104c1213 12574
8e04817f
AC
12575@node Native
12576@section Native
104c1213 12577
8e04817f
AC
12578This section describes details specific to particular native
12579configurations.
6cf7e474 12580
8e04817f
AC
12581@menu
12582* HP-UX:: HP-UX
7561d450 12583* BSD libkvm Interface:: Debugging BSD kernel memory images
8e04817f
AC
12584* SVR4 Process Information:: SVR4 process information
12585* DJGPP Native:: Features specific to the DJGPP port
78c47bea 12586* Cygwin Native:: Features specific to the Cygwin port
14d6dd68 12587* Hurd Native:: Features specific to @sc{gnu} Hurd
a64548ea 12588* Neutrino:: Features specific to QNX Neutrino
8e04817f 12589@end menu
6cf7e474 12590
8e04817f
AC
12591@node HP-UX
12592@subsection HP-UX
104c1213 12593
8e04817f
AC
12594On HP-UX systems, if you refer to a function or variable name that
12595begins with a dollar sign, @value{GDBN} searches for a user or system
12596name first, before it searches for a convenience variable.
104c1213 12597
9c16f35a 12598
7561d450
MK
12599@node BSD libkvm Interface
12600@subsection BSD libkvm Interface
12601
12602@cindex libkvm
12603@cindex kernel memory image
12604@cindex kernel crash dump
12605
12606BSD-derived systems (FreeBSD/NetBSD/OpenBSD) have a kernel memory
12607interface that provides a uniform interface for accessing kernel virtual
12608memory images, including live systems and crash dumps. @value{GDBN}
12609uses this interface to allow you to debug live kernels and kernel crash
12610dumps on many native BSD configurations. This is implemented as a
12611special @code{kvm} debugging target. For debugging a live system, load
12612the currently running kernel into @value{GDBN} and connect to the
12613@code{kvm} target:
12614
12615@smallexample
12616(@value{GDBP}) @b{target kvm}
12617@end smallexample
12618
12619For debugging crash dumps, provide the file name of the crash dump as an
12620argument:
12621
12622@smallexample
12623(@value{GDBP}) @b{target kvm /var/crash/bsd.0}
12624@end smallexample
12625
12626Once connected to the @code{kvm} target, the following commands are
12627available:
12628
12629@table @code
12630@kindex kvm
12631@item kvm pcb
721c2651 12632Set current context from the @dfn{Process Control Block} (PCB) address.
7561d450
MK
12633
12634@item kvm proc
12635Set current context from proc address. This command isn't available on
12636modern FreeBSD systems.
12637@end table
12638
8e04817f
AC
12639@node SVR4 Process Information
12640@subsection SVR4 process information
60bf7e09
EZ
12641@cindex /proc
12642@cindex examine process image
12643@cindex process info via @file{/proc}
104c1213 12644
60bf7e09
EZ
12645Many versions of SVR4 and compatible systems provide a facility called
12646@samp{/proc} that can be used to examine the image of a running
12647process using file-system subroutines. If @value{GDBN} is configured
12648for an operating system with this facility, the command @code{info
12649proc} is available to report information about the process running
12650your program, or about any process running on your system. @code{info
12651proc} works only on SVR4 systems that include the @code{procfs} code.
12652This includes, as of this writing, @sc{gnu}/Linux, OSF/1 (Digital
12653Unix), Solaris, Irix, and Unixware, but not HP-UX, for example.
104c1213 12654
8e04817f
AC
12655@table @code
12656@kindex info proc
60bf7e09 12657@cindex process ID
8e04817f 12658@item info proc
60bf7e09
EZ
12659@itemx info proc @var{process-id}
12660Summarize available information about any running process. If a
12661process ID is specified by @var{process-id}, display information about
12662that process; otherwise display information about the program being
12663debugged. The summary includes the debugged process ID, the command
12664line used to invoke it, its current working directory, and its
12665executable file's absolute file name.
12666
12667On some systems, @var{process-id} can be of the form
12668@samp{[@var{pid}]/@var{tid}} which specifies a certain thread ID
12669within a process. If the optional @var{pid} part is missing, it means
12670a thread from the process being debugged (the leading @samp{/} still
12671needs to be present, or else @value{GDBN} will interpret the number as
12672a process ID rather than a thread ID).
6cf7e474 12673
8e04817f 12674@item info proc mappings
60bf7e09
EZ
12675@cindex memory address space mappings
12676Report the memory address space ranges accessible in the program, with
12677information on whether the process has read, write, or execute access
12678rights to each range. On @sc{gnu}/Linux systems, each memory range
12679includes the object file which is mapped to that range, instead of the
12680memory access rights to that range.
12681
12682@item info proc stat
12683@itemx info proc status
12684@cindex process detailed status information
12685These subcommands are specific to @sc{gnu}/Linux systems. They show
12686the process-related information, including the user ID and group ID;
12687how many threads are there in the process; its virtual memory usage;
12688the signals that are pending, blocked, and ignored; its TTY; its
12689consumption of system and user time; its stack size; its @samp{nice}
2eecc4ab 12690value; etc. For more information, see the @samp{proc} man page
60bf7e09
EZ
12691(type @kbd{man 5 proc} from your shell prompt).
12692
12693@item info proc all
12694Show all the information about the process described under all of the
12695above @code{info proc} subcommands.
12696
8e04817f
AC
12697@ignore
12698@comment These sub-options of 'info proc' were not included when
12699@comment procfs.c was re-written. Keep their descriptions around
12700@comment against the day when someone finds the time to put them back in.
12701@kindex info proc times
12702@item info proc times
12703Starting time, user CPU time, and system CPU time for your program and
12704its children.
6cf7e474 12705
8e04817f
AC
12706@kindex info proc id
12707@item info proc id
12708Report on the process IDs related to your program: its own process ID,
12709the ID of its parent, the process group ID, and the session ID.
8e04817f 12710@end ignore
721c2651
EZ
12711
12712@item set procfs-trace
12713@kindex set procfs-trace
12714@cindex @code{procfs} API calls
12715This command enables and disables tracing of @code{procfs} API calls.
12716
12717@item show procfs-trace
12718@kindex show procfs-trace
12719Show the current state of @code{procfs} API call tracing.
12720
12721@item set procfs-file @var{file}
12722@kindex set procfs-file
12723Tell @value{GDBN} to write @code{procfs} API trace to the named
12724@var{file}. @value{GDBN} appends the trace info to the previous
12725contents of the file. The default is to display the trace on the
12726standard output.
12727
12728@item show procfs-file
12729@kindex show procfs-file
12730Show the file to which @code{procfs} API trace is written.
12731
12732@item proc-trace-entry
12733@itemx proc-trace-exit
12734@itemx proc-untrace-entry
12735@itemx proc-untrace-exit
12736@kindex proc-trace-entry
12737@kindex proc-trace-exit
12738@kindex proc-untrace-entry
12739@kindex proc-untrace-exit
12740These commands enable and disable tracing of entries into and exits
12741from the @code{syscall} interface.
12742
12743@item info pidlist
12744@kindex info pidlist
12745@cindex process list, QNX Neutrino
12746For QNX Neutrino only, this command displays the list of all the
12747processes and all the threads within each process.
12748
12749@item info meminfo
12750@kindex info meminfo
12751@cindex mapinfo list, QNX Neutrino
12752For QNX Neutrino only, this command displays the list of all mapinfos.
8e04817f 12753@end table
104c1213 12754
8e04817f
AC
12755@node DJGPP Native
12756@subsection Features for Debugging @sc{djgpp} Programs
12757@cindex @sc{djgpp} debugging
12758@cindex native @sc{djgpp} debugging
12759@cindex MS-DOS-specific commands
104c1213 12760
514c4d71
EZ
12761@cindex DPMI
12762@sc{djgpp} is a port of the @sc{gnu} development tools to MS-DOS and
8e04817f
AC
12763MS-Windows. @sc{djgpp} programs are 32-bit protected-mode programs
12764that use the @dfn{DPMI} (DOS Protected-Mode Interface) API to run on
12765top of real-mode DOS systems and their emulations.
104c1213 12766
8e04817f
AC
12767@value{GDBN} supports native debugging of @sc{djgpp} programs, and
12768defines a few commands specific to the @sc{djgpp} port. This
12769subsection describes those commands.
104c1213 12770
8e04817f
AC
12771@table @code
12772@kindex info dos
12773@item info dos
12774This is a prefix of @sc{djgpp}-specific commands which print
12775information about the target system and important OS structures.
f1251bdd 12776
8e04817f
AC
12777@kindex sysinfo
12778@cindex MS-DOS system info
12779@cindex free memory information (MS-DOS)
12780@item info dos sysinfo
12781This command displays assorted information about the underlying
12782platform: the CPU type and features, the OS version and flavor, the
12783DPMI version, and the available conventional and DPMI memory.
104c1213 12784
8e04817f
AC
12785@cindex GDT
12786@cindex LDT
12787@cindex IDT
12788@cindex segment descriptor tables
12789@cindex descriptor tables display
12790@item info dos gdt
12791@itemx info dos ldt
12792@itemx info dos idt
12793These 3 commands display entries from, respectively, Global, Local,
12794and Interrupt Descriptor Tables (GDT, LDT, and IDT). The descriptor
12795tables are data structures which store a descriptor for each segment
12796that is currently in use. The segment's selector is an index into a
12797descriptor table; the table entry for that index holds the
12798descriptor's base address and limit, and its attributes and access
12799rights.
104c1213 12800
8e04817f
AC
12801A typical @sc{djgpp} program uses 3 segments: a code segment, a data
12802segment (used for both data and the stack), and a DOS segment (which
12803allows access to DOS/BIOS data structures and absolute addresses in
12804conventional memory). However, the DPMI host will usually define
12805additional segments in order to support the DPMI environment.
d4f3574e 12806
8e04817f
AC
12807@cindex garbled pointers
12808These commands allow to display entries from the descriptor tables.
12809Without an argument, all entries from the specified table are
12810displayed. An argument, which should be an integer expression, means
12811display a single entry whose index is given by the argument. For
12812example, here's a convenient way to display information about the
12813debugged program's data segment:
104c1213 12814
8e04817f
AC
12815@smallexample
12816@exdent @code{(@value{GDBP}) info dos ldt $ds}
12817@exdent @code{0x13f: base=0x11970000 limit=0x0009ffff 32-Bit Data (Read/Write, Exp-up)}
12818@end smallexample
104c1213 12819
8e04817f
AC
12820@noindent
12821This comes in handy when you want to see whether a pointer is outside
12822the data segment's limit (i.e.@: @dfn{garbled}).
104c1213 12823
8e04817f
AC
12824@cindex page tables display (MS-DOS)
12825@item info dos pde
12826@itemx info dos pte
12827These two commands display entries from, respectively, the Page
12828Directory and the Page Tables. Page Directories and Page Tables are
12829data structures which control how virtual memory addresses are mapped
12830into physical addresses. A Page Table includes an entry for every
12831page of memory that is mapped into the program's address space; there
12832may be several Page Tables, each one holding up to 4096 entries. A
12833Page Directory has up to 4096 entries, one each for every Page Table
12834that is currently in use.
104c1213 12835
8e04817f
AC
12836Without an argument, @kbd{info dos pde} displays the entire Page
12837Directory, and @kbd{info dos pte} displays all the entries in all of
12838the Page Tables. An argument, an integer expression, given to the
12839@kbd{info dos pde} command means display only that entry from the Page
12840Directory table. An argument given to the @kbd{info dos pte} command
12841means display entries from a single Page Table, the one pointed to by
12842the specified entry in the Page Directory.
104c1213 12843
8e04817f
AC
12844@cindex direct memory access (DMA) on MS-DOS
12845These commands are useful when your program uses @dfn{DMA} (Direct
12846Memory Access), which needs physical addresses to program the DMA
12847controller.
104c1213 12848
8e04817f 12849These commands are supported only with some DPMI servers.
104c1213 12850
8e04817f
AC
12851@cindex physical address from linear address
12852@item info dos address-pte @var{addr}
12853This command displays the Page Table entry for a specified linear
514c4d71
EZ
12854address. The argument @var{addr} is a linear address which should
12855already have the appropriate segment's base address added to it,
12856because this command accepts addresses which may belong to @emph{any}
12857segment. For example, here's how to display the Page Table entry for
12858the page where a variable @code{i} is stored:
104c1213 12859
b383017d 12860@smallexample
8e04817f
AC
12861@exdent @code{(@value{GDBP}) info dos address-pte __djgpp_base_address + (char *)&i}
12862@exdent @code{Page Table entry for address 0x11a00d30:}
b383017d 12863@exdent @code{Base=0x02698000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0xd30}
8e04817f 12864@end smallexample
104c1213 12865
8e04817f
AC
12866@noindent
12867This says that @code{i} is stored at offset @code{0xd30} from the page
514c4d71 12868whose physical base address is @code{0x02698000}, and shows all the
8e04817f 12869attributes of that page.
104c1213 12870
8e04817f
AC
12871Note that you must cast the addresses of variables to a @code{char *},
12872since otherwise the value of @code{__djgpp_base_address}, the base
12873address of all variables and functions in a @sc{djgpp} program, will
12874be added using the rules of C pointer arithmetics: if @code{i} is
12875declared an @code{int}, @value{GDBN} will add 4 times the value of
12876@code{__djgpp_base_address} to the address of @code{i}.
104c1213 12877
8e04817f
AC
12878Here's another example, it displays the Page Table entry for the
12879transfer buffer:
104c1213 12880
8e04817f
AC
12881@smallexample
12882@exdent @code{(@value{GDBP}) info dos address-pte *((unsigned *)&_go32_info_block + 3)}
12883@exdent @code{Page Table entry for address 0x29110:}
12884@exdent @code{Base=0x00029000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0x110}
12885@end smallexample
104c1213 12886
8e04817f
AC
12887@noindent
12888(The @code{+ 3} offset is because the transfer buffer's address is the
514c4d71
EZ
128893rd member of the @code{_go32_info_block} structure.) The output
12890clearly shows that this DPMI server maps the addresses in conventional
12891memory 1:1, i.e.@: the physical (@code{0x00029000} + @code{0x110}) and
12892linear (@code{0x29110}) addresses are identical.
104c1213 12893
8e04817f
AC
12894This command is supported only with some DPMI servers.
12895@end table
104c1213 12896
c45da7e6 12897@cindex DOS serial data link, remote debugging
a8f24a35
EZ
12898In addition to native debugging, the DJGPP port supports remote
12899debugging via a serial data link. The following commands are specific
12900to remote serial debugging in the DJGPP port of @value{GDBN}.
12901
12902@table @code
12903@kindex set com1base
12904@kindex set com1irq
12905@kindex set com2base
12906@kindex set com2irq
12907@kindex set com3base
12908@kindex set com3irq
12909@kindex set com4base
12910@kindex set com4irq
12911@item set com1base @var{addr}
12912This command sets the base I/O port address of the @file{COM1} serial
12913port.
12914
12915@item set com1irq @var{irq}
12916This command sets the @dfn{Interrupt Request} (@code{IRQ}) line to use
12917for the @file{COM1} serial port.
12918
12919There are similar commands @samp{set com2base}, @samp{set com3irq},
12920etc.@: for setting the port address and the @code{IRQ} lines for the
12921other 3 COM ports.
12922
12923@kindex show com1base
12924@kindex show com1irq
12925@kindex show com2base
12926@kindex show com2irq
12927@kindex show com3base
12928@kindex show com3irq
12929@kindex show com4base
12930@kindex show com4irq
12931The related commands @samp{show com1base}, @samp{show com1irq} etc.@:
12932display the current settings of the base address and the @code{IRQ}
12933lines used by the COM ports.
c45da7e6
EZ
12934
12935@item info serial
12936@kindex info serial
12937@cindex DOS serial port status
12938This command prints the status of the 4 DOS serial ports. For each
12939port, it prints whether it's active or not, its I/O base address and
12940IRQ number, whether it uses a 16550-style FIFO, its baudrate, and the
12941counts of various errors encountered so far.
a8f24a35
EZ
12942@end table
12943
12944
78c47bea
PM
12945@node Cygwin Native
12946@subsection Features for Debugging MS Windows PE executables
12947@cindex MS Windows debugging
12948@cindex native Cygwin debugging
12949@cindex Cygwin-specific commands
12950
be448670
CF
12951@value{GDBN} supports native debugging of MS Windows programs, including
12952DLLs with and without symbolic debugging information. There are various
12953additional Cygwin-specific commands, described in this subsection. The
12954subsubsection @pxref{Non-debug DLL symbols} describes working with DLLs
12955that have no debugging symbols.
12956
78c47bea
PM
12957
12958@table @code
12959@kindex info w32
12960@item info w32
12961This is a prefix of MS Windows specific commands which print
12962information about the target system and important OS structures.
12963
12964@item info w32 selector
12965This command displays information returned by
12966the Win32 API @code{GetThreadSelectorEntry} function.
12967It takes an optional argument that is evaluated to
12968a long value to give the information about this given selector.
12969Without argument, this command displays information
12970about the the six segment registers.
12971
12972@kindex info dll
12973@item info dll
12974This is a Cygwin specific alias of info shared.
12975
12976@kindex dll-symbols
12977@item dll-symbols
12978This command loads symbols from a dll similarly to
12979add-sym command but without the need to specify a base address.
12980
b383017d 12981@kindex set new-console
78c47bea 12982@item set new-console @var{mode}
b383017d 12983If @var{mode} is @code{on} the debuggee will
78c47bea
PM
12984be started in a new console on next start.
12985If @var{mode} is @code{off}i, the debuggee will
12986be started in the same console as the debugger.
12987
12988@kindex show new-console
12989@item show new-console
12990Displays whether a new console is used
12991when the debuggee is started.
12992
12993@kindex set new-group
12994@item set new-group @var{mode}
12995This boolean value controls whether the debuggee should
12996start a new group or stay in the same group as the debugger.
12997This affects the way the Windows OS handles
12998Ctrl-C.
12999
13000@kindex show new-group
13001@item show new-group
13002Displays current value of new-group boolean.
13003
13004@kindex set debugevents
13005@item set debugevents
13006This boolean value adds debug output concerning events seen by the debugger.
13007
13008@kindex set debugexec
13009@item set debugexec
b383017d 13010This boolean value adds debug output concerning execute events
78c47bea
PM
13011seen by the debugger.
13012
13013@kindex set debugexceptions
13014@item set debugexceptions
b383017d 13015This boolean value adds debug ouptut concerning exception events
78c47bea
PM
13016seen by the debugger.
13017
13018@kindex set debugmemory
13019@item set debugmemory
b383017d 13020This boolean value adds debug ouptut concerning memory events
78c47bea
PM
13021seen by the debugger.
13022
13023@kindex set shell
13024@item set shell
13025This boolean values specifies whether the debuggee is called
13026via a shell or directly (default value is on).
13027
13028@kindex show shell
13029@item show shell
13030Displays if the debuggee will be started with a shell.
13031
13032@end table
13033
be448670
CF
13034@menu
13035* Non-debug DLL symbols:: Support for DLLs without debugging symbols
13036@end menu
13037
13038@node Non-debug DLL symbols
13039@subsubsection Support for DLLs without debugging symbols
13040@cindex DLLs with no debugging symbols
13041@cindex Minimal symbols and DLLs
13042
13043Very often on windows, some of the DLLs that your program relies on do
13044not include symbolic debugging information (for example,
13045@file{kernel32.dll}). When @value{GDBN} doesn't recognize any debugging
13046symbols in a DLL, it relies on the minimal amount of symbolic
13047information contained in the DLL's export table. This subsubsection
13048describes working with such symbols, known internally to @value{GDBN} as
13049``minimal symbols''.
13050
13051Note that before the debugged program has started execution, no DLLs
13052will have been loaded. The easiest way around this problem is simply to
13053start the program --- either by setting a breakpoint or letting the
13054program run once to completion. It is also possible to force
13055@value{GDBN} to load a particular DLL before starting the executable ---
13056see the shared library information in @pxref{Files} or the
13057@code{dll-symbols} command in @pxref{Cygwin Native}. Currently,
13058explicitly loading symbols from a DLL with no debugging information will
13059cause the symbol names to be duplicated in @value{GDBN}'s lookup table,
13060which may adversely affect symbol lookup performance.
13061
13062@subsubsection DLL name prefixes
13063
13064In keeping with the naming conventions used by the Microsoft debugging
13065tools, DLL export symbols are made available with a prefix based on the
13066DLL name, for instance @code{KERNEL32!CreateFileA}. The plain name is
13067also entered into the symbol table, so @code{CreateFileA} is often
13068sufficient. In some cases there will be name clashes within a program
13069(particularly if the executable itself includes full debugging symbols)
13070necessitating the use of the fully qualified name when referring to the
13071contents of the DLL. Use single-quotes around the name to avoid the
13072exclamation mark (``!'') being interpreted as a language operator.
13073
13074Note that the internal name of the DLL may be all upper-case, even
13075though the file name of the DLL is lower-case, or vice-versa. Since
13076symbols within @value{GDBN} are @emph{case-sensitive} this may cause
13077some confusion. If in doubt, try the @code{info functions} and
13078@code{info variables} commands or even @code{maint print msymbols} (see
13079@pxref{Symbols}). Here's an example:
13080
13081@smallexample
f7dc1244 13082(@value{GDBP}) info function CreateFileA
be448670
CF
13083All functions matching regular expression "CreateFileA":
13084
13085Non-debugging symbols:
130860x77e885f4 CreateFileA
130870x77e885f4 KERNEL32!CreateFileA
13088@end smallexample
13089
13090@smallexample
f7dc1244 13091(@value{GDBP}) info function !
be448670
CF
13092All functions matching regular expression "!":
13093
13094Non-debugging symbols:
130950x6100114c cygwin1!__assert
130960x61004034 cygwin1!_dll_crt0@@0
130970x61004240 cygwin1!dll_crt0(per_process *)
13098[etc...]
13099@end smallexample
13100
13101@subsubsection Working with minimal symbols
13102
13103Symbols extracted from a DLL's export table do not contain very much
13104type information. All that @value{GDBN} can do is guess whether a symbol
13105refers to a function or variable depending on the linker section that
13106contains the symbol. Also note that the actual contents of the memory
13107contained in a DLL are not available unless the program is running. This
13108means that you cannot examine the contents of a variable or disassemble
13109a function within a DLL without a running program.
13110
13111Variables are generally treated as pointers and dereferenced
13112automatically. For this reason, it is often necessary to prefix a
13113variable name with the address-of operator (``&'') and provide explicit
13114type information in the command. Here's an example of the type of
13115problem:
13116
13117@smallexample
f7dc1244 13118(@value{GDBP}) print 'cygwin1!__argv'
be448670
CF
13119$1 = 268572168
13120@end smallexample
13121
13122@smallexample
f7dc1244 13123(@value{GDBP}) x 'cygwin1!__argv'
be448670
CF
131240x10021610: "\230y\""
13125@end smallexample
13126
13127And two possible solutions:
13128
13129@smallexample
f7dc1244 13130(@value{GDBP}) print ((char **)'cygwin1!__argv')[0]
be448670
CF
13131$2 = 0x22fd98 "/cygdrive/c/mydirectory/myprogram"
13132@end smallexample
13133
13134@smallexample
f7dc1244 13135(@value{GDBP}) x/2x &'cygwin1!__argv'
be448670 131360x610c0aa8 <cygwin1!__argv>: 0x10021608 0x00000000
f7dc1244 13137(@value{GDBP}) x/x 0x10021608
be448670 131380x10021608: 0x0022fd98
f7dc1244 13139(@value{GDBP}) x/s 0x0022fd98
be448670
CF
131400x22fd98: "/cygdrive/c/mydirectory/myprogram"
13141@end smallexample
13142
13143Setting a break point within a DLL is possible even before the program
13144starts execution. However, under these circumstances, @value{GDBN} can't
13145examine the initial instructions of the function in order to skip the
13146function's frame set-up code. You can work around this by using ``*&''
13147to set the breakpoint at a raw memory address:
13148
13149@smallexample
f7dc1244 13150(@value{GDBP}) break *&'python22!PyOS_Readline'
be448670
CF
13151Breakpoint 1 at 0x1e04eff0
13152@end smallexample
13153
13154The author of these extensions is not entirely convinced that setting a
13155break point within a shared DLL like @file{kernel32.dll} is completely
13156safe.
13157
14d6dd68
EZ
13158@node Hurd Native
13159@subsection Commands specific to @sc{gnu} Hurd systems
13160@cindex @sc{gnu} Hurd debugging
13161
13162This subsection describes @value{GDBN} commands specific to the
13163@sc{gnu} Hurd native debugging.
13164
13165@table @code
13166@item set signals
13167@itemx set sigs
13168@kindex set signals@r{, Hurd command}
13169@kindex set sigs@r{, Hurd command}
13170This command toggles the state of inferior signal interception by
13171@value{GDBN}. Mach exceptions, such as breakpoint traps, are not
13172affected by this command. @code{sigs} is a shorthand alias for
13173@code{signals}.
13174
13175@item show signals
13176@itemx show sigs
13177@kindex show signals@r{, Hurd command}
13178@kindex show sigs@r{, Hurd command}
13179Show the current state of intercepting inferior's signals.
13180
13181@item set signal-thread
13182@itemx set sigthread
13183@kindex set signal-thread
13184@kindex set sigthread
13185This command tells @value{GDBN} which thread is the @code{libc} signal
13186thread. That thread is run when a signal is delivered to a running
13187process. @code{set sigthread} is the shorthand alias of @code{set
13188signal-thread}.
13189
13190@item show signal-thread
13191@itemx show sigthread
13192@kindex show signal-thread
13193@kindex show sigthread
13194These two commands show which thread will run when the inferior is
13195delivered a signal.
13196
13197@item set stopped
13198@kindex set stopped@r{, Hurd command}
13199This commands tells @value{GDBN} that the inferior process is stopped,
13200as with the @code{SIGSTOP} signal. The stopped process can be
13201continued by delivering a signal to it.
13202
13203@item show stopped
13204@kindex show stopped@r{, Hurd command}
13205This command shows whether @value{GDBN} thinks the debuggee is
13206stopped.
13207
13208@item set exceptions
13209@kindex set exceptions@r{, Hurd command}
13210Use this command to turn off trapping of exceptions in the inferior.
13211When exception trapping is off, neither breakpoints nor
13212single-stepping will work. To restore the default, set exception
13213trapping on.
13214
13215@item show exceptions
13216@kindex show exceptions@r{, Hurd command}
13217Show the current state of trapping exceptions in the inferior.
13218
13219@item set task pause
13220@kindex set task@r{, Hurd commands}
13221@cindex task attributes (@sc{gnu} Hurd)
13222@cindex pause current task (@sc{gnu} Hurd)
13223This command toggles task suspension when @value{GDBN} has control.
13224Setting it to on takes effect immediately, and the task is suspended
13225whenever @value{GDBN} gets control. Setting it to off will take
13226effect the next time the inferior is continued. If this option is set
13227to off, you can use @code{set thread default pause on} or @code{set
13228thread pause on} (see below) to pause individual threads.
13229
13230@item show task pause
13231@kindex show task@r{, Hurd commands}
13232Show the current state of task suspension.
13233
13234@item set task detach-suspend-count
13235@cindex task suspend count
13236@cindex detach from task, @sc{gnu} Hurd
13237This command sets the suspend count the task will be left with when
13238@value{GDBN} detaches from it.
13239
13240@item show task detach-suspend-count
13241Show the suspend count the task will be left with when detaching.
13242
13243@item set task exception-port
13244@itemx set task excp
13245@cindex task exception port, @sc{gnu} Hurd
13246This command sets the task exception port to which @value{GDBN} will
13247forward exceptions. The argument should be the value of the @dfn{send
13248rights} of the task. @code{set task excp} is a shorthand alias.
13249
13250@item set noninvasive
13251@cindex noninvasive task options
13252This command switches @value{GDBN} to a mode that is the least
13253invasive as far as interfering with the inferior is concerned. This
13254is the same as using @code{set task pause}, @code{set exceptions}, and
13255@code{set signals} to values opposite to the defaults.
13256
13257@item info send-rights
13258@itemx info receive-rights
13259@itemx info port-rights
13260@itemx info port-sets
13261@itemx info dead-names
13262@itemx info ports
13263@itemx info psets
13264@cindex send rights, @sc{gnu} Hurd
13265@cindex receive rights, @sc{gnu} Hurd
13266@cindex port rights, @sc{gnu} Hurd
13267@cindex port sets, @sc{gnu} Hurd
13268@cindex dead names, @sc{gnu} Hurd
13269These commands display information about, respectively, send rights,
13270receive rights, port rights, port sets, and dead names of a task.
13271There are also shorthand aliases: @code{info ports} for @code{info
13272port-rights} and @code{info psets} for @code{info port-sets}.
13273
13274@item set thread pause
13275@kindex set thread@r{, Hurd command}
13276@cindex thread properties, @sc{gnu} Hurd
13277@cindex pause current thread (@sc{gnu} Hurd)
13278This command toggles current thread suspension when @value{GDBN} has
13279control. Setting it to on takes effect immediately, and the current
13280thread is suspended whenever @value{GDBN} gets control. Setting it to
13281off will take effect the next time the inferior is continued.
13282Normally, this command has no effect, since when @value{GDBN} has
13283control, the whole task is suspended. However, if you used @code{set
13284task pause off} (see above), this command comes in handy to suspend
13285only the current thread.
13286
13287@item show thread pause
13288@kindex show thread@r{, Hurd command}
13289This command shows the state of current thread suspension.
13290
13291@item set thread run
13292This comamnd sets whether the current thread is allowed to run.
13293
13294@item show thread run
13295Show whether the current thread is allowed to run.
13296
13297@item set thread detach-suspend-count
13298@cindex thread suspend count, @sc{gnu} Hurd
13299@cindex detach from thread, @sc{gnu} Hurd
13300This command sets the suspend count @value{GDBN} will leave on a
13301thread when detaching. This number is relative to the suspend count
13302found by @value{GDBN} when it notices the thread; use @code{set thread
13303takeover-suspend-count} to force it to an absolute value.
13304
13305@item show thread detach-suspend-count
13306Show the suspend count @value{GDBN} will leave on the thread when
13307detaching.
13308
13309@item set thread exception-port
13310@itemx set thread excp
13311Set the thread exception port to which to forward exceptions. This
13312overrides the port set by @code{set task exception-port} (see above).
13313@code{set thread excp} is the shorthand alias.
13314
13315@item set thread takeover-suspend-count
13316Normally, @value{GDBN}'s thread suspend counts are relative to the
13317value @value{GDBN} finds when it notices each thread. This command
13318changes the suspend counts to be absolute instead.
13319
13320@item set thread default
13321@itemx show thread default
13322@cindex thread default settings, @sc{gnu} Hurd
13323Each of the above @code{set thread} commands has a @code{set thread
13324default} counterpart (e.g., @code{set thread default pause}, @code{set
13325thread default exception-port}, etc.). The @code{thread default}
13326variety of commands sets the default thread properties for all
13327threads; you can then change the properties of individual threads with
13328the non-default commands.
13329@end table
13330
13331
a64548ea
EZ
13332@node Neutrino
13333@subsection QNX Neutrino
13334@cindex QNX Neutrino
13335
13336@value{GDBN} provides the following commands specific to the QNX
13337Neutrino target:
13338
13339@table @code
13340@item set debug nto-debug
13341@kindex set debug nto-debug
13342When set to on, enables debugging messages specific to the QNX
13343Neutrino support.
13344
13345@item show debug nto-debug
13346@kindex show debug nto-debug
13347Show the current state of QNX Neutrino messages.
13348@end table
13349
13350
8e04817f
AC
13351@node Embedded OS
13352@section Embedded Operating Systems
104c1213 13353
8e04817f
AC
13354This section describes configurations involving the debugging of
13355embedded operating systems that are available for several different
13356architectures.
d4f3574e 13357
8e04817f
AC
13358@menu
13359* VxWorks:: Using @value{GDBN} with VxWorks
13360@end menu
104c1213 13361
8e04817f
AC
13362@value{GDBN} includes the ability to debug programs running on
13363various real-time operating systems.
104c1213 13364
8e04817f
AC
13365@node VxWorks
13366@subsection Using @value{GDBN} with VxWorks
104c1213 13367
8e04817f 13368@cindex VxWorks
104c1213 13369
8e04817f 13370@table @code
104c1213 13371
8e04817f
AC
13372@kindex target vxworks
13373@item target vxworks @var{machinename}
13374A VxWorks system, attached via TCP/IP. The argument @var{machinename}
13375is the target system's machine name or IP address.
104c1213 13376
8e04817f 13377@end table
104c1213 13378
8e04817f
AC
13379On VxWorks, @code{load} links @var{filename} dynamically on the
13380current target system as well as adding its symbols in @value{GDBN}.
104c1213 13381
8e04817f
AC
13382@value{GDBN} enables developers to spawn and debug tasks running on networked
13383VxWorks targets from a Unix host. Already-running tasks spawned from
13384the VxWorks shell can also be debugged. @value{GDBN} uses code that runs on
13385both the Unix host and on the VxWorks target. The program
13386@code{@value{GDBP}} is installed and executed on the Unix host. (It may be
13387installed with the name @code{vxgdb}, to distinguish it from a
13388@value{GDBN} for debugging programs on the host itself.)
104c1213 13389
8e04817f
AC
13390@table @code
13391@item VxWorks-timeout @var{args}
13392@kindex vxworks-timeout
13393All VxWorks-based targets now support the option @code{vxworks-timeout}.
13394This option is set by the user, and @var{args} represents the number of
13395seconds @value{GDBN} waits for responses to rpc's. You might use this if
13396your VxWorks target is a slow software simulator or is on the far side
13397of a thin network line.
13398@end table
104c1213 13399
8e04817f
AC
13400The following information on connecting to VxWorks was current when
13401this manual was produced; newer releases of VxWorks may use revised
13402procedures.
104c1213 13403
4644b6e3 13404@findex INCLUDE_RDB
8e04817f
AC
13405To use @value{GDBN} with VxWorks, you must rebuild your VxWorks kernel
13406to include the remote debugging interface routines in the VxWorks
13407library @file{rdb.a}. To do this, define @code{INCLUDE_RDB} in the
13408VxWorks configuration file @file{configAll.h} and rebuild your VxWorks
13409kernel. The resulting kernel contains @file{rdb.a}, and spawns the
13410source debugging task @code{tRdbTask} when VxWorks is booted. For more
13411information on configuring and remaking VxWorks, see the manufacturer's
13412manual.
13413@c VxWorks, see the @cite{VxWorks Programmer's Guide}.
104c1213 13414
8e04817f
AC
13415Once you have included @file{rdb.a} in your VxWorks system image and set
13416your Unix execution search path to find @value{GDBN}, you are ready to
13417run @value{GDBN}. From your Unix host, run @code{@value{GDBP}} (or
13418@code{vxgdb}, depending on your installation).
104c1213 13419
8e04817f 13420@value{GDBN} comes up showing the prompt:
104c1213 13421
474c8240 13422@smallexample
8e04817f 13423(vxgdb)
474c8240 13424@end smallexample
104c1213 13425
8e04817f
AC
13426@menu
13427* VxWorks Connection:: Connecting to VxWorks
13428* VxWorks Download:: VxWorks download
13429* VxWorks Attach:: Running tasks
13430@end menu
104c1213 13431
8e04817f
AC
13432@node VxWorks Connection
13433@subsubsection Connecting to VxWorks
104c1213 13434
8e04817f
AC
13435The @value{GDBN} command @code{target} lets you connect to a VxWorks target on the
13436network. To connect to a target whose host name is ``@code{tt}'', type:
104c1213 13437
474c8240 13438@smallexample
8e04817f 13439(vxgdb) target vxworks tt
474c8240 13440@end smallexample
104c1213 13441
8e04817f
AC
13442@need 750
13443@value{GDBN} displays messages like these:
104c1213 13444
8e04817f
AC
13445@smallexample
13446Attaching remote machine across net...
13447Connected to tt.
13448@end smallexample
104c1213 13449
8e04817f
AC
13450@need 1000
13451@value{GDBN} then attempts to read the symbol tables of any object modules
13452loaded into the VxWorks target since it was last booted. @value{GDBN} locates
13453these files by searching the directories listed in the command search
13454path (@pxref{Environment, ,Your program's environment}); if it fails
13455to find an object file, it displays a message such as:
5d161b24 13456
474c8240 13457@smallexample
8e04817f 13458prog.o: No such file or directory.
474c8240 13459@end smallexample
104c1213 13460
8e04817f
AC
13461When this happens, add the appropriate directory to the search path with
13462the @value{GDBN} command @code{path}, and execute the @code{target}
13463command again.
104c1213 13464
8e04817f
AC
13465@node VxWorks Download
13466@subsubsection VxWorks download
104c1213 13467
8e04817f
AC
13468@cindex download to VxWorks
13469If you have connected to the VxWorks target and you want to debug an
13470object that has not yet been loaded, you can use the @value{GDBN}
13471@code{load} command to download a file from Unix to VxWorks
13472incrementally. The object file given as an argument to the @code{load}
13473command is actually opened twice: first by the VxWorks target in order
13474to download the code, then by @value{GDBN} in order to read the symbol
13475table. This can lead to problems if the current working directories on
13476the two systems differ. If both systems have NFS mounted the same
13477filesystems, you can avoid these problems by using absolute paths.
13478Otherwise, it is simplest to set the working directory on both systems
13479to the directory in which the object file resides, and then to reference
13480the file by its name, without any path. For instance, a program
13481@file{prog.o} may reside in @file{@var{vxpath}/vw/demo/rdb} in VxWorks
13482and in @file{@var{hostpath}/vw/demo/rdb} on the host. To load this
13483program, type this on VxWorks:
104c1213 13484
474c8240 13485@smallexample
8e04817f 13486-> cd "@var{vxpath}/vw/demo/rdb"
474c8240 13487@end smallexample
104c1213 13488
8e04817f
AC
13489@noindent
13490Then, in @value{GDBN}, type:
104c1213 13491
474c8240 13492@smallexample
8e04817f
AC
13493(vxgdb) cd @var{hostpath}/vw/demo/rdb
13494(vxgdb) load prog.o
474c8240 13495@end smallexample
104c1213 13496
8e04817f 13497@value{GDBN} displays a response similar to this:
104c1213 13498
8e04817f
AC
13499@smallexample
13500Reading symbol data from wherever/vw/demo/rdb/prog.o... done.
13501@end smallexample
104c1213 13502
8e04817f
AC
13503You can also use the @code{load} command to reload an object module
13504after editing and recompiling the corresponding source file. Note that
13505this makes @value{GDBN} delete all currently-defined breakpoints,
13506auto-displays, and convenience variables, and to clear the value
13507history. (This is necessary in order to preserve the integrity of
13508debugger's data structures that reference the target system's symbol
13509table.)
104c1213 13510
8e04817f
AC
13511@node VxWorks Attach
13512@subsubsection Running tasks
104c1213
JM
13513
13514@cindex running VxWorks tasks
13515You can also attach to an existing task using the @code{attach} command as
13516follows:
13517
474c8240 13518@smallexample
104c1213 13519(vxgdb) attach @var{task}
474c8240 13520@end smallexample
104c1213
JM
13521
13522@noindent
13523where @var{task} is the VxWorks hexadecimal task ID. The task can be running
13524or suspended when you attach to it. Running tasks are suspended at
13525the time of attachment.
13526
6d2ebf8b 13527@node Embedded Processors
104c1213
JM
13528@section Embedded Processors
13529
13530This section goes into details specific to particular embedded
13531configurations.
13532
c45da7e6
EZ
13533@cindex send command to simulator
13534Whenever a specific embedded processor has a simulator, @value{GDBN}
13535allows to send an arbitrary command to the simulator.
13536
13537@table @code
13538@item sim @var{command}
13539@kindex sim@r{, a command}
13540Send an arbitrary @var{command} string to the simulator. Consult the
13541documentation for the specific simulator in use for information about
13542acceptable commands.
13543@end table
13544
7d86b5d5 13545
104c1213 13546@menu
c45da7e6 13547* ARM:: ARM RDI
172c2a43
KI
13548* H8/300:: Renesas H8/300
13549* H8/500:: Renesas H8/500
13550* M32R/D:: Renesas M32R/D
104c1213 13551* M68K:: Motorola M68K
104c1213 13552* MIPS Embedded:: MIPS Embedded
a37295f9 13553* OpenRISC 1000:: OpenRisc 1000
104c1213
JM
13554* PA:: HP PA Embedded
13555* PowerPC: PowerPC
172c2a43 13556* SH:: Renesas SH
104c1213
JM
13557* Sparclet:: Tsqware Sparclet
13558* Sparclite:: Fujitsu Sparclite
13559* ST2000:: Tandem ST2000
13560* Z8000:: Zilog Z8000
a64548ea
EZ
13561* AVR:: Atmel AVR
13562* CRIS:: CRIS
13563* Super-H:: Renesas Super-H
c45da7e6 13564* WinCE:: Windows CE child processes
104c1213
JM
13565@end menu
13566
6d2ebf8b 13567@node ARM
104c1213 13568@subsection ARM
c45da7e6 13569@cindex ARM RDI
104c1213
JM
13570
13571@table @code
8e04817f
AC
13572@kindex target rdi
13573@item target rdi @var{dev}
13574ARM Angel monitor, via RDI library interface to ADP protocol. You may
13575use this target to communicate with both boards running the Angel
13576monitor, or with the EmbeddedICE JTAG debug device.
13577
13578@kindex target rdp
13579@item target rdp @var{dev}
13580ARM Demon monitor.
13581
13582@end table
13583
e2f4edfd
EZ
13584@value{GDBN} provides the following ARM-specific commands:
13585
13586@table @code
13587@item set arm disassembler
13588@kindex set arm
13589This commands selects from a list of disassembly styles. The
13590@code{"std"} style is the standard style.
13591
13592@item show arm disassembler
13593@kindex show arm
13594Show the current disassembly style.
13595
13596@item set arm apcs32
13597@cindex ARM 32-bit mode
13598This command toggles ARM operation mode between 32-bit and 26-bit.
13599
13600@item show arm apcs32
13601Display the current usage of the ARM 32-bit mode.
13602
13603@item set arm fpu @var{fputype}
13604This command sets the ARM floating-point unit (FPU) type. The
13605argument @var{fputype} can be one of these:
13606
13607@table @code
13608@item auto
13609Determine the FPU type by querying the OS ABI.
13610@item softfpa
13611Software FPU, with mixed-endian doubles on little-endian ARM
13612processors.
13613@item fpa
13614GCC-compiled FPA co-processor.
13615@item softvfp
13616Software FPU with pure-endian doubles.
13617@item vfp
13618VFP co-processor.
13619@end table
13620
13621@item show arm fpu
13622Show the current type of the FPU.
13623
13624@item set arm abi
13625This command forces @value{GDBN} to use the specified ABI.
13626
13627@item show arm abi
13628Show the currently used ABI.
13629
13630@item set debug arm
13631Toggle whether to display ARM-specific debugging messages from the ARM
13632target support subsystem.
13633
13634@item show debug arm
13635Show whether ARM-specific debugging messages are enabled.
13636@end table
13637
c45da7e6
EZ
13638The following commands are available when an ARM target is debugged
13639using the RDI interface:
13640
13641@table @code
13642@item rdilogfile @r{[}@var{file}@r{]}
13643@kindex rdilogfile
13644@cindex ADP (Angel Debugger Protocol) logging
13645Set the filename for the ADP (Angel Debugger Protocol) packet log.
13646With an argument, sets the log file to the specified @var{file}. With
13647no argument, show the current log file name. The default log file is
13648@file{rdi.log}.
13649
13650@item rdilogenable @r{[}@var{arg}@r{]}
13651@kindex rdilogenable
13652Control logging of ADP packets. With an argument of 1 or @code{"yes"}
13653enables logging, with an argument 0 or @code{"no"} disables it. With
13654no arguments displays the current setting. When logging is enabled,
13655ADP packets exchanged between @value{GDBN} and the RDI target device
13656are logged to a file.
13657
13658@item set rdiromatzero
13659@kindex set rdiromatzero
13660@cindex ROM at zero address, RDI
13661Tell @value{GDBN} whether the target has ROM at address 0. If on,
13662vector catching is disabled, so that zero address can be used. If off
13663(the default), vector catching is enabled. For this command to take
13664effect, it needs to be invoked prior to the @code{target rdi} command.
13665
13666@item show rdiromatzero
13667@kindex show rdiromatzero
13668Show the current setting of ROM at zero address.
13669
13670@item set rdiheartbeat
13671@kindex set rdiheartbeat
13672@cindex RDI heartbeat
13673Enable or disable RDI heartbeat packets. It is not recommended to
13674turn on this option, since it confuses ARM and EPI JTAG interface, as
13675well as the Angel monitor.
13676
13677@item show rdiheartbeat
13678@kindex show rdiheartbeat
13679Show the setting of RDI heartbeat packets.
13680@end table
13681
e2f4edfd 13682
8e04817f 13683@node H8/300
172c2a43 13684@subsection Renesas H8/300
8e04817f
AC
13685
13686@table @code
13687
13688@kindex target hms@r{, with H8/300}
13689@item target hms @var{dev}
172c2a43 13690A Renesas SH, H8/300, or H8/500 board, attached via serial line to your host.
8e04817f
AC
13691Use special commands @code{device} and @code{speed} to control the serial
13692line and the communications speed used.
13693
13694@kindex target e7000@r{, with H8/300}
13695@item target e7000 @var{dev}
172c2a43 13696E7000 emulator for Renesas H8 and SH.
8e04817f
AC
13697
13698@kindex target sh3@r{, with H8/300}
13699@kindex target sh3e@r{, with H8/300}
13700@item target sh3 @var{dev}
13701@itemx target sh3e @var{dev}
172c2a43 13702Renesas SH-3 and SH-3E target systems.
8e04817f
AC
13703
13704@end table
13705
13706@cindex download to H8/300 or H8/500
13707@cindex H8/300 or H8/500 download
172c2a43
KI
13708@cindex download to Renesas SH
13709@cindex Renesas SH download
13710When you select remote debugging to a Renesas SH, H8/300, or H8/500
13711board, the @code{load} command downloads your program to the Renesas
8e04817f
AC
13712board and also opens it as the current executable target for
13713@value{GDBN} on your host (like the @code{file} command).
13714
13715@value{GDBN} needs to know these things to talk to your
172c2a43 13716Renesas SH, H8/300, or H8/500:
8e04817f
AC
13717
13718@enumerate
13719@item
13720that you want to use @samp{target hms}, the remote debugging interface
172c2a43
KI
13721for Renesas microprocessors, or @samp{target e7000}, the in-circuit
13722emulator for the Renesas SH and the Renesas 300H. (@samp{target hms} is
13723the default when @value{GDBN} is configured specifically for the Renesas SH,
8e04817f
AC
13724H8/300, or H8/500.)
13725
13726@item
172c2a43 13727what serial device connects your host to your Renesas board (the first
8e04817f
AC
13728serial device available on your host is the default).
13729
13730@item
13731what speed to use over the serial device.
13732@end enumerate
13733
13734@menu
172c2a43
KI
13735* Renesas Boards:: Connecting to Renesas boards.
13736* Renesas ICE:: Using the E7000 In-Circuit Emulator.
13737* Renesas Special:: Special @value{GDBN} commands for Renesas micros.
8e04817f
AC
13738@end menu
13739
172c2a43
KI
13740@node Renesas Boards
13741@subsubsection Connecting to Renesas boards
8e04817f
AC
13742
13743@c only for Unix hosts
13744@kindex device
172c2a43 13745@cindex serial device, Renesas micros
8e04817f
AC
13746Use the special @code{@value{GDBN}} command @samp{device @var{port}} if you
13747need to explicitly set the serial device. The default @var{port} is the
13748first available port on your host. This is only necessary on Unix
13749hosts, where it is typically something like @file{/dev/ttya}.
13750
13751@kindex speed
172c2a43 13752@cindex serial line speed, Renesas micros
8e04817f
AC
13753@code{@value{GDBN}} has another special command to set the communications
13754speed: @samp{speed @var{bps}}. This command also is only used from Unix
13755hosts; on DOS hosts, set the line speed as usual from outside @value{GDBN} with
13756the DOS @code{mode} command (for instance,
13757@w{@kbd{mode com2:9600,n,8,1,p}} for a 9600@dmn{bps} connection).
13758
13759The @samp{device} and @samp{speed} commands are available only when you
172c2a43 13760use a Unix host to debug your Renesas microprocessor programs. If you
8e04817f
AC
13761use a DOS host,
13762@value{GDBN} depends on an auxiliary terminate-and-stay-resident program
13763called @code{asynctsr} to communicate with the development board
13764through a PC serial port. You must also use the DOS @code{mode} command
13765to set up the serial port on the DOS side.
13766
13767The following sample session illustrates the steps needed to start a
13768program under @value{GDBN} control on an H8/300. The example uses a
13769sample H8/300 program called @file{t.x}. The procedure is the same for
172c2a43 13770the Renesas SH and the H8/500.
8e04817f
AC
13771
13772First hook up your development board. In this example, we use a
13773board attached to serial port @code{COM2}; if you use a different serial
13774port, substitute its name in the argument of the @code{mode} command.
13775When you call @code{asynctsr}, the auxiliary comms program used by the
13776debugger, you give it just the numeric part of the serial port's name;
13777for example, @samp{asyncstr 2} below runs @code{asyncstr} on
13778@code{COM2}.
13779
474c8240 13780@smallexample
8e04817f
AC
13781C:\H8300\TEST> asynctsr 2
13782C:\H8300\TEST> mode com2:9600,n,8,1,p
13783
13784Resident portion of MODE loaded
13785
13786COM2: 9600, n, 8, 1, p
13787
474c8240 13788@end smallexample
8e04817f
AC
13789
13790@quotation
13791@emph{Warning:} We have noticed a bug in PC-NFS that conflicts with
13792@code{asynctsr}. If you also run PC-NFS on your DOS host, you may need to
13793disable it, or even boot without it, to use @code{asynctsr} to control
13794your development board.
13795@end quotation
13796
13797@kindex target hms@r{, and serial protocol}
13798Now that serial communications are set up, and the development board is
9c16f35a 13799connected, you can start up @value{GDBN}. Call @code{@value{GDBN}} with
8e04817f
AC
13800the name of your program as the argument. @code{@value{GDBN}} prompts
13801you, as usual, with the prompt @samp{(@value{GDBP})}. Use two special
13802commands to begin your debugging session: @samp{target hms} to specify
172c2a43 13803cross-debugging to the Renesas board, and the @code{load} command to
8e04817f
AC
13804download your program to the board. @code{load} displays the names of
13805the program's sections, and a @samp{*} for each 2K of data downloaded.
13806(If you want to refresh @value{GDBN} data on symbols or on the
13807executable file without downloading, use the @value{GDBN} commands
13808@code{file} or @code{symbol-file}. These commands, and @code{load}
13809itself, are described in @ref{Files,,Commands to specify files}.)
13810
13811@smallexample
13812(eg-C:\H8300\TEST) @value{GDBP} t.x
13813@value{GDBN} is free software and you are welcome to distribute copies
13814 of it under certain conditions; type "show copying" to see
13815 the conditions.
13816There is absolutely no warranty for @value{GDBN}; type "show warranty"
13817for details.
13818@value{GDBN} @value{GDBVN}, Copyright 1992 Free Software Foundation, Inc...
13819(@value{GDBP}) target hms
13820Connected to remote H8/300 HMS system.
13821(@value{GDBP}) load t.x
13822.text : 0x8000 .. 0xabde ***********
13823.data : 0xabde .. 0xad30 *
13824.stack : 0xf000 .. 0xf014 *
13825@end smallexample
13826
13827At this point, you're ready to run or debug your program. From here on,
13828you can use all the usual @value{GDBN} commands. The @code{break} command
13829sets breakpoints; the @code{run} command starts your program;
13830@code{print} or @code{x} display data; the @code{continue} command
13831resumes execution after stopping at a breakpoint. You can use the
13832@code{help} command at any time to find out more about @value{GDBN} commands.
13833
13834Remember, however, that @emph{operating system} facilities aren't
13835available on your development board; for example, if your program hangs,
13836you can't send an interrupt---but you can press the @sc{reset} switch!
13837
13838Use the @sc{reset} button on the development board
13839@itemize @bullet
13840@item
13841to interrupt your program (don't use @kbd{ctl-C} on the DOS host---it has
13842no way to pass an interrupt signal to the development board); and
13843
13844@item
13845to return to the @value{GDBN} command prompt after your program finishes
13846normally. The communications protocol provides no other way for @value{GDBN}
13847to detect program completion.
13848@end itemize
13849
13850In either case, @value{GDBN} sees the effect of a @sc{reset} on the
13851development board as a ``normal exit'' of your program.
13852
172c2a43 13853@node Renesas ICE
8e04817f
AC
13854@subsubsection Using the E7000 in-circuit emulator
13855
172c2a43 13856@kindex target e7000@r{, with Renesas ICE}
8e04817f 13857You can use the E7000 in-circuit emulator to develop code for either the
172c2a43 13858Renesas SH or the H8/300H. Use one of these forms of the @samp{target
8e04817f
AC
13859e7000} command to connect @value{GDBN} to your E7000:
13860
13861@table @code
13862@item target e7000 @var{port} @var{speed}
13863Use this form if your E7000 is connected to a serial port. The
13864@var{port} argument identifies what serial port to use (for example,
13865@samp{com2}). The third argument is the line speed in bits per second
13866(for example, @samp{9600}).
13867
13868@item target e7000 @var{hostname}
13869If your E7000 is installed as a host on a TCP/IP network, you can just
13870specify its hostname; @value{GDBN} uses @code{telnet} to connect.
13871@end table
13872
ba04e063
EZ
13873The following special commands are available when debugging with the
13874Renesas E7000 ICE:
13875
13876@table @code
13877@item e7000 @var{command}
13878@kindex e7000
13879@cindex send command to E7000 monitor
13880This sends the specified @var{command} to the E7000 monitor.
13881
13882@item ftplogin @var{machine} @var{username} @var{password} @var{dir}
13883@kindex ftplogin@r{, E7000}
13884This command records information for subsequent interface with the
13885E7000 monitor via the FTP protocol: @value{GDBN} will log into the
13886named @var{machine} using specified @var{username} and @var{password},
13887and then chdir to the named directory @var{dir}.
13888
13889@item ftpload @var{file}
13890@kindex ftpload@r{, E7000}
13891This command uses credentials recorded by @code{ftplogin} to fetch and
13892load the named @var{file} from the E7000 monitor.
13893
13894@item drain
13895@kindex drain@r{, E7000}
13896This command drains any pending text buffers stored on the E7000.
13897
13898@item set usehardbreakpoints
13899@itemx show usehardbreakpoints
13900@kindex set usehardbreakpoints@r{, E7000}
13901@kindex show usehardbreakpoints@r{, E7000}
13902@cindex hardware breakpoints, and E7000
13903These commands set and show the use of hardware breakpoints for all
13904breakpoints. @xref{Set Breaks, hardware-assisted breakpoint}, for
13905more information about using hardware breakpoints selectively.
13906@end table
13907
172c2a43
KI
13908@node Renesas Special
13909@subsubsection Special @value{GDBN} commands for Renesas micros
8e04817f
AC
13910
13911Some @value{GDBN} commands are available only for the H8/300:
13912
13913@table @code
13914
13915@kindex set machine
13916@kindex show machine
13917@item set machine h8300
13918@itemx set machine h8300h
13919Condition @value{GDBN} for one of the two variants of the H8/300
13920architecture with @samp{set machine}. You can use @samp{show machine}
13921to check which variant is currently in effect.
104c1213
JM
13922
13923@end table
13924
8e04817f
AC
13925@node H8/500
13926@subsection H8/500
104c1213
JM
13927
13928@table @code
13929
8e04817f
AC
13930@kindex set memory @var{mod}
13931@cindex memory models, H8/500
13932@item set memory @var{mod}
13933@itemx show memory
13934Specify which H8/500 memory model (@var{mod}) you are using with
13935@samp{set memory}; check which memory model is in effect with @samp{show
13936memory}. The accepted values for @var{mod} are @code{small},
13937@code{big}, @code{medium}, and @code{compact}.
104c1213 13938
8e04817f 13939@end table
104c1213 13940
8e04817f 13941@node M32R/D
ba04e063 13942@subsection Renesas M32R/D and M32R/SDI
8e04817f
AC
13943
13944@table @code
8e04817f
AC
13945@kindex target m32r
13946@item target m32r @var{dev}
172c2a43 13947Renesas M32R/D ROM monitor.
8e04817f 13948
fb3e19c0
KI
13949@kindex target m32rsdi
13950@item target m32rsdi @var{dev}
13951Renesas M32R SDI server, connected via parallel port to the board.
721c2651
EZ
13952@end table
13953
13954The following @value{GDBN} commands are specific to the M32R monitor:
13955
13956@table @code
13957@item set download-path @var{path}
13958@kindex set download-path
13959@cindex find downloadable @sc{srec} files (M32R)
13960Set the default path for finding donwloadable @sc{srec} files.
13961
13962@item show download-path
13963@kindex show download-path
13964Show the default path for downloadable @sc{srec} files.
fb3e19c0 13965
721c2651
EZ
13966@item set board-address @var{addr}
13967@kindex set board-address
13968@cindex M32-EVA target board address
13969Set the IP address for the M32R-EVA target board.
13970
13971@item show board-address
13972@kindex show board-address
13973Show the current IP address of the target board.
13974
13975@item set server-address @var{addr}
13976@kindex set server-address
13977@cindex download server address (M32R)
13978Set the IP address for the download server, which is the @value{GDBN}'s
13979host machine.
13980
13981@item show server-address
13982@kindex show server-address
13983Display the IP address of the download server.
13984
13985@item upload @r{[}@var{file}@r{]}
13986@kindex upload@r{, M32R}
13987Upload the specified @sc{srec} @var{file} via the monitor's Ethernet
13988upload capability. If no @var{file} argument is given, the current
13989executable file is uploaded.
13990
13991@item tload @r{[}@var{file}@r{]}
13992@kindex tload@r{, M32R}
13993Test the @code{upload} command.
8e04817f
AC
13994@end table
13995
ba04e063
EZ
13996The following commands are available for M32R/SDI:
13997
13998@table @code
13999@item sdireset
14000@kindex sdireset
14001@cindex reset SDI connection, M32R
14002This command resets the SDI connection.
14003
14004@item sdistatus
14005@kindex sdistatus
14006This command shows the SDI connection status.
14007
14008@item debug_chaos
14009@kindex debug_chaos
14010@cindex M32R/Chaos debugging
14011Instructs the remote that M32R/Chaos debugging is to be used.
14012
14013@item use_debug_dma
14014@kindex use_debug_dma
14015Instructs the remote to use the DEBUG_DMA method of accessing memory.
14016
14017@item use_mon_code
14018@kindex use_mon_code
14019Instructs the remote to use the MON_CODE method of accessing memory.
14020
14021@item use_ib_break
14022@kindex use_ib_break
14023Instructs the remote to set breakpoints by IB break.
14024
14025@item use_dbt_break
14026@kindex use_dbt_break
14027Instructs the remote to set breakpoints by DBT.
14028@end table
14029
8e04817f
AC
14030@node M68K
14031@subsection M68k
14032
14033The Motorola m68k configuration includes ColdFire support, and
14034target command for the following ROM monitors.
14035
14036@table @code
14037
14038@kindex target abug
14039@item target abug @var{dev}
14040ABug ROM monitor for M68K.
14041
14042@kindex target cpu32bug
14043@item target cpu32bug @var{dev}
14044CPU32BUG monitor, running on a CPU32 (M68K) board.
14045
14046@kindex target dbug
14047@item target dbug @var{dev}
14048dBUG ROM monitor for Motorola ColdFire.
14049
14050@kindex target est
14051@item target est @var{dev}
14052EST-300 ICE monitor, running on a CPU32 (M68K) board.
14053
14054@kindex target rom68k
14055@item target rom68k @var{dev}
14056ROM 68K monitor, running on an M68K IDP board.
14057
14058@end table
14059
8e04817f
AC
14060@table @code
14061
14062@kindex target rombug
14063@item target rombug @var{dev}
14064ROMBUG ROM monitor for OS/9000.
14065
14066@end table
14067
8e04817f
AC
14068@node MIPS Embedded
14069@subsection MIPS Embedded
14070
14071@cindex MIPS boards
14072@value{GDBN} can use the MIPS remote debugging protocol to talk to a
14073MIPS board attached to a serial line. This is available when
14074you configure @value{GDBN} with @samp{--target=mips-idt-ecoff}.
104c1213 14075
8e04817f
AC
14076@need 1000
14077Use these @value{GDBN} commands to specify the connection to your target board:
104c1213 14078
8e04817f
AC
14079@table @code
14080@item target mips @var{port}
14081@kindex target mips @var{port}
14082To run a program on the board, start up @code{@value{GDBP}} with the
14083name of your program as the argument. To connect to the board, use the
14084command @samp{target mips @var{port}}, where @var{port} is the name of
14085the serial port connected to the board. If the program has not already
14086been downloaded to the board, you may use the @code{load} command to
14087download it. You can then use all the usual @value{GDBN} commands.
104c1213 14088
8e04817f
AC
14089For example, this sequence connects to the target board through a serial
14090port, and loads and runs a program called @var{prog} through the
14091debugger:
104c1213 14092
474c8240 14093@smallexample
8e04817f
AC
14094host$ @value{GDBP} @var{prog}
14095@value{GDBN} is free software and @dots{}
14096(@value{GDBP}) target mips /dev/ttyb
14097(@value{GDBP}) load @var{prog}
14098(@value{GDBP}) run
474c8240 14099@end smallexample
104c1213 14100
8e04817f
AC
14101@item target mips @var{hostname}:@var{portnumber}
14102On some @value{GDBN} host configurations, you can specify a TCP
14103connection (for instance, to a serial line managed by a terminal
14104concentrator) instead of a serial port, using the syntax
14105@samp{@var{hostname}:@var{portnumber}}.
104c1213 14106
8e04817f
AC
14107@item target pmon @var{port}
14108@kindex target pmon @var{port}
14109PMON ROM monitor.
104c1213 14110
8e04817f
AC
14111@item target ddb @var{port}
14112@kindex target ddb @var{port}
14113NEC's DDB variant of PMON for Vr4300.
104c1213 14114
8e04817f
AC
14115@item target lsi @var{port}
14116@kindex target lsi @var{port}
14117LSI variant of PMON.
104c1213 14118
8e04817f
AC
14119@kindex target r3900
14120@item target r3900 @var{dev}
14121Densan DVE-R3900 ROM monitor for Toshiba R3900 Mips.
104c1213 14122
8e04817f
AC
14123@kindex target array
14124@item target array @var{dev}
14125Array Tech LSI33K RAID controller board.
104c1213 14126
8e04817f 14127@end table
104c1213 14128
104c1213 14129
8e04817f
AC
14130@noindent
14131@value{GDBN} also supports these special commands for MIPS targets:
104c1213 14132
8e04817f 14133@table @code
8e04817f
AC
14134@item set mipsfpu double
14135@itemx set mipsfpu single
14136@itemx set mipsfpu none
a64548ea 14137@itemx set mipsfpu auto
8e04817f
AC
14138@itemx show mipsfpu
14139@kindex set mipsfpu
14140@kindex show mipsfpu
14141@cindex MIPS remote floating point
14142@cindex floating point, MIPS remote
14143If your target board does not support the MIPS floating point
14144coprocessor, you should use the command @samp{set mipsfpu none} (if you
14145need this, you may wish to put the command in your @value{GDBN} init
14146file). This tells @value{GDBN} how to find the return value of
14147functions which return floating point values. It also allows
14148@value{GDBN} to avoid saving the floating point registers when calling
14149functions on the board. If you are using a floating point coprocessor
14150with only single precision floating point support, as on the @sc{r4650}
14151processor, use the command @samp{set mipsfpu single}. The default
14152double precision floating point coprocessor may be selected using
14153@samp{set mipsfpu double}.
104c1213 14154
8e04817f
AC
14155In previous versions the only choices were double precision or no
14156floating point, so @samp{set mipsfpu on} will select double precision
14157and @samp{set mipsfpu off} will select no floating point.
104c1213 14158
8e04817f
AC
14159As usual, you can inquire about the @code{mipsfpu} variable with
14160@samp{show mipsfpu}.
104c1213 14161
8e04817f
AC
14162@item set timeout @var{seconds}
14163@itemx set retransmit-timeout @var{seconds}
14164@itemx show timeout
14165@itemx show retransmit-timeout
14166@cindex @code{timeout}, MIPS protocol
14167@cindex @code{retransmit-timeout}, MIPS protocol
14168@kindex set timeout
14169@kindex show timeout
14170@kindex set retransmit-timeout
14171@kindex show retransmit-timeout
14172You can control the timeout used while waiting for a packet, in the MIPS
14173remote protocol, with the @code{set timeout @var{seconds}} command. The
14174default is 5 seconds. Similarly, you can control the timeout used while
14175waiting for an acknowledgement of a packet with the @code{set
14176retransmit-timeout @var{seconds}} command. The default is 3 seconds.
14177You can inspect both values with @code{show timeout} and @code{show
14178retransmit-timeout}. (These commands are @emph{only} available when
14179@value{GDBN} is configured for @samp{--target=mips-idt-ecoff}.)
104c1213 14180
8e04817f
AC
14181The timeout set by @code{set timeout} does not apply when @value{GDBN}
14182is waiting for your program to stop. In that case, @value{GDBN} waits
14183forever because it has no way of knowing how long the program is going
14184to run before stopping.
ba04e063
EZ
14185
14186@item set syn-garbage-limit @var{num}
14187@kindex set syn-garbage-limit@r{, MIPS remote}
14188@cindex synchronize with remote MIPS target
14189Limit the maximum number of characters @value{GDBN} should ignore when
14190it tries to synchronize with the remote target. The default is 10
14191characters. Setting the limit to -1 means there's no limit.
14192
14193@item show syn-garbage-limit
14194@kindex show syn-garbage-limit@r{, MIPS remote}
14195Show the current limit on the number of characters to ignore when
14196trying to synchronize with the remote system.
14197
14198@item set monitor-prompt @var{prompt}
14199@kindex set monitor-prompt@r{, MIPS remote}
14200@cindex remote monitor prompt
14201Tell @value{GDBN} to expect the specified @var{prompt} string from the
14202remote monitor. The default depends on the target:
14203@table @asis
14204@item pmon target
14205@samp{PMON}
14206@item ddb target
14207@samp{NEC010}
14208@item lsi target
14209@samp{PMON>}
14210@end table
14211
14212@item show monitor-prompt
14213@kindex show monitor-prompt@r{, MIPS remote}
14214Show the current strings @value{GDBN} expects as the prompt from the
14215remote monitor.
14216
14217@item set monitor-warnings
14218@kindex set monitor-warnings@r{, MIPS remote}
14219Enable or disable monitor warnings about hardware breakpoints. This
14220has effect only for the @code{lsi} target. When on, @value{GDBN} will
14221display warning messages whose codes are returned by the @code{lsi}
14222PMON monitor for breakpoint commands.
14223
14224@item show monitor-warnings
14225@kindex show monitor-warnings@r{, MIPS remote}
14226Show the current setting of printing monitor warnings.
14227
14228@item pmon @var{command}
14229@kindex pmon@r{, MIPS remote}
14230@cindex send PMON command
14231This command allows sending an arbitrary @var{command} string to the
14232monitor. The monitor must be in debug mode for this to work.
8e04817f 14233@end table
104c1213 14234
a37295f9
MM
14235@node OpenRISC 1000
14236@subsection OpenRISC 1000
14237@cindex OpenRISC 1000
14238
14239@cindex or1k boards
14240See OR1k Architecture document (@uref{www.opencores.org}) for more information
14241about platform and commands.
14242
14243@table @code
14244
14245@kindex target jtag
14246@item target jtag jtag://@var{host}:@var{port}
14247
14248Connects to remote JTAG server.
14249JTAG remote server can be either an or1ksim or JTAG server,
14250connected via parallel port to the board.
14251
14252Example: @code{target jtag jtag://localhost:9999}
14253
14254@kindex or1ksim
14255@item or1ksim @var{command}
14256If connected to @code{or1ksim} OpenRISC 1000 Architectural
14257Simulator, proprietary commands can be executed.
14258
14259@kindex info or1k spr
14260@item info or1k spr
14261Displays spr groups.
14262
14263@item info or1k spr @var{group}
14264@itemx info or1k spr @var{groupno}
14265Displays register names in selected group.
14266
14267@item info or1k spr @var{group} @var{register}
14268@itemx info or1k spr @var{register}
14269@itemx info or1k spr @var{groupno} @var{registerno}
14270@itemx info or1k spr @var{registerno}
14271Shows information about specified spr register.
14272
14273@kindex spr
14274@item spr @var{group} @var{register} @var{value}
14275@itemx spr @var{register @var{value}}
14276@itemx spr @var{groupno} @var{registerno @var{value}}
14277@itemx spr @var{registerno @var{value}}
14278Writes @var{value} to specified spr register.
14279@end table
14280
14281Some implementations of OpenRISC 1000 Architecture also have hardware trace.
14282It is very similar to @value{GDBN} trace, except it does not interfere with normal
14283program execution and is thus much faster. Hardware breakpoints/watchpoint
14284triggers can be set using:
14285@table @code
14286@item $LEA/$LDATA
14287Load effective address/data
14288@item $SEA/$SDATA
14289Store effective address/data
14290@item $AEA/$ADATA
14291Access effective address ($SEA or $LEA) or data ($SDATA/$LDATA)
14292@item $FETCH
14293Fetch data
14294@end table
14295
14296When triggered, it can capture low level data, like: @code{PC}, @code{LSEA},
14297@code{LDATA}, @code{SDATA}, @code{READSPR}, @code{WRITESPR}, @code{INSTR}.
14298
14299@code{htrace} commands:
14300@cindex OpenRISC 1000 htrace
14301@table @code
14302@kindex hwatch
14303@item hwatch @var{conditional}
14304Set hardware watchpoint on combination of Load/Store Effecive Address(es)
14305or Data. For example:
14306
14307@code{hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) && ($SDATA >= 50)}
14308
14309@code{hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) && ($SDATA >= 50)}
14310
4644b6e3 14311@kindex htrace
a37295f9
MM
14312@item htrace info
14313Display information about current HW trace configuration.
14314
a37295f9
MM
14315@item htrace trigger @var{conditional}
14316Set starting criteria for HW trace.
14317
a37295f9
MM
14318@item htrace qualifier @var{conditional}
14319Set acquisition qualifier for HW trace.
14320
a37295f9
MM
14321@item htrace stop @var{conditional}
14322Set HW trace stopping criteria.
14323
f153cc92 14324@item htrace record [@var{data}]*
a37295f9
MM
14325Selects the data to be recorded, when qualifier is met and HW trace was
14326triggered.
14327
a37295f9 14328@item htrace enable
a37295f9
MM
14329@itemx htrace disable
14330Enables/disables the HW trace.
14331
f153cc92 14332@item htrace rewind [@var{filename}]
a37295f9
MM
14333Clears currently recorded trace data.
14334
14335If filename is specified, new trace file is made and any newly collected data
14336will be written there.
14337
f153cc92 14338@item htrace print [@var{start} [@var{len}]]
a37295f9
MM
14339Prints trace buffer, using current record configuration.
14340
a37295f9
MM
14341@item htrace mode continuous
14342Set continuous trace mode.
14343
a37295f9
MM
14344@item htrace mode suspend
14345Set suspend trace mode.
14346
14347@end table
14348
8e04817f
AC
14349@node PowerPC
14350@subsection PowerPC
104c1213
JM
14351
14352@table @code
8e04817f
AC
14353@kindex target dink32
14354@item target dink32 @var{dev}
14355DINK32 ROM monitor.
104c1213 14356
8e04817f
AC
14357@kindex target ppcbug
14358@item target ppcbug @var{dev}
14359@kindex target ppcbug1
14360@item target ppcbug1 @var{dev}
14361PPCBUG ROM monitor for PowerPC.
104c1213 14362
8e04817f
AC
14363@kindex target sds
14364@item target sds @var{dev}
14365SDS monitor, running on a PowerPC board (such as Motorola's ADS).
c45da7e6 14366@end table
8e04817f 14367
c45da7e6
EZ
14368@cindex SDS protocol
14369The following commands specifi to the SDS protocol are supported
14370by@value{GDBN}:
14371
14372@table @code
14373@item set sdstimeout @var{nsec}
14374@kindex set sdstimeout
14375Set the timeout for SDS protocol reads to be @var{nsec} seconds. The
14376default is 2 seconds.
14377
14378@item show sdstimeout
14379@kindex show sdstimeout
14380Show the current value of the SDS timeout.
14381
14382@item sds @var{command}
14383@kindex sds@r{, a command}
14384Send the specified @var{command} string to the SDS monitor.
8e04817f
AC
14385@end table
14386
c45da7e6 14387
8e04817f
AC
14388@node PA
14389@subsection HP PA Embedded
104c1213
JM
14390
14391@table @code
14392
8e04817f
AC
14393@kindex target op50n
14394@item target op50n @var{dev}
14395OP50N monitor, running on an OKI HPPA board.
14396
14397@kindex target w89k
14398@item target w89k @var{dev}
14399W89K monitor, running on a Winbond HPPA board.
104c1213
JM
14400
14401@end table
14402
8e04817f 14403@node SH
172c2a43 14404@subsection Renesas SH
104c1213
JM
14405
14406@table @code
14407
172c2a43 14408@kindex target hms@r{, with Renesas SH}
8e04817f 14409@item target hms @var{dev}
172c2a43 14410A Renesas SH board attached via serial line to your host. Use special
8e04817f
AC
14411commands @code{device} and @code{speed} to control the serial line and
14412the communications speed used.
104c1213 14413
172c2a43 14414@kindex target e7000@r{, with Renesas SH}
8e04817f 14415@item target e7000 @var{dev}
172c2a43 14416E7000 emulator for Renesas SH.
104c1213 14417
8e04817f
AC
14418@kindex target sh3@r{, with SH}
14419@kindex target sh3e@r{, with SH}
14420@item target sh3 @var{dev}
14421@item target sh3e @var{dev}
172c2a43 14422Renesas SH-3 and SH-3E target systems.
104c1213 14423
8e04817f 14424@end table
104c1213 14425
8e04817f
AC
14426@node Sparclet
14427@subsection Tsqware Sparclet
104c1213 14428
8e04817f
AC
14429@cindex Sparclet
14430
14431@value{GDBN} enables developers to debug tasks running on
14432Sparclet targets from a Unix host.
14433@value{GDBN} uses code that runs on
14434both the Unix host and on the Sparclet target. The program
14435@code{@value{GDBP}} is installed and executed on the Unix host.
104c1213 14436
8e04817f
AC
14437@table @code
14438@item remotetimeout @var{args}
14439@kindex remotetimeout
14440@value{GDBN} supports the option @code{remotetimeout}.
14441This option is set by the user, and @var{args} represents the number of
14442seconds @value{GDBN} waits for responses.
104c1213
JM
14443@end table
14444
8e04817f
AC
14445@cindex compiling, on Sparclet
14446When compiling for debugging, include the options @samp{-g} to get debug
14447information and @samp{-Ttext} to relocate the program to where you wish to
14448load it on the target. You may also want to add the options @samp{-n} or
14449@samp{-N} in order to reduce the size of the sections. Example:
104c1213 14450
474c8240 14451@smallexample
8e04817f 14452sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N
474c8240 14453@end smallexample
104c1213 14454
8e04817f 14455You can use @code{objdump} to verify that the addresses are what you intended:
104c1213 14456
474c8240 14457@smallexample
8e04817f 14458sparclet-aout-objdump --headers --syms prog
474c8240 14459@end smallexample
104c1213 14460
8e04817f
AC
14461@cindex running, on Sparclet
14462Once you have set
14463your Unix execution search path to find @value{GDBN}, you are ready to
14464run @value{GDBN}. From your Unix host, run @code{@value{GDBP}}
14465(or @code{sparclet-aout-gdb}, depending on your installation).
104c1213 14466
8e04817f
AC
14467@value{GDBN} comes up showing the prompt:
14468
474c8240 14469@smallexample
8e04817f 14470(gdbslet)
474c8240 14471@end smallexample
104c1213
JM
14472
14473@menu
8e04817f
AC
14474* Sparclet File:: Setting the file to debug
14475* Sparclet Connection:: Connecting to Sparclet
14476* Sparclet Download:: Sparclet download
14477* Sparclet Execution:: Running and debugging
104c1213
JM
14478@end menu
14479
8e04817f
AC
14480@node Sparclet File
14481@subsubsection Setting file to debug
104c1213 14482
8e04817f 14483The @value{GDBN} command @code{file} lets you choose with program to debug.
104c1213 14484
474c8240 14485@smallexample
8e04817f 14486(gdbslet) file prog
474c8240 14487@end smallexample
104c1213 14488
8e04817f
AC
14489@need 1000
14490@value{GDBN} then attempts to read the symbol table of @file{prog}.
14491@value{GDBN} locates
14492the file by searching the directories listed in the command search
14493path.
14494If the file was compiled with debug information (option "-g"), source
14495files will be searched as well.
14496@value{GDBN} locates
14497the source files by searching the directories listed in the directory search
14498path (@pxref{Environment, ,Your program's environment}).
14499If it fails
14500to find a file, it displays a message such as:
104c1213 14501
474c8240 14502@smallexample
8e04817f 14503prog: No such file or directory.
474c8240 14504@end smallexample
104c1213 14505
8e04817f
AC
14506When this happens, add the appropriate directories to the search paths with
14507the @value{GDBN} commands @code{path} and @code{dir}, and execute the
14508@code{target} command again.
104c1213 14509
8e04817f
AC
14510@node Sparclet Connection
14511@subsubsection Connecting to Sparclet
104c1213 14512
8e04817f
AC
14513The @value{GDBN} command @code{target} lets you connect to a Sparclet target.
14514To connect to a target on serial port ``@code{ttya}'', type:
104c1213 14515
474c8240 14516@smallexample
8e04817f
AC
14517(gdbslet) target sparclet /dev/ttya
14518Remote target sparclet connected to /dev/ttya
14519main () at ../prog.c:3
474c8240 14520@end smallexample
104c1213 14521
8e04817f
AC
14522@need 750
14523@value{GDBN} displays messages like these:
104c1213 14524
474c8240 14525@smallexample
8e04817f 14526Connected to ttya.
474c8240 14527@end smallexample
104c1213 14528
8e04817f
AC
14529@node Sparclet Download
14530@subsubsection Sparclet download
104c1213 14531
8e04817f
AC
14532@cindex download to Sparclet
14533Once connected to the Sparclet target,
14534you can use the @value{GDBN}
14535@code{load} command to download the file from the host to the target.
14536The file name and load offset should be given as arguments to the @code{load}
14537command.
14538Since the file format is aout, the program must be loaded to the starting
14539address. You can use @code{objdump} to find out what this value is. The load
14540offset is an offset which is added to the VMA (virtual memory address)
14541of each of the file's sections.
14542For instance, if the program
14543@file{prog} was linked to text address 0x1201000, with data at 0x12010160
14544and bss at 0x12010170, in @value{GDBN}, type:
104c1213 14545
474c8240 14546@smallexample
8e04817f
AC
14547(gdbslet) load prog 0x12010000
14548Loading section .text, size 0xdb0 vma 0x12010000
474c8240 14549@end smallexample
104c1213 14550
8e04817f
AC
14551If the code is loaded at a different address then what the program was linked
14552to, you may need to use the @code{section} and @code{add-symbol-file} commands
14553to tell @value{GDBN} where to map the symbol table.
14554
14555@node Sparclet Execution
14556@subsubsection Running and debugging
14557
14558@cindex running and debugging Sparclet programs
14559You can now begin debugging the task using @value{GDBN}'s execution control
14560commands, @code{b}, @code{step}, @code{run}, etc. See the @value{GDBN}
14561manual for the list of commands.
14562
474c8240 14563@smallexample
8e04817f
AC
14564(gdbslet) b main
14565Breakpoint 1 at 0x12010000: file prog.c, line 3.
14566(gdbslet) run
14567Starting program: prog
14568Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3
145693 char *symarg = 0;
14570(gdbslet) step
145714 char *execarg = "hello!";
14572(gdbslet)
474c8240 14573@end smallexample
8e04817f
AC
14574
14575@node Sparclite
14576@subsection Fujitsu Sparclite
104c1213
JM
14577
14578@table @code
14579
8e04817f
AC
14580@kindex target sparclite
14581@item target sparclite @var{dev}
14582Fujitsu sparclite boards, used only for the purpose of loading.
14583You must use an additional command to debug the program.
14584For example: target remote @var{dev} using @value{GDBN} standard
14585remote protocol.
104c1213
JM
14586
14587@end table
14588
8e04817f
AC
14589@node ST2000
14590@subsection Tandem ST2000
104c1213 14591
8e04817f
AC
14592@value{GDBN} may be used with a Tandem ST2000 phone switch, running Tandem's
14593STDBUG protocol.
104c1213 14594
8e04817f
AC
14595To connect your ST2000 to the host system, see the manufacturer's
14596manual. Once the ST2000 is physically attached, you can run:
104c1213 14597
474c8240 14598@smallexample
8e04817f 14599target st2000 @var{dev} @var{speed}
474c8240 14600@end smallexample
104c1213 14601
8e04817f
AC
14602@noindent
14603to establish it as your debugging environment. @var{dev} is normally
14604the name of a serial device, such as @file{/dev/ttya}, connected to the
14605ST2000 via a serial line. You can instead specify @var{dev} as a TCP
14606connection (for example, to a serial line attached via a terminal
14607concentrator) using the syntax @code{@var{hostname}:@var{portnumber}}.
104c1213 14608
8e04817f
AC
14609The @code{load} and @code{attach} commands are @emph{not} defined for
14610this target; you must load your program into the ST2000 as you normally
14611would for standalone operation. @value{GDBN} reads debugging information
14612(such as symbols) from a separate, debugging version of the program
14613available on your host computer.
14614@c FIXME!! This is terribly vague; what little content is here is
14615@c basically hearsay.
104c1213 14616
8e04817f
AC
14617@cindex ST2000 auxiliary commands
14618These auxiliary @value{GDBN} commands are available to help you with the ST2000
14619environment:
104c1213 14620
8e04817f
AC
14621@table @code
14622@item st2000 @var{command}
14623@kindex st2000 @var{cmd}
14624@cindex STDBUG commands (ST2000)
14625@cindex commands to STDBUG (ST2000)
14626Send a @var{command} to the STDBUG monitor. See the manufacturer's
14627manual for available commands.
104c1213 14628
8e04817f
AC
14629@item connect
14630@cindex connect (to STDBUG)
14631Connect the controlling terminal to the STDBUG command monitor. When
14632you are done interacting with STDBUG, typing either of two character
14633sequences gets you back to the @value{GDBN} command prompt:
14634@kbd{@key{RET}~.} (Return, followed by tilde and period) or
14635@kbd{@key{RET}~@key{C-d}} (Return, followed by tilde and control-D).
104c1213
JM
14636@end table
14637
8e04817f
AC
14638@node Z8000
14639@subsection Zilog Z8000
104c1213 14640
8e04817f
AC
14641@cindex Z8000
14642@cindex simulator, Z8000
14643@cindex Zilog Z8000 simulator
104c1213 14644
8e04817f
AC
14645When configured for debugging Zilog Z8000 targets, @value{GDBN} includes
14646a Z8000 simulator.
14647
14648For the Z8000 family, @samp{target sim} simulates either the Z8002 (the
14649unsegmented variant of the Z8000 architecture) or the Z8001 (the
14650segmented variant). The simulator recognizes which architecture is
14651appropriate by inspecting the object code.
104c1213 14652
8e04817f
AC
14653@table @code
14654@item target sim @var{args}
14655@kindex sim
14656@kindex target sim@r{, with Z8000}
14657Debug programs on a simulated CPU. If the simulator supports setup
14658options, specify them via @var{args}.
104c1213
JM
14659@end table
14660
8e04817f
AC
14661@noindent
14662After specifying this target, you can debug programs for the simulated
14663CPU in the same style as programs for your host computer; use the
14664@code{file} command to load a new program image, the @code{run} command
14665to run your program, and so on.
14666
14667As well as making available all the usual machine registers
14668(@pxref{Registers, ,Registers}), the Z8000 simulator provides three
14669additional items of information as specially named registers:
104c1213
JM
14670
14671@table @code
14672
8e04817f
AC
14673@item cycles
14674Counts clock-ticks in the simulator.
104c1213 14675
8e04817f
AC
14676@item insts
14677Counts instructions run in the simulator.
104c1213 14678
8e04817f
AC
14679@item time
14680Execution time in 60ths of a second.
104c1213 14681
8e04817f 14682@end table
104c1213 14683
8e04817f
AC
14684You can refer to these values in @value{GDBN} expressions with the usual
14685conventions; for example, @w{@samp{b fputc if $cycles>5000}} sets a
14686conditional breakpoint that suspends only after at least 5000
14687simulated clock ticks.
104c1213 14688
a64548ea
EZ
14689@node AVR
14690@subsection Atmel AVR
14691@cindex AVR
14692
14693When configured for debugging the Atmel AVR, @value{GDBN} supports the
14694following AVR-specific commands:
14695
14696@table @code
14697@item info io_registers
14698@kindex info io_registers@r{, AVR}
14699@cindex I/O registers (Atmel AVR)
14700This command displays information about the AVR I/O registers. For
14701each register, @value{GDBN} prints its number and value.
14702@end table
14703
14704@node CRIS
14705@subsection CRIS
14706@cindex CRIS
14707
14708When configured for debugging CRIS, @value{GDBN} provides the
14709following CRIS-specific commands:
14710
14711@table @code
14712@item set cris-version @var{ver}
14713@cindex CRIS version
e22e55c9
OF
14714Set the current CRIS version to @var{ver}, either @samp{10} or @samp{32}.
14715The CRIS version affects register names and sizes. This command is useful in
14716case autodetection of the CRIS version fails.
a64548ea
EZ
14717
14718@item show cris-version
14719Show the current CRIS version.
14720
14721@item set cris-dwarf2-cfi
14722@cindex DWARF-2 CFI and CRIS
e22e55c9
OF
14723Set the usage of DWARF-2 CFI for CRIS debugging. The default is @samp{on}.
14724Change to @samp{off} when using @code{gcc-cris} whose version is below
14725@code{R59}.
a64548ea
EZ
14726
14727@item show cris-dwarf2-cfi
14728Show the current state of using DWARF-2 CFI.
e22e55c9
OF
14729
14730@item set cris-mode @var{mode}
14731@cindex CRIS mode
14732Set the current CRIS mode to @var{mode}. It should only be changed when
14733debugging in guru mode, in which case it should be set to
14734@samp{guru} (the default is @samp{normal}).
14735
14736@item show cris-mode
14737Show the current CRIS mode.
a64548ea
EZ
14738@end table
14739
14740@node Super-H
14741@subsection Renesas Super-H
14742@cindex Super-H
14743
14744For the Renesas Super-H processor, @value{GDBN} provides these
14745commands:
14746
14747@table @code
14748@item regs
14749@kindex regs@r{, Super-H}
14750Show the values of all Super-H registers.
14751@end table
14752
c45da7e6
EZ
14753@node WinCE
14754@subsection Windows CE
14755@cindex Windows CE
14756
14757The following commands are available for Windows CE:
14758
14759@table @code
14760@item set remotedirectory @var{dir}
14761@kindex set remotedirectory
14762Tell @value{GDBN} to upload files from the named directory @var{dir}.
14763The default is @file{/gdb}, i.e.@: the root directory on the current
14764drive.
14765
14766@item show remotedirectory
14767@kindex show remotedirectory
14768Show the current value of the upload directory.
14769
14770@item set remoteupload @var{method}
14771@kindex set remoteupload
14772Set the method used to upload files to remote device. Valid values
14773for @var{method} are @samp{always}, @samp{newer}, and @samp{never}.
14774The default is @samp{newer}.
14775
14776@item show remoteupload
14777@kindex show remoteupload
14778Show the current setting of the upload method.
14779
14780@item set remoteaddhost
14781@kindex set remoteaddhost
14782Tell @value{GDBN} whether to add this host to the remote stub's
14783arguments when you debug over a network.
14784
14785@item show remoteaddhost
14786@kindex show remoteaddhost
14787Show whether to add this host to remote stub's arguments when
14788debugging over a network.
14789@end table
14790
a64548ea 14791
8e04817f
AC
14792@node Architectures
14793@section Architectures
104c1213 14794
8e04817f
AC
14795This section describes characteristics of architectures that affect
14796all uses of @value{GDBN} with the architecture, both native and cross.
104c1213 14797
8e04817f 14798@menu
9c16f35a 14799* i386::
8e04817f
AC
14800* A29K::
14801* Alpha::
14802* MIPS::
a64548ea 14803* HPPA:: HP PA architecture
8e04817f 14804@end menu
104c1213 14805
9c16f35a
EZ
14806@node i386
14807@subsection x86 Architecture-specific issues.
14808
14809@table @code
14810@item set struct-convention @var{mode}
14811@kindex set struct-convention
14812@cindex struct return convention
14813@cindex struct/union returned in registers
14814Set the convention used by the inferior to return @code{struct}s and
14815@code{union}s from functions to @var{mode}. Possible values of
14816@var{mode} are @code{"pcc"}, @code{"reg"}, and @code{"default"} (the
14817default). @code{"default"} or @code{"pcc"} means that @code{struct}s
14818are returned on the stack, while @code{"reg"} means that a
14819@code{struct} or a @code{union} whose size is 1, 2, 4, or 8 bytes will
14820be returned in a register.
14821
14822@item show struct-convention
14823@kindex show struct-convention
14824Show the current setting of the convention to return @code{struct}s
14825from functions.
14826@end table
14827
8e04817f
AC
14828@node A29K
14829@subsection A29K
104c1213
JM
14830
14831@table @code
104c1213 14832
8e04817f
AC
14833@kindex set rstack_high_address
14834@cindex AMD 29K register stack
14835@cindex register stack, AMD29K
14836@item set rstack_high_address @var{address}
14837On AMD 29000 family processors, registers are saved in a separate
14838@dfn{register stack}. There is no way for @value{GDBN} to determine the
14839extent of this stack. Normally, @value{GDBN} just assumes that the
14840stack is ``large enough''. This may result in @value{GDBN} referencing
14841memory locations that do not exist. If necessary, you can get around
14842this problem by specifying the ending address of the register stack with
14843the @code{set rstack_high_address} command. The argument should be an
14844address, which you probably want to precede with @samp{0x} to specify in
14845hexadecimal.
104c1213 14846
8e04817f
AC
14847@kindex show rstack_high_address
14848@item show rstack_high_address
14849Display the current limit of the register stack, on AMD 29000 family
14850processors.
104c1213 14851
8e04817f 14852@end table
104c1213 14853
8e04817f
AC
14854@node Alpha
14855@subsection Alpha
104c1213 14856
8e04817f 14857See the following section.
104c1213 14858
8e04817f
AC
14859@node MIPS
14860@subsection MIPS
104c1213 14861
8e04817f
AC
14862@cindex stack on Alpha
14863@cindex stack on MIPS
14864@cindex Alpha stack
14865@cindex MIPS stack
14866Alpha- and MIPS-based computers use an unusual stack frame, which
14867sometimes requires @value{GDBN} to search backward in the object code to
14868find the beginning of a function.
104c1213 14869
8e04817f
AC
14870@cindex response time, MIPS debugging
14871To improve response time (especially for embedded applications, where
14872@value{GDBN} may be restricted to a slow serial line for this search)
14873you may want to limit the size of this search, using one of these
14874commands:
104c1213 14875
8e04817f
AC
14876@table @code
14877@cindex @code{heuristic-fence-post} (Alpha, MIPS)
14878@item set heuristic-fence-post @var{limit}
14879Restrict @value{GDBN} to examining at most @var{limit} bytes in its
14880search for the beginning of a function. A value of @var{0} (the
14881default) means there is no limit. However, except for @var{0}, the
14882larger the limit the more bytes @code{heuristic-fence-post} must search
e2f4edfd
EZ
14883and therefore the longer it takes to run. You should only need to use
14884this command when debugging a stripped executable.
104c1213 14885
8e04817f
AC
14886@item show heuristic-fence-post
14887Display the current limit.
14888@end table
104c1213
JM
14889
14890@noindent
8e04817f
AC
14891These commands are available @emph{only} when @value{GDBN} is configured
14892for debugging programs on Alpha or MIPS processors.
104c1213 14893
a64548ea
EZ
14894Several MIPS-specific commands are available when debugging MIPS
14895programs:
14896
14897@table @code
14898@item set mips saved-gpreg-size @var{size}
14899@kindex set mips saved-gpreg-size
14900@cindex MIPS GP register size on stack
14901Set the size of MIPS general-purpose registers saved on the stack.
14902The argument @var{size} can be one of the following:
14903
14904@table @samp
14905@item 32
1490632-bit GP registers
14907@item 64
1490864-bit GP registers
14909@item auto
14910Use the target's default setting or autodetect the saved size from the
14911information contained in the executable. This is the default
14912@end table
14913
14914@item show mips saved-gpreg-size
14915@kindex show mips saved-gpreg-size
14916Show the current size of MIPS GP registers on the stack.
14917
14918@item set mips stack-arg-size @var{size}
14919@kindex set mips stack-arg-size
14920@cindex MIPS stack space for arguments
14921Set the amount of stack space reserved for arguments to functions.
14922The argument can be one of @code{"32"}, @code{"64"} or @code{"auto"}
14923(the default).
14924
14925@item set mips abi @var{arg}
14926@kindex set mips abi
14927@cindex set ABI for MIPS
14928Tell @value{GDBN} which MIPS ABI is used by the inferior. Possible
14929values of @var{arg} are:
14930
14931@table @samp
14932@item auto
14933The default ABI associated with the current binary (this is the
14934default).
14935@item o32
14936@item o64
14937@item n32
14938@item n64
14939@item eabi32
14940@item eabi64
14941@item auto
14942@end table
14943
14944@item show mips abi
14945@kindex show mips abi
14946Show the MIPS ABI used by @value{GDBN} to debug the inferior.
14947
14948@item set mipsfpu
14949@itemx show mipsfpu
14950@xref{MIPS Embedded, set mipsfpu}.
14951
14952@item set mips mask-address @var{arg}
14953@kindex set mips mask-address
14954@cindex MIPS addresses, masking
14955This command determines whether the most-significant 32 bits of 64-bit
14956MIPS addresses are masked off. The argument @var{arg} can be
14957@samp{on}, @samp{off}, or @samp{auto}. The latter is the default
14958setting, which lets @value{GDBN} determine the correct value.
14959
14960@item show mips mask-address
14961@kindex show mips mask-address
14962Show whether the upper 32 bits of MIPS addresses are masked off or
14963not.
14964
14965@item set remote-mips64-transfers-32bit-regs
14966@kindex set remote-mips64-transfers-32bit-regs
14967This command controls compatibility with 64-bit MIPS targets that
14968transfer data in 32-bit quantities. If you have an old MIPS 64 target
14969that transfers 32 bits for some registers, like @sc{sr} and @sc{fsr},
14970and 64 bits for other registers, set this option to @samp{on}.
14971
14972@item show remote-mips64-transfers-32bit-regs
14973@kindex show remote-mips64-transfers-32bit-regs
14974Show the current setting of compatibility with older MIPS 64 targets.
14975
14976@item set debug mips
14977@kindex set debug mips
14978This command turns on and off debugging messages for the MIPS-specific
14979target code in @value{GDBN}.
14980
14981@item show debug mips
14982@kindex show debug mips
14983Show the current setting of MIPS debugging messages.
14984@end table
14985
14986
14987@node HPPA
14988@subsection HPPA
14989@cindex HPPA support
14990
14991When @value{GDBN} is debugging te HP PA architecture, it provides the
14992following special commands:
14993
14994@table @code
14995@item set debug hppa
14996@kindex set debug hppa
14997THis command determines whether HPPA architecture specific debugging
14998messages are to be displayed.
14999
15000@item show debug hppa
15001Show whether HPPA debugging messages are displayed.
15002
15003@item maint print unwind @var{address}
15004@kindex maint print unwind@r{, HPPA}
15005This command displays the contents of the unwind table entry at the
15006given @var{address}.
15007
15008@end table
15009
104c1213 15010
8e04817f
AC
15011@node Controlling GDB
15012@chapter Controlling @value{GDBN}
15013
15014You can alter the way @value{GDBN} interacts with you by using the
15015@code{set} command. For commands controlling how @value{GDBN} displays
15016data, see @ref{Print Settings, ,Print settings}. Other settings are
15017described here.
15018
15019@menu
15020* Prompt:: Prompt
15021* Editing:: Command editing
15022* History:: Command history
15023* Screen Size:: Screen size
15024* Numbers:: Numbers
1e698235 15025* ABI:: Configuring the current ABI
8e04817f
AC
15026* Messages/Warnings:: Optional warnings and messages
15027* Debugging Output:: Optional messages about internal happenings
15028@end menu
15029
15030@node Prompt
15031@section Prompt
104c1213 15032
8e04817f 15033@cindex prompt
104c1213 15034
8e04817f
AC
15035@value{GDBN} indicates its readiness to read a command by printing a string
15036called the @dfn{prompt}. This string is normally @samp{(@value{GDBP})}. You
15037can change the prompt string with the @code{set prompt} command. For
15038instance, when debugging @value{GDBN} with @value{GDBN}, it is useful to change
15039the prompt in one of the @value{GDBN} sessions so that you can always tell
15040which one you are talking to.
104c1213 15041
8e04817f
AC
15042@emph{Note:} @code{set prompt} does not add a space for you after the
15043prompt you set. This allows you to set a prompt which ends in a space
15044or a prompt that does not.
104c1213 15045
8e04817f
AC
15046@table @code
15047@kindex set prompt
15048@item set prompt @var{newprompt}
15049Directs @value{GDBN} to use @var{newprompt} as its prompt string henceforth.
104c1213 15050
8e04817f
AC
15051@kindex show prompt
15052@item show prompt
15053Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}}
104c1213
JM
15054@end table
15055
8e04817f
AC
15056@node Editing
15057@section Command editing
15058@cindex readline
15059@cindex command line editing
104c1213 15060
703663ab 15061@value{GDBN} reads its input commands via the @dfn{Readline} interface. This
8e04817f
AC
15062@sc{gnu} library provides consistent behavior for programs which provide a
15063command line interface to the user. Advantages are @sc{gnu} Emacs-style
15064or @dfn{vi}-style inline editing of commands, @code{csh}-like history
15065substitution, and a storage and recall of command history across
15066debugging sessions.
104c1213 15067
8e04817f
AC
15068You may control the behavior of command line editing in @value{GDBN} with the
15069command @code{set}.
104c1213 15070
8e04817f
AC
15071@table @code
15072@kindex set editing
15073@cindex editing
15074@item set editing
15075@itemx set editing on
15076Enable command line editing (enabled by default).
104c1213 15077
8e04817f
AC
15078@item set editing off
15079Disable command line editing.
104c1213 15080
8e04817f
AC
15081@kindex show editing
15082@item show editing
15083Show whether command line editing is enabled.
104c1213
JM
15084@end table
15085
703663ab
EZ
15086@xref{Command Line Editing}, for more details about the Readline
15087interface. Users unfamiliar with @sc{gnu} Emacs or @code{vi} are
15088encouraged to read that chapter.
15089
8e04817f
AC
15090@node History
15091@section Command history
703663ab 15092@cindex command history
8e04817f
AC
15093
15094@value{GDBN} can keep track of the commands you type during your
15095debugging sessions, so that you can be certain of precisely what
15096happened. Use these commands to manage the @value{GDBN} command
15097history facility.
104c1213 15098
703663ab
EZ
15099@value{GDBN} uses the @sc{gnu} History library, a part of the Readline
15100package, to provide the history facility. @xref{Using History
15101Interactively}, for the detailed description of the History library.
15102
15103Here is the description of @value{GDBN} commands related to command
15104history.
15105
104c1213 15106@table @code
8e04817f
AC
15107@cindex history substitution
15108@cindex history file
15109@kindex set history filename
4644b6e3 15110@cindex @env{GDBHISTFILE}, environment variable
8e04817f
AC
15111@item set history filename @var{fname}
15112Set the name of the @value{GDBN} command history file to @var{fname}.
15113This is the file where @value{GDBN} reads an initial command history
15114list, and where it writes the command history from this session when it
15115exits. You can access this list through history expansion or through
15116the history command editing characters listed below. This file defaults
15117to the value of the environment variable @code{GDBHISTFILE}, or to
15118@file{./.gdb_history} (@file{./_gdb_history} on MS-DOS) if this variable
15119is not set.
104c1213 15120
9c16f35a
EZ
15121@cindex save command history
15122@kindex set history save
8e04817f
AC
15123@item set history save
15124@itemx set history save on
15125Record command history in a file, whose name may be specified with the
15126@code{set history filename} command. By default, this option is disabled.
104c1213 15127
8e04817f
AC
15128@item set history save off
15129Stop recording command history in a file.
104c1213 15130
8e04817f 15131@cindex history size
9c16f35a 15132@kindex set history size
6fc08d32 15133@cindex @env{HISTSIZE}, environment variable
8e04817f
AC
15134@item set history size @var{size}
15135Set the number of commands which @value{GDBN} keeps in its history list.
15136This defaults to the value of the environment variable
15137@code{HISTSIZE}, or to 256 if this variable is not set.
104c1213
JM
15138@end table
15139
8e04817f 15140History expansion assigns special meaning to the character @kbd{!}.
703663ab 15141@xref{Event Designators}, for more details.
8e04817f 15142
703663ab 15143@cindex history expansion, turn on/off
8e04817f
AC
15144Since @kbd{!} is also the logical not operator in C, history expansion
15145is off by default. If you decide to enable history expansion with the
15146@code{set history expansion on} command, you may sometimes need to
15147follow @kbd{!} (when it is used as logical not, in an expression) with
15148a space or a tab to prevent it from being expanded. The readline
15149history facilities do not attempt substitution on the strings
15150@kbd{!=} and @kbd{!(}, even when history expansion is enabled.
15151
15152The commands to control history expansion are:
104c1213
JM
15153
15154@table @code
8e04817f
AC
15155@item set history expansion on
15156@itemx set history expansion
703663ab 15157@kindex set history expansion
8e04817f 15158Enable history expansion. History expansion is off by default.
104c1213 15159
8e04817f
AC
15160@item set history expansion off
15161Disable history expansion.
104c1213 15162
8e04817f
AC
15163@c @group
15164@kindex show history
15165@item show history
15166@itemx show history filename
15167@itemx show history save
15168@itemx show history size
15169@itemx show history expansion
15170These commands display the state of the @value{GDBN} history parameters.
15171@code{show history} by itself displays all four states.
15172@c @end group
15173@end table
15174
15175@table @code
9c16f35a
EZ
15176@kindex show commands
15177@cindex show last commands
15178@cindex display command history
8e04817f
AC
15179@item show commands
15180Display the last ten commands in the command history.
104c1213 15181
8e04817f
AC
15182@item show commands @var{n}
15183Print ten commands centered on command number @var{n}.
15184
15185@item show commands +
15186Print ten commands just after the commands last printed.
104c1213
JM
15187@end table
15188
8e04817f
AC
15189@node Screen Size
15190@section Screen size
15191@cindex size of screen
15192@cindex pauses in output
104c1213 15193
8e04817f
AC
15194Certain commands to @value{GDBN} may produce large amounts of
15195information output to the screen. To help you read all of it,
15196@value{GDBN} pauses and asks you for input at the end of each page of
15197output. Type @key{RET} when you want to continue the output, or @kbd{q}
15198to discard the remaining output. Also, the screen width setting
15199determines when to wrap lines of output. Depending on what is being
15200printed, @value{GDBN} tries to break the line at a readable place,
15201rather than simply letting it overflow onto the following line.
15202
15203Normally @value{GDBN} knows the size of the screen from the terminal
15204driver software. For example, on Unix @value{GDBN} uses the termcap data base
15205together with the value of the @code{TERM} environment variable and the
15206@code{stty rows} and @code{stty cols} settings. If this is not correct,
15207you can override it with the @code{set height} and @code{set
15208width} commands:
15209
15210@table @code
15211@kindex set height
15212@kindex set width
15213@kindex show width
15214@kindex show height
15215@item set height @var{lpp}
15216@itemx show height
15217@itemx set width @var{cpl}
15218@itemx show width
15219These @code{set} commands specify a screen height of @var{lpp} lines and
15220a screen width of @var{cpl} characters. The associated @code{show}
15221commands display the current settings.
104c1213 15222
8e04817f
AC
15223If you specify a height of zero lines, @value{GDBN} does not pause during
15224output no matter how long the output is. This is useful if output is to a
15225file or to an editor buffer.
104c1213 15226
8e04817f
AC
15227Likewise, you can specify @samp{set width 0} to prevent @value{GDBN}
15228from wrapping its output.
9c16f35a
EZ
15229
15230@item set pagination on
15231@itemx set pagination off
15232@kindex set pagination
15233Turn the output pagination on or off; the default is on. Turning
15234pagination off is the alternative to @code{set height 0}.
15235
15236@item show pagination
15237@kindex show pagination
15238Show the current pagination mode.
104c1213
JM
15239@end table
15240
8e04817f
AC
15241@node Numbers
15242@section Numbers
15243@cindex number representation
15244@cindex entering numbers
104c1213 15245
8e04817f
AC
15246You can always enter numbers in octal, decimal, or hexadecimal in
15247@value{GDBN} by the usual conventions: octal numbers begin with
15248@samp{0}, decimal numbers end with @samp{.}, and hexadecimal numbers
eb2dae08
EZ
15249begin with @samp{0x}. Numbers that neither begin with @samp{0} or
15250@samp{0x}, nor end with a @samp{.} are, by default, entered in base
1525110; likewise, the default display for numbers---when no particular
15252format is specified---is base 10. You can change the default base for
15253both input and output with the commands described below.
104c1213 15254
8e04817f
AC
15255@table @code
15256@kindex set input-radix
15257@item set input-radix @var{base}
15258Set the default base for numeric input. Supported choices
15259for @var{base} are decimal 8, 10, or 16. @var{base} must itself be
eb2dae08 15260specified either unambiguously or using the current input radix; for
8e04817f 15261example, any of
104c1213 15262
8e04817f 15263@smallexample
9c16f35a
EZ
15264set input-radix 012
15265set input-radix 10.
15266set input-radix 0xa
8e04817f 15267@end smallexample
104c1213 15268
8e04817f 15269@noindent
9c16f35a 15270sets the input base to decimal. On the other hand, @samp{set input-radix 10}
eb2dae08
EZ
15271leaves the input radix unchanged, no matter what it was, since
15272@samp{10}, being without any leading or trailing signs of its base, is
15273interpreted in the current radix. Thus, if the current radix is 16,
15274@samp{10} is interpreted in hex, i.e.@: as 16 decimal, which doesn't
15275change the radix.
104c1213 15276
8e04817f
AC
15277@kindex set output-radix
15278@item set output-radix @var{base}
15279Set the default base for numeric display. Supported choices
15280for @var{base} are decimal 8, 10, or 16. @var{base} must itself be
eb2dae08 15281specified either unambiguously or using the current input radix.
104c1213 15282
8e04817f
AC
15283@kindex show input-radix
15284@item show input-radix
15285Display the current default base for numeric input.
104c1213 15286
8e04817f
AC
15287@kindex show output-radix
15288@item show output-radix
15289Display the current default base for numeric display.
9c16f35a
EZ
15290
15291@item set radix @r{[}@var{base}@r{]}
15292@itemx show radix
15293@kindex set radix
15294@kindex show radix
15295These commands set and show the default base for both input and output
15296of numbers. @code{set radix} sets the radix of input and output to
15297the same base; without an argument, it resets the radix back to its
15298default value of 10.
15299
8e04817f 15300@end table
104c1213 15301
1e698235
DJ
15302@node ABI
15303@section Configuring the current ABI
15304
15305@value{GDBN} can determine the @dfn{ABI} (Application Binary Interface) of your
15306application automatically. However, sometimes you need to override its
15307conclusions. Use these commands to manage @value{GDBN}'s view of the
15308current ABI.
15309
98b45e30
DJ
15310@cindex OS ABI
15311@kindex set osabi
b4e9345d 15312@kindex show osabi
98b45e30
DJ
15313
15314One @value{GDBN} configuration can debug binaries for multiple operating
b383017d 15315system targets, either via remote debugging or native emulation.
98b45e30
DJ
15316@value{GDBN} will autodetect the @dfn{OS ABI} (Operating System ABI) in use,
15317but you can override its conclusion using the @code{set osabi} command.
15318One example where this is useful is in debugging of binaries which use
15319an alternate C library (e.g.@: @sc{uClibc} for @sc{gnu}/Linux) which does
15320not have the same identifying marks that the standard C library for your
15321platform provides.
15322
15323@table @code
15324@item show osabi
15325Show the OS ABI currently in use.
15326
15327@item set osabi
15328With no argument, show the list of registered available OS ABI's.
15329
15330@item set osabi @var{abi}
15331Set the current OS ABI to @var{abi}.
15332@end table
15333
1e698235 15334@cindex float promotion
1e698235
DJ
15335
15336Generally, the way that an argument of type @code{float} is passed to a
15337function depends on whether the function is prototyped. For a prototyped
15338(i.e.@: ANSI/ISO style) function, @code{float} arguments are passed unchanged,
15339according to the architecture's convention for @code{float}. For unprototyped
15340(i.e.@: K&R style) functions, @code{float} arguments are first promoted to type
15341@code{double} and then passed.
15342
15343Unfortunately, some forms of debug information do not reliably indicate whether
15344a function is prototyped. If @value{GDBN} calls a function that is not marked
15345as prototyped, it consults @kbd{set coerce-float-to-double}.
15346
15347@table @code
a8f24a35 15348@kindex set coerce-float-to-double
1e698235
DJ
15349@item set coerce-float-to-double
15350@itemx set coerce-float-to-double on
15351Arguments of type @code{float} will be promoted to @code{double} when passed
15352to an unprototyped function. This is the default setting.
15353
15354@item set coerce-float-to-double off
15355Arguments of type @code{float} will be passed directly to unprototyped
15356functions.
9c16f35a
EZ
15357
15358@kindex show coerce-float-to-double
15359@item show coerce-float-to-double
15360Show the current setting of promoting @code{float} to @code{double}.
1e698235
DJ
15361@end table
15362
f1212245
DJ
15363@kindex set cp-abi
15364@kindex show cp-abi
15365@value{GDBN} needs to know the ABI used for your program's C@t{++}
15366objects. The correct C@t{++} ABI depends on which C@t{++} compiler was
15367used to build your application. @value{GDBN} only fully supports
15368programs with a single C@t{++} ABI; if your program contains code using
15369multiple C@t{++} ABI's or if @value{GDBN} can not identify your
15370program's ABI correctly, you can tell @value{GDBN} which ABI to use.
15371Currently supported ABI's include ``gnu-v2'', for @code{g++} versions
15372before 3.0, ``gnu-v3'', for @code{g++} versions 3.0 and later, and
15373``hpaCC'' for the HP ANSI C@t{++} compiler. Other C@t{++} compilers may
15374use the ``gnu-v2'' or ``gnu-v3'' ABI's as well. The default setting is
15375``auto''.
15376
15377@table @code
15378@item show cp-abi
15379Show the C@t{++} ABI currently in use.
15380
15381@item set cp-abi
15382With no argument, show the list of supported C@t{++} ABI's.
15383
15384@item set cp-abi @var{abi}
15385@itemx set cp-abi auto
15386Set the current C@t{++} ABI to @var{abi}, or return to automatic detection.
15387@end table
15388
8e04817f
AC
15389@node Messages/Warnings
15390@section Optional warnings and messages
104c1213 15391
9c16f35a
EZ
15392@cindex verbose operation
15393@cindex optional warnings
8e04817f
AC
15394By default, @value{GDBN} is silent about its inner workings. If you are
15395running on a slow machine, you may want to use the @code{set verbose}
15396command. This makes @value{GDBN} tell you when it does a lengthy
15397internal operation, so you will not think it has crashed.
104c1213 15398
8e04817f
AC
15399Currently, the messages controlled by @code{set verbose} are those
15400which announce that the symbol table for a source file is being read;
15401see @code{symbol-file} in @ref{Files, ,Commands to specify files}.
104c1213 15402
8e04817f
AC
15403@table @code
15404@kindex set verbose
15405@item set verbose on
15406Enables @value{GDBN} output of certain informational messages.
104c1213 15407
8e04817f
AC
15408@item set verbose off
15409Disables @value{GDBN} output of certain informational messages.
104c1213 15410
8e04817f
AC
15411@kindex show verbose
15412@item show verbose
15413Displays whether @code{set verbose} is on or off.
15414@end table
104c1213 15415
8e04817f
AC
15416By default, if @value{GDBN} encounters bugs in the symbol table of an
15417object file, it is silent; but if you are debugging a compiler, you may
15418find this information useful (@pxref{Symbol Errors, ,Errors reading
15419symbol files}).
104c1213 15420
8e04817f 15421@table @code
104c1213 15422
8e04817f
AC
15423@kindex set complaints
15424@item set complaints @var{limit}
15425Permits @value{GDBN} to output @var{limit} complaints about each type of
15426unusual symbols before becoming silent about the problem. Set
15427@var{limit} to zero to suppress all complaints; set it to a large number
15428to prevent complaints from being suppressed.
104c1213 15429
8e04817f
AC
15430@kindex show complaints
15431@item show complaints
15432Displays how many symbol complaints @value{GDBN} is permitted to produce.
104c1213 15433
8e04817f 15434@end table
104c1213 15435
8e04817f
AC
15436By default, @value{GDBN} is cautious, and asks what sometimes seems to be a
15437lot of stupid questions to confirm certain commands. For example, if
15438you try to run a program which is already running:
104c1213 15439
474c8240 15440@smallexample
8e04817f
AC
15441(@value{GDBP}) run
15442The program being debugged has been started already.
15443Start it from the beginning? (y or n)
474c8240 15444@end smallexample
104c1213 15445
8e04817f
AC
15446If you are willing to unflinchingly face the consequences of your own
15447commands, you can disable this ``feature'':
104c1213 15448
8e04817f 15449@table @code
104c1213 15450
8e04817f
AC
15451@kindex set confirm
15452@cindex flinching
15453@cindex confirmation
15454@cindex stupid questions
15455@item set confirm off
15456Disables confirmation requests.
104c1213 15457
8e04817f
AC
15458@item set confirm on
15459Enables confirmation requests (the default).
104c1213 15460
8e04817f
AC
15461@kindex show confirm
15462@item show confirm
15463Displays state of confirmation requests.
15464
15465@end table
104c1213 15466
8e04817f
AC
15467@node Debugging Output
15468@section Optional messages about internal happenings
4644b6e3
EZ
15469@cindex optional debugging messages
15470
da316a69
EZ
15471@value{GDBN} has commands that enable optional debugging messages from
15472various @value{GDBN} subsystems; normally these commands are of
15473interest to @value{GDBN} maintainers, or when reporting a bug. This
15474section documents those commands.
15475
104c1213 15476@table @code
a8f24a35
EZ
15477@kindex set exec-done-display
15478@item set exec-done-display
15479Turns on or off the notification of asynchronous commands'
15480completion. When on, @value{GDBN} will print a message when an
15481asynchronous command finishes its execution. The default is off.
15482@kindex show exec-done-display
15483@item show exec-done-display
15484Displays the current setting of asynchronous command completion
15485notification.
4644b6e3
EZ
15486@kindex set debug
15487@cindex gdbarch debugging info
a8f24a35 15488@cindex architecture debugging info
8e04817f 15489@item set debug arch
a8f24a35 15490Turns on or off display of gdbarch debugging info. The default is off
4644b6e3 15491@kindex show debug
8e04817f
AC
15492@item show debug arch
15493Displays the current state of displaying gdbarch debugging info.
721c2651
EZ
15494@item set debug aix-thread
15495@cindex AIX threads
15496Display debugging messages about inner workings of the AIX thread
15497module.
15498@item show debug aix-thread
15499Show the current state of AIX thread debugging info display.
8e04817f 15500@item set debug event
4644b6e3 15501@cindex event debugging info
a8f24a35 15502Turns on or off display of @value{GDBN} event debugging info. The
8e04817f 15503default is off.
8e04817f
AC
15504@item show debug event
15505Displays the current state of displaying @value{GDBN} event debugging
15506info.
8e04817f 15507@item set debug expression
4644b6e3 15508@cindex expression debugging info
721c2651
EZ
15509Turns on or off display of debugging info about @value{GDBN}
15510expression parsing. The default is off.
8e04817f 15511@item show debug expression
721c2651
EZ
15512Displays the current state of displaying debugging info about
15513@value{GDBN} expression parsing.
7453dc06 15514@item set debug frame
4644b6e3 15515@cindex frame debugging info
7453dc06
AC
15516Turns on or off display of @value{GDBN} frame debugging info. The
15517default is off.
7453dc06
AC
15518@item show debug frame
15519Displays the current state of displaying @value{GDBN} frame debugging
15520info.
30e91e0b
RC
15521@item set debug infrun
15522@cindex inferior debugging info
15523Turns on or off display of @value{GDBN} debugging info for running the inferior.
15524The default is off. @file{infrun.c} contains GDB's runtime state machine used
15525for implementing operations such as single-stepping the inferior.
15526@item show debug infrun
15527Displays the current state of @value{GDBN} inferior debugging.
da316a69
EZ
15528@item set debug lin-lwp
15529@cindex @sc{gnu}/Linux LWP debug messages
15530@cindex Linux lightweight processes
721c2651 15531Turns on or off debugging messages from the Linux LWP debug support.
da316a69
EZ
15532@item show debug lin-lwp
15533Show the current state of Linux LWP debugging messages.
2b4855ab 15534@item set debug observer
4644b6e3 15535@cindex observer debugging info
2b4855ab
AC
15536Turns on or off display of @value{GDBN} observer debugging. This
15537includes info such as the notification of observable events.
2b4855ab
AC
15538@item show debug observer
15539Displays the current state of observer debugging.
8e04817f 15540@item set debug overload
4644b6e3 15541@cindex C@t{++} overload debugging info
8e04817f
AC
15542Turns on or off display of @value{GDBN} C@t{++} overload debugging
15543info. This includes info such as ranking of functions, etc. The default
15544is off.
8e04817f
AC
15545@item show debug overload
15546Displays the current state of displaying @value{GDBN} C@t{++} overload
15547debugging info.
8e04817f
AC
15548@cindex packets, reporting on stdout
15549@cindex serial connections, debugging
15550@item set debug remote
15551Turns on or off display of reports on all packets sent back and forth across
15552the serial line to the remote machine. The info is printed on the
15553@value{GDBN} standard output stream. The default is off.
8e04817f
AC
15554@item show debug remote
15555Displays the state of display of remote packets.
8e04817f
AC
15556@item set debug serial
15557Turns on or off display of @value{GDBN} serial debugging info. The
15558default is off.
8e04817f
AC
15559@item show debug serial
15560Displays the current state of displaying @value{GDBN} serial debugging
15561info.
c45da7e6
EZ
15562@item set debug solib-frv
15563@cindex FR-V shared-library debugging
15564Turns on or off debugging messages for FR-V shared-library code.
15565@item show debug solib-frv
15566Display the current state of FR-V shared-library code debugging
15567messages.
8e04817f 15568@item set debug target
4644b6e3 15569@cindex target debugging info
8e04817f
AC
15570Turns on or off display of @value{GDBN} target debugging info. This info
15571includes what is going on at the target level of GDB, as it happens. The
701b08bb
DJ
15572default is 0. Set it to 1 to track events, and to 2 to also track the
15573value of large memory transfers. Changes to this flag do not take effect
15574until the next time you connect to a target or use the @code{run} command.
8e04817f
AC
15575@item show debug target
15576Displays the current state of displaying @value{GDBN} target debugging
15577info.
c45da7e6 15578@item set debugvarobj
4644b6e3 15579@cindex variable object debugging info
8e04817f
AC
15580Turns on or off display of @value{GDBN} variable object debugging
15581info. The default is off.
c45da7e6 15582@item show debugvarobj
8e04817f
AC
15583Displays the current state of displaying @value{GDBN} variable object
15584debugging info.
15585@end table
104c1213 15586
8e04817f
AC
15587@node Sequences
15588@chapter Canned Sequences of Commands
104c1213 15589
8e04817f
AC
15590Aside from breakpoint commands (@pxref{Break Commands, ,Breakpoint
15591command lists}), @value{GDBN} provides two ways to store sequences of
15592commands for execution as a unit: user-defined commands and command
15593files.
104c1213 15594
8e04817f
AC
15595@menu
15596* Define:: User-defined commands
15597* Hooks:: User-defined command hooks
15598* Command Files:: Command files
15599* Output:: Commands for controlled output
15600@end menu
104c1213 15601
8e04817f
AC
15602@node Define
15603@section User-defined commands
104c1213 15604
8e04817f
AC
15605@cindex user-defined command
15606A @dfn{user-defined command} is a sequence of @value{GDBN} commands to
15607which you assign a new name as a command. This is done with the
15608@code{define} command. User commands may accept up to 10 arguments
15609separated by whitespace. Arguments are accessed within the user command
15610via @var{$arg0@dots{}$arg9}. A trivial example:
104c1213 15611
8e04817f
AC
15612@smallexample
15613define adder
15614 print $arg0 + $arg1 + $arg2
15615@end smallexample
104c1213
JM
15616
15617@noindent
8e04817f 15618To execute the command use:
104c1213 15619
8e04817f
AC
15620@smallexample
15621adder 1 2 3
15622@end smallexample
104c1213 15623
8e04817f
AC
15624@noindent
15625This defines the command @code{adder}, which prints the sum of
15626its three arguments. Note the arguments are text substitutions, so they may
15627reference variables, use complex expressions, or even perform inferior
15628functions calls.
104c1213
JM
15629
15630@table @code
104c1213 15631
8e04817f
AC
15632@kindex define
15633@item define @var{commandname}
15634Define a command named @var{commandname}. If there is already a command
15635by that name, you are asked to confirm that you want to redefine it.
104c1213 15636
8e04817f
AC
15637The definition of the command is made up of other @value{GDBN} command lines,
15638which are given following the @code{define} command. The end of these
15639commands is marked by a line containing @code{end}.
104c1213 15640
8e04817f
AC
15641@kindex if
15642@kindex else
15643@item if
09d4efe1 15644@itemx else
8e04817f
AC
15645Takes a single argument, which is an expression to evaluate.
15646It is followed by a series of commands that are executed
15647only if the expression is true (nonzero).
15648There can then optionally be a line @code{else}, followed
15649by a series of commands that are only executed if the expression
15650was false. The end of the list is marked by a line containing @code{end}.
104c1213 15651
8e04817f
AC
15652@kindex while
15653@item while
15654The syntax is similar to @code{if}: the command takes a single argument,
15655which is an expression to evaluate, and must be followed by the commands to
15656execute, one per line, terminated by an @code{end}.
15657The commands are executed repeatedly as long as the expression
15658evaluates to true.
104c1213 15659
8e04817f
AC
15660@kindex document
15661@item document @var{commandname}
15662Document the user-defined command @var{commandname}, so that it can be
15663accessed by @code{help}. The command @var{commandname} must already be
15664defined. This command reads lines of documentation just as @code{define}
15665reads the lines of the command definition, ending with @code{end}.
15666After the @code{document} command is finished, @code{help} on command
15667@var{commandname} displays the documentation you have written.
104c1213 15668
8e04817f
AC
15669You may use the @code{document} command again to change the
15670documentation of a command. Redefining the command with @code{define}
15671does not change the documentation.
104c1213 15672
c45da7e6
EZ
15673@kindex dont-repeat
15674@cindex don't repeat command
15675@item dont-repeat
15676Used inside a user-defined command, this tells @value{GDBN} that this
15677command should not be repeated when the user hits @key{RET}
15678(@pxref{Command Syntax, repeat last command}).
15679
8e04817f
AC
15680@kindex help user-defined
15681@item help user-defined
15682List all user-defined commands, with the first line of the documentation
15683(if any) for each.
104c1213 15684
8e04817f
AC
15685@kindex show user
15686@item show user
15687@itemx show user @var{commandname}
15688Display the @value{GDBN} commands used to define @var{commandname} (but
15689not its documentation). If no @var{commandname} is given, display the
15690definitions for all user-defined commands.
104c1213 15691
9c16f35a 15692@cindex infinite recusrion in user-defined commands
20f01a46
DH
15693@kindex show max-user-call-depth
15694@kindex set max-user-call-depth
15695@item show max-user-call-depth
5ca0cb28
DH
15696@itemx set max-user-call-depth
15697The value of @code{max-user-call-depth} controls how many recursion
15698levels are allowed in user-defined commands before GDB suspects an
15699infinite recursion and aborts the command.
20f01a46 15700
104c1213
JM
15701@end table
15702
8e04817f
AC
15703When user-defined commands are executed, the
15704commands of the definition are not printed. An error in any command
15705stops execution of the user-defined command.
104c1213 15706
8e04817f
AC
15707If used interactively, commands that would ask for confirmation proceed
15708without asking when used inside a user-defined command. Many @value{GDBN}
15709commands that normally print messages to say what they are doing omit the
15710messages when used in a user-defined command.
104c1213 15711
8e04817f
AC
15712@node Hooks
15713@section User-defined command hooks
15714@cindex command hooks
15715@cindex hooks, for commands
15716@cindex hooks, pre-command
104c1213 15717
8e04817f 15718@kindex hook
8e04817f
AC
15719You may define @dfn{hooks}, which are a special kind of user-defined
15720command. Whenever you run the command @samp{foo}, if the user-defined
15721command @samp{hook-foo} exists, it is executed (with no arguments)
15722before that command.
104c1213 15723
8e04817f
AC
15724@cindex hooks, post-command
15725@kindex hookpost
8e04817f
AC
15726A hook may also be defined which is run after the command you executed.
15727Whenever you run the command @samp{foo}, if the user-defined command
15728@samp{hookpost-foo} exists, it is executed (with no arguments) after
15729that command. Post-execution hooks may exist simultaneously with
15730pre-execution hooks, for the same command.
104c1213 15731
8e04817f 15732It is valid for a hook to call the command which it hooks. If this
9f1c6395 15733occurs, the hook is not re-executed, thereby avoiding infinite recursion.
104c1213 15734
8e04817f
AC
15735@c It would be nice if hookpost could be passed a parameter indicating
15736@c if the command it hooks executed properly or not. FIXME!
104c1213 15737
8e04817f
AC
15738@kindex stop@r{, a pseudo-command}
15739In addition, a pseudo-command, @samp{stop} exists. Defining
15740(@samp{hook-stop}) makes the associated commands execute every time
15741execution stops in your program: before breakpoint commands are run,
15742displays are printed, or the stack frame is printed.
104c1213 15743
8e04817f
AC
15744For example, to ignore @code{SIGALRM} signals while
15745single-stepping, but treat them normally during normal execution,
15746you could define:
104c1213 15747
474c8240 15748@smallexample
8e04817f
AC
15749define hook-stop
15750handle SIGALRM nopass
15751end
104c1213 15752
8e04817f
AC
15753define hook-run
15754handle SIGALRM pass
15755end
104c1213 15756
8e04817f
AC
15757define hook-continue
15758handle SIGLARM pass
15759end
474c8240 15760@end smallexample
104c1213 15761
8e04817f 15762As a further example, to hook at the begining and end of the @code{echo}
b383017d 15763command, and to add extra text to the beginning and end of the message,
8e04817f 15764you could define:
104c1213 15765
474c8240 15766@smallexample
8e04817f
AC
15767define hook-echo
15768echo <<<---
15769end
104c1213 15770
8e04817f
AC
15771define hookpost-echo
15772echo --->>>\n
15773end
104c1213 15774
8e04817f
AC
15775(@value{GDBP}) echo Hello World
15776<<<---Hello World--->>>
15777(@value{GDBP})
104c1213 15778
474c8240 15779@end smallexample
104c1213 15780
8e04817f
AC
15781You can define a hook for any single-word command in @value{GDBN}, but
15782not for command aliases; you should define a hook for the basic command
15783name, e.g. @code{backtrace} rather than @code{bt}.
15784@c FIXME! So how does Joe User discover whether a command is an alias
15785@c or not?
15786If an error occurs during the execution of your hook, execution of
15787@value{GDBN} commands stops and @value{GDBN} issues a prompt
15788(before the command that you actually typed had a chance to run).
104c1213 15789
8e04817f
AC
15790If you try to define a hook which does not match any known command, you
15791get a warning from the @code{define} command.
c906108c 15792
8e04817f
AC
15793@node Command Files
15794@section Command files
c906108c 15795
8e04817f 15796@cindex command files
6fc08d32
EZ
15797A command file for @value{GDBN} is a text file made of lines that are
15798@value{GDBN} commands. Comments (lines starting with @kbd{#}) may
15799also be included. An empty line in a command file does nothing; it
15800does not mean to repeat the last command, as it would from the
15801terminal.
c906108c 15802
6fc08d32
EZ
15803You can request the execution of a command file with the @code{source}
15804command:
c906108c 15805
8e04817f
AC
15806@table @code
15807@kindex source
15808@item source @var{filename}
15809Execute the command file @var{filename}.
c906108c
SS
15810@end table
15811
8e04817f 15812The lines in a command file are executed sequentially. They are not
a71ec265
DH
15813printed as they are executed. An error in any command terminates
15814execution of the command file and control is returned to the console.
c906108c 15815
8e04817f
AC
15816Commands that would ask for confirmation if used interactively proceed
15817without asking when used in a command file. Many @value{GDBN} commands that
15818normally print messages to say what they are doing omit the messages
15819when called from command files.
c906108c 15820
8e04817f
AC
15821@value{GDBN} also accepts command input from standard input. In this
15822mode, normal output goes to standard output and error output goes to
15823standard error. Errors in a command file supplied on standard input do
6fc08d32 15824not terminate execution of the command file---execution continues with
8e04817f 15825the next command.
c906108c 15826
474c8240 15827@smallexample
8e04817f 15828gdb < cmds > log 2>&1
474c8240 15829@end smallexample
c906108c 15830
8e04817f
AC
15831(The syntax above will vary depending on the shell used.) This example
15832will execute commands from the file @file{cmds}. All output and errors
15833would be directed to @file{log}.
c906108c 15834
8e04817f
AC
15835@node Output
15836@section Commands for controlled output
c906108c 15837
8e04817f
AC
15838During the execution of a command file or a user-defined command, normal
15839@value{GDBN} output is suppressed; the only output that appears is what is
15840explicitly printed by the commands in the definition. This section
15841describes three commands useful for generating exactly the output you
15842want.
c906108c
SS
15843
15844@table @code
8e04817f
AC
15845@kindex echo
15846@item echo @var{text}
15847@c I do not consider backslash-space a standard C escape sequence
15848@c because it is not in ANSI.
15849Print @var{text}. Nonprinting characters can be included in
15850@var{text} using C escape sequences, such as @samp{\n} to print a
15851newline. @strong{No newline is printed unless you specify one.}
15852In addition to the standard C escape sequences, a backslash followed
15853by a space stands for a space. This is useful for displaying a
15854string with spaces at the beginning or the end, since leading and
15855trailing spaces are otherwise trimmed from all arguments.
15856To print @samp{@w{ }and foo =@w{ }}, use the command
15857@samp{echo \@w{ }and foo = \@w{ }}.
c906108c 15858
8e04817f
AC
15859A backslash at the end of @var{text} can be used, as in C, to continue
15860the command onto subsequent lines. For example,
c906108c 15861
474c8240 15862@smallexample
8e04817f
AC
15863echo This is some text\n\
15864which is continued\n\
15865onto several lines.\n
474c8240 15866@end smallexample
c906108c 15867
8e04817f 15868produces the same output as
c906108c 15869
474c8240 15870@smallexample
8e04817f
AC
15871echo This is some text\n
15872echo which is continued\n
15873echo onto several lines.\n
474c8240 15874@end smallexample
c906108c 15875
8e04817f
AC
15876@kindex output
15877@item output @var{expression}
15878Print the value of @var{expression} and nothing but that value: no
15879newlines, no @samp{$@var{nn} = }. The value is not entered in the
15880value history either. @xref{Expressions, ,Expressions}, for more information
15881on expressions.
c906108c 15882
8e04817f
AC
15883@item output/@var{fmt} @var{expression}
15884Print the value of @var{expression} in format @var{fmt}. You can use
15885the same formats as for @code{print}. @xref{Output Formats,,Output
15886formats}, for more information.
c906108c 15887
8e04817f
AC
15888@kindex printf
15889@item printf @var{string}, @var{expressions}@dots{}
15890Print the values of the @var{expressions} under the control of
15891@var{string}. The @var{expressions} are separated by commas and may be
15892either numbers or pointers. Their values are printed as specified by
15893@var{string}, exactly as if your program were to execute the C
15894subroutine
15895@c FIXME: the above implies that at least all ANSI C formats are
15896@c supported, but it isn't true: %E and %G don't work (or so it seems).
15897@c Either this is a bug, or the manual should document what formats are
15898@c supported.
c906108c 15899
474c8240 15900@smallexample
8e04817f 15901printf (@var{string}, @var{expressions}@dots{});
474c8240 15902@end smallexample
c906108c 15903
8e04817f 15904For example, you can print two values in hex like this:
c906108c 15905
8e04817f
AC
15906@smallexample
15907printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
15908@end smallexample
c906108c 15909
8e04817f
AC
15910The only backslash-escape sequences that you can use in the format
15911string are the simple ones that consist of backslash followed by a
15912letter.
c906108c
SS
15913@end table
15914
21c294e6
AC
15915@node Interpreters
15916@chapter Command Interpreters
15917@cindex command interpreters
15918
15919@value{GDBN} supports multiple command interpreters, and some command
15920infrastructure to allow users or user interface writers to switch
15921between interpreters or run commands in other interpreters.
15922
15923@value{GDBN} currently supports two command interpreters, the console
15924interpreter (sometimes called the command-line interpreter or @sc{cli})
15925and the machine interface interpreter (or @sc{gdb/mi}). This manual
15926describes both of these interfaces in great detail.
15927
15928By default, @value{GDBN} will start with the console interpreter.
15929However, the user may choose to start @value{GDBN} with another
15930interpreter by specifying the @option{-i} or @option{--interpreter}
15931startup options. Defined interpreters include:
15932
15933@table @code
15934@item console
15935@cindex console interpreter
15936The traditional console or command-line interpreter. This is the most often
15937used interpreter with @value{GDBN}. With no interpreter specified at runtime,
15938@value{GDBN} will use this interpreter.
15939
15940@item mi
15941@cindex mi interpreter
15942The newest @sc{gdb/mi} interface (currently @code{mi2}). Used primarily
15943by programs wishing to use @value{GDBN} as a backend for a debugger GUI
15944or an IDE. For more information, see @ref{GDB/MI, ,The @sc{gdb/mi}
15945Interface}.
15946
15947@item mi2
15948@cindex mi2 interpreter
15949The current @sc{gdb/mi} interface.
15950
15951@item mi1
15952@cindex mi1 interpreter
15953The @sc{gdb/mi} interface included in @value{GDBN} 5.1, 5.2, and 5.3.
15954
15955@end table
15956
15957@cindex invoke another interpreter
15958The interpreter being used by @value{GDBN} may not be dynamically
15959switched at runtime. Although possible, this could lead to a very
15960precarious situation. Consider an IDE using @sc{gdb/mi}. If a user
15961enters the command "interpreter-set console" in a console view,
15962@value{GDBN} would switch to using the console interpreter, rendering
15963the IDE inoperable!
15964
15965@kindex interpreter-exec
15966Although you may only choose a single interpreter at startup, you may execute
15967commands in any interpreter from the current interpreter using the appropriate
15968command. If you are running the console interpreter, simply use the
15969@code{interpreter-exec} command:
15970
15971@smallexample
15972interpreter-exec mi "-data-list-register-names"
15973@end smallexample
15974
15975@sc{gdb/mi} has a similar command, although it is only available in versions of
15976@value{GDBN} which support @sc{gdb/mi} version 2 (or greater).
15977
8e04817f
AC
15978@node TUI
15979@chapter @value{GDBN} Text User Interface
15980@cindex TUI
d0d5df6f 15981@cindex Text User Interface
c906108c 15982
8e04817f
AC
15983@menu
15984* TUI Overview:: TUI overview
15985* TUI Keys:: TUI key bindings
7cf36c78 15986* TUI Single Key Mode:: TUI single key mode
8e04817f
AC
15987* TUI Commands:: TUI specific commands
15988* TUI Configuration:: TUI configuration variables
15989@end menu
c906108c 15990
d0d5df6f
AC
15991The @value{GDBN} Text User Interface, TUI in short, is a terminal
15992interface which uses the @code{curses} library to show the source
15993file, the assembly output, the program registers and @value{GDBN}
15994commands in separate text windows.
15995
15996The TUI is enabled by invoking @value{GDBN} using either
15997@pindex gdbtui
15998@samp{gdbtui} or @samp{gdb -tui}.
c906108c 15999
8e04817f
AC
16000@node TUI Overview
16001@section TUI overview
c906108c 16002
8e04817f
AC
16003The TUI has two display modes that can be switched while
16004@value{GDBN} runs:
c906108c 16005
8e04817f
AC
16006@itemize @bullet
16007@item
16008A curses (or TUI) mode in which it displays several text
16009windows on the terminal.
c906108c 16010
8e04817f
AC
16011@item
16012A standard mode which corresponds to the @value{GDBN} configured without
16013the TUI.
16014@end itemize
c906108c 16015
8e04817f
AC
16016In the TUI mode, @value{GDBN} can display several text window
16017on the terminal:
c906108c 16018
8e04817f
AC
16019@table @emph
16020@item command
16021This window is the @value{GDBN} command window with the @value{GDBN}
16022prompt and the @value{GDBN} outputs. The @value{GDBN} input is still
16023managed using readline but through the TUI. The @emph{command}
16024window is always visible.
c906108c 16025
8e04817f
AC
16026@item source
16027The source window shows the source file of the program. The current
16028line as well as active breakpoints are displayed in this window.
c906108c 16029
8e04817f
AC
16030@item assembly
16031The assembly window shows the disassembly output of the program.
c906108c 16032
8e04817f
AC
16033@item register
16034This window shows the processor registers. It detects when
16035a register is changed and when this is the case, registers that have
6a1b180d 16036changed are highlighted.
c906108c 16037
c906108c
SS
16038@end table
16039
269c21fe
SC
16040The source and assembly windows show the current program position
16041by highlighting the current line and marking them with the @samp{>} marker.
16042Breakpoints are also indicated with two markers. A first one
16043indicates the breakpoint type:
16044
16045@table @code
16046@item B
16047Breakpoint which was hit at least once.
16048
16049@item b
16050Breakpoint which was never hit.
16051
16052@item H
16053Hardware breakpoint which was hit at least once.
16054
16055@item h
16056Hardware breakpoint which was never hit.
16057
16058@end table
16059
16060The second marker indicates whether the breakpoint is enabled or not:
16061
16062@table @code
16063@item +
16064Breakpoint is enabled.
16065
16066@item -
16067Breakpoint is disabled.
16068
16069@end table
16070
8e04817f
AC
16071The source, assembly and register windows are attached to the thread
16072and the frame position. They are updated when the current thread
16073changes, when the frame changes or when the program counter changes.
16074These three windows are arranged by the TUI according to several
16075layouts. The layout defines which of these three windows are visible.
16076The following layouts are available:
c906108c 16077
8e04817f
AC
16078@itemize @bullet
16079@item
16080source
2df3850c 16081
8e04817f
AC
16082@item
16083assembly
16084
16085@item
16086source and assembly
16087
16088@item
16089source and registers
c906108c 16090
8e04817f
AC
16091@item
16092assembly and registers
2df3850c 16093
8e04817f 16094@end itemize
c906108c 16095
b7bb15bc
SC
16096On top of the command window a status line gives various information
16097concerning the current process begin debugged. The status line is
16098updated when the information it shows changes. The following fields
16099are displayed:
16100
16101@table @emph
16102@item target
16103Indicates the current gdb target
16104(@pxref{Targets, ,Specifying a Debugging Target}).
16105
16106@item process
16107Gives information about the current process or thread number.
16108When no process is being debugged, this field is set to @code{No process}.
16109
16110@item function
16111Gives the current function name for the selected frame.
16112The name is demangled if demangling is turned on (@pxref{Print Settings}).
16113When there is no symbol corresponding to the current program counter
16114the string @code{??} is displayed.
16115
16116@item line
16117Indicates the current line number for the selected frame.
16118When the current line number is not known the string @code{??} is displayed.
16119
16120@item pc
16121Indicates the current program counter address.
16122
16123@end table
16124
8e04817f
AC
16125@node TUI Keys
16126@section TUI Key Bindings
16127@cindex TUI key bindings
c906108c 16128
8e04817f
AC
16129The TUI installs several key bindings in the readline keymaps
16130(@pxref{Command Line Editing}).
16131They allow to leave or enter in the TUI mode or they operate
7cf36c78
SC
16132directly on the TUI layout and windows. The TUI also provides
16133a @emph{SingleKey} keymap which binds several keys directly to
16134@value{GDBN} commands. The following key bindings
8e04817f 16135are installed for both TUI mode and the @value{GDBN} standard mode.
c906108c 16136
8e04817f
AC
16137@table @kbd
16138@kindex C-x C-a
16139@item C-x C-a
16140@kindex C-x a
16141@itemx C-x a
16142@kindex C-x A
16143@itemx C-x A
16144Enter or leave the TUI mode. When the TUI mode is left,
16145the curses window management is left and @value{GDBN} operates using
16146its standard mode writing on the terminal directly. When the TUI
16147mode is entered, the control is given back to the curses windows.
16148The screen is then refreshed.
c906108c 16149
8e04817f
AC
16150@kindex C-x 1
16151@item C-x 1
16152Use a TUI layout with only one window. The layout will
16153either be @samp{source} or @samp{assembly}. When the TUI mode
16154is not active, it will switch to the TUI mode.
2df3850c 16155
8e04817f 16156Think of this key binding as the Emacs @kbd{C-x 1} binding.
c906108c 16157
8e04817f
AC
16158@kindex C-x 2
16159@item C-x 2
16160Use a TUI layout with at least two windows. When the current
16161layout shows already two windows, a next layout with two windows is used.
16162When a new layout is chosen, one window will always be common to the
16163previous layout and the new one.
c906108c 16164
8e04817f 16165Think of it as the Emacs @kbd{C-x 2} binding.
2df3850c 16166
72ffddc9
SC
16167@kindex C-x o
16168@item C-x o
16169Change the active window. The TUI associates several key bindings
16170(like scrolling and arrow keys) to the active window. This command
16171gives the focus to the next TUI window.
16172
16173Think of it as the Emacs @kbd{C-x o} binding.
16174
7cf36c78
SC
16175@kindex C-x s
16176@item C-x s
16177Use the TUI @emph{SingleKey} keymap that binds single key to gdb commands
16178(@pxref{TUI Single Key Mode}).
16179
c906108c
SS
16180@end table
16181
8e04817f 16182The following key bindings are handled only by the TUI mode:
5d161b24 16183
8e04817f
AC
16184@table @key
16185@kindex PgUp
16186@item PgUp
16187Scroll the active window one page up.
c906108c 16188
8e04817f
AC
16189@kindex PgDn
16190@item PgDn
16191Scroll the active window one page down.
c906108c 16192
8e04817f
AC
16193@kindex Up
16194@item Up
16195Scroll the active window one line up.
c906108c 16196
8e04817f
AC
16197@kindex Down
16198@item Down
16199Scroll the active window one line down.
c906108c 16200
8e04817f
AC
16201@kindex Left
16202@item Left
16203Scroll the active window one column left.
c906108c 16204
8e04817f
AC
16205@kindex Right
16206@item Right
16207Scroll the active window one column right.
c906108c 16208
8e04817f
AC
16209@kindex C-L
16210@item C-L
16211Refresh the screen.
c906108c 16212
8e04817f 16213@end table
c906108c 16214
8e04817f 16215In the TUI mode, the arrow keys are used by the active window
72ffddc9
SC
16216for scrolling. This means they are available for readline when the
16217active window is the command window. When the command window
16218does not have the focus, it is necessary to use other readline
16219key bindings such as @key{C-p}, @key{C-n}, @key{C-b} and @key{C-f}.
8e04817f 16220
7cf36c78
SC
16221@node TUI Single Key Mode
16222@section TUI Single Key Mode
16223@cindex TUI single key mode
16224
16225The TUI provides a @emph{SingleKey} mode in which it installs a particular
16226key binding in the readline keymaps to connect single keys to
b383017d 16227some gdb commands.
7cf36c78
SC
16228
16229@table @kbd
16230@kindex c @r{(SingleKey TUI key)}
16231@item c
16232continue
16233
16234@kindex d @r{(SingleKey TUI key)}
16235@item d
16236down
16237
16238@kindex f @r{(SingleKey TUI key)}
16239@item f
16240finish
16241
16242@kindex n @r{(SingleKey TUI key)}
16243@item n
16244next
16245
16246@kindex q @r{(SingleKey TUI key)}
16247@item q
16248exit the @emph{SingleKey} mode.
16249
16250@kindex r @r{(SingleKey TUI key)}
16251@item r
16252run
16253
16254@kindex s @r{(SingleKey TUI key)}
16255@item s
16256step
16257
16258@kindex u @r{(SingleKey TUI key)}
16259@item u
16260up
16261
16262@kindex v @r{(SingleKey TUI key)}
16263@item v
16264info locals
16265
16266@kindex w @r{(SingleKey TUI key)}
16267@item w
16268where
16269
16270@end table
16271
16272Other keys temporarily switch to the @value{GDBN} command prompt.
16273The key that was pressed is inserted in the editing buffer so that
16274it is possible to type most @value{GDBN} commands without interaction
16275with the TUI @emph{SingleKey} mode. Once the command is entered the TUI
16276@emph{SingleKey} mode is restored. The only way to permanently leave
16277this mode is by hitting @key{q} or @samp{@key{C-x} @key{s}}.
16278
16279
8e04817f
AC
16280@node TUI Commands
16281@section TUI specific commands
16282@cindex TUI commands
16283
16284The TUI has specific commands to control the text windows.
16285These commands are always available, that is they do not depend on
16286the current terminal mode in which @value{GDBN} runs. When @value{GDBN}
16287is in the standard mode, using these commands will automatically switch
16288in the TUI mode.
c906108c
SS
16289
16290@table @code
3d757584
SC
16291@item info win
16292@kindex info win
16293List and give the size of all displayed windows.
16294
8e04817f 16295@item layout next
4644b6e3 16296@kindex layout
8e04817f 16297Display the next layout.
2df3850c 16298
8e04817f 16299@item layout prev
8e04817f 16300Display the previous layout.
c906108c 16301
8e04817f 16302@item layout src
8e04817f 16303Display the source window only.
c906108c 16304
8e04817f 16305@item layout asm
8e04817f 16306Display the assembly window only.
c906108c 16307
8e04817f 16308@item layout split
8e04817f 16309Display the source and assembly window.
c906108c 16310
8e04817f 16311@item layout regs
8e04817f
AC
16312Display the register window together with the source or assembly window.
16313
16314@item focus next | prev | src | asm | regs | split
16315@kindex focus
16316Set the focus to the named window.
16317This command allows to change the active window so that scrolling keys
16318can be affected to another window.
c906108c 16319
8e04817f
AC
16320@item refresh
16321@kindex refresh
16322Refresh the screen. This is similar to using @key{C-L} key.
c906108c 16323
6a1b180d
SC
16324@item tui reg float
16325@kindex tui reg
16326Show the floating point registers in the register window.
16327
16328@item tui reg general
16329Show the general registers in the register window.
16330
16331@item tui reg next
16332Show the next register group. The list of register groups as well as
16333their order is target specific. The predefined register groups are the
16334following: @code{general}, @code{float}, @code{system}, @code{vector},
16335@code{all}, @code{save}, @code{restore}.
16336
16337@item tui reg system
16338Show the system registers in the register window.
16339
8e04817f
AC
16340@item update
16341@kindex update
16342Update the source window and the current execution point.
c906108c 16343
8e04817f
AC
16344@item winheight @var{name} +@var{count}
16345@itemx winheight @var{name} -@var{count}
16346@kindex winheight
16347Change the height of the window @var{name} by @var{count}
16348lines. Positive counts increase the height, while negative counts
16349decrease it.
2df3850c 16350
c45da7e6
EZ
16351@item tabset
16352@kindex tabset @var{nchars}
16353Set the width of tab stops to be @var{nchars} characters.
16354
c906108c
SS
16355@end table
16356
8e04817f
AC
16357@node TUI Configuration
16358@section TUI configuration variables
16359@cindex TUI configuration variables
c906108c 16360
8e04817f
AC
16361The TUI has several configuration variables that control the
16362appearance of windows on the terminal.
c906108c 16363
8e04817f
AC
16364@table @code
16365@item set tui border-kind @var{kind}
16366@kindex set tui border-kind
16367Select the border appearance for the source, assembly and register windows.
16368The possible values are the following:
16369@table @code
16370@item space
16371Use a space character to draw the border.
c906108c 16372
8e04817f
AC
16373@item ascii
16374Use ascii characters + - and | to draw the border.
c906108c 16375
8e04817f
AC
16376@item acs
16377Use the Alternate Character Set to draw the border. The border is
16378drawn using character line graphics if the terminal supports them.
c78b4128 16379
8e04817f 16380@end table
c78b4128 16381
8e04817f
AC
16382@item set tui active-border-mode @var{mode}
16383@kindex set tui active-border-mode
16384Select the attributes to display the border of the active window.
16385The possible values are @code{normal}, @code{standout}, @code{reverse},
16386@code{half}, @code{half-standout}, @code{bold} and @code{bold-standout}.
c78b4128 16387
8e04817f
AC
16388@item set tui border-mode @var{mode}
16389@kindex set tui border-mode
16390Select the attributes to display the border of other windows.
16391The @var{mode} can be one of the following:
16392@table @code
16393@item normal
16394Use normal attributes to display the border.
c906108c 16395
8e04817f
AC
16396@item standout
16397Use standout mode.
c906108c 16398
8e04817f
AC
16399@item reverse
16400Use reverse video mode.
c906108c 16401
8e04817f
AC
16402@item half
16403Use half bright mode.
c906108c 16404
8e04817f
AC
16405@item half-standout
16406Use half bright and standout mode.
c906108c 16407
8e04817f
AC
16408@item bold
16409Use extra bright or bold mode.
c78b4128 16410
8e04817f
AC
16411@item bold-standout
16412Use extra bright or bold and standout mode.
c78b4128 16413
8e04817f 16414@end table
c78b4128 16415
8e04817f 16416@end table
c78b4128 16417
8e04817f
AC
16418@node Emacs
16419@chapter Using @value{GDBN} under @sc{gnu} Emacs
c78b4128 16420
8e04817f
AC
16421@cindex Emacs
16422@cindex @sc{gnu} Emacs
16423A special interface allows you to use @sc{gnu} Emacs to view (and
16424edit) the source files for the program you are debugging with
16425@value{GDBN}.
c906108c 16426
8e04817f
AC
16427To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the
16428executable file you want to debug as an argument. This command starts
16429@value{GDBN} as a subprocess of Emacs, with input and output through a newly
16430created Emacs buffer.
16431@c (Do not use the @code{-tui} option to run @value{GDBN} from Emacs.)
c906108c 16432
8e04817f
AC
16433Using @value{GDBN} under Emacs is just like using @value{GDBN} normally except for two
16434things:
c906108c 16435
8e04817f
AC
16436@itemize @bullet
16437@item
16438All ``terminal'' input and output goes through the Emacs buffer.
16439@end itemize
c906108c 16440
8e04817f
AC
16441This applies both to @value{GDBN} commands and their output, and to the input
16442and output done by the program you are debugging.
bf0184be 16443
8e04817f
AC
16444This is useful because it means that you can copy the text of previous
16445commands and input them again; you can even use parts of the output
16446in this way.
bf0184be 16447
8e04817f
AC
16448All the facilities of Emacs' Shell mode are available for interacting
16449with your program. In particular, you can send signals the usual
16450way---for example, @kbd{C-c C-c} for an interrupt, @kbd{C-c C-z} for a
16451stop.
bf0184be 16452
8e04817f 16453@itemize @bullet
bf0184be 16454@item
8e04817f
AC
16455@value{GDBN} displays source code through Emacs.
16456@end itemize
bf0184be 16457
8e04817f
AC
16458Each time @value{GDBN} displays a stack frame, Emacs automatically finds the
16459source file for that frame and puts an arrow (@samp{=>}) at the
16460left margin of the current line. Emacs uses a separate buffer for
16461source display, and splits the screen to show both your @value{GDBN} session
16462and the source.
bf0184be 16463
8e04817f
AC
16464Explicit @value{GDBN} @code{list} or search commands still produce output as
16465usual, but you probably have no reason to use them from Emacs.
c906108c 16466
64fabec2
AC
16467If you specify an absolute file name when prompted for the @kbd{M-x
16468gdb} argument, then Emacs sets your current working directory to where
16469your program resides. If you only specify the file name, then Emacs
16470sets your current working directory to to the directory associated
16471with the previous buffer. In this case, @value{GDBN} may find your
16472program by searching your environment's @code{PATH} variable, but on
16473some operating systems it might not find the source. So, although the
16474@value{GDBN} input and output session proceeds normally, the auxiliary
16475buffer does not display the current source and line of execution.
16476
16477The initial working directory of @value{GDBN} is printed on the top
16478line of the @value{GDBN} I/O buffer and this serves as a default for
16479the commands that specify files for @value{GDBN} to operate
16480on. @xref{Files, ,Commands to specify files}.
16481
16482By default, @kbd{M-x gdb} calls the program called @file{gdb}. If you
16483need to call @value{GDBN} by a different name (for example, if you
16484keep several configurations around, with different names) you can
16485customize the Emacs variable @code{gud-gdb-command-name} to run the
16486one you want.
8e04817f
AC
16487
16488In the @value{GDBN} I/O buffer, you can use these special Emacs commands in
16489addition to the standard Shell mode commands:
c906108c 16490
8e04817f
AC
16491@table @kbd
16492@item C-h m
16493Describe the features of Emacs' @value{GDBN} Mode.
c906108c 16494
64fabec2 16495@item C-c C-s
8e04817f
AC
16496Execute to another source line, like the @value{GDBN} @code{step} command; also
16497update the display window to show the current file and location.
c906108c 16498
64fabec2 16499@item C-c C-n
8e04817f
AC
16500Execute to next source line in this function, skipping all function
16501calls, like the @value{GDBN} @code{next} command. Then update the display window
16502to show the current file and location.
c906108c 16503
64fabec2 16504@item C-c C-i
8e04817f
AC
16505Execute one instruction, like the @value{GDBN} @code{stepi} command; update
16506display window accordingly.
c906108c 16507
8e04817f
AC
16508@item C-c C-f
16509Execute until exit from the selected stack frame, like the @value{GDBN}
16510@code{finish} command.
c906108c 16511
64fabec2 16512@item C-c C-r
8e04817f
AC
16513Continue execution of your program, like the @value{GDBN} @code{continue}
16514command.
b433d00b 16515
64fabec2 16516@item C-c <
8e04817f
AC
16517Go up the number of frames indicated by the numeric argument
16518(@pxref{Arguments, , Numeric Arguments, Emacs, The @sc{gnu} Emacs Manual}),
16519like the @value{GDBN} @code{up} command.
b433d00b 16520
64fabec2 16521@item C-c >
8e04817f
AC
16522Go down the number of frames indicated by the numeric argument, like the
16523@value{GDBN} @code{down} command.
8e04817f 16524@end table
c906108c 16525
64fabec2 16526In any source file, the Emacs command @kbd{C-x SPC} (@code{gud-break})
8e04817f 16527tells @value{GDBN} to set a breakpoint on the source line point is on.
c906108c 16528
64fabec2
AC
16529If you type @kbd{M-x speedbar}, then Emacs displays a separate frame which
16530shows a backtrace when the @value{GDBN} I/O buffer is current. Move
16531point to any frame in the stack and type @key{RET} to make it become the
16532current frame and display the associated source in the source buffer.
16533Alternatively, click @kbd{Mouse-2} to make the selected frame become the
16534current one.
16535
8e04817f
AC
16536If you accidentally delete the source-display buffer, an easy way to get
16537it back is to type the command @code{f} in the @value{GDBN} buffer, to
16538request a frame display; when you run under Emacs, this recreates
16539the source buffer if necessary to show you the context of the current
16540frame.
c906108c 16541
8e04817f
AC
16542The source files displayed in Emacs are in ordinary Emacs buffers
16543which are visiting the source files in the usual way. You can edit
16544the files with these buffers if you wish; but keep in mind that @value{GDBN}
16545communicates with Emacs in terms of line numbers. If you add or
16546delete lines from the text, the line numbers that @value{GDBN} knows cease
16547to correspond properly with the code.
b383017d 16548
64fabec2
AC
16549The description given here is for GNU Emacs version 21.3 and a more
16550detailed description of its interaction with @value{GDBN} is given in
16551the Emacs manual (@pxref{Debuggers,,, Emacs, The @sc{gnu} Emacs Manual}).
c906108c 16552
8e04817f
AC
16553@c The following dropped because Epoch is nonstandard. Reactivate
16554@c if/when v19 does something similar. ---doc@cygnus.com 19dec1990
16555@ignore
16556@kindex Emacs Epoch environment
16557@kindex Epoch
16558@kindex inspect
c906108c 16559
8e04817f
AC
16560Version 18 of @sc{gnu} Emacs has a built-in window system
16561called the @code{epoch}
16562environment. Users of this environment can use a new command,
16563@code{inspect} which performs identically to @code{print} except that
16564each value is printed in its own window.
16565@end ignore
c906108c 16566
922fbb7b
AC
16567
16568@node GDB/MI
16569@chapter The @sc{gdb/mi} Interface
16570
16571@unnumberedsec Function and Purpose
16572
16573@cindex @sc{gdb/mi}, its purpose
6b5e8c01
NR
16574@sc{gdb/mi} is a line based machine oriented text interface to
16575@value{GDBN} and is activated by specifying using the
16576@option{--interpreter} command line option (@pxref{Mode Options}). It
16577is specifically intended to support the development of systems which
16578use the debugger as just one small component of a larger system.
922fbb7b
AC
16579
16580This chapter is a specification of the @sc{gdb/mi} interface. It is written
16581in the form of a reference manual.
16582
16583Note that @sc{gdb/mi} is still under construction, so some of the
16584features described below are incomplete and subject to change.
16585
16586@unnumberedsec Notation and Terminology
16587
16588@cindex notational conventions, for @sc{gdb/mi}
16589This chapter uses the following notation:
16590
16591@itemize @bullet
16592@item
16593@code{|} separates two alternatives.
16594
16595@item
16596@code{[ @var{something} ]} indicates that @var{something} is optional:
16597it may or may not be given.
16598
16599@item
16600@code{( @var{group} )*} means that @var{group} inside the parentheses
16601may repeat zero or more times.
16602
16603@item
16604@code{( @var{group} )+} means that @var{group} inside the parentheses
16605may repeat one or more times.
16606
16607@item
16608@code{"@var{string}"} means a literal @var{string}.
16609@end itemize
16610
16611@ignore
16612@heading Dependencies
16613@end ignore
16614
16615@heading Acknowledgments
16616
16617In alphabetic order: Andrew Cagney, Fernando Nasser, Stan Shebs and
16618Elena Zannoni.
16619
16620@menu
16621* GDB/MI Command Syntax::
16622* GDB/MI Compatibility with CLI::
16623* GDB/MI Output Records::
16624* GDB/MI Command Description Format::
16625* GDB/MI Breakpoint Table Commands::
16626* GDB/MI Data Manipulation::
16627* GDB/MI Program Control::
16628* GDB/MI Miscellaneous Commands::
16629@ignore
16630* GDB/MI Kod Commands::
16631* GDB/MI Memory Overlay Commands::
16632* GDB/MI Signal Handling Commands::
16633@end ignore
16634* GDB/MI Stack Manipulation::
16635* GDB/MI Symbol Query::
16636* GDB/MI Target Manipulation::
16637* GDB/MI Thread Commands::
16638* GDB/MI Tracepoint Commands::
16639* GDB/MI Variable Objects::
16640@end menu
16641
16642@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16643@node GDB/MI Command Syntax
16644@section @sc{gdb/mi} Command Syntax
16645
16646@menu
16647* GDB/MI Input Syntax::
16648* GDB/MI Output Syntax::
16649* GDB/MI Simple Examples::
16650@end menu
16651
16652@node GDB/MI Input Syntax
16653@subsection @sc{gdb/mi} Input Syntax
16654
16655@cindex input syntax for @sc{gdb/mi}
16656@cindex @sc{gdb/mi}, input syntax
16657@table @code
16658@item @var{command} @expansion{}
16659@code{@var{cli-command} | @var{mi-command}}
16660
16661@item @var{cli-command} @expansion{}
16662@code{[ @var{token} ] @var{cli-command} @var{nl}}, where
16663@var{cli-command} is any existing @value{GDBN} CLI command.
16664
16665@item @var{mi-command} @expansion{}
16666@code{[ @var{token} ] "-" @var{operation} ( " " @var{option} )*
16667@code{[} " --" @code{]} ( " " @var{parameter} )* @var{nl}}
16668
16669@item @var{token} @expansion{}
16670"any sequence of digits"
16671
16672@item @var{option} @expansion{}
16673@code{"-" @var{parameter} [ " " @var{parameter} ]}
16674
16675@item @var{parameter} @expansion{}
16676@code{@var{non-blank-sequence} | @var{c-string}}
16677
16678@item @var{operation} @expansion{}
16679@emph{any of the operations described in this chapter}
16680
16681@item @var{non-blank-sequence} @expansion{}
16682@emph{anything, provided it doesn't contain special characters such as
16683"-", @var{nl}, """ and of course " "}
16684
16685@item @var{c-string} @expansion{}
16686@code{""" @var{seven-bit-iso-c-string-content} """}
16687
16688@item @var{nl} @expansion{}
16689@code{CR | CR-LF}
16690@end table
16691
16692@noindent
16693Notes:
16694
16695@itemize @bullet
16696@item
16697The CLI commands are still handled by the @sc{mi} interpreter; their
16698output is described below.
16699
16700@item
16701The @code{@var{token}}, when present, is passed back when the command
16702finishes.
16703
16704@item
16705Some @sc{mi} commands accept optional arguments as part of the parameter
16706list. Each option is identified by a leading @samp{-} (dash) and may be
16707followed by an optional argument parameter. Options occur first in the
16708parameter list and can be delimited from normal parameters using
16709@samp{--} (this is useful when some parameters begin with a dash).
16710@end itemize
16711
16712Pragmatics:
16713
16714@itemize @bullet
16715@item
16716We want easy access to the existing CLI syntax (for debugging).
16717
16718@item
16719We want it to be easy to spot a @sc{mi} operation.
16720@end itemize
16721
16722@node GDB/MI Output Syntax
16723@subsection @sc{gdb/mi} Output Syntax
16724
16725@cindex output syntax of @sc{gdb/mi}
16726@cindex @sc{gdb/mi}, output syntax
16727The output from @sc{gdb/mi} consists of zero or more out-of-band records
16728followed, optionally, by a single result record. This result record
16729is for the most recent command. The sequence of output records is
16730terminated by @samp{(@value{GDBP})}.
16731
16732If an input command was prefixed with a @code{@var{token}} then the
16733corresponding output for that command will also be prefixed by that same
16734@var{token}.
16735
16736@table @code
16737@item @var{output} @expansion{}
f7dc1244 16738@code{( @var{out-of-band-record} )* [ @var{result-record} ] "(@value{GDBP})" @var{nl}}
922fbb7b
AC
16739
16740@item @var{result-record} @expansion{}
16741@code{ [ @var{token} ] "^" @var{result-class} ( "," @var{result} )* @var{nl}}
16742
16743@item @var{out-of-band-record} @expansion{}
16744@code{@var{async-record} | @var{stream-record}}
16745
16746@item @var{async-record} @expansion{}
16747@code{@var{exec-async-output} | @var{status-async-output} | @var{notify-async-output}}
16748
16749@item @var{exec-async-output} @expansion{}
16750@code{[ @var{token} ] "*" @var{async-output}}
16751
16752@item @var{status-async-output} @expansion{}
16753@code{[ @var{token} ] "+" @var{async-output}}
16754
16755@item @var{notify-async-output} @expansion{}
16756@code{[ @var{token} ] "=" @var{async-output}}
16757
16758@item @var{async-output} @expansion{}
16759@code{@var{async-class} ( "," @var{result} )* @var{nl}}
16760
16761@item @var{result-class} @expansion{}
16762@code{"done" | "running" | "connected" | "error" | "exit"}
16763
16764@item @var{async-class} @expansion{}
16765@code{"stopped" | @var{others}} (where @var{others} will be added
16766depending on the needs---this is still in development).
16767
16768@item @var{result} @expansion{}
16769@code{ @var{variable} "=" @var{value}}
16770
16771@item @var{variable} @expansion{}
16772@code{ @var{string} }
16773
16774@item @var{value} @expansion{}
16775@code{ @var{const} | @var{tuple} | @var{list} }
16776
16777@item @var{const} @expansion{}
16778@code{@var{c-string}}
16779
16780@item @var{tuple} @expansion{}
16781@code{ "@{@}" | "@{" @var{result} ( "," @var{result} )* "@}" }
16782
16783@item @var{list} @expansion{}
16784@code{ "[]" | "[" @var{value} ( "," @var{value} )* "]" | "["
16785@var{result} ( "," @var{result} )* "]" }
16786
16787@item @var{stream-record} @expansion{}
16788@code{@var{console-stream-output} | @var{target-stream-output} | @var{log-stream-output}}
16789
16790@item @var{console-stream-output} @expansion{}
16791@code{"~" @var{c-string}}
16792
16793@item @var{target-stream-output} @expansion{}
16794@code{"@@" @var{c-string}}
16795
16796@item @var{log-stream-output} @expansion{}
16797@code{"&" @var{c-string}}
16798
16799@item @var{nl} @expansion{}
16800@code{CR | CR-LF}
16801
16802@item @var{token} @expansion{}
16803@emph{any sequence of digits}.
16804@end table
16805
16806@noindent
16807Notes:
16808
16809@itemize @bullet
16810@item
16811All output sequences end in a single line containing a period.
16812
16813@item
16814The @code{@var{token}} is from the corresponding request. If an execution
16815command is interrupted by the @samp{-exec-interrupt} command, the
16816@var{token} associated with the @samp{*stopped} message is the one of the
16817original execution command, not the one of the interrupt command.
16818
16819@item
16820@cindex status output in @sc{gdb/mi}
16821@var{status-async-output} contains on-going status information about the
16822progress of a slow operation. It can be discarded. All status output is
16823prefixed by @samp{+}.
16824
16825@item
16826@cindex async output in @sc{gdb/mi}
16827@var{exec-async-output} contains asynchronous state change on the target
16828(stopped, started, disappeared). All async output is prefixed by
16829@samp{*}.
16830
16831@item
16832@cindex notify output in @sc{gdb/mi}
16833@var{notify-async-output} contains supplementary information that the
16834client should handle (e.g., a new breakpoint information). All notify
16835output is prefixed by @samp{=}.
16836
16837@item
16838@cindex console output in @sc{gdb/mi}
16839@var{console-stream-output} is output that should be displayed as is in the
16840console. It is the textual response to a CLI command. All the console
16841output is prefixed by @samp{~}.
16842
16843@item
16844@cindex target output in @sc{gdb/mi}
16845@var{target-stream-output} is the output produced by the target program.
16846All the target output is prefixed by @samp{@@}.
16847
16848@item
16849@cindex log output in @sc{gdb/mi}
16850@var{log-stream-output} is output text coming from @value{GDBN}'s internals, for
16851instance messages that should be displayed as part of an error log. All
16852the log output is prefixed by @samp{&}.
16853
16854@item
16855@cindex list output in @sc{gdb/mi}
16856New @sc{gdb/mi} commands should only output @var{lists} containing
16857@var{values}.
16858
16859
16860@end itemize
16861
16862@xref{GDB/MI Stream Records, , @sc{gdb/mi} Stream Records}, for more
16863details about the various output records.
16864
16865@node GDB/MI Simple Examples
16866@subsection Simple Examples of @sc{gdb/mi} Interaction
16867@cindex @sc{gdb/mi}, simple examples
16868
16869This subsection presents several simple examples of interaction using
16870the @sc{gdb/mi} interface. In these examples, @samp{->} means that the
16871following line is passed to @sc{gdb/mi} as input, while @samp{<-} means
16872the output received from @sc{gdb/mi}.
16873
16874@subsubheading Target Stop
16875@c Ummm... There is no "-stop" command. This assumes async, no?
16876Here's an example of stopping the inferior process:
16877
16878@smallexample
16879-> -stop
16880<- (@value{GDBP})
16881@end smallexample
16882
16883@noindent
16884and later:
16885
16886@smallexample
16887<- *stop,reason="stop",address="0x123",source="a.c:123"
16888<- (@value{GDBP})
16889@end smallexample
16890
16891@subsubheading Simple CLI Command
16892
16893Here's an example of a simple CLI command being passed through
16894@sc{gdb/mi} and on to the CLI.
16895
16896@smallexample
16897-> print 1+2
16898<- &"print 1+2\n"
16899<- ~"$1 = 3\n"
16900<- ^done
16901<- (@value{GDBP})
16902@end smallexample
16903
16904@subsubheading Command With Side Effects
16905
16906@smallexample
16907-> -symbol-file xyz.exe
16908<- *breakpoint,nr="3",address="0x123",source="a.c:123"
16909<- (@value{GDBP})
16910@end smallexample
16911
16912@subsubheading A Bad Command
16913
16914Here's what happens if you pass a non-existent command:
16915
16916@smallexample
16917-> -rubbish
16918<- ^error,msg="Undefined MI command: rubbish"
16919<- (@value{GDBP})
16920@end smallexample
16921
16922@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16923@node GDB/MI Compatibility with CLI
16924@section @sc{gdb/mi} Compatibility with CLI
16925
16926@cindex compatibility, @sc{gdb/mi} and CLI
16927@cindex @sc{gdb/mi}, compatibility with CLI
16928To help users familiar with @value{GDBN}'s existing CLI interface, @sc{gdb/mi}
16929accepts existing CLI commands. As specified by the syntax, such
16930commands can be directly entered into the @sc{gdb/mi} interface and @value{GDBN} will
16931respond.
16932
16933This mechanism is provided as an aid to developers of @sc{gdb/mi}
16934clients and not as a reliable interface into the CLI. Since the command
16935is being interpreteted in an environment that assumes @sc{gdb/mi}
16936behaviour, the exact output of such commands is likely to end up being
16937an un-supported hybrid of @sc{gdb/mi} and CLI output.
16938
16939@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16940@node GDB/MI Output Records
16941@section @sc{gdb/mi} Output Records
16942
16943@menu
16944* GDB/MI Result Records::
16945* GDB/MI Stream Records::
16946* GDB/MI Out-of-band Records::
16947@end menu
16948
16949@node GDB/MI Result Records
16950@subsection @sc{gdb/mi} Result Records
16951
16952@cindex result records in @sc{gdb/mi}
16953@cindex @sc{gdb/mi}, result records
16954In addition to a number of out-of-band notifications, the response to a
16955@sc{gdb/mi} command includes one of the following result indications:
16956
16957@table @code
16958@findex ^done
16959@item "^done" [ "," @var{results} ]
16960The synchronous operation was successful, @code{@var{results}} are the return
16961values.
16962
16963@item "^running"
16964@findex ^running
16965@c Is this one correct? Should it be an out-of-band notification?
16966The asynchronous operation was successfully started. The target is
16967running.
16968
16969@item "^error" "," @var{c-string}
16970@findex ^error
16971The operation failed. The @code{@var{c-string}} contains the corresponding
16972error message.
16973@end table
16974
16975@node GDB/MI Stream Records
16976@subsection @sc{gdb/mi} Stream Records
16977
16978@cindex @sc{gdb/mi}, stream records
16979@cindex stream records in @sc{gdb/mi}
16980@value{GDBN} internally maintains a number of output streams: the console, the
16981target, and the log. The output intended for each of these streams is
16982funneled through the @sc{gdb/mi} interface using @dfn{stream records}.
16983
16984Each stream record begins with a unique @dfn{prefix character} which
16985identifies its stream (@pxref{GDB/MI Output Syntax, , @sc{gdb/mi} Output
16986Syntax}). In addition to the prefix, each stream record contains a
16987@code{@var{string-output}}. This is either raw text (with an implicit new
16988line) or a quoted C string (which does not contain an implicit newline).
16989
16990@table @code
16991@item "~" @var{string-output}
16992The console output stream contains text that should be displayed in the
16993CLI console window. It contains the textual responses to CLI commands.
16994
16995@item "@@" @var{string-output}
16996The target output stream contains any textual output from the running
16997target.
16998
16999@item "&" @var{string-output}
17000The log stream contains debugging messages being produced by @value{GDBN}'s
17001internals.
17002@end table
17003
17004@node GDB/MI Out-of-band Records
17005@subsection @sc{gdb/mi} Out-of-band Records
17006
17007@cindex out-of-band records in @sc{gdb/mi}
17008@cindex @sc{gdb/mi}, out-of-band records
17009@dfn{Out-of-band} records are used to notify the @sc{gdb/mi} client of
17010additional changes that have occurred. Those changes can either be a
17011consequence of @sc{gdb/mi} (e.g., a breakpoint modified) or a result of
17012target activity (e.g., target stopped).
17013
17014The following is a preliminary list of possible out-of-band records.
034dad6f 17015In particular, the @var{exec-async-output} records.
922fbb7b
AC
17016
17017@table @code
034dad6f
BR
17018@item *stopped,reason="@var{reason}"
17019@end table
17020
17021@var{reason} can be one of the following:
17022
17023@table @code
17024@item breakpoint-hit
17025A breakpoint was reached.
17026@item watchpoint-trigger
17027A watchpoint was triggered.
17028@item read-watchpoint-trigger
17029A read watchpoint was triggered.
17030@item access-watchpoint-trigger
17031An access watchpoint was triggered.
17032@item function-finished
17033An -exec-finish or similar CLI command was accomplished.
17034@item location-reached
17035An -exec-until or similar CLI command was accomplished.
17036@item watchpoint-scope
17037A watchpoint has gone out of scope.
17038@item end-stepping-range
17039An -exec-next, -exec-next-instruction, -exec-step, -exec-step-instruction or
17040similar CLI command was accomplished.
17041@item exited-signalled
17042The inferior exited because of a signal.
17043@item exited
17044The inferior exited.
17045@item exited-normally
17046The inferior exited normally.
17047@item signal-received
17048A signal was received by the inferior.
922fbb7b
AC
17049@end table
17050
17051
17052@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17053@node GDB/MI Command Description Format
17054@section @sc{gdb/mi} Command Description Format
17055
17056The remaining sections describe blocks of commands. Each block of
17057commands is laid out in a fashion similar to this section.
17058
17059Note the the line breaks shown in the examples are here only for
17060readability. They don't appear in the real output.
17061Also note that the commands with a non-available example (N.A.@:) are
17062not yet implemented.
17063
17064@subheading Motivation
17065
17066The motivation for this collection of commands.
17067
17068@subheading Introduction
17069
17070A brief introduction to this collection of commands as a whole.
17071
17072@subheading Commands
17073
17074For each command in the block, the following is described:
17075
17076@subsubheading Synopsis
17077
17078@smallexample
17079 -command @var{args}@dots{}
17080@end smallexample
17081
17082@subsubheading @value{GDBN} Command
17083
17084The corresponding @value{GDBN} CLI command.
17085
17086@subsubheading Result
17087
17088@subsubheading Out-of-band
17089
17090@subsubheading Notes
17091
17092@subsubheading Example
17093
17094
17095@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17096@node GDB/MI Breakpoint Table Commands
17097@section @sc{gdb/mi} Breakpoint table commands
17098
17099@cindex breakpoint commands for @sc{gdb/mi}
17100@cindex @sc{gdb/mi}, breakpoint commands
17101This section documents @sc{gdb/mi} commands for manipulating
17102breakpoints.
17103
17104@subheading The @code{-break-after} Command
17105@findex -break-after
17106
17107@subsubheading Synopsis
17108
17109@smallexample
17110 -break-after @var{number} @var{count}
17111@end smallexample
17112
17113The breakpoint number @var{number} is not in effect until it has been
17114hit @var{count} times. To see how this is reflected in the output of
17115the @samp{-break-list} command, see the description of the
17116@samp{-break-list} command below.
17117
17118@subsubheading @value{GDBN} Command
17119
17120The corresponding @value{GDBN} command is @samp{ignore}.
17121
17122@subsubheading Example
17123
17124@smallexample
17125(@value{GDBP})
17126-break-insert main
17127^done,bkpt=@{number="1",addr="0x000100d0",file="hello.c",line="5"@}
17128(@value{GDBP})
17129-break-after 1 3
17130~
17131^done
17132(@value{GDBP})
17133-break-list
17134^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
17135hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17136@{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17137@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17138@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17139@{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17140@{width="40",alignment="2",col_name="what",colhdr="What"@}],
17141body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17142addr="0x000100d0",func="main",file="hello.c",line="5",times="0",
17143ignore="3"@}]@}
17144(@value{GDBP})
17145@end smallexample
17146
17147@ignore
17148@subheading The @code{-break-catch} Command
17149@findex -break-catch
17150
17151@subheading The @code{-break-commands} Command
17152@findex -break-commands
17153@end ignore
17154
17155
17156@subheading The @code{-break-condition} Command
17157@findex -break-condition
17158
17159@subsubheading Synopsis
17160
17161@smallexample
17162 -break-condition @var{number} @var{expr}
17163@end smallexample
17164
17165Breakpoint @var{number} will stop the program only if the condition in
17166@var{expr} is true. The condition becomes part of the
17167@samp{-break-list} output (see the description of the @samp{-break-list}
17168command below).
17169
17170@subsubheading @value{GDBN} Command
17171
17172The corresponding @value{GDBN} command is @samp{condition}.
17173
17174@subsubheading Example
17175
17176@smallexample
17177(@value{GDBP})
17178-break-condition 1 1
17179^done
17180(@value{GDBP})
17181-break-list
17182^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
17183hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17184@{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17185@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17186@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17187@{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17188@{width="40",alignment="2",col_name="what",colhdr="What"@}],
17189body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17190addr="0x000100d0",func="main",file="hello.c",line="5",cond="1",
17191times="0",ignore="3"@}]@}
17192(@value{GDBP})
17193@end smallexample
17194
17195@subheading The @code{-break-delete} Command
17196@findex -break-delete
17197
17198@subsubheading Synopsis
17199
17200@smallexample
17201 -break-delete ( @var{breakpoint} )+
17202@end smallexample
17203
17204Delete the breakpoint(s) whose number(s) are specified in the argument
17205list. This is obviously reflected in the breakpoint list.
17206
17207@subsubheading @value{GDBN} command
17208
17209The corresponding @value{GDBN} command is @samp{delete}.
17210
17211@subsubheading Example
17212
17213@smallexample
17214(@value{GDBP})
17215-break-delete 1
17216^done
17217(@value{GDBP})
17218-break-list
17219^done,BreakpointTable=@{nr_rows="0",nr_cols="6",
17220hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17221@{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17222@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17223@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17224@{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17225@{width="40",alignment="2",col_name="what",colhdr="What"@}],
17226body=[]@}
17227(@value{GDBP})
17228@end smallexample
17229
17230@subheading The @code{-break-disable} Command
17231@findex -break-disable
17232
17233@subsubheading Synopsis
17234
17235@smallexample
17236 -break-disable ( @var{breakpoint} )+
17237@end smallexample
17238
17239Disable the named @var{breakpoint}(s). The field @samp{enabled} in the
17240break list is now set to @samp{n} for the named @var{breakpoint}(s).
17241
17242@subsubheading @value{GDBN} Command
17243
17244The corresponding @value{GDBN} command is @samp{disable}.
17245
17246@subsubheading Example
17247
17248@smallexample
17249(@value{GDBP})
17250-break-disable 2
17251^done
17252(@value{GDBP})
17253-break-list
17254^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
17255hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17256@{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17257@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17258@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17259@{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17260@{width="40",alignment="2",col_name="what",colhdr="What"@}],
17261body=[bkpt=@{number="2",type="breakpoint",disp="keep",enabled="n",
17262addr="0x000100d0",func="main",file="hello.c",line="5",times="0"@}]@}
17263(@value{GDBP})
17264@end smallexample
17265
17266@subheading The @code{-break-enable} Command
17267@findex -break-enable
17268
17269@subsubheading Synopsis
17270
17271@smallexample
17272 -break-enable ( @var{breakpoint} )+
17273@end smallexample
17274
17275Enable (previously disabled) @var{breakpoint}(s).
17276
17277@subsubheading @value{GDBN} Command
17278
17279The corresponding @value{GDBN} command is @samp{enable}.
17280
17281@subsubheading Example
17282
17283@smallexample
17284(@value{GDBP})
17285-break-enable 2
17286^done
17287(@value{GDBP})
17288-break-list
17289^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
17290hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17291@{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17292@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17293@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17294@{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17295@{width="40",alignment="2",col_name="what",colhdr="What"@}],
17296body=[bkpt=@{number="2",type="breakpoint",disp="keep",enabled="y",
17297addr="0x000100d0",func="main",file="hello.c",line="5",times="0"@}]@}
17298(@value{GDBP})
17299@end smallexample
17300
17301@subheading The @code{-break-info} Command
17302@findex -break-info
17303
17304@subsubheading Synopsis
17305
17306@smallexample
17307 -break-info @var{breakpoint}
17308@end smallexample
17309
17310@c REDUNDANT???
17311Get information about a single breakpoint.
17312
17313@subsubheading @value{GDBN} command
17314
17315The corresponding @value{GDBN} command is @samp{info break @var{breakpoint}}.
17316
17317@subsubheading Example
17318N.A.
17319
17320@subheading The @code{-break-insert} Command
17321@findex -break-insert
17322
17323@subsubheading Synopsis
17324
17325@smallexample
17326 -break-insert [ -t ] [ -h ] [ -r ]
17327 [ -c @var{condition} ] [ -i @var{ignore-count} ]
17328 [ -p @var{thread} ] [ @var{line} | @var{addr} ]
17329@end smallexample
17330
17331@noindent
17332If specified, @var{line}, can be one of:
17333
17334@itemize @bullet
17335@item function
17336@c @item +offset
17337@c @item -offset
17338@c @item linenum
17339@item filename:linenum
17340@item filename:function
17341@item *address
17342@end itemize
17343
17344The possible optional parameters of this command are:
17345
17346@table @samp
17347@item -t
17348Insert a tempoary breakpoint.
17349@item -h
17350Insert a hardware breakpoint.
17351@item -c @var{condition}
17352Make the breakpoint conditional on @var{condition}.
17353@item -i @var{ignore-count}
17354Initialize the @var{ignore-count}.
17355@item -r
17356Insert a regular breakpoint in all the functions whose names match the
17357given regular expression. Other flags are not applicable to regular
17358expresson.
17359@end table
17360
17361@subsubheading Result
17362
17363The result is in the form:
17364
17365@smallexample
17366 ^done,bkptno="@var{number}",func="@var{funcname}",
17367 file="@var{filename}",line="@var{lineno}"
17368@end smallexample
17369
17370@noindent
17371where @var{number} is the @value{GDBN} number for this breakpoint, @var{funcname}
17372is the name of the function where the breakpoint was inserted,
17373@var{filename} is the name of the source file which contains this
17374function, and @var{lineno} is the source line number within that file.
17375
17376Note: this format is open to change.
17377@c An out-of-band breakpoint instead of part of the result?
17378
17379@subsubheading @value{GDBN} Command
17380
17381The corresponding @value{GDBN} commands are @samp{break}, @samp{tbreak},
17382@samp{hbreak}, @samp{thbreak}, and @samp{rbreak}.
17383
17384@subsubheading Example
17385
17386@smallexample
17387(@value{GDBP})
17388-break-insert main
17389^done,bkpt=@{number="1",addr="0x0001072c",file="recursive2.c",line="4"@}
17390(@value{GDBP})
17391-break-insert -t foo
17392^done,bkpt=@{number="2",addr="0x00010774",file="recursive2.c",line="11"@}
17393(@value{GDBP})
17394-break-list
17395^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
17396hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17397@{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17398@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17399@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17400@{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17401@{width="40",alignment="2",col_name="what",colhdr="What"@}],
17402body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17403addr="0x0001072c", func="main",file="recursive2.c",line="4",times="0"@},
17404bkpt=@{number="2",type="breakpoint",disp="del",enabled="y",
17405addr="0x00010774",func="foo",file="recursive2.c",line="11",times="0"@}]@}
17406(@value{GDBP})
17407-break-insert -r foo.*
17408~int foo(int, int);
17409^done,bkpt=@{number="3",addr="0x00010774",file="recursive2.c",line="11"@}
17410(@value{GDBP})
17411@end smallexample
17412
17413@subheading The @code{-break-list} Command
17414@findex -break-list
17415
17416@subsubheading Synopsis
17417
17418@smallexample
17419 -break-list
17420@end smallexample
17421
17422Displays the list of inserted breakpoints, showing the following fields:
17423
17424@table @samp
17425@item Number
17426number of the breakpoint
17427@item Type
17428type of the breakpoint: @samp{breakpoint} or @samp{watchpoint}
17429@item Disposition
17430should the breakpoint be deleted or disabled when it is hit: @samp{keep}
17431or @samp{nokeep}
17432@item Enabled
17433is the breakpoint enabled or no: @samp{y} or @samp{n}
17434@item Address
17435memory location at which the breakpoint is set
17436@item What
17437logical location of the breakpoint, expressed by function name, file
17438name, line number
17439@item Times
17440number of times the breakpoint has been hit
17441@end table
17442
17443If there are no breakpoints or watchpoints, the @code{BreakpointTable}
17444@code{body} field is an empty list.
17445
17446@subsubheading @value{GDBN} Command
17447
17448The corresponding @value{GDBN} command is @samp{info break}.
17449
17450@subsubheading Example
17451
17452@smallexample
17453(@value{GDBP})
17454-break-list
17455^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
17456hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17457@{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17458@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17459@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17460@{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17461@{width="40",alignment="2",col_name="what",colhdr="What"@}],
17462body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17463addr="0x000100d0",func="main",file="hello.c",line="5",times="0"@},
17464bkpt=@{number="2",type="breakpoint",disp="keep",enabled="y",
17465addr="0x00010114",func="foo",file="hello.c",line="13",times="0"@}]@}
17466(@value{GDBP})
17467@end smallexample
17468
17469Here's an example of the result when there are no breakpoints:
17470
17471@smallexample
17472(@value{GDBP})
17473-break-list
17474^done,BreakpointTable=@{nr_rows="0",nr_cols="6",
17475hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17476@{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17477@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17478@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17479@{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17480@{width="40",alignment="2",col_name="what",colhdr="What"@}],
17481body=[]@}
17482(@value{GDBP})
17483@end smallexample
17484
17485@subheading The @code{-break-watch} Command
17486@findex -break-watch
17487
17488@subsubheading Synopsis
17489
17490@smallexample
17491 -break-watch [ -a | -r ]
17492@end smallexample
17493
17494Create a watchpoint. With the @samp{-a} option it will create an
17495@dfn{access} watchpoint, i.e. a watchpoint that triggers either on a
17496read from or on a write to the memory location. With the @samp{-r}
17497option, the watchpoint created is a @dfn{read} watchpoint, i.e. it will
17498trigger only when the memory location is accessed for reading. Without
17499either of the options, the watchpoint created is a regular watchpoint,
17500i.e. it will trigger when the memory location is accessed for writing.
17501@xref{Set Watchpoints, , Setting watchpoints}.
17502
17503Note that @samp{-break-list} will report a single list of watchpoints and
17504breakpoints inserted.
17505
17506@subsubheading @value{GDBN} Command
17507
17508The corresponding @value{GDBN} commands are @samp{watch}, @samp{awatch}, and
17509@samp{rwatch}.
17510
17511@subsubheading Example
17512
17513Setting a watchpoint on a variable in the @code{main} function:
17514
17515@smallexample
17516(@value{GDBP})
17517-break-watch x
17518^done,wpt=@{number="2",exp="x"@}
17519(@value{GDBP})
17520-exec-continue
17521^running
17522^done,reason="watchpoint-trigger",wpt=@{number="2",exp="x"@},
17523value=@{old="-268439212",new="55"@},
76ff342d
DJ
17524frame=@{func="main",args=[],file="recursive2.c",
17525fullname="/home/foo/bar/devo/myproject/recursive2.c",line="5"@}
922fbb7b
AC
17526(@value{GDBP})
17527@end smallexample
17528
17529Setting a watchpoint on a variable local to a function. @value{GDBN} will stop
17530the program execution twice: first for the variable changing value, then
17531for the watchpoint going out of scope.
17532
17533@smallexample
17534(@value{GDBP})
17535-break-watch C
17536^done,wpt=@{number="5",exp="C"@}
17537(@value{GDBP})
17538-exec-continue
17539^running
17540^done,reason="watchpoint-trigger",
17541wpt=@{number="5",exp="C"@},value=@{old="-276895068",new="3"@},
17542frame=@{func="callee4",args=[],
76ff342d
DJ
17543file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
17544fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"@}
922fbb7b
AC
17545(@value{GDBP})
17546-exec-continue
17547^running
17548^done,reason="watchpoint-scope",wpnum="5",
17549frame=@{func="callee3",args=[@{name="strarg",
17550value="0x11940 \"A string argument.\""@}],
76ff342d
DJ
17551file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
17552fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"@}
922fbb7b
AC
17553(@value{GDBP})
17554@end smallexample
17555
17556Listing breakpoints and watchpoints, at different points in the program
17557execution. Note that once the watchpoint goes out of scope, it is
17558deleted.
17559
17560@smallexample
17561(@value{GDBP})
17562-break-watch C
17563^done,wpt=@{number="2",exp="C"@}
17564(@value{GDBP})
17565-break-list
17566^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
17567hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17568@{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17569@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17570@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17571@{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17572@{width="40",alignment="2",col_name="what",colhdr="What"@}],
17573body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17574addr="0x00010734",func="callee4",
17575file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"@},
17576bkpt=@{number="2",type="watchpoint",disp="keep",
17577enabled="y",addr="",what="C",times="0"@}]@}
17578(@value{GDBP})
17579-exec-continue
17580^running
17581^done,reason="watchpoint-trigger",wpt=@{number="2",exp="C"@},
17582value=@{old="-276895068",new="3"@},
17583frame=@{func="callee4",args=[],
76ff342d
DJ
17584file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
17585fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"@}
922fbb7b
AC
17586(@value{GDBP})
17587-break-list
17588^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
17589hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17590@{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17591@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17592@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17593@{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17594@{width="40",alignment="2",col_name="what",colhdr="What"@}],
17595body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17596addr="0x00010734",func="callee4",
17597file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"@},
17598bkpt=@{number="2",type="watchpoint",disp="keep",
17599enabled="y",addr="",what="C",times="-5"@}]@}
17600(@value{GDBP})
17601-exec-continue
17602^running
17603^done,reason="watchpoint-scope",wpnum="2",
17604frame=@{func="callee3",args=[@{name="strarg",
17605value="0x11940 \"A string argument.\""@}],
76ff342d
DJ
17606file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
17607fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"@}
922fbb7b
AC
17608(@value{GDBP})
17609-break-list
17610^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
17611hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
17612@{width="14",alignment="-1",col_name="type",colhdr="Type"@},
17613@{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
17614@{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
17615@{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
17616@{width="40",alignment="2",col_name="what",colhdr="What"@}],
17617body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
17618addr="0x00010734",func="callee4",
17619file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"@}]@}
17620(@value{GDBP})
17621@end smallexample
17622
17623@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17624@node GDB/MI Data Manipulation
17625@section @sc{gdb/mi} Data Manipulation
17626
17627@cindex data manipulation, in @sc{gdb/mi}
17628@cindex @sc{gdb/mi}, data manipulation
17629This section describes the @sc{gdb/mi} commands that manipulate data:
17630examine memory and registers, evaluate expressions, etc.
17631
17632@c REMOVED FROM THE INTERFACE.
17633@c @subheading -data-assign
17634@c Change the value of a program variable. Plenty of side effects.
17635@c @subsubheading GDB command
17636@c set variable
17637@c @subsubheading Example
17638@c N.A.
17639
17640@subheading The @code{-data-disassemble} Command
17641@findex -data-disassemble
17642
17643@subsubheading Synopsis
17644
17645@smallexample
17646 -data-disassemble
17647 [ -s @var{start-addr} -e @var{end-addr} ]
17648 | [ -f @var{filename} -l @var{linenum} [ -n @var{lines} ] ]
17649 -- @var{mode}
17650@end smallexample
17651
17652@noindent
17653Where:
17654
17655@table @samp
17656@item @var{start-addr}
17657is the beginning address (or @code{$pc})
17658@item @var{end-addr}
17659is the end address
17660@item @var{filename}
17661is the name of the file to disassemble
17662@item @var{linenum}
17663is the line number to disassemble around
17664@item @var{lines}
17665is the the number of disassembly lines to be produced. If it is -1,
17666the whole function will be disassembled, in case no @var{end-addr} is
17667specified. If @var{end-addr} is specified as a non-zero value, and
17668@var{lines} is lower than the number of disassembly lines between
17669@var{start-addr} and @var{end-addr}, only @var{lines} lines are
17670displayed; if @var{lines} is higher than the number of lines between
17671@var{start-addr} and @var{end-addr}, only the lines up to @var{end-addr}
17672are displayed.
17673@item @var{mode}
17674is either 0 (meaning only disassembly) or 1 (meaning mixed source and
17675disassembly).
17676@end table
17677
17678@subsubheading Result
17679
17680The output for each instruction is composed of four fields:
17681
17682@itemize @bullet
17683@item Address
17684@item Func-name
17685@item Offset
17686@item Instruction
17687@end itemize
17688
17689Note that whatever included in the instruction field, is not manipulated
17690directely by @sc{gdb/mi}, i.e. it is not possible to adjust its format.
17691
17692@subsubheading @value{GDBN} Command
17693
17694There's no direct mapping from this command to the CLI.
17695
17696@subsubheading Example
17697
17698Disassemble from the current value of @code{$pc} to @code{$pc + 20}:
17699
17700@smallexample
17701(@value{GDBP})
17702-data-disassemble -s $pc -e "$pc + 20" -- 0
17703^done,
17704asm_insns=[
17705@{address="0x000107c0",func-name="main",offset="4",
17706inst="mov 2, %o0"@},
17707@{address="0x000107c4",func-name="main",offset="8",
17708inst="sethi %hi(0x11800), %o2"@},
17709@{address="0x000107c8",func-name="main",offset="12",
17710inst="or %o2, 0x140, %o1\t! 0x11940 <_lib_version+8>"@},
17711@{address="0x000107cc",func-name="main",offset="16",
17712inst="sethi %hi(0x11800), %o2"@},
17713@{address="0x000107d0",func-name="main",offset="20",
17714inst="or %o2, 0x168, %o4\t! 0x11968 <_lib_version+48>"@}]
17715(@value{GDBP})
17716@end smallexample
17717
17718Disassemble the whole @code{main} function. Line 32 is part of
17719@code{main}.
17720
17721@smallexample
17722-data-disassemble -f basics.c -l 32 -- 0
17723^done,asm_insns=[
17724@{address="0x000107bc",func-name="main",offset="0",
17725inst="save %sp, -112, %sp"@},
17726@{address="0x000107c0",func-name="main",offset="4",
17727inst="mov 2, %o0"@},
17728@{address="0x000107c4",func-name="main",offset="8",
17729inst="sethi %hi(0x11800), %o2"@},
17730[@dots{}]
17731@{address="0x0001081c",func-name="main",offset="96",inst="ret "@},
17732@{address="0x00010820",func-name="main",offset="100",inst="restore "@}]
17733(@value{GDBP})
17734@end smallexample
17735
17736Disassemble 3 instructions from the start of @code{main}:
17737
17738@smallexample
17739(@value{GDBP})
17740-data-disassemble -f basics.c -l 32 -n 3 -- 0
17741^done,asm_insns=[
17742@{address="0x000107bc",func-name="main",offset="0",
17743inst="save %sp, -112, %sp"@},
17744@{address="0x000107c0",func-name="main",offset="4",
17745inst="mov 2, %o0"@},
17746@{address="0x000107c4",func-name="main",offset="8",
17747inst="sethi %hi(0x11800), %o2"@}]
17748(@value{GDBP})
17749@end smallexample
17750
17751Disassemble 3 instructions from the start of @code{main} in mixed mode:
17752
17753@smallexample
17754(@value{GDBP})
17755-data-disassemble -f basics.c -l 32 -n 3 -- 1
17756^done,asm_insns=[
17757src_and_asm_line=@{line="31",
17758file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \
17759 testsuite/gdb.mi/basics.c",line_asm_insn=[
17760@{address="0x000107bc",func-name="main",offset="0",
17761inst="save %sp, -112, %sp"@}]@},
17762src_and_asm_line=@{line="32",
17763file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ \
17764 testsuite/gdb.mi/basics.c",line_asm_insn=[
17765@{address="0x000107c0",func-name="main",offset="4",
17766inst="mov 2, %o0"@},
17767@{address="0x000107c4",func-name="main",offset="8",
17768inst="sethi %hi(0x11800), %o2"@}]@}]
17769(@value{GDBP})
17770@end smallexample
17771
17772
17773@subheading The @code{-data-evaluate-expression} Command
17774@findex -data-evaluate-expression
17775
17776@subsubheading Synopsis
17777
17778@smallexample
17779 -data-evaluate-expression @var{expr}
17780@end smallexample
17781
17782Evaluate @var{expr} as an expression. The expression could contain an
17783inferior function call. The function call will execute synchronously.
17784If the expression contains spaces, it must be enclosed in double quotes.
17785
17786@subsubheading @value{GDBN} Command
17787
17788The corresponding @value{GDBN} commands are @samp{print}, @samp{output}, and
17789@samp{call}. In @code{gdbtk} only, there's a corresponding
17790@samp{gdb_eval} command.
17791
17792@subsubheading Example
17793
17794In the following example, the numbers that precede the commands are the
17795@dfn{tokens} described in @ref{GDB/MI Command Syntax, ,@sc{gdb/mi}
17796Command Syntax}. Notice how @sc{gdb/mi} returns the same tokens in its
17797output.
17798
17799@smallexample
17800211-data-evaluate-expression A
17801211^done,value="1"
17802(@value{GDBP})
17803311-data-evaluate-expression &A
17804311^done,value="0xefffeb7c"
17805(@value{GDBP})
17806411-data-evaluate-expression A+3
17807411^done,value="4"
17808(@value{GDBP})
17809511-data-evaluate-expression "A + 3"
17810511^done,value="4"
17811(@value{GDBP})
17812@end smallexample
17813
17814
17815@subheading The @code{-data-list-changed-registers} Command
17816@findex -data-list-changed-registers
17817
17818@subsubheading Synopsis
17819
17820@smallexample
17821 -data-list-changed-registers
17822@end smallexample
17823
17824Display a list of the registers that have changed.
17825
17826@subsubheading @value{GDBN} Command
17827
17828@value{GDBN} doesn't have a direct analog for this command; @code{gdbtk}
17829has the corresponding command @samp{gdb_changed_register_list}.
17830
17831@subsubheading Example
17832
17833On a PPC MBX board:
17834
17835@smallexample
17836(@value{GDBP})
17837-exec-continue
17838^running
17839
17840(@value{GDBP})
17841*stopped,reason="breakpoint-hit",bkptno="1",frame=@{func="main",
76ff342d 17842args=[],file="try.c",fullname="/home/foo/bar/devo/myproject/try.c",line="5"@}
922fbb7b
AC
17843(@value{GDBP})
17844-data-list-changed-registers
17845^done,changed-registers=["0","1","2","4","5","6","7","8","9",
17846"10","11","13","14","15","16","17","18","19","20","21","22","23",
17847"24","25","26","27","28","30","31","64","65","66","67","69"]
17848(@value{GDBP})
17849@end smallexample
17850
17851
17852@subheading The @code{-data-list-register-names} Command
17853@findex -data-list-register-names
17854
17855@subsubheading Synopsis
17856
17857@smallexample
17858 -data-list-register-names [ ( @var{regno} )+ ]
17859@end smallexample
17860
17861Show a list of register names for the current target. If no arguments
17862are given, it shows a list of the names of all the registers. If
17863integer numbers are given as arguments, it will print a list of the
17864names of the registers corresponding to the arguments. To ensure
17865consistency between a register name and its number, the output list may
17866include empty register names.
17867
17868@subsubheading @value{GDBN} Command
17869
17870@value{GDBN} does not have a command which corresponds to
17871@samp{-data-list-register-names}. In @code{gdbtk} there is a
17872corresponding command @samp{gdb_regnames}.
17873
17874@subsubheading Example
17875
17876For the PPC MBX board:
17877@smallexample
17878(@value{GDBP})
17879-data-list-register-names
17880^done,register-names=["r0","r1","r2","r3","r4","r5","r6","r7",
17881"r8","r9","r10","r11","r12","r13","r14","r15","r16","r17","r18",
17882"r19","r20","r21","r22","r23","r24","r25","r26","r27","r28","r29",
17883"r30","r31","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9",
17884"f10","f11","f12","f13","f14","f15","f16","f17","f18","f19","f20",
17885"f21","f22","f23","f24","f25","f26","f27","f28","f29","f30","f31",
17886"", "pc","ps","cr","lr","ctr","xer"]
17887(@value{GDBP})
17888-data-list-register-names 1 2 3
17889^done,register-names=["r1","r2","r3"]
17890(@value{GDBP})
17891@end smallexample
17892
17893@subheading The @code{-data-list-register-values} Command
17894@findex -data-list-register-values
17895
17896@subsubheading Synopsis
17897
17898@smallexample
17899 -data-list-register-values @var{fmt} [ ( @var{regno} )*]
17900@end smallexample
17901
17902Display the registers' contents. @var{fmt} is the format according to
17903which the registers' contents are to be returned, followed by an optional
17904list of numbers specifying the registers to display. A missing list of
17905numbers indicates that the contents of all the registers must be returned.
17906
17907Allowed formats for @var{fmt} are:
17908
17909@table @code
17910@item x
17911Hexadecimal
17912@item o
17913Octal
17914@item t
17915Binary
17916@item d
17917Decimal
17918@item r
17919Raw
17920@item N
17921Natural
17922@end table
17923
17924@subsubheading @value{GDBN} Command
17925
17926The corresponding @value{GDBN} commands are @samp{info reg}, @samp{info
17927all-reg}, and (in @code{gdbtk}) @samp{gdb_fetch_registers}.
17928
17929@subsubheading Example
17930
17931For a PPC MBX board (note: line breaks are for readability only, they
17932don't appear in the actual output):
17933
17934@smallexample
17935(@value{GDBP})
17936-data-list-register-values r 64 65
17937^done,register-values=[@{number="64",value="0xfe00a300"@},
17938@{number="65",value="0x00029002"@}]
17939(@value{GDBP})
17940-data-list-register-values x
17941^done,register-values=[@{number="0",value="0xfe0043c8"@},
17942@{number="1",value="0x3fff88"@},@{number="2",value="0xfffffffe"@},
17943@{number="3",value="0x0"@},@{number="4",value="0xa"@},
17944@{number="5",value="0x3fff68"@},@{number="6",value="0x3fff58"@},
17945@{number="7",value="0xfe011e98"@},@{number="8",value="0x2"@},
17946@{number="9",value="0xfa202820"@},@{number="10",value="0xfa202808"@},
17947@{number="11",value="0x1"@},@{number="12",value="0x0"@},
17948@{number="13",value="0x4544"@},@{number="14",value="0xffdfffff"@},
17949@{number="15",value="0xffffffff"@},@{number="16",value="0xfffffeff"@},
17950@{number="17",value="0xefffffed"@},@{number="18",value="0xfffffffe"@},
17951@{number="19",value="0xffffffff"@},@{number="20",value="0xffffffff"@},
17952@{number="21",value="0xffffffff"@},@{number="22",value="0xfffffff7"@},
17953@{number="23",value="0xffffffff"@},@{number="24",value="0xffffffff"@},
17954@{number="25",value="0xffffffff"@},@{number="26",value="0xfffffffb"@},
17955@{number="27",value="0xffffffff"@},@{number="28",value="0xf7bfffff"@},
17956@{number="29",value="0x0"@},@{number="30",value="0xfe010000"@},
17957@{number="31",value="0x0"@},@{number="32",value="0x0"@},
17958@{number="33",value="0x0"@},@{number="34",value="0x0"@},
17959@{number="35",value="0x0"@},@{number="36",value="0x0"@},
17960@{number="37",value="0x0"@},@{number="38",value="0x0"@},
17961@{number="39",value="0x0"@},@{number="40",value="0x0"@},
17962@{number="41",value="0x0"@},@{number="42",value="0x0"@},
17963@{number="43",value="0x0"@},@{number="44",value="0x0"@},
17964@{number="45",value="0x0"@},@{number="46",value="0x0"@},
17965@{number="47",value="0x0"@},@{number="48",value="0x0"@},
17966@{number="49",value="0x0"@},@{number="50",value="0x0"@},
17967@{number="51",value="0x0"@},@{number="52",value="0x0"@},
17968@{number="53",value="0x0"@},@{number="54",value="0x0"@},
17969@{number="55",value="0x0"@},@{number="56",value="0x0"@},
17970@{number="57",value="0x0"@},@{number="58",value="0x0"@},
17971@{number="59",value="0x0"@},@{number="60",value="0x0"@},
17972@{number="61",value="0x0"@},@{number="62",value="0x0"@},
17973@{number="63",value="0x0"@},@{number="64",value="0xfe00a300"@},
17974@{number="65",value="0x29002"@},@{number="66",value="0x202f04b5"@},
17975@{number="67",value="0xfe0043b0"@},@{number="68",value="0xfe00b3e4"@},
17976@{number="69",value="0x20002b03"@}]
17977(@value{GDBP})
17978@end smallexample
17979
17980
17981@subheading The @code{-data-read-memory} Command
17982@findex -data-read-memory
17983
17984@subsubheading Synopsis
17985
17986@smallexample
17987 -data-read-memory [ -o @var{byte-offset} ]
17988 @var{address} @var{word-format} @var{word-size}
17989 @var{nr-rows} @var{nr-cols} [ @var{aschar} ]
17990@end smallexample
17991
17992@noindent
17993where:
17994
17995@table @samp
17996@item @var{address}
17997An expression specifying the address of the first memory word to be
17998read. Complex expressions containing embedded white space should be
17999quoted using the C convention.
18000
18001@item @var{word-format}
18002The format to be used to print the memory words. The notation is the
18003same as for @value{GDBN}'s @code{print} command (@pxref{Output Formats,
18004,Output formats}).
18005
18006@item @var{word-size}
18007The size of each memory word in bytes.
18008
18009@item @var{nr-rows}
18010The number of rows in the output table.
18011
18012@item @var{nr-cols}
18013The number of columns in the output table.
18014
18015@item @var{aschar}
18016If present, indicates that each row should include an @sc{ascii} dump. The
18017value of @var{aschar} is used as a padding character when a byte is not a
18018member of the printable @sc{ascii} character set (printable @sc{ascii}
18019characters are those whose code is between 32 and 126, inclusively).
18020
18021@item @var{byte-offset}
18022An offset to add to the @var{address} before fetching memory.
18023@end table
18024
18025This command displays memory contents as a table of @var{nr-rows} by
18026@var{nr-cols} words, each word being @var{word-size} bytes. In total,
18027@code{@var{nr-rows} * @var{nr-cols} * @var{word-size}} bytes are read
18028(returned as @samp{total-bytes}). Should less than the requested number
18029of bytes be returned by the target, the missing words are identified
18030using @samp{N/A}. The number of bytes read from the target is returned
18031in @samp{nr-bytes} and the starting address used to read memory in
18032@samp{addr}.
18033
18034The address of the next/previous row or page is available in
18035@samp{next-row} and @samp{prev-row}, @samp{next-page} and
18036@samp{prev-page}.
18037
18038@subsubheading @value{GDBN} Command
18039
18040The corresponding @value{GDBN} command is @samp{x}. @code{gdbtk} has
18041@samp{gdb_get_mem} memory read command.
18042
18043@subsubheading Example
18044
18045Read six bytes of memory starting at @code{bytes+6} but then offset by
18046@code{-6} bytes. Format as three rows of two columns. One byte per
18047word. Display each word in hex.
18048
18049@smallexample
18050(@value{GDBP})
180519-data-read-memory -o -6 -- bytes+6 x 1 3 2
180529^done,addr="0x00001390",nr-bytes="6",total-bytes="6",
18053next-row="0x00001396",prev-row="0x0000138e",next-page="0x00001396",
18054prev-page="0x0000138a",memory=[
18055@{addr="0x00001390",data=["0x00","0x01"]@},
18056@{addr="0x00001392",data=["0x02","0x03"]@},
18057@{addr="0x00001394",data=["0x04","0x05"]@}]
18058(@value{GDBP})
18059@end smallexample
18060
18061Read two bytes of memory starting at address @code{shorts + 64} and
18062display as a single word formatted in decimal.
18063
18064@smallexample
18065(@value{GDBP})
180665-data-read-memory shorts+64 d 2 1 1
180675^done,addr="0x00001510",nr-bytes="2",total-bytes="2",
18068next-row="0x00001512",prev-row="0x0000150e",
18069next-page="0x00001512",prev-page="0x0000150e",memory=[
18070@{addr="0x00001510",data=["128"]@}]
18071(@value{GDBP})
18072@end smallexample
18073
18074Read thirty two bytes of memory starting at @code{bytes+16} and format
18075as eight rows of four columns. Include a string encoding with @samp{x}
18076used as the non-printable character.
18077
18078@smallexample
18079(@value{GDBP})
180804-data-read-memory bytes+16 x 1 8 4 x
180814^done,addr="0x000013a0",nr-bytes="32",total-bytes="32",
18082next-row="0x000013c0",prev-row="0x0000139c",
18083next-page="0x000013c0",prev-page="0x00001380",memory=[
18084@{addr="0x000013a0",data=["0x10","0x11","0x12","0x13"],ascii="xxxx"@},
18085@{addr="0x000013a4",data=["0x14","0x15","0x16","0x17"],ascii="xxxx"@},
18086@{addr="0x000013a8",data=["0x18","0x19","0x1a","0x1b"],ascii="xxxx"@},
18087@{addr="0x000013ac",data=["0x1c","0x1d","0x1e","0x1f"],ascii="xxxx"@},
18088@{addr="0x000013b0",data=["0x20","0x21","0x22","0x23"],ascii=" !\"#"@},
18089@{addr="0x000013b4",data=["0x24","0x25","0x26","0x27"],ascii="$%&'"@},
18090@{addr="0x000013b8",data=["0x28","0x29","0x2a","0x2b"],ascii="()*+"@},
18091@{addr="0x000013bc",data=["0x2c","0x2d","0x2e","0x2f"],ascii=",-./"@}]
18092(@value{GDBP})
18093@end smallexample
18094
18095@subheading The @code{-display-delete} Command
18096@findex -display-delete
18097
18098@subsubheading Synopsis
18099
18100@smallexample
18101 -display-delete @var{number}
18102@end smallexample
18103
18104Delete the display @var{number}.
18105
18106@subsubheading @value{GDBN} Command
18107
18108The corresponding @value{GDBN} command is @samp{delete display}.
18109
18110@subsubheading Example
18111N.A.
18112
18113
18114@subheading The @code{-display-disable} Command
18115@findex -display-disable
18116
18117@subsubheading Synopsis
18118
18119@smallexample
18120 -display-disable @var{number}
18121@end smallexample
18122
18123Disable display @var{number}.
18124
18125@subsubheading @value{GDBN} Command
18126
18127The corresponding @value{GDBN} command is @samp{disable display}.
18128
18129@subsubheading Example
18130N.A.
18131
18132
18133@subheading The @code{-display-enable} Command
18134@findex -display-enable
18135
18136@subsubheading Synopsis
18137
18138@smallexample
18139 -display-enable @var{number}
18140@end smallexample
18141
18142Enable display @var{number}.
18143
18144@subsubheading @value{GDBN} Command
18145
18146The corresponding @value{GDBN} command is @samp{enable display}.
18147
18148@subsubheading Example
18149N.A.
18150
18151
18152@subheading The @code{-display-insert} Command
18153@findex -display-insert
18154
18155@subsubheading Synopsis
18156
18157@smallexample
18158 -display-insert @var{expression}
18159@end smallexample
18160
18161Display @var{expression} every time the program stops.
18162
18163@subsubheading @value{GDBN} Command
18164
18165The corresponding @value{GDBN} command is @samp{display}.
18166
18167@subsubheading Example
18168N.A.
18169
18170
18171@subheading The @code{-display-list} Command
18172@findex -display-list
18173
18174@subsubheading Synopsis
18175
18176@smallexample
18177 -display-list
18178@end smallexample
18179
18180List the displays. Do not show the current values.
18181
18182@subsubheading @value{GDBN} Command
18183
18184The corresponding @value{GDBN} command is @samp{info display}.
18185
18186@subsubheading Example
18187N.A.
18188
18189
18190@subheading The @code{-environment-cd} Command
18191@findex -environment-cd
18192
18193@subsubheading Synopsis
18194
18195@smallexample
18196 -environment-cd @var{pathdir}
18197@end smallexample
18198
18199Set @value{GDBN}'s working directory.
18200
18201@subsubheading @value{GDBN} Command
18202
18203The corresponding @value{GDBN} command is @samp{cd}.
18204
18205@subsubheading Example
18206
18207@smallexample
18208(@value{GDBP})
18209-environment-cd /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
18210^done
18211(@value{GDBP})
18212@end smallexample
18213
18214
18215@subheading The @code{-environment-directory} Command
18216@findex -environment-directory
18217
18218@subsubheading Synopsis
18219
18220@smallexample
18221 -environment-directory [ -r ] [ @var{pathdir} ]+
18222@end smallexample
18223
18224Add directories @var{pathdir} to beginning of search path for source files.
18225If the @samp{-r} option is used, the search path is reset to the default
b383017d 18226search path. If directories @var{pathdir} are supplied in addition to the
922fbb7b
AC
18227@samp{-r} option, the search path is first reset and then addition
18228occurs as normal.
b383017d 18229Multiple directories may be specified, separated by blanks. Specifying
922fbb7b
AC
18230multiple directories in a single command
18231results in the directories added to the beginning of the
18232search path in the same order they were presented in the command.
18233If blanks are needed as
18234part of a directory name, double-quotes should be used around
18235the name. In the command output, the path will show up separated
b383017d 18236by the system directory-separator character. The directory-seperator
922fbb7b
AC
18237character must not be used
18238in any directory name.
18239If no directories are specified, the current search path is displayed.
18240
18241@subsubheading @value{GDBN} Command
18242
18243The corresponding @value{GDBN} command is @samp{dir}.
18244
18245@subsubheading Example
18246
18247@smallexample
18248(@value{GDBP})
18249-environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
18250^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
18251(@value{GDBP})
18252-environment-directory ""
18253^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
18254(@value{GDBP})
18255-environment-directory -r /home/jjohnstn/src/gdb /usr/src
18256^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd"
18257(@value{GDBP})
18258-environment-directory -r
18259^done,source-path="$cdir:$cwd"
18260(@value{GDBP})
18261@end smallexample
18262
18263
18264@subheading The @code{-environment-path} Command
18265@findex -environment-path
18266
18267@subsubheading Synopsis
18268
18269@smallexample
18270 -environment-path [ -r ] [ @var{pathdir} ]+
18271@end smallexample
18272
18273Add directories @var{pathdir} to beginning of search path for object files.
18274If the @samp{-r} option is used, the search path is reset to the original
b383017d
RM
18275search path that existed at gdb start-up. If directories @var{pathdir} are
18276supplied in addition to the
922fbb7b
AC
18277@samp{-r} option, the search path is first reset and then addition
18278occurs as normal.
b383017d 18279Multiple directories may be specified, separated by blanks. Specifying
922fbb7b
AC
18280multiple directories in a single command
18281results in the directories added to the beginning of the
18282search path in the same order they were presented in the command.
18283If blanks are needed as
18284part of a directory name, double-quotes should be used around
18285the name. In the command output, the path will show up separated
b383017d 18286by the system directory-separator character. The directory-seperator
922fbb7b
AC
18287character must not be used
18288in any directory name.
18289If no directories are specified, the current path is displayed.
18290
18291
18292@subsubheading @value{GDBN} Command
18293
18294The corresponding @value{GDBN} command is @samp{path}.
18295
18296@subsubheading Example
18297
18298@smallexample
18299(@value{GDBP})
b383017d 18300-environment-path
922fbb7b
AC
18301^done,path="/usr/bin"
18302(@value{GDBP})
18303-environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb /bin
18304^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin"
18305(@value{GDBP})
18306-environment-path -r /usr/local/bin
18307^done,path="/usr/local/bin:/usr/bin"
18308(@value{GDBP})
18309@end smallexample
18310
18311
18312@subheading The @code{-environment-pwd} Command
18313@findex -environment-pwd
18314
18315@subsubheading Synopsis
18316
18317@smallexample
18318 -environment-pwd
18319@end smallexample
18320
18321Show the current working directory.
18322
18323@subsubheading @value{GDBN} command
18324
18325The corresponding @value{GDBN} command is @samp{pwd}.
18326
18327@subsubheading Example
18328
18329@smallexample
18330(@value{GDBP})
18331-environment-pwd
18332^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
18333(@value{GDBP})
18334@end smallexample
18335
18336@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18337@node GDB/MI Program Control
18338@section @sc{gdb/mi} Program control
18339
18340@subsubheading Program termination
18341
18342As a result of execution, the inferior program can run to completion, if
18343it doesn't encounter any breakpoints. In this case the output will
18344include an exit code, if the program has exited exceptionally.
18345
18346@subsubheading Examples
18347
18348@noindent
18349Program exited normally:
18350
18351@smallexample
18352(@value{GDBP})
18353-exec-run
18354^running
18355(@value{GDBP})
18356x = 55
18357*stopped,reason="exited-normally"
18358(@value{GDBP})
18359@end smallexample
18360
18361@noindent
18362Program exited exceptionally:
18363
18364@smallexample
18365(@value{GDBP})
18366-exec-run
18367^running
18368(@value{GDBP})
18369x = 55
18370*stopped,reason="exited",exit-code="01"
18371(@value{GDBP})
18372@end smallexample
18373
18374Another way the program can terminate is if it receives a signal such as
18375@code{SIGINT}. In this case, @sc{gdb/mi} displays this:
18376
18377@smallexample
18378(@value{GDBP})
18379*stopped,reason="exited-signalled",signal-name="SIGINT",
18380signal-meaning="Interrupt"
18381@end smallexample
18382
18383
18384@subheading The @code{-exec-abort} Command
18385@findex -exec-abort
18386
18387@subsubheading Synopsis
18388
18389@smallexample
18390 -exec-abort
18391@end smallexample
18392
18393Kill the inferior running program.
18394
18395@subsubheading @value{GDBN} Command
18396
18397The corresponding @value{GDBN} command is @samp{kill}.
18398
18399@subsubheading Example
18400N.A.
18401
18402
18403@subheading The @code{-exec-arguments} Command
18404@findex -exec-arguments
18405
18406@subsubheading Synopsis
18407
18408@smallexample
18409 -exec-arguments @var{args}
18410@end smallexample
18411
18412Set the inferior program arguments, to be used in the next
18413@samp{-exec-run}.
18414
18415@subsubheading @value{GDBN} Command
18416
18417The corresponding @value{GDBN} command is @samp{set args}.
18418
18419@subsubheading Example
18420
18421@c FIXME!
18422Don't have one around.
18423
18424
18425@subheading The @code{-exec-continue} Command
18426@findex -exec-continue
18427
18428@subsubheading Synopsis
18429
18430@smallexample
18431 -exec-continue
18432@end smallexample
18433
18434Asynchronous command. Resumes the execution of the inferior program
18435until a breakpoint is encountered, or until the inferior exits.
18436
18437@subsubheading @value{GDBN} Command
18438
18439The corresponding @value{GDBN} corresponding is @samp{continue}.
18440
18441@subsubheading Example
18442
18443@smallexample
18444-exec-continue
18445^running
18446(@value{GDBP})
18447@@Hello world
18448*stopped,reason="breakpoint-hit",bkptno="2",frame=@{func="foo",args=[],
76ff342d 18449file="hello.c",fullname="/home/foo/bar/devo/myproject/hello.c",line="13"@}
922fbb7b
AC
18450(@value{GDBP})
18451@end smallexample
18452
18453
18454@subheading The @code{-exec-finish} Command
18455@findex -exec-finish
18456
18457@subsubheading Synopsis
18458
18459@smallexample
18460 -exec-finish
18461@end smallexample
18462
18463Asynchronous command. Resumes the execution of the inferior program
18464until the current function is exited. Displays the results returned by
18465the function.
18466
18467@subsubheading @value{GDBN} Command
18468
18469The corresponding @value{GDBN} command is @samp{finish}.
18470
18471@subsubheading Example
18472
18473Function returning @code{void}.
18474
18475@smallexample
18476-exec-finish
18477^running
18478(@value{GDBP})
18479@@hello from foo
18480*stopped,reason="function-finished",frame=@{func="main",args=[],
76ff342d 18481file="hello.c",fullname="/home/foo/bar/devo/myproject/hello.c",line="7"@}
922fbb7b
AC
18482(@value{GDBP})
18483@end smallexample
18484
18485Function returning other than @code{void}. The name of the internal
18486@value{GDBN} variable storing the result is printed, together with the
18487value itself.
18488
18489@smallexample
18490-exec-finish
18491^running
18492(@value{GDBP})
18493*stopped,reason="function-finished",frame=@{addr="0x000107b0",func="foo",
18494args=[@{name="a",value="1"],@{name="b",value="9"@}@},
76ff342d 18495file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
922fbb7b
AC
18496gdb-result-var="$1",return-value="0"
18497(@value{GDBP})
18498@end smallexample
18499
18500
18501@subheading The @code{-exec-interrupt} Command
18502@findex -exec-interrupt
18503
18504@subsubheading Synopsis
18505
18506@smallexample
18507 -exec-interrupt
18508@end smallexample
18509
18510Asynchronous command. Interrupts the background execution of the target.
18511Note how the token associated with the stop message is the one for the
18512execution command that has been interrupted. The token for the interrupt
18513itself only appears in the @samp{^done} output. If the user is trying to
18514interrupt a non-running program, an error message will be printed.
18515
18516@subsubheading @value{GDBN} Command
18517
18518The corresponding @value{GDBN} command is @samp{interrupt}.
18519
18520@subsubheading Example
18521
18522@smallexample
18523(@value{GDBP})
18524111-exec-continue
18525111^running
18526
18527(@value{GDBP})
18528222-exec-interrupt
18529222^done
18530(@value{GDBP})
18531111*stopped,signal-name="SIGINT",signal-meaning="Interrupt",
76ff342d
DJ
18532frame=@{addr="0x00010140",func="foo",args=[],file="try.c",
18533fullname="/home/foo/bar/devo/myproject/try.c",line="13"@}
922fbb7b
AC
18534(@value{GDBP})
18535
18536(@value{GDBP})
18537-exec-interrupt
18538^error,msg="mi_cmd_exec_interrupt: Inferior not executing."
18539(@value{GDBP})
18540@end smallexample
18541
18542
18543@subheading The @code{-exec-next} Command
18544@findex -exec-next
18545
18546@subsubheading Synopsis
18547
18548@smallexample
18549 -exec-next
18550@end smallexample
18551
18552Asynchronous command. Resumes execution of the inferior program, stopping
18553when the beginning of the next source line is reached.
18554
18555@subsubheading @value{GDBN} Command
18556
18557The corresponding @value{GDBN} command is @samp{next}.
18558
18559@subsubheading Example
18560
18561@smallexample
18562-exec-next
18563^running
18564(@value{GDBP})
18565*stopped,reason="end-stepping-range",line="8",file="hello.c"
18566(@value{GDBP})
18567@end smallexample
18568
18569
18570@subheading The @code{-exec-next-instruction} Command
18571@findex -exec-next-instruction
18572
18573@subsubheading Synopsis
18574
18575@smallexample
18576 -exec-next-instruction
18577@end smallexample
18578
18579Asynchronous command. Executes one machine instruction. If the
18580instruction is a function call continues until the function returns. If
18581the program stops at an instruction in the middle of a source line, the
18582address will be printed as well.
18583
18584@subsubheading @value{GDBN} Command
18585
18586The corresponding @value{GDBN} command is @samp{nexti}.
18587
18588@subsubheading Example
18589
18590@smallexample
18591(@value{GDBP})
18592-exec-next-instruction
18593^running
18594
18595(@value{GDBP})
18596*stopped,reason="end-stepping-range",
18597addr="0x000100d4",line="5",file="hello.c"
18598(@value{GDBP})
18599@end smallexample
18600
18601
18602@subheading The @code{-exec-return} Command
18603@findex -exec-return
18604
18605@subsubheading Synopsis
18606
18607@smallexample
18608 -exec-return
18609@end smallexample
18610
18611Makes current function return immediately. Doesn't execute the inferior.
18612Displays the new current frame.
18613
18614@subsubheading @value{GDBN} Command
18615
18616The corresponding @value{GDBN} command is @samp{return}.
18617
18618@subsubheading Example
18619
18620@smallexample
18621(@value{GDBP})
18622200-break-insert callee4
18623200^done,bkpt=@{number="1",addr="0x00010734",
18624file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"@}
18625(@value{GDBP})
18626000-exec-run
18627000^running
18628(@value{GDBP})
18629000*stopped,reason="breakpoint-hit",bkptno="1",
18630frame=@{func="callee4",args=[],
76ff342d
DJ
18631file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
18632fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"@}
922fbb7b
AC
18633(@value{GDBP})
18634205-break-delete
18635205^done
18636(@value{GDBP})
18637111-exec-return
18638111^done,frame=@{level="0",func="callee3",
18639args=[@{name="strarg",
18640value="0x11940 \"A string argument.\""@}],
76ff342d
DJ
18641file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
18642fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"@}
922fbb7b
AC
18643(@value{GDBP})
18644@end smallexample
18645
18646
18647@subheading The @code{-exec-run} Command
18648@findex -exec-run
18649
18650@subsubheading Synopsis
18651
18652@smallexample
18653 -exec-run
18654@end smallexample
18655
18656Asynchronous command. Starts execution of the inferior from the
18657beginning. The inferior executes until either a breakpoint is
18658encountered or the program exits.
18659
18660@subsubheading @value{GDBN} Command
18661
18662The corresponding @value{GDBN} command is @samp{run}.
18663
18664@subsubheading Example
18665
18666@smallexample
18667(@value{GDBP})
18668-break-insert main
18669^done,bkpt=@{number="1",addr="0x0001072c",file="recursive2.c",line="4"@}
18670(@value{GDBP})
18671-exec-run
18672^running
18673(@value{GDBP})
18674*stopped,reason="breakpoint-hit",bkptno="1",
76ff342d
DJ
18675frame=@{func="main",args=[],file="recursive2.c",
18676fullname="/home/foo/bar/devo/myproject/recursive2.c",line="4"@}
922fbb7b
AC
18677(@value{GDBP})
18678@end smallexample
18679
18680
18681@subheading The @code{-exec-show-arguments} Command
18682@findex -exec-show-arguments
18683
18684@subsubheading Synopsis
18685
18686@smallexample
18687 -exec-show-arguments
18688@end smallexample
18689
18690Print the arguments of the program.
18691
18692@subsubheading @value{GDBN} Command
18693
18694The corresponding @value{GDBN} command is @samp{show args}.
18695
18696@subsubheading Example
18697N.A.
18698
18699@c @subheading -exec-signal
18700
18701@subheading The @code{-exec-step} Command
18702@findex -exec-step
18703
18704@subsubheading Synopsis
18705
18706@smallexample
18707 -exec-step
18708@end smallexample
18709
18710Asynchronous command. Resumes execution of the inferior program, stopping
18711when the beginning of the next source line is reached, if the next
18712source line is not a function call. If it is, stop at the first
18713instruction of the called function.
18714
18715@subsubheading @value{GDBN} Command
18716
18717The corresponding @value{GDBN} command is @samp{step}.
18718
18719@subsubheading Example
18720
18721Stepping into a function:
18722
18723@smallexample
18724-exec-step
18725^running
18726(@value{GDBP})
18727*stopped,reason="end-stepping-range",
18728frame=@{func="foo",args=[@{name="a",value="10"@},
76ff342d
DJ
18729@{name="b",value="0"@}],file="recursive2.c",
18730fullname="/home/foo/bar/devo/myproject/recursive2.c",line="11"@}
922fbb7b
AC
18731(@value{GDBP})
18732@end smallexample
18733
18734Regular stepping:
18735
18736@smallexample
18737-exec-step
18738^running
18739(@value{GDBP})
18740*stopped,reason="end-stepping-range",line="14",file="recursive2.c"
18741(@value{GDBP})
18742@end smallexample
18743
18744
18745@subheading The @code{-exec-step-instruction} Command
18746@findex -exec-step-instruction
18747
18748@subsubheading Synopsis
18749
18750@smallexample
18751 -exec-step-instruction
18752@end smallexample
18753
18754Asynchronous command. Resumes the inferior which executes one machine
18755instruction. The output, once @value{GDBN} has stopped, will vary depending on
18756whether we have stopped in the middle of a source line or not. In the
18757former case, the address at which the program stopped will be printed as
18758well.
18759
18760@subsubheading @value{GDBN} Command
18761
18762The corresponding @value{GDBN} command is @samp{stepi}.
18763
18764@subsubheading Example
18765
18766@smallexample
18767(@value{GDBP})
18768-exec-step-instruction
18769^running
18770
18771(@value{GDBP})
18772*stopped,reason="end-stepping-range",
76ff342d
DJ
18773frame=@{func="foo",args=[],file="try.c",
18774fullname="/home/foo/bar/devo/myproject/try.c",line="10"@}
922fbb7b
AC
18775(@value{GDBP})
18776-exec-step-instruction
18777^running
18778
18779(@value{GDBP})
18780*stopped,reason="end-stepping-range",
76ff342d
DJ
18781frame=@{addr="0x000100f4",func="foo",args=[],file="try.c",
18782fullname="/home/foo/bar/devo/myproject/try.c",line="10"@}
922fbb7b
AC
18783(@value{GDBP})
18784@end smallexample
18785
18786
18787@subheading The @code{-exec-until} Command
18788@findex -exec-until
18789
18790@subsubheading Synopsis
18791
18792@smallexample
18793 -exec-until [ @var{location} ]
18794@end smallexample
18795
18796Asynchronous command. Executes the inferior until the @var{location}
18797specified in the argument is reached. If there is no argument, the inferior
18798executes until a source line greater than the current one is reached.
18799The reason for stopping in this case will be @samp{location-reached}.
18800
18801@subsubheading @value{GDBN} Command
18802
18803The corresponding @value{GDBN} command is @samp{until}.
18804
18805@subsubheading Example
18806
18807@smallexample
18808(@value{GDBP})
18809-exec-until recursive2.c:6
18810^running
18811(@value{GDBP})
18812x = 55
18813*stopped,reason="location-reached",frame=@{func="main",args=[],
76ff342d 18814file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="6"@}
922fbb7b
AC
18815(@value{GDBP})
18816@end smallexample
18817
18818@ignore
18819@subheading -file-clear
18820Is this going away????
18821@end ignore
18822
18823
18824@subheading The @code{-file-exec-and-symbols} Command
18825@findex -file-exec-and-symbols
18826
18827@subsubheading Synopsis
18828
18829@smallexample
18830 -file-exec-and-symbols @var{file}
18831@end smallexample
18832
18833Specify the executable file to be debugged. This file is the one from
18834which the symbol table is also read. If no file is specified, the
18835command clears the executable and symbol information. If breakpoints
18836are set when using this command with no arguments, @value{GDBN} will produce
18837error messages. Otherwise, no output is produced, except a completion
18838notification.
18839
18840@subsubheading @value{GDBN} Command
18841
18842The corresponding @value{GDBN} command is @samp{file}.
18843
18844@subsubheading Example
18845
18846@smallexample
18847(@value{GDBP})
18848-file-exec-and-symbols /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
18849^done
18850(@value{GDBP})
18851@end smallexample
18852
18853
18854@subheading The @code{-file-exec-file} Command
18855@findex -file-exec-file
18856
18857@subsubheading Synopsis
18858
18859@smallexample
18860 -file-exec-file @var{file}
18861@end smallexample
18862
18863Specify the executable file to be debugged. Unlike
18864@samp{-file-exec-and-symbols}, the symbol table is @emph{not} read
18865from this file. If used without argument, @value{GDBN} clears the information
18866about the executable file. No output is produced, except a completion
18867notification.
18868
18869@subsubheading @value{GDBN} Command
18870
18871The corresponding @value{GDBN} command is @samp{exec-file}.
18872
18873@subsubheading Example
18874
18875@smallexample
18876(@value{GDBP})
18877-file-exec-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
18878^done
18879(@value{GDBP})
18880@end smallexample
18881
18882
18883@subheading The @code{-file-list-exec-sections} Command
18884@findex -file-list-exec-sections
18885
18886@subsubheading Synopsis
18887
18888@smallexample
18889 -file-list-exec-sections
18890@end smallexample
18891
18892List the sections of the current executable file.
18893
18894@subsubheading @value{GDBN} Command
18895
18896The @value{GDBN} command @samp{info file} shows, among the rest, the same
18897information as this command. @code{gdbtk} has a corresponding command
18898@samp{gdb_load_info}.
18899
18900@subsubheading Example
18901N.A.
18902
18903
1abaf70c
BR
18904@subheading The @code{-file-list-exec-source-file} Command
18905@findex -file-list-exec-source-file
18906
18907@subsubheading Synopsis
18908
18909@smallexample
18910 -file-list-exec-source-file
18911@end smallexample
18912
b383017d 18913List the line number, the current source file, and the absolute path
1abaf70c
BR
18914to the current source file for the current executable.
18915
18916@subsubheading @value{GDBN} Command
18917
18918There's no @value{GDBN} command which directly corresponds to this one.
18919
18920@subsubheading Example
18921
18922@smallexample
18923(@value{GDBP})
18924123-file-list-exec-source-file
18925123^done,line="1",file="foo.c",fullname="/home/bar/foo.c"
18926(@value{GDBP})
18927@end smallexample
18928
18929
922fbb7b
AC
18930@subheading The @code{-file-list-exec-source-files} Command
18931@findex -file-list-exec-source-files
18932
18933@subsubheading Synopsis
18934
18935@smallexample
18936 -file-list-exec-source-files
18937@end smallexample
18938
18939List the source files for the current executable.
18940
57c22c6c
BR
18941It will always output the filename, but only when GDB can find the absolute
18942file name of a source file, will it output the fullname.
18943
922fbb7b
AC
18944@subsubheading @value{GDBN} Command
18945
18946There's no @value{GDBN} command which directly corresponds to this one.
18947@code{gdbtk} has an analogous command @samp{gdb_listfiles}.
18948
18949@subsubheading Example
57c22c6c
BR
18950@smallexample
18951(@value{GDBP})
18952-file-list-exec-source-files
18953^done,files=[
18954@{file=foo.c,fullname=/home/foo.c@},
18955@{file=/home/bar.c,fullname=/home/bar.c@},
18956@{file=gdb_could_not_find_fullpath.c@}]
18957(@value{GDBP})
18958@end smallexample
922fbb7b
AC
18959
18960@subheading The @code{-file-list-shared-libraries} Command
18961@findex -file-list-shared-libraries
18962
18963@subsubheading Synopsis
18964
18965@smallexample
18966 -file-list-shared-libraries
18967@end smallexample
18968
18969List the shared libraries in the program.
18970
18971@subsubheading @value{GDBN} Command
18972
18973The corresponding @value{GDBN} command is @samp{info shared}.
18974
18975@subsubheading Example
18976N.A.
18977
18978
18979@subheading The @code{-file-list-symbol-files} Command
18980@findex -file-list-symbol-files
18981
18982@subsubheading Synopsis
18983
18984@smallexample
18985 -file-list-symbol-files
18986@end smallexample
18987
18988List symbol files.
18989
18990@subsubheading @value{GDBN} Command
18991
18992The corresponding @value{GDBN} command is @samp{info file} (part of it).
18993
18994@subsubheading Example
18995N.A.
18996
18997
18998@subheading The @code{-file-symbol-file} Command
18999@findex -file-symbol-file
19000
19001@subsubheading Synopsis
19002
19003@smallexample
19004 -file-symbol-file @var{file}
19005@end smallexample
19006
19007Read symbol table info from the specified @var{file} argument. When
19008used without arguments, clears @value{GDBN}'s symbol table info. No output is
19009produced, except for a completion notification.
19010
19011@subsubheading @value{GDBN} Command
19012
19013The corresponding @value{GDBN} command is @samp{symbol-file}.
19014
19015@subsubheading Example
19016
19017@smallexample
19018(@value{GDBP})
19019-file-symbol-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
19020^done
19021(@value{GDBP})
19022@end smallexample
19023
19024@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19025@node GDB/MI Miscellaneous Commands
19026@section Miscellaneous @value{GDBN} commands in @sc{gdb/mi}
19027
19028@c @subheading -gdb-complete
19029
19030@subheading The @code{-gdb-exit} Command
19031@findex -gdb-exit
19032
19033@subsubheading Synopsis
19034
19035@smallexample
19036 -gdb-exit
19037@end smallexample
19038
19039Exit @value{GDBN} immediately.
19040
19041@subsubheading @value{GDBN} Command
19042
19043Approximately corresponds to @samp{quit}.
19044
19045@subsubheading Example
19046
19047@smallexample
19048(@value{GDBP})
19049-gdb-exit
19050@end smallexample
19051
19052@subheading The @code{-gdb-set} Command
19053@findex -gdb-set
19054
19055@subsubheading Synopsis
19056
19057@smallexample
19058 -gdb-set
19059@end smallexample
19060
19061Set an internal @value{GDBN} variable.
19062@c IS THIS A DOLLAR VARIABLE? OR SOMETHING LIKE ANNOTATE ?????
19063
19064@subsubheading @value{GDBN} Command
19065
19066The corresponding @value{GDBN} command is @samp{set}.
19067
19068@subsubheading Example
19069
19070@smallexample
19071(@value{GDBP})
19072-gdb-set $foo=3
19073^done
19074(@value{GDBP})
19075@end smallexample
19076
19077
19078@subheading The @code{-gdb-show} Command
19079@findex -gdb-show
19080
19081@subsubheading Synopsis
19082
19083@smallexample
19084 -gdb-show
19085@end smallexample
19086
19087Show the current value of a @value{GDBN} variable.
19088
19089@subsubheading @value{GDBN} command
19090
19091The corresponding @value{GDBN} command is @samp{show}.
19092
19093@subsubheading Example
19094
19095@smallexample
19096(@value{GDBP})
19097-gdb-show annotate
19098^done,value="0"
19099(@value{GDBP})
19100@end smallexample
19101
19102@c @subheading -gdb-source
19103
19104
19105@subheading The @code{-gdb-version} Command
19106@findex -gdb-version
19107
19108@subsubheading Synopsis
19109
19110@smallexample
19111 -gdb-version
19112@end smallexample
19113
19114Show version information for @value{GDBN}. Used mostly in testing.
19115
19116@subsubheading @value{GDBN} Command
19117
19118There's no equivalent @value{GDBN} command. @value{GDBN} by default shows this
19119information when you start an interactive session.
19120
19121@subsubheading Example
19122
19123@c This example modifies the actual output from GDB to avoid overfull
19124@c box in TeX.
19125@smallexample
19126(@value{GDBP})
19127-gdb-version
19128~GNU gdb 5.2.1
19129~Copyright 2000 Free Software Foundation, Inc.
19130~GDB is free software, covered by the GNU General Public License, and
19131~you are welcome to change it and/or distribute copies of it under
19132~ certain conditions.
19133~Type "show copying" to see the conditions.
19134~There is absolutely no warranty for GDB. Type "show warranty" for
19135~ details.
b383017d 19136~This GDB was configured as
922fbb7b
AC
19137 "--host=sparc-sun-solaris2.5.1 --target=ppc-eabi".
19138^done
19139(@value{GDBP})
19140@end smallexample
19141
19142@subheading The @code{-interpreter-exec} Command
19143@findex -interpreter-exec
19144
19145@subheading Synopsis
19146
19147@smallexample
19148-interpreter-exec @var{interpreter} @var{command}
19149@end smallexample
19150
19151Execute the specified @var{command} in the given @var{interpreter}.
19152
19153@subheading @value{GDBN} Command
19154
19155The corresponding @value{GDBN} command is @samp{interpreter-exec}.
19156
19157@subheading Example
19158
19159@smallexample
19160(@value{GDBP})
19161-interpreter-exec console "break main"
19162&"During symbol reading, couldn't parse type; debugger out of date?.\n"
19163&"During symbol reading, bad structure-type format.\n"
19164~"Breakpoint 1 at 0x8074fc6: file ../../src/gdb/main.c, line 743.\n"
19165^done
19166(@value{GDBP})
19167@end smallexample
19168
19169@ignore
19170@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19171@node GDB/MI Kod Commands
19172@section @sc{gdb/mi} Kod Commands
19173
19174The Kod commands are not implemented.
19175
19176@c @subheading -kod-info
19177
19178@c @subheading -kod-list
19179
19180@c @subheading -kod-list-object-types
19181
19182@c @subheading -kod-show
19183
19184@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19185@node GDB/MI Memory Overlay Commands
19186@section @sc{gdb/mi} Memory Overlay Commands
19187
19188The memory overlay commands are not implemented.
19189
19190@c @subheading -overlay-auto
19191
19192@c @subheading -overlay-list-mapping-state
19193
19194@c @subheading -overlay-list-overlays
19195
19196@c @subheading -overlay-map
19197
19198@c @subheading -overlay-off
19199
19200@c @subheading -overlay-on
19201
19202@c @subheading -overlay-unmap
19203
19204@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19205@node GDB/MI Signal Handling Commands
19206@section @sc{gdb/mi} Signal Handling Commands
19207
19208Signal handling commands are not implemented.
19209
19210@c @subheading -signal-handle
19211
19212@c @subheading -signal-list-handle-actions
19213
19214@c @subheading -signal-list-signal-types
19215@end ignore
19216
19217
19218@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19219@node GDB/MI Stack Manipulation
19220@section @sc{gdb/mi} Stack Manipulation Commands
19221
922fbb7b
AC
19222@subheading The @code{-stack-info-depth} Command
19223@findex -stack-info-depth
19224
19225@subsubheading Synopsis
19226
19227@smallexample
19228 -stack-info-depth [ @var{max-depth} ]
19229@end smallexample
19230
19231Return the depth of the stack. If the integer argument @var{max-depth}
19232is specified, do not count beyond @var{max-depth} frames.
19233
19234@subsubheading @value{GDBN} Command
19235
19236There's no equivalent @value{GDBN} command.
19237
19238@subsubheading Example
19239
19240For a stack with frame levels 0 through 11:
19241
19242@smallexample
19243(@value{GDBP})
19244-stack-info-depth
19245^done,depth="12"
19246(@value{GDBP})
19247-stack-info-depth 4
19248^done,depth="4"
19249(@value{GDBP})
19250-stack-info-depth 12
19251^done,depth="12"
19252(@value{GDBP})
19253-stack-info-depth 11
19254^done,depth="11"
19255(@value{GDBP})
19256-stack-info-depth 13
19257^done,depth="12"
19258(@value{GDBP})
19259@end smallexample
19260
19261@subheading The @code{-stack-list-arguments} Command
19262@findex -stack-list-arguments
19263
19264@subsubheading Synopsis
19265
19266@smallexample
19267 -stack-list-arguments @var{show-values}
19268 [ @var{low-frame} @var{high-frame} ]
19269@end smallexample
19270
19271Display a list of the arguments for the frames between @var{low-frame}
19272and @var{high-frame} (inclusive). If @var{low-frame} and
19273@var{high-frame} are not provided, list the arguments for the whole call
19274stack.
19275
19276The @var{show-values} argument must have a value of 0 or 1. A value of
192770 means that only the names of the arguments are listed, a value of 1
19278means that both names and values of the arguments are printed.
19279
19280@subsubheading @value{GDBN} Command
19281
19282@value{GDBN} does not have an equivalent command. @code{gdbtk} has a
19283@samp{gdb_get_args} command which partially overlaps with the
19284functionality of @samp{-stack-list-arguments}.
19285
19286@subsubheading Example
19287
19288@smallexample
19289(@value{GDBP})
19290-stack-list-frames
19291^done,
19292stack=[
19293frame=@{level="0",addr="0x00010734",func="callee4",
76ff342d
DJ
19294file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
19295fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8"@},
922fbb7b 19296frame=@{level="1",addr="0x0001076c",func="callee3",
76ff342d
DJ
19297file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
19298fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17"@},
922fbb7b 19299frame=@{level="2",addr="0x0001078c",func="callee2",
76ff342d
DJ
19300file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
19301fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="22"@},
922fbb7b 19302frame=@{level="3",addr="0x000107b4",func="callee1",
76ff342d
DJ
19303file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
19304fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="27"@},
922fbb7b 19305frame=@{level="4",addr="0x000107e0",func="main",
76ff342d
DJ
19306file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
19307fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="32"@}]
922fbb7b
AC
19308(@value{GDBP})
19309-stack-list-arguments 0
19310^done,
19311stack-args=[
19312frame=@{level="0",args=[]@},
19313frame=@{level="1",args=[name="strarg"]@},
19314frame=@{level="2",args=[name="intarg",name="strarg"]@},
19315frame=@{level="3",args=[name="intarg",name="strarg",name="fltarg"]@},
19316frame=@{level="4",args=[]@}]
19317(@value{GDBP})
19318-stack-list-arguments 1
19319^done,
19320stack-args=[
19321frame=@{level="0",args=[]@},
19322frame=@{level="1",
19323 args=[@{name="strarg",value="0x11940 \"A string argument.\""@}]@},
19324frame=@{level="2",args=[
19325@{name="intarg",value="2"@},
19326@{name="strarg",value="0x11940 \"A string argument.\""@}]@},
19327@{frame=@{level="3",args=[
19328@{name="intarg",value="2"@},
19329@{name="strarg",value="0x11940 \"A string argument.\""@},
19330@{name="fltarg",value="3.5"@}]@},
19331frame=@{level="4",args=[]@}]
19332(@value{GDBP})
19333-stack-list-arguments 0 2 2
19334^done,stack-args=[frame=@{level="2",args=[name="intarg",name="strarg"]@}]
19335(@value{GDBP})
19336-stack-list-arguments 1 2 2
19337^done,stack-args=[frame=@{level="2",
19338args=[@{name="intarg",value="2"@},
19339@{name="strarg",value="0x11940 \"A string argument.\""@}]@}]
19340(@value{GDBP})
19341@end smallexample
19342
19343@c @subheading -stack-list-exception-handlers
19344
19345
19346@subheading The @code{-stack-list-frames} Command
19347@findex -stack-list-frames
19348
19349@subsubheading Synopsis
19350
19351@smallexample
19352 -stack-list-frames [ @var{low-frame} @var{high-frame} ]
19353@end smallexample
19354
19355List the frames currently on the stack. For each frame it displays the
19356following info:
19357
19358@table @samp
19359@item @var{level}
19360The frame number, 0 being the topmost frame, i.e. the innermost function.
19361@item @var{addr}
19362The @code{$pc} value for that frame.
19363@item @var{func}
19364Function name.
19365@item @var{file}
19366File name of the source file where the function lives.
19367@item @var{line}
19368Line number corresponding to the @code{$pc}.
19369@end table
19370
19371If invoked without arguments, this command prints a backtrace for the
19372whole stack. If given two integer arguments, it shows the frames whose
19373levels are between the two arguments (inclusive). If the two arguments
19374are equal, it shows the single frame at the corresponding level.
19375
19376@subsubheading @value{GDBN} Command
19377
19378The corresponding @value{GDBN} commands are @samp{backtrace} and @samp{where}.
19379
19380@subsubheading Example
19381
19382Full stack backtrace:
19383
19384@smallexample
19385(@value{GDBP})
19386-stack-list-frames
19387^done,stack=
19388[frame=@{level="0",addr="0x0001076c",func="foo",
76ff342d 19389 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="11"@},
922fbb7b 19390frame=@{level="1",addr="0x000107a4",func="foo",
76ff342d 19391 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
922fbb7b 19392frame=@{level="2",addr="0x000107a4",func="foo",
76ff342d 19393 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
922fbb7b 19394frame=@{level="3",addr="0x000107a4",func="foo",
76ff342d 19395 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
922fbb7b 19396frame=@{level="4",addr="0x000107a4",func="foo",
76ff342d 19397 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
922fbb7b 19398frame=@{level="5",addr="0x000107a4",func="foo",
76ff342d 19399 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
922fbb7b 19400frame=@{level="6",addr="0x000107a4",func="foo",
76ff342d 19401 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
922fbb7b 19402frame=@{level="7",addr="0x000107a4",func="foo",
76ff342d 19403 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
922fbb7b 19404frame=@{level="8",addr="0x000107a4",func="foo",
76ff342d 19405 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
922fbb7b 19406frame=@{level="9",addr="0x000107a4",func="foo",
76ff342d 19407 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
922fbb7b 19408frame=@{level="10",addr="0x000107a4",func="foo",
76ff342d 19409 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
922fbb7b 19410frame=@{level="11",addr="0x00010738",func="main",
76ff342d 19411 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="4"@}]
922fbb7b
AC
19412(@value{GDBP})
19413@end smallexample
19414
19415Show frames between @var{low_frame} and @var{high_frame}:
19416
19417@smallexample
19418(@value{GDBP})
19419-stack-list-frames 3 5
19420^done,stack=
19421[frame=@{level="3",addr="0x000107a4",func="foo",
76ff342d 19422 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
922fbb7b 19423frame=@{level="4",addr="0x000107a4",func="foo",
76ff342d 19424 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@},
922fbb7b 19425frame=@{level="5",addr="0x000107a4",func="foo",
76ff342d 19426 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@}]
922fbb7b
AC
19427(@value{GDBP})
19428@end smallexample
19429
19430Show a single frame:
19431
19432@smallexample
19433(@value{GDBP})
19434-stack-list-frames 3 3
19435^done,stack=
19436[frame=@{level="3",addr="0x000107a4",func="foo",
76ff342d 19437 file="recursive2.c",fullname="/home/foo/bar/devo/myproject/recursive2.c",line="14"@}]
922fbb7b
AC
19438(@value{GDBP})
19439@end smallexample
19440
19441
19442@subheading The @code{-stack-list-locals} Command
19443@findex -stack-list-locals
19444
19445@subsubheading Synopsis
19446
19447@smallexample
19448 -stack-list-locals @var{print-values}
19449@end smallexample
19450
19451Display the local variable names for the current frame. With an
bc8ced35
NR
19452argument of 0 or @code{--no-values}, prints only the names of the variables.
19453With argument of 1 or @code{--all-values}, prints also their values. With
19454argument of 2 or @code{--simple-values}, prints the name, type and value for
19455simple data types and the name and type for arrays, structures and
19456unions. In this last case, the idea is that the user can see the
19457value of simple data types immediately and he can create variable
19458objects for other data types if he wishes to explore their values in
19459more detail.
922fbb7b
AC
19460
19461@subsubheading @value{GDBN} Command
19462
19463@samp{info locals} in @value{GDBN}, @samp{gdb_get_locals} in @code{gdbtk}.
19464
19465@subsubheading Example
19466
19467@smallexample
19468(@value{GDBP})
19469-stack-list-locals 0
19470^done,locals=[name="A",name="B",name="C"]
19471(@value{GDBP})
bc8ced35 19472-stack-list-locals --all-values
922fbb7b 19473^done,locals=[@{name="A",value="1"@},@{name="B",value="2"@},
bc8ced35
NR
19474 @{name="C",value="@{1, 2, 3@}"@}]
19475-stack-list-locals --simple-values
19476^done,locals=[@{name="A",type="int",value="1"@},
19477 @{name="B",type="int",value="2"@},@{name="C",type="int [3]"@}]
922fbb7b
AC
19478(@value{GDBP})
19479@end smallexample
19480
19481
19482@subheading The @code{-stack-select-frame} Command
19483@findex -stack-select-frame
19484
19485@subsubheading Synopsis
19486
19487@smallexample
19488 -stack-select-frame @var{framenum}
19489@end smallexample
19490
19491Change the current frame. Select a different frame @var{framenum} on
19492the stack.
19493
19494@subsubheading @value{GDBN} Command
19495
19496The corresponding @value{GDBN} commands are @samp{frame}, @samp{up},
19497@samp{down}, @samp{select-frame}, @samp{up-silent}, and @samp{down-silent}.
19498
19499@subsubheading Example
19500
19501@smallexample
19502(@value{GDBP})
19503-stack-select-frame 2
19504^done
19505(@value{GDBP})
19506@end smallexample
19507
19508@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19509@node GDB/MI Symbol Query
19510@section @sc{gdb/mi} Symbol Query Commands
19511
19512
19513@subheading The @code{-symbol-info-address} Command
19514@findex -symbol-info-address
19515
19516@subsubheading Synopsis
19517
19518@smallexample
19519 -symbol-info-address @var{symbol}
19520@end smallexample
19521
19522Describe where @var{symbol} is stored.
19523
19524@subsubheading @value{GDBN} Command
19525
19526The corresponding @value{GDBN} command is @samp{info address}.
19527
19528@subsubheading Example
19529N.A.
19530
19531
19532@subheading The @code{-symbol-info-file} Command
19533@findex -symbol-info-file
19534
19535@subsubheading Synopsis
19536
19537@smallexample
19538 -symbol-info-file
19539@end smallexample
19540
19541Show the file for the symbol.
19542
19543@subsubheading @value{GDBN} Command
19544
19545There's no equivalent @value{GDBN} command. @code{gdbtk} has
19546@samp{gdb_find_file}.
19547
19548@subsubheading Example
19549N.A.
19550
19551
19552@subheading The @code{-symbol-info-function} Command
19553@findex -symbol-info-function
19554
19555@subsubheading Synopsis
19556
19557@smallexample
19558 -symbol-info-function
19559@end smallexample
19560
19561Show which function the symbol lives in.
19562
19563@subsubheading @value{GDBN} Command
19564
19565@samp{gdb_get_function} in @code{gdbtk}.
19566
19567@subsubheading Example
19568N.A.
19569
19570
19571@subheading The @code{-symbol-info-line} Command
19572@findex -symbol-info-line
19573
19574@subsubheading Synopsis
19575
19576@smallexample
19577 -symbol-info-line
19578@end smallexample
19579
19580Show the core addresses of the code for a source line.
19581
19582@subsubheading @value{GDBN} Command
19583
71952f4c 19584The corresponding @value{GDBN} command is @samp{info line}.
922fbb7b
AC
19585@code{gdbtk} has the @samp{gdb_get_line} and @samp{gdb_get_file} commands.
19586
19587@subsubheading Example
19588N.A.
19589
19590
19591@subheading The @code{-symbol-info-symbol} Command
19592@findex -symbol-info-symbol
19593
19594@subsubheading Synopsis
19595
19596@smallexample
19597 -symbol-info-symbol @var{addr}
19598@end smallexample
19599
19600Describe what symbol is at location @var{addr}.
19601
19602@subsubheading @value{GDBN} Command
19603
19604The corresponding @value{GDBN} command is @samp{info symbol}.
19605
19606@subsubheading Example
19607N.A.
19608
19609
19610@subheading The @code{-symbol-list-functions} Command
19611@findex -symbol-list-functions
19612
19613@subsubheading Synopsis
19614
19615@smallexample
19616 -symbol-list-functions
19617@end smallexample
19618
19619List the functions in the executable.
19620
19621@subsubheading @value{GDBN} Command
19622
19623@samp{info functions} in @value{GDBN}, @samp{gdb_listfunc} and
19624@samp{gdb_search} in @code{gdbtk}.
19625
19626@subsubheading Example
19627N.A.
19628
19629
32e7087d
JB
19630@subheading The @code{-symbol-list-lines} Command
19631@findex -symbol-list-lines
19632
19633@subsubheading Synopsis
19634
19635@smallexample
19636 -symbol-list-lines @var{filename}
19637@end smallexample
19638
19639Print the list of lines that contain code and their associated program
19640addresses for the given source filename. The entries are sorted in
19641ascending PC order.
19642
19643@subsubheading @value{GDBN} Command
19644
19645There is no corresponding @value{GDBN} command.
19646
19647@subsubheading Example
19648@smallexample
19649(@value{GDBP})
19650-symbol-list-lines basics.c
54ff5908 19651^done,lines=[@{pc="0x08048554",line="7"@},@{pc="0x0804855a",line="8"@}]
32e7087d
JB
19652(@value{GDBP})
19653@end smallexample
19654
19655
922fbb7b
AC
19656@subheading The @code{-symbol-list-types} Command
19657@findex -symbol-list-types
19658
19659@subsubheading Synopsis
19660
19661@smallexample
19662 -symbol-list-types
19663@end smallexample
19664
19665List all the type names.
19666
19667@subsubheading @value{GDBN} Command
19668
19669The corresponding commands are @samp{info types} in @value{GDBN},
19670@samp{gdb_search} in @code{gdbtk}.
19671
19672@subsubheading Example
19673N.A.
19674
19675
19676@subheading The @code{-symbol-list-variables} Command
19677@findex -symbol-list-variables
19678
19679@subsubheading Synopsis
19680
19681@smallexample
19682 -symbol-list-variables
19683@end smallexample
19684
19685List all the global and static variable names.
19686
19687@subsubheading @value{GDBN} Command
19688
19689@samp{info variables} in @value{GDBN}, @samp{gdb_search} in @code{gdbtk}.
19690
19691@subsubheading Example
19692N.A.
19693
19694
19695@subheading The @code{-symbol-locate} Command
19696@findex -symbol-locate
19697
19698@subsubheading Synopsis
19699
19700@smallexample
19701 -symbol-locate
19702@end smallexample
19703
19704@subsubheading @value{GDBN} Command
19705
19706@samp{gdb_loc} in @code{gdbtk}.
19707
19708@subsubheading Example
19709N.A.
19710
19711
19712@subheading The @code{-symbol-type} Command
19713@findex -symbol-type
19714
19715@subsubheading Synopsis
19716
19717@smallexample
19718 -symbol-type @var{variable}
19719@end smallexample
19720
19721Show type of @var{variable}.
19722
19723@subsubheading @value{GDBN} Command
19724
19725The corresponding @value{GDBN} command is @samp{ptype}, @code{gdbtk} has
19726@samp{gdb_obj_variable}.
19727
19728@subsubheading Example
19729N.A.
19730
19731
19732@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19733@node GDB/MI Target Manipulation
19734@section @sc{gdb/mi} Target Manipulation Commands
19735
19736
19737@subheading The @code{-target-attach} Command
19738@findex -target-attach
19739
19740@subsubheading Synopsis
19741
19742@smallexample
19743 -target-attach @var{pid} | @var{file}
19744@end smallexample
19745
19746Attach to a process @var{pid} or a file @var{file} outside of @value{GDBN}.
19747
19748@subsubheading @value{GDBN} command
19749
19750The corresponding @value{GDBN} command is @samp{attach}.
19751
19752@subsubheading Example
19753N.A.
19754
19755
19756@subheading The @code{-target-compare-sections} Command
19757@findex -target-compare-sections
19758
19759@subsubheading Synopsis
19760
19761@smallexample
19762 -target-compare-sections [ @var{section} ]
19763@end smallexample
19764
19765Compare data of section @var{section} on target to the exec file.
19766Without the argument, all sections are compared.
19767
19768@subsubheading @value{GDBN} Command
19769
19770The @value{GDBN} equivalent is @samp{compare-sections}.
19771
19772@subsubheading Example
19773N.A.
19774
19775
19776@subheading The @code{-target-detach} Command
19777@findex -target-detach
19778
19779@subsubheading Synopsis
19780
19781@smallexample
19782 -target-detach
19783@end smallexample
19784
19785Disconnect from the remote target. There's no output.
19786
19787@subsubheading @value{GDBN} command
19788
19789The corresponding @value{GDBN} command is @samp{detach}.
19790
19791@subsubheading Example
19792
19793@smallexample
19794(@value{GDBP})
19795-target-detach
19796^done
19797(@value{GDBP})
19798@end smallexample
19799
19800
07f31aa6
DJ
19801@subheading The @code{-target-disconnect} Command
19802@findex -target-disconnect
19803
19804@subsubheading Synopsis
19805
19806@example
19807 -target-disconnect
19808@end example
19809
19810Disconnect from the remote target. There's no output.
19811
19812@subsubheading @value{GDBN} command
19813
19814The corresponding @value{GDBN} command is @samp{disconnect}.
19815
19816@subsubheading Example
19817
19818@smallexample
19819(@value{GDBP})
19820-target-disconnect
19821^done
19822(@value{GDBP})
19823@end smallexample
19824
19825
922fbb7b
AC
19826@subheading The @code{-target-download} Command
19827@findex -target-download
19828
19829@subsubheading Synopsis
19830
19831@smallexample
19832 -target-download
19833@end smallexample
19834
19835Loads the executable onto the remote target.
19836It prints out an update message every half second, which includes the fields:
19837
19838@table @samp
19839@item section
19840The name of the section.
19841@item section-sent
19842The size of what has been sent so far for that section.
19843@item section-size
19844The size of the section.
19845@item total-sent
19846The total size of what was sent so far (the current and the previous sections).
19847@item total-size
19848The size of the overall executable to download.
19849@end table
19850
19851@noindent
19852Each message is sent as status record (@pxref{GDB/MI Output Syntax, ,
19853@sc{gdb/mi} Output Syntax}).
19854
19855In addition, it prints the name and size of the sections, as they are
19856downloaded. These messages include the following fields:
19857
19858@table @samp
19859@item section
19860The name of the section.
19861@item section-size
19862The size of the section.
19863@item total-size
19864The size of the overall executable to download.
19865@end table
19866
19867@noindent
19868At the end, a summary is printed.
19869
19870@subsubheading @value{GDBN} Command
19871
19872The corresponding @value{GDBN} command is @samp{load}.
19873
19874@subsubheading Example
19875
19876Note: each status message appears on a single line. Here the messages
19877have been broken down so that they can fit onto a page.
19878
19879@smallexample
19880(@value{GDBP})
19881-target-download
19882+download,@{section=".text",section-size="6668",total-size="9880"@}
19883+download,@{section=".text",section-sent="512",section-size="6668",
19884total-sent="512",total-size="9880"@}
19885+download,@{section=".text",section-sent="1024",section-size="6668",
19886total-sent="1024",total-size="9880"@}
19887+download,@{section=".text",section-sent="1536",section-size="6668",
19888total-sent="1536",total-size="9880"@}
19889+download,@{section=".text",section-sent="2048",section-size="6668",
19890total-sent="2048",total-size="9880"@}
19891+download,@{section=".text",section-sent="2560",section-size="6668",
19892total-sent="2560",total-size="9880"@}
19893+download,@{section=".text",section-sent="3072",section-size="6668",
19894total-sent="3072",total-size="9880"@}
19895+download,@{section=".text",section-sent="3584",section-size="6668",
19896total-sent="3584",total-size="9880"@}
19897+download,@{section=".text",section-sent="4096",section-size="6668",
19898total-sent="4096",total-size="9880"@}
19899+download,@{section=".text",section-sent="4608",section-size="6668",
19900total-sent="4608",total-size="9880"@}
19901+download,@{section=".text",section-sent="5120",section-size="6668",
19902total-sent="5120",total-size="9880"@}
19903+download,@{section=".text",section-sent="5632",section-size="6668",
19904total-sent="5632",total-size="9880"@}
19905+download,@{section=".text",section-sent="6144",section-size="6668",
19906total-sent="6144",total-size="9880"@}
19907+download,@{section=".text",section-sent="6656",section-size="6668",
19908total-sent="6656",total-size="9880"@}
19909+download,@{section=".init",section-size="28",total-size="9880"@}
19910+download,@{section=".fini",section-size="28",total-size="9880"@}
19911+download,@{section=".data",section-size="3156",total-size="9880"@}
19912+download,@{section=".data",section-sent="512",section-size="3156",
19913total-sent="7236",total-size="9880"@}
19914+download,@{section=".data",section-sent="1024",section-size="3156",
19915total-sent="7748",total-size="9880"@}
19916+download,@{section=".data",section-sent="1536",section-size="3156",
19917total-sent="8260",total-size="9880"@}
19918+download,@{section=".data",section-sent="2048",section-size="3156",
19919total-sent="8772",total-size="9880"@}
19920+download,@{section=".data",section-sent="2560",section-size="3156",
19921total-sent="9284",total-size="9880"@}
19922+download,@{section=".data",section-sent="3072",section-size="3156",
19923total-sent="9796",total-size="9880"@}
19924^done,address="0x10004",load-size="9880",transfer-rate="6586",
19925write-rate="429"
19926(@value{GDBP})
19927@end smallexample
19928
19929
19930@subheading The @code{-target-exec-status} Command
19931@findex -target-exec-status
19932
19933@subsubheading Synopsis
19934
19935@smallexample
19936 -target-exec-status
19937@end smallexample
19938
19939Provide information on the state of the target (whether it is running or
19940not, for instance).
19941
19942@subsubheading @value{GDBN} Command
19943
19944There's no equivalent @value{GDBN} command.
19945
19946@subsubheading Example
19947N.A.
19948
19949
19950@subheading The @code{-target-list-available-targets} Command
19951@findex -target-list-available-targets
19952
19953@subsubheading Synopsis
19954
19955@smallexample
19956 -target-list-available-targets
19957@end smallexample
19958
19959List the possible targets to connect to.
19960
19961@subsubheading @value{GDBN} Command
19962
19963The corresponding @value{GDBN} command is @samp{help target}.
19964
19965@subsubheading Example
19966N.A.
19967
19968
19969@subheading The @code{-target-list-current-targets} Command
19970@findex -target-list-current-targets
19971
19972@subsubheading Synopsis
19973
19974@smallexample
19975 -target-list-current-targets
19976@end smallexample
19977
19978Describe the current target.
19979
19980@subsubheading @value{GDBN} Command
19981
19982The corresponding information is printed by @samp{info file} (among
19983other things).
19984
19985@subsubheading Example
19986N.A.
19987
19988
19989@subheading The @code{-target-list-parameters} Command
19990@findex -target-list-parameters
19991
19992@subsubheading Synopsis
19993
19994@smallexample
19995 -target-list-parameters
19996@end smallexample
19997
19998@c ????
19999
20000@subsubheading @value{GDBN} Command
20001
20002No equivalent.
20003
20004@subsubheading Example
20005N.A.
20006
20007
20008@subheading The @code{-target-select} Command
20009@findex -target-select
20010
20011@subsubheading Synopsis
20012
20013@smallexample
20014 -target-select @var{type} @var{parameters @dots{}}
20015@end smallexample
20016
20017Connect @value{GDBN} to the remote target. This command takes two args:
20018
20019@table @samp
20020@item @var{type}
20021The type of target, for instance @samp{async}, @samp{remote}, etc.
20022@item @var{parameters}
20023Device names, host names and the like. @xref{Target Commands, ,
20024Commands for managing targets}, for more details.
20025@end table
20026
20027The output is a connection notification, followed by the address at
20028which the target program is, in the following form:
20029
20030@smallexample
20031^connected,addr="@var{address}",func="@var{function name}",
20032 args=[@var{arg list}]
20033@end smallexample
20034
20035@subsubheading @value{GDBN} Command
20036
20037The corresponding @value{GDBN} command is @samp{target}.
20038
20039@subsubheading Example
20040
20041@smallexample
20042(@value{GDBP})
20043-target-select async /dev/ttya
20044^connected,addr="0xfe00a300",func="??",args=[]
20045(@value{GDBP})
20046@end smallexample
20047
20048@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20049@node GDB/MI Thread Commands
20050@section @sc{gdb/mi} Thread Commands
20051
20052
20053@subheading The @code{-thread-info} Command
20054@findex -thread-info
20055
20056@subsubheading Synopsis
20057
20058@smallexample
20059 -thread-info
20060@end smallexample
20061
20062@subsubheading @value{GDBN} command
20063
20064No equivalent.
20065
20066@subsubheading Example
20067N.A.
20068
20069
20070@subheading The @code{-thread-list-all-threads} Command
20071@findex -thread-list-all-threads
20072
20073@subsubheading Synopsis
20074
20075@smallexample
20076 -thread-list-all-threads
20077@end smallexample
20078
20079@subsubheading @value{GDBN} Command
20080
20081The equivalent @value{GDBN} command is @samp{info threads}.
20082
20083@subsubheading Example
20084N.A.
20085
20086
20087@subheading The @code{-thread-list-ids} Command
20088@findex -thread-list-ids
20089
20090@subsubheading Synopsis
20091
20092@smallexample
20093 -thread-list-ids
20094@end smallexample
20095
20096Produces a list of the currently known @value{GDBN} thread ids. At the
20097end of the list it also prints the total number of such threads.
20098
20099@subsubheading @value{GDBN} Command
20100
20101Part of @samp{info threads} supplies the same information.
20102
20103@subsubheading Example
20104
20105No threads present, besides the main process:
20106
20107@smallexample
20108(@value{GDBP})
20109-thread-list-ids
20110^done,thread-ids=@{@},number-of-threads="0"
20111(@value{GDBP})
20112@end smallexample
20113
20114
20115Several threads:
20116
20117@smallexample
20118(@value{GDBP})
20119-thread-list-ids
20120^done,thread-ids=@{thread-id="3",thread-id="2",thread-id="1"@},
20121number-of-threads="3"
20122(@value{GDBP})
20123@end smallexample
20124
20125
20126@subheading The @code{-thread-select} Command
20127@findex -thread-select
20128
20129@subsubheading Synopsis
20130
20131@smallexample
20132 -thread-select @var{threadnum}
20133@end smallexample
20134
20135Make @var{threadnum} the current thread. It prints the number of the new
20136current thread, and the topmost frame for that thread.
20137
20138@subsubheading @value{GDBN} Command
20139
20140The corresponding @value{GDBN} command is @samp{thread}.
20141
20142@subsubheading Example
20143
20144@smallexample
20145(@value{GDBP})
20146-exec-next
20147^running
20148(@value{GDBP})
20149*stopped,reason="end-stepping-range",thread-id="2",line="187",
20150file="../../../devo/gdb/testsuite/gdb.threads/linux-dp.c"
20151(@value{GDBP})
20152-thread-list-ids
20153^done,
20154thread-ids=@{thread-id="3",thread-id="2",thread-id="1"@},
20155number-of-threads="3"
20156(@value{GDBP})
20157-thread-select 3
20158^done,new-thread-id="3",
20159frame=@{level="0",func="vprintf",
20160args=[@{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""@},
20161@{name="arg",value="0x2"@}],file="vprintf.c",line="31"@}
20162(@value{GDBP})
20163@end smallexample
20164
20165@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20166@node GDB/MI Tracepoint Commands
20167@section @sc{gdb/mi} Tracepoint Commands
20168
20169The tracepoint commands are not yet implemented.
20170
20171@c @subheading -trace-actions
20172
20173@c @subheading -trace-delete
20174
20175@c @subheading -trace-disable
20176
20177@c @subheading -trace-dump
20178
20179@c @subheading -trace-enable
20180
20181@c @subheading -trace-exists
20182
20183@c @subheading -trace-find
20184
20185@c @subheading -trace-frame-number
20186
20187@c @subheading -trace-info
20188
20189@c @subheading -trace-insert
20190
20191@c @subheading -trace-list
20192
20193@c @subheading -trace-pass-count
20194
20195@c @subheading -trace-save
20196
20197@c @subheading -trace-start
20198
20199@c @subheading -trace-stop
20200
20201
20202@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20203@node GDB/MI Variable Objects
20204@section @sc{gdb/mi} Variable Objects
20205
20206
20207@subheading Motivation for Variable Objects in @sc{gdb/mi}
20208
20209For the implementation of a variable debugger window (locals, watched
20210expressions, etc.), we are proposing the adaptation of the existing code
20211used by @code{Insight}.
20212
20213The two main reasons for that are:
20214
20215@enumerate 1
20216@item
20217It has been proven in practice (it is already on its second generation).
20218
20219@item
20220It will shorten development time (needless to say how important it is
20221now).
20222@end enumerate
20223
20224The original interface was designed to be used by Tcl code, so it was
20225slightly changed so it could be used through @sc{gdb/mi}. This section
20226describes the @sc{gdb/mi} operations that will be available and gives some
20227hints about their use.
20228
20229@emph{Note}: In addition to the set of operations described here, we
20230expect the @sc{gui} implementation of a variable window to require, at
20231least, the following operations:
20232
20233@itemize @bullet
20234@item @code{-gdb-show} @code{output-radix}
20235@item @code{-stack-list-arguments}
20236@item @code{-stack-list-locals}
20237@item @code{-stack-select-frame}
20238@end itemize
20239
20240@subheading Introduction to Variable Objects in @sc{gdb/mi}
20241
20242@cindex variable objects in @sc{gdb/mi}
20243The basic idea behind variable objects is the creation of a named object
20244to represent a variable, an expression, a memory location or even a CPU
20245register. For each object created, a set of operations is available for
20246examining or changing its properties.
20247
20248Furthermore, complex data types, such as C structures, are represented
20249in a tree format. For instance, the @code{struct} type variable is the
20250root and the children will represent the struct members. If a child
20251is itself of a complex type, it will also have children of its own.
20252Appropriate language differences are handled for C, C@t{++} and Java.
20253
20254When returning the actual values of the objects, this facility allows
20255for the individual selection of the display format used in the result
20256creation. It can be chosen among: binary, decimal, hexadecimal, octal
20257and natural. Natural refers to a default format automatically
20258chosen based on the variable type (like decimal for an @code{int}, hex
20259for pointers, etc.).
20260
20261The following is the complete set of @sc{gdb/mi} operations defined to
20262access this functionality:
20263
20264@multitable @columnfractions .4 .6
20265@item @strong{Operation}
20266@tab @strong{Description}
20267
20268@item @code{-var-create}
20269@tab create a variable object
20270@item @code{-var-delete}
20271@tab delete the variable object and its children
20272@item @code{-var-set-format}
20273@tab set the display format of this variable
20274@item @code{-var-show-format}
20275@tab show the display format of this variable
20276@item @code{-var-info-num-children}
20277@tab tells how many children this object has
20278@item @code{-var-list-children}
20279@tab return a list of the object's children
20280@item @code{-var-info-type}
20281@tab show the type of this variable object
20282@item @code{-var-info-expression}
20283@tab print what this variable object represents
20284@item @code{-var-show-attributes}
20285@tab is this variable editable? does it exist here?
20286@item @code{-var-evaluate-expression}
20287@tab get the value of this variable
20288@item @code{-var-assign}
20289@tab set the value of this variable
20290@item @code{-var-update}
20291@tab update the variable and its children
20292@end multitable
20293
20294In the next subsection we describe each operation in detail and suggest
20295how it can be used.
20296
20297@subheading Description And Use of Operations on Variable Objects
20298
20299@subheading The @code{-var-create} Command
20300@findex -var-create
20301
20302@subsubheading Synopsis
20303
20304@smallexample
20305 -var-create @{@var{name} | "-"@}
20306 @{@var{frame-addr} | "*"@} @var{expression}
20307@end smallexample
20308
20309This operation creates a variable object, which allows the monitoring of
20310a variable, the result of an expression, a memory cell or a CPU
20311register.
20312
20313The @var{name} parameter is the string by which the object can be
20314referenced. It must be unique. If @samp{-} is specified, the varobj
20315system will generate a string ``varNNNNNN'' automatically. It will be
20316unique provided that one does not specify @var{name} on that format.
20317The command fails if a duplicate name is found.
20318
20319The frame under which the expression should be evaluated can be
20320specified by @var{frame-addr}. A @samp{*} indicates that the current
20321frame should be used.
20322
20323@var{expression} is any expression valid on the current language set (must not
20324begin with a @samp{*}), or one of the following:
20325
20326@itemize @bullet
20327@item
20328@samp{*@var{addr}}, where @var{addr} is the address of a memory cell
20329
20330@item
20331@samp{*@var{addr}-@var{addr}} --- a memory address range (TBD)
20332
20333@item
20334@samp{$@var{regname}} --- a CPU register name
20335@end itemize
20336
20337@subsubheading Result
20338
20339This operation returns the name, number of children and the type of the
20340object created. Type is returned as a string as the ones generated by
20341the @value{GDBN} CLI:
20342
20343@smallexample
20344 name="@var{name}",numchild="N",type="@var{type}"
20345@end smallexample
20346
20347
20348@subheading The @code{-var-delete} Command
20349@findex -var-delete
20350
20351@subsubheading Synopsis
20352
20353@smallexample
20354 -var-delete @var{name}
20355@end smallexample
20356
20357Deletes a previously created variable object and all of its children.
20358
20359Returns an error if the object @var{name} is not found.
20360
20361
20362@subheading The @code{-var-set-format} Command
20363@findex -var-set-format
20364
20365@subsubheading Synopsis
20366
20367@smallexample
20368 -var-set-format @var{name} @var{format-spec}
20369@end smallexample
20370
20371Sets the output format for the value of the object @var{name} to be
20372@var{format-spec}.
20373
20374The syntax for the @var{format-spec} is as follows:
20375
20376@smallexample
20377 @var{format-spec} @expansion{}
20378 @{binary | decimal | hexadecimal | octal | natural@}
20379@end smallexample
20380
20381
20382@subheading The @code{-var-show-format} Command
20383@findex -var-show-format
20384
20385@subsubheading Synopsis
20386
20387@smallexample
20388 -var-show-format @var{name}
20389@end smallexample
20390
20391Returns the format used to display the value of the object @var{name}.
20392
20393@smallexample
20394 @var{format} @expansion{}
20395 @var{format-spec}
20396@end smallexample
20397
20398
20399@subheading The @code{-var-info-num-children} Command
20400@findex -var-info-num-children
20401
20402@subsubheading Synopsis
20403
20404@smallexample
20405 -var-info-num-children @var{name}
20406@end smallexample
20407
20408Returns the number of children of a variable object @var{name}:
20409
20410@smallexample
20411 numchild=@var{n}
20412@end smallexample
20413
20414
20415@subheading The @code{-var-list-children} Command
20416@findex -var-list-children
20417
20418@subsubheading Synopsis
20419
20420@smallexample
bc8ced35 20421 -var-list-children [@var{print-values}] @var{name}
922fbb7b
AC
20422@end smallexample
20423
bc8ced35
NR
20424Returns a list of the children of the specified variable object. With
20425just the variable object name as an argument or with an optional
20426preceding argument of 0 or @code{--no-values}, prints only the names of the
20427variables. With an optional preceding argument of 1 or @code{--all-values},
20428also prints their values.
20429
20430@subsubheading Example
922fbb7b
AC
20431
20432@smallexample
bc8ced35
NR
20433(@value{GDBP})
20434 -var-list-children n
922fbb7b
AC
20435 numchild=@var{n},children=[@{name=@var{name},
20436 numchild=@var{n},type=@var{type}@},@r{(repeats N times)}]
bc8ced35
NR
20437(@value{GDBP})
20438 -var-list-children --all-values n
20439 numchild=@var{n},children=[@{name=@var{name},
20440 numchild=@var{n},value=@var{value},type=@var{type}@},@r{(repeats N times)}]
922fbb7b
AC
20441@end smallexample
20442
20443
20444@subheading The @code{-var-info-type} Command
20445@findex -var-info-type
20446
20447@subsubheading Synopsis
20448
20449@smallexample
20450 -var-info-type @var{name}
20451@end smallexample
20452
20453Returns the type of the specified variable @var{name}. The type is
20454returned as a string in the same format as it is output by the
20455@value{GDBN} CLI:
20456
20457@smallexample
20458 type=@var{typename}
20459@end smallexample
20460
20461
20462@subheading The @code{-var-info-expression} Command
20463@findex -var-info-expression
20464
20465@subsubheading Synopsis
20466
20467@smallexample
20468 -var-info-expression @var{name}
20469@end smallexample
20470
20471Returns what is represented by the variable object @var{name}:
20472
20473@smallexample
20474 lang=@var{lang-spec},exp=@var{expression}
20475@end smallexample
20476
20477@noindent
20478where @var{lang-spec} is @code{@{"C" | "C++" | "Java"@}}.
20479
20480@subheading The @code{-var-show-attributes} Command
20481@findex -var-show-attributes
20482
20483@subsubheading Synopsis
20484
20485@smallexample
20486 -var-show-attributes @var{name}
20487@end smallexample
20488
20489List attributes of the specified variable object @var{name}:
20490
20491@smallexample
20492 status=@var{attr} [ ( ,@var{attr} )* ]
20493@end smallexample
20494
20495@noindent
20496where @var{attr} is @code{@{ @{ editable | noneditable @} | TBD @}}.
20497
20498@subheading The @code{-var-evaluate-expression} Command
20499@findex -var-evaluate-expression
20500
20501@subsubheading Synopsis
20502
20503@smallexample
20504 -var-evaluate-expression @var{name}
20505@end smallexample
20506
20507Evaluates the expression that is represented by the specified variable
20508object and returns its value as a string in the current format specified
20509for the object:
20510
20511@smallexample
20512 value=@var{value}
20513@end smallexample
20514
20515Note that one must invoke @code{-var-list-children} for a variable
20516before the value of a child variable can be evaluated.
20517
20518@subheading The @code{-var-assign} Command
20519@findex -var-assign
20520
20521@subsubheading Synopsis
20522
20523@smallexample
20524 -var-assign @var{name} @var{expression}
20525@end smallexample
20526
20527Assigns the value of @var{expression} to the variable object specified
20528by @var{name}. The object must be @samp{editable}. If the variable's
b383017d 20529value is altered by the assign, the variable will show up in any
922fbb7b
AC
20530subsequent @code{-var-update} list.
20531
20532@subsubheading Example
20533
20534@smallexample
20535(@value{GDBP})
20536-var-assign var1 3
20537^done,value="3"
20538(@value{GDBP})
20539-var-update *
20540^done,changelist=[@{name="var1",in_scope="true",type_changed="false"@}]
20541(@value{GDBP})
20542@end smallexample
20543
20544@subheading The @code{-var-update} Command
20545@findex -var-update
20546
20547@subsubheading Synopsis
20548
20549@smallexample
20550 -var-update @{@var{name} | "*"@}
20551@end smallexample
20552
20553Update the value of the variable object @var{name} by evaluating its
20554expression after fetching all the new values from memory or registers.
20555A @samp{*} causes all existing variable objects to be updated.
20556
20557
20558@node Annotations
20559@chapter @value{GDBN} Annotations
20560
086432e2
AC
20561This chapter describes annotations in @value{GDBN}. Annotations were
20562designed to interface @value{GDBN} to graphical user interfaces or other
20563similar programs which want to interact with @value{GDBN} at a
922fbb7b
AC
20564relatively high level.
20565
086432e2
AC
20566The annotation mechanism has largely been superseeded by @sc{gdb/mi}
20567(@pxref{GDB/MI}).
20568
922fbb7b
AC
20569@ignore
20570This is Edition @value{EDITION}, @value{DATE}.
20571@end ignore
20572
20573@menu
20574* Annotations Overview:: What annotations are; the general syntax.
20575* Server Prefix:: Issuing a command without affecting user state.
922fbb7b
AC
20576* Prompting:: Annotations marking @value{GDBN}'s need for input.
20577* Errors:: Annotations for error messages.
922fbb7b
AC
20578* Invalidation:: Some annotations describe things now invalid.
20579* Annotations for Running::
20580 Whether the program is running, how it stopped, etc.
20581* Source Annotations:: Annotations describing source code.
922fbb7b
AC
20582@end menu
20583
20584@node Annotations Overview
20585@section What is an Annotation?
20586@cindex annotations
20587
922fbb7b
AC
20588Annotations start with a newline character, two @samp{control-z}
20589characters, and the name of the annotation. If there is no additional
20590information associated with this annotation, the name of the annotation
20591is followed immediately by a newline. If there is additional
20592information, the name of the annotation is followed by a space, the
20593additional information, and a newline. The additional information
20594cannot contain newline characters.
20595
20596Any output not beginning with a newline and two @samp{control-z}
20597characters denotes literal output from @value{GDBN}. Currently there is
20598no need for @value{GDBN} to output a newline followed by two
20599@samp{control-z} characters, but if there was such a need, the
20600annotations could be extended with an @samp{escape} annotation which
20601means those three characters as output.
20602
086432e2
AC
20603The annotation @var{level}, which is specified using the
20604@option{--annotate} command line option (@pxref{Mode Options}), controls
20605how much information @value{GDBN} prints together with its prompt,
20606values of expressions, source lines, and other types of output. Level 0
20607is for no anntations, level 1 is for use when @value{GDBN} is run as a
20608subprocess of @sc{gnu} Emacs, level 3 is the maximum annotation suitable
20609for programs that control @value{GDBN}, and level 2 annotations have
20610been made obsolete (@pxref{Limitations, , Limitations of the Annotation
09d4efe1
EZ
20611Interface, annotate, GDB's Obsolete Annotations}).
20612
20613@table @code
20614@kindex set annotate
20615@item set annotate @var{level}
e09f16f9 20616The @value{GDBN} command @code{set annotate} sets the level of
09d4efe1 20617annotations to the specified @var{level}.
9c16f35a
EZ
20618
20619@item show annotate
20620@kindex show annotate
20621Show the current annotation level.
09d4efe1
EZ
20622@end table
20623
20624This chapter describes level 3 annotations.
086432e2 20625
922fbb7b
AC
20626A simple example of starting up @value{GDBN} with annotations is:
20627
20628@smallexample
086432e2
AC
20629$ @kbd{gdb --annotate=3}
20630GNU gdb 6.0
20631Copyright 2003 Free Software Foundation, Inc.
922fbb7b
AC
20632GDB is free software, covered by the GNU General Public License,
20633and you are welcome to change it and/or distribute copies of it
20634under certain conditions.
20635Type "show copying" to see the conditions.
20636There is absolutely no warranty for GDB. Type "show warranty"
20637for details.
086432e2 20638This GDB was configured as "i386-pc-linux-gnu"
922fbb7b
AC
20639
20640^Z^Zpre-prompt
f7dc1244 20641(@value{GDBP})
922fbb7b 20642^Z^Zprompt
086432e2 20643@kbd{quit}
922fbb7b
AC
20644
20645^Z^Zpost-prompt
b383017d 20646$
922fbb7b
AC
20647@end smallexample
20648
20649Here @samp{quit} is input to @value{GDBN}; the rest is output from
20650@value{GDBN}. The three lines beginning @samp{^Z^Z} (where @samp{^Z}
20651denotes a @samp{control-z} character) are annotations; the rest is
20652output from @value{GDBN}.
20653
20654@node Server Prefix
20655@section The Server Prefix
20656@cindex server prefix for annotations
20657
20658To issue a command to @value{GDBN} without affecting certain aspects of
20659the state which is seen by users, prefix it with @samp{server }. This
20660means that this command will not affect the command history, nor will it
20661affect @value{GDBN}'s notion of which command to repeat if @key{RET} is
20662pressed on a line by itself.
20663
20664The server prefix does not affect the recording of values into the value
20665history; to print a value without recording it into the value history,
20666use the @code{output} command instead of the @code{print} command.
20667
922fbb7b
AC
20668@node Prompting
20669@section Annotation for @value{GDBN} Input
20670
20671@cindex annotations for prompts
20672When @value{GDBN} prompts for input, it annotates this fact so it is possible
20673to know when to send output, when the output from a given command is
20674over, etc.
20675
20676Different kinds of input each have a different @dfn{input type}. Each
20677input type has three annotations: a @code{pre-} annotation, which
20678denotes the beginning of any prompt which is being output, a plain
20679annotation, which denotes the end of the prompt, and then a @code{post-}
20680annotation which denotes the end of any echo which may (or may not) be
20681associated with the input. For example, the @code{prompt} input type
20682features the following annotations:
20683
20684@smallexample
20685^Z^Zpre-prompt
20686^Z^Zprompt
20687^Z^Zpost-prompt
20688@end smallexample
20689
20690The input types are
20691
20692@table @code
20693@findex pre-prompt
20694@findex prompt
20695@findex post-prompt
20696@item prompt
20697When @value{GDBN} is prompting for a command (the main @value{GDBN} prompt).
20698
20699@findex pre-commands
20700@findex commands
20701@findex post-commands
20702@item commands
20703When @value{GDBN} prompts for a set of commands, like in the @code{commands}
20704command. The annotations are repeated for each command which is input.
20705
20706@findex pre-overload-choice
20707@findex overload-choice
20708@findex post-overload-choice
20709@item overload-choice
20710When @value{GDBN} wants the user to select between various overloaded functions.
20711
20712@findex pre-query
20713@findex query
20714@findex post-query
20715@item query
20716When @value{GDBN} wants the user to confirm a potentially dangerous operation.
20717
20718@findex pre-prompt-for-continue
20719@findex prompt-for-continue
20720@findex post-prompt-for-continue
20721@item prompt-for-continue
20722When @value{GDBN} is asking the user to press return to continue. Note: Don't
20723expect this to work well; instead use @code{set height 0} to disable
20724prompting. This is because the counting of lines is buggy in the
20725presence of annotations.
20726@end table
20727
20728@node Errors
20729@section Errors
20730@cindex annotations for errors, warnings and interrupts
20731
20732@findex quit
20733@smallexample
20734^Z^Zquit
20735@end smallexample
20736
20737This annotation occurs right before @value{GDBN} responds to an interrupt.
20738
20739@findex error
20740@smallexample
20741^Z^Zerror
20742@end smallexample
20743
20744This annotation occurs right before @value{GDBN} responds to an error.
20745
20746Quit and error annotations indicate that any annotations which @value{GDBN} was
20747in the middle of may end abruptly. For example, if a
20748@code{value-history-begin} annotation is followed by a @code{error}, one
20749cannot expect to receive the matching @code{value-history-end}. One
20750cannot expect not to receive it either, however; an error annotation
20751does not necessarily mean that @value{GDBN} is immediately returning all the way
20752to the top level.
20753
20754@findex error-begin
20755A quit or error annotation may be preceded by
20756
20757@smallexample
20758^Z^Zerror-begin
20759@end smallexample
20760
20761Any output between that and the quit or error annotation is the error
20762message.
20763
20764Warning messages are not yet annotated.
20765@c If we want to change that, need to fix warning(), type_error(),
20766@c range_error(), and possibly other places.
20767
922fbb7b
AC
20768@node Invalidation
20769@section Invalidation Notices
20770
20771@cindex annotations for invalidation messages
20772The following annotations say that certain pieces of state may have
20773changed.
20774
20775@table @code
20776@findex frames-invalid
20777@item ^Z^Zframes-invalid
20778
20779The frames (for example, output from the @code{backtrace} command) may
20780have changed.
20781
20782@findex breakpoints-invalid
20783@item ^Z^Zbreakpoints-invalid
20784
20785The breakpoints may have changed. For example, the user just added or
20786deleted a breakpoint.
20787@end table
20788
20789@node Annotations for Running
20790@section Running the Program
20791@cindex annotations for running programs
20792
20793@findex starting
20794@findex stopping
20795When the program starts executing due to a @value{GDBN} command such as
b383017d 20796@code{step} or @code{continue},
922fbb7b
AC
20797
20798@smallexample
20799^Z^Zstarting
20800@end smallexample
20801
b383017d 20802is output. When the program stops,
922fbb7b
AC
20803
20804@smallexample
20805^Z^Zstopped
20806@end smallexample
20807
20808is output. Before the @code{stopped} annotation, a variety of
20809annotations describe how the program stopped.
20810
20811@table @code
20812@findex exited
20813@item ^Z^Zexited @var{exit-status}
20814The program exited, and @var{exit-status} is the exit status (zero for
20815successful exit, otherwise nonzero).
20816
20817@findex signalled
20818@findex signal-name
20819@findex signal-name-end
20820@findex signal-string
20821@findex signal-string-end
20822@item ^Z^Zsignalled
20823The program exited with a signal. After the @code{^Z^Zsignalled}, the
20824annotation continues:
20825
20826@smallexample
20827@var{intro-text}
20828^Z^Zsignal-name
20829@var{name}
20830^Z^Zsignal-name-end
20831@var{middle-text}
20832^Z^Zsignal-string
20833@var{string}
20834^Z^Zsignal-string-end
20835@var{end-text}
20836@end smallexample
20837
20838@noindent
20839where @var{name} is the name of the signal, such as @code{SIGILL} or
20840@code{SIGSEGV}, and @var{string} is the explanation of the signal, such
20841as @code{Illegal Instruction} or @code{Segmentation fault}.
20842@var{intro-text}, @var{middle-text}, and @var{end-text} are for the
20843user's benefit and have no particular format.
20844
20845@findex signal
20846@item ^Z^Zsignal
20847The syntax of this annotation is just like @code{signalled}, but @value{GDBN} is
20848just saying that the program received the signal, not that it was
20849terminated with it.
20850
20851@findex breakpoint
20852@item ^Z^Zbreakpoint @var{number}
20853The program hit breakpoint number @var{number}.
20854
20855@findex watchpoint
20856@item ^Z^Zwatchpoint @var{number}
20857The program hit watchpoint number @var{number}.
20858@end table
20859
20860@node Source Annotations
20861@section Displaying Source
20862@cindex annotations for source display
20863
20864@findex source
20865The following annotation is used instead of displaying source code:
20866
20867@smallexample
20868^Z^Zsource @var{filename}:@var{line}:@var{character}:@var{middle}:@var{addr}
20869@end smallexample
20870
20871where @var{filename} is an absolute file name indicating which source
20872file, @var{line} is the line number within that file (where 1 is the
20873first line in the file), @var{character} is the character position
20874within the file (where 0 is the first character in the file) (for most
20875debug formats this will necessarily point to the beginning of a line),
20876@var{middle} is @samp{middle} if @var{addr} is in the middle of the
20877line, or @samp{beg} if @var{addr} is at the beginning of the line, and
20878@var{addr} is the address in the target program associated with the
20879source which is being displayed. @var{addr} is in the form @samp{0x}
20880followed by one or more lowercase hex digits (note that this does not
20881depend on the language).
20882
8e04817f
AC
20883@node GDB Bugs
20884@chapter Reporting Bugs in @value{GDBN}
20885@cindex bugs in @value{GDBN}
20886@cindex reporting bugs in @value{GDBN}
c906108c 20887
8e04817f 20888Your bug reports play an essential role in making @value{GDBN} reliable.
c906108c 20889
8e04817f
AC
20890Reporting a bug may help you by bringing a solution to your problem, or it
20891may not. But in any case the principal function of a bug report is to help
20892the entire community by making the next version of @value{GDBN} work better. Bug
20893reports are your contribution to the maintenance of @value{GDBN}.
c906108c 20894
8e04817f
AC
20895In order for a bug report to serve its purpose, you must include the
20896information that enables us to fix the bug.
c4555f82
SC
20897
20898@menu
8e04817f
AC
20899* Bug Criteria:: Have you found a bug?
20900* Bug Reporting:: How to report bugs
c4555f82
SC
20901@end menu
20902
8e04817f
AC
20903@node Bug Criteria
20904@section Have you found a bug?
20905@cindex bug criteria
c4555f82 20906
8e04817f 20907If you are not sure whether you have found a bug, here are some guidelines:
c4555f82
SC
20908
20909@itemize @bullet
8e04817f
AC
20910@cindex fatal signal
20911@cindex debugger crash
20912@cindex crash of debugger
c4555f82 20913@item
8e04817f
AC
20914If the debugger gets a fatal signal, for any input whatever, that is a
20915@value{GDBN} bug. Reliable debuggers never crash.
20916
20917@cindex error on valid input
20918@item
20919If @value{GDBN} produces an error message for valid input, that is a
20920bug. (Note that if you're cross debugging, the problem may also be
20921somewhere in the connection to the target.)
c4555f82 20922
8e04817f 20923@cindex invalid input
c4555f82 20924@item
8e04817f
AC
20925If @value{GDBN} does not produce an error message for invalid input,
20926that is a bug. However, you should note that your idea of
20927``invalid input'' might be our idea of ``an extension'' or ``support
20928for traditional practice''.
20929
20930@item
20931If you are an experienced user of debugging tools, your suggestions
20932for improvement of @value{GDBN} are welcome in any case.
c4555f82
SC
20933@end itemize
20934
8e04817f
AC
20935@node Bug Reporting
20936@section How to report bugs
20937@cindex bug reports
20938@cindex @value{GDBN} bugs, reporting
20939
20940A number of companies and individuals offer support for @sc{gnu} products.
20941If you obtained @value{GDBN} from a support organization, we recommend you
20942contact that organization first.
20943
20944You can find contact information for many support companies and
20945individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
20946distribution.
20947@c should add a web page ref...
20948
129188f6
AC
20949In any event, we also recommend that you submit bug reports for
20950@value{GDBN}. The prefered method is to submit them directly using
20951@uref{http://www.gnu.org/software/gdb/bugs/, @value{GDBN}'s Bugs web
20952page}. Alternatively, the @email{bug-gdb@@gnu.org, e-mail gateway} can
20953be used.
8e04817f
AC
20954
20955@strong{Do not send bug reports to @samp{info-gdb}, or to
20956@samp{help-gdb}, or to any newsgroups.} Most users of @value{GDBN} do
20957not want to receive bug reports. Those that do have arranged to receive
20958@samp{bug-gdb}.
20959
20960The mailing list @samp{bug-gdb} has a newsgroup @samp{gnu.gdb.bug} which
20961serves as a repeater. The mailing list and the newsgroup carry exactly
20962the same messages. Often people think of posting bug reports to the
20963newsgroup instead of mailing them. This appears to work, but it has one
20964problem which can be crucial: a newsgroup posting often lacks a mail
20965path back to the sender. Thus, if we need to ask for more information,
20966we may be unable to reach you. For this reason, it is better to send
20967bug reports to the mailing list.
c4555f82 20968
8e04817f
AC
20969The fundamental principle of reporting bugs usefully is this:
20970@strong{report all the facts}. If you are not sure whether to state a
20971fact or leave it out, state it!
c4555f82 20972
8e04817f
AC
20973Often people omit facts because they think they know what causes the
20974problem and assume that some details do not matter. Thus, you might
20975assume that the name of the variable you use in an example does not matter.
20976Well, probably it does not, but one cannot be sure. Perhaps the bug is a
20977stray memory reference which happens to fetch from the location where that
20978name is stored in memory; perhaps, if the name were different, the contents
20979of that location would fool the debugger into doing the right thing despite
20980the bug. Play it safe and give a specific, complete example. That is the
20981easiest thing for you to do, and the most helpful.
c4555f82 20982
8e04817f
AC
20983Keep in mind that the purpose of a bug report is to enable us to fix the
20984bug. It may be that the bug has been reported previously, but neither
20985you nor we can know that unless your bug report is complete and
20986self-contained.
c4555f82 20987
8e04817f
AC
20988Sometimes people give a few sketchy facts and ask, ``Does this ring a
20989bell?'' Those bug reports are useless, and we urge everyone to
20990@emph{refuse to respond to them} except to chide the sender to report
20991bugs properly.
20992
20993To enable us to fix the bug, you should include all these things:
c4555f82
SC
20994
20995@itemize @bullet
20996@item
8e04817f
AC
20997The version of @value{GDBN}. @value{GDBN} announces it if you start
20998with no arguments; you can also print it at any time using @code{show
20999version}.
c4555f82 21000
8e04817f
AC
21001Without this, we will not know whether there is any point in looking for
21002the bug in the current version of @value{GDBN}.
c4555f82
SC
21003
21004@item
8e04817f
AC
21005The type of machine you are using, and the operating system name and
21006version number.
c4555f82
SC
21007
21008@item
8e04817f
AC
21009What compiler (and its version) was used to compile @value{GDBN}---e.g.
21010``@value{GCC}--2.8.1''.
c4555f82
SC
21011
21012@item
8e04817f
AC
21013What compiler (and its version) was used to compile the program you are
21014debugging---e.g. ``@value{GCC}--2.8.1'', or ``HP92453-01 A.10.32.03 HP
21015C Compiler''. For GCC, you can say @code{gcc --version} to get this
21016information; for other compilers, see the documentation for those
21017compilers.
c4555f82 21018
8e04817f
AC
21019@item
21020The command arguments you gave the compiler to compile your example and
21021observe the bug. For example, did you use @samp{-O}? To guarantee
21022you will not omit something important, list them all. A copy of the
21023Makefile (or the output from make) is sufficient.
c4555f82 21024
8e04817f
AC
21025If we were to try to guess the arguments, we would probably guess wrong
21026and then we might not encounter the bug.
c4555f82 21027
8e04817f
AC
21028@item
21029A complete input script, and all necessary source files, that will
21030reproduce the bug.
c4555f82 21031
8e04817f
AC
21032@item
21033A description of what behavior you observe that you believe is
21034incorrect. For example, ``It gets a fatal signal.''
c4555f82 21035
8e04817f
AC
21036Of course, if the bug is that @value{GDBN} gets a fatal signal, then we
21037will certainly notice it. But if the bug is incorrect output, we might
21038not notice unless it is glaringly wrong. You might as well not give us
21039a chance to make a mistake.
c4555f82 21040
8e04817f
AC
21041Even if the problem you experience is a fatal signal, you should still
21042say so explicitly. Suppose something strange is going on, such as, your
21043copy of @value{GDBN} is out of synch, or you have encountered a bug in
21044the C library on your system. (This has happened!) Your copy might
21045crash and ours would not. If you told us to expect a crash, then when
21046ours fails to crash, we would know that the bug was not happening for
21047us. If you had not told us to expect a crash, then we would not be able
21048to draw any conclusion from our observations.
c4555f82 21049
e0c07bf0
MC
21050@pindex script
21051@cindex recording a session script
21052To collect all this information, you can use a session recording program
21053such as @command{script}, which is available on many Unix systems.
21054Just run your @value{GDBN} session inside @command{script} and then
21055include the @file{typescript} file with your bug report.
21056
21057Another way to record a @value{GDBN} session is to run @value{GDBN}
21058inside Emacs and then save the entire buffer to a file.
21059
8e04817f
AC
21060@item
21061If you wish to suggest changes to the @value{GDBN} source, send us context
21062diffs. If you even discuss something in the @value{GDBN} source, refer to
21063it by context, not by line number.
c4555f82 21064
8e04817f
AC
21065The line numbers in our development sources will not match those in your
21066sources. Your line numbers would convey no useful information to us.
c4555f82 21067
8e04817f 21068@end itemize
c4555f82 21069
8e04817f 21070Here are some things that are not necessary:
c4555f82 21071
8e04817f
AC
21072@itemize @bullet
21073@item
21074A description of the envelope of the bug.
c4555f82 21075
8e04817f
AC
21076Often people who encounter a bug spend a lot of time investigating
21077which changes to the input file will make the bug go away and which
21078changes will not affect it.
c4555f82 21079
8e04817f
AC
21080This is often time consuming and not very useful, because the way we
21081will find the bug is by running a single example under the debugger
21082with breakpoints, not by pure deduction from a series of examples.
21083We recommend that you save your time for something else.
c4555f82 21084
8e04817f
AC
21085Of course, if you can find a simpler example to report @emph{instead}
21086of the original one, that is a convenience for us. Errors in the
21087output will be easier to spot, running under the debugger will take
21088less time, and so on.
c4555f82 21089
8e04817f
AC
21090However, simplification is not vital; if you do not want to do this,
21091report the bug anyway and send us the entire test case you used.
c4555f82 21092
8e04817f
AC
21093@item
21094A patch for the bug.
c4555f82 21095
8e04817f
AC
21096A patch for the bug does help us if it is a good one. But do not omit
21097the necessary information, such as the test case, on the assumption that
21098a patch is all we need. We might see problems with your patch and decide
21099to fix the problem another way, or we might not understand it at all.
c4555f82 21100
8e04817f
AC
21101Sometimes with a program as complicated as @value{GDBN} it is very hard to
21102construct an example that will make the program follow a certain path
21103through the code. If you do not send us the example, we will not be able
21104to construct one, so we will not be able to verify that the bug is fixed.
c4555f82 21105
8e04817f
AC
21106And if we cannot understand what bug you are trying to fix, or why your
21107patch should be an improvement, we will not install it. A test case will
21108help us to understand.
c4555f82 21109
8e04817f
AC
21110@item
21111A guess about what the bug is or what it depends on.
c4555f82 21112
8e04817f
AC
21113Such guesses are usually wrong. Even we cannot guess right about such
21114things without first using the debugger to find the facts.
21115@end itemize
c4555f82 21116
8e04817f
AC
21117@c The readline documentation is distributed with the readline code
21118@c and consists of the two following files:
21119@c rluser.texinfo
21120@c inc-hist.texinfo
21121@c Use -I with makeinfo to point to the appropriate directory,
21122@c environment var TEXINPUTS with TeX.
21123@include rluser.texinfo
21124@include inc-hist.texinfo
c4555f82 21125
c4555f82 21126
8e04817f
AC
21127@node Formatting Documentation
21128@appendix Formatting Documentation
c4555f82 21129
8e04817f
AC
21130@cindex @value{GDBN} reference card
21131@cindex reference card
21132The @value{GDBN} 4 release includes an already-formatted reference card, ready
21133for printing with PostScript or Ghostscript, in the @file{gdb}
21134subdirectory of the main source directory@footnote{In
21135@file{gdb-@value{GDBVN}/gdb/refcard.ps} of the version @value{GDBVN}
21136release.}. If you can use PostScript or Ghostscript with your printer,
21137you can print the reference card immediately with @file{refcard.ps}.
c4555f82 21138
8e04817f
AC
21139The release also includes the source for the reference card. You
21140can format it, using @TeX{}, by typing:
c4555f82 21141
474c8240 21142@smallexample
8e04817f 21143make refcard.dvi
474c8240 21144@end smallexample
c4555f82 21145
8e04817f
AC
21146The @value{GDBN} reference card is designed to print in @dfn{landscape}
21147mode on US ``letter'' size paper;
21148that is, on a sheet 11 inches wide by 8.5 inches
21149high. You will need to specify this form of printing as an option to
21150your @sc{dvi} output program.
c4555f82 21151
8e04817f 21152@cindex documentation
c4555f82 21153
8e04817f
AC
21154All the documentation for @value{GDBN} comes as part of the machine-readable
21155distribution. The documentation is written in Texinfo format, which is
21156a documentation system that uses a single source file to produce both
21157on-line information and a printed manual. You can use one of the Info
21158formatting commands to create the on-line version of the documentation
21159and @TeX{} (or @code{texi2roff}) to typeset the printed version.
c4555f82 21160
8e04817f
AC
21161@value{GDBN} includes an already formatted copy of the on-line Info
21162version of this manual in the @file{gdb} subdirectory. The main Info
21163file is @file{gdb-@value{GDBVN}/gdb/gdb.info}, and it refers to
21164subordinate files matching @samp{gdb.info*} in the same directory. If
21165necessary, you can print out these files, or read them with any editor;
21166but they are easier to read using the @code{info} subsystem in @sc{gnu}
21167Emacs or the standalone @code{info} program, available as part of the
21168@sc{gnu} Texinfo distribution.
c4555f82 21169
8e04817f
AC
21170If you want to format these Info files yourself, you need one of the
21171Info formatting programs, such as @code{texinfo-format-buffer} or
21172@code{makeinfo}.
c4555f82 21173
8e04817f
AC
21174If you have @code{makeinfo} installed, and are in the top level
21175@value{GDBN} source directory (@file{gdb-@value{GDBVN}}, in the case of
21176version @value{GDBVN}), you can make the Info file by typing:
c4555f82 21177
474c8240 21178@smallexample
8e04817f
AC
21179cd gdb
21180make gdb.info
474c8240 21181@end smallexample
c4555f82 21182
8e04817f
AC
21183If you want to typeset and print copies of this manual, you need @TeX{},
21184a program to print its @sc{dvi} output files, and @file{texinfo.tex}, the
21185Texinfo definitions file.
c4555f82 21186
8e04817f
AC
21187@TeX{} is a typesetting program; it does not print files directly, but
21188produces output files called @sc{dvi} files. To print a typeset
21189document, you need a program to print @sc{dvi} files. If your system
21190has @TeX{} installed, chances are it has such a program. The precise
21191command to use depends on your system; @kbd{lpr -d} is common; another
21192(for PostScript devices) is @kbd{dvips}. The @sc{dvi} print command may
21193require a file name without any extension or a @samp{.dvi} extension.
c4555f82 21194
8e04817f
AC
21195@TeX{} also requires a macro definitions file called
21196@file{texinfo.tex}. This file tells @TeX{} how to typeset a document
21197written in Texinfo format. On its own, @TeX{} cannot either read or
21198typeset a Texinfo file. @file{texinfo.tex} is distributed with GDB
21199and is located in the @file{gdb-@var{version-number}/texinfo}
21200directory.
c4555f82 21201
8e04817f
AC
21202If you have @TeX{} and a @sc{dvi} printer program installed, you can
21203typeset and print this manual. First switch to the the @file{gdb}
21204subdirectory of the main source directory (for example, to
21205@file{gdb-@value{GDBVN}/gdb}) and type:
c4555f82 21206
474c8240 21207@smallexample
8e04817f 21208make gdb.dvi
474c8240 21209@end smallexample
c4555f82 21210
8e04817f 21211Then give @file{gdb.dvi} to your @sc{dvi} printing program.
c4555f82 21212
8e04817f
AC
21213@node Installing GDB
21214@appendix Installing @value{GDBN}
21215@cindex configuring @value{GDBN}
21216@cindex installation
94e91d6d 21217@cindex configuring @value{GDBN}, and source tree subdirectories
c4555f82 21218
8e04817f
AC
21219@value{GDBN} comes with a @code{configure} script that automates the process
21220of preparing @value{GDBN} for installation; you can then use @code{make} to
21221build the @code{gdb} program.
21222@iftex
21223@c irrelevant in info file; it's as current as the code it lives with.
21224@footnote{If you have a more recent version of @value{GDBN} than @value{GDBVN},
21225look at the @file{README} file in the sources; we may have improved the
21226installation procedures since publishing this manual.}
21227@end iftex
c4555f82 21228
8e04817f
AC
21229The @value{GDBN} distribution includes all the source code you need for
21230@value{GDBN} in a single directory, whose name is usually composed by
21231appending the version number to @samp{gdb}.
c4555f82 21232
8e04817f
AC
21233For example, the @value{GDBN} version @value{GDBVN} distribution is in the
21234@file{gdb-@value{GDBVN}} directory. That directory contains:
c4555f82 21235
8e04817f
AC
21236@table @code
21237@item gdb-@value{GDBVN}/configure @r{(and supporting files)}
21238script for configuring @value{GDBN} and all its supporting libraries
c4555f82 21239
8e04817f
AC
21240@item gdb-@value{GDBVN}/gdb
21241the source specific to @value{GDBN} itself
c4555f82 21242
8e04817f
AC
21243@item gdb-@value{GDBVN}/bfd
21244source for the Binary File Descriptor library
c906108c 21245
8e04817f
AC
21246@item gdb-@value{GDBVN}/include
21247@sc{gnu} include files
c906108c 21248
8e04817f
AC
21249@item gdb-@value{GDBVN}/libiberty
21250source for the @samp{-liberty} free software library
c906108c 21251
8e04817f
AC
21252@item gdb-@value{GDBVN}/opcodes
21253source for the library of opcode tables and disassemblers
c906108c 21254
8e04817f
AC
21255@item gdb-@value{GDBVN}/readline
21256source for the @sc{gnu} command-line interface
c906108c 21257
8e04817f
AC
21258@item gdb-@value{GDBVN}/glob
21259source for the @sc{gnu} filename pattern-matching subroutine
c906108c 21260
8e04817f
AC
21261@item gdb-@value{GDBVN}/mmalloc
21262source for the @sc{gnu} memory-mapped malloc package
21263@end table
c906108c 21264
8e04817f
AC
21265The simplest way to configure and build @value{GDBN} is to run @code{configure}
21266from the @file{gdb-@var{version-number}} source directory, which in
21267this example is the @file{gdb-@value{GDBVN}} directory.
c906108c 21268
8e04817f
AC
21269First switch to the @file{gdb-@var{version-number}} source directory
21270if you are not already in it; then run @code{configure}. Pass the
21271identifier for the platform on which @value{GDBN} will run as an
21272argument.
c906108c 21273
8e04817f 21274For example:
c906108c 21275
474c8240 21276@smallexample
8e04817f
AC
21277cd gdb-@value{GDBVN}
21278./configure @var{host}
21279make
474c8240 21280@end smallexample
c906108c 21281
8e04817f
AC
21282@noindent
21283where @var{host} is an identifier such as @samp{sun4} or
21284@samp{decstation}, that identifies the platform where @value{GDBN} will run.
21285(You can often leave off @var{host}; @code{configure} tries to guess the
21286correct value by examining your system.)
c906108c 21287
8e04817f
AC
21288Running @samp{configure @var{host}} and then running @code{make} builds the
21289@file{bfd}, @file{readline}, @file{mmalloc}, and @file{libiberty}
21290libraries, then @code{gdb} itself. The configured source files, and the
21291binaries, are left in the corresponding source directories.
c906108c 21292
8e04817f
AC
21293@need 750
21294@code{configure} is a Bourne-shell (@code{/bin/sh}) script; if your
21295system does not recognize this automatically when you run a different
21296shell, you may need to run @code{sh} on it explicitly:
c906108c 21297
474c8240 21298@smallexample
8e04817f 21299sh configure @var{host}
474c8240 21300@end smallexample
c906108c 21301
8e04817f
AC
21302If you run @code{configure} from a directory that contains source
21303directories for multiple libraries or programs, such as the
21304@file{gdb-@value{GDBVN}} source directory for version @value{GDBVN}, @code{configure}
21305creates configuration files for every directory level underneath (unless
21306you tell it not to, with the @samp{--norecursion} option).
21307
94e91d6d
MC
21308You should run the @code{configure} script from the top directory in the
21309source tree, the @file{gdb-@var{version-number}} directory. If you run
21310@code{configure} from one of the subdirectories, you will configure only
21311that subdirectory. That is usually not what you want. In particular,
21312if you run the first @code{configure} from the @file{gdb} subdirectory
21313of the @file{gdb-@var{version-number}} directory, you will omit the
21314configuration of @file{bfd}, @file{readline}, and other sibling
21315directories of the @file{gdb} subdirectory. This leads to build errors
21316about missing include files such as @file{bfd/bfd.h}.
c906108c 21317
8e04817f
AC
21318You can install @code{@value{GDBP}} anywhere; it has no hardwired paths.
21319However, you should make sure that the shell on your path (named by
21320the @samp{SHELL} environment variable) is publicly readable. Remember
21321that @value{GDBN} uses the shell to start your program---some systems refuse to
21322let @value{GDBN} debug child processes whose programs are not readable.
c906108c 21323
8e04817f
AC
21324@menu
21325* Separate Objdir:: Compiling @value{GDBN} in another directory
21326* Config Names:: Specifying names for hosts and targets
21327* Configure Options:: Summary of options for configure
21328@end menu
c906108c 21329
8e04817f
AC
21330@node Separate Objdir
21331@section Compiling @value{GDBN} in another directory
c906108c 21332
8e04817f
AC
21333If you want to run @value{GDBN} versions for several host or target machines,
21334you need a different @code{gdb} compiled for each combination of
21335host and target. @code{configure} is designed to make this easy by
21336allowing you to generate each configuration in a separate subdirectory,
21337rather than in the source directory. If your @code{make} program
21338handles the @samp{VPATH} feature (@sc{gnu} @code{make} does), running
21339@code{make} in each of these directories builds the @code{gdb}
21340program specified there.
c906108c 21341
8e04817f
AC
21342To build @code{gdb} in a separate directory, run @code{configure}
21343with the @samp{--srcdir} option to specify where to find the source.
21344(You also need to specify a path to find @code{configure}
21345itself from your working directory. If the path to @code{configure}
21346would be the same as the argument to @samp{--srcdir}, you can leave out
21347the @samp{--srcdir} option; it is assumed.)
c906108c 21348
8e04817f
AC
21349For example, with version @value{GDBVN}, you can build @value{GDBN} in a
21350separate directory for a Sun 4 like this:
c906108c 21351
474c8240 21352@smallexample
8e04817f
AC
21353@group
21354cd gdb-@value{GDBVN}
21355mkdir ../gdb-sun4
21356cd ../gdb-sun4
21357../gdb-@value{GDBVN}/configure sun4
21358make
21359@end group
474c8240 21360@end smallexample
c906108c 21361
8e04817f
AC
21362When @code{configure} builds a configuration using a remote source
21363directory, it creates a tree for the binaries with the same structure
21364(and using the same names) as the tree under the source directory. In
21365the example, you'd find the Sun 4 library @file{libiberty.a} in the
21366directory @file{gdb-sun4/libiberty}, and @value{GDBN} itself in
21367@file{gdb-sun4/gdb}.
c906108c 21368
94e91d6d
MC
21369Make sure that your path to the @file{configure} script has just one
21370instance of @file{gdb} in it. If your path to @file{configure} looks
21371like @file{../gdb-@value{GDBVN}/gdb/configure}, you are configuring only
21372one subdirectory of @value{GDBN}, not the whole package. This leads to
21373build errors about missing include files such as @file{bfd/bfd.h}.
21374
8e04817f
AC
21375One popular reason to build several @value{GDBN} configurations in separate
21376directories is to configure @value{GDBN} for cross-compiling (where
21377@value{GDBN} runs on one machine---the @dfn{host}---while debugging
21378programs that run on another machine---the @dfn{target}).
21379You specify a cross-debugging target by
21380giving the @samp{--target=@var{target}} option to @code{configure}.
c906108c 21381
8e04817f
AC
21382When you run @code{make} to build a program or library, you must run
21383it in a configured directory---whatever directory you were in when you
21384called @code{configure} (or one of its subdirectories).
c906108c 21385
8e04817f
AC
21386The @code{Makefile} that @code{configure} generates in each source
21387directory also runs recursively. If you type @code{make} in a source
21388directory such as @file{gdb-@value{GDBVN}} (or in a separate configured
21389directory configured with @samp{--srcdir=@var{dirname}/gdb-@value{GDBVN}}), you
21390will build all the required libraries, and then build GDB.
c906108c 21391
8e04817f
AC
21392When you have multiple hosts or targets configured in separate
21393directories, you can run @code{make} on them in parallel (for example,
21394if they are NFS-mounted on each of the hosts); they will not interfere
21395with each other.
c906108c 21396
8e04817f
AC
21397@node Config Names
21398@section Specifying names for hosts and targets
c906108c 21399
8e04817f
AC
21400The specifications used for hosts and targets in the @code{configure}
21401script are based on a three-part naming scheme, but some short predefined
21402aliases are also supported. The full naming scheme encodes three pieces
21403of information in the following pattern:
c906108c 21404
474c8240 21405@smallexample
8e04817f 21406@var{architecture}-@var{vendor}-@var{os}
474c8240 21407@end smallexample
c906108c 21408
8e04817f
AC
21409For example, you can use the alias @code{sun4} as a @var{host} argument,
21410or as the value for @var{target} in a @code{--target=@var{target}}
21411option. The equivalent full name is @samp{sparc-sun-sunos4}.
c906108c 21412
8e04817f
AC
21413The @code{configure} script accompanying @value{GDBN} does not provide
21414any query facility to list all supported host and target names or
21415aliases. @code{configure} calls the Bourne shell script
21416@code{config.sub} to map abbreviations to full names; you can read the
21417script, if you wish, or you can use it to test your guesses on
21418abbreviations---for example:
c906108c 21419
8e04817f
AC
21420@smallexample
21421% sh config.sub i386-linux
21422i386-pc-linux-gnu
21423% sh config.sub alpha-linux
21424alpha-unknown-linux-gnu
21425% sh config.sub hp9k700
21426hppa1.1-hp-hpux
21427% sh config.sub sun4
21428sparc-sun-sunos4.1.1
21429% sh config.sub sun3
21430m68k-sun-sunos4.1.1
21431% sh config.sub i986v
21432Invalid configuration `i986v': machine `i986v' not recognized
21433@end smallexample
c906108c 21434
8e04817f
AC
21435@noindent
21436@code{config.sub} is also distributed in the @value{GDBN} source
21437directory (@file{gdb-@value{GDBVN}}, for version @value{GDBVN}).
d700128c 21438
8e04817f
AC
21439@node Configure Options
21440@section @code{configure} options
c906108c 21441
8e04817f
AC
21442Here is a summary of the @code{configure} options and arguments that
21443are most often useful for building @value{GDBN}. @code{configure} also has
21444several other options not listed here. @inforef{What Configure
21445Does,,configure.info}, for a full explanation of @code{configure}.
c906108c 21446
474c8240 21447@smallexample
8e04817f
AC
21448configure @r{[}--help@r{]}
21449 @r{[}--prefix=@var{dir}@r{]}
21450 @r{[}--exec-prefix=@var{dir}@r{]}
21451 @r{[}--srcdir=@var{dirname}@r{]}
21452 @r{[}--norecursion@r{]} @r{[}--rm@r{]}
21453 @r{[}--target=@var{target}@r{]}
21454 @var{host}
474c8240 21455@end smallexample
c906108c 21456
8e04817f
AC
21457@noindent
21458You may introduce options with a single @samp{-} rather than
21459@samp{--} if you prefer; but you may abbreviate option names if you use
21460@samp{--}.
c906108c 21461
8e04817f
AC
21462@table @code
21463@item --help
21464Display a quick summary of how to invoke @code{configure}.
c906108c 21465
8e04817f
AC
21466@item --prefix=@var{dir}
21467Configure the source to install programs and files under directory
21468@file{@var{dir}}.
c906108c 21469
8e04817f
AC
21470@item --exec-prefix=@var{dir}
21471Configure the source to install programs under directory
21472@file{@var{dir}}.
c906108c 21473
8e04817f
AC
21474@c avoid splitting the warning from the explanation:
21475@need 2000
21476@item --srcdir=@var{dirname}
21477@strong{Warning: using this option requires @sc{gnu} @code{make}, or another
21478@code{make} that implements the @code{VPATH} feature.}@*
21479Use this option to make configurations in directories separate from the
21480@value{GDBN} source directories. Among other things, you can use this to
21481build (or maintain) several configurations simultaneously, in separate
21482directories. @code{configure} writes configuration specific files in
21483the current directory, but arranges for them to use the source in the
21484directory @var{dirname}. @code{configure} creates directories under
21485the working directory in parallel to the source directories below
21486@var{dirname}.
c906108c 21487
8e04817f
AC
21488@item --norecursion
21489Configure only the directory level where @code{configure} is executed; do not
21490propagate configuration to subdirectories.
c906108c 21491
8e04817f
AC
21492@item --target=@var{target}
21493Configure @value{GDBN} for cross-debugging programs running on the specified
21494@var{target}. Without this option, @value{GDBN} is configured to debug
21495programs that run on the same machine (@var{host}) as @value{GDBN} itself.
c906108c 21496
8e04817f 21497There is no convenient way to generate a list of all available targets.
c906108c 21498
8e04817f
AC
21499@item @var{host} @dots{}
21500Configure @value{GDBN} to run on the specified @var{host}.
c906108c 21501
8e04817f
AC
21502There is no convenient way to generate a list of all available hosts.
21503@end table
c906108c 21504
8e04817f
AC
21505There are many other options available as well, but they are generally
21506needed for special purposes only.
c906108c 21507
8e04817f
AC
21508@node Maintenance Commands
21509@appendix Maintenance Commands
21510@cindex maintenance commands
21511@cindex internal commands
c906108c 21512
8e04817f 21513In addition to commands intended for @value{GDBN} users, @value{GDBN}
09d4efe1
EZ
21514includes a number of commands intended for @value{GDBN} developers,
21515that are not documented elsewhere in this manual. These commands are
da316a69
EZ
21516provided here for reference. (For commands that turn on debugging
21517messages, see @ref{Debugging Output}.)
c906108c 21518
8e04817f 21519@table @code
09d4efe1
EZ
21520@kindex maint agent
21521@item maint agent @var{expression}
21522Translate the given @var{expression} into remote agent bytecodes.
21523This command is useful for debugging the Agent Expression mechanism
21524(@pxref{Agent Expressions}).
21525
8e04817f
AC
21526@kindex maint info breakpoints
21527@item @anchor{maint info breakpoints}maint info breakpoints
21528Using the same format as @samp{info breakpoints}, display both the
21529breakpoints you've set explicitly, and those @value{GDBN} is using for
21530internal purposes. Internal breakpoints are shown with negative
21531breakpoint numbers. The type column identifies what kind of breakpoint
21532is shown:
c906108c 21533
8e04817f
AC
21534@table @code
21535@item breakpoint
21536Normal, explicitly set breakpoint.
c906108c 21537
8e04817f
AC
21538@item watchpoint
21539Normal, explicitly set watchpoint.
c906108c 21540
8e04817f
AC
21541@item longjmp
21542Internal breakpoint, used to handle correctly stepping through
21543@code{longjmp} calls.
c906108c 21544
8e04817f
AC
21545@item longjmp resume
21546Internal breakpoint at the target of a @code{longjmp}.
c906108c 21547
8e04817f
AC
21548@item until
21549Temporary internal breakpoint used by the @value{GDBN} @code{until} command.
c906108c 21550
8e04817f
AC
21551@item finish
21552Temporary internal breakpoint used by the @value{GDBN} @code{finish} command.
c906108c 21553
8e04817f
AC
21554@item shlib events
21555Shared library events.
c906108c 21556
8e04817f 21557@end table
c906108c 21558
09d4efe1
EZ
21559@kindex maint check-symtabs
21560@item maint check-symtabs
21561Check the consistency of psymtabs and symtabs.
21562
21563@kindex maint cplus first_component
21564@item maint cplus first_component @var{name}
21565Print the first C@t{++} class/namespace component of @var{name}.
21566
21567@kindex maint cplus namespace
21568@item maint cplus namespace
21569Print the list of possible C@t{++} namespaces.
21570
21571@kindex maint demangle
21572@item maint demangle @var{name}
21573Demangle a C@t{++} or Objective-C manled @var{name}.
21574
21575@kindex maint deprecate
21576@kindex maint undeprecate
21577@cindex deprecated commands
21578@item maint deprecate @var{command} @r{[}@var{replacement}@r{]}
21579@itemx maint undeprecate @var{command}
21580Deprecate or undeprecate the named @var{command}. Deprecated commands
21581cause @value{GDBN} to issue a warning when you use them. The optional
21582argument @var{replacement} says which newer command should be used in
21583favor of the deprecated one; if it is given, @value{GDBN} will mention
21584the replacement as part of the warning.
21585
21586@kindex maint dump-me
21587@item maint dump-me
721c2651 21588@cindex @code{SIGQUIT} signal, dump core of @value{GDBN}
09d4efe1 21589Cause a fatal signal in the debugger and force it to dump its core.
721c2651
EZ
21590This is supported only on systems which support aborting a program
21591with the @code{SIGQUIT} signal.
09d4efe1 21592
8d30a00d
AC
21593@kindex maint internal-error
21594@kindex maint internal-warning
09d4efe1
EZ
21595@item maint internal-error @r{[}@var{message-text}@r{]}
21596@itemx maint internal-warning @r{[}@var{message-text}@r{]}
8d30a00d
AC
21597Cause @value{GDBN} to call the internal function @code{internal_error}
21598or @code{internal_warning} and hence behave as though an internal error
21599or internal warning has been detected. In addition to reporting the
21600internal problem, these functions give the user the opportunity to
21601either quit @value{GDBN} or create a core file of the current
21602@value{GDBN} session.
21603
09d4efe1
EZ
21604These commands take an optional parameter @var{message-text} that is
21605used as the text of the error or warning message.
21606
21607Here's an example of using @code{indernal-error}:
21608
8d30a00d 21609@smallexample
f7dc1244 21610(@value{GDBP}) @kbd{maint internal-error testing, 1, 2}
8d30a00d
AC
21611@dots{}/maint.c:121: internal-error: testing, 1, 2
21612A problem internal to GDB has been detected. Further
21613debugging may prove unreliable.
21614Quit this debugging session? (y or n) @kbd{n}
21615Create a core file? (y or n) @kbd{n}
f7dc1244 21616(@value{GDBP})
8d30a00d
AC
21617@end smallexample
21618
09d4efe1
EZ
21619@kindex maint packet
21620@item maint packet @var{text}
21621If @value{GDBN} is talking to an inferior via the serial protocol,
21622then this command sends the string @var{text} to the inferior, and
21623displays the response packet. @value{GDBN} supplies the initial
21624@samp{$} character, the terminating @samp{#} character, and the
21625checksum.
21626
21627@kindex maint print architecture
21628@item maint print architecture @r{[}@var{file}@r{]}
21629Print the entire architecture configuration. The optional argument
21630@var{file} names the file where the output goes.
8d30a00d 21631
00905d52
AC
21632@kindex maint print dummy-frames
21633@item maint print dummy-frames
00905d52
AC
21634Prints the contents of @value{GDBN}'s internal dummy-frame stack.
21635
21636@smallexample
f7dc1244 21637(@value{GDBP}) @kbd{b add}
00905d52 21638@dots{}
f7dc1244 21639(@value{GDBP}) @kbd{print add(2,3)}
00905d52
AC
21640Breakpoint 2, add (a=2, b=3) at @dots{}
2164158 return (a + b);
21642The program being debugged stopped while in a function called from GDB.
21643@dots{}
f7dc1244 21644(@value{GDBP}) @kbd{maint print dummy-frames}
00905d52
AC
216450x1a57c80: pc=0x01014068 fp=0x0200bddc sp=0x0200bdd6
21646 top=0x0200bdd4 id=@{stack=0x200bddc,code=0x101405c@}
21647 call_lo=0x01014000 call_hi=0x01014001
f7dc1244 21648(@value{GDBP})
00905d52
AC
21649@end smallexample
21650
21651Takes an optional file parameter.
21652
0680b120
AC
21653@kindex maint print registers
21654@kindex maint print raw-registers
21655@kindex maint print cooked-registers
617073a9 21656@kindex maint print register-groups
09d4efe1
EZ
21657@item maint print registers @r{[}@var{file}@r{]}
21658@itemx maint print raw-registers @r{[}@var{file}@r{]}
21659@itemx maint print cooked-registers @r{[}@var{file}@r{]}
21660@itemx maint print register-groups @r{[}@var{file}@r{]}
0680b120
AC
21661Print @value{GDBN}'s internal register data structures.
21662
617073a9
AC
21663The command @code{maint print raw-registers} includes the contents of
21664the raw register cache; the command @code{maint print cooked-registers}
21665includes the (cooked) value of all registers; and the command
21666@code{maint print register-groups} includes the groups that each
21667register is a member of. @xref{Registers,, Registers, gdbint,
21668@value{GDBN} Internals}.
0680b120 21669
09d4efe1
EZ
21670These commands take an optional parameter, a file name to which to
21671write the information.
0680b120 21672
617073a9 21673@kindex maint print reggroups
09d4efe1
EZ
21674@item maint print reggroups @r{[}@var{file}@r{]}
21675Print @value{GDBN}'s internal register group data structures. The
21676optional argument @var{file} tells to what file to write the
21677information.
617073a9 21678
09d4efe1 21679The register groups info looks like this:
617073a9
AC
21680
21681@smallexample
f7dc1244 21682(@value{GDBP}) @kbd{maint print reggroups}
b383017d
RM
21683 Group Type
21684 general user
21685 float user
21686 all user
21687 vector user
21688 system user
21689 save internal
21690 restore internal
617073a9
AC
21691@end smallexample
21692
09d4efe1
EZ
21693@kindex flushregs
21694@item flushregs
21695This command forces @value{GDBN} to flush its internal register cache.
21696
21697@kindex maint print objfiles
21698@cindex info for known object files
21699@item maint print objfiles
21700Print a dump of all known object files. For each object file, this
21701command prints its name, address in memory, and all of its psymtabs
21702and symtabs.
21703
21704@kindex maint print statistics
21705@cindex bcache statistics
21706@item maint print statistics
21707This command prints, for each object file in the program, various data
21708about that object file followed by the byte cache (@dfn{bcache})
21709statistics for the object file. The objfile data includes the number
21710of minimal, partical, full, and stabs symbols, the number of types
21711defined by the objfile, the number of as yet unexpanded psym tables,
21712the number of line tables and string tables, and the amount of memory
21713used by the various tables. The bcache statistics include the counts,
21714sizes, and counts of duplicates of all and unique objects, max,
21715average, and median entry size, total memory used and its overhead and
21716savings, and various measures of the hash table size and chain
21717lengths.
21718
21719@kindex maint print type
21720@cindex type chain of a data type
21721@item maint print type @var{expr}
21722Print the type chain for a type specified by @var{expr}. The argument
21723can be either a type name or a symbol. If it is a symbol, the type of
21724that symbol is described. The type chain produced by this command is
21725a recursive definition of the data type as stored in @value{GDBN}'s
21726data structures, including its flags and contained types.
21727
21728@kindex maint set dwarf2 max-cache-age
21729@kindex maint show dwarf2 max-cache-age
21730@item maint set dwarf2 max-cache-age
21731@itemx maint show dwarf2 max-cache-age
21732Control the DWARF 2 compilation unit cache.
21733
21734@cindex DWARF 2 compilation units cache
21735In object files with inter-compilation-unit references, such as those
21736produced by the GCC option @samp{-feliminate-dwarf2-dups}, the DWARF 2
21737reader needs to frequently refer to previously read compilation units.
21738This setting controls how long a compilation unit will remain in the
21739cache if it is not referenced. A higher limit means that cached
21740compilation units will be stored in memory longer, and more total
21741memory will be used. Setting it to zero disables caching, which will
21742slow down @value{GDBN} startup, but reduce memory consumption.
21743
e7ba9c65
DJ
21744@kindex maint set profile
21745@kindex maint show profile
21746@cindex profiling GDB
21747@item maint set profile
21748@itemx maint show profile
21749Control profiling of @value{GDBN}.
21750
21751Profiling will be disabled until you use the @samp{maint set profile}
21752command to enable it. When you enable profiling, the system will begin
21753collecting timing and execution count data; when you disable profiling or
21754exit @value{GDBN}, the results will be written to a log file. Remember that
21755if you use profiling, @value{GDBN} will overwrite the profiling log file
21756(often called @file{gmon.out}). If you have a record of important profiling
21757data in a @file{gmon.out} file, be sure to move it to a safe location.
21758
21759Configuring with @samp{--enable-profiling} arranges for @value{GDBN} to be
b383017d 21760compiled with the @samp{-pg} compiler option.
e7ba9c65 21761
09d4efe1
EZ
21762@kindex maint show-debug-regs
21763@cindex x86 hardware debug registers
21764@item maint show-debug-regs
21765Control whether to show variables that mirror the x86 hardware debug
21766registers. Use @code{ON} to enable, @code{OFF} to disable. If
21767enabled, the debug registers values are shown when GDB inserts or
21768removes a hardware breakpoint or watchpoint, and when the inferior
21769triggers a hardware-assisted breakpoint or watchpoint.
21770
21771@kindex maint space
21772@cindex memory used by commands
21773@item maint space
21774Control whether to display memory usage for each command. If set to a
21775nonzero value, @value{GDBN} will display how much memory each command
21776took, following the command's own output. This can also be requested
21777by invoking @value{GDBN} with the @option{--statistics} command-line
21778switch (@pxref{Mode Options}).
21779
21780@kindex maint time
21781@cindex time of command execution
21782@item maint time
21783Control whether to display the execution time for each command. If
21784set to a nonzero value, @value{GDBN} will display how much time it
21785took to execute each command, following the command's own output.
21786This can also be requested by invoking @value{GDBN} with the
21787@option{--statistics} command-line switch (@pxref{Mode Options}).
21788
21789@kindex maint translate-address
21790@item maint translate-address @r{[}@var{section}@r{]} @var{addr}
21791Find the symbol stored at the location specified by the address
21792@var{addr} and an optional section name @var{section}. If found,
21793@value{GDBN} prints the name of the closest symbol and an offset from
21794the symbol's location to the specified address. This is similar to
21795the @code{info address} command (@pxref{Symbols}), except that this
21796command also allows to find symbols in other sections.
ae038cb0 21797
8e04817f 21798@end table
c906108c 21799
9c16f35a
EZ
21800The following command is useful for non-interactive invocations of
21801@value{GDBN}, such as in the test suite.
21802
21803@table @code
21804@item set watchdog @var{nsec}
21805@kindex set watchdog
21806@cindex watchdog timer
21807@cindex timeout for commands
21808Set the maximum number of seconds @value{GDBN} will wait for the
21809target operation to finish. If this time expires, @value{GDBN}
21810reports and error and the command is aborted.
21811
21812@item show watchdog
21813Show the current setting of the target wait timeout.
21814@end table
c906108c 21815
e0ce93ac 21816@node Remote Protocol
8e04817f 21817@appendix @value{GDBN} Remote Serial Protocol
c906108c 21818
ee2d5c50
AC
21819@menu
21820* Overview::
21821* Packets::
21822* Stop Reply Packets::
21823* General Query Packets::
21824* Register Packet Format::
21825* Examples::
0ce1b118 21826* File-I/O remote protocol extension::
ee2d5c50
AC
21827@end menu
21828
21829@node Overview
21830@section Overview
21831
8e04817f
AC
21832There may be occasions when you need to know something about the
21833protocol---for example, if there is only one serial port to your target
21834machine, you might want your program to do something special if it
21835recognizes a packet meant for @value{GDBN}.
c906108c 21836
d2c6833e 21837In the examples below, @samp{->} and @samp{<-} are used to indicate
8e04817f 21838transmitted and received data respectfully.
c906108c 21839
8e04817f
AC
21840@cindex protocol, @value{GDBN} remote serial
21841@cindex serial protocol, @value{GDBN} remote
21842@cindex remote serial protocol
21843All @value{GDBN} commands and responses (other than acknowledgments) are
21844sent as a @var{packet}. A @var{packet} is introduced with the character
21845@samp{$}, the actual @var{packet-data}, and the terminating character
21846@samp{#} followed by a two-digit @var{checksum}:
c906108c 21847
474c8240 21848@smallexample
8e04817f 21849@code{$}@var{packet-data}@code{#}@var{checksum}
474c8240 21850@end smallexample
8e04817f 21851@noindent
c906108c 21852
8e04817f
AC
21853@cindex checksum, for @value{GDBN} remote
21854@noindent
21855The two-digit @var{checksum} is computed as the modulo 256 sum of all
21856characters between the leading @samp{$} and the trailing @samp{#} (an
21857eight bit unsigned checksum).
c906108c 21858
8e04817f
AC
21859Implementors should note that prior to @value{GDBN} 5.0 the protocol
21860specification also included an optional two-digit @var{sequence-id}:
c906108c 21861
474c8240 21862@smallexample
8e04817f 21863@code{$}@var{sequence-id}@code{:}@var{packet-data}@code{#}@var{checksum}
474c8240 21864@end smallexample
c906108c 21865
8e04817f
AC
21866@cindex sequence-id, for @value{GDBN} remote
21867@noindent
21868That @var{sequence-id} was appended to the acknowledgment. @value{GDBN}
21869has never output @var{sequence-id}s. Stubs that handle packets added
21870since @value{GDBN} 5.0 must not accept @var{sequence-id}.
c906108c 21871
8e04817f
AC
21872@cindex acknowledgment, for @value{GDBN} remote
21873When either the host or the target machine receives a packet, the first
21874response expected is an acknowledgment: either @samp{+} (to indicate
21875the package was received correctly) or @samp{-} (to request
21876retransmission):
c906108c 21877
474c8240 21878@smallexample
d2c6833e
AC
21879-> @code{$}@var{packet-data}@code{#}@var{checksum}
21880<- @code{+}
474c8240 21881@end smallexample
8e04817f 21882@noindent
53a5351d 21883
8e04817f
AC
21884The host (@value{GDBN}) sends @var{command}s, and the target (the
21885debugging stub incorporated in your program) sends a @var{response}. In
21886the case of step and continue @var{command}s, the response is only sent
21887when the operation has completed (the target has again stopped).
c906108c 21888
8e04817f
AC
21889@var{packet-data} consists of a sequence of characters with the
21890exception of @samp{#} and @samp{$} (see @samp{X} packet for additional
21891exceptions).
c906108c 21892
8e04817f 21893Fields within the packet should be separated using @samp{,} @samp{;} or
ee2d5c50 21894@cindex remote protocol, field separator
8e04817f 21895@samp{:}. Except where otherwise noted all numbers are represented in
ee2d5c50 21896@sc{hex} with leading zeros suppressed.
c906108c 21897
8e04817f
AC
21898Implementors should note that prior to @value{GDBN} 5.0, the character
21899@samp{:} could not appear as the third character in a packet (as it
21900would potentially conflict with the @var{sequence-id}).
c906108c 21901
8e04817f
AC
21902Response @var{data} can be run-length encoded to save space. A @samp{*}
21903means that the next character is an @sc{ascii} encoding giving a repeat count
21904which stands for that many repetitions of the character preceding the
21905@samp{*}. The encoding is @code{n+29}, yielding a printable character
21906where @code{n >=3} (which is where rle starts to win). The printable
21907characters @samp{$}, @samp{#}, @samp{+} and @samp{-} or with a numeric
21908value greater than 126 should not be used.
c906108c 21909
8e04817f 21910So:
474c8240 21911@smallexample
8e04817f 21912"@code{0* }"
474c8240 21913@end smallexample
8e04817f
AC
21914@noindent
21915means the same as "0000".
c906108c 21916
8e04817f
AC
21917The error response returned for some packets includes a two character
21918error number. That number is not well defined.
c906108c 21919
8e04817f
AC
21920For any @var{command} not supported by the stub, an empty response
21921(@samp{$#00}) should be returned. That way it is possible to extend the
21922protocol. A newer @value{GDBN} can tell if a packet is supported based
21923on that response.
c906108c 21924
b383017d
RM
21925A stub is required to support the @samp{g}, @samp{G}, @samp{m}, @samp{M},
21926@samp{c}, and @samp{s} @var{command}s. All other @var{command}s are
8e04817f 21927optional.
c906108c 21928
ee2d5c50
AC
21929@node Packets
21930@section Packets
21931
21932The following table provides a complete list of all currently defined
21933@var{command}s and their corresponding response @var{data}.
9c16f35a
EZ
21934@xref{File-I/O remote protocol extension}, for details about the File
21935I/O extension of the remote protocol.
ee2d5c50
AC
21936
21937@table @r
21938
21939@item @code{!} --- extended mode
21940@cindex @code{!} packet
21941
8e04817f
AC
21942Enable extended mode. In extended mode, the remote server is made
21943persistent. The @samp{R} packet is used to restart the program being
21944debugged.
ee2d5c50
AC
21945
21946Reply:
21947@table @samp
21948@item OK
8e04817f 21949The remote target both supports and has enabled extended mode.
ee2d5c50 21950@end table
c906108c 21951
ee2d5c50
AC
21952@item @code{?} --- last signal
21953@cindex @code{?} packet
c906108c 21954
ee2d5c50
AC
21955Indicate the reason the target halted. The reply is the same as for
21956step and continue.
c906108c 21957
ee2d5c50
AC
21958Reply:
21959@xref{Stop Reply Packets}, for the reply specifications.
21960
21961@item @code{a} --- reserved
21962
21963Reserved for future use.
21964
21965@item @code{A}@var{arglen}@code{,}@var{argnum}@code{,}@var{arg}@code{,@dots{}} --- set program arguments @strong{(reserved)}
21966@cindex @code{A} packet
c906108c 21967
8e04817f
AC
21968Initialized @samp{argv[]} array passed into program. @var{arglen}
21969specifies the number of bytes in the hex encoded byte stream @var{arg}.
ee2d5c50
AC
21970See @code{gdbserver} for more details.
21971
21972Reply:
21973@table @samp
21974@item OK
21975@item E@var{NN}
21976@end table
21977
21978@item @code{b}@var{baud} --- set baud @strong{(deprecated)}
21979@cindex @code{b} packet
21980
21981Change the serial line speed to @var{baud}.
21982
21983JTC: @emph{When does the transport layer state change? When it's
21984received, or after the ACK is transmitted. In either case, there are
21985problems if the command or the acknowledgment packet is dropped.}
21986
21987Stan: @emph{If people really wanted to add something like this, and get
21988it working for the first time, they ought to modify ser-unix.c to send
21989some kind of out-of-band message to a specially-setup stub and have the
21990switch happen "in between" packets, so that from remote protocol's point
21991of view, nothing actually happened.}
21992
21993@item @code{B}@var{addr},@var{mode} --- set breakpoint @strong{(deprecated)}
21994@cindex @code{B} packet
21995
8e04817f 21996Set (@var{mode} is @samp{S}) or clear (@var{mode} is @samp{C}) a
2f870471
AC
21997breakpoint at @var{addr}.
21998
21999This packet has been replaced by the @samp{Z} and @samp{z} packets
22000(@pxref{insert breakpoint or watchpoint packet}).
c906108c 22001
ee2d5c50
AC
22002@item @code{c}@var{addr} --- continue
22003@cindex @code{c} packet
22004
22005@var{addr} is address to resume. If @var{addr} is omitted, resume at
8e04817f 22006current address.
c906108c 22007
ee2d5c50
AC
22008Reply:
22009@xref{Stop Reply Packets}, for the reply specifications.
22010
22011@item @code{C}@var{sig}@code{;}@var{addr} --- continue with signal
22012@cindex @code{C} packet
22013
8e04817f
AC
22014Continue with signal @var{sig} (hex signal number). If
22015@code{;}@var{addr} is omitted, resume at same address.
c906108c 22016
ee2d5c50
AC
22017Reply:
22018@xref{Stop Reply Packets}, for the reply specifications.
c906108c 22019
ee2d5c50
AC
22020@item @code{d} --- toggle debug @strong{(deprecated)}
22021@cindex @code{d} packet
22022
22023Toggle debug flag.
22024
22025@item @code{D} --- detach
22026@cindex @code{D} packet
22027
22028Detach @value{GDBN} from the remote system. Sent to the remote target
07f31aa6 22029before @value{GDBN} disconnects via the @code{detach} command.
ee2d5c50
AC
22030
22031Reply:
22032@table @samp
22033@item @emph{no response}
8e04817f 22034@value{GDBN} does not check for any response after sending this packet.
ee2d5c50 22035@end table
c906108c 22036
ee2d5c50 22037@item @code{e} --- reserved
c906108c 22038
ee2d5c50 22039Reserved for future use.
c906108c 22040
ee2d5c50 22041@item @code{E} --- reserved
c906108c 22042
ee2d5c50 22043Reserved for future use.
c906108c 22044
ee2d5c50
AC
22045@item @code{f} --- reserved
22046
22047Reserved for future use.
22048
0ce1b118
CV
22049@item @code{F}@var{RC}@code{,}@var{EE}@code{,}@var{CF}@code{;}@var{XX} --- Reply to target's F packet.
22050@cindex @code{F} packet
ee2d5c50 22051
0ce1b118
CV
22052This packet is send by @value{GDBN} as reply to a @code{F} request packet
22053sent by the target. This is part of the File-I/O protocol extension.
22054@xref{File-I/O remote protocol extension}, for the specification.
ee2d5c50
AC
22055
22056@item @code{g} --- read registers
22057@anchor{read registers packet}
22058@cindex @code{g} packet
22059
22060Read general registers.
22061
22062Reply:
22063@table @samp
22064@item @var{XX@dots{}}
8e04817f
AC
22065Each byte of register data is described by two hex digits. The bytes
22066with the register are transmitted in target byte order. The size of
22067each register and their position within the @samp{g} @var{packet} are
12c266ea
AC
22068determined by the @value{GDBN} internal macros
22069@var{DEPRECATED_REGISTER_RAW_SIZE} and @var{REGISTER_NAME} macros. The
22070specification of several standard @code{g} packets is specified below.
ee2d5c50
AC
22071@item E@var{NN}
22072for an error.
22073@end table
c906108c 22074
ee2d5c50
AC
22075@item @code{G}@var{XX@dots{}} --- write regs
22076@cindex @code{G} packet
c906108c 22077
ee2d5c50
AC
22078@xref{read registers packet}, for a description of the @var{XX@dots{}}
22079data.
22080
22081Reply:
22082@table @samp
22083@item OK
22084for success
22085@item E@var{NN}
22086for an error
22087@end table
22088
22089@item @code{h} --- reserved
22090
22091Reserved for future use.
22092
b383017d 22093@item @code{H}@var{c}@var{t@dots{}} --- set thread
ee2d5c50 22094@cindex @code{H} packet
c906108c 22095
8e04817f 22096Set thread for subsequent operations (@samp{m}, @samp{M}, @samp{g},
ee2d5c50
AC
22097@samp{G}, et.al.). @var{c} depends on the operation to be performed: it
22098should be @samp{c} for step and continue operations, @samp{g} for other
22099operations. The thread designator @var{t@dots{}} may be -1, meaning all
22100the threads, a thread number, or zero which means pick any thread.
22101
22102Reply:
22103@table @samp
22104@item OK
22105for success
22106@item E@var{NN}
22107for an error
22108@end table
c906108c 22109
8e04817f
AC
22110@c FIXME: JTC:
22111@c 'H': How restrictive (or permissive) is the thread model. If a
22112@c thread is selected and stopped, are other threads allowed
22113@c to continue to execute? As I mentioned above, I think the
22114@c semantics of each command when a thread is selected must be
22115@c described. For example:
22116@c
22117@c 'g': If the stub supports threads and a specific thread is
22118@c selected, returns the register block from that thread;
22119@c otherwise returns current registers.
22120@c
22121@c 'G' If the stub supports threads and a specific thread is
22122@c selected, sets the registers of the register block of
22123@c that thread; otherwise sets current registers.
c906108c 22124
ee2d5c50
AC
22125@item @code{i}@var{addr}@code{,}@var{nnn} --- cycle step @strong{(draft)}
22126@anchor{cycle step packet}
22127@cindex @code{i} packet
22128
8e04817f
AC
22129Step the remote target by a single clock cycle. If @code{,}@var{nnn} is
22130present, cycle step @var{nnn} cycles. If @var{addr} is present, cycle
22131step starting at that address.
c906108c 22132
ee2d5c50
AC
22133@item @code{I} --- signal then cycle step @strong{(reserved)}
22134@cindex @code{I} packet
22135
22136@xref{step with signal packet}. @xref{cycle step packet}.
22137
22138@item @code{j} --- reserved
22139
22140Reserved for future use.
22141
22142@item @code{J} --- reserved
c906108c 22143
ee2d5c50 22144Reserved for future use.
c906108c 22145
ee2d5c50
AC
22146@item @code{k} --- kill request
22147@cindex @code{k} packet
c906108c 22148
ac282366 22149FIXME: @emph{There is no description of how to operate when a specific
ee2d5c50
AC
22150thread context has been selected (i.e.@: does 'k' kill only that
22151thread?)}.
c906108c 22152
ee2d5c50 22153@item @code{K} --- reserved
c906108c 22154
ee2d5c50
AC
22155Reserved for future use.
22156
22157@item @code{l} --- reserved
22158
22159Reserved for future use.
22160
22161@item @code{L} --- reserved
22162
22163Reserved for future use.
22164
22165@item @code{m}@var{addr}@code{,}@var{length} --- read memory
22166@cindex @code{m} packet
c906108c 22167
8e04817f 22168Read @var{length} bytes of memory starting at address @var{addr}.
ee2d5c50 22169Neither @value{GDBN} nor the stub assume that sized memory transfers are
2e834e49 22170assumed using word aligned accesses. FIXME: @emph{A word aligned memory
8e04817f 22171transfer mechanism is needed.}
c906108c 22172
ee2d5c50
AC
22173Reply:
22174@table @samp
22175@item @var{XX@dots{}}
22176@var{XX@dots{}} is mem contents. Can be fewer bytes than requested if able
22177to read only part of the data. Neither @value{GDBN} nor the stub assume
2e834e49 22178that sized memory transfers are assumed using word aligned
ee2d5c50
AC
22179accesses. FIXME: @emph{A word aligned memory transfer mechanism is
22180needed.}
22181@item E@var{NN}
22182@var{NN} is errno
22183@end table
22184
22185@item @code{M}@var{addr},@var{length}@code{:}@var{XX@dots{}} --- write mem
22186@cindex @code{M} packet
22187
8e04817f 22188Write @var{length} bytes of memory starting at address @var{addr}.
ee2d5c50
AC
22189@var{XX@dots{}} is the data.
22190
22191Reply:
22192@table @samp
22193@item OK
22194for success
22195@item E@var{NN}
8e04817f
AC
22196for an error (this includes the case where only part of the data was
22197written).
ee2d5c50 22198@end table
c906108c 22199
ee2d5c50 22200@item @code{n} --- reserved
c906108c 22201
ee2d5c50 22202Reserved for future use.
c906108c 22203
ee2d5c50 22204@item @code{N} --- reserved
c906108c 22205
ee2d5c50 22206Reserved for future use.
c906108c 22207
ee2d5c50
AC
22208@item @code{o} --- reserved
22209
22210Reserved for future use.
22211
22212@item @code{O} --- reserved
22213
2e868123 22214@item @code{p}@var{hex number of register} --- read register packet
ee2d5c50
AC
22215@cindex @code{p} packet
22216
2e868123
AC
22217@xref{read registers packet}, for a description of how the returned
22218register value is encoded.
ee2d5c50
AC
22219
22220Reply:
22221@table @samp
2e868123
AC
22222@item @var{XX@dots{}}
22223the register's value
22224@item E@var{NN}
22225for an error
22226@item
22227Indicating an unrecognized @var{query}.
ee2d5c50
AC
22228@end table
22229
22230@item @code{P}@var{n@dots{}}@code{=}@var{r@dots{}} --- write register
22231@anchor{write register packet}
22232@cindex @code{P} packet
22233
22234Write register @var{n@dots{}} with value @var{r@dots{}}, which contains two hex
8e04817f 22235digits for each byte in the register (target byte order).
c906108c 22236
ee2d5c50
AC
22237Reply:
22238@table @samp
22239@item OK
22240for success
22241@item E@var{NN}
22242for an error
22243@end table
22244
22245@item @code{q}@var{query} --- general query
22246@anchor{general query packet}
22247@cindex @code{q} packet
22248
22249Request info about @var{query}. In general @value{GDBN} queries have a
22250leading upper case letter. Custom vendor queries should use a company
22251prefix (in lower case) ex: @samp{qfsf.var}. @var{query} may optionally
22252be followed by a @samp{,} or @samp{;} separated list. Stubs must ensure
22253that they match the full @var{query} name.
22254
22255Reply:
22256@table @samp
22257@item @var{XX@dots{}}
22258Hex encoded data from query. The reply can not be empty.
22259@item E@var{NN}
22260error reply
8e04817f 22261@item
ee2d5c50
AC
22262Indicating an unrecognized @var{query}.
22263@end table
22264
22265@item @code{Q}@var{var}@code{=}@var{val} --- general set
22266@cindex @code{Q} packet
22267
22268Set value of @var{var} to @var{val}.
22269
22270@xref{general query packet}, for a discussion of naming conventions.
c906108c 22271
ee2d5c50
AC
22272@item @code{r} --- reset @strong{(deprecated)}
22273@cindex @code{r} packet
c906108c 22274
8e04817f 22275Reset the entire system.
c906108c 22276
ee2d5c50
AC
22277@item @code{R}@var{XX} --- remote restart
22278@cindex @code{R} packet
22279
8e04817f
AC
22280Restart the program being debugged. @var{XX}, while needed, is ignored.
22281This packet is only available in extended mode.
ee2d5c50
AC
22282
22283Reply:
22284@table @samp
22285@item @emph{no reply}
8e04817f 22286The @samp{R} packet has no reply.
ee2d5c50
AC
22287@end table
22288
22289@item @code{s}@var{addr} --- step
22290@cindex @code{s} packet
c906108c 22291
8e04817f
AC
22292@var{addr} is address to resume. If @var{addr} is omitted, resume at
22293same address.
c906108c 22294
ee2d5c50
AC
22295Reply:
22296@xref{Stop Reply Packets}, for the reply specifications.
22297
22298@item @code{S}@var{sig}@code{;}@var{addr} --- step with signal
22299@anchor{step with signal packet}
22300@cindex @code{S} packet
22301
8e04817f 22302Like @samp{C} but step not continue.
c906108c 22303
ee2d5c50
AC
22304Reply:
22305@xref{Stop Reply Packets}, for the reply specifications.
22306
b383017d 22307@item @code{t}@var{addr}@code{:}@var{PP}@code{,}@var{MM} --- search
ee2d5c50
AC
22308@cindex @code{t} packet
22309
8e04817f 22310Search backwards starting at address @var{addr} for a match with pattern
ee2d5c50
AC
22311@var{PP} and mask @var{MM}. @var{PP} and @var{MM} are 4 bytes.
22312@var{addr} must be at least 3 digits.
c906108c 22313
ee2d5c50
AC
22314@item @code{T}@var{XX} --- thread alive
22315@cindex @code{T} packet
c906108c 22316
ee2d5c50 22317Find out if the thread XX is alive.
c906108c 22318
ee2d5c50
AC
22319Reply:
22320@table @samp
22321@item OK
22322thread is still alive
22323@item E@var{NN}
22324thread is dead
22325@end table
22326
22327@item @code{u} --- reserved
22328
22329Reserved for future use.
22330
22331@item @code{U} --- reserved
22332
22333Reserved for future use.
22334
86d30acc 22335@item @code{v} --- verbose packet prefix
ee2d5c50 22336
86d30acc
DJ
22337Packets starting with @code{v} are identified by a multi-letter name,
22338up to the first @code{;} or @code{?} (or the end of the packet).
22339
22340@item @code{vCont}[;@var{action}[@code{:}@var{tid}]]... --- extended resume
22341@cindex @code{vCont} packet
22342
22343Resume the inferior. Different actions may be specified for each thread.
22344If an action is specified with no @var{tid}, then it is applied to any
22345threads that don't have a specific action specified; if no default action is
22346specified then other threads should remain stopped. Specifying multiple
22347default actions is an error; specifying no actions is also an error.
22348Thread IDs are specified in hexadecimal. Currently supported actions are:
22349
22350@table @code
22351@item c
22352Continue.
22353@item C@var{sig}
22354Continue with signal @var{sig}. @var{sig} should be two hex digits.
22355@item s
22356Step.
22357@item S@var{sig}
22358Step with signal @var{sig}. @var{sig} should be two hex digits.
22359@end table
22360
22361The optional @var{addr} argument normally associated with these packets is
22362not supported in @code{vCont}.
22363
22364Reply:
22365@xref{Stop Reply Packets}, for the reply specifications.
22366
22367@item @code{vCont?} --- extended resume query
22368@cindex @code{vCont?} packet
22369
22370Query support for the @code{vCont} packet.
22371
22372Reply:
22373@table @samp
22374@item @code{vCont}[;@var{action}]...
22375The @code{vCont} packet is supported. Each @var{action} is a supported
22376command in the @code{vCont} packet.
22377@item
22378The @code{vCont} packet is not supported.
22379@end table
ee2d5c50
AC
22380
22381@item @code{V} --- reserved
c906108c 22382
ee2d5c50 22383Reserved for future use.
c906108c 22384
ee2d5c50 22385@item @code{w} --- reserved
c906108c 22386
ee2d5c50 22387Reserved for future use.
c906108c 22388
ee2d5c50 22389@item @code{W} --- reserved
c906108c 22390
ee2d5c50 22391Reserved for future use.
c906108c 22392
ee2d5c50
AC
22393@item @code{x} --- reserved
22394
22395Reserved for future use.
22396
22397@item @code{X}@var{addr}@code{,}@var{length}@var{:}@var{XX@dots{}} --- write mem (binary)
22398@cindex @code{X} packet
22399
22400@var{addr} is address, @var{length} is number of bytes, @var{XX@dots{}}
22401is binary data. The characters @code{$}, @code{#}, and @code{0x7d} are
69065f5d
AC
22402escaped using @code{0x7d}, and then XORed with @code{0x20}.
22403For example, @code{0x7d} would be transmitted as @code{0x7d 0x5d}.
c906108c 22404
ee2d5c50
AC
22405Reply:
22406@table @samp
22407@item OK
22408for success
22409@item E@var{NN}
22410for an error
22411@end table
22412
22413@item @code{y} --- reserved
c906108c 22414
ee2d5c50 22415Reserved for future use.
c906108c 22416
ee2d5c50
AC
22417@item @code{Y} reserved
22418
22419Reserved for future use.
22420
2f870471
AC
22421@item @code{z}@var{type}@code{,}@var{addr}@code{,}@var{length} --- remove breakpoint or watchpoint @strong{(draft)}
22422@itemx @code{Z}@var{type}@code{,}@var{addr}@code{,}@var{length} --- insert breakpoint or watchpoint @strong{(draft)}
22423@anchor{insert breakpoint or watchpoint packet}
ee2d5c50 22424@cindex @code{z} packet
2f870471 22425@cindex @code{Z} packets
ee2d5c50 22426
2f870471
AC
22427Insert (@code{Z}) or remove (@code{z}) a @var{type} breakpoint or
22428watchpoint starting at address @var{address} and covering the next
22429@var{length} bytes.
ee2d5c50 22430
2f870471
AC
22431Each breakpoint and watchpoint packet @var{type} is documented
22432separately.
22433
512217c7
AC
22434@emph{Implementation notes: A remote target shall return an empty string
22435for an unrecognized breakpoint or watchpoint packet @var{type}. A
22436remote target shall support either both or neither of a given
2f870471
AC
22437@code{Z}@var{type}@dots{} and @code{z}@var{type}@dots{} packet pair. To
22438avoid potential problems with duplicate packets, the operations should
22439be implemented in an idempotent way.}
22440
22441@item @code{z}@code{0}@code{,}@var{addr}@code{,}@var{length} --- remove memory breakpoint @strong{(draft)}
22442@item @code{Z}@code{0}@code{,}@var{addr}@code{,}@var{length} --- insert memory breakpoint @strong{(draft)}
22443@cindex @code{z0} packet
22444@cindex @code{Z0} packet
22445
22446Insert (@code{Z0}) or remove (@code{z0}) a memory breakpoint at address
22447@code{addr} of size @code{length}.
22448
22449A memory breakpoint is implemented by replacing the instruction at
22450@var{addr} with a software breakpoint or trap instruction. The
22451@code{length} is used by targets that indicates the size of the
22452breakpoint (in bytes) that should be inserted (e.g., the @sc{arm} and
22453@sc{mips} can insert either a 2 or 4 byte breakpoint).
c906108c 22454
2f870471
AC
22455@emph{Implementation note: It is possible for a target to copy or move
22456code that contains memory breakpoints (e.g., when implementing
22457overlays). The behavior of this packet, in the presence of such a
22458target, is not defined.}
c906108c 22459
ee2d5c50
AC
22460Reply:
22461@table @samp
2f870471
AC
22462@item OK
22463success
22464@item
22465not supported
ee2d5c50
AC
22466@item E@var{NN}
22467for an error
2f870471
AC
22468@end table
22469
22470@item @code{z}@code{1}@code{,}@var{addr}@code{,}@var{length} --- remove hardware breakpoint @strong{(draft)}
22471@item @code{Z}@code{1}@code{,}@var{addr}@code{,}@var{length} --- insert hardware breakpoint @strong{(draft)}
22472@cindex @code{z1} packet
22473@cindex @code{Z1} packet
22474
22475Insert (@code{Z1}) or remove (@code{z1}) a hardware breakpoint at
22476address @code{addr} of size @code{length}.
22477
22478A hardware breakpoint is implemented using a mechanism that is not
22479dependant on being able to modify the target's memory.
22480
22481@emph{Implementation note: A hardware breakpoint is not affected by code
22482movement.}
22483
22484Reply:
22485@table @samp
ee2d5c50 22486@item OK
2f870471
AC
22487success
22488@item
22489not supported
22490@item E@var{NN}
22491for an error
22492@end table
22493
22494@item @code{z}@code{2}@code{,}@var{addr}@code{,}@var{length} --- remove write watchpoint @strong{(draft)}
22495@item @code{Z}@code{2}@code{,}@var{addr}@code{,}@var{length} --- insert write watchpoint @strong{(draft)}
22496@cindex @code{z2} packet
22497@cindex @code{Z2} packet
22498
22499Insert (@code{Z2}) or remove (@code{z2}) a write watchpoint.
22500
22501Reply:
22502@table @samp
22503@item OK
22504success
22505@item
22506not supported
22507@item E@var{NN}
22508for an error
22509@end table
22510
22511@item @code{z}@code{3}@code{,}@var{addr}@code{,}@var{length} --- remove read watchpoint @strong{(draft)}
22512@item @code{Z}@code{3}@code{,}@var{addr}@code{,}@var{length} --- insert read watchpoint @strong{(draft)}
22513@cindex @code{z3} packet
22514@cindex @code{Z3} packet
22515
2e834e49 22516Insert (@code{Z3}) or remove (@code{z3}) a read watchpoint.
2f870471
AC
22517
22518Reply:
22519@table @samp
22520@item OK
22521success
22522@item
22523not supported
22524@item E@var{NN}
22525for an error
22526@end table
22527
2e834e49
HPN
22528@item @code{z}@code{4}@code{,}@var{addr}@code{,}@var{length} --- remove access watchpoint @strong{(draft)}
22529@item @code{Z}@code{4}@code{,}@var{addr}@code{,}@var{length} --- insert access watchpoint @strong{(draft)}
2f870471
AC
22530@cindex @code{z4} packet
22531@cindex @code{Z4} packet
22532
22533Insert (@code{Z4}) or remove (@code{z4}) an access watchpoint.
22534
22535Reply:
22536@table @samp
22537@item OK
22538success
22539@item
22540not supported
22541@item E@var{NN}
22542for an error
ee2d5c50
AC
22543@end table
22544
22545@end table
c906108c 22546
ee2d5c50
AC
22547@node Stop Reply Packets
22548@section Stop Reply Packets
22549@cindex stop reply packets
c906108c 22550
8e04817f
AC
22551The @samp{C}, @samp{c}, @samp{S}, @samp{s} and @samp{?} packets can
22552receive any of the below as a reply. In the case of the @samp{C},
22553@samp{c}, @samp{S} and @samp{s} packets, that reply is only returned
22554when the target halts. In the below the exact meaning of @samp{signal
22555number} is poorly defined. In general one of the UNIX signal numbering
22556conventions is used.
c906108c 22557
ee2d5c50 22558@table @samp
c906108c 22559
ee2d5c50
AC
22560@item S@var{AA}
22561@var{AA} is the signal number
c906108c 22562
8e04817f 22563@item @code{T}@var{AA}@var{n...}@code{:}@var{r...}@code{;}@var{n...}@code{:}@var{r...}@code{;}@var{n...}@code{:}@var{r...}@code{;}
ee2d5c50
AC
22564@cindex @code{T} packet reply
22565
8e04817f
AC
22566@var{AA} = two hex digit signal number; @var{n...} = register number
22567(hex), @var{r...} = target byte ordered register contents, size defined
12c266ea
AC
22568by @code{DEPRECATED_REGISTER_RAW_SIZE}; @var{n...} = @samp{thread},
22569@var{r...} = thread process ID, this is a hex integer; @var{n...} =
22570(@samp{watch} | @samp{rwatch} | @samp{awatch}, @var{r...} = data
22571address, this is a hex integer; @var{n...} = other string not starting
22572with valid hex digit. @value{GDBN} should ignore this @var{n...},
22573@var{r...} pair and go on to the next. This way we can extend the
22574protocol.
c906108c 22575
ee2d5c50
AC
22576@item W@var{AA}
22577
8e04817f 22578The process exited, and @var{AA} is the exit status. This is only
ee2d5c50
AC
22579applicable to certain targets.
22580
22581@item X@var{AA}
c906108c 22582
8e04817f 22583The process terminated with signal @var{AA}.
c906108c 22584
ee2d5c50 22585@item O@var{XX@dots{}}
c906108c 22586
ee2d5c50
AC
22587@var{XX@dots{}} is hex encoding of @sc{ascii} data. This can happen at
22588any time while the program is running and the debugger should continue
22589to wait for @samp{W}, @samp{T}, etc.
22590
0ce1b118
CV
22591@item F@var{call-id}@code{,}@var{parameter@dots{}}
22592
22593@var{call-id} is the identifier which says which host system call should
22594be called. This is just the name of the function. Translation into the
22595correct system call is only applicable as it's defined in @value{GDBN}.
22596@xref{File-I/O remote protocol extension}, for a list of implemented
22597system calls.
22598
22599@var{parameter@dots{}} is a list of parameters as defined for this very
22600system call.
22601
22602The target replies with this packet when it expects @value{GDBN} to call
22603a host system call on behalf of the target. @value{GDBN} replies with
22604an appropriate @code{F} packet and keeps up waiting for the next reply
22605packet from the target. The latest @samp{C}, @samp{c}, @samp{S} or
22606@samp{s} action is expected to be continued.
22607@xref{File-I/O remote protocol extension}, for more details.
22608
ee2d5c50
AC
22609@end table
22610
22611@node General Query Packets
22612@section General Query Packets
9c16f35a 22613@cindex remote query requests
c906108c 22614
8e04817f 22615The following set and query packets have already been defined.
c906108c 22616
ee2d5c50 22617@table @r
c906108c 22618
ee2d5c50 22619@item @code{q}@code{C} --- current thread
9c16f35a
EZ
22620@cindex current thread, remote request
22621@cindex @code{qC} packet
ee2d5c50
AC
22622Return the current thread id.
22623
22624Reply:
22625@table @samp
22626@item @code{QC}@var{pid}
e1aac25b 22627Where @var{pid} is an unsigned hexidecimal process id.
ee2d5c50
AC
22628@item *
22629Any other reply implies the old pid.
22630@end table
22631
22632@item @code{q}@code{fThreadInfo} -- all thread ids
9c16f35a
EZ
22633@cindex list active threads, remote request
22634@cindex @code{qfThreadInfo} packet
ee2d5c50 22635@code{q}@code{sThreadInfo}
c906108c 22636
8e04817f
AC
22637Obtain a list of active thread ids from the target (OS). Since there
22638may be too many active threads to fit into one reply packet, this query
22639works iteratively: it may require more than one query/reply sequence to
22640obtain the entire list of threads. The first query of the sequence will
22641be the @code{qf}@code{ThreadInfo} query; subsequent queries in the
22642sequence will be the @code{qs}@code{ThreadInfo} query.
ee2d5c50
AC
22643
22644NOTE: replaces the @code{qL} query (see below).
22645
22646Reply:
22647@table @samp
22648@item @code{m}@var{id}
22649A single thread id
22650@item @code{m}@var{id},@var{id}@dots{}
22651a comma-separated list of thread ids
22652@item @code{l}
22653(lower case 'el') denotes end of list.
22654@end table
22655
22656In response to each query, the target will reply with a list of one or
e1aac25b
JB
22657more thread ids, in big-endian unsigned hex, separated by commas.
22658@value{GDBN} will respond to each reply with a request for more thread
22659ids (using the @code{qs} form of the query), until the target responds
22660with @code{l} (lower-case el, for @code{'last'}).
c906108c 22661
ee2d5c50 22662@item @code{q}@code{ThreadExtraInfo}@code{,}@var{id} --- extra thread info
9c16f35a
EZ
22663@cindex thread attributes info, remote request
22664@cindex @code{qThreadExtraInfo} packet
ee2d5c50
AC
22665Where @var{id} is a thread-id in big-endian hex. Obtain a printable
22666string description of a thread's attributes from the target OS. This
22667string may contain anything that the target OS thinks is interesting for
22668@value{GDBN} to tell the user about the thread. The string is displayed
22669in @value{GDBN}'s @samp{info threads} display. Some examples of
22670possible thread extra info strings are ``Runnable'', or ``Blocked on
22671Mutex''.
22672
22673Reply:
22674@table @samp
22675@item @var{XX@dots{}}
22676Where @var{XX@dots{}} is a hex encoding of @sc{ascii} data, comprising
22677the printable string containing the extra information about the thread's
8e04817f 22678attributes.
ee2d5c50
AC
22679@end table
22680
22681@item @code{q}@code{L}@var{startflag}@var{threadcount}@var{nextthread} --- query @var{LIST} or @var{threadLIST} @strong{(deprecated)}
c906108c 22682
8e04817f
AC
22683Obtain thread information from RTOS. Where: @var{startflag} (one hex
22684digit) is one to indicate the first query and zero to indicate a
22685subsequent query; @var{threadcount} (two hex digits) is the maximum
22686number of threads the response packet can contain; and @var{nextthread}
22687(eight hex digits), for subsequent queries (@var{startflag} is zero), is
22688returned in the response as @var{argthread}.
ee2d5c50
AC
22689
22690NOTE: this query is replaced by the @code{q}@code{fThreadInfo} query
22691(see above).
22692
22693Reply:
22694@table @samp
22695@item @code{q}@code{M}@var{count}@var{done}@var{argthread}@var{thread@dots{}}
8e04817f
AC
22696Where: @var{count} (two hex digits) is the number of threads being
22697returned; @var{done} (one hex digit) is zero to indicate more threads
22698and one indicates no further threads; @var{argthreadid} (eight hex
ee2d5c50
AC
22699digits) is @var{nextthread} from the request packet; @var{thread@dots{}}
22700is a sequence of thread IDs from the target. @var{threadid} (eight hex
8e04817f 22701digits). See @code{remote.c:parse_threadlist_response()}.
ee2d5c50 22702@end table
c906108c 22703
ee2d5c50 22704@item @code{q}@code{CRC:}@var{addr}@code{,}@var{length} --- compute CRC of memory block
9c16f35a
EZ
22705@cindex CRC of memory block, remote request
22706@cindex @code{qCRC} packet
ee2d5c50
AC
22707Reply:
22708@table @samp
22709@item @code{E}@var{NN}
22710An error (such as memory fault)
22711@item @code{C}@var{CRC32}
22712A 32 bit cyclic redundancy check of the specified memory region.
22713@end table
22714
22715@item @code{q}@code{Offsets} --- query sect offs
9c16f35a
EZ
22716@cindex section offsets, remote request
22717@cindex @code{qOffsets} packet
8e04817f
AC
22718Get section offsets that the target used when re-locating the downloaded
22719image. @emph{Note: while a @code{Bss} offset is included in the
22720response, @value{GDBN} ignores this and instead applies the @code{Data}
22721offset to the @code{Bss} section.}
c906108c 22722
ee2d5c50
AC
22723Reply:
22724@table @samp
22725@item @code{Text=}@var{xxx}@code{;Data=}@var{yyy}@code{;Bss=}@var{zzz}
22726@end table
22727
22728@item @code{q}@code{P}@var{mode}@var{threadid} --- thread info request
9c16f35a
EZ
22729@cindex thread information, remote request
22730@cindex @code{qP} packet
8e04817f
AC
22731Returns information on @var{threadid}. Where: @var{mode} is a hex
22732encoded 32 bit mode; @var{threadid} is a hex encoded 64 bit thread ID.
ee2d5c50
AC
22733
22734Reply:
22735@table @samp
22736@item *
22737@end table
22738
8e04817f 22739See @code{remote.c:remote_unpack_thread_info_response()}.
c906108c 22740
ee2d5c50 22741@item @code{q}@code{Rcmd,}@var{command} --- remote command
9c16f35a
EZ
22742@cindex execute remote command, remote request
22743@cindex @code{qRcmd} packet
ee2d5c50 22744@var{command} (hex encoded) is passed to the local interpreter for
8e04817f
AC
22745execution. Invalid commands should be reported using the output string.
22746Before the final result packet, the target may also respond with a
ee2d5c50
AC
22747number of intermediate @code{O}@var{output} console output packets.
22748@emph{Implementors should note that providing access to a stubs's
22749interpreter may have security implications}.
22750
22751Reply:
22752@table @samp
22753@item OK
8e04817f 22754A command response with no output.
ee2d5c50 22755@item @var{OUTPUT}
8e04817f 22756A command response with the hex encoded output string @var{OUTPUT}.
ee2d5c50 22757@item @code{E}@var{NN}
8e04817f 22758Indicate a badly formed request.
ee2d5c50 22759@item @samp{}
8e04817f 22760When @samp{q}@samp{Rcmd} is not recognized.
ee2d5c50 22761@end table
9c16f35a 22762z
ee2d5c50 22763@item @code{qSymbol::} --- symbol lookup
9c16f35a
EZ
22764@cindex symbol lookup, remote request
22765@cindex @code{qSymbol} packet
8e04817f
AC
22766Notify the target that @value{GDBN} is prepared to serve symbol lookup
22767requests. Accept requests from the target for the values of symbols.
ee2d5c50
AC
22768
22769Reply:
22770@table @samp
22771@item @code{OK}
8e04817f 22772The target does not need to look up any (more) symbols.
ee2d5c50
AC
22773@item @code{qSymbol:}@var{sym_name}
22774The target requests the value of symbol @var{sym_name} (hex encoded).
22775@value{GDBN} may provide the value by using the
22776@code{qSymbol:}@var{sym_value}:@var{sym_name} message, described below.
22777@end table
22778
22779@item @code{qSymbol:}@var{sym_value}:@var{sym_name} --- symbol value
22780
22781Set the value of @var{sym_name} to @var{sym_value}.
22782
22783@var{sym_name} (hex encoded) is the name of a symbol whose value the
22784target has previously requested.
22785
22786@var{sym_value} (hex) is the value for symbol @var{sym_name}. If
22787@value{GDBN} cannot supply a value for @var{sym_name}, then this field
22788will be empty.
22789
22790Reply:
22791@table @samp
22792@item @code{OK}
8e04817f 22793The target does not need to look up any (more) symbols.
ee2d5c50
AC
22794@item @code{qSymbol:}@var{sym_name}
22795The target requests the value of a new symbol @var{sym_name} (hex
22796encoded). @value{GDBN} will continue to supply the values of symbols
22797(if available), until the target ceases to request them.
22798@end table
eb12ee30 22799
649e03f6 22800@item @code{qPart}:@var{object}:@code{read}:@var{annex}:@var{offset},@var{length} --- read special data
9c16f35a
EZ
22801@cindex read special object, remote request
22802@cindex @code{qPart} packet
649e03f6
RM
22803Read uninterpreted bytes from the target's special data area
22804identified by the keyword @code{object}.
22805Request @var{length} bytes starting at @var{offset} bytes into the data.
22806The content and encoding of @var{annex} is specific to the object;
22807it can supply additional details about what data to access.
22808
22809Here are the specific requests of this form defined so far.
22810All @samp{@code{qPart}:@var{object}:@code{read}:@dots{}}
22811requests use the same reply formats, listed below.
22812
22813@table @asis
22814@item @code{qPart}:@code{auxv}:@code{read}::@var{offset},@var{length}
721c2651
EZ
22815Access the target's @dfn{auxiliary vector}. @xref{OS Information,
22816auxiliary vector}, and see @ref{Remote configuration,
22817read-aux-vector-packet}. Note @var{annex} must be empty.
649e03f6
RM
22818@end table
22819
22820Reply:
22821@table @asis
22822@item @code{OK}
22823The @var{offset} in the request is at the end of the data.
22824There is no more data to be read.
22825
22826@item @var{XX@dots{}}
22827Hex encoded data bytes read.
22828This may be fewer bytes than the @var{length} in the request.
22829
22830@item @code{E00}
22831The request was malformed, or @var{annex} was invalid.
22832
22833@item @code{E}@var{nn}
22834The offset was invalid, or there was an error encountered reading the data.
22835@var{nn} is a hex-encoded @code{errno} value.
22836
22837@item @code{""} (empty)
22838An empty reply indicates the @var{object} or @var{annex} string was not
22839recognized by the stub.
22840@end table
22841
22842@item @code{qPart}:@var{object}:@code{write}:@var{annex}:@var{offset}:@var{data@dots{}}
9c16f35a 22843@cindex write data into object, remote request
649e03f6
RM
22844Write uninterpreted bytes into the target's special data area
22845identified by the keyword @code{object},
22846starting at @var{offset} bytes into the data.
22847@var{data@dots{}} is the hex-encoded data to be written.
22848The content and encoding of @var{annex} is specific to the object;
22849it can supply additional details about what data to access.
22850
22851No requests of this form are presently in use. This specification
22852serves as a placeholder to document the common format that new
22853specific request specifications ought to use.
22854
22855Reply:
22856@table @asis
22857@item @var{nn}
22858@var{nn} (hex encoded) is the number of bytes written.
22859This may be fewer bytes than supplied in the request.
22860
22861@item @code{E00}
22862The request was malformed, or @var{annex} was invalid.
22863
22864@item @code{E}@var{nn}
22865The offset was invalid, or there was an error encountered writing the data.
22866@var{nn} is a hex-encoded @code{errno} value.
22867
22868@item @code{""} (empty)
22869An empty reply indicates the @var{object} or @var{annex} string was not
22870recognized by the stub, or that the object does not support writing.
22871@end table
22872
22873@item @code{qPart}:@var{object}:@var{operation}:@dots{}
22874Requests of this form may be added in the future. When a stub does
22875not recognize the @var{object} keyword, or its support for
22876@var{object} does not recognize the @var{operation} keyword,
22877the stub must respond with an empty packet.
83761cbd
KB
22878
22879@item @code{qGetTLSAddr}:@var{thread-id},@var{offset},@var{lm} --- get thread local storage address
9c16f35a
EZ
22880@cindex get thread-local storage address, remote request
22881@cindex @code{qGetTLSAddr} packet
83761cbd
KB
22882Fetch the address associated with thread local storage specified
22883by @var{thread-id}, @var{offset}, and @var{lm}.
22884
22885@var{thread-id} is the (big endian, hex encoded) thread id associated with the
22886thread for which to fetch the TLS address.
22887
22888@var{offset} is the (big endian, hex encoded) offset associated with the
22889thread local variable. (This offset is obtained from the debug
22890information associated with the variable.)
22891
22892@var{lm} is the (big endian, hex encoded) OS/ABI specific encoding of the
22893the load module associated with the thread local storage. For example,
22894a @sc{gnu}/Linux system will pass the link map address of the shared
22895object associated with the thread local storage under consideration.
22896Other operating environments may choose to represent the load module
22897differently, so the precise meaning of this parameter will vary.
22898
22899Reply:
22900@table @asis
68c71a2e 22901@item @var{XX@dots{}}
83761cbd
KB
22902Hex encoded (big endian) bytes representing the address of the thread
22903local storage requested.
22904
22905@item @code{E}@var{nn} (where @var{nn} are hex digits)
22906An error occurred.
22907
22908@item @code{""} (empty)
22909An empty reply indicates that @code{qGetTLSAddr} is not supported by the stub.
22910@end table
22911
0abb7bc7
EZ
22912Use of this request packet is controlled by the @code{set remote
22913get-thread-local-storage-address} command (@pxref{Remote
22914configuration, set remote get-thread-local-storage-address}).
22915
ee2d5c50
AC
22916@end table
22917
22918@node Register Packet Format
22919@section Register Packet Format
eb12ee30 22920
8e04817f 22921The following @samp{g}/@samp{G} packets have previously been defined.
ee2d5c50
AC
22922In the below, some thirty-two bit registers are transferred as
22923sixty-four bits. Those registers should be zero/sign extended (which?)
22924to fill the space allocated. Register bytes are transfered in target
22925byte order. The two nibbles within a register byte are transfered
22926most-significant - least-significant.
eb12ee30 22927
ee2d5c50 22928@table @r
eb12ee30 22929
8e04817f 22930@item MIPS32
ee2d5c50 22931
8e04817f
AC
22932All registers are transfered as thirty-two bit quantities in the order:
2293332 general-purpose; sr; lo; hi; bad; cause; pc; 32 floating-point
22934registers; fsr; fir; fp.
eb12ee30 22935
8e04817f 22936@item MIPS64
ee2d5c50 22937
8e04817f
AC
22938All registers are transfered as sixty-four bit quantities (including
22939thirty-two bit registers such as @code{sr}). The ordering is the same
22940as @code{MIPS32}.
eb12ee30 22941
ee2d5c50
AC
22942@end table
22943
22944@node Examples
22945@section Examples
eb12ee30 22946
8e04817f
AC
22947Example sequence of a target being re-started. Notice how the restart
22948does not get any direct output:
eb12ee30 22949
474c8240 22950@smallexample
d2c6833e
AC
22951-> @code{R00}
22952<- @code{+}
8e04817f 22953@emph{target restarts}
d2c6833e 22954-> @code{?}
8e04817f 22955<- @code{+}
d2c6833e
AC
22956<- @code{T001:1234123412341234}
22957-> @code{+}
474c8240 22958@end smallexample
eb12ee30 22959
8e04817f 22960Example sequence of a target being stepped by a single instruction:
eb12ee30 22961
474c8240 22962@smallexample
d2c6833e 22963-> @code{G1445@dots{}}
8e04817f 22964<- @code{+}
d2c6833e
AC
22965-> @code{s}
22966<- @code{+}
22967@emph{time passes}
22968<- @code{T001:1234123412341234}
8e04817f 22969-> @code{+}
d2c6833e 22970-> @code{g}
8e04817f 22971<- @code{+}
d2c6833e
AC
22972<- @code{1455@dots{}}
22973-> @code{+}
474c8240 22974@end smallexample
eb12ee30 22975
0ce1b118
CV
22976@node File-I/O remote protocol extension
22977@section File-I/O remote protocol extension
22978@cindex File-I/O remote protocol extension
22979
22980@menu
22981* File-I/O Overview::
22982* Protocol basics::
1d8b2f28
JB
22983* The F request packet::
22984* The F reply packet::
0ce1b118
CV
22985* Memory transfer::
22986* The Ctrl-C message::
22987* Console I/O::
22988* The isatty call::
22989* The system call::
22990* List of supported calls::
22991* Protocol specific representation of datatypes::
22992* Constants::
22993* File-I/O Examples::
22994@end menu
22995
22996@node File-I/O Overview
22997@subsection File-I/O Overview
22998@cindex file-i/o overview
22999
9c16f35a
EZ
23000The @dfn{File I/O remote protocol extension} (short: File-I/O) allows the
23001target to use the host's file system and console I/O when calling various
0ce1b118
CV
23002system calls. System calls on the target system are translated into a
23003remote protocol packet to the host system which then performs the needed
23004actions and returns with an adequate response packet to the target system.
23005This simulates file system operations even on targets that lack file systems.
23006
23007The protocol is defined host- and target-system independent. It uses
9c16f35a 23008its own independent representation of datatypes and values. Both,
0ce1b118
CV
23009@value{GDBN} and the target's @value{GDBN} stub are responsible for
23010translating the system dependent values into the unified protocol values
23011when data is transmitted.
23012
23013The communication is synchronous. A system call is possible only
23014when GDB is waiting for the @samp{C}, @samp{c}, @samp{S} or @samp{s}
23015packets. While @value{GDBN} handles the request for a system call,
23016the target is stopped to allow deterministic access to the target's
23017memory. Therefore File-I/O is not interuptible by target signals. It
23018is possible to interrupt File-I/O by a user interrupt (Ctrl-C), though.
23019
23020The target's request to perform a host system call does not finish
23021the latest @samp{C}, @samp{c}, @samp{S} or @samp{s} action. That means,
23022after finishing the system call, the target returns to continuing the
23023previous activity (continue, step). No additional continue or step
23024request from @value{GDBN} is required.
23025
23026@smallexample
f7dc1244 23027(@value{GDBP}) continue
0ce1b118
CV
23028 <- target requests 'system call X'
23029 target is stopped, @value{GDBN} executes system call
23030 -> GDB returns result
23031 ... target continues, GDB returns to wait for the target
23032 <- target hits breakpoint and sends a Txx packet
23033@end smallexample
23034
23035The protocol is only used for files on the host file system and
23036for I/O on the console. Character or block special devices, pipes,
23037named pipes or sockets or any other communication method on the host
23038system are not supported by this protocol.
23039
23040@node Protocol basics
23041@subsection Protocol basics
23042@cindex protocol basics, file-i/o
23043
23044The File-I/O protocol uses the @code{F} packet, as request as well
23045as as reply packet. Since a File-I/O system call can only occur when
b383017d 23046@value{GDBN} is waiting for the continuing or stepping target, the
0ce1b118
CV
23047File-I/O request is a reply that @value{GDBN} has to expect as a result
23048of a former @samp{C}, @samp{c}, @samp{S} or @samp{s} packet.
23049This @code{F} packet contains all information needed to allow @value{GDBN}
23050to call the appropriate host system call:
23051
23052@itemize @bullet
b383017d 23053@item
0ce1b118
CV
23054A unique identifier for the requested system call.
23055
23056@item
23057All parameters to the system call. Pointers are given as addresses
23058in the target memory address space. Pointers to strings are given as
b383017d 23059pointer/length pair. Numerical values are given as they are.
0ce1b118
CV
23060Numerical control values are given in a protocol specific representation.
23061
23062@end itemize
23063
23064At that point @value{GDBN} has to perform the following actions.
23065
23066@itemize @bullet
b383017d 23067@item
0ce1b118
CV
23068If parameter pointer values are given, which point to data needed as input
23069to a system call, @value{GDBN} requests this data from the target with a
23070standard @code{m} packet request. This additional communication has to be
23071expected by the target implementation and is handled as any other @code{m}
23072packet.
23073
23074@item
23075@value{GDBN} translates all value from protocol representation to host
23076representation as needed. Datatypes are coerced into the host types.
23077
23078@item
23079@value{GDBN} calls the system call
23080
23081@item
23082It then coerces datatypes back to protocol representation.
23083
23084@item
23085If pointer parameters in the request packet point to buffer space in which
23086a system call is expected to copy data to, the data is transmitted to the
23087target using a @code{M} or @code{X} packet. This packet has to be expected
23088by the target implementation and is handled as any other @code{M} or @code{X}
23089packet.
23090
23091@end itemize
23092
23093Eventually @value{GDBN} replies with another @code{F} packet which contains all
23094necessary information for the target to continue. This at least contains
23095
23096@itemize @bullet
23097@item
23098Return value.
23099
23100@item
23101@code{errno}, if has been changed by the system call.
23102
23103@item
23104``Ctrl-C'' flag.
23105
23106@end itemize
23107
23108After having done the needed type and value coercion, the target continues
23109the latest continue or step action.
23110
1d8b2f28 23111@node The F request packet
0ce1b118
CV
23112@subsection The @code{F} request packet
23113@cindex file-i/o request packet
23114@cindex @code{F} request packet
23115
23116The @code{F} request packet has the following format:
23117
23118@table @samp
23119
23120@smallexample
23121@code{F}@var{call-id}@code{,}@var{parameter@dots{}}
23122@end smallexample
23123
23124@var{call-id} is the identifier to indicate the host system call to be called.
23125This is just the name of the function.
23126
23127@var{parameter@dots{}} are the parameters to the system call.
23128
b383017d 23129@end table
0ce1b118
CV
23130
23131Parameters are hexadecimal integer values, either the real values in case
23132of scalar datatypes, as pointers to target buffer space in case of compound
23133datatypes and unspecified memory areas or as pointer/length pairs in case
23134of string parameters. These are appended to the call-id, each separated
23135from its predecessor by a comma. All values are transmitted in ASCII
23136string representation, pointer/length pairs separated by a slash.
23137
1d8b2f28 23138@node The F reply packet
0ce1b118
CV
23139@subsection The @code{F} reply packet
23140@cindex file-i/o reply packet
23141@cindex @code{F} reply packet
23142
23143The @code{F} reply packet has the following format:
23144
23145@table @samp
23146
23147@smallexample
23148@code{F}@var{retcode}@code{,}@var{errno}@code{,}@var{Ctrl-C flag}@code{;}@var{call specific attachment}
23149@end smallexample
23150
23151@var{retcode} is the return code of the system call as hexadecimal value.
23152
23153@var{errno} is the errno set by the call, in protocol specific representation.
23154This parameter can be omitted if the call was successful.
23155
23156@var{Ctrl-C flag} is only send if the user requested a break. In this
23157case, @var{errno} must be send as well, even if the call was successful.
23158The @var{Ctrl-C flag} itself consists of the character 'C':
23159
23160@smallexample
23161F0,0,C
23162@end smallexample
23163
23164@noindent
23165or, if the call was interupted before the host call has been performed:
23166
23167@smallexample
23168F-1,4,C
23169@end smallexample
23170
23171@noindent
23172assuming 4 is the protocol specific representation of @code{EINTR}.
23173
23174@end table
23175
23176@node Memory transfer
23177@subsection Memory transfer
23178@cindex memory transfer, in file-i/o protocol
23179
23180Structured data which is transferred using a memory read or write as e.g.@:
23181a @code{struct stat} is expected to be in a protocol specific format with
23182all scalar multibyte datatypes being big endian. This should be done by
23183the target before the @code{F} packet is sent resp.@: by @value{GDBN} before
23184it transfers memory to the target. Transferred pointers to structured
23185data should point to the already coerced data at any time.
23186
23187@node The Ctrl-C message
23188@subsection The Ctrl-C message
23189@cindex ctrl-c message, in file-i/o protocol
23190
23191A special case is, if the @var{Ctrl-C flag} is set in the @value{GDBN}
23192reply packet. In this case the target should behave, as if it had
23193gotten a break message. The meaning for the target is ``system call
23194interupted by @code{SIGINT}''. Consequentially, the target should actually stop
23195(as with a break message) and return to @value{GDBN} with a @code{T02}
b383017d 23196packet. In this case, it's important for the target to know, in which
0ce1b118
CV
23197state the system call was interrupted. Since this action is by design
23198not an atomic operation, we have to differ between two cases:
23199
23200@itemize @bullet
23201@item
23202The system call hasn't been performed on the host yet.
23203
23204@item
23205The system call on the host has been finished.
23206
23207@end itemize
23208
23209These two states can be distinguished by the target by the value of the
23210returned @code{errno}. If it's the protocol representation of @code{EINTR}, the system
23211call hasn't been performed. This is equivalent to the @code{EINTR} handling
23212on POSIX systems. In any other case, the target may presume that the
23213system call has been finished --- successful or not --- and should behave
23214as if the break message arrived right after the system call.
23215
23216@value{GDBN} must behave reliable. If the system call has not been called
23217yet, @value{GDBN} may send the @code{F} reply immediately, setting @code{EINTR} as
23218@code{errno} in the packet. If the system call on the host has been finished
23219before the user requests a break, the full action must be finshed by
23220@value{GDBN}. This requires sending @code{M} or @code{X} packets as they fit.
23221The @code{F} packet may only be send when either nothing has happened
23222or the full action has been completed.
23223
23224@node Console I/O
23225@subsection Console I/O
23226@cindex console i/o as part of file-i/o
23227
23228By default and if not explicitely closed by the target system, the file
23229descriptors 0, 1 and 2 are connected to the @value{GDBN} console. Output
23230on the @value{GDBN} console is handled as any other file output operation
23231(@code{write(1, @dots{})} or @code{write(2, @dots{})}). Console input is handled
23232by @value{GDBN} so that after the target read request from file descriptor
232330 all following typing is buffered until either one of the following
23234conditions is met:
23235
23236@itemize @bullet
23237@item
23238The user presses @kbd{Ctrl-C}. The behaviour is as explained above, the
23239@code{read}
23240system call is treated as finished.
23241
23242@item
23243The user presses @kbd{Enter}. This is treated as end of input with a trailing
23244line feed.
23245
23246@item
23247The user presses @kbd{Ctrl-D}. This is treated as end of input. No trailing
23248character, especially no Ctrl-D is appended to the input.
23249
23250@end itemize
23251
23252If the user has typed more characters as fit in the buffer given to
23253the read call, the trailing characters are buffered in @value{GDBN} until
23254either another @code{read(0, @dots{})} is requested by the target or debugging
23255is stopped on users request.
23256
23257@node The isatty call
2eecc4ab 23258@subsection The @samp{isatty} function call
0ce1b118
CV
23259@cindex isatty call, file-i/o protocol
23260
23261A special case in this protocol is the library call @code{isatty} which
9c16f35a 23262is implemented as its own call inside of this protocol. It returns
0ce1b118
CV
232631 to the target if the file descriptor given as parameter is attached
23264to the @value{GDBN} console, 0 otherwise. Implementing through system calls
23265would require implementing @code{ioctl} and would be more complex than
23266needed.
23267
23268@node The system call
2eecc4ab 23269@subsection The @samp{system} function call
0ce1b118
CV
23270@cindex system call, file-i/o protocol
23271
23272The other special case in this protocol is the @code{system} call which
9c16f35a 23273is implemented as its own call, too. @value{GDBN} is taking over the full
0ce1b118
CV
23274task of calling the necessary host calls to perform the @code{system}
23275call. The return value of @code{system} is simplified before it's returned
23276to the target. Basically, the only signal transmitted back is @code{EINTR}
23277in case the user pressed @kbd{Ctrl-C}. Otherwise the return value consists
23278entirely of the exit status of the called command.
23279
9c16f35a
EZ
23280Due to security concerns, the @code{system} call is by default refused
23281by @value{GDBN}. The user has to allow this call explicitly with the
23282@kbd{set remote system-call-allowed 1} command.
0ce1b118 23283
9c16f35a
EZ
23284@table @code
23285@item set remote system-call-allowed
23286@kindex set remote system-call-allowed
23287Control whether to allow the @code{system} calls in the File I/O
23288protocol for the remote target. The default is zero (disabled).
0ce1b118 23289
9c16f35a 23290@item show remote system-call-allowed
0ce1b118 23291@kindex show remote system-call-allowed
9c16f35a
EZ
23292Show the current setting of system calls for the remote File I/O
23293protocol.
0ce1b118
CV
23294@end table
23295
23296@node List of supported calls
23297@subsection List of supported calls
23298@cindex list of supported file-i/o calls
23299
23300@menu
23301* open::
23302* close::
23303* read::
23304* write::
23305* lseek::
23306* rename::
23307* unlink::
23308* stat/fstat::
23309* gettimeofday::
23310* isatty::
23311* system::
23312@end menu
23313
23314@node open
23315@unnumberedsubsubsec open
23316@cindex open, file-i/o system call
23317
23318@smallexample
23319@exdent Synopsis:
23320int open(const char *pathname, int flags);
23321int open(const char *pathname, int flags, mode_t mode);
23322
b383017d 23323@exdent Request:
0ce1b118
CV
23324Fopen,pathptr/len,flags,mode
23325@end smallexample
23326
23327@noindent
23328@code{flags} is the bitwise or of the following values:
23329
23330@table @code
b383017d 23331@item O_CREAT
0ce1b118
CV
23332If the file does not exist it will be created. The host
23333rules apply as far as file ownership and time stamps
23334are concerned.
23335
b383017d 23336@item O_EXCL
0ce1b118
CV
23337When used with O_CREAT, if the file already exists it is
23338an error and open() fails.
23339
b383017d 23340@item O_TRUNC
0ce1b118
CV
23341If the file already exists and the open mode allows
23342writing (O_RDWR or O_WRONLY is given) it will be
23343truncated to length 0.
23344
b383017d 23345@item O_APPEND
0ce1b118
CV
23346The file is opened in append mode.
23347
b383017d 23348@item O_RDONLY
0ce1b118
CV
23349The file is opened for reading only.
23350
b383017d 23351@item O_WRONLY
0ce1b118
CV
23352The file is opened for writing only.
23353
b383017d 23354@item O_RDWR
0ce1b118
CV
23355The file is opened for reading and writing.
23356
23357@noindent
23358Each other bit is silently ignored.
23359
23360@end table
23361
23362@noindent
23363@code{mode} is the bitwise or of the following values:
23364
23365@table @code
b383017d 23366@item S_IRUSR
0ce1b118
CV
23367User has read permission.
23368
b383017d 23369@item S_IWUSR
0ce1b118
CV
23370User has write permission.
23371
b383017d 23372@item S_IRGRP
0ce1b118
CV
23373Group has read permission.
23374
b383017d 23375@item S_IWGRP
0ce1b118
CV
23376Group has write permission.
23377
b383017d 23378@item S_IROTH
0ce1b118
CV
23379Others have read permission.
23380
b383017d 23381@item S_IWOTH
0ce1b118
CV
23382Others have write permission.
23383
23384@noindent
23385Each other bit is silently ignored.
23386
23387@end table
23388
23389@smallexample
23390@exdent Return value:
23391open returns the new file descriptor or -1 if an error
23392occured.
23393
23394@exdent Errors:
23395@end smallexample
23396
23397@table @code
b383017d 23398@item EEXIST
0ce1b118
CV
23399pathname already exists and O_CREAT and O_EXCL were used.
23400
b383017d 23401@item EISDIR
0ce1b118
CV
23402pathname refers to a directory.
23403
b383017d 23404@item EACCES
0ce1b118
CV
23405The requested access is not allowed.
23406
23407@item ENAMETOOLONG
23408pathname was too long.
23409
b383017d 23410@item ENOENT
0ce1b118
CV
23411A directory component in pathname does not exist.
23412
b383017d 23413@item ENODEV
0ce1b118
CV
23414pathname refers to a device, pipe, named pipe or socket.
23415
b383017d 23416@item EROFS
0ce1b118
CV
23417pathname refers to a file on a read-only filesystem and
23418write access was requested.
23419
b383017d 23420@item EFAULT
0ce1b118
CV
23421pathname is an invalid pointer value.
23422
b383017d 23423@item ENOSPC
0ce1b118
CV
23424No space on device to create the file.
23425
b383017d 23426@item EMFILE
0ce1b118
CV
23427The process already has the maximum number of files open.
23428
b383017d 23429@item ENFILE
0ce1b118
CV
23430The limit on the total number of files open on the system
23431has been reached.
23432
b383017d 23433@item EINTR
0ce1b118
CV
23434The call was interrupted by the user.
23435@end table
23436
23437@node close
23438@unnumberedsubsubsec close
23439@cindex close, file-i/o system call
23440
23441@smallexample
b383017d 23442@exdent Synopsis:
0ce1b118
CV
23443int close(int fd);
23444
b383017d 23445@exdent Request:
0ce1b118
CV
23446Fclose,fd
23447
23448@exdent Return value:
23449close returns zero on success, or -1 if an error occurred.
23450
23451@exdent Errors:
23452@end smallexample
23453
23454@table @code
b383017d 23455@item EBADF
0ce1b118
CV
23456fd isn't a valid open file descriptor.
23457
b383017d 23458@item EINTR
0ce1b118
CV
23459The call was interrupted by the user.
23460@end table
23461
23462@node read
23463@unnumberedsubsubsec read
23464@cindex read, file-i/o system call
23465
23466@smallexample
b383017d 23467@exdent Synopsis:
0ce1b118
CV
23468int read(int fd, void *buf, unsigned int count);
23469
b383017d 23470@exdent Request:
0ce1b118
CV
23471Fread,fd,bufptr,count
23472
23473@exdent Return value:
23474On success, the number of bytes read is returned.
23475Zero indicates end of file. If count is zero, read
b383017d 23476returns zero as well. On error, -1 is returned.
0ce1b118
CV
23477
23478@exdent Errors:
23479@end smallexample
23480
23481@table @code
b383017d 23482@item EBADF
0ce1b118
CV
23483fd is not a valid file descriptor or is not open for
23484reading.
23485
b383017d 23486@item EFAULT
0ce1b118
CV
23487buf is an invalid pointer value.
23488
b383017d 23489@item EINTR
0ce1b118
CV
23490The call was interrupted by the user.
23491@end table
23492
23493@node write
23494@unnumberedsubsubsec write
23495@cindex write, file-i/o system call
23496
23497@smallexample
b383017d 23498@exdent Synopsis:
0ce1b118
CV
23499int write(int fd, const void *buf, unsigned int count);
23500
b383017d 23501@exdent Request:
0ce1b118
CV
23502Fwrite,fd,bufptr,count
23503
23504@exdent Return value:
23505On success, the number of bytes written are returned.
23506Zero indicates nothing was written. On error, -1
23507is returned.
23508
23509@exdent Errors:
23510@end smallexample
23511
23512@table @code
b383017d 23513@item EBADF
0ce1b118
CV
23514fd is not a valid file descriptor or is not open for
23515writing.
23516
b383017d 23517@item EFAULT
0ce1b118
CV
23518buf is an invalid pointer value.
23519
b383017d 23520@item EFBIG
0ce1b118
CV
23521An attempt was made to write a file that exceeds the
23522host specific maximum file size allowed.
23523
b383017d 23524@item ENOSPC
0ce1b118
CV
23525No space on device to write the data.
23526
b383017d 23527@item EINTR
0ce1b118
CV
23528The call was interrupted by the user.
23529@end table
23530
23531@node lseek
23532@unnumberedsubsubsec lseek
23533@cindex lseek, file-i/o system call
23534
23535@smallexample
b383017d 23536@exdent Synopsis:
0ce1b118
CV
23537long lseek (int fd, long offset, int flag);
23538
b383017d 23539@exdent Request:
0ce1b118
CV
23540Flseek,fd,offset,flag
23541@end smallexample
23542
23543@code{flag} is one of:
23544
23545@table @code
b383017d 23546@item SEEK_SET
0ce1b118
CV
23547The offset is set to offset bytes.
23548
b383017d 23549@item SEEK_CUR
0ce1b118
CV
23550The offset is set to its current location plus offset
23551bytes.
23552
b383017d 23553@item SEEK_END
0ce1b118
CV
23554The offset is set to the size of the file plus offset
23555bytes.
23556@end table
23557
23558@smallexample
23559@exdent Return value:
23560On success, the resulting unsigned offset in bytes from
23561the beginning of the file is returned. Otherwise, a
23562value of -1 is returned.
23563
23564@exdent Errors:
23565@end smallexample
23566
23567@table @code
b383017d 23568@item EBADF
0ce1b118
CV
23569fd is not a valid open file descriptor.
23570
b383017d 23571@item ESPIPE
0ce1b118
CV
23572fd is associated with the @value{GDBN} console.
23573
b383017d 23574@item EINVAL
0ce1b118
CV
23575flag is not a proper value.
23576
b383017d 23577@item EINTR
0ce1b118
CV
23578The call was interrupted by the user.
23579@end table
23580
23581@node rename
23582@unnumberedsubsubsec rename
23583@cindex rename, file-i/o system call
23584
23585@smallexample
b383017d 23586@exdent Synopsis:
0ce1b118
CV
23587int rename(const char *oldpath, const char *newpath);
23588
b383017d 23589@exdent Request:
0ce1b118
CV
23590Frename,oldpathptr/len,newpathptr/len
23591
23592@exdent Return value:
23593On success, zero is returned. On error, -1 is returned.
23594
23595@exdent Errors:
23596@end smallexample
23597
23598@table @code
b383017d 23599@item EISDIR
0ce1b118
CV
23600newpath is an existing directory, but oldpath is not a
23601directory.
23602
b383017d 23603@item EEXIST
0ce1b118
CV
23604newpath is a non-empty directory.
23605
b383017d 23606@item EBUSY
0ce1b118
CV
23607oldpath or newpath is a directory that is in use by some
23608process.
23609
b383017d 23610@item EINVAL
0ce1b118
CV
23611An attempt was made to make a directory a subdirectory
23612of itself.
23613
b383017d 23614@item ENOTDIR
0ce1b118
CV
23615A component used as a directory in oldpath or new
23616path is not a directory. Or oldpath is a directory
23617and newpath exists but is not a directory.
23618
b383017d 23619@item EFAULT
0ce1b118
CV
23620oldpathptr or newpathptr are invalid pointer values.
23621
b383017d 23622@item EACCES
0ce1b118
CV
23623No access to the file or the path of the file.
23624
23625@item ENAMETOOLONG
b383017d 23626
0ce1b118
CV
23627oldpath or newpath was too long.
23628
b383017d 23629@item ENOENT
0ce1b118
CV
23630A directory component in oldpath or newpath does not exist.
23631
b383017d 23632@item EROFS
0ce1b118
CV
23633The file is on a read-only filesystem.
23634
b383017d 23635@item ENOSPC
0ce1b118
CV
23636The device containing the file has no room for the new
23637directory entry.
23638
b383017d 23639@item EINTR
0ce1b118
CV
23640The call was interrupted by the user.
23641@end table
23642
23643@node unlink
23644@unnumberedsubsubsec unlink
23645@cindex unlink, file-i/o system call
23646
23647@smallexample
b383017d 23648@exdent Synopsis:
0ce1b118
CV
23649int unlink(const char *pathname);
23650
b383017d 23651@exdent Request:
0ce1b118
CV
23652Funlink,pathnameptr/len
23653
23654@exdent Return value:
23655On success, zero is returned. On error, -1 is returned.
23656
23657@exdent Errors:
23658@end smallexample
23659
23660@table @code
b383017d 23661@item EACCES
0ce1b118
CV
23662No access to the file or the path of the file.
23663
b383017d 23664@item EPERM
0ce1b118
CV
23665The system does not allow unlinking of directories.
23666
b383017d 23667@item EBUSY
0ce1b118
CV
23668The file pathname cannot be unlinked because it's
23669being used by another process.
23670
b383017d 23671@item EFAULT
0ce1b118
CV
23672pathnameptr is an invalid pointer value.
23673
23674@item ENAMETOOLONG
23675pathname was too long.
23676
b383017d 23677@item ENOENT
0ce1b118
CV
23678A directory component in pathname does not exist.
23679
b383017d 23680@item ENOTDIR
0ce1b118
CV
23681A component of the path is not a directory.
23682
b383017d 23683@item EROFS
0ce1b118
CV
23684The file is on a read-only filesystem.
23685
b383017d 23686@item EINTR
0ce1b118
CV
23687The call was interrupted by the user.
23688@end table
23689
23690@node stat/fstat
23691@unnumberedsubsubsec stat/fstat
23692@cindex fstat, file-i/o system call
23693@cindex stat, file-i/o system call
23694
23695@smallexample
b383017d 23696@exdent Synopsis:
0ce1b118
CV
23697int stat(const char *pathname, struct stat *buf);
23698int fstat(int fd, struct stat *buf);
23699
b383017d 23700@exdent Request:
0ce1b118
CV
23701Fstat,pathnameptr/len,bufptr
23702Ffstat,fd,bufptr
23703
23704@exdent Return value:
23705On success, zero is returned. On error, -1 is returned.
23706
23707@exdent Errors:
23708@end smallexample
23709
23710@table @code
b383017d 23711@item EBADF
0ce1b118
CV
23712fd is not a valid open file.
23713
b383017d 23714@item ENOENT
0ce1b118
CV
23715A directory component in pathname does not exist or the
23716path is an empty string.
23717
b383017d 23718@item ENOTDIR
0ce1b118
CV
23719A component of the path is not a directory.
23720
b383017d 23721@item EFAULT
0ce1b118
CV
23722pathnameptr is an invalid pointer value.
23723
b383017d 23724@item EACCES
0ce1b118
CV
23725No access to the file or the path of the file.
23726
23727@item ENAMETOOLONG
23728pathname was too long.
23729
b383017d 23730@item EINTR
0ce1b118
CV
23731The call was interrupted by the user.
23732@end table
23733
23734@node gettimeofday
23735@unnumberedsubsubsec gettimeofday
23736@cindex gettimeofday, file-i/o system call
23737
23738@smallexample
b383017d 23739@exdent Synopsis:
0ce1b118
CV
23740int gettimeofday(struct timeval *tv, void *tz);
23741
b383017d 23742@exdent Request:
0ce1b118
CV
23743Fgettimeofday,tvptr,tzptr
23744
23745@exdent Return value:
23746On success, 0 is returned, -1 otherwise.
23747
23748@exdent Errors:
23749@end smallexample
23750
23751@table @code
b383017d 23752@item EINVAL
0ce1b118
CV
23753tz is a non-NULL pointer.
23754
b383017d 23755@item EFAULT
0ce1b118
CV
23756tvptr and/or tzptr is an invalid pointer value.
23757@end table
23758
23759@node isatty
23760@unnumberedsubsubsec isatty
23761@cindex isatty, file-i/o system call
23762
23763@smallexample
b383017d 23764@exdent Synopsis:
0ce1b118
CV
23765int isatty(int fd);
23766
b383017d 23767@exdent Request:
0ce1b118
CV
23768Fisatty,fd
23769
23770@exdent Return value:
23771Returns 1 if fd refers to the @value{GDBN} console, 0 otherwise.
23772
23773@exdent Errors:
23774@end smallexample
23775
23776@table @code
b383017d 23777@item EINTR
0ce1b118
CV
23778The call was interrupted by the user.
23779@end table
23780
23781@node system
23782@unnumberedsubsubsec system
23783@cindex system, file-i/o system call
23784
23785@smallexample
b383017d 23786@exdent Synopsis:
0ce1b118
CV
23787int system(const char *command);
23788
b383017d 23789@exdent Request:
0ce1b118
CV
23790Fsystem,commandptr/len
23791
23792@exdent Return value:
23793The value returned is -1 on error and the return status
23794of the command otherwise. Only the exit status of the
23795command is returned, which is extracted from the hosts
23796system return value by calling WEXITSTATUS(retval).
23797In case /bin/sh could not be executed, 127 is returned.
23798
23799@exdent Errors:
23800@end smallexample
23801
23802@table @code
b383017d 23803@item EINTR
0ce1b118
CV
23804The call was interrupted by the user.
23805@end table
23806
23807@node Protocol specific representation of datatypes
23808@subsection Protocol specific representation of datatypes
23809@cindex protocol specific representation of datatypes, in file-i/o protocol
23810
23811@menu
23812* Integral datatypes::
23813* Pointer values::
23814* struct stat::
23815* struct timeval::
23816@end menu
23817
23818@node Integral datatypes
23819@unnumberedsubsubsec Integral datatypes
23820@cindex integral datatypes, in file-i/o protocol
23821
23822The integral datatypes used in the system calls are
23823
23824@smallexample
23825int@r{,} unsigned int@r{,} long@r{,} unsigned long@r{,} mode_t @r{and} time_t
23826@end smallexample
23827
23828@code{Int}, @code{unsigned int}, @code{mode_t} and @code{time_t} are
23829implemented as 32 bit values in this protocol.
23830
b383017d
RM
23831@code{Long} and @code{unsigned long} are implemented as 64 bit types.
23832
0ce1b118
CV
23833@xref{Limits}, for corresponding MIN and MAX values (similar to those
23834in @file{limits.h}) to allow range checking on host and target.
23835
23836@code{time_t} datatypes are defined as seconds since the Epoch.
23837
23838All integral datatypes transferred as part of a memory read or write of a
23839structured datatype e.g.@: a @code{struct stat} have to be given in big endian
23840byte order.
23841
23842@node Pointer values
23843@unnumberedsubsubsec Pointer values
23844@cindex pointer values, in file-i/o protocol
23845
23846Pointers to target data are transmitted as they are. An exception
23847is made for pointers to buffers for which the length isn't
23848transmitted as part of the function call, namely strings. Strings
23849are transmitted as a pointer/length pair, both as hex values, e.g.@:
23850
23851@smallexample
23852@code{1aaf/12}
23853@end smallexample
23854
23855@noindent
23856which is a pointer to data of length 18 bytes at position 0x1aaf.
23857The length is defined as the full string length in bytes, including
23858the trailing null byte. Example:
23859
23860@smallexample
23861``hello, world'' at address 0x123456
23862@end smallexample
23863
23864@noindent
23865is transmitted as
23866
23867@smallexample
23868@code{123456/d}
23869@end smallexample
23870
23871@node struct stat
23872@unnumberedsubsubsec struct stat
23873@cindex struct stat, in file-i/o protocol
23874
23875The buffer of type struct stat used by the target and @value{GDBN} is defined
23876as follows:
23877
23878@smallexample
23879struct stat @{
23880 unsigned int st_dev; /* device */
23881 unsigned int st_ino; /* inode */
23882 mode_t st_mode; /* protection */
23883 unsigned int st_nlink; /* number of hard links */
23884 unsigned int st_uid; /* user ID of owner */
23885 unsigned int st_gid; /* group ID of owner */
23886 unsigned int st_rdev; /* device type (if inode device) */
23887 unsigned long st_size; /* total size, in bytes */
23888 unsigned long st_blksize; /* blocksize for filesystem I/O */
23889 unsigned long st_blocks; /* number of blocks allocated */
23890 time_t st_atime; /* time of last access */
23891 time_t st_mtime; /* time of last modification */
23892 time_t st_ctime; /* time of last change */
23893@};
23894@end smallexample
23895
23896The integral datatypes are conforming to the definitions given in the
23897approriate section (see @ref{Integral datatypes}, for details) so this
23898structure is of size 64 bytes.
23899
23900The values of several fields have a restricted meaning and/or
23901range of values.
23902
23903@smallexample
23904st_dev: 0 file
23905 1 console
23906
23907st_ino: No valid meaning for the target. Transmitted unchanged.
23908
23909st_mode: Valid mode bits are described in Appendix C. Any other
23910 bits have currently no meaning for the target.
23911
23912st_uid: No valid meaning for the target. Transmitted unchanged.
23913
23914st_gid: No valid meaning for the target. Transmitted unchanged.
23915
23916st_rdev: No valid meaning for the target. Transmitted unchanged.
23917
23918st_atime, st_mtime, st_ctime:
23919 These values have a host and file system dependent
23920 accuracy. Especially on Windows hosts the file systems
23921 don't support exact timing values.
23922@end smallexample
23923
23924The target gets a struct stat of the above representation and is
23925responsible to coerce it to the target representation before
23926continuing.
23927
23928Note that due to size differences between the host and target
23929representation of stat members, these members could eventually
23930get truncated on the target.
23931
23932@node struct timeval
23933@unnumberedsubsubsec struct timeval
23934@cindex struct timeval, in file-i/o protocol
23935
23936The buffer of type struct timeval used by the target and @value{GDBN}
23937is defined as follows:
23938
23939@smallexample
b383017d 23940struct timeval @{
0ce1b118
CV
23941 time_t tv_sec; /* second */
23942 long tv_usec; /* microsecond */
23943@};
23944@end smallexample
23945
23946The integral datatypes are conforming to the definitions given in the
23947approriate section (see @ref{Integral datatypes}, for details) so this
23948structure is of size 8 bytes.
23949
23950@node Constants
23951@subsection Constants
23952@cindex constants, in file-i/o protocol
23953
23954The following values are used for the constants inside of the
23955protocol. @value{GDBN} and target are resposible to translate these
23956values before and after the call as needed.
23957
23958@menu
23959* Open flags::
23960* mode_t values::
23961* Errno values::
23962* Lseek flags::
23963* Limits::
23964@end menu
23965
23966@node Open flags
23967@unnumberedsubsubsec Open flags
23968@cindex open flags, in file-i/o protocol
23969
23970All values are given in hexadecimal representation.
23971
23972@smallexample
23973 O_RDONLY 0x0
23974 O_WRONLY 0x1
23975 O_RDWR 0x2
23976 O_APPEND 0x8
23977 O_CREAT 0x200
23978 O_TRUNC 0x400
23979 O_EXCL 0x800
23980@end smallexample
23981
23982@node mode_t values
23983@unnumberedsubsubsec mode_t values
23984@cindex mode_t values, in file-i/o protocol
23985
23986All values are given in octal representation.
23987
23988@smallexample
23989 S_IFREG 0100000
23990 S_IFDIR 040000
23991 S_IRUSR 0400
23992 S_IWUSR 0200
23993 S_IXUSR 0100
23994 S_IRGRP 040
23995 S_IWGRP 020
23996 S_IXGRP 010
23997 S_IROTH 04
23998 S_IWOTH 02
23999 S_IXOTH 01
24000@end smallexample
24001
24002@node Errno values
24003@unnumberedsubsubsec Errno values
24004@cindex errno values, in file-i/o protocol
24005
24006All values are given in decimal representation.
24007
24008@smallexample
24009 EPERM 1
24010 ENOENT 2
24011 EINTR 4
24012 EBADF 9
24013 EACCES 13
24014 EFAULT 14
24015 EBUSY 16
24016 EEXIST 17
24017 ENODEV 19
24018 ENOTDIR 20
24019 EISDIR 21
24020 EINVAL 22
24021 ENFILE 23
24022 EMFILE 24
24023 EFBIG 27
24024 ENOSPC 28
24025 ESPIPE 29
24026 EROFS 30
24027 ENAMETOOLONG 91
24028 EUNKNOWN 9999
24029@end smallexample
24030
24031 EUNKNOWN is used as a fallback error value if a host system returns
24032 any error value not in the list of supported error numbers.
24033
24034@node Lseek flags
24035@unnumberedsubsubsec Lseek flags
24036@cindex lseek flags, in file-i/o protocol
24037
24038@smallexample
24039 SEEK_SET 0
24040 SEEK_CUR 1
24041 SEEK_END 2
24042@end smallexample
24043
24044@node Limits
24045@unnumberedsubsubsec Limits
24046@cindex limits, in file-i/o protocol
24047
24048All values are given in decimal representation.
24049
24050@smallexample
24051 INT_MIN -2147483648
24052 INT_MAX 2147483647
24053 UINT_MAX 4294967295
24054 LONG_MIN -9223372036854775808
24055 LONG_MAX 9223372036854775807
24056 ULONG_MAX 18446744073709551615
24057@end smallexample
24058
24059@node File-I/O Examples
24060@subsection File-I/O Examples
24061@cindex file-i/o examples
24062
24063Example sequence of a write call, file descriptor 3, buffer is at target
24064address 0x1234, 6 bytes should be written:
24065
24066@smallexample
24067<- @code{Fwrite,3,1234,6}
24068@emph{request memory read from target}
24069-> @code{m1234,6}
24070<- XXXXXX
24071@emph{return "6 bytes written"}
24072-> @code{F6}
24073@end smallexample
24074
24075Example sequence of a read call, file descriptor 3, buffer is at target
24076address 0x1234, 6 bytes should be read:
24077
24078@smallexample
24079<- @code{Fread,3,1234,6}
24080@emph{request memory write to target}
24081-> @code{X1234,6:XXXXXX}
24082@emph{return "6 bytes read"}
24083-> @code{F6}
24084@end smallexample
24085
24086Example sequence of a read call, call fails on the host due to invalid
24087file descriptor (EBADF):
24088
24089@smallexample
24090<- @code{Fread,3,1234,6}
24091-> @code{F-1,9}
24092@end smallexample
24093
24094Example sequence of a read call, user presses Ctrl-C before syscall on
24095host is called:
24096
24097@smallexample
24098<- @code{Fread,3,1234,6}
24099-> @code{F-1,4,C}
24100<- @code{T02}
24101@end smallexample
24102
24103Example sequence of a read call, user presses Ctrl-C after syscall on
24104host is called:
24105
24106@smallexample
24107<- @code{Fread,3,1234,6}
24108-> @code{X1234,6:XXXXXX}
24109<- @code{T02}
24110@end smallexample
24111
f418dd93
DJ
24112@include agentexpr.texi
24113
aab4e0ec 24114@include gpl.texi
eb12ee30 24115
2154891a 24116@raisesections
6826cf00 24117@include fdl.texi
2154891a 24118@lowersections
6826cf00 24119
6d2ebf8b 24120@node Index
c906108c
SS
24121@unnumbered Index
24122
24123@printindex cp
24124
24125@tex
24126% I think something like @colophon should be in texinfo. In the
24127% meantime:
24128\long\def\colophon{\hbox to0pt{}\vfill
24129\centerline{The body of this manual is set in}
24130\centerline{\fontname\tenrm,}
24131\centerline{with headings in {\bf\fontname\tenbf}}
24132\centerline{and examples in {\tt\fontname\tentt}.}
24133\centerline{{\it\fontname\tenit\/},}
24134\centerline{{\bf\fontname\tenbf}, and}
24135\centerline{{\sl\fontname\tensl\/}}
24136\centerline{are used for emphasis.}\vfill}
24137\page\colophon
24138% Blame: doc@cygnus.com, 1991.
24139@end tex
24140
c906108c 24141@bye
This page took 1.851616 seconds and 4 git commands to generate.