OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gdb-6.8/] [pre-binutils-2.20.1-sync/] [gdb/] [doc/] [gdb.info-2] - Diff between revs 157 and 223

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 157 Rev 223
This is gdb.info, produced by makeinfo version 4.8 from
This is gdb.info, produced by makeinfo version 4.8 from
../.././gdb/doc/gdb.texinfo.
../.././gdb/doc/gdb.texinfo.
INFO-DIR-SECTION Software development
INFO-DIR-SECTION Software development
START-INFO-DIR-ENTRY
START-INFO-DIR-ENTRY
* Gdb: (gdb).                     The GNU debugger.
* Gdb: (gdb).                     The GNU debugger.
END-INFO-DIR-ENTRY
END-INFO-DIR-ENTRY
   This file documents the GNU debugger GDB.
   This file documents the GNU debugger GDB.
   This is the Ninth Edition, of `Debugging with GDB: the GNU
   This is the Ninth Edition, of `Debugging with GDB: the GNU
Source-Level Debugger' for GDB Version 6.8.
Source-Level Debugger' for GDB Version 6.8.
   Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
   Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
1998,
1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
Free Software Foundation, Inc.
   Permission is granted to copy, distribute and/or modify this document
   Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with the
any later version published by the Free Software Foundation; with the
Invariant Sections being "Free Software" and "Free Software Needs Free
Invariant Sections being "Free Software" and "Free Software Needs Free
Documentation", with the Front-Cover Texts being "A GNU Manual," and
Documentation", with the Front-Cover Texts being "A GNU Manual," and
with the Back-Cover Texts as in (a) below.
with the Back-Cover Texts as in (a) below.
   (a) The FSF's Back-Cover Text is: "You are free to copy and modify
   (a) The FSF's Back-Cover Text is: "You are free to copy and modify
this GNU Manual.  Buying copies from GNU Press supports the FSF in
this GNU Manual.  Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom."
developing GNU and promoting software freedom."


File: gdb.info,  Node: Automatic Overlay Debugging,  Next: Overlay Sample Program,  Prev: Overlay Commands,  Up: Overlays
File: gdb.info,  Node: Automatic Overlay Debugging,  Next: Overlay Sample Program,  Prev: Overlay Commands,  Up: Overlays
11.3 Automatic Overlay Debugging
11.3 Automatic Overlay Debugging
================================
================================
GDB can automatically track which overlays are mapped and which are
GDB can automatically track which overlays are mapped and which are
not, given some simple co-operation from the overlay manager in the
not, given some simple co-operation from the overlay manager in the
inferior.  If you enable automatic overlay debugging with the `overlay
inferior.  If you enable automatic overlay debugging with the `overlay
auto' command (*note Overlay Commands::), GDB looks in the inferior's
auto' command (*note Overlay Commands::), GDB looks in the inferior's
memory for certain variables describing the current state of the
memory for certain variables describing the current state of the
overlays.
overlays.
   Here are the variables your overlay manager must define to support
   Here are the variables your overlay manager must define to support
GDB's automatic overlay debugging:
GDB's automatic overlay debugging:
`_ovly_table':
`_ovly_table':
     This variable must be an array of the following structures:
     This variable must be an array of the following structures:
          struct
          struct
          {
          {
            /* The overlay's mapped address.  */
            /* The overlay's mapped address.  */
            unsigned long vma;
            unsigned long vma;
            /* The size of the overlay, in bytes.  */
            /* The size of the overlay, in bytes.  */
            unsigned long size;
            unsigned long size;
            /* The overlay's load address.  */
            /* The overlay's load address.  */
            unsigned long lma;
            unsigned long lma;
            /* Non-zero if the overlay is currently mapped;
            /* Non-zero if the overlay is currently mapped;
               zero otherwise.  */
               zero otherwise.  */
            unsigned long mapped;
            unsigned long mapped;
          }
          }
`_novlys':
`_novlys':
     This variable must be a four-byte signed integer, holding the total
     This variable must be a four-byte signed integer, holding the total
     number of elements in `_ovly_table'.
     number of elements in `_ovly_table'.
   To decide whether a particular overlay is mapped or not, GDB looks
   To decide whether a particular overlay is mapped or not, GDB looks
for an entry in `_ovly_table' whose `vma' and `lma' members equal the
for an entry in `_ovly_table' whose `vma' and `lma' members equal the
VMA and LMA of the overlay's section in the executable file.  When GDB
VMA and LMA of the overlay's section in the executable file.  When GDB
finds a matching entry, it consults the entry's `mapped' member to
finds a matching entry, it consults the entry's `mapped' member to
determine whether the overlay is currently mapped.
determine whether the overlay is currently mapped.
   In addition, your overlay manager may define a function called
   In addition, your overlay manager may define a function called
`_ovly_debug_event'.  If this function is defined, GDB will silently
`_ovly_debug_event'.  If this function is defined, GDB will silently
set a breakpoint there.  If the overlay manager then calls this
set a breakpoint there.  If the overlay manager then calls this
function whenever it has changed the overlay table, this will enable
function whenever it has changed the overlay table, this will enable
GDB to accurately keep track of which overlays are in program memory,
GDB to accurately keep track of which overlays are in program memory,
and update any breakpoints that may be set in overlays.  This will
and update any breakpoints that may be set in overlays.  This will
allow breakpoints to work even if the overlays are kept in ROM or other
allow breakpoints to work even if the overlays are kept in ROM or other
non-writable memory while they are not being executed.
non-writable memory while they are not being executed.


File: gdb.info,  Node: Overlay Sample Program,  Prev: Automatic Overlay Debugging,  Up: Overlays
File: gdb.info,  Node: Overlay Sample Program,  Prev: Automatic Overlay Debugging,  Up: Overlays
11.4 Overlay Sample Program
11.4 Overlay Sample Program
===========================
===========================
When linking a program which uses overlays, you must place the overlays
When linking a program which uses overlays, you must place the overlays
at their load addresses, while relocating them to run at their mapped
at their load addresses, while relocating them to run at their mapped
addresses.  To do this, you must write a linker script (*note Overlay
addresses.  To do this, you must write a linker script (*note Overlay
Description: (ld.info)Overlay Description.).  Unfortunately, since
Description: (ld.info)Overlay Description.).  Unfortunately, since
linker scripts are specific to a particular host system, target
linker scripts are specific to a particular host system, target
architecture, and target memory layout, this manual cannot provide
architecture, and target memory layout, this manual cannot provide
portable sample code demonstrating GDB's overlay support.
portable sample code demonstrating GDB's overlay support.
   However, the GDB source distribution does contain an overlaid
   However, the GDB source distribution does contain an overlaid
program, with linker scripts for a few systems, as part of its test
program, with linker scripts for a few systems, as part of its test
suite.  The program consists of the following files from
suite.  The program consists of the following files from
`gdb/testsuite/gdb.base':
`gdb/testsuite/gdb.base':
`overlays.c'
`overlays.c'
     The main program file.
     The main program file.
`ovlymgr.c'
`ovlymgr.c'
     A simple overlay manager, used by `overlays.c'.
     A simple overlay manager, used by `overlays.c'.
`foo.c'
`foo.c'
`bar.c'
`bar.c'
`baz.c'
`baz.c'
`grbx.c'
`grbx.c'
     Overlay modules, loaded and used by `overlays.c'.
     Overlay modules, loaded and used by `overlays.c'.
`d10v.ld'
`d10v.ld'
`m32r.ld'
`m32r.ld'
     Linker scripts for linking the test program on the `d10v-elf' and
     Linker scripts for linking the test program on the `d10v-elf' and
     `m32r-elf' targets.
     `m32r-elf' targets.
   You can build the test program using the `d10v-elf' GCC
   You can build the test program using the `d10v-elf' GCC
cross-compiler like this:
cross-compiler like this:
     $ d10v-elf-gcc -g -c overlays.c
     $ d10v-elf-gcc -g -c overlays.c
     $ d10v-elf-gcc -g -c ovlymgr.c
     $ d10v-elf-gcc -g -c ovlymgr.c
     $ d10v-elf-gcc -g -c foo.c
     $ d10v-elf-gcc -g -c foo.c
     $ d10v-elf-gcc -g -c bar.c
     $ d10v-elf-gcc -g -c bar.c
     $ d10v-elf-gcc -g -c baz.c
     $ d10v-elf-gcc -g -c baz.c
     $ d10v-elf-gcc -g -c grbx.c
     $ d10v-elf-gcc -g -c grbx.c
     $ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \
     $ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \
                       baz.o grbx.o -Wl,-Td10v.ld -o overlays
                       baz.o grbx.o -Wl,-Td10v.ld -o overlays
   The build process is identical for any other architecture, except
   The build process is identical for any other architecture, except
that you must substitute the appropriate compiler and linker script for
that you must substitute the appropriate compiler and linker script for
the target system for `d10v-elf-gcc' and `d10v.ld'.
the target system for `d10v-elf-gcc' and `d10v.ld'.


File: gdb.info,  Node: Languages,  Next: Symbols,  Prev: Overlays,  Up: Top
File: gdb.info,  Node: Languages,  Next: Symbols,  Prev: Overlays,  Up: Top
12 Using GDB with Different Languages
12 Using GDB with Different Languages
*************************************
*************************************
Although programming languages generally have common aspects, they are
Although programming languages generally have common aspects, they are
rarely expressed in the same manner.  For instance, in ANSI C,
rarely expressed in the same manner.  For instance, in ANSI C,
dereferencing a pointer `p' is accomplished by `*p', but in Modula-2,
dereferencing a pointer `p' is accomplished by `*p', but in Modula-2,
it is accomplished by `p^'.  Values can also be represented (and
it is accomplished by `p^'.  Values can also be represented (and
displayed) differently.  Hex numbers in C appear as `0x1ae', while in
displayed) differently.  Hex numbers in C appear as `0x1ae', while in
Modula-2 they appear as `1AEH'.
Modula-2 they appear as `1AEH'.
   Language-specific information is built into GDB for some languages,
   Language-specific information is built into GDB for some languages,
allowing you to express operations like the above in your program's
allowing you to express operations like the above in your program's
native language, and allowing GDB to output values in a manner
native language, and allowing GDB to output values in a manner
consistent with the syntax of your program's native language.  The
consistent with the syntax of your program's native language.  The
language you use to build expressions is called the "working language".
language you use to build expressions is called the "working language".
* Menu:
* Menu:
* Setting::                     Switching between source languages
* Setting::                     Switching between source languages
* Show::                        Displaying the language
* Show::                        Displaying the language
* Checks::                      Type and range checks
* Checks::                      Type and range checks
* Supported Languages::         Supported languages
* Supported Languages::         Supported languages
* Unsupported Languages::       Unsupported languages
* Unsupported Languages::       Unsupported languages


File: gdb.info,  Node: Setting,  Next: Show,  Up: Languages
File: gdb.info,  Node: Setting,  Next: Show,  Up: Languages
12.1 Switching Between Source Languages
12.1 Switching Between Source Languages
=======================================
=======================================
There are two ways to control the working language--either have GDB set
There are two ways to control the working language--either have GDB set
it automatically, or select it manually yourself.  You can use the `set
it automatically, or select it manually yourself.  You can use the `set
language' command for either purpose.  On startup, GDB defaults to
language' command for either purpose.  On startup, GDB defaults to
setting the language automatically.  The working language is used to
setting the language automatically.  The working language is used to
determine how expressions you type are interpreted, how values are
determine how expressions you type are interpreted, how values are
printed, etc.
printed, etc.
   In addition to the working language, every source file that GDB
   In addition to the working language, every source file that GDB
knows about has its own working language.  For some object file
knows about has its own working language.  For some object file
formats, the compiler might indicate which language a particular source
formats, the compiler might indicate which language a particular source
file is in.  However, most of the time GDB infers the language from the
file is in.  However, most of the time GDB infers the language from the
name of the file.  The language of a source file controls whether C++
name of the file.  The language of a source file controls whether C++
names are demangled--this way `backtrace' can show each frame
names are demangled--this way `backtrace' can show each frame
appropriately for its own language.  There is no way to set the
appropriately for its own language.  There is no way to set the
language of a source file from within GDB, but you can set the language
language of a source file from within GDB, but you can set the language
associated with a filename extension.  *Note Displaying the Language:
associated with a filename extension.  *Note Displaying the Language:
Show.
Show.
   This is most commonly a problem when you use a program, such as
   This is most commonly a problem when you use a program, such as
`cfront' or `f2c', that generates C but is written in another language.
`cfront' or `f2c', that generates C but is written in another language.
In that case, make the program use `#line' directives in its C output;
In that case, make the program use `#line' directives in its C output;
that way GDB will know the correct language of the source code of the
that way GDB will know the correct language of the source code of the
original program, and will display that source code, not the generated
original program, and will display that source code, not the generated
C code.
C code.
* Menu:
* Menu:
* Filenames::                   Filename extensions and languages.
* Filenames::                   Filename extensions and languages.
* Manually::                    Setting the working language manually
* Manually::                    Setting the working language manually
* Automatically::               Having GDB infer the source language
* Automatically::               Having GDB infer the source language


File: gdb.info,  Node: Filenames,  Next: Manually,  Up: Setting
File: gdb.info,  Node: Filenames,  Next: Manually,  Up: Setting
12.1.1 List of Filename Extensions and Languages
12.1.1 List of Filename Extensions and Languages
------------------------------------------------
------------------------------------------------
If a source file name ends in one of the following extensions, then GDB
If a source file name ends in one of the following extensions, then GDB
infers that its language is the one indicated.
infers that its language is the one indicated.
`.ada'
`.ada'
`.ads'
`.ads'
`.adb'
`.adb'
`.a'
`.a'
     Ada source file.
     Ada source file.
`.c'
`.c'
     C source file
     C source file
`.C'
`.C'
`.cc'
`.cc'
`.cp'
`.cp'
`.cpp'
`.cpp'
`.cxx'
`.cxx'
`.c++'
`.c++'
     C++ source file
     C++ source file
`.m'
`.m'
     Objective-C source file
     Objective-C source file
`.f'
`.f'
`.F'
`.F'
     Fortran source file
     Fortran source file
`.mod'
`.mod'
     Modula-2 source file
     Modula-2 source file
`.s'
`.s'
`.S'
`.S'
     Assembler source file.  This actually behaves almost like C, but
     Assembler source file.  This actually behaves almost like C, but
     GDB does not skip over function prologues when stepping.
     GDB does not skip over function prologues when stepping.
   In addition, you may set the language associated with a filename
   In addition, you may set the language associated with a filename
extension.  *Note Displaying the Language: Show.
extension.  *Note Displaying the Language: Show.


File: gdb.info,  Node: Manually,  Next: Automatically,  Prev: Filenames,  Up: Setting
File: gdb.info,  Node: Manually,  Next: Automatically,  Prev: Filenames,  Up: Setting
12.1.2 Setting the Working Language
12.1.2 Setting the Working Language
-----------------------------------
-----------------------------------
If you allow GDB to set the language automatically, expressions are
If you allow GDB to set the language automatically, expressions are
interpreted the same way in your debugging session and your program.
interpreted the same way in your debugging session and your program.
   If you wish, you may set the language manually.  To do this, issue
   If you wish, you may set the language manually.  To do this, issue
the command `set language LANG', where LANG is the name of a language,
the command `set language LANG', where LANG is the name of a language,
such as `c' or `modula-2'.  For a list of the supported languages, type
such as `c' or `modula-2'.  For a list of the supported languages, type
`set language'.
`set language'.
   Setting the language manually prevents GDB from updating the working
   Setting the language manually prevents GDB from updating the working
language automatically.  This can lead to confusion if you try to debug
language automatically.  This can lead to confusion if you try to debug
a program when the working language is not the same as the source
a program when the working language is not the same as the source
language, when an expression is acceptable to both languages--but means
language, when an expression is acceptable to both languages--but means
different things.  For instance, if the current source file were
different things.  For instance, if the current source file were
written in C, and GDB was parsing Modula-2, a command such as:
written in C, and GDB was parsing Modula-2, a command such as:
     print a = b + c
     print a = b + c
might not have the effect you intended.  In C, this means to add `b'
might not have the effect you intended.  In C, this means to add `b'
and `c' and place the result in `a'.  The result printed would be the
and `c' and place the result in `a'.  The result printed would be the
value of `a'.  In Modula-2, this means to compare `a' to the result of
value of `a'.  In Modula-2, this means to compare `a' to the result of
`b+c', yielding a `BOOLEAN' value.
`b+c', yielding a `BOOLEAN' value.


File: gdb.info,  Node: Automatically,  Prev: Manually,  Up: Setting
File: gdb.info,  Node: Automatically,  Prev: Manually,  Up: Setting
12.1.3 Having GDB Infer the Source Language
12.1.3 Having GDB Infer the Source Language
-------------------------------------------
-------------------------------------------
To have GDB set the working language automatically, use `set language
To have GDB set the working language automatically, use `set language
local' or `set language auto'.  GDB then infers the working language.
local' or `set language auto'.  GDB then infers the working language.
That is, when your program stops in a frame (usually by encountering a
That is, when your program stops in a frame (usually by encountering a
breakpoint), GDB sets the working language to the language recorded for
breakpoint), GDB sets the working language to the language recorded for
the function in that frame.  If the language for a frame is unknown
the function in that frame.  If the language for a frame is unknown
(that is, if the function or block corresponding to the frame was
(that is, if the function or block corresponding to the frame was
defined in a source file that does not have a recognized extension),
defined in a source file that does not have a recognized extension),
the current working language is not changed, and GDB issues a warning.
the current working language is not changed, and GDB issues a warning.
   This may not seem necessary for most programs, which are written
   This may not seem necessary for most programs, which are written
entirely in one source language.  However, program modules and libraries
entirely in one source language.  However, program modules and libraries
written in one source language can be used by a main program written in
written in one source language can be used by a main program written in
a different source language.  Using `set language auto' in this case
a different source language.  Using `set language auto' in this case
frees you from having to set the working language manually.
frees you from having to set the working language manually.


File: gdb.info,  Node: Show,  Next: Checks,  Prev: Setting,  Up: Languages
File: gdb.info,  Node: Show,  Next: Checks,  Prev: Setting,  Up: Languages
12.2 Displaying the Language
12.2 Displaying the Language
============================
============================
The following commands help you find out which language is the working
The following commands help you find out which language is the working
language, and also what language source files were written in.
language, and also what language source files were written in.
`show language'
`show language'
     Display the current working language.  This is the language you
     Display the current working language.  This is the language you
     can use with commands such as `print' to build and compute
     can use with commands such as `print' to build and compute
     expressions that may involve variables in your program.
     expressions that may involve variables in your program.
`info frame'
`info frame'
     Display the source language for this frame.  This language becomes
     Display the source language for this frame.  This language becomes
     the working language if you use an identifier from this frame.
     the working language if you use an identifier from this frame.
     *Note Information about a Frame: Frame Info, to identify the other
     *Note Information about a Frame: Frame Info, to identify the other
     information listed here.
     information listed here.
`info source'
`info source'
     Display the source language of this source file.  *Note Examining
     Display the source language of this source file.  *Note Examining
     the Symbol Table: Symbols, to identify the other information
     the Symbol Table: Symbols, to identify the other information
     listed here.
     listed here.
   In unusual circumstances, you may have source files with extensions
   In unusual circumstances, you may have source files with extensions
not in the standard list.  You can then set the extension associated
not in the standard list.  You can then set the extension associated
with a language explicitly:
with a language explicitly:
`set extension-language EXT LANGUAGE'
`set extension-language EXT LANGUAGE'
     Tell GDB that source files with extension EXT are to be assumed as
     Tell GDB that source files with extension EXT are to be assumed as
     written in the source language LANGUAGE.
     written in the source language LANGUAGE.
`info extensions'
`info extensions'
     List all the filename extensions and the associated languages.
     List all the filename extensions and the associated languages.


File: gdb.info,  Node: Checks,  Next: Supported Languages,  Prev: Show,  Up: Languages
File: gdb.info,  Node: Checks,  Next: Supported Languages,  Prev: Show,  Up: Languages
12.3 Type and Range Checking
12.3 Type and Range Checking
============================
============================
     _Warning:_ In this release, the GDB commands for type and range
     _Warning:_ In this release, the GDB commands for type and range
     checking are included, but they do not yet have any effect.  This
     checking are included, but they do not yet have any effect.  This
     section documents the intended facilities.
     section documents the intended facilities.
   Some languages are designed to guard you against making seemingly
   Some languages are designed to guard you against making seemingly
common errors through a series of compile- and run-time checks.  These
common errors through a series of compile- and run-time checks.  These
include checking the type of arguments to functions and operators, and
include checking the type of arguments to functions and operators, and
making sure mathematical overflows are caught at run time.  Checks such
making sure mathematical overflows are caught at run time.  Checks such
as these help to ensure a program's correctness once it has been
as these help to ensure a program's correctness once it has been
compiled by eliminating type mismatches, and providing active checks
compiled by eliminating type mismatches, and providing active checks
for range errors when your program is running.
for range errors when your program is running.
   GDB can check for conditions like the above if you wish.  Although
   GDB can check for conditions like the above if you wish.  Although
GDB does not check the statements in your program, it can check
GDB does not check the statements in your program, it can check
expressions entered directly into GDB for evaluation via the `print'
expressions entered directly into GDB for evaluation via the `print'
command, for example.  As with the working language, GDB can also
command, for example.  As with the working language, GDB can also
decide whether or not to check automatically based on your program's
decide whether or not to check automatically based on your program's
source language.  *Note Supported Languages: Supported Languages, for
source language.  *Note Supported Languages: Supported Languages, for
the default settings of supported languages.
the default settings of supported languages.
* Menu:
* Menu:
* Type Checking::               An overview of type checking
* Type Checking::               An overview of type checking
* Range Checking::              An overview of range checking
* Range Checking::              An overview of range checking


File: gdb.info,  Node: Type Checking,  Next: Range Checking,  Up: Checks
File: gdb.info,  Node: Type Checking,  Next: Range Checking,  Up: Checks
12.3.1 An Overview of Type Checking
12.3.1 An Overview of Type Checking
-----------------------------------
-----------------------------------
Some languages, such as Modula-2, are strongly typed, meaning that the
Some languages, such as Modula-2, are strongly typed, meaning that the
arguments to operators and functions have to be of the correct type,
arguments to operators and functions have to be of the correct type,
otherwise an error occurs.  These checks prevent type mismatch errors
otherwise an error occurs.  These checks prevent type mismatch errors
from ever causing any run-time problems.  For example,
from ever causing any run-time problems.  For example,
     1 + 2 => 3
     1 + 2 => 3
but
but
     error--> 1 + 2.3
     error--> 1 + 2.3
   The second example fails because the `CARDINAL' 1 is not
   The second example fails because the `CARDINAL' 1 is not
type-compatible with the `REAL' 2.3.
type-compatible with the `REAL' 2.3.
   For the expressions you use in GDB commands, you can tell the GDB
   For the expressions you use in GDB commands, you can tell the GDB
type checker to skip checking; to treat any mismatches as errors and
type checker to skip checking; to treat any mismatches as errors and
abandon the expression; or to only issue warnings when type mismatches
abandon the expression; or to only issue warnings when type mismatches
occur, but evaluate the expression anyway.  When you choose the last of
occur, but evaluate the expression anyway.  When you choose the last of
these, GDB evaluates expressions like the second example above, but
these, GDB evaluates expressions like the second example above, but
also issues a warning.
also issues a warning.
   Even if you turn type checking off, there may be other reasons
   Even if you turn type checking off, there may be other reasons
related to type that prevent GDB from evaluating an expression.  For
related to type that prevent GDB from evaluating an expression.  For
instance, GDB does not know how to add an `int' and a `struct foo'.
instance, GDB does not know how to add an `int' and a `struct foo'.
These particular type errors have nothing to do with the language in
These particular type errors have nothing to do with the language in
use, and usually arise from expressions, such as the one described
use, and usually arise from expressions, such as the one described
above, which make little sense to evaluate anyway.
above, which make little sense to evaluate anyway.
   Each language defines to what degree it is strict about type.  For
   Each language defines to what degree it is strict about type.  For
instance, both Modula-2 and C require the arguments to arithmetical
instance, both Modula-2 and C require the arguments to arithmetical
operators to be numbers.  In C, enumerated types and pointers can be
operators to be numbers.  In C, enumerated types and pointers can be
represented as numbers, so that they are valid arguments to mathematical
represented as numbers, so that they are valid arguments to mathematical
operators.  *Note Supported Languages: Supported Languages, for further
operators.  *Note Supported Languages: Supported Languages, for further
details on specific languages.
details on specific languages.
   GDB provides some additional commands for controlling the type
   GDB provides some additional commands for controlling the type
checker:
checker:
`set check type auto'
`set check type auto'
     Set type checking on or off based on the current working language.
     Set type checking on or off based on the current working language.
     *Note Supported Languages: Supported Languages, for the default
     *Note Supported Languages: Supported Languages, for the default
     settings for each language.
     settings for each language.
`set check type on'
`set check type on'
`set check type off'
`set check type off'
     Set type checking on or off, overriding the default setting for the
     Set type checking on or off, overriding the default setting for the
     current working language.  Issue a warning if the setting does not
     current working language.  Issue a warning if the setting does not
     match the language default.  If any type mismatches occur in
     match the language default.  If any type mismatches occur in
     evaluating an expression while type checking is on, GDB prints a
     evaluating an expression while type checking is on, GDB prints a
     message and aborts evaluation of the expression.
     message and aborts evaluation of the expression.
`set check type warn'
`set check type warn'
     Cause the type checker to issue warnings, but to always attempt to
     Cause the type checker to issue warnings, but to always attempt to
     evaluate the expression.  Evaluating the expression may still be
     evaluate the expression.  Evaluating the expression may still be
     impossible for other reasons.  For example, GDB cannot add numbers
     impossible for other reasons.  For example, GDB cannot add numbers
     and structures.
     and structures.
`show type'
`show type'
     Show the current setting of the type checker, and whether or not
     Show the current setting of the type checker, and whether or not
     GDB is setting it automatically.
     GDB is setting it automatically.


File: gdb.info,  Node: Range Checking,  Prev: Type Checking,  Up: Checks
File: gdb.info,  Node: Range Checking,  Prev: Type Checking,  Up: Checks
12.3.2 An Overview of Range Checking
12.3.2 An Overview of Range Checking
------------------------------------
------------------------------------
In some languages (such as Modula-2), it is an error to exceed the
In some languages (such as Modula-2), it is an error to exceed the
bounds of a type; this is enforced with run-time checks.  Such range
bounds of a type; this is enforced with run-time checks.  Such range
checking is meant to ensure program correctness by making sure
checking is meant to ensure program correctness by making sure
computations do not overflow, or indices on an array element access do
computations do not overflow, or indices on an array element access do
not exceed the bounds of the array.
not exceed the bounds of the array.
   For expressions you use in GDB commands, you can tell GDB to treat
   For expressions you use in GDB commands, you can tell GDB to treat
range errors in one of three ways: ignore them, always treat them as
range errors in one of three ways: ignore them, always treat them as
errors and abandon the expression, or issue warnings but evaluate the
errors and abandon the expression, or issue warnings but evaluate the
expression anyway.
expression anyway.
   A range error can result from numerical overflow, from exceeding an
   A range error can result from numerical overflow, from exceeding an
array index bound, or when you type a constant that is not a member of
array index bound, or when you type a constant that is not a member of
any type.  Some languages, however, do not treat overflows as an error.
any type.  Some languages, however, do not treat overflows as an error.
In many implementations of C, mathematical overflow causes the result
In many implementations of C, mathematical overflow causes the result
to "wrap around" to lower values--for example, if M is the largest
to "wrap around" to lower values--for example, if M is the largest
integer value, and S is the smallest, then
integer value, and S is the smallest, then
     M + 1 => S
     M + 1 => S
   This, too, is specific to individual languages, and in some cases
   This, too, is specific to individual languages, and in some cases
specific to individual compilers or machines.  *Note Supported
specific to individual compilers or machines.  *Note Supported
Languages: Supported Languages, for further details on specific
Languages: Supported Languages, for further details on specific
languages.
languages.
   GDB provides some additional commands for controlling the range
   GDB provides some additional commands for controlling the range
checker:
checker:
`set check range auto'
`set check range auto'
     Set range checking on or off based on the current working language.
     Set range checking on or off based on the current working language.
     *Note Supported Languages: Supported Languages, for the default
     *Note Supported Languages: Supported Languages, for the default
     settings for each language.
     settings for each language.
`set check range on'
`set check range on'
`set check range off'
`set check range off'
     Set range checking on or off, overriding the default setting for
     Set range checking on or off, overriding the default setting for
     the current working language.  A warning is issued if the setting
     the current working language.  A warning is issued if the setting
     does not match the language default.  If a range error occurs and
     does not match the language default.  If a range error occurs and
     range checking is on, then a message is printed and evaluation of
     range checking is on, then a message is printed and evaluation of
     the expression is aborted.
     the expression is aborted.
`set check range warn'
`set check range warn'
     Output messages when the GDB range checker detects a range error,
     Output messages when the GDB range checker detects a range error,
     but attempt to evaluate the expression anyway.  Evaluating the
     but attempt to evaluate the expression anyway.  Evaluating the
     expression may still be impossible for other reasons, such as
     expression may still be impossible for other reasons, such as
     accessing memory that the process does not own (a typical example
     accessing memory that the process does not own (a typical example
     from many Unix systems).
     from many Unix systems).
`show range'
`show range'
     Show the current setting of the range checker, and whether or not
     Show the current setting of the range checker, and whether or not
     it is being set automatically by GDB.
     it is being set automatically by GDB.


File: gdb.info,  Node: Supported Languages,  Next: Unsupported Languages,  Prev: Checks,  Up: Languages
File: gdb.info,  Node: Supported Languages,  Next: Unsupported Languages,  Prev: Checks,  Up: Languages
12.4 Supported Languages
12.4 Supported Languages
========================
========================
GDB supports C, C++, Objective-C, Fortran, Java, Pascal, assembly,
GDB supports C, C++, Objective-C, Fortran, Java, Pascal, assembly,
Modula-2, and Ada.  Some GDB features may be used in expressions
Modula-2, and Ada.  Some GDB features may be used in expressions
regardless of the language you use: the GDB `@' and `::' operators, and
regardless of the language you use: the GDB `@' and `::' operators, and
the `{type}addr' construct (*note Expressions: Expressions.) can be
the `{type}addr' construct (*note Expressions: Expressions.) can be
used with the constructs of any supported language.
used with the constructs of any supported language.
   The following sections detail to what degree each source language is
   The following sections detail to what degree each source language is
supported by GDB.  These sections are not meant to be language
supported by GDB.  These sections are not meant to be language
tutorials or references, but serve only as a reference guide to what the
tutorials or references, but serve only as a reference guide to what the
GDB expression parser accepts, and what input and output formats should
GDB expression parser accepts, and what input and output formats should
look like for different languages.  There are many good books written
look like for different languages.  There are many good books written
on each of these languages; please look to these for a language
on each of these languages; please look to these for a language
reference or tutorial.
reference or tutorial.
* Menu:
* Menu:
* C::                           C and C++
* C::                           C and C++
* Objective-C::                 Objective-C
* Objective-C::                 Objective-C
* Fortran::                     Fortran
* Fortran::                     Fortran
* Pascal::                      Pascal
* Pascal::                      Pascal
* Modula-2::                    Modula-2
* Modula-2::                    Modula-2
* Ada::                         Ada
* Ada::                         Ada


File: gdb.info,  Node: C,  Next: Objective-C,  Up: Supported Languages
File: gdb.info,  Node: C,  Next: Objective-C,  Up: Supported Languages
12.4.1 C and C++
12.4.1 C and C++
----------------
----------------
Since C and C++ are so closely related, many features of GDB apply to
Since C and C++ are so closely related, many features of GDB apply to
both languages.  Whenever this is the case, we discuss those languages
both languages.  Whenever this is the case, we discuss those languages
together.
together.
   The C++ debugging facilities are jointly implemented by the C++
   The C++ debugging facilities are jointly implemented by the C++
compiler and GDB.  Therefore, to debug your C++ code effectively, you
compiler and GDB.  Therefore, to debug your C++ code effectively, you
must compile your C++ programs with a supported C++ compiler, such as
must compile your C++ programs with a supported C++ compiler, such as
GNU `g++', or the HP ANSI C++ compiler (`aCC').
GNU `g++', or the HP ANSI C++ compiler (`aCC').
   For best results when using GNU C++, use the DWARF 2 debugging
   For best results when using GNU C++, use the DWARF 2 debugging
format; if it doesn't work on your system, try the stabs+ debugging
format; if it doesn't work on your system, try the stabs+ debugging
format.  You can select those formats explicitly with the `g++'
format.  You can select those formats explicitly with the `g++'
command-line options `-gdwarf-2' and `-gstabs+'.  *Note Options for
command-line options `-gdwarf-2' and `-gstabs+'.  *Note Options for
Debugging Your Program or GCC: (gcc.info)Debugging Options.
Debugging Your Program or GCC: (gcc.info)Debugging Options.
* Menu:
* Menu:
* C Operators::                 C and C++ operators
* C Operators::                 C and C++ operators
* C Constants::                 C and C++ constants
* C Constants::                 C and C++ constants
* C Plus Plus Expressions::     C++ expressions
* C Plus Plus Expressions::     C++ expressions
* C Defaults::                  Default settings for C and C++
* C Defaults::                  Default settings for C and C++
* C Checks::                    C and C++ type and range checks
* C Checks::                    C and C++ type and range checks
* Debugging C::                 GDB and C
* Debugging C::                 GDB and C
* Debugging C Plus Plus::       GDB features for C++
* Debugging C Plus Plus::       GDB features for C++
* Decimal Floating Point::      Numbers in Decimal Floating Point format
* Decimal Floating Point::      Numbers in Decimal Floating Point format


File: gdb.info,  Node: C Operators,  Next: C Constants,  Up: C
File: gdb.info,  Node: C Operators,  Next: C Constants,  Up: C
12.4.1.1 C and C++ Operators
12.4.1.1 C and C++ Operators
............................
............................
Operators must be defined on values of specific types.  For instance,
Operators must be defined on values of specific types.  For instance,
`+' is defined on numbers, but not on structures.  Operators are often
`+' is defined on numbers, but not on structures.  Operators are often
defined on groups of types.
defined on groups of types.
   For the purposes of C and C++, the following definitions hold:
   For the purposes of C and C++, the following definitions hold:
   * _Integral types_ include `int' with any of its storage-class
   * _Integral types_ include `int' with any of its storage-class
     specifiers; `char'; `enum'; and, for C++, `bool'.
     specifiers; `char'; `enum'; and, for C++, `bool'.
   * _Floating-point types_ include `float', `double', and `long
   * _Floating-point types_ include `float', `double', and `long
     double' (if supported by the target platform).
     double' (if supported by the target platform).
   * _Pointer types_ include all types defined as `(TYPE *)'.
   * _Pointer types_ include all types defined as `(TYPE *)'.
   * _Scalar types_ include all of the above.
   * _Scalar types_ include all of the above.
The following operators are supported.  They are listed here in order
The following operators are supported.  They are listed here in order
of increasing precedence:
of increasing precedence:
`,'
`,'
     The comma or sequencing operator.  Expressions in a
     The comma or sequencing operator.  Expressions in a
     comma-separated list are evaluated from left to right, with the
     comma-separated list are evaluated from left to right, with the
     result of the entire expression being the last expression
     result of the entire expression being the last expression
     evaluated.
     evaluated.
`='
`='
     Assignment.  The value of an assignment expression is the value
     Assignment.  The value of an assignment expression is the value
     assigned.  Defined on scalar types.
     assigned.  Defined on scalar types.
`OP='
`OP='
     Used in an expression of the form `A OP= B', and translated to
     Used in an expression of the form `A OP= B', and translated to
     `A = A OP B'.  `OP=' and `=' have the same precedence.  OP is any
     `A = A OP B'.  `OP=' and `=' have the same precedence.  OP is any
     one of the operators `|', `^', `&', `<<', `>>', `+', `-', `*',
     one of the operators `|', `^', `&', `<<', `>>', `+', `-', `*',
     `/', `%'.
     `/', `%'.
`?:'
`?:'
     The ternary operator.  `A ? B : C' can be thought of as:  if A
     The ternary operator.  `A ? B : C' can be thought of as:  if A
     then B else C.  A should be of an integral type.
     then B else C.  A should be of an integral type.
`||'
`||'
     Logical OR.  Defined on integral types.
     Logical OR.  Defined on integral types.
`&&'
`&&'
     Logical AND.  Defined on integral types.
     Logical AND.  Defined on integral types.
`|'
`|'
     Bitwise OR.  Defined on integral types.
     Bitwise OR.  Defined on integral types.
`^'
`^'
     Bitwise exclusive-OR.  Defined on integral types.
     Bitwise exclusive-OR.  Defined on integral types.
`&'
`&'
     Bitwise AND.  Defined on integral types.
     Bitwise AND.  Defined on integral types.
`==, !='
`==, !='
     Equality and inequality.  Defined on scalar types.  The value of
     Equality and inequality.  Defined on scalar types.  The value of
     these expressions is 0 for false and non-zero for true.
     these expressions is 0 for false and non-zero for true.
`<, >, <=, >='
`<, >, <=, >='
     Less than, greater than, less than or equal, greater than or equal.
     Less than, greater than, less than or equal, greater than or equal.
     Defined on scalar types.  The value of these expressions is 0 for
     Defined on scalar types.  The value of these expressions is 0 for
     false and non-zero for true.
     false and non-zero for true.
`<<, >>'
`<<, >>'
     left shift, and right shift.  Defined on integral types.
     left shift, and right shift.  Defined on integral types.
`@'
`@'
     The GDB "artificial array" operator (*note Expressions:
     The GDB "artificial array" operator (*note Expressions:
     Expressions.).
     Expressions.).
`+, -'
`+, -'
     Addition and subtraction.  Defined on integral types,
     Addition and subtraction.  Defined on integral types,
     floating-point types and pointer types.
     floating-point types and pointer types.
`*, /, %'
`*, /, %'
     Multiplication, division, and modulus.  Multiplication and
     Multiplication, division, and modulus.  Multiplication and
     division are defined on integral and floating-point types.
     division are defined on integral and floating-point types.
     Modulus is defined on integral types.
     Modulus is defined on integral types.
`++, --'
`++, --'
     Increment and decrement.  When appearing before a variable, the
     Increment and decrement.  When appearing before a variable, the
     operation is performed before the variable is used in an
     operation is performed before the variable is used in an
     expression; when appearing after it, the variable's value is used
     expression; when appearing after it, the variable's value is used
     before the operation takes place.
     before the operation takes place.
`*'
`*'
     Pointer dereferencing.  Defined on pointer types.  Same precedence
     Pointer dereferencing.  Defined on pointer types.  Same precedence
     as `++'.
     as `++'.
`&'
`&'
     Address operator.  Defined on variables.  Same precedence as `++'.
     Address operator.  Defined on variables.  Same precedence as `++'.
     For debugging C++, GDB implements a use of `&' beyond what is
     For debugging C++, GDB implements a use of `&' beyond what is
     allowed in the C++ language itself: you can use `&(&REF)' to
     allowed in the C++ language itself: you can use `&(&REF)' to
     examine the address where a C++ reference variable (declared with
     examine the address where a C++ reference variable (declared with
     `&REF') is stored.
     `&REF') is stored.
`-'
`-'
     Negative.  Defined on integral and floating-point types.  Same
     Negative.  Defined on integral and floating-point types.  Same
     precedence as `++'.
     precedence as `++'.
`!'
`!'
     Logical negation.  Defined on integral types.  Same precedence as
     Logical negation.  Defined on integral types.  Same precedence as
     `++'.
     `++'.
`~'
`~'
     Bitwise complement operator.  Defined on integral types.  Same
     Bitwise complement operator.  Defined on integral types.  Same
     precedence as `++'.
     precedence as `++'.
`., ->'
`., ->'
     Structure member, and pointer-to-structure member.  For
     Structure member, and pointer-to-structure member.  For
     convenience, GDB regards the two as equivalent, choosing whether
     convenience, GDB regards the two as equivalent, choosing whether
     to dereference a pointer based on the stored type information.
     to dereference a pointer based on the stored type information.
     Defined on `struct' and `union' data.
     Defined on `struct' and `union' data.
`.*, ->*'
`.*, ->*'
     Dereferences of pointers to members.
     Dereferences of pointers to members.
`[]'
`[]'
     Array indexing.  `A[I]' is defined as `*(A+I)'.  Same precedence
     Array indexing.  `A[I]' is defined as `*(A+I)'.  Same precedence
     as `->'.
     as `->'.
`()'
`()'
     Function parameter list.  Same precedence as `->'.
     Function parameter list.  Same precedence as `->'.
`::'
`::'
     C++ scope resolution operator.  Defined on `struct', `union', and
     C++ scope resolution operator.  Defined on `struct', `union', and
     `class' types.
     `class' types.
`::'
`::'
     Doubled colons also represent the GDB scope operator (*note
     Doubled colons also represent the GDB scope operator (*note
     Expressions: Expressions.).  Same precedence as `::', above.
     Expressions: Expressions.).  Same precedence as `::', above.
   If an operator is redefined in the user code, GDB usually attempts
   If an operator is redefined in the user code, GDB usually attempts
to invoke the redefined version instead of using the operator's
to invoke the redefined version instead of using the operator's
predefined meaning.
predefined meaning.


File: gdb.info,  Node: C Constants,  Next: C Plus Plus Expressions,  Prev: C Operators,  Up: C
File: gdb.info,  Node: C Constants,  Next: C Plus Plus Expressions,  Prev: C Operators,  Up: C
12.4.1.2 C and C++ Constants
12.4.1.2 C and C++ Constants
............................
............................
GDB allows you to express the constants of C and C++ in the following
GDB allows you to express the constants of C and C++ in the following
ways:
ways:
   * Integer constants are a sequence of digits.  Octal constants are
   * Integer constants are a sequence of digits.  Octal constants are
     specified by a leading `0' (i.e. zero), and hexadecimal constants
     specified by a leading `0' (i.e. zero), and hexadecimal constants
     by a leading `0x' or `0X'.  Constants may also end with a letter
     by a leading `0x' or `0X'.  Constants may also end with a letter
     `l', specifying that the constant should be treated as a `long'
     `l', specifying that the constant should be treated as a `long'
     value.
     value.
   * Floating point constants are a sequence of digits, followed by a
   * Floating point constants are a sequence of digits, followed by a
     decimal point, followed by a sequence of digits, and optionally
     decimal point, followed by a sequence of digits, and optionally
     followed by an exponent.  An exponent is of the form:
     followed by an exponent.  An exponent is of the form:
     `e[[+]|-]NNN', where NNN is another sequence of digits.  The `+'
     `e[[+]|-]NNN', where NNN is another sequence of digits.  The `+'
     is optional for positive exponents.  A floating-point constant may
     is optional for positive exponents.  A floating-point constant may
     also end with a letter `f' or `F', specifying that the constant
     also end with a letter `f' or `F', specifying that the constant
     should be treated as being of the `float' (as opposed to the
     should be treated as being of the `float' (as opposed to the
     default `double') type; or with a letter `l' or `L', which
     default `double') type; or with a letter `l' or `L', which
     specifies a `long double' constant.
     specifies a `long double' constant.
   * Enumerated constants consist of enumerated identifiers, or their
   * Enumerated constants consist of enumerated identifiers, or their
     integral equivalents.
     integral equivalents.
   * Character constants are a single character surrounded by single
   * Character constants are a single character surrounded by single
     quotes (`''), or a number--the ordinal value of the corresponding
     quotes (`''), or a number--the ordinal value of the corresponding
     character (usually its ASCII value).  Within quotes, the single
     character (usually its ASCII value).  Within quotes, the single
     character may be represented by a letter or by "escape sequences",
     character may be represented by a letter or by "escape sequences",
     which are of the form `\NNN', where NNN is the octal representation
     which are of the form `\NNN', where NNN is the octal representation
     of the character's ordinal value; or of the form `\X', where `X'
     of the character's ordinal value; or of the form `\X', where `X'
     is a predefined special character--for example, `\n' for newline.
     is a predefined special character--for example, `\n' for newline.
   * String constants are a sequence of character constants surrounded
   * String constants are a sequence of character constants surrounded
     by double quotes (`"').  Any valid character constant (as described
     by double quotes (`"').  Any valid character constant (as described
     above) may appear.  Double quotes within the string must be
     above) may appear.  Double quotes within the string must be
     preceded by a backslash, so for instance `"a\"b'c"' is a string of
     preceded by a backslash, so for instance `"a\"b'c"' is a string of
     five characters.
     five characters.
   * Pointer constants are an integral value.  You can also write
   * Pointer constants are an integral value.  You can also write
     pointers to constants using the C operator `&'.
     pointers to constants using the C operator `&'.
   * Array constants are comma-separated lists surrounded by braces `{'
   * Array constants are comma-separated lists surrounded by braces `{'
     and `}'; for example, `{1,2,3}' is a three-element array of
     and `}'; for example, `{1,2,3}' is a three-element array of
     integers, `{{1,2}, {3,4}, {5,6}}' is a three-by-two array, and
     integers, `{{1,2}, {3,4}, {5,6}}' is a three-by-two array, and
     `{&"hi", &"there", &"fred"}' is a three-element array of pointers.
     `{&"hi", &"there", &"fred"}' is a three-element array of pointers.


File: gdb.info,  Node: C Plus Plus Expressions,  Next: C Defaults,  Prev: C Constants,  Up: C
File: gdb.info,  Node: C Plus Plus Expressions,  Next: C Defaults,  Prev: C Constants,  Up: C
12.4.1.3 C++ Expressions
12.4.1.3 C++ Expressions
........................
........................
GDB expression handling can interpret most C++ expressions.
GDB expression handling can interpret most C++ expressions.
     _Warning:_ GDB can only debug C++ code if you use the proper
     _Warning:_ GDB can only debug C++ code if you use the proper
     compiler and the proper debug format.  Currently, GDB works best
     compiler and the proper debug format.  Currently, GDB works best
     when debugging C++ code that is compiled with GCC 2.95.3 or with
     when debugging C++ code that is compiled with GCC 2.95.3 or with
     GCC 3.1 or newer, using the options `-gdwarf-2' or `-gstabs+'.
     GCC 3.1 or newer, using the options `-gdwarf-2' or `-gstabs+'.
     DWARF 2 is preferred over stabs+.  Most configurations of GCC emit
     DWARF 2 is preferred over stabs+.  Most configurations of GCC emit
     either DWARF 2 or stabs+ as their default debug format, so you
     either DWARF 2 or stabs+ as their default debug format, so you
     usually don't need to specify a debug format explicitly.  Other
     usually don't need to specify a debug format explicitly.  Other
     compilers and/or debug formats are likely to work badly or not at
     compilers and/or debug formats are likely to work badly or not at
     all when using GDB to debug C++ code.
     all when using GDB to debug C++ code.
  1. Member function calls are allowed; you can use expressions like
  1. Member function calls are allowed; you can use expressions like
          count = aml->GetOriginal(x, y)
          count = aml->GetOriginal(x, y)
  2. While a member function is active (in the selected stack frame),
  2. While a member function is active (in the selected stack frame),
     your expressions have the same namespace available as the member
     your expressions have the same namespace available as the member
     function; that is, GDB allows implicit references to the class
     function; that is, GDB allows implicit references to the class
     instance pointer `this' following the same rules as C++.
     instance pointer `this' following the same rules as C++.
  3. You can call overloaded functions; GDB resolves the function call
  3. You can call overloaded functions; GDB resolves the function call
     to the right definition, with some restrictions.  GDB does not
     to the right definition, with some restrictions.  GDB does not
     perform overload resolution involving user-defined type
     perform overload resolution involving user-defined type
     conversions, calls to constructors, or instantiations of templates
     conversions, calls to constructors, or instantiations of templates
     that do not exist in the program.  It also cannot handle ellipsis
     that do not exist in the program.  It also cannot handle ellipsis
     argument lists or default arguments.
     argument lists or default arguments.
     It does perform integral conversions and promotions, floating-point
     It does perform integral conversions and promotions, floating-point
     promotions, arithmetic conversions, pointer conversions,
     promotions, arithmetic conversions, pointer conversions,
     conversions of class objects to base classes, and standard
     conversions of class objects to base classes, and standard
     conversions such as those of functions or arrays to pointers; it
     conversions such as those of functions or arrays to pointers; it
     requires an exact match on the number of function arguments.
     requires an exact match on the number of function arguments.
     Overload resolution is always performed, unless you have specified
     Overload resolution is always performed, unless you have specified
     `set overload-resolution off'.  *Note GDB Features for C++:
     `set overload-resolution off'.  *Note GDB Features for C++:
     Debugging C Plus Plus.
     Debugging C Plus Plus.
     You must specify `set overload-resolution off' in order to use an
     You must specify `set overload-resolution off' in order to use an
     explicit function signature to call an overloaded function, as in
     explicit function signature to call an overloaded function, as in
          p 'foo(char,int)'('x', 13)
          p 'foo(char,int)'('x', 13)
     The GDB command-completion facility can simplify this; see *Note
     The GDB command-completion facility can simplify this; see *Note
     Command Completion: Completion.
     Command Completion: Completion.
  4. GDB understands variables declared as C++ references; you can use
  4. GDB understands variables declared as C++ references; you can use
     them in expressions just as you do in C++ source--they are
     them in expressions just as you do in C++ source--they are
     automatically dereferenced.
     automatically dereferenced.
     In the parameter list shown when GDB displays a frame, the values
     In the parameter list shown when GDB displays a frame, the values
     of reference variables are not displayed (unlike other variables);
     of reference variables are not displayed (unlike other variables);
     this avoids clutter, since references are often used for large
     this avoids clutter, since references are often used for large
     structures.  The _address_ of a reference variable is always
     structures.  The _address_ of a reference variable is always
     shown, unless you have specified `set print address off'.
     shown, unless you have specified `set print address off'.
  5. GDB supports the C++ name resolution operator `::'--your
  5. GDB supports the C++ name resolution operator `::'--your
     expressions can use it just as expressions in your program do.
     expressions can use it just as expressions in your program do.
     Since one scope may be defined in another, you can use `::'
     Since one scope may be defined in another, you can use `::'
     repeatedly if necessary, for example in an expression like
     repeatedly if necessary, for example in an expression like
     `SCOPE1::SCOPE2::NAME'.  GDB also allows resolving name scope by
     `SCOPE1::SCOPE2::NAME'.  GDB also allows resolving name scope by
     reference to source files, in both C and C++ debugging (*note
     reference to source files, in both C and C++ debugging (*note
     Program Variables: Variables.).
     Program Variables: Variables.).
   In addition, when used with HP's C++ compiler, GDB supports calling
   In addition, when used with HP's C++ compiler, GDB supports calling
virtual functions correctly, printing out virtual bases of objects,
virtual functions correctly, printing out virtual bases of objects,
calling functions in a base subobject, casting objects, and invoking
calling functions in a base subobject, casting objects, and invoking
user-defined operators.
user-defined operators.


File: gdb.info,  Node: C Defaults,  Next: C Checks,  Prev: C Plus Plus Expressions,  Up: C
File: gdb.info,  Node: C Defaults,  Next: C Checks,  Prev: C Plus Plus Expressions,  Up: C
12.4.1.4 C and C++ Defaults
12.4.1.4 C and C++ Defaults
...........................
...........................
If you allow GDB to set type and range checking automatically, they
If you allow GDB to set type and range checking automatically, they
both default to `off' whenever the working language changes to C or
both default to `off' whenever the working language changes to C or
C++.  This happens regardless of whether you or GDB selects the working
C++.  This happens regardless of whether you or GDB selects the working
language.
language.
   If you allow GDB to set the language automatically, it recognizes
   If you allow GDB to set the language automatically, it recognizes
source files whose names end with `.c', `.C', or `.cc', etc, and when
source files whose names end with `.c', `.C', or `.cc', etc, and when
GDB enters code compiled from one of these files, it sets the working
GDB enters code compiled from one of these files, it sets the working
language to C or C++.  *Note Having GDB Infer the Source Language:
language to C or C++.  *Note Having GDB Infer the Source Language:
Automatically, for further details.
Automatically, for further details.


File: gdb.info,  Node: C Checks,  Next: Debugging C,  Prev: C Defaults,  Up: C
File: gdb.info,  Node: C Checks,  Next: Debugging C,  Prev: C Defaults,  Up: C
12.4.1.5 C and C++ Type and Range Checks
12.4.1.5 C and C++ Type and Range Checks
........................................
........................................
By default, when GDB parses C or C++ expressions, type checking is not
By default, when GDB parses C or C++ expressions, type checking is not
used.  However, if you turn type checking on, GDB considers two
used.  However, if you turn type checking on, GDB considers two
variables type equivalent if:
variables type equivalent if:
   * The two variables are structured and have the same structure,
   * The two variables are structured and have the same structure,
     union, or enumerated tag.
     union, or enumerated tag.
   * The two variables have the same type name, or types that have been
   * The two variables have the same type name, or types that have been
     declared equivalent through `typedef'.
     declared equivalent through `typedef'.
   Range checking, if turned on, is done on mathematical operations.
   Range checking, if turned on, is done on mathematical operations.
Array indices are not checked, since they are often used to index a
Array indices are not checked, since they are often used to index a
pointer that is not itself an array.
pointer that is not itself an array.


File: gdb.info,  Node: Debugging C,  Next: Debugging C Plus Plus,  Prev: C Checks,  Up: C
File: gdb.info,  Node: Debugging C,  Next: Debugging C Plus Plus,  Prev: C Checks,  Up: C
12.4.1.6 GDB and C
12.4.1.6 GDB and C
..................
..................
The `set print union' and `show print union' commands apply to the
The `set print union' and `show print union' commands apply to the
`union' type.  When set to `on', any `union' that is inside a `struct'
`union' type.  When set to `on', any `union' that is inside a `struct'
or `class' is also printed.  Otherwise, it appears as `{...}'.
or `class' is also printed.  Otherwise, it appears as `{...}'.
   The `@' operator aids in the debugging of dynamic arrays, formed
   The `@' operator aids in the debugging of dynamic arrays, formed
with pointers and a memory allocation function.  *Note Expressions:
with pointers and a memory allocation function.  *Note Expressions:
Expressions.
Expressions.


File: gdb.info,  Node: Debugging C Plus Plus,  Next: Decimal Floating Point,  Prev: Debugging C,  Up: C
File: gdb.info,  Node: Debugging C Plus Plus,  Next: Decimal Floating Point,  Prev: Debugging C,  Up: C
12.4.1.7 GDB Features for C++
12.4.1.7 GDB Features for C++
.............................
.............................
Some GDB commands are particularly useful with C++, and some are
Some GDB commands are particularly useful with C++, and some are
designed specifically for use with C++.  Here is a summary:
designed specifically for use with C++.  Here is a summary:
`breakpoint menus'
`breakpoint menus'
     When you want a breakpoint in a function whose name is overloaded,
     When you want a breakpoint in a function whose name is overloaded,
     GDB breakpoint menus help you specify which function definition
     GDB breakpoint menus help you specify which function definition
     you want.  *Note Breakpoint Menus: Breakpoint Menus.
     you want.  *Note Breakpoint Menus: Breakpoint Menus.
`rbreak REGEX'
`rbreak REGEX'
     Setting breakpoints using regular expressions is helpful for
     Setting breakpoints using regular expressions is helpful for
     setting breakpoints on overloaded functions that are not members
     setting breakpoints on overloaded functions that are not members
     of any special classes.  *Note Setting Breakpoints: Set Breaks.
     of any special classes.  *Note Setting Breakpoints: Set Breaks.
`catch throw'
`catch throw'
`catch catch'
`catch catch'
     Debug C++ exception handling using these commands.  *Note Setting
     Debug C++ exception handling using these commands.  *Note Setting
     Catchpoints: Set Catchpoints.
     Catchpoints: Set Catchpoints.
`ptype TYPENAME'
`ptype TYPENAME'
     Print inheritance relationships as well as other information for
     Print inheritance relationships as well as other information for
     type TYPENAME.  *Note Examining the Symbol Table: Symbols.
     type TYPENAME.  *Note Examining the Symbol Table: Symbols.
`set print demangle'
`set print demangle'
`show print demangle'
`show print demangle'
`set print asm-demangle'
`set print asm-demangle'
`show print asm-demangle'
`show print asm-demangle'
     Control whether C++ symbols display in their source form, both when
     Control whether C++ symbols display in their source form, both when
     displaying code as C++ source and when displaying disassemblies.
     displaying code as C++ source and when displaying disassemblies.
     *Note Print Settings: Print Settings.
     *Note Print Settings: Print Settings.
`set print object'
`set print object'
`show print object'
`show print object'
     Choose whether to print derived (actual) or declared types of
     Choose whether to print derived (actual) or declared types of
     objects.  *Note Print Settings: Print Settings.
     objects.  *Note Print Settings: Print Settings.
`set print vtbl'
`set print vtbl'
`show print vtbl'
`show print vtbl'
     Control the format for printing virtual function tables.  *Note
     Control the format for printing virtual function tables.  *Note
     Print Settings: Print Settings.  (The `vtbl' commands do not work
     Print Settings: Print Settings.  (The `vtbl' commands do not work
     on programs compiled with the HP ANSI C++ compiler (`aCC').)
     on programs compiled with the HP ANSI C++ compiler (`aCC').)
`set overload-resolution on'
`set overload-resolution on'
     Enable overload resolution for C++ expression evaluation.  The
     Enable overload resolution for C++ expression evaluation.  The
     default is on.  For overloaded functions, GDB evaluates the
     default is on.  For overloaded functions, GDB evaluates the
     arguments and searches for a function whose signature matches the
     arguments and searches for a function whose signature matches the
     argument types, using the standard C++ conversion rules (see *Note
     argument types, using the standard C++ conversion rules (see *Note
     C++ Expressions: C Plus Plus Expressions, for details).  If it
     C++ Expressions: C Plus Plus Expressions, for details).  If it
     cannot find a match, it emits a message.
     cannot find a match, it emits a message.
`set overload-resolution off'
`set overload-resolution off'
     Disable overload resolution for C++ expression evaluation.  For
     Disable overload resolution for C++ expression evaluation.  For
     overloaded functions that are not class member functions, GDB
     overloaded functions that are not class member functions, GDB
     chooses the first function of the specified name that it finds in
     chooses the first function of the specified name that it finds in
     the symbol table, whether or not its arguments are of the correct
     the symbol table, whether or not its arguments are of the correct
     type.  For overloaded functions that are class member functions,
     type.  For overloaded functions that are class member functions,
     GDB searches for a function whose signature _exactly_ matches the
     GDB searches for a function whose signature _exactly_ matches the
     argument types.
     argument types.
`show overload-resolution'
`show overload-resolution'
     Show the current setting of overload resolution.
     Show the current setting of overload resolution.
`Overloaded symbol names'
`Overloaded symbol names'
     You can specify a particular definition of an overloaded symbol,
     You can specify a particular definition of an overloaded symbol,
     using the same notation that is used to declare such symbols in
     using the same notation that is used to declare such symbols in
     C++: type `SYMBOL(TYPES)' rather than just SYMBOL.  You can also
     C++: type `SYMBOL(TYPES)' rather than just SYMBOL.  You can also
     use the GDB command-line word completion facilities to list the
     use the GDB command-line word completion facilities to list the
     available choices, or to finish the type list for you.  *Note
     available choices, or to finish the type list for you.  *Note
     Command Completion: Completion, for details on how to do this.
     Command Completion: Completion, for details on how to do this.


File: gdb.info,  Node: Decimal Floating Point,  Prev: Debugging C Plus Plus,  Up: C
File: gdb.info,  Node: Decimal Floating Point,  Prev: Debugging C Plus Plus,  Up: C
12.4.1.8 Decimal Floating Point format
12.4.1.8 Decimal Floating Point format
......................................
......................................
GDB can examine, set and perform computations with numbers in decimal
GDB can examine, set and perform computations with numbers in decimal
floating point format, which in the C language correspond to the
floating point format, which in the C language correspond to the
`_Decimal32', `_Decimal64' and `_Decimal128' types as specified by the
`_Decimal32', `_Decimal64' and `_Decimal128' types as specified by the
extension to support decimal floating-point arithmetic.
extension to support decimal floating-point arithmetic.
   There are two encodings in use, depending on the architecture: BID
   There are two encodings in use, depending on the architecture: BID
(Binary Integer Decimal) for x86 and x86-64, and DPD (Densely Packed
(Binary Integer Decimal) for x86 and x86-64, and DPD (Densely Packed
Decimal) for PowerPC. GDB will use the appropriate encoding for the
Decimal) for PowerPC. GDB will use the appropriate encoding for the
configured target.
configured target.
   Because of a limitation in `libdecnumber', the library used by GDB
   Because of a limitation in `libdecnumber', the library used by GDB
to manipulate decimal floating point numbers, it is not possible to
to manipulate decimal floating point numbers, it is not possible to
convert (using a cast, for example) integers wider than 32-bit to
convert (using a cast, for example) integers wider than 32-bit to
decimal float.
decimal float.
   In addition, in order to imitate GDB's behaviour with binary floating
   In addition, in order to imitate GDB's behaviour with binary floating
point computations, error checking in decimal float operations ignores
point computations, error checking in decimal float operations ignores
underflow, overflow and divide by zero exceptions.
underflow, overflow and divide by zero exceptions.
   In the PowerPC architecture, GDB provides a set of pseudo-registers
   In the PowerPC architecture, GDB provides a set of pseudo-registers
to inspect `_Decimal128' values stored in floating point registers. See
to inspect `_Decimal128' values stored in floating point registers. See
*Note PowerPC: PowerPC. for more details.
*Note PowerPC: PowerPC. for more details.


File: gdb.info,  Node: Objective-C,  Next: Fortran,  Prev: C,  Up: Supported Languages
File: gdb.info,  Node: Objective-C,  Next: Fortran,  Prev: C,  Up: Supported Languages
12.4.2 Objective-C
12.4.2 Objective-C
------------------
------------------
This section provides information about some commands and command
This section provides information about some commands and command
options that are useful for debugging Objective-C code.  See also *Note
options that are useful for debugging Objective-C code.  See also *Note
info classes: Symbols, and *Note info selectors: Symbols, for a few
info classes: Symbols, and *Note info selectors: Symbols, for a few
more commands specific to Objective-C support.
more commands specific to Objective-C support.
* Menu:
* Menu:
* Method Names in Commands::
* Method Names in Commands::
* The Print Command with Objective-C::
* The Print Command with Objective-C::


File: gdb.info,  Node: Method Names in Commands,  Next: The Print Command with Objective-C,  Up: Objective-C
File: gdb.info,  Node: Method Names in Commands,  Next: The Print Command with Objective-C,  Up: Objective-C
12.4.2.1 Method Names in Commands
12.4.2.1 Method Names in Commands
.................................
.................................
The following commands have been extended to accept Objective-C method
The following commands have been extended to accept Objective-C method
names as line specifications:
names as line specifications:
   * `clear'
   * `clear'
   * `break'
   * `break'
   * `info line'
   * `info line'
   * `jump'
   * `jump'
   * `list'
   * `list'
   A fully qualified Objective-C method name is specified as
   A fully qualified Objective-C method name is specified as
     -[CLASS METHODNAME]
     -[CLASS METHODNAME]
   where the minus sign is used to indicate an instance method and a
   where the minus sign is used to indicate an instance method and a
plus sign (not shown) is used to indicate a class method.  The class
plus sign (not shown) is used to indicate a class method.  The class
name CLASS and method name METHODNAME are enclosed in brackets, similar
name CLASS and method name METHODNAME are enclosed in brackets, similar
to the way messages are specified in Objective-C source code.  For
to the way messages are specified in Objective-C source code.  For
example, to set a breakpoint at the `create' instance method of class
example, to set a breakpoint at the `create' instance method of class
`Fruit' in the program currently being debugged, enter:
`Fruit' in the program currently being debugged, enter:
     break -[Fruit create]
     break -[Fruit create]
   To list ten program lines around the `initialize' class method,
   To list ten program lines around the `initialize' class method,
enter:
enter:
     list +[NSText initialize]
     list +[NSText initialize]
   In the current version of GDB, the plus or minus sign is required.
   In the current version of GDB, the plus or minus sign is required.
In future versions of GDB, the plus or minus sign will be optional, but
In future versions of GDB, the plus or minus sign will be optional, but
you can use it to narrow the search.  It is also possible to specify
you can use it to narrow the search.  It is also possible to specify
just a method name:
just a method name:
     break create
     break create
   You must specify the complete method name, including any colons.  If
   You must specify the complete method name, including any colons.  If
your program's source files contain more than one `create' method,
your program's source files contain more than one `create' method,
you'll be presented with a numbered list of classes that implement that
you'll be presented with a numbered list of classes that implement that
method.  Indicate your choice by number, or type `0' to exit if none
method.  Indicate your choice by number, or type `0' to exit if none
apply.
apply.
   As another example, to clear a breakpoint established at the
   As another example, to clear a breakpoint established at the
`makeKeyAndOrderFront:' method of the `NSWindow' class, enter:
`makeKeyAndOrderFront:' method of the `NSWindow' class, enter:
     clear -[NSWindow makeKeyAndOrderFront:]
     clear -[NSWindow makeKeyAndOrderFront:]


File: gdb.info,  Node: The Print Command with Objective-C,  Prev: Method Names in Commands,  Up: Objective-C
File: gdb.info,  Node: The Print Command with Objective-C,  Prev: Method Names in Commands,  Up: Objective-C
12.4.2.2 The Print Command With Objective-C
12.4.2.2 The Print Command With Objective-C
...........................................
...........................................
The print command has also been extended to accept methods.  For
The print command has also been extended to accept methods.  For
example:
example:
     print -[OBJECT hash]
     print -[OBJECT hash]
will tell GDB to send the `hash' message to OBJECT and print the
will tell GDB to send the `hash' message to OBJECT and print the
result.  Also, an additional command has been added, `print-object' or
result.  Also, an additional command has been added, `print-object' or
`po' for short, which is meant to print the description of an object.
`po' for short, which is meant to print the description of an object.
However, this command may only work with certain Objective-C libraries
However, this command may only work with certain Objective-C libraries
that have a particular hook function, `_NSPrintForDebugger', defined.
that have a particular hook function, `_NSPrintForDebugger', defined.


File: gdb.info,  Node: Fortran,  Next: Pascal,  Prev: Objective-C,  Up: Supported Languages
File: gdb.info,  Node: Fortran,  Next: Pascal,  Prev: Objective-C,  Up: Supported Languages
12.4.3 Fortran
12.4.3 Fortran
--------------
--------------
GDB can be used to debug programs written in Fortran, but it currently
GDB can be used to debug programs written in Fortran, but it currently
supports only the features of Fortran 77 language.
supports only the features of Fortran 77 language.
   Some Fortran compilers (GNU Fortran 77 and Fortran 95 compilers
   Some Fortran compilers (GNU Fortran 77 and Fortran 95 compilers
among them) append an underscore to the names of variables and
among them) append an underscore to the names of variables and
functions.  When you debug programs compiled by those compilers, you
functions.  When you debug programs compiled by those compilers, you
will need to refer to variables and functions with a trailing
will need to refer to variables and functions with a trailing
underscore.
underscore.
* Menu:
* Menu:
* Fortran Operators::           Fortran operators and expressions
* Fortran Operators::           Fortran operators and expressions
* Fortran Defaults::            Default settings for Fortran
* Fortran Defaults::            Default settings for Fortran
* Special Fortran Commands::    Special GDB commands for Fortran
* Special Fortran Commands::    Special GDB commands for Fortran


File: gdb.info,  Node: Fortran Operators,  Next: Fortran Defaults,  Up: Fortran
File: gdb.info,  Node: Fortran Operators,  Next: Fortran Defaults,  Up: Fortran
12.4.3.1 Fortran Operators and Expressions
12.4.3.1 Fortran Operators and Expressions
..........................................
..........................................
Operators must be defined on values of specific types.  For instance,
Operators must be defined on values of specific types.  For instance,
`+' is defined on numbers, but not on characters or other non-
`+' is defined on numbers, but not on characters or other non-
arithmetic types.  Operators are often defined on groups of types.
arithmetic types.  Operators are often defined on groups of types.
`**'
`**'
     The exponentiation operator. It raises the first operand to the
     The exponentiation operator. It raises the first operand to the
     power of the second one.
     power of the second one.
`:'
`:'
     The range operator.  Normally used in the form of array(low:high)
     The range operator.  Normally used in the form of array(low:high)
     to represent a section of array.
     to represent a section of array.


File: gdb.info,  Node: Fortran Defaults,  Next: Special Fortran Commands,  Prev: Fortran Operators,  Up: Fortran
File: gdb.info,  Node: Fortran Defaults,  Next: Special Fortran Commands,  Prev: Fortran Operators,  Up: Fortran
12.4.3.2 Fortran Defaults
12.4.3.2 Fortran Defaults
.........................
.........................
Fortran symbols are usually case-insensitive, so GDB by default uses
Fortran symbols are usually case-insensitive, so GDB by default uses
case-insensitive matches for Fortran symbols.  You can change that with
case-insensitive matches for Fortran symbols.  You can change that with
the `set case-insensitive' command, see *Note Symbols::, for the
the `set case-insensitive' command, see *Note Symbols::, for the
details.
details.


File: gdb.info,  Node: Special Fortran Commands,  Prev: Fortran Defaults,  Up: Fortran
File: gdb.info,  Node: Special Fortran Commands,  Prev: Fortran Defaults,  Up: Fortran
12.4.3.3 Special Fortran Commands
12.4.3.3 Special Fortran Commands
.................................
.................................
GDB has some commands to support Fortran-specific features, such as
GDB has some commands to support Fortran-specific features, such as
displaying common blocks.
displaying common blocks.
`info common [COMMON-NAME]'
`info common [COMMON-NAME]'
     This command prints the values contained in the Fortran `COMMON'
     This command prints the values contained in the Fortran `COMMON'
     block whose name is COMMON-NAME.  With no argument, the names of
     block whose name is COMMON-NAME.  With no argument, the names of
     all `COMMON' blocks visible at the current program location are
     all `COMMON' blocks visible at the current program location are
     printed.
     printed.


File: gdb.info,  Node: Pascal,  Next: Modula-2,  Prev: Fortran,  Up: Supported Languages
File: gdb.info,  Node: Pascal,  Next: Modula-2,  Prev: Fortran,  Up: Supported Languages
12.4.4 Pascal
12.4.4 Pascal
-------------
-------------
Debugging Pascal programs which use sets, subranges, file variables, or
Debugging Pascal programs which use sets, subranges, file variables, or
nested functions does not currently work.  GDB does not support
nested functions does not currently work.  GDB does not support
entering expressions, printing values, or similar features using Pascal
entering expressions, printing values, or similar features using Pascal
syntax.
syntax.
   The Pascal-specific command `set print pascal_static-members'
   The Pascal-specific command `set print pascal_static-members'
controls whether static members of Pascal objects are displayed.  *Note
controls whether static members of Pascal objects are displayed.  *Note
pascal_static-members: Print Settings.
pascal_static-members: Print Settings.


File: gdb.info,  Node: Modula-2,  Next: Ada,  Prev: Pascal,  Up: Supported Languages
File: gdb.info,  Node: Modula-2,  Next: Ada,  Prev: Pascal,  Up: Supported Languages
12.4.5 Modula-2
12.4.5 Modula-2
---------------
---------------
The extensions made to GDB to support Modula-2 only support output from
The extensions made to GDB to support Modula-2 only support output from
the GNU Modula-2 compiler (which is currently being developed).  Other
the GNU Modula-2 compiler (which is currently being developed).  Other
Modula-2 compilers are not currently supported, and attempting to debug
Modula-2 compilers are not currently supported, and attempting to debug
executables produced by them is most likely to give an error as GDB
executables produced by them is most likely to give an error as GDB
reads in the executable's symbol table.
reads in the executable's symbol table.
* Menu:
* Menu:
* M2 Operators::                Built-in operators
* M2 Operators::                Built-in operators
* Built-In Func/Proc::          Built-in functions and procedures
* Built-In Func/Proc::          Built-in functions and procedures
* M2 Constants::                Modula-2 constants
* M2 Constants::                Modula-2 constants
* M2 Types::                    Modula-2 types
* M2 Types::                    Modula-2 types
* M2 Defaults::                 Default settings for Modula-2
* M2 Defaults::                 Default settings for Modula-2
* Deviations::                  Deviations from standard Modula-2
* Deviations::                  Deviations from standard Modula-2
* M2 Checks::                   Modula-2 type and range checks
* M2 Checks::                   Modula-2 type and range checks
* M2 Scope::                    The scope operators `::' and `.'
* M2 Scope::                    The scope operators `::' and `.'
* GDB/M2::                      GDB and Modula-2
* GDB/M2::                      GDB and Modula-2


File: gdb.info,  Node: M2 Operators,  Next: Built-In Func/Proc,  Up: Modula-2
File: gdb.info,  Node: M2 Operators,  Next: Built-In Func/Proc,  Up: Modula-2
12.4.5.1 Operators
12.4.5.1 Operators
..................
..................
Operators must be defined on values of specific types.  For instance,
Operators must be defined on values of specific types.  For instance,
`+' is defined on numbers, but not on structures.  Operators are often
`+' is defined on numbers, but not on structures.  Operators are often
defined on groups of types.  For the purposes of Modula-2, the
defined on groups of types.  For the purposes of Modula-2, the
following definitions hold:
following definitions hold:
   * _Integral types_ consist of `INTEGER', `CARDINAL', and their
   * _Integral types_ consist of `INTEGER', `CARDINAL', and their
     subranges.
     subranges.
   * _Character types_ consist of `CHAR' and its subranges.
   * _Character types_ consist of `CHAR' and its subranges.
   * _Floating-point types_ consist of `REAL'.
   * _Floating-point types_ consist of `REAL'.
   * _Pointer types_ consist of anything declared as `POINTER TO TYPE'.
   * _Pointer types_ consist of anything declared as `POINTER TO TYPE'.
   * _Scalar types_ consist of all of the above.
   * _Scalar types_ consist of all of the above.
   * _Set types_ consist of `SET' and `BITSET' types.
   * _Set types_ consist of `SET' and `BITSET' types.
   * _Boolean types_ consist of `BOOLEAN'.
   * _Boolean types_ consist of `BOOLEAN'.
The following operators are supported, and appear in order of
The following operators are supported, and appear in order of
increasing precedence:
increasing precedence:
`,'
`,'
     Function argument or array index separator.
     Function argument or array index separator.
`:='
`:='
     Assignment.  The value of VAR `:=' VALUE is VALUE.
     Assignment.  The value of VAR `:=' VALUE is VALUE.
`<, >'
`<, >'
     Less than, greater than on integral, floating-point, or enumerated
     Less than, greater than on integral, floating-point, or enumerated
     types.
     types.
`<=, >='
`<=, >='
     Less than or equal to, greater than or equal to on integral,
     Less than or equal to, greater than or equal to on integral,
     floating-point and enumerated types, or set inclusion on set
     floating-point and enumerated types, or set inclusion on set
     types.  Same precedence as `<'.
     types.  Same precedence as `<'.
`=, <>, #'
`=, <>, #'
     Equality and two ways of expressing inequality, valid on scalar
     Equality and two ways of expressing inequality, valid on scalar
     types.  Same precedence as `<'.  In GDB scripts, only `<>' is
     types.  Same precedence as `<'.  In GDB scripts, only `<>' is
     available for inequality, since `#' conflicts with the script
     available for inequality, since `#' conflicts with the script
     comment character.
     comment character.
`IN'
`IN'
     Set membership.  Defined on set types and the types of their
     Set membership.  Defined on set types and the types of their
     members.  Same precedence as `<'.
     members.  Same precedence as `<'.
`OR'
`OR'
     Boolean disjunction.  Defined on boolean types.
     Boolean disjunction.  Defined on boolean types.
`AND, &'
`AND, &'
     Boolean conjunction.  Defined on boolean types.
     Boolean conjunction.  Defined on boolean types.
`@'
`@'
     The GDB "artificial array" operator (*note Expressions:
     The GDB "artificial array" operator (*note Expressions:
     Expressions.).
     Expressions.).
`+, -'
`+, -'
     Addition and subtraction on integral and floating-point types, or
     Addition and subtraction on integral and floating-point types, or
     union and difference on set types.
     union and difference on set types.
`*'
`*'
     Multiplication on integral and floating-point types, or set
     Multiplication on integral and floating-point types, or set
     intersection on set types.
     intersection on set types.
`/'
`/'
     Division on floating-point types, or symmetric set difference on
     Division on floating-point types, or symmetric set difference on
     set types.  Same precedence as `*'.
     set types.  Same precedence as `*'.
`DIV, MOD'
`DIV, MOD'
     Integer division and remainder.  Defined on integral types.  Same
     Integer division and remainder.  Defined on integral types.  Same
     precedence as `*'.
     precedence as `*'.
`-'
`-'
     Negative. Defined on `INTEGER' and `REAL' data.
     Negative. Defined on `INTEGER' and `REAL' data.
`^'
`^'
     Pointer dereferencing.  Defined on pointer types.
     Pointer dereferencing.  Defined on pointer types.
`NOT'
`NOT'
     Boolean negation.  Defined on boolean types.  Same precedence as
     Boolean negation.  Defined on boolean types.  Same precedence as
     `^'.
     `^'.
`.'
`.'
     `RECORD' field selector.  Defined on `RECORD' data.  Same
     `RECORD' field selector.  Defined on `RECORD' data.  Same
     precedence as `^'.
     precedence as `^'.
`[]'
`[]'
     Array indexing.  Defined on `ARRAY' data.  Same precedence as `^'.
     Array indexing.  Defined on `ARRAY' data.  Same precedence as `^'.
`()'
`()'
     Procedure argument list.  Defined on `PROCEDURE' objects.  Same
     Procedure argument list.  Defined on `PROCEDURE' objects.  Same
     precedence as `^'.
     precedence as `^'.
`::, .'
`::, .'
     GDB and Modula-2 scope operators.
     GDB and Modula-2 scope operators.
     _Warning:_ Set expressions and their operations are not yet
     _Warning:_ Set expressions and their operations are not yet
     supported, so GDB treats the use of the operator `IN', or the use
     supported, so GDB treats the use of the operator `IN', or the use
     of operators `+', `-', `*', `/', `=', , `<>', `#', `<=', and `>='
     of operators `+', `-', `*', `/', `=', , `<>', `#', `<=', and `>='
     on sets as an error.
     on sets as an error.


File: gdb.info,  Node: Built-In Func/Proc,  Next: M2 Constants,  Prev: M2 Operators,  Up: Modula-2
File: gdb.info,  Node: Built-In Func/Proc,  Next: M2 Constants,  Prev: M2 Operators,  Up: Modula-2
12.4.5.2 Built-in Functions and Procedures
12.4.5.2 Built-in Functions and Procedures
..........................................
..........................................
Modula-2 also makes available several built-in procedures and functions.
Modula-2 also makes available several built-in procedures and functions.
In describing these, the following metavariables are used:
In describing these, the following metavariables are used:
A
A
     represents an `ARRAY' variable.
     represents an `ARRAY' variable.
C
C
     represents a `CHAR' constant or variable.
     represents a `CHAR' constant or variable.
I
I
     represents a variable or constant of integral type.
     represents a variable or constant of integral type.
M
M
     represents an identifier that belongs to a set.  Generally used in
     represents an identifier that belongs to a set.  Generally used in
     the same function with the metavariable S.  The type of S should
     the same function with the metavariable S.  The type of S should
     be `SET OF MTYPE' (where MTYPE is the type of M).
     be `SET OF MTYPE' (where MTYPE is the type of M).
N
N
     represents a variable or constant of integral or floating-point
     represents a variable or constant of integral or floating-point
     type.
     type.
R
R
     represents a variable or constant of floating-point type.
     represents a variable or constant of floating-point type.
T
T
     represents a type.
     represents a type.
V
V
     represents a variable.
     represents a variable.
X
X
     represents a variable or constant of one of many types.  See the
     represents a variable or constant of one of many types.  See the
     explanation of the function for details.
     explanation of the function for details.
   All Modula-2 built-in procedures also return a result, described
   All Modula-2 built-in procedures also return a result, described
below.
below.
`ABS(N)'
`ABS(N)'
     Returns the absolute value of N.
     Returns the absolute value of N.
`CAP(C)'
`CAP(C)'
     If C is a lower case letter, it returns its upper case equivalent,
     If C is a lower case letter, it returns its upper case equivalent,
     otherwise it returns its argument.
     otherwise it returns its argument.
`CHR(I)'
`CHR(I)'
     Returns the character whose ordinal value is I.
     Returns the character whose ordinal value is I.
`DEC(V)'
`DEC(V)'
     Decrements the value in the variable V by one.  Returns the new
     Decrements the value in the variable V by one.  Returns the new
     value.
     value.
`DEC(V,I)'
`DEC(V,I)'
     Decrements the value in the variable V by I.  Returns the new
     Decrements the value in the variable V by I.  Returns the new
     value.
     value.
`EXCL(M,S)'
`EXCL(M,S)'
     Removes the element M from the set S.  Returns the new set.
     Removes the element M from the set S.  Returns the new set.
`FLOAT(I)'
`FLOAT(I)'
     Returns the floating point equivalent of the integer I.
     Returns the floating point equivalent of the integer I.
`HIGH(A)'
`HIGH(A)'
     Returns the index of the last member of A.
     Returns the index of the last member of A.
`INC(V)'
`INC(V)'
     Increments the value in the variable V by one.  Returns the new
     Increments the value in the variable V by one.  Returns the new
     value.
     value.
`INC(V,I)'
`INC(V,I)'
     Increments the value in the variable V by I.  Returns the new
     Increments the value in the variable V by I.  Returns the new
     value.
     value.
`INCL(M,S)'
`INCL(M,S)'
     Adds the element M to the set S if it is not already there.
     Adds the element M to the set S if it is not already there.
     Returns the new set.
     Returns the new set.
`MAX(T)'
`MAX(T)'
     Returns the maximum value of the type T.
     Returns the maximum value of the type T.
`MIN(T)'
`MIN(T)'
     Returns the minimum value of the type T.
     Returns the minimum value of the type T.
`ODD(I)'
`ODD(I)'
     Returns boolean TRUE if I is an odd number.
     Returns boolean TRUE if I is an odd number.
`ORD(X)'
`ORD(X)'
     Returns the ordinal value of its argument.  For example, the
     Returns the ordinal value of its argument.  For example, the
     ordinal value of a character is its ASCII value (on machines
     ordinal value of a character is its ASCII value (on machines
     supporting the ASCII character set).  X must be of an ordered
     supporting the ASCII character set).  X must be of an ordered
     type, which include integral, character and enumerated types.
     type, which include integral, character and enumerated types.
`SIZE(X)'
`SIZE(X)'
     Returns the size of its argument.  X can be a variable or a type.
     Returns the size of its argument.  X can be a variable or a type.
`TRUNC(R)'
`TRUNC(R)'
     Returns the integral part of R.
     Returns the integral part of R.
`TSIZE(X)'
`TSIZE(X)'
     Returns the size of its argument.  X can be a variable or a type.
     Returns the size of its argument.  X can be a variable or a type.
`VAL(T,I)'
`VAL(T,I)'
     Returns the member of the type T whose ordinal value is I.
     Returns the member of the type T whose ordinal value is I.
     _Warning:_  Sets and their operations are not yet supported, so
     _Warning:_  Sets and their operations are not yet supported, so
     GDB treats the use of procedures `INCL' and `EXCL' as an error.
     GDB treats the use of procedures `INCL' and `EXCL' as an error.


File: gdb.info,  Node: M2 Constants,  Next: M2 Types,  Prev: Built-In Func/Proc,  Up: Modula-2
File: gdb.info,  Node: M2 Constants,  Next: M2 Types,  Prev: Built-In Func/Proc,  Up: Modula-2
12.4.5.3 Constants
12.4.5.3 Constants
..................
..................
GDB allows you to express the constants of Modula-2 in the following
GDB allows you to express the constants of Modula-2 in the following
ways:
ways:
   * Integer constants are simply a sequence of digits.  When used in an
   * Integer constants are simply a sequence of digits.  When used in an
     expression, a constant is interpreted to be type-compatible with
     expression, a constant is interpreted to be type-compatible with
     the rest of the expression.  Hexadecimal integers are specified by
     the rest of the expression.  Hexadecimal integers are specified by
     a trailing `H', and octal integers by a trailing `B'.
     a trailing `H', and octal integers by a trailing `B'.
   * Floating point constants appear as a sequence of digits, followed
   * Floating point constants appear as a sequence of digits, followed
     by a decimal point and another sequence of digits.  An optional
     by a decimal point and another sequence of digits.  An optional
     exponent can then be specified, in the form `E[+|-]NNN', where
     exponent can then be specified, in the form `E[+|-]NNN', where
     `[+|-]NNN' is the desired exponent.  All of the digits of the
     `[+|-]NNN' is the desired exponent.  All of the digits of the
     floating point constant must be valid decimal (base 10) digits.
     floating point constant must be valid decimal (base 10) digits.
   * Character constants consist of a single character enclosed by a
   * Character constants consist of a single character enclosed by a
     pair of like quotes, either single (`'') or double (`"').  They may
     pair of like quotes, either single (`'') or double (`"').  They may
     also be expressed by their ordinal value (their ASCII value,
     also be expressed by their ordinal value (their ASCII value,
     usually) followed by a `C'.
     usually) followed by a `C'.
   * String constants consist of a sequence of characters enclosed by a
   * String constants consist of a sequence of characters enclosed by a
     pair of like quotes, either single (`'') or double (`"').  Escape
     pair of like quotes, either single (`'') or double (`"').  Escape
     sequences in the style of C are also allowed.  *Note C and C++
     sequences in the style of C are also allowed.  *Note C and C++
     Constants: C Constants, for a brief explanation of escape
     Constants: C Constants, for a brief explanation of escape
     sequences.
     sequences.
   * Enumerated constants consist of an enumerated identifier.
   * Enumerated constants consist of an enumerated identifier.
   * Boolean constants consist of the identifiers `TRUE' and `FALSE'.
   * Boolean constants consist of the identifiers `TRUE' and `FALSE'.
   * Pointer constants consist of integral values only.
   * Pointer constants consist of integral values only.
   * Set constants are not yet supported.
   * Set constants are not yet supported.


File: gdb.info,  Node: M2 Types,  Next: M2 Defaults,  Prev: M2 Constants,  Up: Modula-2
File: gdb.info,  Node: M2 Types,  Next: M2 Defaults,  Prev: M2 Constants,  Up: Modula-2
12.4.5.4 Modula-2 Types
12.4.5.4 Modula-2 Types
.......................
.......................
Currently GDB can print the following data types in Modula-2 syntax:
Currently GDB can print the following data types in Modula-2 syntax:
array types, record types, set types, pointer types, procedure types,
array types, record types, set types, pointer types, procedure types,
enumerated types, subrange types and base types.  You can also print
enumerated types, subrange types and base types.  You can also print
the contents of variables declared using these type.  This section
the contents of variables declared using these type.  This section
gives a number of simple source code examples together with sample GDB
gives a number of simple source code examples together with sample GDB
sessions.
sessions.
   The first example contains the following section of code:
   The first example contains the following section of code:
     VAR
     VAR
        s: SET OF CHAR ;
        s: SET OF CHAR ;
        r: [20..40] ;
        r: [20..40] ;
and you can request GDB to interrogate the type and value of `r' and
and you can request GDB to interrogate the type and value of `r' and
`s'.
`s'.
     (gdb) print s
     (gdb) print s
     {'A'..'C', 'Z'}
     {'A'..'C', 'Z'}
     (gdb) ptype s
     (gdb) ptype s
     SET OF CHAR
     SET OF CHAR
     (gdb) print r
     (gdb) print r
     21
     21
     (gdb) ptype r
     (gdb) ptype r
     [20..40]
     [20..40]
Likewise if your source code declares `s' as:
Likewise if your source code declares `s' as:
     VAR
     VAR
        s: SET ['A'..'Z'] ;
        s: SET ['A'..'Z'] ;
then you may query the type of `s' by:
then you may query the type of `s' by:
     (gdb) ptype s
     (gdb) ptype s
     type = SET ['A'..'Z']
     type = SET ['A'..'Z']
Note that at present you cannot interactively manipulate set
Note that at present you cannot interactively manipulate set
expressions using the debugger.
expressions using the debugger.
   The following example shows how you might declare an array in
   The following example shows how you might declare an array in
Modula-2 and how you can interact with GDB to print its type and
Modula-2 and how you can interact with GDB to print its type and
contents:
contents:
     VAR
     VAR
        s: ARRAY [-10..10] OF CHAR ;
        s: ARRAY [-10..10] OF CHAR ;
     (gdb) ptype s
     (gdb) ptype s
     ARRAY [-10..10] OF CHAR
     ARRAY [-10..10] OF CHAR
   Note that the array handling is not yet complete and although the
   Note that the array handling is not yet complete and although the
type is printed correctly, expression handling still assumes that all
type is printed correctly, expression handling still assumes that all
arrays have a lower bound of zero and not `-10' as in the example above.
arrays have a lower bound of zero and not `-10' as in the example above.
   Here are some more type related Modula-2 examples:
   Here are some more type related Modula-2 examples:
     TYPE
     TYPE
        colour = (blue, red, yellow, green) ;
        colour = (blue, red, yellow, green) ;
        t = [blue..yellow] ;
        t = [blue..yellow] ;
     VAR
     VAR
        s: t ;
        s: t ;
     BEGIN
     BEGIN
        s := blue ;
        s := blue ;
The GDB interaction shows how you can query the data type and value of
The GDB interaction shows how you can query the data type and value of
a variable.
a variable.
     (gdb) print s
     (gdb) print s
     $1 = blue
     $1 = blue
     (gdb) ptype t
     (gdb) ptype t
     type = [blue..yellow]
     type = [blue..yellow]
In this example a Modula-2 array is declared and its contents
In this example a Modula-2 array is declared and its contents
displayed.  Observe that the contents are written in the same way as
displayed.  Observe that the contents are written in the same way as
their `C' counterparts.
their `C' counterparts.
     VAR
     VAR
        s: ARRAY [1..5] OF CARDINAL ;
        s: ARRAY [1..5] OF CARDINAL ;
     BEGIN
     BEGIN
        s[1] := 1 ;
        s[1] := 1 ;
     (gdb) print s
     (gdb) print s
     $1 = {1, 0, 0, 0, 0}
     $1 = {1, 0, 0, 0, 0}
     (gdb) ptype s
     (gdb) ptype s
     type = ARRAY [1..5] OF CARDINAL
     type = ARRAY [1..5] OF CARDINAL
   The Modula-2 language interface to GDB also understands pointer
   The Modula-2 language interface to GDB also understands pointer
types as shown in this example:
types as shown in this example:
     VAR
     VAR
        s: POINTER TO ARRAY [1..5] OF CARDINAL ;
        s: POINTER TO ARRAY [1..5] OF CARDINAL ;
     BEGIN
     BEGIN
        NEW(s) ;
        NEW(s) ;
        s^[1] := 1 ;
        s^[1] := 1 ;
and you can request that GDB describes the type of `s'.
and you can request that GDB describes the type of `s'.
     (gdb) ptype s
     (gdb) ptype s
     type = POINTER TO ARRAY [1..5] OF CARDINAL
     type = POINTER TO ARRAY [1..5] OF CARDINAL
   GDB handles compound types as we can see in this example.  Here we
   GDB handles compound types as we can see in this example.  Here we
combine array types, record types, pointer types and subrange types:
combine array types, record types, pointer types and subrange types:
     TYPE
     TYPE
        foo = RECORD
        foo = RECORD
                 f1: CARDINAL ;
                 f1: CARDINAL ;
                 f2: CHAR ;
                 f2: CHAR ;
                 f3: myarray ;
                 f3: myarray ;
              END ;
              END ;
        myarray = ARRAY myrange OF CARDINAL ;
        myarray = ARRAY myrange OF CARDINAL ;
        myrange = [-2..2] ;
        myrange = [-2..2] ;
     VAR
     VAR
        s: POINTER TO ARRAY myrange OF foo ;
        s: POINTER TO ARRAY myrange OF foo ;
and you can ask GDB to describe the type of `s' as shown below.
and you can ask GDB to describe the type of `s' as shown below.
     (gdb) ptype s
     (gdb) ptype s
     type = POINTER TO ARRAY [-2..2] OF foo = RECORD
     type = POINTER TO ARRAY [-2..2] OF foo = RECORD
         f1 : CARDINAL;
         f1 : CARDINAL;
         f2 : CHAR;
         f2 : CHAR;
         f3 : ARRAY [-2..2] OF CARDINAL;
         f3 : ARRAY [-2..2] OF CARDINAL;
     END
     END


File: gdb.info,  Node: M2 Defaults,  Next: Deviations,  Prev: M2 Types,  Up: Modula-2
File: gdb.info,  Node: M2 Defaults,  Next: Deviations,  Prev: M2 Types,  Up: Modula-2
12.4.5.5 Modula-2 Defaults
12.4.5.5 Modula-2 Defaults
..........................
..........................
If type and range checking are set automatically by GDB, they both
If type and range checking are set automatically by GDB, they both
default to `on' whenever the working language changes to Modula-2.
default to `on' whenever the working language changes to Modula-2.
This happens regardless of whether you or GDB selected the working
This happens regardless of whether you or GDB selected the working
language.
language.
   If you allow GDB to set the language automatically, then entering
   If you allow GDB to set the language automatically, then entering
code compiled from a file whose name ends with `.mod' sets the working
code compiled from a file whose name ends with `.mod' sets the working
language to Modula-2.  *Note Having GDB Infer the Source Language:
language to Modula-2.  *Note Having GDB Infer the Source Language:
Automatically, for further details.
Automatically, for further details.


File: gdb.info,  Node: Deviations,  Next: M2 Checks,  Prev: M2 Defaults,  Up: Modula-2
File: gdb.info,  Node: Deviations,  Next: M2 Checks,  Prev: M2 Defaults,  Up: Modula-2
12.4.5.6 Deviations from Standard Modula-2
12.4.5.6 Deviations from Standard Modula-2
..........................................
..........................................
A few changes have been made to make Modula-2 programs easier to debug.
A few changes have been made to make Modula-2 programs easier to debug.
This is done primarily via loosening its type strictness:
This is done primarily via loosening its type strictness:
   * Unlike in standard Modula-2, pointer constants can be formed by
   * Unlike in standard Modula-2, pointer constants can be formed by
     integers.  This allows you to modify pointer variables during
     integers.  This allows you to modify pointer variables during
     debugging.  (In standard Modula-2, the actual address contained in
     debugging.  (In standard Modula-2, the actual address contained in
     a pointer variable is hidden from you; it can only be modified
     a pointer variable is hidden from you; it can only be modified
     through direct assignment to another pointer variable or
     through direct assignment to another pointer variable or
     expression that returned a pointer.)
     expression that returned a pointer.)
   * C escape sequences can be used in strings and characters to
   * C escape sequences can be used in strings and characters to
     represent non-printable characters.  GDB prints out strings with
     represent non-printable characters.  GDB prints out strings with
     these escape sequences embedded.  Single non-printable characters
     these escape sequences embedded.  Single non-printable characters
     are printed using the `CHR(NNN)' format.
     are printed using the `CHR(NNN)' format.
   * The assignment operator (`:=') returns the value of its right-hand
   * The assignment operator (`:=') returns the value of its right-hand
     argument.
     argument.
   * All built-in procedures both modify _and_ return their argument.
   * All built-in procedures both modify _and_ return their argument.


File: gdb.info,  Node: M2 Checks,  Next: M2 Scope,  Prev: Deviations,  Up: Modula-2
File: gdb.info,  Node: M2 Checks,  Next: M2 Scope,  Prev: Deviations,  Up: Modula-2
12.4.5.7 Modula-2 Type and Range Checks
12.4.5.7 Modula-2 Type and Range Checks
.......................................
.......................................
     _Warning:_ in this release, GDB does not yet perform type or range
     _Warning:_ in this release, GDB does not yet perform type or range
     checking.
     checking.
   GDB considers two Modula-2 variables type equivalent if:
   GDB considers two Modula-2 variables type equivalent if:
   * They are of types that have been declared equivalent via a `TYPE
   * They are of types that have been declared equivalent via a `TYPE
     T1 = T2' statement
     T1 = T2' statement
   * They have been declared on the same line.  (Note:  This is true of
   * They have been declared on the same line.  (Note:  This is true of
     the GNU Modula-2 compiler, but it may not be true of other
     the GNU Modula-2 compiler, but it may not be true of other
     compilers.)
     compilers.)
   As long as type checking is enabled, any attempt to combine variables
   As long as type checking is enabled, any attempt to combine variables
whose types are not equivalent is an error.
whose types are not equivalent is an error.
   Range checking is done on all mathematical operations, assignment,
   Range checking is done on all mathematical operations, assignment,
array index bounds, and all built-in functions and procedures.
array index bounds, and all built-in functions and procedures.


File: gdb.info,  Node: M2 Scope,  Next: GDB/M2,  Prev: M2 Checks,  Up: Modula-2
File: gdb.info,  Node: M2 Scope,  Next: GDB/M2,  Prev: M2 Checks,  Up: Modula-2
12.4.5.8 The Scope Operators `::' and `.'
12.4.5.8 The Scope Operators `::' and `.'
.........................................
.........................................
There are a few subtle differences between the Modula-2 scope operator
There are a few subtle differences between the Modula-2 scope operator
(`.') and the GDB scope operator (`::').  The two have similar syntax:
(`.') and the GDB scope operator (`::').  The two have similar syntax:
     MODULE . ID
     MODULE . ID
     SCOPE :: ID
     SCOPE :: ID
where SCOPE is the name of a module or a procedure, MODULE the name of
where SCOPE is the name of a module or a procedure, MODULE the name of
a module, and ID is any declared identifier within your program, except
a module, and ID is any declared identifier within your program, except
another module.
another module.
   Using the `::' operator makes GDB search the scope specified by
   Using the `::' operator makes GDB search the scope specified by
SCOPE for the identifier ID.  If it is not found in the specified
SCOPE for the identifier ID.  If it is not found in the specified
scope, then GDB searches all scopes enclosing the one specified by
scope, then GDB searches all scopes enclosing the one specified by
SCOPE.
SCOPE.
   Using the `.' operator makes GDB search the current scope for the
   Using the `.' operator makes GDB search the current scope for the
identifier specified by ID that was imported from the definition module
identifier specified by ID that was imported from the definition module
specified by MODULE.  With this operator, it is an error if the
specified by MODULE.  With this operator, it is an error if the
identifier ID was not imported from definition module MODULE, or if ID
identifier ID was not imported from definition module MODULE, or if ID
is not an identifier in MODULE.
is not an identifier in MODULE.


File: gdb.info,  Node: GDB/M2,  Prev: M2 Scope,  Up: Modula-2
File: gdb.info,  Node: GDB/M2,  Prev: M2 Scope,  Up: Modula-2
12.4.5.9 GDB and Modula-2
12.4.5.9 GDB and Modula-2
.........................
.........................
Some GDB commands have little use when debugging Modula-2 programs.
Some GDB commands have little use when debugging Modula-2 programs.
Five subcommands of `set print' and `show print' apply specifically to
Five subcommands of `set print' and `show print' apply specifically to
C and C++: `vtbl', `demangle', `asm-demangle', `object', and `union'.
C and C++: `vtbl', `demangle', `asm-demangle', `object', and `union'.
The first four apply to C++, and the last to the C `union' type, which
The first four apply to C++, and the last to the C `union' type, which
has no direct analogue in Modula-2.
has no direct analogue in Modula-2.
   The `@' operator (*note Expressions: Expressions.), while available
   The `@' operator (*note Expressions: Expressions.), while available
with any language, is not useful with Modula-2.  Its intent is to aid
with any language, is not useful with Modula-2.  Its intent is to aid
the debugging of "dynamic arrays", which cannot be created in Modula-2
the debugging of "dynamic arrays", which cannot be created in Modula-2
as they can in C or C++.  However, because an address can be specified
as they can in C or C++.  However, because an address can be specified
by an integral constant, the construct `{TYPE}ADREXP' is still useful.
by an integral constant, the construct `{TYPE}ADREXP' is still useful.
   In GDB scripts, the Modula-2 inequality operator `#' is interpreted
   In GDB scripts, the Modula-2 inequality operator `#' is interpreted
as the beginning of a comment.  Use `<>' instead.
as the beginning of a comment.  Use `<>' instead.


File: gdb.info,  Node: Ada,  Prev: Modula-2,  Up: Supported Languages
File: gdb.info,  Node: Ada,  Prev: Modula-2,  Up: Supported Languages
12.4.6 Ada
12.4.6 Ada
----------
----------
The extensions made to GDB for Ada only support output from the GNU Ada
The extensions made to GDB for Ada only support output from the GNU Ada
(GNAT) compiler.  Other Ada compilers are not currently supported, and
(GNAT) compiler.  Other Ada compilers are not currently supported, and
attempting to debug executables produced by them is most likely to be
attempting to debug executables produced by them is most likely to be
difficult.
difficult.
* Menu:
* Menu:
* Ada Mode Intro::              General remarks on the Ada syntax
* Ada Mode Intro::              General remarks on the Ada syntax
                                   and semantics supported by Ada mode
                                   and semantics supported by Ada mode
                                   in GDB.
                                   in GDB.
* Omissions from Ada::          Restrictions on the Ada expression syntax.
* Omissions from Ada::          Restrictions on the Ada expression syntax.
* Additions to Ada::            Extensions of the Ada expression syntax.
* Additions to Ada::            Extensions of the Ada expression syntax.
* Stopping Before Main Program:: Debugging the program during elaboration.
* Stopping Before Main Program:: Debugging the program during elaboration.
* Ada Glitches::                Known peculiarities of Ada mode.
* Ada Glitches::                Known peculiarities of Ada mode.


File: gdb.info,  Node: Ada Mode Intro,  Next: Omissions from Ada,  Up: Ada
File: gdb.info,  Node: Ada Mode Intro,  Next: Omissions from Ada,  Up: Ada
12.4.6.1 Introduction
12.4.6.1 Introduction
.....................
.....................
The Ada mode of GDB supports a fairly large subset of Ada expression
The Ada mode of GDB supports a fairly large subset of Ada expression
syntax, with some extensions.  The philosophy behind the design of this
syntax, with some extensions.  The philosophy behind the design of this
subset is
subset is
   * That GDB should provide basic literals and access to operations for
   * That GDB should provide basic literals and access to operations for
     arithmetic, dereferencing, field selection, indexing, and
     arithmetic, dereferencing, field selection, indexing, and
     subprogram calls, leaving more sophisticated computations to
     subprogram calls, leaving more sophisticated computations to
     subprograms written into the program (which therefore may be
     subprograms written into the program (which therefore may be
     called from GDB).
     called from GDB).
   * That type safety and strict adherence to Ada language restrictions
   * That type safety and strict adherence to Ada language restrictions
     are not particularly important to the GDB user.
     are not particularly important to the GDB user.
   * That brevity is important to the GDB user.
   * That brevity is important to the GDB user.
   Thus, for brevity, the debugger acts as if there were implicit
   Thus, for brevity, the debugger acts as if there were implicit
`with' and `use' clauses in effect for all user-written packages,
`with' and `use' clauses in effect for all user-written packages,
making it unnecessary to fully qualify most names with their packages,
making it unnecessary to fully qualify most names with their packages,
regardless of context.  Where this causes ambiguity, GDB asks the
regardless of context.  Where this causes ambiguity, GDB asks the
user's intent.
user's intent.
   The debugger will start in Ada mode if it detects an Ada main
   The debugger will start in Ada mode if it detects an Ada main
program.  As for other languages, it will enter Ada mode when stopped
program.  As for other languages, it will enter Ada mode when stopped
in a program that was translated from an Ada source file.
in a program that was translated from an Ada source file.
   While in Ada mode, you may use `-' for comments.  This is useful
   While in Ada mode, you may use `-' for comments.  This is useful
mostly for documenting command files.  The standard GDB comment (`#')
mostly for documenting command files.  The standard GDB comment (`#')
still works at the beginning of a line in Ada mode, but not in the
still works at the beginning of a line in Ada mode, but not in the
middle (to allow based literals).
middle (to allow based literals).
   The debugger supports limited overloading.  Given a subprogram call
   The debugger supports limited overloading.  Given a subprogram call
in which the function symbol has multiple definitions, it will use the
in which the function symbol has multiple definitions, it will use the
number of actual parameters and some information about their types to
number of actual parameters and some information about their types to
attempt to narrow the set of definitions.  It also makes very limited
attempt to narrow the set of definitions.  It also makes very limited
use of context, preferring procedures to functions in the context of
use of context, preferring procedures to functions in the context of
the `call' command, and functions to procedures elsewhere.
the `call' command, and functions to procedures elsewhere.


File: gdb.info,  Node: Omissions from Ada,  Next: Additions to Ada,  Prev: Ada Mode Intro,  Up: Ada
File: gdb.info,  Node: Omissions from Ada,  Next: Additions to Ada,  Prev: Ada Mode Intro,  Up: Ada
12.4.6.2 Omissions from Ada
12.4.6.2 Omissions from Ada
...........................
...........................
Here are the notable omissions from the subset:
Here are the notable omissions from the subset:
   * Only a subset of the attributes are supported:
   * Only a subset of the attributes are supported:
        - 'First, 'Last, and 'Length  on array objects (not on types
        - 'First, 'Last, and 'Length  on array objects (not on types
          and subtypes).
          and subtypes).
        - 'Min and 'Max.
        - 'Min and 'Max.
        - 'Pos and 'Val.
        - 'Pos and 'Val.
        - 'Tag.
        - 'Tag.
        - 'Range on array objects (not subtypes), but only as the right
        - 'Range on array objects (not subtypes), but only as the right
          operand of the membership (`in') operator.
          operand of the membership (`in') operator.
        - 'Access, 'Unchecked_Access, and 'Unrestricted_Access (a GNAT
        - 'Access, 'Unchecked_Access, and 'Unrestricted_Access (a GNAT
          extension).
          extension).
        - 'Address.
        - 'Address.
   * The names in `Characters.Latin_1' are not available and
   * The names in `Characters.Latin_1' are not available and
     concatenation is not implemented.  Thus, escape characters in
     concatenation is not implemented.  Thus, escape characters in
     strings are not currently available.
     strings are not currently available.
   * Equality tests (`=' and `/=') on arrays test for bitwise equality
   * Equality tests (`=' and `/=') on arrays test for bitwise equality
     of representations.  They will generally work correctly for
     of representations.  They will generally work correctly for
     strings and arrays whose elements have integer or enumeration
     strings and arrays whose elements have integer or enumeration
     types.  They may not work correctly for arrays whose element types
     types.  They may not work correctly for arrays whose element types
     have user-defined equality, for arrays of real values (in
     have user-defined equality, for arrays of real values (in
     particular, IEEE-conformant floating point, because of negative
     particular, IEEE-conformant floating point, because of negative
     zeroes and NaNs), and for arrays whose elements contain unused
     zeroes and NaNs), and for arrays whose elements contain unused
     bits with indeterminate values.
     bits with indeterminate values.
   * The other component-by-component array operations (`and', `or',
   * The other component-by-component array operations (`and', `or',
     `xor', `not', and relational tests other than equality) are not
     `xor', `not', and relational tests other than equality) are not
     implemented.
     implemented.
   * There is limited support for array and record aggregates.  They are
   * There is limited support for array and record aggregates.  They are
     permitted only on the right sides of assignments, as in these
     permitted only on the right sides of assignments, as in these
     examples:
     examples:
          set An_Array := (1, 2, 3, 4, 5, 6)
          set An_Array := (1, 2, 3, 4, 5, 6)
          set An_Array := (1, others => 0)
          set An_Array := (1, others => 0)
          set An_Array := (0|4 => 1, 1..3 => 2, 5 => 6)
          set An_Array := (0|4 => 1, 1..3 => 2, 5 => 6)
          set A_2D_Array := ((1, 2, 3), (4, 5, 6), (7, 8, 9))
          set A_2D_Array := ((1, 2, 3), (4, 5, 6), (7, 8, 9))
          set A_Record := (1, "Peter", True);
          set A_Record := (1, "Peter", True);
          set A_Record := (Name => "Peter", Id => 1, Alive => True)
          set A_Record := (Name => "Peter", Id => 1, Alive => True)
     Changing a discriminant's value by assigning an aggregate has an
     Changing a discriminant's value by assigning an aggregate has an
     undefined effect if that discriminant is used within the record.
     undefined effect if that discriminant is used within the record.
     However, you can first modify discriminants by directly assigning
     However, you can first modify discriminants by directly assigning
     to them (which normally would not be allowed in Ada), and then
     to them (which normally would not be allowed in Ada), and then
     performing an aggregate assignment.  For example, given a variable
     performing an aggregate assignment.  For example, given a variable
     `A_Rec' declared to have a type such as:
     `A_Rec' declared to have a type such as:
          type Rec (Len : Small_Integer := 0) is record
          type Rec (Len : Small_Integer := 0) is record
              Id : Integer;
              Id : Integer;
              Vals : IntArray (1 .. Len);
              Vals : IntArray (1 .. Len);
          end record;
          end record;
     you can assign a value with a different size of `Vals' with two
     you can assign a value with a different size of `Vals' with two
     assignments:
     assignments:
          set A_Rec.Len := 4
          set A_Rec.Len := 4
          set A_Rec := (Id => 42, Vals => (1, 2, 3, 4))
          set A_Rec := (Id => 42, Vals => (1, 2, 3, 4))
     As this example also illustrates, GDB is very loose about the usual
     As this example also illustrates, GDB is very loose about the usual
     rules concerning aggregates.  You may leave out some of the
     rules concerning aggregates.  You may leave out some of the
     components of an array or record aggregate (such as the `Len'
     components of an array or record aggregate (such as the `Len'
     component in the assignment to `A_Rec' above); they will retain
     component in the assignment to `A_Rec' above); they will retain
     their original values upon assignment.  You may freely use dynamic
     their original values upon assignment.  You may freely use dynamic
     values as indices in component associations.  You may even use
     values as indices in component associations.  You may even use
     overlapping or redundant component associations, although which
     overlapping or redundant component associations, although which
     component values are assigned in such cases is not defined.
     component values are assigned in such cases is not defined.
   * Calls to dispatching subprograms are not implemented.
   * Calls to dispatching subprograms are not implemented.
   * The overloading algorithm is much more limited (i.e., less
   * The overloading algorithm is much more limited (i.e., less
     selective) than that of real Ada.  It makes only limited use of
     selective) than that of real Ada.  It makes only limited use of
     the context in which a subexpression appears to resolve its
     the context in which a subexpression appears to resolve its
     meaning, and it is much looser in its rules for allowing type
     meaning, and it is much looser in its rules for allowing type
     matches.  As a result, some function calls will be ambiguous, and
     matches.  As a result, some function calls will be ambiguous, and
     the user will be asked to choose the proper resolution.
     the user will be asked to choose the proper resolution.
   * The `new' operator is not implemented.
   * The `new' operator is not implemented.
   * Entry calls are not implemented.
   * Entry calls are not implemented.
   * Aside from printing, arithmetic operations on the native VAX
   * Aside from printing, arithmetic operations on the native VAX
     floating-point formats are not supported.
     floating-point formats are not supported.
   * It is not possible to slice a packed array.
   * It is not possible to slice a packed array.


File: gdb.info,  Node: Additions to Ada,  Next: Stopping Before Main Program,  Prev: Omissions from Ada,  Up: Ada
File: gdb.info,  Node: Additions to Ada,  Next: Stopping Before Main Program,  Prev: Omissions from Ada,  Up: Ada
12.4.6.3 Additions to Ada
12.4.6.3 Additions to Ada
.........................
.........................
As it does for other languages, GDB makes certain generic extensions to
As it does for other languages, GDB makes certain generic extensions to
Ada (*note Expressions::):
Ada (*note Expressions::):
   * If the expression E is a variable residing in memory (typically a
   * If the expression E is a variable residing in memory (typically a
     local variable or array element) and N is a positive integer, then
     local variable or array element) and N is a positive integer, then
     `E@N' displays the values of E and the N-1 adjacent variables
     `E@N' displays the values of E and the N-1 adjacent variables
     following it in memory as an array.  In Ada, this operator is
     following it in memory as an array.  In Ada, this operator is
     generally not necessary, since its prime use is in displaying
     generally not necessary, since its prime use is in displaying
     parts of an array, and slicing will usually do this in Ada.
     parts of an array, and slicing will usually do this in Ada.
     However, there are occasional uses when debugging programs in
     However, there are occasional uses when debugging programs in
     which certain debugging information has been optimized away.
     which certain debugging information has been optimized away.
   * `B::VAR' means "the variable named VAR that appears in function or
   * `B::VAR' means "the variable named VAR that appears in function or
     file B."  When B is a file name, you must typically surround it in
     file B."  When B is a file name, you must typically surround it in
     single quotes.
     single quotes.
   * The expression `{TYPE} ADDR' means "the variable of type TYPE that
   * The expression `{TYPE} ADDR' means "the variable of type TYPE that
     appears at address ADDR."
     appears at address ADDR."
   * A name starting with `$' is a convenience variable (*note
   * A name starting with `$' is a convenience variable (*note
     Convenience Vars::) or a machine register (*note Registers::).
     Convenience Vars::) or a machine register (*note Registers::).
   In addition, GDB provides a few other shortcuts and outright
   In addition, GDB provides a few other shortcuts and outright
additions specific to Ada:
additions specific to Ada:
   * The assignment statement is allowed as an expression, returning
   * The assignment statement is allowed as an expression, returning
     its right-hand operand as its value.  Thus, you may enter
     its right-hand operand as its value.  Thus, you may enter
          set x := y + 3
          set x := y + 3
          print A(tmp := y + 1)
          print A(tmp := y + 1)
   * The semicolon is allowed as an "operator,"  returning as its value
   * The semicolon is allowed as an "operator,"  returning as its value
     the value of its right-hand operand.  This allows, for example,
     the value of its right-hand operand.  This allows, for example,
     complex conditional breaks:
     complex conditional breaks:
          break f
          break f
          condition 1 (report(i); k += 1; A(k) > 100)
          condition 1 (report(i); k += 1; A(k) > 100)
   * Rather than use catenation and symbolic character names to
   * Rather than use catenation and symbolic character names to
     introduce special characters into strings, one may instead use a
     introduce special characters into strings, one may instead use a
     special bracket notation, which is also used to print strings.  A
     special bracket notation, which is also used to print strings.  A
     sequence of characters of the form `["XX"]' within a string or
     sequence of characters of the form `["XX"]' within a string or
     character literal denotes the (single) character whose numeric
     character literal denotes the (single) character whose numeric
     encoding is XX in hexadecimal.  The sequence of characters `["""]'
     encoding is XX in hexadecimal.  The sequence of characters `["""]'
     also denotes a single quotation mark in strings.   For example,
     also denotes a single quotation mark in strings.   For example,
             "One line.["0a"]Next line.["0a"]"
             "One line.["0a"]Next line.["0a"]"
     contains an ASCII newline character (`Ada.Characters.Latin_1.LF')
     contains an ASCII newline character (`Ada.Characters.Latin_1.LF')
     after each period.
     after each period.
   * The subtype used as a prefix for the attributes 'Pos, 'Min, and
   * The subtype used as a prefix for the attributes 'Pos, 'Min, and
     'Max is optional (and is ignored in any case).  For example, it is
     'Max is optional (and is ignored in any case).  For example, it is
     valid to write
     valid to write
          print 'max(x, y)
          print 'max(x, y)
   * When printing arrays, GDB uses positional notation when the array
   * When printing arrays, GDB uses positional notation when the array
     has a lower bound of 1, and uses a modified named notation
     has a lower bound of 1, and uses a modified named notation
     otherwise.  For example, a one-dimensional array of three integers
     otherwise.  For example, a one-dimensional array of three integers
     with a lower bound of 3 might print as
     with a lower bound of 3 might print as
          (3 => 10, 17, 1)
          (3 => 10, 17, 1)
     That is, in contrast to valid Ada, only the first component has a
     That is, in contrast to valid Ada, only the first component has a
     `=>' clause.
     `=>' clause.
   * You may abbreviate attributes in expressions with any unique,
   * You may abbreviate attributes in expressions with any unique,
     multi-character subsequence of their names (an exact match gets
     multi-character subsequence of their names (an exact match gets
     preference).  For example, you may use a'len, a'gth, or a'lh in
     preference).  For example, you may use a'len, a'gth, or a'lh in
     place of  a'length.
     place of  a'length.
   * Since Ada is case-insensitive, the debugger normally maps
   * Since Ada is case-insensitive, the debugger normally maps
     identifiers you type to lower case.  The GNAT compiler uses
     identifiers you type to lower case.  The GNAT compiler uses
     upper-case characters for some of its internal identifiers, which
     upper-case characters for some of its internal identifiers, which
     are normally of no interest to users.  For the rare occasions when
     are normally of no interest to users.  For the rare occasions when
     you actually have to look at them, enclose them in angle brackets
     you actually have to look at them, enclose them in angle brackets
     to avoid the lower-case mapping.  For example,
     to avoid the lower-case mapping.  For example,
          gdb print [0]
          gdb print [0]
   * Printing an object of class-wide type or dereferencing an
   * Printing an object of class-wide type or dereferencing an
     access-to-class-wide value will display all the components of the
     access-to-class-wide value will display all the components of the
     object's specific type (as indicated by its run-time tag).
     object's specific type (as indicated by its run-time tag).
     Likewise, component selection on such a value will operate on the
     Likewise, component selection on such a value will operate on the
     specific type of the object.
     specific type of the object.


File: gdb.info,  Node: Stopping Before Main Program,  Next: Ada Glitches,  Prev: Additions to Ada,  Up: Ada
File: gdb.info,  Node: Stopping Before Main Program,  Next: Ada Glitches,  Prev: Additions to Ada,  Up: Ada
12.4.6.4 Stopping at the Very Beginning
12.4.6.4 Stopping at the Very Beginning
.......................................
.......................................
It is sometimes necessary to debug the program during elaboration, and
It is sometimes necessary to debug the program during elaboration, and
before reaching the main procedure.  As defined in the Ada Reference
before reaching the main procedure.  As defined in the Ada Reference
Manual, the elaboration code is invoked from a procedure called
Manual, the elaboration code is invoked from a procedure called
`adainit'.  To run your program up to the beginning of elaboration,
`adainit'.  To run your program up to the beginning of elaboration,
simply use the following two commands: `tbreak adainit' and `run'.
simply use the following two commands: `tbreak adainit' and `run'.


File: gdb.info,  Node: Ada Glitches,  Prev: Stopping Before Main Program,  Up: Ada
File: gdb.info,  Node: Ada Glitches,  Prev: Stopping Before Main Program,  Up: Ada
12.4.6.5 Known Peculiarities of Ada Mode
12.4.6.5 Known Peculiarities of Ada Mode
........................................
........................................
Besides the omissions listed previously (*note Omissions from Ada::),
Besides the omissions listed previously (*note Omissions from Ada::),
we know of several problems with and limitations of Ada mode in GDB,
we know of several problems with and limitations of Ada mode in GDB,
some of which will be fixed with planned future releases of the debugger
some of which will be fixed with planned future releases of the debugger
and the GNU Ada compiler.
and the GNU Ada compiler.
   * Currently, the debugger has insufficient information to determine
   * Currently, the debugger has insufficient information to determine
     whether certain pointers represent pointers to objects or the
     whether certain pointers represent pointers to objects or the
     objects themselves.  Thus, the user may have to tack an extra
     objects themselves.  Thus, the user may have to tack an extra
     `.all' after an expression to get it printed properly.
     `.all' after an expression to get it printed properly.
   * Static constants that the compiler chooses not to materialize as
   * Static constants that the compiler chooses not to materialize as
     objects in storage are invisible to the debugger.
     objects in storage are invisible to the debugger.
   * Named parameter associations in function argument lists are
   * Named parameter associations in function argument lists are
     ignored (the argument lists are treated as positional).
     ignored (the argument lists are treated as positional).
   * Many useful library packages are currently invisible to the
   * Many useful library packages are currently invisible to the
     debugger.
     debugger.
   * Fixed-point arithmetic, conversions, input, and output is carried
   * Fixed-point arithmetic, conversions, input, and output is carried
     out using floating-point arithmetic, and may give results that
     out using floating-point arithmetic, and may give results that
     only approximate those on the host machine.
     only approximate those on the host machine.
   * The type of the 'Address attribute may not be `System.Address'.
   * The type of the 'Address attribute may not be `System.Address'.
   * The GNAT compiler never generates the prefix `Standard' for any of
   * The GNAT compiler never generates the prefix `Standard' for any of
     the standard symbols defined by the Ada language.  GDB knows about
     the standard symbols defined by the Ada language.  GDB knows about
     this: it will strip the prefix from names when you use it, and
     this: it will strip the prefix from names when you use it, and
     will never look for a name you have so qualified among local
     will never look for a name you have so qualified among local
     symbols, nor match against symbols in other packages or
     symbols, nor match against symbols in other packages or
     subprograms.  If you have defined entities anywhere in your
     subprograms.  If you have defined entities anywhere in your
     program other than parameters and local variables whose simple
     program other than parameters and local variables whose simple
     names match names in `Standard', GNAT's lack of qualification here
     names match names in `Standard', GNAT's lack of qualification here
     can cause confusion.  When this happens, you can usually resolve
     can cause confusion.  When this happens, you can usually resolve
     the confusion by qualifying the problematic names with package
     the confusion by qualifying the problematic names with package
     `Standard' explicitly.
     `Standard' explicitly.


File: gdb.info,  Node: Unsupported Languages,  Prev: Supported Languages,  Up: Languages
File: gdb.info,  Node: Unsupported Languages,  Prev: Supported Languages,  Up: Languages
12.5 Unsupported Languages
12.5 Unsupported Languages
==========================
==========================
In addition to the other fully-supported programming languages, GDB
In addition to the other fully-supported programming languages, GDB
also provides a pseudo-language, called `minimal'.  It does not
also provides a pseudo-language, called `minimal'.  It does not
represent a real programming language, but provides a set of
represent a real programming language, but provides a set of
capabilities close to what the C or assembly languages provide.  This
capabilities close to what the C or assembly languages provide.  This
should allow most simple operations to be performed while debugging an
should allow most simple operations to be performed while debugging an
application that uses a language currently not supported by GDB.
application that uses a language currently not supported by GDB.
   If the language is set to `auto', GDB will automatically select this
   If the language is set to `auto', GDB will automatically select this
language if the current frame corresponds to an unsupported language.
language if the current frame corresponds to an unsupported language.


File: gdb.info,  Node: Symbols,  Next: Altering,  Prev: Languages,  Up: Top
File: gdb.info,  Node: Symbols,  Next: Altering,  Prev: Languages,  Up: Top
13 Examining the Symbol Table
13 Examining the Symbol Table
*****************************
*****************************
The commands described in this chapter allow you to inquire about the
The commands described in this chapter allow you to inquire about the
symbols (names of variables, functions and types) defined in your
symbols (names of variables, functions and types) defined in your
program.  This information is inherent in the text of your program and
program.  This information is inherent in the text of your program and
does not change as your program executes.  GDB finds it in your
does not change as your program executes.  GDB finds it in your
program's symbol table, in the file indicated when you started GDB
program's symbol table, in the file indicated when you started GDB
(*note Choosing Files: File Options.), or by one of the file-management
(*note Choosing Files: File Options.), or by one of the file-management
commands (*note Commands to Specify Files: Files.).
commands (*note Commands to Specify Files: Files.).
   Occasionally, you may need to refer to symbols that contain unusual
   Occasionally, you may need to refer to symbols that contain unusual
characters, which GDB ordinarily treats as word delimiters.  The most
characters, which GDB ordinarily treats as word delimiters.  The most
frequent case is in referring to static variables in other source files
frequent case is in referring to static variables in other source files
(*note Program Variables: Variables.).  File names are recorded in
(*note Program Variables: Variables.).  File names are recorded in
object files as debugging symbols, but GDB would ordinarily parse a
object files as debugging symbols, but GDB would ordinarily parse a
typical file name, like `foo.c', as the three words `foo' `.' `c'.  To
typical file name, like `foo.c', as the three words `foo' `.' `c'.  To
allow GDB to recognize `foo.c' as a single symbol, enclose it in single
allow GDB to recognize `foo.c' as a single symbol, enclose it in single
quotes; for example,
quotes; for example,
     p 'foo.c'::x
     p 'foo.c'::x
looks up the value of `x' in the scope of the file `foo.c'.
looks up the value of `x' in the scope of the file `foo.c'.
`set case-sensitive on'
`set case-sensitive on'
`set case-sensitive off'
`set case-sensitive off'
`set case-sensitive auto'
`set case-sensitive auto'
     Normally, when GDB looks up symbols, it matches their names with
     Normally, when GDB looks up symbols, it matches their names with
     case sensitivity determined by the current source language.
     case sensitivity determined by the current source language.
     Occasionally, you may wish to control that.  The command `set
     Occasionally, you may wish to control that.  The command `set
     case-sensitive' lets you do that by specifying `on' for
     case-sensitive' lets you do that by specifying `on' for
     case-sensitive matches or `off' for case-insensitive ones.  If you
     case-sensitive matches or `off' for case-insensitive ones.  If you
     specify `auto', case sensitivity is reset to the default suitable
     specify `auto', case sensitivity is reset to the default suitable
     for the source language.  The default is case-sensitive matches
     for the source language.  The default is case-sensitive matches
     for all languages except for Fortran, for which the default is
     for all languages except for Fortran, for which the default is
     case-insensitive matches.
     case-insensitive matches.
`show case-sensitive'
`show case-sensitive'
     This command shows the current setting of case sensitivity for
     This command shows the current setting of case sensitivity for
     symbols lookups.
     symbols lookups.
`info address SYMBOL'
`info address SYMBOL'
     Describe where the data for SYMBOL is stored.  For a register
     Describe where the data for SYMBOL is stored.  For a register
     variable, this says which register it is kept in.  For a
     variable, this says which register it is kept in.  For a
     non-register local variable, this prints the stack-frame offset at
     non-register local variable, this prints the stack-frame offset at
     which the variable is always stored.
     which the variable is always stored.
     Note the contrast with `print &SYMBOL', which does not work at all
     Note the contrast with `print &SYMBOL', which does not work at all
     for a register variable, and for a stack local variable prints the
     for a register variable, and for a stack local variable prints the
     exact address of the current instantiation of the variable.
     exact address of the current instantiation of the variable.
`info symbol ADDR'
`info symbol ADDR'
     Print the name of a symbol which is stored at the address ADDR.
     Print the name of a symbol which is stored at the address ADDR.
     If no symbol is stored exactly at ADDR, GDB prints the nearest
     If no symbol is stored exactly at ADDR, GDB prints the nearest
     symbol and an offset from it:
     symbol and an offset from it:
          (gdb) info symbol 0x54320
          (gdb) info symbol 0x54320
          _initialize_vx + 396 in section .text
          _initialize_vx + 396 in section .text
     This is the opposite of the `info address' command.  You can use
     This is the opposite of the `info address' command.  You can use
     it to find out the name of a variable or a function given its
     it to find out the name of a variable or a function given its
     address.
     address.
`whatis [ARG]'
`whatis [ARG]'
     Print the data type of ARG, which can be either an expression or a
     Print the data type of ARG, which can be either an expression or a
     data type.  With no argument, print the data type of `$', the last
     data type.  With no argument, print the data type of `$', the last
     value in the value history.  If ARG is an expression, it is not
     value in the value history.  If ARG is an expression, it is not
     actually evaluated, and any side-effecting operations (such as
     actually evaluated, and any side-effecting operations (such as
     assignments or function calls) inside it do not take place.  If
     assignments or function calls) inside it do not take place.  If
     ARG is a type name, it may be the name of a type or typedef, or
     ARG is a type name, it may be the name of a type or typedef, or
     for C code it may have the form `class CLASS-NAME', `struct
     for C code it may have the form `class CLASS-NAME', `struct
     STRUCT-TAG', `union UNION-TAG' or `enum ENUM-TAG'.  *Note
     STRUCT-TAG', `union UNION-TAG' or `enum ENUM-TAG'.  *Note
     Expressions: Expressions.
     Expressions: Expressions.
`ptype [ARG]'
`ptype [ARG]'
     `ptype' accepts the same arguments as `whatis', but prints a
     `ptype' accepts the same arguments as `whatis', but prints a
     detailed description of the type, instead of just the name of the
     detailed description of the type, instead of just the name of the
     type.  *Note Expressions: Expressions.
     type.  *Note Expressions: Expressions.
     For example, for this variable declaration:
     For example, for this variable declaration:
          struct complex {double real; double imag;} v;
          struct complex {double real; double imag;} v;
     the two commands give this output:
     the two commands give this output:
          (gdb) whatis v
          (gdb) whatis v
          type = struct complex
          type = struct complex
          (gdb) ptype v
          (gdb) ptype v
          type = struct complex {
          type = struct complex {
              double real;
              double real;
              double imag;
              double imag;
          }
          }
     As with `whatis', using `ptype' without an argument refers to the
     As with `whatis', using `ptype' without an argument refers to the
     type of `$', the last value in the value history.
     type of `$', the last value in the value history.
     Sometimes, programs use opaque data types or incomplete
     Sometimes, programs use opaque data types or incomplete
     specifications of complex data structure.  If the debug
     specifications of complex data structure.  If the debug
     information included in the program does not allow GDB to display
     information included in the program does not allow GDB to display
     a full declaration of the data type, it will say `
     a full declaration of the data type, it will say `
     type>'.  For example, given these declarations:
     type>'.  For example, given these declarations:
              struct foo;
              struct foo;
              struct foo *fooptr;
              struct foo *fooptr;
     but no definition for `struct foo' itself, GDB will say:
     but no definition for `struct foo' itself, GDB will say:
            (gdb) ptype foo
            (gdb) ptype foo
            $1 = 
            $1 = 
     "Incomplete type" is C terminology for data types that are not
     "Incomplete type" is C terminology for data types that are not
     completely specified.
     completely specified.
`info types REGEXP'
`info types REGEXP'
`info types'
`info types'
     Print a brief description of all types whose names match the
     Print a brief description of all types whose names match the
     regular expression REGEXP (or all types in your program, if you
     regular expression REGEXP (or all types in your program, if you
     supply no argument).  Each complete typename is matched as though
     supply no argument).  Each complete typename is matched as though
     it were a complete line; thus, `i type value' gives information on
     it were a complete line; thus, `i type value' gives information on
     all types in your program whose names include the string `value',
     all types in your program whose names include the string `value',
     but `i type ^value$' gives information only on types whose complete
     but `i type ^value$' gives information only on types whose complete
     name is `value'.
     name is `value'.
     This command differs from `ptype' in two ways: first, like
     This command differs from `ptype' in two ways: first, like
     `whatis', it does not print a detailed description; second, it
     `whatis', it does not print a detailed description; second, it
     lists all source files where a type is defined.
     lists all source files where a type is defined.
`info scope LOCATION'
`info scope LOCATION'
     List all the variables local to a particular scope.  This command
     List all the variables local to a particular scope.  This command
     accepts a LOCATION argument--a function name, a source line, or an
     accepts a LOCATION argument--a function name, a source line, or an
     address preceded by a `*', and prints all the variables local to
     address preceded by a `*', and prints all the variables local to
     the scope defined by that location.  (*Note Specify Location::, for
     the scope defined by that location.  (*Note Specify Location::, for
     details about supported forms of LOCATION.)  For example:
     details about supported forms of LOCATION.)  For example:
          (gdb) info scope command_line_handler
          (gdb) info scope command_line_handler
          Scope for command_line_handler:
          Scope for command_line_handler:
          Symbol rl is an argument at stack/frame offset 8, length 4.
          Symbol rl is an argument at stack/frame offset 8, length 4.
          Symbol linebuffer is in static storage at address 0x150a18, length 4.
          Symbol linebuffer is in static storage at address 0x150a18, length 4.
          Symbol linelength is in static storage at address 0x150a1c, length 4.
          Symbol linelength is in static storage at address 0x150a1c, length 4.
          Symbol p is a local variable in register $esi, length 4.
          Symbol p is a local variable in register $esi, length 4.
          Symbol p1 is a local variable in register $ebx, length 4.
          Symbol p1 is a local variable in register $ebx, length 4.
          Symbol nline is a local variable in register $edx, length 4.
          Symbol nline is a local variable in register $edx, length 4.
          Symbol repeat is a local variable at frame offset -8, length 4.
          Symbol repeat is a local variable at frame offset -8, length 4.
     This command is especially useful for determining what data to
     This command is especially useful for determining what data to
     collect during a "trace experiment", see *Note collect: Tracepoint
     collect during a "trace experiment", see *Note collect: Tracepoint
     Actions.
     Actions.
`info source'
`info source'
     Show information about the current source file--that is, the
     Show information about the current source file--that is, the
     source file for the function containing the current point of
     source file for the function containing the current point of
     execution:
     execution:
        * the name of the source file, and the directory containing it,
        * the name of the source file, and the directory containing it,
        * the directory it was compiled in,
        * the directory it was compiled in,
        * its length, in lines,
        * its length, in lines,
        * which programming language it is written in,
        * which programming language it is written in,
        * whether the executable includes debugging information for
        * whether the executable includes debugging information for
          that file, and if so, what format the information is in
          that file, and if so, what format the information is in
          (e.g., STABS, Dwarf 2, etc.), and
          (e.g., STABS, Dwarf 2, etc.), and
        * whether the debugging information includes information about
        * whether the debugging information includes information about
          preprocessor macros.
          preprocessor macros.
`info sources'
`info sources'
     Print the names of all source files in your program for which
     Print the names of all source files in your program for which
     there is debugging information, organized into two lists: files
     there is debugging information, organized into two lists: files
     whose symbols have already been read, and files whose symbols will
     whose symbols have already been read, and files whose symbols will
     be read when needed.
     be read when needed.
`info functions'
`info functions'
     Print the names and data types of all defined functions.
     Print the names and data types of all defined functions.
`info functions REGEXP'
`info functions REGEXP'
     Print the names and data types of all defined functions whose
     Print the names and data types of all defined functions whose
     names contain a match for regular expression REGEXP.  Thus, `info
     names contain a match for regular expression REGEXP.  Thus, `info
     fun step' finds all functions whose names include `step'; `info
     fun step' finds all functions whose names include `step'; `info
     fun ^step' finds those whose names start with `step'.  If a
     fun ^step' finds those whose names start with `step'.  If a
     function name contains characters that conflict with the regular
     function name contains characters that conflict with the regular
     expression language (e.g.  `operator*()'), they may be quoted with
     expression language (e.g.  `operator*()'), they may be quoted with
     a backslash.
     a backslash.
`info variables'
`info variables'
     Print the names and data types of all variables that are declared
     Print the names and data types of all variables that are declared
     outside of functions (i.e. excluding local variables).
     outside of functions (i.e. excluding local variables).
`info variables REGEXP'
`info variables REGEXP'
     Print the names and data types of all variables (except for local
     Print the names and data types of all variables (except for local
     variables) whose names contain a match for regular expression
     variables) whose names contain a match for regular expression
     REGEXP.
     REGEXP.
`info classes'
`info classes'
`info classes REGEXP'
`info classes REGEXP'
     Display all Objective-C classes in your program, or (with the
     Display all Objective-C classes in your program, or (with the
     REGEXP argument) all those matching a particular regular
     REGEXP argument) all those matching a particular regular
     expression.
     expression.
`info selectors'
`info selectors'
`info selectors REGEXP'
`info selectors REGEXP'
     Display all Objective-C selectors in your program, or (with the
     Display all Objective-C selectors in your program, or (with the
     REGEXP argument) all those matching a particular regular
     REGEXP argument) all those matching a particular regular
     expression.
     expression.
     Some systems allow individual object files that make up your
     Some systems allow individual object files that make up your
     program to be replaced without stopping and restarting your
     program to be replaced without stopping and restarting your
     program.  For example, in VxWorks you can simply recompile a
     program.  For example, in VxWorks you can simply recompile a
     defective object file and keep on running.  If you are running on
     defective object file and keep on running.  If you are running on
     one of these systems, you can allow GDB to reload the symbols for
     one of these systems, you can allow GDB to reload the symbols for
     automatically relinked modules:
     automatically relinked modules:
    `set symbol-reloading on'
    `set symbol-reloading on'
          Replace symbol definitions for the corresponding source file
          Replace symbol definitions for the corresponding source file
          when an object file with a particular name is seen again.
          when an object file with a particular name is seen again.
    `set symbol-reloading off'
    `set symbol-reloading off'
          Do not replace symbol definitions when encountering object
          Do not replace symbol definitions when encountering object
          files of the same name more than once.  This is the default
          files of the same name more than once.  This is the default
          state; if you are not running on a system that permits
          state; if you are not running on a system that permits
          automatic relinking of modules, you should leave
          automatic relinking of modules, you should leave
          `symbol-reloading' off, since otherwise GDB may discard
          `symbol-reloading' off, since otherwise GDB may discard
          symbols when linking large programs, that may contain several
          symbols when linking large programs, that may contain several
          modules (from different directories or libraries) with the
          modules (from different directories or libraries) with the
          same name.
          same name.
    `show symbol-reloading'
    `show symbol-reloading'
          Show the current `on' or `off' setting.
          Show the current `on' or `off' setting.
`set opaque-type-resolution on'
`set opaque-type-resolution on'
     Tell GDB to resolve opaque types.  An opaque type is a type
     Tell GDB to resolve opaque types.  An opaque type is a type
     declared as a pointer to a `struct', `class', or `union'--for
     declared as a pointer to a `struct', `class', or `union'--for
     example, `struct MyType *'--that is used in one source file
     example, `struct MyType *'--that is used in one source file
     although the full declaration of `struct MyType' is in another
     although the full declaration of `struct MyType' is in another
     source file.  The default is on.
     source file.  The default is on.
     A change in the setting of this subcommand will not take effect
     A change in the setting of this subcommand will not take effect
     until the next time symbols for a file are loaded.
     until the next time symbols for a file are loaded.
`set opaque-type-resolution off'
`set opaque-type-resolution off'
     Tell GDB not to resolve opaque types.  In this case, the type is
     Tell GDB not to resolve opaque types.  In this case, the type is
     printed as follows:
     printed as follows:
          {}
          {}
`show opaque-type-resolution'
`show opaque-type-resolution'
     Show whether opaque types are resolved or not.
     Show whether opaque types are resolved or not.
`maint print symbols FILENAME'
`maint print symbols FILENAME'
`maint print psymbols FILENAME'
`maint print psymbols FILENAME'
`maint print msymbols FILENAME'
`maint print msymbols FILENAME'
     Write a dump of debugging symbol data into the file FILENAME.
     Write a dump of debugging symbol data into the file FILENAME.
     These commands are used to debug the GDB symbol-reading code.  Only
     These commands are used to debug the GDB symbol-reading code.  Only
     symbols with debugging data are included.  If you use `maint print
     symbols with debugging data are included.  If you use `maint print
     symbols', GDB includes all the symbols for which it has already
     symbols', GDB includes all the symbols for which it has already
     collected full details: that is, FILENAME reflects symbols for
     collected full details: that is, FILENAME reflects symbols for
     only those files whose symbols GDB has read.  You can use the
     only those files whose symbols GDB has read.  You can use the
     command `info sources' to find out which files these are.  If you
     command `info sources' to find out which files these are.  If you
     use `maint print psymbols' instead, the dump shows information
     use `maint print psymbols' instead, the dump shows information
     about symbols that GDB only knows partially--that is, symbols
     about symbols that GDB only knows partially--that is, symbols
     defined in files that GDB has skimmed, but not yet read
     defined in files that GDB has skimmed, but not yet read
     completely.  Finally, `maint print msymbols' dumps just the
     completely.  Finally, `maint print msymbols' dumps just the
     minimal symbol information required for each object file from
     minimal symbol information required for each object file from
     which GDB has read some symbols.  *Note Commands to Specify Files:
     which GDB has read some symbols.  *Note Commands to Specify Files:
     Files, for a discussion of how GDB reads symbols (in the
     Files, for a discussion of how GDB reads symbols (in the
     description of `symbol-file').
     description of `symbol-file').
`maint info symtabs [ REGEXP ]'
`maint info symtabs [ REGEXP ]'
`maint info psymtabs [ REGEXP ]'
`maint info psymtabs [ REGEXP ]'
     List the `struct symtab' or `struct partial_symtab' structures
     List the `struct symtab' or `struct partial_symtab' structures
     whose names match REGEXP.  If REGEXP is not given, list them all.
     whose names match REGEXP.  If REGEXP is not given, list them all.
     The output includes expressions which you can copy into a GDB
     The output includes expressions which you can copy into a GDB
     debugging this one to examine a particular structure in more
     debugging this one to examine a particular structure in more
     detail.  For example:
     detail.  For example:
          (gdb) maint info psymtabs dwarf2read
          (gdb) maint info psymtabs dwarf2read
          { objfile /home/gnu/build/gdb/gdb
          { objfile /home/gnu/build/gdb/gdb
            ((struct objfile *) 0x82e69d0)
            ((struct objfile *) 0x82e69d0)
            { psymtab /home/gnu/src/gdb/dwarf2read.c
            { psymtab /home/gnu/src/gdb/dwarf2read.c
              ((struct partial_symtab *) 0x8474b10)
              ((struct partial_symtab *) 0x8474b10)
              readin no
              readin no
              fullname (null)
              fullname (null)
              text addresses 0x814d3c8 -- 0x8158074
              text addresses 0x814d3c8 -- 0x8158074
              globals (* (struct partial_symbol **) 0x8507a08 @ 9)
              globals (* (struct partial_symbol **) 0x8507a08 @ 9)
              statics (* (struct partial_symbol **) 0x40e95b78 @ 2882)
              statics (* (struct partial_symbol **) 0x40e95b78 @ 2882)
              dependencies (none)
              dependencies (none)
            }
            }
          }
          }
          (gdb) maint info symtabs
          (gdb) maint info symtabs
          (gdb)
          (gdb)
     We see that there is one partial symbol table whose filename
     We see that there is one partial symbol table whose filename
     contains the string `dwarf2read', belonging to the `gdb'
     contains the string `dwarf2read', belonging to the `gdb'
     executable; and we see that GDB has not read in any symtabs yet at
     executable; and we see that GDB has not read in any symtabs yet at
     all.  If we set a breakpoint on a function, that will cause GDB to
     all.  If we set a breakpoint on a function, that will cause GDB to
     read the symtab for the compilation unit containing that function:
     read the symtab for the compilation unit containing that function:
          (gdb) break dwarf2_psymtab_to_symtab
          (gdb) break dwarf2_psymtab_to_symtab
          Breakpoint 1 at 0x814e5da: file /home/gnu/src/gdb/dwarf2read.c,
          Breakpoint 1 at 0x814e5da: file /home/gnu/src/gdb/dwarf2read.c,
          line 1574.
          line 1574.
          (gdb) maint info symtabs
          (gdb) maint info symtabs
          { objfile /home/gnu/build/gdb/gdb
          { objfile /home/gnu/build/gdb/gdb
            ((struct objfile *) 0x82e69d0)
            ((struct objfile *) 0x82e69d0)
            { symtab /home/gnu/src/gdb/dwarf2read.c
            { symtab /home/gnu/src/gdb/dwarf2read.c
              ((struct symtab *) 0x86c1f38)
              ((struct symtab *) 0x86c1f38)
              dirname (null)
              dirname (null)
              fullname (null)
              fullname (null)
              blockvector ((struct blockvector *) 0x86c1bd0) (primary)
              blockvector ((struct blockvector *) 0x86c1bd0) (primary)
              linetable ((struct linetable *) 0x8370fa0)
              linetable ((struct linetable *) 0x8370fa0)
              debugformat DWARF 2
              debugformat DWARF 2
            }
            }
          }
          }
          (gdb)
          (gdb)


File: gdb.info,  Node: Altering,  Next: GDB Files,  Prev: Symbols,  Up: Top
File: gdb.info,  Node: Altering,  Next: GDB Files,  Prev: Symbols,  Up: Top
14 Altering Execution
14 Altering Execution
*********************
*********************
Once you think you have found an error in your program, you might want
Once you think you have found an error in your program, you might want
to find out for certain whether correcting the apparent error would
to find out for certain whether correcting the apparent error would
lead to correct results in the rest of the run.  You can find the
lead to correct results in the rest of the run.  You can find the
answer by experiment, using the GDB features for altering execution of
answer by experiment, using the GDB features for altering execution of
the program.
the program.
   For example, you can store new values into variables or memory
   For example, you can store new values into variables or memory
locations, give your program a signal, restart it at a different
locations, give your program a signal, restart it at a different
address, or even return prematurely from a function.
address, or even return prematurely from a function.
* Menu:
* Menu:
* Assignment::                  Assignment to variables
* Assignment::                  Assignment to variables
* Jumping::                     Continuing at a different address
* Jumping::                     Continuing at a different address
* Signaling::                   Giving your program a signal
* Signaling::                   Giving your program a signal
* Returning::                   Returning from a function
* Returning::                   Returning from a function
* Calling::                     Calling your program's functions
* Calling::                     Calling your program's functions
* Patching::                    Patching your program
* Patching::                    Patching your program


File: gdb.info,  Node: Assignment,  Next: Jumping,  Up: Altering
File: gdb.info,  Node: Assignment,  Next: Jumping,  Up: Altering
14.1 Assignment to Variables
14.1 Assignment to Variables
============================
============================
To alter the value of a variable, evaluate an assignment expression.
To alter the value of a variable, evaluate an assignment expression.
*Note Expressions: Expressions.  For example,
*Note Expressions: Expressions.  For example,
     print x=4
     print x=4
stores the value 4 into the variable `x', and then prints the value of
stores the value 4 into the variable `x', and then prints the value of
the assignment expression (which is 4).  *Note Using GDB with Different
the assignment expression (which is 4).  *Note Using GDB with Different
Languages: Languages, for more information on operators in supported
Languages: Languages, for more information on operators in supported
languages.
languages.
   If you are not interested in seeing the value of the assignment, use
   If you are not interested in seeing the value of the assignment, use
the `set' command instead of the `print' command.  `set' is really the
the `set' command instead of the `print' command.  `set' is really the
same as `print' except that the expression's value is not printed and
same as `print' except that the expression's value is not printed and
is not put in the value history (*note Value History: Value History.).
is not put in the value history (*note Value History: Value History.).
The expression is evaluated only for its effects.
The expression is evaluated only for its effects.
   If the beginning of the argument string of the `set' command appears
   If the beginning of the argument string of the `set' command appears
identical to a `set' subcommand, use the `set variable' command instead
identical to a `set' subcommand, use the `set variable' command instead
of just `set'.  This command is identical to `set' except for its lack
of just `set'.  This command is identical to `set' except for its lack
of subcommands.  For example, if your program has a variable `width',
of subcommands.  For example, if your program has a variable `width',
you get an error if you try to set a new value with just `set
you get an error if you try to set a new value with just `set
width=13', because GDB has the command `set width':
width=13', because GDB has the command `set width':
     (gdb) whatis width
     (gdb) whatis width
     type = double
     type = double
     (gdb) p width
     (gdb) p width
     $4 = 13
     $4 = 13
     (gdb) set width=47
     (gdb) set width=47
     Invalid syntax in expression.
     Invalid syntax in expression.
The invalid expression, of course, is `=47'.  In order to actually set
The invalid expression, of course, is `=47'.  In order to actually set
the program's variable `width', use
the program's variable `width', use
     (gdb) set var width=47
     (gdb) set var width=47
   Because the `set' command has many subcommands that can conflict
   Because the `set' command has many subcommands that can conflict
with the names of program variables, it is a good idea to use the `set
with the names of program variables, it is a good idea to use the `set
variable' command instead of just `set'.  For example, if your program
variable' command instead of just `set'.  For example, if your program
has a variable `g', you run into problems if you try to set a new value
has a variable `g', you run into problems if you try to set a new value
with just `set g=4', because GDB has the command `set gnutarget',
with just `set g=4', because GDB has the command `set gnutarget',
abbreviated `set g':
abbreviated `set g':
     (gdb) whatis g
     (gdb) whatis g
     type = double
     type = double
     (gdb) p g
     (gdb) p g
     $1 = 1
     $1 = 1
     (gdb) set g=4
     (gdb) set g=4
     (gdb) p g
     (gdb) p g
     $2 = 1
     $2 = 1
     (gdb) r
     (gdb) r
     The program being debugged has been started already.
     The program being debugged has been started already.
     Start it from the beginning? (y or n) y
     Start it from the beginning? (y or n) y
     Starting program: /home/smith/cc_progs/a.out
     Starting program: /home/smith/cc_progs/a.out
     "/home/smith/cc_progs/a.out": can't open to read symbols:
     "/home/smith/cc_progs/a.out": can't open to read symbols:
                                      Invalid bfd target.
                                      Invalid bfd target.
     (gdb) show g
     (gdb) show g
     The current BFD target is "=4".
     The current BFD target is "=4".
The program variable `g' did not change, and you silently set the
The program variable `g' did not change, and you silently set the
`gnutarget' to an invalid value.  In order to set the variable `g', use
`gnutarget' to an invalid value.  In order to set the variable `g', use
     (gdb) set var g=4
     (gdb) set var g=4
   GDB allows more implicit conversions in assignments than C; you can
   GDB allows more implicit conversions in assignments than C; you can
freely store an integer value into a pointer variable or vice versa,
freely store an integer value into a pointer variable or vice versa,
and you can convert any structure to any other structure that is the
and you can convert any structure to any other structure that is the
same length or shorter.
same length or shorter.
   To store values into arbitrary places in memory, use the `{...}'
   To store values into arbitrary places in memory, use the `{...}'
construct to generate a value of specified type at a specified address
construct to generate a value of specified type at a specified address
(*note Expressions: Expressions.).  For example, `{int}0x83040' refers
(*note Expressions: Expressions.).  For example, `{int}0x83040' refers
to memory location `0x83040' as an integer (which implies a certain size
to memory location `0x83040' as an integer (which implies a certain size
and representation in memory), and
and representation in memory), and
     set {int}0x83040 = 4
     set {int}0x83040 = 4
stores the value 4 into that memory location.
stores the value 4 into that memory location.


File: gdb.info,  Node: Jumping,  Next: Signaling,  Prev: Assignment,  Up: Altering
File: gdb.info,  Node: Jumping,  Next: Signaling,  Prev: Assignment,  Up: Altering
14.2 Continuing at a Different Address
14.2 Continuing at a Different Address
======================================
======================================
Ordinarily, when you continue your program, you do so at the place where
Ordinarily, when you continue your program, you do so at the place where
it stopped, with the `continue' command.  You can instead continue at
it stopped, with the `continue' command.  You can instead continue at
an address of your own choosing, with the following commands:
an address of your own choosing, with the following commands:
`jump LINESPEC'
`jump LINESPEC'
`jump LOCATION'
`jump LOCATION'
     Resume execution at line LINESPEC or at address given by LOCATION.
     Resume execution at line LINESPEC or at address given by LOCATION.
     Execution stops again immediately if there is a breakpoint there.
     Execution stops again immediately if there is a breakpoint there.
     *Note Specify Location::, for a description of the different
     *Note Specify Location::, for a description of the different
     forms of LINESPEC and LOCATION.  It is common practice to use the
     forms of LINESPEC and LOCATION.  It is common practice to use the
     `tbreak' command in conjunction with `jump'.  *Note Setting
     `tbreak' command in conjunction with `jump'.  *Note Setting
     Breakpoints: Set Breaks.
     Breakpoints: Set Breaks.
     The `jump' command does not change the current stack frame, or the
     The `jump' command does not change the current stack frame, or the
     stack pointer, or the contents of any memory location or any
     stack pointer, or the contents of any memory location or any
     register other than the program counter.  If line LINESPEC is in a
     register other than the program counter.  If line LINESPEC is in a
     different function from the one currently executing, the results
     different function from the one currently executing, the results
     may be bizarre if the two functions expect different patterns of
     may be bizarre if the two functions expect different patterns of
     arguments or of local variables.  For this reason, the `jump'
     arguments or of local variables.  For this reason, the `jump'
     command requests confirmation if the specified line is not in the
     command requests confirmation if the specified line is not in the
     function currently executing.  However, even bizarre results are
     function currently executing.  However, even bizarre results are
     predictable if you are well acquainted with the machine-language
     predictable if you are well acquainted with the machine-language
     code of your program.
     code of your program.
   On many systems, you can get much the same effect as the `jump'
   On many systems, you can get much the same effect as the `jump'
command by storing a new value into the register `$pc'.  The difference
command by storing a new value into the register `$pc'.  The difference
is that this does not start your program running; it only changes the
is that this does not start your program running; it only changes the
address of where it _will_ run when you continue.  For example,
address of where it _will_ run when you continue.  For example,
     set $pc = 0x485
     set $pc = 0x485
makes the next `continue' command or stepping command execute at
makes the next `continue' command or stepping command execute at
address `0x485', rather than at the address where your program stopped.
address `0x485', rather than at the address where your program stopped.
*Note Continuing and Stepping: Continuing and Stepping.
*Note Continuing and Stepping: Continuing and Stepping.
   The most common occasion to use the `jump' command is to back
   The most common occasion to use the `jump' command is to back
up--perhaps with more breakpoints set--over a portion of a program that
up--perhaps with more breakpoints set--over a portion of a program that
has already executed, in order to examine its execution in more detail.
has already executed, in order to examine its execution in more detail.


File: gdb.info,  Node: Signaling,  Next: Returning,  Prev: Jumping,  Up: Altering
File: gdb.info,  Node: Signaling,  Next: Returning,  Prev: Jumping,  Up: Altering
14.3 Giving your Program a Signal
14.3 Giving your Program a Signal
=================================
=================================
`signal SIGNAL'
`signal SIGNAL'
     Resume execution where your program stopped, but immediately give
     Resume execution where your program stopped, but immediately give
     it the signal SIGNAL.  SIGNAL can be the name or the number of a
     it the signal SIGNAL.  SIGNAL can be the name or the number of a
     signal.  For example, on many systems `signal 2' and `signal
     signal.  For example, on many systems `signal 2' and `signal
     SIGINT' are both ways of sending an interrupt signal.
     SIGINT' are both ways of sending an interrupt signal.
     Alternatively, if SIGNAL is zero, continue execution without
     Alternatively, if SIGNAL is zero, continue execution without
     giving a signal.  This is useful when your program stopped on
     giving a signal.  This is useful when your program stopped on
     account of a signal and would ordinary see the signal when resumed
     account of a signal and would ordinary see the signal when resumed
     with the `continue' command; `signal 0' causes it to resume
     with the `continue' command; `signal 0' causes it to resume
     without a signal.
     without a signal.
     `signal' does not repeat when you press  a second time after
     `signal' does not repeat when you press  a second time after
     executing the command.
     executing the command.
   Invoking the `signal' command is not the same as invoking the `kill'
   Invoking the `signal' command is not the same as invoking the `kill'
utility from the shell.  Sending a signal with `kill' causes GDB to
utility from the shell.  Sending a signal with `kill' causes GDB to
decide what to do with the signal depending on the signal handling
decide what to do with the signal depending on the signal handling
tables (*note Signals::).  The `signal' command passes the signal
tables (*note Signals::).  The `signal' command passes the signal
directly to your program.
directly to your program.


File: gdb.info,  Node: Returning,  Next: Calling,  Prev: Signaling,  Up: Altering
File: gdb.info,  Node: Returning,  Next: Calling,  Prev: Signaling,  Up: Altering
14.4 Returning from a Function
14.4 Returning from a Function
==============================
==============================
`return'
`return'
`return EXPRESSION'
`return EXPRESSION'
     You can cancel execution of a function call with the `return'
     You can cancel execution of a function call with the `return'
     command.  If you give an EXPRESSION argument, its value is used as
     command.  If you give an EXPRESSION argument, its value is used as
     the function's return value.
     the function's return value.
   When you use `return', GDB discards the selected stack frame (and
   When you use `return', GDB discards the selected stack frame (and
all frames within it).  You can think of this as making the discarded
all frames within it).  You can think of this as making the discarded
frame return prematurely.  If you wish to specify a value to be
frame return prematurely.  If you wish to specify a value to be
returned, give that value as the argument to `return'.
returned, give that value as the argument to `return'.
   This pops the selected stack frame (*note Selecting a Frame:
   This pops the selected stack frame (*note Selecting a Frame:
Selection.), and any other frames inside of it, leaving its caller as
Selection.), and any other frames inside of it, leaving its caller as
the innermost remaining frame.  That frame becomes selected.  The
the innermost remaining frame.  That frame becomes selected.  The
specified value is stored in the registers used for returning values of
specified value is stored in the registers used for returning values of
functions.
functions.
   The `return' command does not resume execution; it leaves the
   The `return' command does not resume execution; it leaves the
program stopped in the state that would exist if the function had just
program stopped in the state that would exist if the function had just
returned.  In contrast, the `finish' command (*note Continuing and
returned.  In contrast, the `finish' command (*note Continuing and
Stepping: Continuing and Stepping.) resumes execution until the
Stepping: Continuing and Stepping.) resumes execution until the
selected stack frame returns naturally.
selected stack frame returns naturally.


File: gdb.info,  Node: Calling,  Next: Patching,  Prev: Returning,  Up: Altering
File: gdb.info,  Node: Calling,  Next: Patching,  Prev: Returning,  Up: Altering
14.5 Calling Program Functions
14.5 Calling Program Functions
==============================
==============================
`print EXPR'
`print EXPR'
     Evaluate the expression EXPR and display the resulting value.
     Evaluate the expression EXPR and display the resulting value.
     EXPR may include calls to functions in the program being debugged.
     EXPR may include calls to functions in the program being debugged.
`call EXPR'
`call EXPR'
     Evaluate the expression EXPR without displaying `void' returned
     Evaluate the expression EXPR without displaying `void' returned
     values.
     values.
     You can use this variant of the `print' command if you want to
     You can use this variant of the `print' command if you want to
     execute a function from your program that does not return anything
     execute a function from your program that does not return anything
     (a.k.a. "a void function"), but without cluttering the output with
     (a.k.a. "a void function"), but without cluttering the output with
     `void' returned values that GDB will otherwise print.  If the
     `void' returned values that GDB will otherwise print.  If the
     result is not void, it is printed and saved in the value history.
     result is not void, it is printed and saved in the value history.
   It is possible for the function you call via the `print' or `call'
   It is possible for the function you call via the `print' or `call'
command to generate a signal (e.g., if there's a bug in the function,
command to generate a signal (e.g., if there's a bug in the function,
or if you passed it incorrect arguments).  What happens in that case is
or if you passed it incorrect arguments).  What happens in that case is
controlled by the `set unwindonsignal' command.
controlled by the `set unwindonsignal' command.
`set unwindonsignal'
`set unwindonsignal'
     Set unwinding of the stack if a signal is received while in a
     Set unwinding of the stack if a signal is received while in a
     function that GDB called in the program being debugged.  If set to
     function that GDB called in the program being debugged.  If set to
     on, GDB unwinds the stack it created for the call and restores the
     on, GDB unwinds the stack it created for the call and restores the
     context to what it was before the call.  If set to off (the
     context to what it was before the call.  If set to off (the
     default), GDB stops in the frame where the signal was received.
     default), GDB stops in the frame where the signal was received.
`show unwindonsignal'
`show unwindonsignal'
     Show the current setting of stack unwinding in the functions
     Show the current setting of stack unwinding in the functions
     called by GDB.
     called by GDB.
   Sometimes, a function you wish to call is actually a "weak alias"
   Sometimes, a function you wish to call is actually a "weak alias"
for another function.  In such case, GDB might not pick up the type
for another function.  In such case, GDB might not pick up the type
information, including the types of the function arguments, which
information, including the types of the function arguments, which
causes GDB to call the inferior function incorrectly.  As a result, the
causes GDB to call the inferior function incorrectly.  As a result, the
called function will function erroneously and may even crash.  A
called function will function erroneously and may even crash.  A
solution to that is to use the name of the aliased function instead.
solution to that is to use the name of the aliased function instead.


File: gdb.info,  Node: Patching,  Prev: Calling,  Up: Altering
File: gdb.info,  Node: Patching,  Prev: Calling,  Up: Altering
14.6 Patching Programs
14.6 Patching Programs
======================
======================
By default, GDB opens the file containing your program's executable
By default, GDB opens the file containing your program's executable
code (or the corefile) read-only.  This prevents accidental alterations
code (or the corefile) read-only.  This prevents accidental alterations
to machine code; but it also prevents you from intentionally patching
to machine code; but it also prevents you from intentionally patching
your program's binary.
your program's binary.
   If you'd like to be able to patch the binary, you can specify that
   If you'd like to be able to patch the binary, you can specify that
explicitly with the `set write' command.  For example, you might want
explicitly with the `set write' command.  For example, you might want
to turn on internal debugging flags, or even to make emergency repairs.
to turn on internal debugging flags, or even to make emergency repairs.
`set write on'
`set write on'
`set write off'
`set write off'
     If you specify `set write on', GDB opens executable and core files
     If you specify `set write on', GDB opens executable and core files
     for both reading and writing; if you specify `set write off' (the
     for both reading and writing; if you specify `set write off' (the
     default), GDB opens them read-only.
     default), GDB opens them read-only.
     If you have already loaded a file, you must load it again (using
     If you have already loaded a file, you must load it again (using
     the `exec-file' or `core-file' command) after changing `set
     the `exec-file' or `core-file' command) after changing `set
     write', for your new setting to take effect.
     write', for your new setting to take effect.
`show write'
`show write'
     Display whether executable files and core files are opened for
     Display whether executable files and core files are opened for
     writing as well as reading.
     writing as well as reading.


File: gdb.info,  Node: GDB Files,  Next: Targets,  Prev: Altering,  Up: Top
File: gdb.info,  Node: GDB Files,  Next: Targets,  Prev: Altering,  Up: Top
15 GDB Files
15 GDB Files
************
************
GDB needs to know the file name of the program to be debugged, both in
GDB needs to know the file name of the program to be debugged, both in
order to read its symbol table and in order to start your program.  To
order to read its symbol table and in order to start your program.  To
debug a core dump of a previous run, you must also tell GDB the name of
debug a core dump of a previous run, you must also tell GDB the name of
the core dump file.
the core dump file.
* Menu:
* Menu:
* Files::                       Commands to specify files
* Files::                       Commands to specify files
* Separate Debug Files::        Debugging information in separate files
* Separate Debug Files::        Debugging information in separate files
* Symbol Errors::               Errors reading symbol files
* Symbol Errors::               Errors reading symbol files


File: gdb.info,  Node: Files,  Next: Separate Debug Files,  Up: GDB Files
File: gdb.info,  Node: Files,  Next: Separate Debug Files,  Up: GDB Files
15.1 Commands to Specify Files
15.1 Commands to Specify Files
==============================
==============================
You may want to specify executable and core dump file names.  The usual
You may want to specify executable and core dump file names.  The usual
way to do this is at start-up time, using the arguments to GDB's
way to do this is at start-up time, using the arguments to GDB's
start-up commands (*note Getting In and Out of GDB: Invocation.).
start-up commands (*note Getting In and Out of GDB: Invocation.).
   Occasionally it is necessary to change to a different file during a
   Occasionally it is necessary to change to a different file during a
GDB session.  Or you may run GDB and forget to specify a file you want
GDB session.  Or you may run GDB and forget to specify a file you want
to use.  Or you are debugging a remote target via `gdbserver' (*note
to use.  Or you are debugging a remote target via `gdbserver' (*note
file: Server.).  In these situations the GDB commands to specify new
file: Server.).  In these situations the GDB commands to specify new
files are useful.
files are useful.
`file FILENAME'
`file FILENAME'
     Use FILENAME as the program to be debugged.  It is read for its
     Use FILENAME as the program to be debugged.  It is read for its
     symbols and for the contents of pure memory.  It is also the
     symbols and for the contents of pure memory.  It is also the
     program executed when you use the `run' command.  If you do not
     program executed when you use the `run' command.  If you do not
     specify a directory and the file is not found in the GDB working
     specify a directory and the file is not found in the GDB working
     directory, GDB uses the environment variable `PATH' as a list of
     directory, GDB uses the environment variable `PATH' as a list of
     directories to search, just as the shell does when looking for a
     directories to search, just as the shell does when looking for a
     program to run.  You can change the value of this variable, for
     program to run.  You can change the value of this variable, for
     both GDB and your program, using the `path' command.
     both GDB and your program, using the `path' command.
     You can load unlinked object `.o' files into GDB using the `file'
     You can load unlinked object `.o' files into GDB using the `file'
     command.  You will not be able to "run" an object file, but you
     command.  You will not be able to "run" an object file, but you
     can disassemble functions and inspect variables.  Also, if the
     can disassemble functions and inspect variables.  Also, if the
     underlying BFD functionality supports it, you could use `gdb
     underlying BFD functionality supports it, you could use `gdb
     -write' to patch object files using this technique.  Note that GDB
     -write' to patch object files using this technique.  Note that GDB
     can neither interpret nor modify relocations in this case, so
     can neither interpret nor modify relocations in this case, so
     branches and some initialized variables will appear to go to the
     branches and some initialized variables will appear to go to the
     wrong place.  But this feature is still handy from time to time.
     wrong place.  But this feature is still handy from time to time.
`file'
`file'
     `file' with no argument makes GDB discard any information it has
     `file' with no argument makes GDB discard any information it has
     on both executable file and the symbol table.
     on both executable file and the symbol table.
`exec-file [ FILENAME ]'
`exec-file [ FILENAME ]'
     Specify that the program to be run (but not the symbol table) is
     Specify that the program to be run (but not the symbol table) is
     found in FILENAME.  GDB searches the environment variable `PATH'
     found in FILENAME.  GDB searches the environment variable `PATH'
     if necessary to locate your program.  Omitting FILENAME means to
     if necessary to locate your program.  Omitting FILENAME means to
     discard information on the executable file.
     discard information on the executable file.
`symbol-file [ FILENAME ]'
`symbol-file [ FILENAME ]'
     Read symbol table information from file FILENAME.  `PATH' is
     Read symbol table information from file FILENAME.  `PATH' is
     searched when necessary.  Use the `file' command to get both symbol
     searched when necessary.  Use the `file' command to get both symbol
     table and program to run from the same file.
     table and program to run from the same file.
     `symbol-file' with no argument clears out GDB information on your
     `symbol-file' with no argument clears out GDB information on your
     program's symbol table.
     program's symbol table.
     The `symbol-file' command causes GDB to forget the contents of
     The `symbol-file' command causes GDB to forget the contents of
     some breakpoints and auto-display expressions.  This is because
     some breakpoints and auto-display expressions.  This is because
     they may contain pointers to the internal data recording symbols
     they may contain pointers to the internal data recording symbols
     and data types, which are part of the old symbol table data being
     and data types, which are part of the old symbol table data being
     discarded inside GDB.
     discarded inside GDB.
     `symbol-file' does not repeat if you press  again after
     `symbol-file' does not repeat if you press  again after
     executing it once.
     executing it once.
     When GDB is configured for a particular environment, it
     When GDB is configured for a particular environment, it
     understands debugging information in whatever format is the
     understands debugging information in whatever format is the
     standard generated for that environment; you may use either a GNU
     standard generated for that environment; you may use either a GNU
     compiler, or other compilers that adhere to the local conventions.
     compiler, or other compilers that adhere to the local conventions.
     Best results are usually obtained from GNU compilers; for example,
     Best results are usually obtained from GNU compilers; for example,
     using `GCC' you can generate debugging information for optimized
     using `GCC' you can generate debugging information for optimized
     code.
     code.
     For most kinds of object files, with the exception of old SVR3
     For most kinds of object files, with the exception of old SVR3
     systems using COFF, the `symbol-file' command does not normally
     systems using COFF, the `symbol-file' command does not normally
     read the symbol table in full right away.  Instead, it scans the
     read the symbol table in full right away.  Instead, it scans the
     symbol table quickly to find which source files and which symbols
     symbol table quickly to find which source files and which symbols
     are present.  The details are read later, one source file at a
     are present.  The details are read later, one source file at a
     time, as they are needed.
     time, as they are needed.
     The purpose of this two-stage reading strategy is to make GDB
     The purpose of this two-stage reading strategy is to make GDB
     start up faster.  For the most part, it is invisible except for
     start up faster.  For the most part, it is invisible except for
     occasional pauses while the symbol table details for a particular
     occasional pauses while the symbol table details for a particular
     source file are being read.  (The `set verbose' command can turn
     source file are being read.  (The `set verbose' command can turn
     these pauses into messages if desired.  *Note Optional Warnings
     these pauses into messages if desired.  *Note Optional Warnings
     and Messages: Messages/Warnings.)
     and Messages: Messages/Warnings.)
     We have not implemented the two-stage strategy for COFF yet.  When
     We have not implemented the two-stage strategy for COFF yet.  When
     the symbol table is stored in COFF format, `symbol-file' reads the
     the symbol table is stored in COFF format, `symbol-file' reads the
     symbol table data in full right away.  Note that "stabs-in-COFF"
     symbol table data in full right away.  Note that "stabs-in-COFF"
     still does the two-stage strategy, since the debug info is actually
     still does the two-stage strategy, since the debug info is actually
     in stabs format.
     in stabs format.
`symbol-file FILENAME [ -readnow ]'
`symbol-file FILENAME [ -readnow ]'
`file FILENAME [ -readnow ]'
`file FILENAME [ -readnow ]'
     You can override the GDB two-stage strategy for reading symbol
     You can override the GDB two-stage strategy for reading symbol
     tables by using the `-readnow' option with any of the commands that
     tables by using the `-readnow' option with any of the commands that
     load symbol table information, if you want to be sure GDB has the
     load symbol table information, if you want to be sure GDB has the
     entire symbol table available.
     entire symbol table available.
`core-file [FILENAME]'
`core-file [FILENAME]'
`core'
`core'
     Specify the whereabouts of a core dump file to be used as the
     Specify the whereabouts of a core dump file to be used as the
     "contents of memory".  Traditionally, core files contain only some
     "contents of memory".  Traditionally, core files contain only some
     parts of the address space of the process that generated them; GDB
     parts of the address space of the process that generated them; GDB
     can access the executable file itself for other parts.
     can access the executable file itself for other parts.
     `core-file' with no argument specifies that no core file is to be
     `core-file' with no argument specifies that no core file is to be
     used.
     used.
     Note that the core file is ignored when your program is actually
     Note that the core file is ignored when your program is actually
     running under GDB.  So, if you have been running your program and
     running under GDB.  So, if you have been running your program and
     you wish to debug a core file instead, you must kill the
     you wish to debug a core file instead, you must kill the
     subprocess in which the program is running.  To do this, use the
     subprocess in which the program is running.  To do this, use the
     `kill' command (*note Killing the Child Process: Kill Process.).
     `kill' command (*note Killing the Child Process: Kill Process.).
`add-symbol-file FILENAME ADDRESS'
`add-symbol-file FILENAME ADDRESS'
`add-symbol-file FILENAME ADDRESS [ -readnow ]'
`add-symbol-file FILENAME ADDRESS [ -readnow ]'
`add-symbol-file FILENAME -sSECTION ADDRESS ...'
`add-symbol-file FILENAME -sSECTION ADDRESS ...'
     The `add-symbol-file' command reads additional symbol table
     The `add-symbol-file' command reads additional symbol table
     information from the file FILENAME.  You would use this command
     information from the file FILENAME.  You would use this command
     when FILENAME has been dynamically loaded (by some other means)
     when FILENAME has been dynamically loaded (by some other means)
     into the program that is running.  ADDRESS should be the memory
     into the program that is running.  ADDRESS should be the memory
     address at which the file has been loaded; GDB cannot figure this
     address at which the file has been loaded; GDB cannot figure this
     out for itself.  You can additionally specify an arbitrary number
     out for itself.  You can additionally specify an arbitrary number
     of `-sSECTION ADDRESS' pairs, to give an explicit section name and
     of `-sSECTION ADDRESS' pairs, to give an explicit section name and
     base address for that section.  You can specify any ADDRESS as an
     base address for that section.  You can specify any ADDRESS as an
     expression.
     expression.
     The symbol table of the file FILENAME is added to the symbol table
     The symbol table of the file FILENAME is added to the symbol table
     originally read with the `symbol-file' command.  You can use the
     originally read with the `symbol-file' command.  You can use the
     `add-symbol-file' command any number of times; the new symbol data
     `add-symbol-file' command any number of times; the new symbol data
     thus read keeps adding to the old.  To discard all old symbol data
     thus read keeps adding to the old.  To discard all old symbol data
     instead, use the `symbol-file' command without any arguments.
     instead, use the `symbol-file' command without any arguments.
     Although FILENAME is typically a shared library file, an
     Although FILENAME is typically a shared library file, an
     executable file, or some other object file which has been fully
     executable file, or some other object file which has been fully
     relocated for loading into a process, you can also load symbolic
     relocated for loading into a process, you can also load symbolic
     information from relocatable `.o' files, as long as:
     information from relocatable `.o' files, as long as:
        * the file's symbolic information refers only to linker symbols
        * the file's symbolic information refers only to linker symbols
          defined in that file, not to symbols defined by other object
          defined in that file, not to symbols defined by other object
          files,
          files,
        * every section the file's symbolic information refers to has
        * every section the file's symbolic information refers to has
          actually been loaded into the inferior, as it appears in the
          actually been loaded into the inferior, as it appears in the
          file, and
          file, and
        * you can determine the address at which every section was
        * you can determine the address at which every section was
          loaded, and provide these to the `add-symbol-file' command.
          loaded, and provide these to the `add-symbol-file' command.
     Some embedded operating systems, like Sun Chorus and VxWorks, can
     Some embedded operating systems, like Sun Chorus and VxWorks, can
     load relocatable files into an already running program; such
     load relocatable files into an already running program; such
     systems typically make the requirements above easy to meet.
     systems typically make the requirements above easy to meet.
     However, it's important to recognize that many native systems use
     However, it's important to recognize that many native systems use
     complex link procedures (`.linkonce' section factoring and C++
     complex link procedures (`.linkonce' section factoring and C++
     constructor table assembly, for example) that make the
     constructor table assembly, for example) that make the
     requirements difficult to meet.  In general, one cannot assume
     requirements difficult to meet.  In general, one cannot assume
     that using `add-symbol-file' to read a relocatable object file's
     that using `add-symbol-file' to read a relocatable object file's
     symbolic information will have the same effect as linking the
     symbolic information will have the same effect as linking the
     relocatable object file into the program in the normal way.
     relocatable object file into the program in the normal way.
     `add-symbol-file' does not repeat if you press  after using
     `add-symbol-file' does not repeat if you press  after using
     it.
     it.
`add-symbol-file-from-memory ADDRESS'
`add-symbol-file-from-memory ADDRESS'
     Load symbols from the given ADDRESS in a dynamically loaded object
     Load symbols from the given ADDRESS in a dynamically loaded object
     file whose image is mapped directly into the inferior's memory.
     file whose image is mapped directly into the inferior's memory.
     For example, the Linux kernel maps a `syscall DSO' into each
     For example, the Linux kernel maps a `syscall DSO' into each
     process's address space; this DSO provides kernel-specific code for
     process's address space; this DSO provides kernel-specific code for
     some system calls.  The argument can be any expression whose
     some system calls.  The argument can be any expression whose
     evaluation yields the address of the file's shared object file
     evaluation yields the address of the file's shared object file
     header.  For this command to work, you must have used
     header.  For this command to work, you must have used
     `symbol-file' or `exec-file' commands in advance.
     `symbol-file' or `exec-file' commands in advance.
`add-shared-symbol-files LIBRARY-FILE'
`add-shared-symbol-files LIBRARY-FILE'
`assf LIBRARY-FILE'
`assf LIBRARY-FILE'
     The `add-shared-symbol-files' command can currently be used only
     The `add-shared-symbol-files' command can currently be used only
     in the Cygwin build of GDB on MS-Windows OS, where it is an alias
     in the Cygwin build of GDB on MS-Windows OS, where it is an alias
     for the `dll-symbols' command (*note Cygwin Native::).  GDB
     for the `dll-symbols' command (*note Cygwin Native::).  GDB
     automatically looks for shared libraries, however if GDB does not
     automatically looks for shared libraries, however if GDB does not
     find yours, you can invoke `add-shared-symbol-files'.  It takes
     find yours, you can invoke `add-shared-symbol-files'.  It takes
     one argument: the shared library's file name.  `assf' is a
     one argument: the shared library's file name.  `assf' is a
     shorthand alias for `add-shared-symbol-files'.
     shorthand alias for `add-shared-symbol-files'.
`section SECTION ADDR'
`section SECTION ADDR'
     The `section' command changes the base address of the named
     The `section' command changes the base address of the named
     SECTION of the exec file to ADDR.  This can be used if the exec
     SECTION of the exec file to ADDR.  This can be used if the exec
     file does not contain section addresses, (such as in the `a.out'
     file does not contain section addresses, (such as in the `a.out'
     format), or when the addresses specified in the file itself are
     format), or when the addresses specified in the file itself are
     wrong.  Each section must be changed separately.  The `info files'
     wrong.  Each section must be changed separately.  The `info files'
     command, described below, lists all the sections and their
     command, described below, lists all the sections and their
     addresses.
     addresses.
`info files'
`info files'
`info target'
`info target'
     `info files' and `info target' are synonymous; both print the
     `info files' and `info target' are synonymous; both print the
     current target (*note Specifying a Debugging Target: Targets.),
     current target (*note Specifying a Debugging Target: Targets.),
     including the names of the executable and core dump files
     including the names of the executable and core dump files
     currently in use by GDB, and the files from which symbols were
     currently in use by GDB, and the files from which symbols were
     loaded.  The command `help target' lists all possible targets
     loaded.  The command `help target' lists all possible targets
     rather than current ones.
     rather than current ones.
`maint info sections'
`maint info sections'
     Another command that can give you extra information about program
     Another command that can give you extra information about program
     sections is `maint info sections'.  In addition to the section
     sections is `maint info sections'.  In addition to the section
     information displayed by `info files', this command displays the
     information displayed by `info files', this command displays the
     flags and file offset of each section in the executable and core
     flags and file offset of each section in the executable and core
     dump files.  In addition, `maint info sections' provides the
     dump files.  In addition, `maint info sections' provides the
     following command options (which may be arbitrarily combined):
     following command options (which may be arbitrarily combined):
    `ALLOBJ'
    `ALLOBJ'
          Display sections for all loaded object files, including
          Display sections for all loaded object files, including
          shared libraries.
          shared libraries.
    `SECTIONS'
    `SECTIONS'
          Display info only for named SECTIONS.
          Display info only for named SECTIONS.
    `SECTION-FLAGS'
    `SECTION-FLAGS'
          Display info only for sections for which SECTION-FLAGS are
          Display info only for sections for which SECTION-FLAGS are
          true.  The section flags that GDB currently knows about are:
          true.  The section flags that GDB currently knows about are:
         `ALLOC'
         `ALLOC'
               Section will have space allocated in the process when
               Section will have space allocated in the process when
               loaded.  Set for all sections except those containing
               loaded.  Set for all sections except those containing
               debug information.
               debug information.
         `LOAD'
         `LOAD'
               Section will be loaded from the file into the child
               Section will be loaded from the file into the child
               process memory.  Set for pre-initialized code and data,
               process memory.  Set for pre-initialized code and data,
               clear for `.bss' sections.
               clear for `.bss' sections.
         `RELOC'
         `RELOC'
               Section needs to be relocated before loading.
               Section needs to be relocated before loading.
         `READONLY'
         `READONLY'
               Section cannot be modified by the child process.
               Section cannot be modified by the child process.
         `CODE'
         `CODE'
               Section contains executable code only.
               Section contains executable code only.
         `DATA'
         `DATA'
               Section contains data only (no executable code).
               Section contains data only (no executable code).
         `ROM'
         `ROM'
               Section will reside in ROM.
               Section will reside in ROM.
         `CONSTRUCTOR'
         `CONSTRUCTOR'
               Section contains data for constructor/destructor lists.
               Section contains data for constructor/destructor lists.
         `HAS_CONTENTS'
         `HAS_CONTENTS'
               Section is not empty.
               Section is not empty.
         `NEVER_LOAD'
         `NEVER_LOAD'
               An instruction to the linker to not output the section.
               An instruction to the linker to not output the section.
         `COFF_SHARED_LIBRARY'
         `COFF_SHARED_LIBRARY'
               A notification to the linker that the section contains
               A notification to the linker that the section contains
               COFF shared library information.
               COFF shared library information.
         `IS_COMMON'
         `IS_COMMON'
               Section contains common symbols.
               Section contains common symbols.
`set trust-readonly-sections on'
`set trust-readonly-sections on'
     Tell GDB that readonly sections in your object file really are
     Tell GDB that readonly sections in your object file really are
     read-only (i.e. that their contents will not change).  In that
     read-only (i.e. that their contents will not change).  In that
     case, GDB can fetch values from these sections out of the object
     case, GDB can fetch values from these sections out of the object
     file, rather than from the target program.  For some targets
     file, rather than from the target program.  For some targets
     (notably embedded ones), this can be a significant enhancement to
     (notably embedded ones), this can be a significant enhancement to
     debugging performance.
     debugging performance.
     The default is off.
     The default is off.
`set trust-readonly-sections off'
`set trust-readonly-sections off'
     Tell GDB not to trust readonly sections.  This means that the
     Tell GDB not to trust readonly sections.  This means that the
     contents of the section might change while the program is running,
     contents of the section might change while the program is running,
     and must therefore be fetched from the target when needed.
     and must therefore be fetched from the target when needed.
`show trust-readonly-sections'
`show trust-readonly-sections'
     Show the current setting of trusting readonly sections.
     Show the current setting of trusting readonly sections.
   All file-specifying commands allow both absolute and relative file
   All file-specifying commands allow both absolute and relative file
names as arguments.  GDB always converts the file name to an absolute
names as arguments.  GDB always converts the file name to an absolute
file name and remembers it that way.
file name and remembers it that way.
   GDB supports GNU/Linux, MS-Windows, HP-UX, SunOS, SVr4, Irix, and
   GDB supports GNU/Linux, MS-Windows, HP-UX, SunOS, SVr4, Irix, and
IBM RS/6000 AIX shared libraries.
IBM RS/6000 AIX shared libraries.
   On MS-Windows GDB must be linked with the Expat library to support
   On MS-Windows GDB must be linked with the Expat library to support
shared libraries.  *Note Expat::.
shared libraries.  *Note Expat::.
   GDB automatically loads symbol definitions from shared libraries
   GDB automatically loads symbol definitions from shared libraries
when you use the `run' command, or when you examine a core file.
when you use the `run' command, or when you examine a core file.
(Before you issue the `run' command, GDB does not understand references
(Before you issue the `run' command, GDB does not understand references
to a function in a shared library, however--unless you are debugging a
to a function in a shared library, however--unless you are debugging a
core file).
core file).
   On HP-UX, if the program loads a library explicitly, GDB
   On HP-UX, if the program loads a library explicitly, GDB
automatically loads the symbols at the time of the `shl_load' call.
automatically loads the symbols at the time of the `shl_load' call.
   There are times, however, when you may wish to not automatically load
   There are times, however, when you may wish to not automatically load
symbol definitions from shared libraries, such as when they are
symbol definitions from shared libraries, such as when they are
particularly large or there are many of them.
particularly large or there are many of them.
   To control the automatic loading of shared library symbols, use the
   To control the automatic loading of shared library symbols, use the
commands:
commands:
`set auto-solib-add MODE'
`set auto-solib-add MODE'
     If MODE is `on', symbols from all shared object libraries will be
     If MODE is `on', symbols from all shared object libraries will be
     loaded automatically when the inferior begins execution, you
     loaded automatically when the inferior begins execution, you
     attach to an independently started inferior, or when the dynamic
     attach to an independently started inferior, or when the dynamic
     linker informs GDB that a new library has been loaded.  If MODE is
     linker informs GDB that a new library has been loaded.  If MODE is
     `off', symbols must be loaded manually, using the `sharedlibrary'
     `off', symbols must be loaded manually, using the `sharedlibrary'
     command.  The default value is `on'.
     command.  The default value is `on'.
     If your program uses lots of shared libraries with debug info that
     If your program uses lots of shared libraries with debug info that
     takes large amounts of memory, you can decrease the GDB memory
     takes large amounts of memory, you can decrease the GDB memory
     footprint by preventing it from automatically loading the symbols
     footprint by preventing it from automatically loading the symbols
     from shared libraries.  To that end, type `set auto-solib-add off'
     from shared libraries.  To that end, type `set auto-solib-add off'
     before running the inferior, then load each library whose debug
     before running the inferior, then load each library whose debug
     symbols you do need with `sharedlibrary REGEXP', where REGEXP is a
     symbols you do need with `sharedlibrary REGEXP', where REGEXP is a
     regular expression that matches the libraries whose symbols you
     regular expression that matches the libraries whose symbols you
     want to be loaded.
     want to be loaded.
`show auto-solib-add'
`show auto-solib-add'
     Display the current autoloading mode.
     Display the current autoloading mode.
   To explicitly load shared library symbols, use the `sharedlibrary'
   To explicitly load shared library symbols, use the `sharedlibrary'
command:
command:
`info share'
`info share'
`info sharedlibrary'
`info sharedlibrary'
     Print the names of the shared libraries which are currently loaded.
     Print the names of the shared libraries which are currently loaded.
`sharedlibrary REGEX'
`sharedlibrary REGEX'
`share REGEX'
`share REGEX'
     Load shared object library symbols for files matching a Unix
     Load shared object library symbols for files matching a Unix
     regular expression.  As with files loaded automatically, it only
     regular expression.  As with files loaded automatically, it only
     loads shared libraries required by your program for a core file or
     loads shared libraries required by your program for a core file or
     after typing `run'.  If REGEX is omitted all shared libraries
     after typing `run'.  If REGEX is omitted all shared libraries
     required by your program are loaded.
     required by your program are loaded.
`nosharedlibrary'
`nosharedlibrary'
     Unload all shared object library symbols.  This discards all
     Unload all shared object library symbols.  This discards all
     symbols that have been loaded from all shared libraries.  Symbols
     symbols that have been loaded from all shared libraries.  Symbols
     from shared libraries that were loaded by explicit user requests
     from shared libraries that were loaded by explicit user requests
     are not discarded.
     are not discarded.
   Sometimes you may wish that GDB stops and gives you control when any
   Sometimes you may wish that GDB stops and gives you control when any
of shared library events happen.  Use the `set stop-on-solib-events'
of shared library events happen.  Use the `set stop-on-solib-events'
command for this:
command for this:
`set stop-on-solib-events'
`set stop-on-solib-events'
     This command controls whether GDB should give you control when the
     This command controls whether GDB should give you control when the
     dynamic linker notifies it about some shared library event.  The
     dynamic linker notifies it about some shared library event.  The
     most common event of interest is loading or unloading of a new
     most common event of interest is loading or unloading of a new
     shared library.
     shared library.
`show stop-on-solib-events'
`show stop-on-solib-events'
     Show whether GDB stops and gives you control when shared library
     Show whether GDB stops and gives you control when shared library
     events happen.
     events happen.
   Shared libraries are also supported in many cross or remote debugging
   Shared libraries are also supported in many cross or remote debugging
configurations.  A copy of the target's libraries need to be present on
configurations.  A copy of the target's libraries need to be present on
the host system; they need to be the same as the target libraries,
the host system; they need to be the same as the target libraries,
although the copies on the target can be stripped as long as the copies
although the copies on the target can be stripped as long as the copies
on the host are not.
on the host are not.
   For remote debugging, you need to tell GDB where the target
   For remote debugging, you need to tell GDB where the target
libraries are, so that it can load the correct copies--otherwise, it
libraries are, so that it can load the correct copies--otherwise, it
may try to load the host's libraries.  GDB has two variables to specify
may try to load the host's libraries.  GDB has two variables to specify
the search directories for target libraries.
the search directories for target libraries.
`set sysroot PATH'
`set sysroot PATH'
     Use PATH as the system root for the program being debugged.  Any
     Use PATH as the system root for the program being debugged.  Any
     absolute shared library paths will be prefixed with PATH; many
     absolute shared library paths will be prefixed with PATH; many
     runtime loaders store the absolute paths to the shared library in
     runtime loaders store the absolute paths to the shared library in
     the target program's memory.  If you use `set sysroot' to find
     the target program's memory.  If you use `set sysroot' to find
     shared libraries, they need to be laid out in the same way that
     shared libraries, they need to be laid out in the same way that
     they are on the target, with e.g. a `/lib' and `/usr/lib' hierarchy
     they are on the target, with e.g. a `/lib' and `/usr/lib' hierarchy
     under PATH.
     under PATH.
     The `set solib-absolute-prefix' command is an alias for `set
     The `set solib-absolute-prefix' command is an alias for `set
     sysroot'.
     sysroot'.
     You can set the default system root by using the configure-time
     You can set the default system root by using the configure-time
     `--with-sysroot' option.  If the system root is inside GDB's
     `--with-sysroot' option.  If the system root is inside GDB's
     configured binary prefix (set with `--prefix' or `--exec-prefix'),
     configured binary prefix (set with `--prefix' or `--exec-prefix'),
     then the default system root will be updated automatically if the
     then the default system root will be updated automatically if the
     installed GDB is moved to a new location.
     installed GDB is moved to a new location.
`show sysroot'
`show sysroot'
     Display the current shared library prefix.
     Display the current shared library prefix.
`set solib-search-path PATH'
`set solib-search-path PATH'
     If this variable is set, PATH is a colon-separated list of
     If this variable is set, PATH is a colon-separated list of
     directories to search for shared libraries.  `solib-search-path'
     directories to search for shared libraries.  `solib-search-path'
     is used after `sysroot' fails to locate the library, or if the
     is used after `sysroot' fails to locate the library, or if the
     path to the library is relative instead of absolute.  If you want
     path to the library is relative instead of absolute.  If you want
     to use `solib-search-path' instead of `sysroot', be sure to set
     to use `solib-search-path' instead of `sysroot', be sure to set
     `sysroot' to a nonexistent directory to prevent GDB from finding
     `sysroot' to a nonexistent directory to prevent GDB from finding
     your host's libraries.  `sysroot' is preferred; setting it to a
     your host's libraries.  `sysroot' is preferred; setting it to a
     nonexistent directory may interfere with automatic loading of
     nonexistent directory may interfere with automatic loading of
     shared library symbols.
     shared library symbols.
`show solib-search-path'
`show solib-search-path'
     Display the current shared library search path.
     Display the current shared library search path.


File: gdb.info,  Node: Separate Debug Files,  Next: Symbol Errors,  Prev: Files,  Up: GDB Files
File: gdb.info,  Node: Separate Debug Files,  Next: Symbol Errors,  Prev: Files,  Up: GDB Files
15.2 Debugging Information in Separate Files
15.2 Debugging Information in Separate Files
============================================
============================================
GDB allows you to put a program's debugging information in a file
GDB allows you to put a program's debugging information in a file
separate from the executable itself, in a way that allows GDB to find
separate from the executable itself, in a way that allows GDB to find
and load the debugging information automatically.  Since debugging
and load the debugging information automatically.  Since debugging
information can be very large--sometimes larger than the executable
information can be very large--sometimes larger than the executable
code itself--some systems distribute debugging information for their
code itself--some systems distribute debugging information for their
executables in separate files, which users can install only when they
executables in separate files, which users can install only when they
need to debug a problem.
need to debug a problem.
   GDB supports two ways of specifying the separate debug info file:
   GDB supports two ways of specifying the separate debug info file:
   * The executable contains a "debug link" that specifies the name of
   * The executable contains a "debug link" that specifies the name of
     the separate debug info file.  The separate debug file's name is
     the separate debug info file.  The separate debug file's name is
     usually `EXECUTABLE.debug', where EXECUTABLE is the name of the
     usually `EXECUTABLE.debug', where EXECUTABLE is the name of the
     corresponding executable file without leading directories (e.g.,
     corresponding executable file without leading directories (e.g.,
     `ls.debug' for `/usr/bin/ls').  In addition, the debug link
     `ls.debug' for `/usr/bin/ls').  In addition, the debug link
     specifies a CRC32 checksum for the debug file, which GDB uses to
     specifies a CRC32 checksum for the debug file, which GDB uses to
     validate that the executable and the debug file came from the same
     validate that the executable and the debug file came from the same
     build.
     build.
   * The executable contains a "build ID", a unique bit string that is
   * The executable contains a "build ID", a unique bit string that is
     also present in the corresponding debug info file.  (This is
     also present in the corresponding debug info file.  (This is
     supported only on some operating systems, notably those which use
     supported only on some operating systems, notably those which use
     the ELF format for binary files and the GNU Binutils.)  For more
     the ELF format for binary files and the GNU Binutils.)  For more
     details about this feature, see the description of the `--build-id'
     details about this feature, see the description of the `--build-id'
     command-line option in *Note Command Line Options:
     command-line option in *Note Command Line Options:
     (ld.info)Options.  The debug info file's name is not specified
     (ld.info)Options.  The debug info file's name is not specified
     explicitly by the build ID, but can be computed from the build ID,
     explicitly by the build ID, but can be computed from the build ID,
     see below.
     see below.
   Depending on the way the debug info file is specified, GDB uses two
   Depending on the way the debug info file is specified, GDB uses two
different methods of looking for the debug file:
different methods of looking for the debug file:
   * For the "debug link" method, GDB looks up the named file in the
   * For the "debug link" method, GDB looks up the named file in the
     directory of the executable file, then in a subdirectory of that
     directory of the executable file, then in a subdirectory of that
     directory named `.debug', and finally under the global debug
     directory named `.debug', and finally under the global debug
     directory, in a subdirectory whose name is identical to the leading
     directory, in a subdirectory whose name is identical to the leading
     directories of the executable's absolute file name.
     directories of the executable's absolute file name.
   * For the "build ID" method, GDB looks in the `.build-id'
   * For the "build ID" method, GDB looks in the `.build-id'
     subdirectory of the global debug directory for a file named
     subdirectory of the global debug directory for a file named
     `NN/NNNNNNNN.debug', where NN are the first 2 hex characters of
     `NN/NNNNNNNN.debug', where NN are the first 2 hex characters of
     the build ID bit string, and NNNNNNNN are the rest of the bit
     the build ID bit string, and NNNNNNNN are the rest of the bit
     string.  (Real build ID strings are 32 or more hex characters, not
     string.  (Real build ID strings are 32 or more hex characters, not
     10.)
     10.)
   So, for example, suppose you ask GDB to debug `/usr/bin/ls', which
   So, for example, suppose you ask GDB to debug `/usr/bin/ls', which
has a debug link that specifies the file `ls.debug', and a build ID
has a debug link that specifies the file `ls.debug', and a build ID
whose value in hex is `abcdef1234'.  If the global debug directory is
whose value in hex is `abcdef1234'.  If the global debug directory is
`/usr/lib/debug', then GDB will look for the following debug
`/usr/lib/debug', then GDB will look for the following debug
information files, in the indicated order:
information files, in the indicated order:
   - `/usr/lib/debug/.build-id/ab/cdef1234.debug'
   - `/usr/lib/debug/.build-id/ab/cdef1234.debug'
   - `/usr/bin/ls.debug'
   - `/usr/bin/ls.debug'
   - `/usr/bin/.debug/ls.debug'
   - `/usr/bin/.debug/ls.debug'
   - `/usr/lib/debug/usr/bin/ls.debug'.
   - `/usr/lib/debug/usr/bin/ls.debug'.
   You can set the global debugging info directory's name, and view the
   You can set the global debugging info directory's name, and view the
name GDB is currently using.
name GDB is currently using.
`set debug-file-directory DIRECTORY'
`set debug-file-directory DIRECTORY'
     Set the directory which GDB searches for separate debugging
     Set the directory which GDB searches for separate debugging
     information files to DIRECTORY.
     information files to DIRECTORY.
`show debug-file-directory'
`show debug-file-directory'
     Show the directory GDB searches for separate debugging information
     Show the directory GDB searches for separate debugging information
     files.
     files.
   A debug link is a special section of the executable file named
   A debug link is a special section of the executable file named
`.gnu_debuglink'.  The section must contain:
`.gnu_debuglink'.  The section must contain:
   * A filename, with any leading directory components removed,
   * A filename, with any leading directory components removed,
     followed by a zero byte,
     followed by a zero byte,
   * zero to three bytes of padding, as needed to reach the next
   * zero to three bytes of padding, as needed to reach the next
     four-byte boundary within the section, and
     four-byte boundary within the section, and
   * a four-byte CRC checksum, stored in the same endianness used for
   * a four-byte CRC checksum, stored in the same endianness used for
     the executable file itself.  The checksum is computed on the
     the executable file itself.  The checksum is computed on the
     debugging information file's full contents by the function given
     debugging information file's full contents by the function given
     below, passing zero as the CRC argument.
     below, passing zero as the CRC argument.
   Any executable file format can carry a debug link, as long as it can
   Any executable file format can carry a debug link, as long as it can
contain a section named `.gnu_debuglink' with the contents described
contain a section named `.gnu_debuglink' with the contents described
above.
above.
   The build ID is a special section in the executable file (and in
   The build ID is a special section in the executable file (and in
other ELF binary files that GDB may consider).  This section is often
other ELF binary files that GDB may consider).  This section is often
named `.note.gnu.build-id', but that name is not mandatory.  It
named `.note.gnu.build-id', but that name is not mandatory.  It
contains unique identification for the built files--the ID remains the
contains unique identification for the built files--the ID remains the
same across multiple builds of the same build tree.  The default
same across multiple builds of the same build tree.  The default
algorithm SHA1 produces 160 bits (40 hexadecimal characters) of the
algorithm SHA1 produces 160 bits (40 hexadecimal characters) of the
content for the build ID string.  The same section with an identical
content for the build ID string.  The same section with an identical
value is present in the original built binary with symbols, in its
value is present in the original built binary with symbols, in its
stripped variant, and in the separate debugging information file.
stripped variant, and in the separate debugging information file.
   The debugging information file itself should be an ordinary
   The debugging information file itself should be an ordinary
executable, containing a full set of linker symbols, sections, and
executable, containing a full set of linker symbols, sections, and
debugging information.  The sections of the debugging information file
debugging information.  The sections of the debugging information file
should have the same names, addresses, and sizes as the original file,
should have the same names, addresses, and sizes as the original file,
but they need not contain any data--much like a `.bss' section in an
but they need not contain any data--much like a `.bss' section in an
ordinary executable.
ordinary executable.
   The GNU binary utilities (Binutils) package includes the `objcopy'
   The GNU binary utilities (Binutils) package includes the `objcopy'
utility that can produce the separated executable / debugging
utility that can produce the separated executable / debugging
information file pairs using the following commands:
information file pairs using the following commands:
     objcopy --only-keep-debug foo foo.debug
     objcopy --only-keep-debug foo foo.debug
     strip -g foo
     strip -g foo
These commands remove the debugging information from the executable
These commands remove the debugging information from the executable
file `foo' and place it in the file `foo.debug'.  You can use the
file `foo' and place it in the file `foo.debug'.  You can use the
first, second or both methods to link the two files:
first, second or both methods to link the two files:
   * The debug link method needs the following additional command to
   * The debug link method needs the following additional command to
     also leave behind a debug link in `foo':
     also leave behind a debug link in `foo':
          objcopy --add-gnu-debuglink=foo.debug foo
          objcopy --add-gnu-debuglink=foo.debug foo
     Ulrich Drepper's `elfutils' package, starting with version 0.53,
     Ulrich Drepper's `elfutils' package, starting with version 0.53,
     contains a version of the `strip' command such that the command
     contains a version of the `strip' command such that the command
     `strip foo -f foo.debug' has the same functionality as the two
     `strip foo -f foo.debug' has the same functionality as the two
     `objcopy' commands and the `ln -s' command above, together.
     `objcopy' commands and the `ln -s' command above, together.
   * Build ID gets embedded into the main executable using `ld
   * Build ID gets embedded into the main executable using `ld
     --build-id' or the GCC counterpart `gcc -Wl,--build-id'.  Build ID
     --build-id' or the GCC counterpart `gcc -Wl,--build-id'.  Build ID
     support plus compatibility fixes for debug files separation are
     support plus compatibility fixes for debug files separation are
     present in GNU binary utilities (Binutils) package since version
     present in GNU binary utilities (Binutils) package since version
     2.18.
     2.18.
Since there are many different ways to compute CRC's for the debug link
Since there are many different ways to compute CRC's for the debug link
(different polynomials, reversals, byte ordering, etc.), the simplest
(different polynomials, reversals, byte ordering, etc.), the simplest
way to describe the CRC used in `.gnu_debuglink' sections is to give
way to describe the CRC used in `.gnu_debuglink' sections is to give
the complete code for a function that computes it:
the complete code for a function that computes it:
     unsigned long
     unsigned long
     gnu_debuglink_crc32 (unsigned long crc,
     gnu_debuglink_crc32 (unsigned long crc,
                          unsigned char *buf, size_t len)
                          unsigned char *buf, size_t len)
     {
     {
       static const unsigned long crc32_table[256] =
       static const unsigned long crc32_table[256] =
         {
         {
           0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
           0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
           0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
           0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
           0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
           0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
           0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
           0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
           0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
           0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
           0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
           0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
           0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
           0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
           0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
           0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
           0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
           0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
           0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
           0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
           0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
           0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
           0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
           0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
           0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
           0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
           0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
           0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
           0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
           0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
           0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
           0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
           0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
           0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
           0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
           0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
           0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
           0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
           0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
           0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
           0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
           0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
           0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
           0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
           0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
           0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
           0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
           0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
           0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
           0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
           0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
           0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
           0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
           0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
           0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
           0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
           0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
           0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
           0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
           0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
           0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
           0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
           0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
           0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
           0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
           0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
           0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
           0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
           0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
           0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
           0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
           0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
           0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
           0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
           0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
           0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
           0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
           0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
           0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
           0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
           0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
           0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
           0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
           0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
           0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
           0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
           0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
           0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
           0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
           0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
           0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
           0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
           0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
           0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
           0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
           0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
           0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
           0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
           0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
           0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
           0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
           0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
           0x2d02ef8d
           0x2d02ef8d
         };
         };
       unsigned char *end;
       unsigned char *end;
       crc = ~crc & 0xffffffff;
       crc = ~crc & 0xffffffff;
       for (end = buf + len; buf < end; ++buf)
       for (end = buf + len; buf < end; ++buf)
         crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
         crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
       return ~crc & 0xffffffff;
       return ~crc & 0xffffffff;
     }
     }
This computation does not apply to the "build ID" method.
This computation does not apply to the "build ID" method.


File: gdb.info,  Node: Symbol Errors,  Prev: Separate Debug Files,  Up: GDB Files
File: gdb.info,  Node: Symbol Errors,  Prev: Separate Debug Files,  Up: GDB Files
15.3 Errors Reading Symbol Files
15.3 Errors Reading Symbol Files
================================
================================
While reading a symbol file, GDB occasionally encounters problems, such
While reading a symbol file, GDB occasionally encounters problems, such
as symbol types it does not recognize, or known bugs in compiler
as symbol types it does not recognize, or known bugs in compiler
output.  By default, GDB does not notify you of such problems, since
output.  By default, GDB does not notify you of such problems, since
they are relatively common and primarily of interest to people
they are relatively common and primarily of interest to people
debugging compilers.  If you are interested in seeing information about
debugging compilers.  If you are interested in seeing information about
ill-constructed symbol tables, you can either ask GDB to print only one
ill-constructed symbol tables, you can either ask GDB to print only one
message about each such type of problem, no matter how many times the
message about each such type of problem, no matter how many times the
problem occurs; or you can ask GDB to print more messages, to see how
problem occurs; or you can ask GDB to print more messages, to see how
many times the problems occur, with the `set complaints' command (*note
many times the problems occur, with the `set complaints' command (*note
Optional Warnings and Messages: Messages/Warnings.).
Optional Warnings and Messages: Messages/Warnings.).
   The messages currently printed, and their meanings, include:
   The messages currently printed, and their meanings, include:
`inner block not inside outer block in SYMBOL'
`inner block not inside outer block in SYMBOL'
     The symbol information shows where symbol scopes begin and end
     The symbol information shows where symbol scopes begin and end
     (such as at the start of a function or a block of statements).
     (such as at the start of a function or a block of statements).
     This error indicates that an inner scope block is not fully
     This error indicates that an inner scope block is not fully
     contained in its outer scope blocks.
     contained in its outer scope blocks.
     GDB circumvents the problem by treating the inner block as if it
     GDB circumvents the problem by treating the inner block as if it
     had the same scope as the outer block.  In the error message,
     had the same scope as the outer block.  In the error message,
     SYMBOL may be shown as "`(don't know)'" if the outer block is not a
     SYMBOL may be shown as "`(don't know)'" if the outer block is not a
     function.
     function.
`block at ADDRESS out of order'
`block at ADDRESS out of order'
     The symbol information for symbol scope blocks should occur in
     The symbol information for symbol scope blocks should occur in
     order of increasing addresses.  This error indicates that it does
     order of increasing addresses.  This error indicates that it does
     not do so.
     not do so.
     GDB does not circumvent this problem, and has trouble locating
     GDB does not circumvent this problem, and has trouble locating
     symbols in the source file whose symbols it is reading.  (You can
     symbols in the source file whose symbols it is reading.  (You can
     often determine what source file is affected by specifying `set
     often determine what source file is affected by specifying `set
     verbose on'.  *Note Optional Warnings and Messages:
     verbose on'.  *Note Optional Warnings and Messages:
     Messages/Warnings.)
     Messages/Warnings.)
`bad block start address patched'
`bad block start address patched'
     The symbol information for a symbol scope block has a start address
     The symbol information for a symbol scope block has a start address
     smaller than the address of the preceding source line.  This is
     smaller than the address of the preceding source line.  This is
     known to occur in the SunOS 4.1.1 (and earlier) C compiler.
     known to occur in the SunOS 4.1.1 (and earlier) C compiler.
     GDB circumvents the problem by treating the symbol scope block as
     GDB circumvents the problem by treating the symbol scope block as
     starting on the previous source line.
     starting on the previous source line.
`bad string table offset in symbol N'
`bad string table offset in symbol N'
     Symbol number N contains a pointer into the string table which is
     Symbol number N contains a pointer into the string table which is
     larger than the size of the string table.
     larger than the size of the string table.
     GDB circumvents the problem by considering the symbol to have the
     GDB circumvents the problem by considering the symbol to have the
     name `foo', which may cause other problems if many symbols end up
     name `foo', which may cause other problems if many symbols end up
     with this name.
     with this name.
`unknown symbol type `0xNN''
`unknown symbol type `0xNN''
     The symbol information contains new data types that GDB does not
     The symbol information contains new data types that GDB does not
     yet know how to read.  `0xNN' is the symbol type of the
     yet know how to read.  `0xNN' is the symbol type of the
     uncomprehended information, in hexadecimal.
     uncomprehended information, in hexadecimal.
     GDB circumvents the error by ignoring this symbol information.
     GDB circumvents the error by ignoring this symbol information.
     This usually allows you to debug your program, though certain
     This usually allows you to debug your program, though certain
     symbols are not accessible.  If you encounter such a problem and
     symbols are not accessible.  If you encounter such a problem and
     feel like debugging it, you can debug `gdb' with itself, breakpoint
     feel like debugging it, you can debug `gdb' with itself, breakpoint
     on `complain', then go up to the function `read_dbx_symtab' and
     on `complain', then go up to the function `read_dbx_symtab' and
     examine `*bufp' to see the symbol.
     examine `*bufp' to see the symbol.
`stub type has NULL name'
`stub type has NULL name'
     GDB could not find the full definition for a struct or class.
     GDB could not find the full definition for a struct or class.
`const/volatile indicator missing (ok if using g++ v1.x), got...'
`const/volatile indicator missing (ok if using g++ v1.x), got...'
     The symbol information for a C++ member function is missing some
     The symbol information for a C++ member function is missing some
     information that recent versions of the compiler should have
     information that recent versions of the compiler should have
     output for it.
     output for it.
`info mismatch between compiler and debugger'
`info mismatch between compiler and debugger'
     GDB could not parse a type specification output by the compiler.
     GDB could not parse a type specification output by the compiler.


File: gdb.info,  Node: Targets,  Next: Remote Debugging,  Prev: GDB Files,  Up: Top
File: gdb.info,  Node: Targets,  Next: Remote Debugging,  Prev: GDB Files,  Up: Top
16 Specifying a Debugging Target
16 Specifying a Debugging Target
********************************
********************************
A "target" is the execution environment occupied by your program.
A "target" is the execution environment occupied by your program.
   Often, GDB runs in the same host environment as your program; in
   Often, GDB runs in the same host environment as your program; in
that case, the debugging target is specified as a side effect when you
that case, the debugging target is specified as a side effect when you
use the `file' or `core' commands.  When you need more flexibility--for
use the `file' or `core' commands.  When you need more flexibility--for
example, running GDB on a physically separate host, or controlling a
example, running GDB on a physically separate host, or controlling a
standalone system over a serial port or a realtime system over a TCP/IP
standalone system over a serial port or a realtime system over a TCP/IP
connection--you can use the `target' command to specify one of the
connection--you can use the `target' command to specify one of the
target types configured for GDB (*note Commands for Managing Targets:
target types configured for GDB (*note Commands for Managing Targets:
Target Commands.).
Target Commands.).
   It is possible to build GDB for several different "target
   It is possible to build GDB for several different "target
architectures".  When GDB is built like that, you can choose one of the
architectures".  When GDB is built like that, you can choose one of the
available architectures with the `set architecture' command.
available architectures with the `set architecture' command.
`set architecture ARCH'
`set architecture ARCH'
     This command sets the current target architecture to ARCH.  The
     This command sets the current target architecture to ARCH.  The
     value of ARCH can be `"auto"', in addition to one of the supported
     value of ARCH can be `"auto"', in addition to one of the supported
     architectures.
     architectures.
`show architecture'
`show architecture'
     Show the current target architecture.
     Show the current target architecture.
`set processor'
`set processor'
`processor'
`processor'
     These are alias commands for, respectively, `set architecture' and
     These are alias commands for, respectively, `set architecture' and
     `show architecture'.
     `show architecture'.
* Menu:
* Menu:
* Active Targets::              Active targets
* Active Targets::              Active targets
* Target Commands::             Commands for managing targets
* Target Commands::             Commands for managing targets
* Byte Order::                  Choosing target byte order
* Byte Order::                  Choosing target byte order


File: gdb.info,  Node: Active Targets,  Next: Target Commands,  Up: Targets
File: gdb.info,  Node: Active Targets,  Next: Target Commands,  Up: Targets
16.1 Active Targets
16.1 Active Targets
===================
===================
There are three classes of targets: processes, core files, and
There are three classes of targets: processes, core files, and
executable files.  GDB can work concurrently on up to three active
executable files.  GDB can work concurrently on up to three active
targets, one in each class.  This allows you to (for example) start a
targets, one in each class.  This allows you to (for example) start a
process and inspect its activity without abandoning your work on a core
process and inspect its activity without abandoning your work on a core
file.
file.
   For example, if you execute `gdb a.out', then the executable file
   For example, if you execute `gdb a.out', then the executable file
`a.out' is the only active target.  If you designate a core file as
`a.out' is the only active target.  If you designate a core file as
well--presumably from a prior run that crashed and coredumped--then GDB
well--presumably from a prior run that crashed and coredumped--then GDB
has two active targets and uses them in tandem, looking first in the
has two active targets and uses them in tandem, looking first in the
corefile target, then in the executable file, to satisfy requests for
corefile target, then in the executable file, to satisfy requests for
memory addresses.  (Typically, these two classes of target are
memory addresses.  (Typically, these two classes of target are
complementary, since core files contain only a program's read-write
complementary, since core files contain only a program's read-write
memory--variables and so on--plus machine status, while executable
memory--variables and so on--plus machine status, while executable
files contain only the program text and initialized data.)
files contain only the program text and initialized data.)
   When you type `run', your executable file becomes an active process
   When you type `run', your executable file becomes an active process
target as well.  When a process target is active, all GDB commands
target as well.  When a process target is active, all GDB commands
requesting memory addresses refer to that target; addresses in an
requesting memory addresses refer to that target; addresses in an
active core file or executable file target are obscured while the
active core file or executable file target are obscured while the
process target is active.
process target is active.
   Use the `core-file' and `exec-file' commands to select a new core
   Use the `core-file' and `exec-file' commands to select a new core
file or executable target (*note Commands to Specify Files: Files.).
file or executable target (*note Commands to Specify Files: Files.).
To specify as a target a process that is already running, use the
To specify as a target a process that is already running, use the
`attach' command (*note Debugging an Already-running Process: Attach.).
`attach' command (*note Debugging an Already-running Process: Attach.).


File: gdb.info,  Node: Target Commands,  Next: Byte Order,  Prev: Active Targets,  Up: Targets
File: gdb.info,  Node: Target Commands,  Next: Byte Order,  Prev: Active Targets,  Up: Targets
16.2 Commands for Managing Targets
16.2 Commands for Managing Targets
==================================
==================================
`target TYPE PARAMETERS'
`target TYPE PARAMETERS'
     Connects the GDB host environment to a target machine or process.
     Connects the GDB host environment to a target machine or process.
     A target is typically a protocol for talking to debugging
     A target is typically a protocol for talking to debugging
     facilities.  You use the argument TYPE to specify the type or
     facilities.  You use the argument TYPE to specify the type or
     protocol of the target machine.
     protocol of the target machine.
     Further PARAMETERS are interpreted by the target protocol, but
     Further PARAMETERS are interpreted by the target protocol, but
     typically include things like device names or host names to connect
     typically include things like device names or host names to connect
     with, process numbers, and baud rates.
     with, process numbers, and baud rates.
     The `target' command does not repeat if you press  again
     The `target' command does not repeat if you press  again
     after executing the command.
     after executing the command.
`help target'
`help target'
     Displays the names of all targets available.  To display targets
     Displays the names of all targets available.  To display targets
     currently selected, use either `info target' or `info files'
     currently selected, use either `info target' or `info files'
     (*note Commands to Specify Files: Files.).
     (*note Commands to Specify Files: Files.).
`help target NAME'
`help target NAME'
     Describe a particular target, including any parameters necessary to
     Describe a particular target, including any parameters necessary to
     select it.
     select it.
`set gnutarget ARGS'
`set gnutarget ARGS'
     GDB uses its own library BFD to read your files.  GDB knows
     GDB uses its own library BFD to read your files.  GDB knows
     whether it is reading an "executable", a "core", or a ".o" file;
     whether it is reading an "executable", a "core", or a ".o" file;
     however, you can specify the file format with the `set gnutarget'
     however, you can specify the file format with the `set gnutarget'
     command.  Unlike most `target' commands, with `gnutarget' the
     command.  Unlike most `target' commands, with `gnutarget' the
     `target' refers to a program, not a machine.
     `target' refers to a program, not a machine.
          _Warning:_ To specify a file format with `set gnutarget', you
          _Warning:_ To specify a file format with `set gnutarget', you
          must know the actual BFD name.
          must know the actual BFD name.
     *Note Commands to Specify Files: Files.
     *Note Commands to Specify Files: Files.
`show gnutarget'
`show gnutarget'
     Use the `show gnutarget' command to display what file format
     Use the `show gnutarget' command to display what file format
     `gnutarget' is set to read.  If you have not set `gnutarget', GDB
     `gnutarget' is set to read.  If you have not set `gnutarget', GDB
     will determine the file format for each file automatically, and
     will determine the file format for each file automatically, and
     `show gnutarget' displays `The current BDF target is "auto"'.
     `show gnutarget' displays `The current BDF target is "auto"'.
   Here are some common targets (available, or not, depending on the GDB
   Here are some common targets (available, or not, depending on the GDB
configuration):
configuration):
`target exec PROGRAM'
`target exec PROGRAM'
     An executable file.  `target exec PROGRAM' is the same as
     An executable file.  `target exec PROGRAM' is the same as
     `exec-file PROGRAM'.
     `exec-file PROGRAM'.
`target core FILENAME'
`target core FILENAME'
     A core dump file.  `target core FILENAME' is the same as
     A core dump file.  `target core FILENAME' is the same as
     `core-file FILENAME'.
     `core-file FILENAME'.
`target remote MEDIUM'
`target remote MEDIUM'
     A remote system connected to GDB via a serial line or network
     A remote system connected to GDB via a serial line or network
     connection.  This command tells GDB to use its own remote protocol
     connection.  This command tells GDB to use its own remote protocol
     over MEDIUM for debugging.  *Note Remote Debugging::.
     over MEDIUM for debugging.  *Note Remote Debugging::.
     For example, if you have a board connected to `/dev/ttya' on the
     For example, if you have a board connected to `/dev/ttya' on the
     machine running GDB, you could say:
     machine running GDB, you could say:
          target remote /dev/ttya
          target remote /dev/ttya
     `target remote' supports the `load' command.  This is only useful
     `target remote' supports the `load' command.  This is only useful
     if you have some other way of getting the stub to the target
     if you have some other way of getting the stub to the target
     system, and you can put it somewhere in memory where it won't get
     system, and you can put it somewhere in memory where it won't get
     clobbered by the download.
     clobbered by the download.
`target sim'
`target sim'
     Builtin CPU simulator.  GDB includes simulators for most
     Builtin CPU simulator.  GDB includes simulators for most
     architectures.  In general,
     architectures.  In general,
                  target sim
                  target sim
                  load
                  load
                  run
                  run
     works; however, you cannot assume that a specific memory map,
     works; however, you cannot assume that a specific memory map,
     device drivers, or even basic I/O is available, although some
     device drivers, or even basic I/O is available, although some
     simulators do provide these.  For info about any
     simulators do provide these.  For info about any
     processor-specific simulator details, see the appropriate section
     processor-specific simulator details, see the appropriate section
     in *Note Embedded Processors: Embedded Processors.
     in *Note Embedded Processors: Embedded Processors.
   Some configurations may include these targets as well:
   Some configurations may include these targets as well:
`target nrom DEV'
`target nrom DEV'
     NetROM ROM emulator.  This target only supports downloading.
     NetROM ROM emulator.  This target only supports downloading.
   Different targets are available on different configurations of GDB;
   Different targets are available on different configurations of GDB;
your configuration may have more or fewer targets.
your configuration may have more or fewer targets.
   Many remote targets require you to download the executable's code
   Many remote targets require you to download the executable's code
once you've successfully established a connection.  You may wish to
once you've successfully established a connection.  You may wish to
control various aspects of this process.
control various aspects of this process.
`set hash'
`set hash'
     This command controls whether a hash mark `#' is displayed while
     This command controls whether a hash mark `#' is displayed while
     downloading a file to the remote monitor.  If on, a hash mark is
     downloading a file to the remote monitor.  If on, a hash mark is
     displayed after each S-record is successfully downloaded to the
     displayed after each S-record is successfully downloaded to the
     monitor.
     monitor.
`show hash'
`show hash'
     Show the current status of displaying the hash mark.
     Show the current status of displaying the hash mark.
`set debug monitor'
`set debug monitor'
     Enable or disable display of communications messages between GDB
     Enable or disable display of communications messages between GDB
     and the remote monitor.
     and the remote monitor.
`show debug monitor'
`show debug monitor'
     Show the current status of displaying communications between GDB
     Show the current status of displaying communications between GDB
     and the remote monitor.
     and the remote monitor.
`load FILENAME'
`load FILENAME'
     Depending on what remote debugging facilities are configured into
     Depending on what remote debugging facilities are configured into
     GDB, the `load' command may be available.  Where it exists, it is
     GDB, the `load' command may be available.  Where it exists, it is
     meant to make FILENAME (an executable) available for debugging on
     meant to make FILENAME (an executable) available for debugging on
     the remote system--by downloading, or dynamic linking, for example.
     the remote system--by downloading, or dynamic linking, for example.
     `load' also records the FILENAME symbol table in GDB, like the
     `load' also records the FILENAME symbol table in GDB, like the
     `add-symbol-file' command.
     `add-symbol-file' command.
     If your GDB does not have a `load' command, attempting to execute
     If your GDB does not have a `load' command, attempting to execute
     it gets the error message "`You can't do that when your target is
     it gets the error message "`You can't do that when your target is
     ...'"
     ...'"
     The file is loaded at whatever address is specified in the
     The file is loaded at whatever address is specified in the
     executable.  For some object file formats, you can specify the
     executable.  For some object file formats, you can specify the
     load address when you link the program; for other formats, like
     load address when you link the program; for other formats, like
     a.out, the object file format specifies a fixed address.
     a.out, the object file format specifies a fixed address.
     Depending on the remote side capabilities, GDB may be able to load
     Depending on the remote side capabilities, GDB may be able to load
     programs into flash memory.
     programs into flash memory.
     `load' does not repeat if you press  again after using it.
     `load' does not repeat if you press  again after using it.


File: gdb.info,  Node: Byte Order,  Prev: Target Commands,  Up: Targets
File: gdb.info,  Node: Byte Order,  Prev: Target Commands,  Up: Targets
16.3 Choosing Target Byte Order
16.3 Choosing Target Byte Order
===============================
===============================
Some types of processors, such as the MIPS, PowerPC, and Renesas SH,
Some types of processors, such as the MIPS, PowerPC, and Renesas SH,
offer the ability to run either big-endian or little-endian byte
offer the ability to run either big-endian or little-endian byte
orders.  Usually the executable or symbol will include a bit to
orders.  Usually the executable or symbol will include a bit to
designate the endian-ness, and you will not need to worry about which
designate the endian-ness, and you will not need to worry about which
to use.  However, you may still find it useful to adjust GDB's idea of
to use.  However, you may still find it useful to adjust GDB's idea of
processor endian-ness manually.
processor endian-ness manually.
`set endian big'
`set endian big'
     Instruct GDB to assume the target is big-endian.
     Instruct GDB to assume the target is big-endian.
`set endian little'
`set endian little'
     Instruct GDB to assume the target is little-endian.
     Instruct GDB to assume the target is little-endian.
`set endian auto'
`set endian auto'
     Instruct GDB to use the byte order associated with the executable.
     Instruct GDB to use the byte order associated with the executable.
`show endian'
`show endian'
     Display GDB's current idea of the target byte order.
     Display GDB's current idea of the target byte order.
   Note that these commands merely adjust interpretation of symbolic
   Note that these commands merely adjust interpretation of symbolic
data on the host, and that they have absolutely no effect on the target
data on the host, and that they have absolutely no effect on the target
system.
system.


File: gdb.info,  Node: Remote Debugging,  Next: Configurations,  Prev: Targets,  Up: Top
File: gdb.info,  Node: Remote Debugging,  Next: Configurations,  Prev: Targets,  Up: Top
17 Debugging Remote Programs
17 Debugging Remote Programs
****************************
****************************
If you are trying to debug a program running on a machine that cannot
If you are trying to debug a program running on a machine that cannot
run GDB in the usual way, it is often useful to use remote debugging.
run GDB in the usual way, it is often useful to use remote debugging.
For example, you might use remote debugging on an operating system
For example, you might use remote debugging on an operating system
kernel, or on a small system which does not have a general purpose
kernel, or on a small system which does not have a general purpose
operating system powerful enough to run a full-featured debugger.
operating system powerful enough to run a full-featured debugger.
   Some configurations of GDB have special serial or TCP/IP interfaces
   Some configurations of GDB have special serial or TCP/IP interfaces
to make this work with particular debugging targets.  In addition, GDB
to make this work with particular debugging targets.  In addition, GDB
comes with a generic serial protocol (specific to GDB, but not specific
comes with a generic serial protocol (specific to GDB, but not specific
to any particular target system) which you can use if you write the
to any particular target system) which you can use if you write the
remote stubs--the code that runs on the remote system to communicate
remote stubs--the code that runs on the remote system to communicate
with GDB.
with GDB.
   Other remote targets may be available in your configuration of GDB;
   Other remote targets may be available in your configuration of GDB;
use `help target' to list them.
use `help target' to list them.
* Menu:
* Menu:
* Connecting::                  Connecting to a remote target
* Connecting::                  Connecting to a remote target
* File Transfer::               Sending files to a remote system
* File Transfer::               Sending files to a remote system
* Server::                      Using the gdbserver program
* Server::                      Using the gdbserver program
* Remote Configuration::        Remote configuration
* Remote Configuration::        Remote configuration
* Remote Stub::                 Implementing a remote stub
* Remote Stub::                 Implementing a remote stub


File: gdb.info,  Node: Connecting,  Next: File Transfer,  Up: Remote Debugging
File: gdb.info,  Node: Connecting,  Next: File Transfer,  Up: Remote Debugging
17.1 Connecting to a Remote Target
17.1 Connecting to a Remote Target
==================================
==================================
On the GDB host machine, you will need an unstripped copy of your
On the GDB host machine, you will need an unstripped copy of your
program, since GDB needs symbol and debugging information.  Start up
program, since GDB needs symbol and debugging information.  Start up
GDB as usual, using the name of the local copy of your program as the
GDB as usual, using the name of the local copy of your program as the
first argument.
first argument.
   GDB can communicate with the target over a serial line, or over an
   GDB can communicate with the target over a serial line, or over an
IP network using TCP or UDP.  In each case, GDB uses the same protocol
IP network using TCP or UDP.  In each case, GDB uses the same protocol
for debugging your program; only the medium carrying the debugging
for debugging your program; only the medium carrying the debugging
packets varies.  The `target remote' command establishes a connection
packets varies.  The `target remote' command establishes a connection
to the target.  Its arguments indicate which medium to use:
to the target.  Its arguments indicate which medium to use:
`target remote SERIAL-DEVICE'
`target remote SERIAL-DEVICE'
     Use SERIAL-DEVICE to communicate with the target.  For example, to
     Use SERIAL-DEVICE to communicate with the target.  For example, to
     use a serial line connected to the device named `/dev/ttyb':
     use a serial line connected to the device named `/dev/ttyb':
          target remote /dev/ttyb
          target remote /dev/ttyb
     If you're using a serial line, you may want to give GDB the
     If you're using a serial line, you may want to give GDB the
     `--baud' option, or use the `set remotebaud' command (*note set
     `--baud' option, or use the `set remotebaud' command (*note set
     remotebaud: Remote Configuration.) before the `target' command.
     remotebaud: Remote Configuration.) before the `target' command.
`target remote `HOST:PORT''
`target remote `HOST:PORT''
`target remote `tcp:HOST:PORT''
`target remote `tcp:HOST:PORT''
     Debug using a TCP connection to PORT on HOST.  The HOST may be
     Debug using a TCP connection to PORT on HOST.  The HOST may be
     either a host name or a numeric IP address; PORT must be a decimal
     either a host name or a numeric IP address; PORT must be a decimal
     number.  The HOST could be the target machine itself, if it is
     number.  The HOST could be the target machine itself, if it is
     directly connected to the net, or it might be a terminal server
     directly connected to the net, or it might be a terminal server
     which in turn has a serial line to the target.
     which in turn has a serial line to the target.
     For example, to connect to port 2828 on a terminal server named
     For example, to connect to port 2828 on a terminal server named
     `manyfarms':
     `manyfarms':
          target remote manyfarms:2828
          target remote manyfarms:2828
     If your remote target is actually running on the same machine as
     If your remote target is actually running on the same machine as
     your debugger session (e.g. a simulator for your target running on
     your debugger session (e.g. a simulator for your target running on
     the same host), you can omit the hostname.  For example, to
     the same host), you can omit the hostname.  For example, to
     connect to port 1234 on your local machine:
     connect to port 1234 on your local machine:
          target remote :1234
          target remote :1234
     Note that the colon is still required here.
     Note that the colon is still required here.
`target remote `udp:HOST:PORT''
`target remote `udp:HOST:PORT''
     Debug using UDP packets to PORT on HOST.  For example, to connect
     Debug using UDP packets to PORT on HOST.  For example, to connect
     to UDP port 2828 on a terminal server named `manyfarms':
     to UDP port 2828 on a terminal server named `manyfarms':
          target remote udp:manyfarms:2828
          target remote udp:manyfarms:2828
     When using a UDP connection for remote debugging, you should keep
     When using a UDP connection for remote debugging, you should keep
     in mind that the `U' stands for "Unreliable".  UDP can silently
     in mind that the `U' stands for "Unreliable".  UDP can silently
     drop packets on busy or unreliable networks, which will cause
     drop packets on busy or unreliable networks, which will cause
     havoc with your debugging session.
     havoc with your debugging session.
`target remote | COMMAND'
`target remote | COMMAND'
     Run COMMAND in the background and communicate with it using a
     Run COMMAND in the background and communicate with it using a
     pipe.  The COMMAND is a shell command, to be parsed and expanded
     pipe.  The COMMAND is a shell command, to be parsed and expanded
     by the system's command shell, `/bin/sh'; it should expect remote
     by the system's command shell, `/bin/sh'; it should expect remote
     protocol packets on its standard input, and send replies on its
     protocol packets on its standard input, and send replies on its
     standard output.  You could use this to run a stand-alone simulator
     standard output.  You could use this to run a stand-alone simulator
     that speaks the remote debugging protocol, to make net connections
     that speaks the remote debugging protocol, to make net connections
     using programs like `ssh', or for other similar tricks.
     using programs like `ssh', or for other similar tricks.
     If COMMAND closes its standard output (perhaps by exiting), GDB
     If COMMAND closes its standard output (perhaps by exiting), GDB
     will try to send it a `SIGTERM' signal.  (If the program has
     will try to send it a `SIGTERM' signal.  (If the program has
     already exited, this will have no effect.)
     already exited, this will have no effect.)
   Once the connection has been established, you can use all the usual
   Once the connection has been established, you can use all the usual
commands to examine and change data and to step and continue the remote
commands to examine and change data and to step and continue the remote
program.
program.
   Whenever GDB is waiting for the remote program, if you type the
   Whenever GDB is waiting for the remote program, if you type the
interrupt character (often `Ctrl-c'), GDB attempts to stop the program.
interrupt character (often `Ctrl-c'), GDB attempts to stop the program.
This may or may not succeed, depending in part on the hardware and the
This may or may not succeed, depending in part on the hardware and the
serial drivers the remote system uses.  If you type the interrupt
serial drivers the remote system uses.  If you type the interrupt
character once again, GDB displays this prompt:
character once again, GDB displays this prompt:
     Interrupted while waiting for the program.
     Interrupted while waiting for the program.
     Give up (and stop debugging it)?  (y or n)
     Give up (and stop debugging it)?  (y or n)
   If you type `y', GDB abandons the remote debugging session.  (If you
   If you type `y', GDB abandons the remote debugging session.  (If you
decide you want to try again later, you can use `target remote' again
decide you want to try again later, you can use `target remote' again
to connect once more.)  If you type `n', GDB goes back to waiting.
to connect once more.)  If you type `n', GDB goes back to waiting.
`detach'
`detach'
     When you have finished debugging the remote program, you can use
     When you have finished debugging the remote program, you can use
     the `detach' command to release it from GDB control.  Detaching
     the `detach' command to release it from GDB control.  Detaching
     from the target normally resumes its execution, but the results
     from the target normally resumes its execution, but the results
     will depend on your particular remote stub.  After the `detach'
     will depend on your particular remote stub.  After the `detach'
     command, GDB is free to connect to another target.
     command, GDB is free to connect to another target.
`disconnect'
`disconnect'
     The `disconnect' command behaves like `detach', except that the
     The `disconnect' command behaves like `detach', except that the
     target is generally not resumed.  It will wait for GDB (this
     target is generally not resumed.  It will wait for GDB (this
     instance or another one) to connect and continue debugging.  After
     instance or another one) to connect and continue debugging.  After
     the `disconnect' command, GDB is again free to connect to another
     the `disconnect' command, GDB is again free to connect to another
     target.
     target.
`monitor CMD'
`monitor CMD'
     This command allows you to send arbitrary commands directly to the
     This command allows you to send arbitrary commands directly to the
     remote monitor.  Since GDB doesn't care about the commands it
     remote monitor.  Since GDB doesn't care about the commands it
     sends like this, this command is the way to extend GDB--you can
     sends like this, this command is the way to extend GDB--you can
     add new commands that only the external monitor will understand
     add new commands that only the external monitor will understand
     and implement.
     and implement.


File: gdb.info,  Node: File Transfer,  Next: Server,  Prev: Connecting,  Up: Remote Debugging
File: gdb.info,  Node: File Transfer,  Next: Server,  Prev: Connecting,  Up: Remote Debugging
17.2 Sending files to a remote system
17.2 Sending files to a remote system
=====================================
=====================================
Some remote targets offer the ability to transfer files over the same
Some remote targets offer the ability to transfer files over the same
connection used to communicate with GDB.  This is convenient for
connection used to communicate with GDB.  This is convenient for
targets accessible through other means, e.g. GNU/Linux systems running
targets accessible through other means, e.g. GNU/Linux systems running
`gdbserver' over a network interface.  For other targets, e.g. embedded
`gdbserver' over a network interface.  For other targets, e.g. embedded
devices with only a single serial port, this may be the only way to
devices with only a single serial port, this may be the only way to
upload or download files.
upload or download files.
   Not all remote targets support these commands.
   Not all remote targets support these commands.
`remote put HOSTFILE TARGETFILE'
`remote put HOSTFILE TARGETFILE'
     Copy file HOSTFILE from the host system (the machine running GDB)
     Copy file HOSTFILE from the host system (the machine running GDB)
     to TARGETFILE on the target system.
     to TARGETFILE on the target system.
`remote get TARGETFILE HOSTFILE'
`remote get TARGETFILE HOSTFILE'
     Copy file TARGETFILE from the target system to HOSTFILE on the
     Copy file TARGETFILE from the target system to HOSTFILE on the
     host system.
     host system.
`remote delete TARGETFILE'
`remote delete TARGETFILE'
     Delete TARGETFILE from the target system.
     Delete TARGETFILE from the target system.


File: gdb.info,  Node: Server,  Next: Remote Configuration,  Prev: File Transfer,  Up: Remote Debugging
File: gdb.info,  Node: Server,  Next: Remote Configuration,  Prev: File Transfer,  Up: Remote Debugging
17.3 Using the `gdbserver' Program
17.3 Using the `gdbserver' Program
==================================
==================================
`gdbserver' is a control program for Unix-like systems, which allows
`gdbserver' is a control program for Unix-like systems, which allows
you to connect your program with a remote GDB via `target remote'--but
you to connect your program with a remote GDB via `target remote'--but
without linking in the usual debugging stub.
without linking in the usual debugging stub.
   `gdbserver' is not a complete replacement for the debugging stubs,
   `gdbserver' is not a complete replacement for the debugging stubs,
because it requires essentially the same operating-system facilities
because it requires essentially the same operating-system facilities
that GDB itself does.  In fact, a system that can run `gdbserver' to
that GDB itself does.  In fact, a system that can run `gdbserver' to
connect to a remote GDB could also run GDB locally!  `gdbserver' is
connect to a remote GDB could also run GDB locally!  `gdbserver' is
sometimes useful nevertheless, because it is a much smaller program
sometimes useful nevertheless, because it is a much smaller program
than GDB itself.  It is also easier to port than all of GDB, so you may
than GDB itself.  It is also easier to port than all of GDB, so you may
be able to get started more quickly on a new system by using
be able to get started more quickly on a new system by using
`gdbserver'.  Finally, if you develop code for real-time systems, you
`gdbserver'.  Finally, if you develop code for real-time systems, you
may find that the tradeoffs involved in real-time operation make it
may find that the tradeoffs involved in real-time operation make it
more convenient to do as much development work as possible on another
more convenient to do as much development work as possible on another
system, for example by cross-compiling.  You can use `gdbserver' to
system, for example by cross-compiling.  You can use `gdbserver' to
make a similar choice for debugging.
make a similar choice for debugging.
   GDB and `gdbserver' communicate via either a serial line or a TCP
   GDB and `gdbserver' communicate via either a serial line or a TCP
connection, using the standard GDB remote serial protocol.
connection, using the standard GDB remote serial protocol.
     _Warning:_ `gdbserver' does not have any built-in security.  Do
     _Warning:_ `gdbserver' does not have any built-in security.  Do
     not run `gdbserver' connected to any public network; a GDB
     not run `gdbserver' connected to any public network; a GDB
     connection to `gdbserver' provides access to the target system
     connection to `gdbserver' provides access to the target system
     with the same privileges as the user running `gdbserver'.
     with the same privileges as the user running `gdbserver'.
17.3.1 Running `gdbserver'
17.3.1 Running `gdbserver'
--------------------------
--------------------------
Run `gdbserver' on the target system.  You need a copy of the program
Run `gdbserver' on the target system.  You need a copy of the program
you want to debug, including any libraries it requires.  `gdbserver'
you want to debug, including any libraries it requires.  `gdbserver'
does not need your program's symbol table, so you can strip the program
does not need your program's symbol table, so you can strip the program
if necessary to save space.  GDB on the host system does all the symbol
if necessary to save space.  GDB on the host system does all the symbol
handling.
handling.
   To use the server, you must tell it how to communicate with GDB; the
   To use the server, you must tell it how to communicate with GDB; the
name of your program; and the arguments for your program.  The usual
name of your program; and the arguments for your program.  The usual
syntax is:
syntax is:
     target> gdbserver COMM PROGRAM [ ARGS ... ]
     target> gdbserver COMM PROGRAM [ ARGS ... ]
   COMM is either a device name (to use a serial line) or a TCP
   COMM is either a device name (to use a serial line) or a TCP
hostname and portnumber.  For example, to debug Emacs with the argument
hostname and portnumber.  For example, to debug Emacs with the argument
`foo.txt' and communicate with GDB over the serial port `/dev/com1':
`foo.txt' and communicate with GDB over the serial port `/dev/com1':
     target> gdbserver /dev/com1 emacs foo.txt
     target> gdbserver /dev/com1 emacs foo.txt
   `gdbserver' waits passively for the host GDB to communicate with it.
   `gdbserver' waits passively for the host GDB to communicate with it.
   To use a TCP connection instead of a serial line:
   To use a TCP connection instead of a serial line:
     target> gdbserver host:2345 emacs foo.txt
     target> gdbserver host:2345 emacs foo.txt
   The only difference from the previous example is the first argument,
   The only difference from the previous example is the first argument,
specifying that you are communicating with the host GDB via TCP.  The
specifying that you are communicating with the host GDB via TCP.  The
`host:2345' argument means that `gdbserver' is to expect a TCP
`host:2345' argument means that `gdbserver' is to expect a TCP
connection from machine `host' to local TCP port 2345.  (Currently, the
connection from machine `host' to local TCP port 2345.  (Currently, the
`host' part is ignored.)  You can choose any number you want for the
`host' part is ignored.)  You can choose any number you want for the
port number as long as it does not conflict with any TCP ports already
port number as long as it does not conflict with any TCP ports already
in use on the target system (for example, `23' is reserved for
in use on the target system (for example, `23' is reserved for
`telnet').(1)  You must use the same port number with the host GDB
`telnet').(1)  You must use the same port number with the host GDB
`target remote' command.
`target remote' command.
17.3.1.1 Attaching to a Running Program
17.3.1.1 Attaching to a Running Program
.......................................
.......................................
On some targets, `gdbserver' can also attach to running programs.  This
On some targets, `gdbserver' can also attach to running programs.  This
is accomplished via the `--attach' argument.  The syntax is:
is accomplished via the `--attach' argument.  The syntax is:
     target> gdbserver --attach COMM PID
     target> gdbserver --attach COMM PID
   PID is the process ID of a currently running process.  It isn't
   PID is the process ID of a currently running process.  It isn't
necessary to point `gdbserver' at a binary for the running process.
necessary to point `gdbserver' at a binary for the running process.
   You can debug processes by name instead of process ID if your target
   You can debug processes by name instead of process ID if your target
has the `pidof' utility:
has the `pidof' utility:
     target> gdbserver --attach COMM `pidof PROGRAM`
     target> gdbserver --attach COMM `pidof PROGRAM`
   In case more than one copy of PROGRAM is running, or PROGRAM has
   In case more than one copy of PROGRAM is running, or PROGRAM has
multiple threads, most versions of `pidof' support the `-s' option to
multiple threads, most versions of `pidof' support the `-s' option to
only return the first process ID.
only return the first process ID.
17.3.1.2 Multi-Process Mode for `gdbserver'
17.3.1.2 Multi-Process Mode for `gdbserver'
...........................................
...........................................
When you connect to `gdbserver' using `target remote', `gdbserver'
When you connect to `gdbserver' using `target remote', `gdbserver'
debugs the specified program only once.  When the program exits, or you
debugs the specified program only once.  When the program exits, or you
detach from it, GDB closes the connection and `gdbserver' exits.
detach from it, GDB closes the connection and `gdbserver' exits.
   If you connect using `target extended-remote', `gdbserver' enters
   If you connect using `target extended-remote', `gdbserver' enters
multi-process mode.  When the debugged program exits, or you detach
multi-process mode.  When the debugged program exits, or you detach
from it, GDB stays connected to `gdbserver' even though no program is
from it, GDB stays connected to `gdbserver' even though no program is
running.  The `run' and `attach' commands instruct `gdbserver' to run
running.  The `run' and `attach' commands instruct `gdbserver' to run
or attach to a new program.  The `run' command uses `set remote
or attach to a new program.  The `run' command uses `set remote
exec-file' (*note set remote exec-file::) to select the program to run.
exec-file' (*note set remote exec-file::) to select the program to run.
Command line arguments are supported, except for wildcard expansion
Command line arguments are supported, except for wildcard expansion
and I/O redirection (*note Arguments::).
and I/O redirection (*note Arguments::).
   To start `gdbserver' without supplying an initial command to run or
   To start `gdbserver' without supplying an initial command to run or
process ID to attach, use the `--multi' command line option.  Then you
process ID to attach, use the `--multi' command line option.  Then you
can connect using `target extended-remote' and start the program you
can connect using `target extended-remote' and start the program you
want to debug.
want to debug.
   `gdbserver' does not automatically exit in multi-process mode.  You
   `gdbserver' does not automatically exit in multi-process mode.  You
can terminate it by using `monitor exit' (*note Monitor Commands for
can terminate it by using `monitor exit' (*note Monitor Commands for
gdbserver::).
gdbserver::).
17.3.1.3 Other Command-Line Arguments for `gdbserver'
17.3.1.3 Other Command-Line Arguments for `gdbserver'
.....................................................
.....................................................
You can include `--debug' on the `gdbserver' command line.  `gdbserver'
You can include `--debug' on the `gdbserver' command line.  `gdbserver'
will display extra status information about the debugging process.
will display extra status information about the debugging process.
This option is intended for `gdbserver' development and for bug reports
This option is intended for `gdbserver' development and for bug reports
to the developers.
to the developers.
17.3.2 Connecting to `gdbserver'
17.3.2 Connecting to `gdbserver'
--------------------------------
--------------------------------
Run GDB on the host system.
Run GDB on the host system.
   First make sure you have the necessary symbol files.  Load symbols
   First make sure you have the necessary symbol files.  Load symbols
for your application using the `file' command before you connect.  Use
for your application using the `file' command before you connect.  Use
`set sysroot' to locate target libraries (unless your GDB was compiled
`set sysroot' to locate target libraries (unless your GDB was compiled
with the correct sysroot using `--with-sysroot').
with the correct sysroot using `--with-sysroot').
   The symbol file and target libraries must exactly match the
   The symbol file and target libraries must exactly match the
executable and libraries on the target, with one exception: the files
executable and libraries on the target, with one exception: the files
on the host system should not be stripped, even if the files on the
on the host system should not be stripped, even if the files on the
target system are.  Mismatched or missing files will lead to confusing
target system are.  Mismatched or missing files will lead to confusing
results during debugging.  On GNU/Linux targets, mismatched or missing
results during debugging.  On GNU/Linux targets, mismatched or missing
files may also prevent `gdbserver' from debugging multi-threaded
files may also prevent `gdbserver' from debugging multi-threaded
programs.
programs.
   Connect to your target (*note Connecting to a Remote Target:
   Connect to your target (*note Connecting to a Remote Target:
Connecting.).  For TCP connections, you must start up `gdbserver' prior
Connecting.).  For TCP connections, you must start up `gdbserver' prior
to using the `target remote' command.  Otherwise you may get an error
to using the `target remote' command.  Otherwise you may get an error
whose text depends on the host system, but which usually looks
whose text depends on the host system, but which usually looks
something like `Connection refused'.  Don't use the `load' command in
something like `Connection refused'.  Don't use the `load' command in
GDB when using `gdbserver', since the program is already on the target.
GDB when using `gdbserver', since the program is already on the target.
17.3.3 Monitor Commands for `gdbserver'
17.3.3 Monitor Commands for `gdbserver'
---------------------------------------
---------------------------------------
During a GDB session using `gdbserver', you can use the `monitor'
During a GDB session using `gdbserver', you can use the `monitor'
command to send special requests to `gdbserver'.  Here are the
command to send special requests to `gdbserver'.  Here are the
available commands.
available commands.
`monitor help'
`monitor help'
     List the available monitor commands.
     List the available monitor commands.
`monitor set debug 0'
`monitor set debug 0'
`monitor set debug 1'
`monitor set debug 1'
     Disable or enable general debugging messages.
     Disable or enable general debugging messages.
`monitor set remote-debug 0'
`monitor set remote-debug 0'
`monitor set remote-debug 1'
`monitor set remote-debug 1'
     Disable or enable specific debugging messages associated with the
     Disable or enable specific debugging messages associated with the
     remote protocol (*note Remote Protocol::).
     remote protocol (*note Remote Protocol::).
`monitor exit'
`monitor exit'
     Tell gdbserver to exit immediately.  This command should be
     Tell gdbserver to exit immediately.  This command should be
     followed by `disconnect' to close the debugging session.
     followed by `disconnect' to close the debugging session.
     `gdbserver' will detach from any attached processes and kill any
     `gdbserver' will detach from any attached processes and kill any
     processes it created.  Use `monitor exit' to terminate `gdbserver'
     processes it created.  Use `monitor exit' to terminate `gdbserver'
     at the end of a multi-process mode debug session.
     at the end of a multi-process mode debug session.
   ---------- Footnotes ----------
   ---------- Footnotes ----------
   (1) If you choose a port number that conflicts with another service,
   (1) If you choose a port number that conflicts with another service,
`gdbserver' prints an error message and exits.
`gdbserver' prints an error message and exits.


File: gdb.info,  Node: Remote Configuration,  Next: Remote Stub,  Prev: Server,  Up: Remote Debugging
File: gdb.info,  Node: Remote Configuration,  Next: Remote Stub,  Prev: Server,  Up: Remote Debugging
17.4 Remote Configuration
17.4 Remote Configuration
=========================
=========================
This section documents the configuration options available when
This section documents the configuration options available when
debugging remote programs.  For the options related to the File I/O
debugging remote programs.  For the options related to the File I/O
extensions of the remote protocol, see *Note system-call-allowed:
extensions of the remote protocol, see *Note system-call-allowed:
system.
system.
`set remoteaddresssize BITS'
`set remoteaddresssize BITS'
     Set the maximum size of address in a memory packet to the specified
     Set the maximum size of address in a memory packet to the specified
     number of bits.  GDB will mask off the address bits above that
     number of bits.  GDB will mask off the address bits above that
     number, when it passes addresses to the remote target.  The
     number, when it passes addresses to the remote target.  The
     default value is the number of bits in the target's address.
     default value is the number of bits in the target's address.
`show remoteaddresssize'
`show remoteaddresssize'
     Show the current value of remote address size in bits.
     Show the current value of remote address size in bits.
`set remotebaud N'
`set remotebaud N'
     Set the baud rate for the remote serial I/O to N baud.  The value
     Set the baud rate for the remote serial I/O to N baud.  The value
     is used to set the speed of the serial port used for debugging
     is used to set the speed of the serial port used for debugging
     remote targets.
     remote targets.
`show remotebaud'
`show remotebaud'
     Show the current speed of the remote connection.
     Show the current speed of the remote connection.
`set remotebreak'
`set remotebreak'
     If set to on, GDB sends a `BREAK' signal to the remote when you
     If set to on, GDB sends a `BREAK' signal to the remote when you
     type `Ctrl-c' to interrupt the program running on the remote.  If
     type `Ctrl-c' to interrupt the program running on the remote.  If
     set to off, GDB sends the `Ctrl-C' character instead.  The default
     set to off, GDB sends the `Ctrl-C' character instead.  The default
     is off, since most remote systems expect to see `Ctrl-C' as the
     is off, since most remote systems expect to see `Ctrl-C' as the
     interrupt signal.
     interrupt signal.
`show remotebreak'
`show remotebreak'
     Show whether GDB sends `BREAK' or `Ctrl-C' to interrupt the remote
     Show whether GDB sends `BREAK' or `Ctrl-C' to interrupt the remote
     program.
     program.
`set remoteflow on'
`set remoteflow on'
`set remoteflow off'
`set remoteflow off'
     Enable or disable hardware flow control (`RTS'/`CTS') on the
     Enable or disable hardware flow control (`RTS'/`CTS') on the
     serial port used to communicate to the remote target.
     serial port used to communicate to the remote target.
`show remoteflow'
`show remoteflow'
     Show the current setting of hardware flow control.
     Show the current setting of hardware flow control.
`set remotelogbase BASE'
`set remotelogbase BASE'
     Set the base (a.k.a. radix) of logging serial protocol
     Set the base (a.k.a. radix) of logging serial protocol
     communications to BASE.  Supported values of BASE are: `ascii',
     communications to BASE.  Supported values of BASE are: `ascii',
     `octal', and `hex'.  The default is `ascii'.
     `octal', and `hex'.  The default is `ascii'.
`show remotelogbase'
`show remotelogbase'
     Show the current setting of the radix for logging remote serial
     Show the current setting of the radix for logging remote serial
     protocol.
     protocol.
`set remotelogfile FILE'
`set remotelogfile FILE'
     Record remote serial communications on the named FILE.  The
     Record remote serial communications on the named FILE.  The
     default is not to record at all.
     default is not to record at all.
`show remotelogfile.'
`show remotelogfile.'
     Show the current setting  of the file name on which to record the
     Show the current setting  of the file name on which to record the
     serial communications.
     serial communications.
`set remotetimeout NUM'
`set remotetimeout NUM'
     Set the timeout limit to wait for the remote target to respond to
     Set the timeout limit to wait for the remote target to respond to
     NUM seconds.  The default is 2 seconds.
     NUM seconds.  The default is 2 seconds.
`show remotetimeout'
`show remotetimeout'
     Show the current number of seconds to wait for the remote target
     Show the current number of seconds to wait for the remote target
     responses.
     responses.
`set remote hardware-watchpoint-limit LIMIT'
`set remote hardware-watchpoint-limit LIMIT'
`set remote hardware-breakpoint-limit LIMIT'
`set remote hardware-breakpoint-limit LIMIT'
     Restrict GDB to using LIMIT remote hardware breakpoint or
     Restrict GDB to using LIMIT remote hardware breakpoint or
     watchpoints.  A limit of -1, the default, is treated as unlimited.
     watchpoints.  A limit of -1, the default, is treated as unlimited.
`set remote exec-file FILENAME'
`set remote exec-file FILENAME'
`show remote exec-file'
`show remote exec-file'
     Select the file used for `run' with `target extended-remote'.
     Select the file used for `run' with `target extended-remote'.
     This should be set to a filename valid on the target system.  If
     This should be set to a filename valid on the target system.  If
     it is not set, the target will use a default filename (e.g. the
     it is not set, the target will use a default filename (e.g. the
     last program run).
     last program run).
   The GDB remote protocol autodetects the packets supported by your
   The GDB remote protocol autodetects the packets supported by your
debugging stub.  If you need to override the autodetection, you can use
debugging stub.  If you need to override the autodetection, you can use
these commands to enable or disable individual packets.  Each packet
these commands to enable or disable individual packets.  Each packet
can be set to `on' (the remote target supports this packet), `off' (the
can be set to `on' (the remote target supports this packet), `off' (the
remote target does not support this packet), or `auto' (detect remote
remote target does not support this packet), or `auto' (detect remote
target support for this packet).  They all default to `auto'.  For more
target support for this packet).  They all default to `auto'.  For more
information about each packet, see *Note Remote Protocol::.
information about each packet, see *Note Remote Protocol::.
   During normal use, you should not have to use any of these commands.
   During normal use, you should not have to use any of these commands.
If you do, that may be a bug in your remote debugging stub, or a bug in
If you do, that may be a bug in your remote debugging stub, or a bug in
GDB.  You may want to report the problem to the GDB developers.
GDB.  You may want to report the problem to the GDB developers.
   For each packet NAME, the command to enable or disable the packet is
   For each packet NAME, the command to enable or disable the packet is
`set remote NAME-packet'.  The available settings are:
`set remote NAME-packet'.  The available settings are:
Command Name         Remote Packet           Related Features
Command Name         Remote Packet           Related Features
`fetch-register'     `p'                     `info registers'
`fetch-register'     `p'                     `info registers'
`set-register'       `P'                     `set'
`set-register'       `P'                     `set'
`binary-download'    `X'                     `load', `set'
`binary-download'    `X'                     `load', `set'
`read-aux-vector'    `qXfer:auxv:read'       `info auxv'
`read-aux-vector'    `qXfer:auxv:read'       `info auxv'
`symbol-lookup'      `qSymbol'               Detecting
`symbol-lookup'      `qSymbol'               Detecting
                                             multiple threads
                                             multiple threads
`attach'             `vAttach'               `attach'
`attach'             `vAttach'               `attach'
`verbose-resume'     `vCont'                 Stepping or
`verbose-resume'     `vCont'                 Stepping or
                                             resuming multiple
                                             resuming multiple
                                             threads
                                             threads
`run'                `vRun'                  `run'
`run'                `vRun'                  `run'
`software-breakpoint'`Z0'                    `break'
`software-breakpoint'`Z0'                    `break'
`hardware-breakpoint'`Z1'                    `hbreak'
`hardware-breakpoint'`Z1'                    `hbreak'
`write-watchpoint'   `Z2'                    `watch'
`write-watchpoint'   `Z2'                    `watch'
`read-watchpoint'    `Z3'                    `rwatch'
`read-watchpoint'    `Z3'                    `rwatch'
`access-watchpoint'  `Z4'                    `awatch'
`access-watchpoint'  `Z4'                    `awatch'
`target-features'    `qXfer:features:read'   `set architecture'
`target-features'    `qXfer:features:read'   `set architecture'
`library-info'       `qXfer:libraries:read'  `info
`library-info'       `qXfer:libraries:read'  `info
                                             sharedlibrary'
                                             sharedlibrary'
`memory-map'         `qXfer:memory-map:read' `info mem'
`memory-map'         `qXfer:memory-map:read' `info mem'
`read-spu-object'    `qXfer:spu:read'        `info spu'
`read-spu-object'    `qXfer:spu:read'        `info spu'
`write-spu-object'   `qXfer:spu:write'       `info spu'
`write-spu-object'   `qXfer:spu:write'       `info spu'
`get-thread-local-   `qGetTLSAddr'           Displaying
`get-thread-local-   `qGetTLSAddr'           Displaying
storage-address'                             `__thread'
storage-address'                             `__thread'
                                             variables
                                             variables
`supported-packets'  `qSupported'            Remote
`supported-packets'  `qSupported'            Remote
                                             communications
                                             communications
                                             parameters
                                             parameters
`pass-signals'       `QPassSignals'          `handle SIGNAL'
`pass-signals'       `QPassSignals'          `handle SIGNAL'
`hostio-close-packet'`vFile:close'           `remote get',
`hostio-close-packet'`vFile:close'           `remote get',
                                             `remote put'
                                             `remote put'
`hostio-open-packet' `vFile:open'            `remote get',
`hostio-open-packet' `vFile:open'            `remote get',
                                             `remote put'
                                             `remote put'
`hostio-pread-packet'`vFile:pread'           `remote get',
`hostio-pread-packet'`vFile:pread'           `remote get',
                                             `remote put'
                                             `remote put'
`hostio-pwrite-packet'`vFile:pwrite'          `remote get',
`hostio-pwrite-packet'`vFile:pwrite'          `remote get',
                                             `remote put'
                                             `remote put'
`hostio-unlink-packet'`vFile:unlink'          `remote delete'
`hostio-unlink-packet'`vFile:unlink'          `remote delete'


File: gdb.info,  Node: Remote Stub,  Prev: Remote Configuration,  Up: Remote Debugging
File: gdb.info,  Node: Remote Stub,  Prev: Remote Configuration,  Up: Remote Debugging
17.5 Implementing a Remote Stub
17.5 Implementing a Remote Stub
===============================
===============================
The stub files provided with GDB implement the target side of the
The stub files provided with GDB implement the target side of the
communication protocol, and the GDB side is implemented in the GDB
communication protocol, and the GDB side is implemented in the GDB
source file `remote.c'.  Normally, you can simply allow these
source file `remote.c'.  Normally, you can simply allow these
subroutines to communicate, and ignore the details.  (If you're
subroutines to communicate, and ignore the details.  (If you're
implementing your own stub file, you can still ignore the details: start
implementing your own stub file, you can still ignore the details: start
with one of the existing stub files.  `sparc-stub.c' is the best
with one of the existing stub files.  `sparc-stub.c' is the best
organized, and therefore the easiest to read.)
organized, and therefore the easiest to read.)
   To debug a program running on another machine (the debugging
   To debug a program running on another machine (the debugging
"target" machine), you must first arrange for all the usual
"target" machine), you must first arrange for all the usual
prerequisites for the program to run by itself.  For example, for a C
prerequisites for the program to run by itself.  For example, for a C
program, you need:
program, you need:
  1. A startup routine to set up the C runtime environment; these
  1. A startup routine to set up the C runtime environment; these
     usually have a name like `crt0'.  The startup routine may be
     usually have a name like `crt0'.  The startup routine may be
     supplied by your hardware supplier, or you may have to write your
     supplied by your hardware supplier, or you may have to write your
     own.
     own.
  2. A C subroutine library to support your program's subroutine calls,
  2. A C subroutine library to support your program's subroutine calls,
     notably managing input and output.
     notably managing input and output.
  3. A way of getting your program to the other machine--for example, a
  3. A way of getting your program to the other machine--for example, a
     download program.  These are often supplied by the hardware
     download program.  These are often supplied by the hardware
     manufacturer, but you may have to write your own from hardware
     manufacturer, but you may have to write your own from hardware
     documentation.
     documentation.
   The next step is to arrange for your program to use a serial port to
   The next step is to arrange for your program to use a serial port to
communicate with the machine where GDB is running (the "host" machine).
communicate with the machine where GDB is running (the "host" machine).
In general terms, the scheme looks like this:
In general terms, the scheme looks like this:
_On the host,_
_On the host,_
     GDB already understands how to use this protocol; when everything
     GDB already understands how to use this protocol; when everything
     else is set up, you can simply use the `target remote' command
     else is set up, you can simply use the `target remote' command
     (*note Specifying a Debugging Target: Targets.).
     (*note Specifying a Debugging Target: Targets.).
_On the target,_
_On the target,_
     you must link with your program a few special-purpose subroutines
     you must link with your program a few special-purpose subroutines
     that implement the GDB remote serial protocol.  The file
     that implement the GDB remote serial protocol.  The file
     containing these subroutines is called  a "debugging stub".
     containing these subroutines is called  a "debugging stub".
     On certain remote targets, you can use an auxiliary program
     On certain remote targets, you can use an auxiliary program
     `gdbserver' instead of linking a stub into your program.  *Note
     `gdbserver' instead of linking a stub into your program.  *Note
     Using the `gdbserver' Program: Server, for details.
     Using the `gdbserver' Program: Server, for details.
   The debugging stub is specific to the architecture of the remote
   The debugging stub is specific to the architecture of the remote
machine; for example, use `sparc-stub.c' to debug programs on SPARC
machine; for example, use `sparc-stub.c' to debug programs on SPARC
boards.
boards.
   These working remote stubs are distributed with GDB:
   These working remote stubs are distributed with GDB:
`i386-stub.c'
`i386-stub.c'
     For Intel 386 and compatible architectures.
     For Intel 386 and compatible architectures.
`m68k-stub.c'
`m68k-stub.c'
     For Motorola 680x0 architectures.
     For Motorola 680x0 architectures.
`sh-stub.c'
`sh-stub.c'
     For Renesas SH architectures.
     For Renesas SH architectures.
`sparc-stub.c'
`sparc-stub.c'
     For SPARC architectures.
     For SPARC architectures.
`sparcl-stub.c'
`sparcl-stub.c'
     For Fujitsu SPARCLITE architectures.
     For Fujitsu SPARCLITE architectures.
   The `README' file in the GDB distribution may list other recently
   The `README' file in the GDB distribution may list other recently
added stubs.
added stubs.
* Menu:
* Menu:
* Stub Contents::       What the stub can do for you
* Stub Contents::       What the stub can do for you
* Bootstrapping::       What you must do for the stub
* Bootstrapping::       What you must do for the stub
* Debug Session::       Putting it all together
* Debug Session::       Putting it all together


File: gdb.info,  Node: Stub Contents,  Next: Bootstrapping,  Up: Remote Stub
File: gdb.info,  Node: Stub Contents,  Next: Bootstrapping,  Up: Remote Stub
17.5.1 What the Stub Can Do for You
17.5.1 What the Stub Can Do for You
-----------------------------------
-----------------------------------
The debugging stub for your architecture supplies these three
The debugging stub for your architecture supplies these three
subroutines:
subroutines:
`set_debug_traps'
`set_debug_traps'
     This routine arranges for `handle_exception' to run when your
     This routine arranges for `handle_exception' to run when your
     program stops.  You must call this subroutine explicitly near the
     program stops.  You must call this subroutine explicitly near the
     beginning of your program.
     beginning of your program.
`handle_exception'
`handle_exception'
     This is the central workhorse, but your program never calls it
     This is the central workhorse, but your program never calls it
     explicitly--the setup code arranges for `handle_exception' to run
     explicitly--the setup code arranges for `handle_exception' to run
     when a trap is triggered.
     when a trap is triggered.
     `handle_exception' takes control when your program stops during
     `handle_exception' takes control when your program stops during
     execution (for example, on a breakpoint), and mediates
     execution (for example, on a breakpoint), and mediates
     communications with GDB on the host machine.  This is where the
     communications with GDB on the host machine.  This is where the
     communications protocol is implemented; `handle_exception' acts as
     communications protocol is implemented; `handle_exception' acts as
     the GDB representative on the target machine.  It begins by
     the GDB representative on the target machine.  It begins by
     sending summary information on the state of your program, then
     sending summary information on the state of your program, then
     continues to execute, retrieving and transmitting any information
     continues to execute, retrieving and transmitting any information
     GDB needs, until you execute a GDB command that makes your program
     GDB needs, until you execute a GDB command that makes your program
     resume; at that point, `handle_exception' returns control to your
     resume; at that point, `handle_exception' returns control to your
     own code on the target machine.
     own code on the target machine.
`breakpoint'
`breakpoint'
     Use this auxiliary subroutine to make your program contain a
     Use this auxiliary subroutine to make your program contain a
     breakpoint.  Depending on the particular situation, this may be
     breakpoint.  Depending on the particular situation, this may be
     the only way for GDB to get control.  For instance, if your target
     the only way for GDB to get control.  For instance, if your target
     machine has some sort of interrupt button, you won't need to call
     machine has some sort of interrupt button, you won't need to call
     this; pressing the interrupt button transfers control to
     this; pressing the interrupt button transfers control to
     `handle_exception'--in effect, to GDB.  On some machines, simply
     `handle_exception'--in effect, to GDB.  On some machines, simply
     receiving characters on the serial port may also trigger a trap;
     receiving characters on the serial port may also trigger a trap;
     again, in that situation, you don't need to call `breakpoint' from
     again, in that situation, you don't need to call `breakpoint' from
     your own program--simply running `target remote' from the host GDB
     your own program--simply running `target remote' from the host GDB
     session gets control.
     session gets control.
     Call `breakpoint' if none of these is true, or if you simply want
     Call `breakpoint' if none of these is true, or if you simply want
     to make certain your program stops at a predetermined point for the
     to make certain your program stops at a predetermined point for the
     start of your debugging session.
     start of your debugging session.


File: gdb.info,  Node: Bootstrapping,  Next: Debug Session,  Prev: Stub Contents,  Up: Remote Stub
File: gdb.info,  Node: Bootstrapping,  Next: Debug Session,  Prev: Stub Contents,  Up: Remote Stub
17.5.2 What You Must Do for the Stub
17.5.2 What You Must Do for the Stub
------------------------------------
------------------------------------
The debugging stubs that come with GDB are set up for a particular chip
The debugging stubs that come with GDB are set up for a particular chip
architecture, but they have no information about the rest of your
architecture, but they have no information about the rest of your
debugging target machine.
debugging target machine.
   First of all you need to tell the stub how to communicate with the
   First of all you need to tell the stub how to communicate with the
serial port.
serial port.
`int getDebugChar()'
`int getDebugChar()'
     Write this subroutine to read a single character from the serial
     Write this subroutine to read a single character from the serial
     port.  It may be identical to `getchar' for your target system; a
     port.  It may be identical to `getchar' for your target system; a
     different name is used to allow you to distinguish the two if you
     different name is used to allow you to distinguish the two if you
     wish.
     wish.
`void putDebugChar(int)'
`void putDebugChar(int)'
     Write this subroutine to write a single character to the serial
     Write this subroutine to write a single character to the serial
     port.  It may be identical to `putchar' for your target system; a
     port.  It may be identical to `putchar' for your target system; a
     different name is used to allow you to distinguish the two if you
     different name is used to allow you to distinguish the two if you
     wish.
     wish.
   If you want GDB to be able to stop your program while it is running,
   If you want GDB to be able to stop your program while it is running,
you need to use an interrupt-driven serial driver, and arrange for it
you need to use an interrupt-driven serial driver, and arrange for it
to stop when it receives a `^C' (`\003', the control-C character).
to stop when it receives a `^C' (`\003', the control-C character).
That is the character which GDB uses to tell the remote system to stop.
That is the character which GDB uses to tell the remote system to stop.
   Getting the debugging target to return the proper status to GDB
   Getting the debugging target to return the proper status to GDB
probably requires changes to the standard stub; one quick and dirty way
probably requires changes to the standard stub; one quick and dirty way
is to just execute a breakpoint instruction (the "dirty" part is that
is to just execute a breakpoint instruction (the "dirty" part is that
GDB reports a `SIGTRAP' instead of a `SIGINT').
GDB reports a `SIGTRAP' instead of a `SIGINT').
   Other routines you need to supply are:
   Other routines you need to supply are:
`void exceptionHandler (int EXCEPTION_NUMBER, void *EXCEPTION_ADDRESS)'
`void exceptionHandler (int EXCEPTION_NUMBER, void *EXCEPTION_ADDRESS)'
     Write this function to install EXCEPTION_ADDRESS in the exception
     Write this function to install EXCEPTION_ADDRESS in the exception
     handling tables.  You need to do this because the stub does not
     handling tables.  You need to do this because the stub does not
     have any way of knowing what the exception handling tables on your
     have any way of knowing what the exception handling tables on your
     target system are like (for example, the processor's table might
     target system are like (for example, the processor's table might
     be in ROM, containing entries which point to a table in RAM).
     be in ROM, containing entries which point to a table in RAM).
     EXCEPTION_NUMBER is the exception number which should be changed;
     EXCEPTION_NUMBER is the exception number which should be changed;
     its meaning is architecture-dependent (for example, different
     its meaning is architecture-dependent (for example, different
     numbers might represent divide by zero, misaligned access, etc).
     numbers might represent divide by zero, misaligned access, etc).
     When this exception occurs, control should be transferred directly
     When this exception occurs, control should be transferred directly
     to EXCEPTION_ADDRESS, and the processor state (stack, registers,
     to EXCEPTION_ADDRESS, and the processor state (stack, registers,
     and so on) should be just as it is when a processor exception
     and so on) should be just as it is when a processor exception
     occurs.  So if you want to use a jump instruction to reach
     occurs.  So if you want to use a jump instruction to reach
     EXCEPTION_ADDRESS, it should be a simple jump, not a jump to
     EXCEPTION_ADDRESS, it should be a simple jump, not a jump to
     subroutine.
     subroutine.
     For the 386, EXCEPTION_ADDRESS should be installed as an interrupt
     For the 386, EXCEPTION_ADDRESS should be installed as an interrupt
     gate so that interrupts are masked while the handler runs.  The
     gate so that interrupts are masked while the handler runs.  The
     gate should be at privilege level 0 (the most privileged level).
     gate should be at privilege level 0 (the most privileged level).
     The SPARC and 68k stubs are able to mask interrupts themselves
     The SPARC and 68k stubs are able to mask interrupts themselves
     without help from `exceptionHandler'.
     without help from `exceptionHandler'.
`void flush_i_cache()'
`void flush_i_cache()'
     On SPARC and SPARCLITE only, write this subroutine to flush the
     On SPARC and SPARCLITE only, write this subroutine to flush the
     instruction cache, if any, on your target machine.  If there is no
     instruction cache, if any, on your target machine.  If there is no
     instruction cache, this subroutine may be a no-op.
     instruction cache, this subroutine may be a no-op.
     On target machines that have instruction caches, GDB requires this
     On target machines that have instruction caches, GDB requires this
     function to make certain that the state of your program is stable.
     function to make certain that the state of your program is stable.
You must also make sure this library routine is available:
You must also make sure this library routine is available:
`void *memset(void *, int, int)'
`void *memset(void *, int, int)'
     This is the standard library function `memset' that sets an area of
     This is the standard library function `memset' that sets an area of
     memory to a known value.  If you have one of the free versions of
     memory to a known value.  If you have one of the free versions of
     `libc.a', `memset' can be found there; otherwise, you must either
     `libc.a', `memset' can be found there; otherwise, you must either
     obtain it from your hardware manufacturer, or write your own.
     obtain it from your hardware manufacturer, or write your own.
   If you do not use the GNU C compiler, you may need other standard
   If you do not use the GNU C compiler, you may need other standard
library subroutines as well; this varies from one stub to another, but
library subroutines as well; this varies from one stub to another, but
in general the stubs are likely to use any of the common library
in general the stubs are likely to use any of the common library
subroutines which `GCC' generates as inline code.
subroutines which `GCC' generates as inline code.


File: gdb.info,  Node: Debug Session,  Prev: Bootstrapping,  Up: Remote Stub
File: gdb.info,  Node: Debug Session,  Prev: Bootstrapping,  Up: Remote Stub
17.5.3 Putting it All Together
17.5.3 Putting it All Together
------------------------------
------------------------------
In summary, when your program is ready to debug, you must follow these
In summary, when your program is ready to debug, you must follow these
steps.
steps.
  1. Make sure you have defined the supporting low-level routines
  1. Make sure you have defined the supporting low-level routines
     (*note What You Must Do for the Stub: Bootstrapping.):
     (*note What You Must Do for the Stub: Bootstrapping.):
          `getDebugChar', `putDebugChar',
          `getDebugChar', `putDebugChar',
          `flush_i_cache', `memset', `exceptionHandler'.
          `flush_i_cache', `memset', `exceptionHandler'.
  2. Insert these lines near the top of your program:
  2. Insert these lines near the top of your program:
          set_debug_traps();
          set_debug_traps();
          breakpoint();
          breakpoint();
  3. For the 680x0 stub only, you need to provide a variable called
  3. For the 680x0 stub only, you need to provide a variable called
     `exceptionHook'.  Normally you just use:
     `exceptionHook'.  Normally you just use:
          void (*exceptionHook)() = 0;
          void (*exceptionHook)() = 0;
     but if before calling `set_debug_traps', you set it to point to a
     but if before calling `set_debug_traps', you set it to point to a
     function in your program, that function is called when `GDB'
     function in your program, that function is called when `GDB'
     continues after stopping on a trap (for example, bus error).  The
     continues after stopping on a trap (for example, bus error).  The
     function indicated by `exceptionHook' is called with one
     function indicated by `exceptionHook' is called with one
     parameter: an `int' which is the exception number.
     parameter: an `int' which is the exception number.
  4. Compile and link together: your program, the GDB debugging stub for
  4. Compile and link together: your program, the GDB debugging stub for
     your target architecture, and the supporting subroutines.
     your target architecture, and the supporting subroutines.
  5. Make sure you have a serial connection between your target machine
  5. Make sure you have a serial connection between your target machine
     and the GDB host, and identify the serial port on the host.
     and the GDB host, and identify the serial port on the host.
  6. Download your program to your target machine (or get it there by
  6. Download your program to your target machine (or get it there by
     whatever means the manufacturer provides), and start it.
     whatever means the manufacturer provides), and start it.
  7. Start GDB on the host, and connect to the target (*note Connecting
  7. Start GDB on the host, and connect to the target (*note Connecting
     to a Remote Target: Connecting.).
     to a Remote Target: Connecting.).


File: gdb.info,  Node: Configurations,  Next: Controlling GDB,  Prev: Remote Debugging,  Up: Top
File: gdb.info,  Node: Configurations,  Next: Controlling GDB,  Prev: Remote Debugging,  Up: Top
18 Configuration-Specific Information
18 Configuration-Specific Information
*************************************
*************************************
While nearly all GDB commands are available for all native and cross
While nearly all GDB commands are available for all native and cross
versions of the debugger, there are some exceptions.  This chapter
versions of the debugger, there are some exceptions.  This chapter
describes things that are only available in certain configurations.
describes things that are only available in certain configurations.
   There are three major categories of configurations: native
   There are three major categories of configurations: native
configurations, where the host and target are the same, embedded
configurations, where the host and target are the same, embedded
operating system configurations, which are usually the same for several
operating system configurations, which are usually the same for several
different processor architectures, and bare embedded processors, which
different processor architectures, and bare embedded processors, which
are quite different from each other.
are quite different from each other.
* Menu:
* Menu:
* Native::
* Native::
* Embedded OS::
* Embedded OS::
* Embedded Processors::
* Embedded Processors::
* Architectures::
* Architectures::


File: gdb.info,  Node: Native,  Next: Embedded OS,  Up: Configurations
File: gdb.info,  Node: Native,  Next: Embedded OS,  Up: Configurations
18.1 Native
18.1 Native
===========
===========
This section describes details specific to particular native
This section describes details specific to particular native
configurations.
configurations.
* Menu:
* Menu:
* HP-UX::                       HP-UX
* HP-UX::                       HP-UX
* BSD libkvm Interface::        Debugging BSD kernel memory images
* BSD libkvm Interface::        Debugging BSD kernel memory images
* SVR4 Process Information::    SVR4 process information
* SVR4 Process Information::    SVR4 process information
* DJGPP Native::                Features specific to the DJGPP port
* DJGPP Native::                Features specific to the DJGPP port
* Cygwin Native::               Features specific to the Cygwin port
* Cygwin Native::               Features specific to the Cygwin port
* Hurd Native::                 Features specific to GNU Hurd
* Hurd Native::                 Features specific to GNU Hurd
* Neutrino::                    Features specific to QNX Neutrino
* Neutrino::                    Features specific to QNX Neutrino


File: gdb.info,  Node: HP-UX,  Next: BSD libkvm Interface,  Up: Native
File: gdb.info,  Node: HP-UX,  Next: BSD libkvm Interface,  Up: Native
18.1.1 HP-UX
18.1.1 HP-UX
------------
------------
On HP-UX systems, if you refer to a function or variable name that
On HP-UX systems, if you refer to a function or variable name that
begins with a dollar sign, GDB searches for a user or system name
begins with a dollar sign, GDB searches for a user or system name
first, before it searches for a convenience variable.
first, before it searches for a convenience variable.


File: gdb.info,  Node: BSD libkvm Interface,  Next: SVR4 Process Information,  Prev: HP-UX,  Up: Native
File: gdb.info,  Node: BSD libkvm Interface,  Next: SVR4 Process Information,  Prev: HP-UX,  Up: Native
18.1.2 BSD libkvm Interface
18.1.2 BSD libkvm Interface
---------------------------
---------------------------
BSD-derived systems (FreeBSD/NetBSD/OpenBSD) have a kernel memory
BSD-derived systems (FreeBSD/NetBSD/OpenBSD) have a kernel memory
interface that provides a uniform interface for accessing kernel virtual
interface that provides a uniform interface for accessing kernel virtual
memory images, including live systems and crash dumps.  GDB uses this
memory images, including live systems and crash dumps.  GDB uses this
interface to allow you to debug live kernels and kernel crash dumps on
interface to allow you to debug live kernels and kernel crash dumps on
many native BSD configurations.  This is implemented as a special `kvm'
many native BSD configurations.  This is implemented as a special `kvm'
debugging target.  For debugging a live system, load the currently
debugging target.  For debugging a live system, load the currently
running kernel into GDB and connect to the `kvm' target:
running kernel into GDB and connect to the `kvm' target:
     (gdb) target kvm
     (gdb) target kvm
   For debugging crash dumps, provide the file name of the crash dump
   For debugging crash dumps, provide the file name of the crash dump
as an argument:
as an argument:
     (gdb) target kvm /var/crash/bsd.0
     (gdb) target kvm /var/crash/bsd.0
   Once connected to the `kvm' target, the following commands are
   Once connected to the `kvm' target, the following commands are
available:
available:
`kvm pcb'
`kvm pcb'
     Set current context from the "Process Control Block" (PCB) address.
     Set current context from the "Process Control Block" (PCB) address.
`kvm proc'
`kvm proc'
     Set current context from proc address.  This command isn't
     Set current context from proc address.  This command isn't
     available on modern FreeBSD systems.
     available on modern FreeBSD systems.


File: gdb.info,  Node: SVR4 Process Information,  Next: DJGPP Native,  Prev: BSD libkvm Interface,  Up: Native
File: gdb.info,  Node: SVR4 Process Information,  Next: DJGPP Native,  Prev: BSD libkvm Interface,  Up: Native
18.1.3 SVR4 Process Information
18.1.3 SVR4 Process Information
-------------------------------
-------------------------------
Many versions of SVR4 and compatible systems provide a facility called
Many versions of SVR4 and compatible systems provide a facility called
`/proc' that can be used to examine the image of a running process
`/proc' that can be used to examine the image of a running process
using file-system subroutines.  If GDB is configured for an operating
using file-system subroutines.  If GDB is configured for an operating
system with this facility, the command `info proc' is available to
system with this facility, the command `info proc' is available to
report information about the process running your program, or about any
report information about the process running your program, or about any
process running on your system.  `info proc' works only on SVR4 systems
process running on your system.  `info proc' works only on SVR4 systems
that include the `procfs' code.  This includes, as of this writing,
that include the `procfs' code.  This includes, as of this writing,
GNU/Linux, OSF/1 (Digital Unix), Solaris, Irix, and Unixware, but not
GNU/Linux, OSF/1 (Digital Unix), Solaris, Irix, and Unixware, but not
HP-UX, for example.
HP-UX, for example.
`info proc'
`info proc'
`info proc PROCESS-ID'
`info proc PROCESS-ID'
     Summarize available information about any running process.  If a
     Summarize available information about any running process.  If a
     process ID is specified by PROCESS-ID, display information about
     process ID is specified by PROCESS-ID, display information about
     that process; otherwise display information about the program being
     that process; otherwise display information about the program being
     debugged.  The summary includes the debugged process ID, the
     debugged.  The summary includes the debugged process ID, the
     command line used to invoke it, its current working directory, and
     command line used to invoke it, its current working directory, and
     its executable file's absolute file name.
     its executable file's absolute file name.
     On some systems, PROCESS-ID can be of the form `[PID]/TID' which
     On some systems, PROCESS-ID can be of the form `[PID]/TID' which
     specifies a certain thread ID within a process.  If the optional
     specifies a certain thread ID within a process.  If the optional
     PID part is missing, it means a thread from the process being
     PID part is missing, it means a thread from the process being
     debugged (the leading `/' still needs to be present, or else GDB
     debugged (the leading `/' still needs to be present, or else GDB
     will interpret the number as a process ID rather than a thread ID).
     will interpret the number as a process ID rather than a thread ID).
`info proc mappings'
`info proc mappings'
     Report the memory address space ranges accessible in the program,
     Report the memory address space ranges accessible in the program,
     with information on whether the process has read, write, or
     with information on whether the process has read, write, or
     execute access rights to each range.  On GNU/Linux systems, each
     execute access rights to each range.  On GNU/Linux systems, each
     memory range includes the object file which is mapped to that
     memory range includes the object file which is mapped to that
     range, instead of the memory access rights to that range.
     range, instead of the memory access rights to that range.
`info proc stat'
`info proc stat'
`info proc status'
`info proc status'
     These subcommands are specific to GNU/Linux systems.  They show
     These subcommands are specific to GNU/Linux systems.  They show
     the process-related information, including the user ID and group
     the process-related information, including the user ID and group
     ID; how many threads are there in the process; its virtual memory
     ID; how many threads are there in the process; its virtual memory
     usage; the signals that are pending, blocked, and ignored; its
     usage; the signals that are pending, blocked, and ignored; its
     TTY; its consumption of system and user time; its stack size; its
     TTY; its consumption of system and user time; its stack size; its
     `nice' value; etc.  For more information, see the `proc' man page
     `nice' value; etc.  For more information, see the `proc' man page
     (type `man 5 proc' from your shell prompt).
     (type `man 5 proc' from your shell prompt).
`info proc all'
`info proc all'
     Show all the information about the process described under all of
     Show all the information about the process described under all of
     the above `info proc' subcommands.
     the above `info proc' subcommands.
`set procfs-trace'
`set procfs-trace'
     This command enables and disables tracing of `procfs' API calls.
     This command enables and disables tracing of `procfs' API calls.
`show procfs-trace'
`show procfs-trace'
     Show the current state of `procfs' API call tracing.
     Show the current state of `procfs' API call tracing.
`set procfs-file FILE'
`set procfs-file FILE'
     Tell GDB to write `procfs' API trace to the named FILE.  GDB
     Tell GDB to write `procfs' API trace to the named FILE.  GDB
     appends the trace info to the previous contents of the file.  The
     appends the trace info to the previous contents of the file.  The
     default is to display the trace on the standard output.
     default is to display the trace on the standard output.
`show procfs-file'
`show procfs-file'
     Show the file to which `procfs' API trace is written.
     Show the file to which `procfs' API trace is written.
`proc-trace-entry'
`proc-trace-entry'
`proc-trace-exit'
`proc-trace-exit'
`proc-untrace-entry'
`proc-untrace-entry'
`proc-untrace-exit'
`proc-untrace-exit'
     These commands enable and disable tracing of entries into and exits
     These commands enable and disable tracing of entries into and exits
     from the `syscall' interface.
     from the `syscall' interface.
`info pidlist'
`info pidlist'
     For QNX Neutrino only, this command displays the list of all the
     For QNX Neutrino only, this command displays the list of all the
     processes and all the threads within each process.
     processes and all the threads within each process.
`info meminfo'
`info meminfo'
     For QNX Neutrino only, this command displays the list of all
     For QNX Neutrino only, this command displays the list of all
     mapinfos.
     mapinfos.


File: gdb.info,  Node: DJGPP Native,  Next: Cygwin Native,  Prev: SVR4 Process Information,  Up: Native
File: gdb.info,  Node: DJGPP Native,  Next: Cygwin Native,  Prev: SVR4 Process Information,  Up: Native
18.1.4 Features for Debugging DJGPP Programs
18.1.4 Features for Debugging DJGPP Programs
--------------------------------------------
--------------------------------------------
DJGPP is a port of the GNU development tools to MS-DOS and MS-Windows.
DJGPP is a port of the GNU development tools to MS-DOS and MS-Windows.
DJGPP programs are 32-bit protected-mode programs that use the "DPMI"
DJGPP programs are 32-bit protected-mode programs that use the "DPMI"
(DOS Protected-Mode Interface) API to run on top of real-mode DOS
(DOS Protected-Mode Interface) API to run on top of real-mode DOS
systems and their emulations.
systems and their emulations.
   GDB supports native debugging of DJGPP programs, and defines a few
   GDB supports native debugging of DJGPP programs, and defines a few
commands specific to the DJGPP port.  This subsection describes those
commands specific to the DJGPP port.  This subsection describes those
commands.
commands.
`info dos'
`info dos'
     This is a prefix of DJGPP-specific commands which print
     This is a prefix of DJGPP-specific commands which print
     information about the target system and important OS structures.
     information about the target system and important OS structures.
`info dos sysinfo'
`info dos sysinfo'
     This command displays assorted information about the underlying
     This command displays assorted information about the underlying
     platform: the CPU type and features, the OS version and flavor, the
     platform: the CPU type and features, the OS version and flavor, the
     DPMI version, and the available conventional and DPMI memory.
     DPMI version, and the available conventional and DPMI memory.
`info dos gdt'
`info dos gdt'
`info dos ldt'
`info dos ldt'
`info dos idt'
`info dos idt'
     These 3 commands display entries from, respectively, Global, Local,
     These 3 commands display entries from, respectively, Global, Local,
     and Interrupt Descriptor Tables (GDT, LDT, and IDT).  The
     and Interrupt Descriptor Tables (GDT, LDT, and IDT).  The
     descriptor tables are data structures which store a descriptor for
     descriptor tables are data structures which store a descriptor for
     each segment that is currently in use.  The segment's selector is
     each segment that is currently in use.  The segment's selector is
     an index into a descriptor table; the table entry for that index
     an index into a descriptor table; the table entry for that index
     holds the descriptor's base address and limit, and its attributes
     holds the descriptor's base address and limit, and its attributes
     and access rights.
     and access rights.
     A typical DJGPP program uses 3 segments: a code segment, a data
     A typical DJGPP program uses 3 segments: a code segment, a data
     segment (used for both data and the stack), and a DOS segment
     segment (used for both data and the stack), and a DOS segment
     (which allows access to DOS/BIOS data structures and absolute
     (which allows access to DOS/BIOS data structures and absolute
     addresses in conventional memory).  However, the DPMI host will
     addresses in conventional memory).  However, the DPMI host will
     usually define additional segments in order to support the DPMI
     usually define additional segments in order to support the DPMI
     environment.
     environment.
     These commands allow to display entries from the descriptor tables.
     These commands allow to display entries from the descriptor tables.
     Without an argument, all entries from the specified table are
     Without an argument, all entries from the specified table are
     displayed.  An argument, which should be an integer expression,
     displayed.  An argument, which should be an integer expression,
     means display a single entry whose index is given by the argument.
     means display a single entry whose index is given by the argument.
     For example, here's a convenient way to display information about
     For example, here's a convenient way to display information about
     the debugged program's data segment:
     the debugged program's data segment:
     `(gdb) info dos ldt $ds'
     `(gdb) info dos ldt $ds'
     `0x13f: base=0x11970000 limit=0x0009ffff 32-Bit Data (Read/Write, Exp-up)'
     `0x13f: base=0x11970000 limit=0x0009ffff 32-Bit Data (Read/Write, Exp-up)'
     This comes in handy when you want to see whether a pointer is
     This comes in handy when you want to see whether a pointer is
     outside the data segment's limit (i.e. "garbled").
     outside the data segment's limit (i.e. "garbled").
`info dos pde'
`info dos pde'
`info dos pte'
`info dos pte'
     These two commands display entries from, respectively, the Page
     These two commands display entries from, respectively, the Page
     Directory and the Page Tables.  Page Directories and Page Tables
     Directory and the Page Tables.  Page Directories and Page Tables
     are data structures which control how virtual memory addresses are
     are data structures which control how virtual memory addresses are
     mapped into physical addresses.  A Page Table includes an entry
     mapped into physical addresses.  A Page Table includes an entry
     for every page of memory that is mapped into the program's address
     for every page of memory that is mapped into the program's address
     space; there may be several Page Tables, each one holding up to
     space; there may be several Page Tables, each one holding up to
     4096 entries.  A Page Directory has up to 4096 entries, one each
     4096 entries.  A Page Directory has up to 4096 entries, one each
     for every Page Table that is currently in use.
     for every Page Table that is currently in use.
     Without an argument, `info dos pde' displays the entire Page
     Without an argument, `info dos pde' displays the entire Page
     Directory, and `info dos pte' displays all the entries in all of
     Directory, and `info dos pte' displays all the entries in all of
     the Page Tables.  An argument, an integer expression, given to the
     the Page Tables.  An argument, an integer expression, given to the
     `info dos pde' command means display only that entry from the Page
     `info dos pde' command means display only that entry from the Page
     Directory table.  An argument given to the `info dos pte' command
     Directory table.  An argument given to the `info dos pte' command
     means display entries from a single Page Table, the one pointed to
     means display entries from a single Page Table, the one pointed to
     by the specified entry in the Page Directory.
     by the specified entry in the Page Directory.
     These commands are useful when your program uses "DMA" (Direct
     These commands are useful when your program uses "DMA" (Direct
     Memory Access), which needs physical addresses to program the DMA
     Memory Access), which needs physical addresses to program the DMA
     controller.
     controller.
     These commands are supported only with some DPMI servers.
     These commands are supported only with some DPMI servers.
`info dos address-pte ADDR'
`info dos address-pte ADDR'
     This command displays the Page Table entry for a specified linear
     This command displays the Page Table entry for a specified linear
     address.  The argument ADDR is a linear address which should
     address.  The argument ADDR is a linear address which should
     already have the appropriate segment's base address added to it,
     already have the appropriate segment's base address added to it,
     because this command accepts addresses which may belong to _any_
     because this command accepts addresses which may belong to _any_
     segment.  For example, here's how to display the Page Table entry
     segment.  For example, here's how to display the Page Table entry
     for the page where a variable `i' is stored:
     for the page where a variable `i' is stored:
     `(gdb) info dos address-pte __djgpp_base_address + (char *)&i'
     `(gdb) info dos address-pte __djgpp_base_address + (char *)&i'
     `Page Table entry for address 0x11a00d30:'
     `Page Table entry for address 0x11a00d30:'
     `Base=0x02698000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0xd30'
     `Base=0x02698000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0xd30'
     This says that `i' is stored at offset `0xd30' from the page whose
     This says that `i' is stored at offset `0xd30' from the page whose
     physical base address is `0x02698000', and shows all the
     physical base address is `0x02698000', and shows all the
     attributes of that page.
     attributes of that page.
     Note that you must cast the addresses of variables to a `char *',
     Note that you must cast the addresses of variables to a `char *',
     since otherwise the value of `__djgpp_base_address', the base
     since otherwise the value of `__djgpp_base_address', the base
     address of all variables and functions in a DJGPP program, will be
     address of all variables and functions in a DJGPP program, will be
     added using the rules of C pointer arithmetics: if `i' is declared
     added using the rules of C pointer arithmetics: if `i' is declared
     an `int', GDB will add 4 times the value of `__djgpp_base_address'
     an `int', GDB will add 4 times the value of `__djgpp_base_address'
     to the address of `i'.
     to the address of `i'.
     Here's another example, it displays the Page Table entry for the
     Here's another example, it displays the Page Table entry for the
     transfer buffer:
     transfer buffer:
     `(gdb) info dos address-pte *((unsigned *)&_go32_info_block + 3)'
     `(gdb) info dos address-pte *((unsigned *)&_go32_info_block + 3)'
     `Page Table entry for address 0x29110:'
     `Page Table entry for address 0x29110:'
     `Base=0x00029000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0x110'
     `Base=0x00029000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0x110'
     (The `+ 3' offset is because the transfer buffer's address is the
     (The `+ 3' offset is because the transfer buffer's address is the
     3rd member of the `_go32_info_block' structure.)  The output
     3rd member of the `_go32_info_block' structure.)  The output
     clearly shows that this DPMI server maps the addresses in
     clearly shows that this DPMI server maps the addresses in
     conventional memory 1:1, i.e. the physical (`0x00029000' +
     conventional memory 1:1, i.e. the physical (`0x00029000' +
     `0x110') and linear (`0x29110') addresses are identical.
     `0x110') and linear (`0x29110') addresses are identical.
     This command is supported only with some DPMI servers.
     This command is supported only with some DPMI servers.
   In addition to native debugging, the DJGPP port supports remote
   In addition to native debugging, the DJGPP port supports remote
debugging via a serial data link.  The following commands are specific
debugging via a serial data link.  The following commands are specific
to remote serial debugging in the DJGPP port of GDB.
to remote serial debugging in the DJGPP port of GDB.
`set com1base ADDR'
`set com1base ADDR'
     This command sets the base I/O port address of the `COM1' serial
     This command sets the base I/O port address of the `COM1' serial
     port.
     port.
`set com1irq IRQ'
`set com1irq IRQ'
     This command sets the "Interrupt Request" (`IRQ') line to use for
     This command sets the "Interrupt Request" (`IRQ') line to use for
     the `COM1' serial port.
     the `COM1' serial port.
     There are similar commands `set com2base', `set com3irq', etc. for
     There are similar commands `set com2base', `set com3irq', etc. for
     setting the port address and the `IRQ' lines for the other 3 COM
     setting the port address and the `IRQ' lines for the other 3 COM
     ports.
     ports.
     The related commands `show com1base', `show com1irq' etc.  display
     The related commands `show com1base', `show com1irq' etc.  display
     the current settings of the base address and the `IRQ' lines used
     the current settings of the base address and the `IRQ' lines used
     by the COM ports.
     by the COM ports.
`info serial'
`info serial'
     This command prints the status of the 4 DOS serial ports.  For each
     This command prints the status of the 4 DOS serial ports.  For each
     port, it prints whether it's active or not, its I/O base address
     port, it prints whether it's active or not, its I/O base address
     and IRQ number, whether it uses a 16550-style FIFO, its baudrate,
     and IRQ number, whether it uses a 16550-style FIFO, its baudrate,
     and the counts of various errors encountered so far.
     and the counts of various errors encountered so far.


File: gdb.info,  Node: Cygwin Native,  Next: Hurd Native,  Prev: DJGPP Native,  Up: Native
File: gdb.info,  Node: Cygwin Native,  Next: Hurd Native,  Prev: DJGPP Native,  Up: Native
18.1.5 Features for Debugging MS Windows PE Executables
18.1.5 Features for Debugging MS Windows PE Executables
-------------------------------------------------------
-------------------------------------------------------
GDB supports native debugging of MS Windows programs, including DLLs
GDB supports native debugging of MS Windows programs, including DLLs
with and without symbolic debugging information.  There are various
with and without symbolic debugging information.  There are various
additional Cygwin-specific commands, described in this section.
additional Cygwin-specific commands, described in this section.
Working with DLLs that have no debugging symbols is described in *Note
Working with DLLs that have no debugging symbols is described in *Note
Non-debug DLL Symbols::.
Non-debug DLL Symbols::.
`info w32'
`info w32'
     This is a prefix of MS Windows-specific commands which print
     This is a prefix of MS Windows-specific commands which print
     information about the target system and important OS structures.
     information about the target system and important OS structures.
`info w32 selector'
`info w32 selector'
     This command displays information returned by the Win32 API
     This command displays information returned by the Win32 API
     `GetThreadSelectorEntry' function.  It takes an optional argument
     `GetThreadSelectorEntry' function.  It takes an optional argument
     that is evaluated to a long value to give the information about
     that is evaluated to a long value to give the information about
     this given selector.  Without argument, this command displays
     this given selector.  Without argument, this command displays
     information about the six segment registers.
     information about the six segment registers.
`info dll'
`info dll'
     This is a Cygwin-specific alias of `info shared'.
     This is a Cygwin-specific alias of `info shared'.
`dll-symbols'
`dll-symbols'
     This command loads symbols from a dll similarly to add-sym command
     This command loads symbols from a dll similarly to add-sym command
     but without the need to specify a base address.
     but without the need to specify a base address.
`set cygwin-exceptions MODE'
`set cygwin-exceptions MODE'
     If MODE is `on', GDB will break on exceptions that happen inside
     If MODE is `on', GDB will break on exceptions that happen inside
     the Cygwin DLL.  If MODE is `off', GDB will delay recognition of
     the Cygwin DLL.  If MODE is `off', GDB will delay recognition of
     exceptions, and may ignore some exceptions which seem to be caused
     exceptions, and may ignore some exceptions which seem to be caused
     by internal Cygwin DLL "bookkeeping".  This option is meant
     by internal Cygwin DLL "bookkeeping".  This option is meant
     primarily for debugging the Cygwin DLL itself; the default value
     primarily for debugging the Cygwin DLL itself; the default value
     is `off' to avoid annoying GDB users with false `SIGSEGV' signals.
     is `off' to avoid annoying GDB users with false `SIGSEGV' signals.
`show cygwin-exceptions'
`show cygwin-exceptions'
     Displays whether GDB will break on exceptions that happen inside
     Displays whether GDB will break on exceptions that happen inside
     the Cygwin DLL itself.
     the Cygwin DLL itself.
`set new-console MODE'
`set new-console MODE'
     If MODE is `on' the debuggee will be started in a new console on
     If MODE is `on' the debuggee will be started in a new console on
     next start.  If MODE is `off'i, the debuggee will be started in
     next start.  If MODE is `off'i, the debuggee will be started in
     the same console as the debugger.
     the same console as the debugger.
`show new-console'
`show new-console'
     Displays whether a new console is used when the debuggee is
     Displays whether a new console is used when the debuggee is
     started.
     started.
`set new-group MODE'
`set new-group MODE'
     This boolean value controls whether the debuggee should start a
     This boolean value controls whether the debuggee should start a
     new group or stay in the same group as the debugger.  This affects
     new group or stay in the same group as the debugger.  This affects
     the way the Windows OS handles `Ctrl-C'.
     the way the Windows OS handles `Ctrl-C'.
`show new-group'
`show new-group'
     Displays current value of new-group boolean.
     Displays current value of new-group boolean.
`set debugevents'
`set debugevents'
     This boolean value adds debug output concerning kernel events
     This boolean value adds debug output concerning kernel events
     related to the debuggee seen by the debugger.  This includes
     related to the debuggee seen by the debugger.  This includes
     events that signal thread and process creation and exit, DLL
     events that signal thread and process creation and exit, DLL
     loading and unloading, console interrupts, and debugging messages
     loading and unloading, console interrupts, and debugging messages
     produced by the Windows `OutputDebugString' API call.
     produced by the Windows `OutputDebugString' API call.
`set debugexec'
`set debugexec'
     This boolean value adds debug output concerning execute events
     This boolean value adds debug output concerning execute events
     (such as resume thread) seen by the debugger.
     (such as resume thread) seen by the debugger.
`set debugexceptions'
`set debugexceptions'
     This boolean value adds debug output concerning exceptions in the
     This boolean value adds debug output concerning exceptions in the
     debuggee seen by the debugger.
     debuggee seen by the debugger.
`set debugmemory'
`set debugmemory'
     This boolean value adds debug output concerning debuggee memory
     This boolean value adds debug output concerning debuggee memory
     reads and writes by the debugger.
     reads and writes by the debugger.
`set shell'
`set shell'
     This boolean values specifies whether the debuggee is called via a
     This boolean values specifies whether the debuggee is called via a
     shell or directly (default value is on).
     shell or directly (default value is on).
`show shell'
`show shell'
     Displays if the debuggee will be started with a shell.
     Displays if the debuggee will be started with a shell.
* Menu:
* Menu:
* Non-debug DLL Symbols::  Support for DLLs without debugging symbols
* Non-debug DLL Symbols::  Support for DLLs without debugging symbols


File: gdb.info,  Node: Non-debug DLL Symbols,  Up: Cygwin Native
File: gdb.info,  Node: Non-debug DLL Symbols,  Up: Cygwin Native
18.1.5.1 Support for DLLs without Debugging Symbols
18.1.5.1 Support for DLLs without Debugging Symbols
...................................................
...................................................
Very often on windows, some of the DLLs that your program relies on do
Very often on windows, some of the DLLs that your program relies on do
not include symbolic debugging information (for example,
not include symbolic debugging information (for example,
`kernel32.dll').  When GDB doesn't recognize any debugging symbols in a
`kernel32.dll').  When GDB doesn't recognize any debugging symbols in a
DLL, it relies on the minimal amount of symbolic information contained
DLL, it relies on the minimal amount of symbolic information contained
in the DLL's export table.  This section describes working with such
in the DLL's export table.  This section describes working with such
symbols, known internally to GDB as "minimal symbols".
symbols, known internally to GDB as "minimal symbols".
   Note that before the debugged program has started execution, no DLLs
   Note that before the debugged program has started execution, no DLLs
will have been loaded.  The easiest way around this problem is simply to
will have been loaded.  The easiest way around this problem is simply to
start the program -- either by setting a breakpoint or letting the
start the program -- either by setting a breakpoint or letting the
program run once to completion.  It is also possible to force GDB to
program run once to completion.  It is also possible to force GDB to
load a particular DLL before starting the executable -- see the shared
load a particular DLL before starting the executable -- see the shared
library information in *Note Files::, or the `dll-symbols' command in
library information in *Note Files::, or the `dll-symbols' command in
*Note Cygwin Native::.  Currently, explicitly loading symbols from a
*Note Cygwin Native::.  Currently, explicitly loading symbols from a
DLL with no debugging information will cause the symbol names to be
DLL with no debugging information will cause the symbol names to be
duplicated in GDB's lookup table, which may adversely affect symbol
duplicated in GDB's lookup table, which may adversely affect symbol
lookup performance.
lookup performance.
18.1.5.2 DLL Name Prefixes
18.1.5.2 DLL Name Prefixes
..........................
..........................
In keeping with the naming conventions used by the Microsoft debugging
In keeping with the naming conventions used by the Microsoft debugging
tools, DLL export symbols are made available with a prefix based on the
tools, DLL export symbols are made available with a prefix based on the
DLL name, for instance `KERNEL32!CreateFileA'.  The plain name is also
DLL name, for instance `KERNEL32!CreateFileA'.  The plain name is also
entered into the symbol table, so `CreateFileA' is often sufficient. In
entered into the symbol table, so `CreateFileA' is often sufficient. In
some cases there will be name clashes within a program (particularly if
some cases there will be name clashes within a program (particularly if
the executable itself includes full debugging symbols) necessitating
the executable itself includes full debugging symbols) necessitating
the use of the fully qualified name when referring to the contents of
the use of the fully qualified name when referring to the contents of
the DLL. Use single-quotes around the name to avoid the exclamation
the DLL. Use single-quotes around the name to avoid the exclamation
mark ("!")  being interpreted as a language operator.
mark ("!")  being interpreted as a language operator.
   Note that the internal name of the DLL may be all upper-case, even
   Note that the internal name of the DLL may be all upper-case, even
though the file name of the DLL is lower-case, or vice-versa. Since
though the file name of the DLL is lower-case, or vice-versa. Since
symbols within GDB are _case-sensitive_ this may cause some confusion.
symbols within GDB are _case-sensitive_ this may cause some confusion.
If in doubt, try the `info functions' and `info variables' commands or
If in doubt, try the `info functions' and `info variables' commands or
even `maint print msymbols' (*note Symbols::). Here's an example:
even `maint print msymbols' (*note Symbols::). Here's an example:
     (gdb) info function CreateFileA
     (gdb) info function CreateFileA
     All functions matching regular expression "CreateFileA":
     All functions matching regular expression "CreateFileA":
     Non-debugging symbols:
     Non-debugging symbols:
     0x77e885f4  CreateFileA
     0x77e885f4  CreateFileA
     0x77e885f4  KERNEL32!CreateFileA
     0x77e885f4  KERNEL32!CreateFileA
     (gdb) info function !
     (gdb) info function !
     All functions matching regular expression "!":
     All functions matching regular expression "!":
     Non-debugging symbols:
     Non-debugging symbols:
     0x6100114c  cygwin1!__assert
     0x6100114c  cygwin1!__assert
     0x61004034  cygwin1!_dll_crt0@0
     0x61004034  cygwin1!_dll_crt0@0
     0x61004240  cygwin1!dll_crt0(per_process *)
     0x61004240  cygwin1!dll_crt0(per_process *)
     [etc...]
     [etc...]
18.1.5.3 Working with Minimal Symbols
18.1.5.3 Working with Minimal Symbols
.....................................
.....................................
Symbols extracted from a DLL's export table do not contain very much
Symbols extracted from a DLL's export table do not contain very much
type information. All that GDB can do is guess whether a symbol refers
type information. All that GDB can do is guess whether a symbol refers
to a function or variable depending on the linker section that contains
to a function or variable depending on the linker section that contains
the symbol. Also note that the actual contents of the memory contained
the symbol. Also note that the actual contents of the memory contained
in a DLL are not available unless the program is running. This means
in a DLL are not available unless the program is running. This means
that you cannot examine the contents of a variable or disassemble a
that you cannot examine the contents of a variable or disassemble a
function within a DLL without a running program.
function within a DLL without a running program.
   Variables are generally treated as pointers and dereferenced
   Variables are generally treated as pointers and dereferenced
automatically. For this reason, it is often necessary to prefix a
automatically. For this reason, it is often necessary to prefix a
variable name with the address-of operator ("&") and provide explicit
variable name with the address-of operator ("&") and provide explicit
type information in the command. Here's an example of the type of
type information in the command. Here's an example of the type of
problem:
problem:
     (gdb) print 'cygwin1!__argv'
     (gdb) print 'cygwin1!__argv'
     $1 = 268572168
     $1 = 268572168
     (gdb) x 'cygwin1!__argv'
     (gdb) x 'cygwin1!__argv'
     0x10021610:      "\230y\""
     0x10021610:      "\230y\""
   And two possible solutions:
   And two possible solutions:
     (gdb) print ((char **)'cygwin1!__argv')[0]
     (gdb) print ((char **)'cygwin1!__argv')[0]
     $2 = 0x22fd98 "/cygdrive/c/mydirectory/myprogram"
     $2 = 0x22fd98 "/cygdrive/c/mydirectory/myprogram"
     (gdb) x/2x &'cygwin1!__argv'
     (gdb) x/2x &'cygwin1!__argv'
     0x610c0aa8 :    0x10021608      0x00000000
     0x610c0aa8 :    0x10021608      0x00000000
     (gdb) x/x 0x10021608
     (gdb) x/x 0x10021608
     0x10021608:     0x0022fd98
     0x10021608:     0x0022fd98
     (gdb) x/s 0x0022fd98
     (gdb) x/s 0x0022fd98
     0x22fd98:        "/cygdrive/c/mydirectory/myprogram"
     0x22fd98:        "/cygdrive/c/mydirectory/myprogram"
   Setting a break point within a DLL is possible even before the
   Setting a break point within a DLL is possible even before the
program starts execution. However, under these circumstances, GDB can't
program starts execution. However, under these circumstances, GDB can't
examine the initial instructions of the function in order to skip the
examine the initial instructions of the function in order to skip the
function's frame set-up code. You can work around this by using "*&" to
function's frame set-up code. You can work around this by using "*&" to
set the breakpoint at a raw memory address:
set the breakpoint at a raw memory address:
     (gdb) break *&'python22!PyOS_Readline'
     (gdb) break *&'python22!PyOS_Readline'
     Breakpoint 1 at 0x1e04eff0
     Breakpoint 1 at 0x1e04eff0
   The author of these extensions is not entirely convinced that
   The author of these extensions is not entirely convinced that
setting a break point within a shared DLL like `kernel32.dll' is
setting a break point within a shared DLL like `kernel32.dll' is
completely safe.
completely safe.


File: gdb.info,  Node: Hurd Native,  Next: Neutrino,  Prev: Cygwin Native,  Up: Native
File: gdb.info,  Node: Hurd Native,  Next: Neutrino,  Prev: Cygwin Native,  Up: Native
18.1.6 Commands Specific to GNU Hurd Systems
18.1.6 Commands Specific to GNU Hurd Systems
--------------------------------------------
--------------------------------------------
This subsection describes GDB commands specific to the GNU Hurd native
This subsection describes GDB commands specific to the GNU Hurd native
debugging.
debugging.
`set signals'
`set signals'
`set sigs'
`set sigs'
     This command toggles the state of inferior signal interception by
     This command toggles the state of inferior signal interception by
     GDB.  Mach exceptions, such as breakpoint traps, are not affected
     GDB.  Mach exceptions, such as breakpoint traps, are not affected
     by this command.  `sigs' is a shorthand alias for `signals'.
     by this command.  `sigs' is a shorthand alias for `signals'.
`show signals'
`show signals'
`show sigs'
`show sigs'
     Show the current state of intercepting inferior's signals.
     Show the current state of intercepting inferior's signals.
`set signal-thread'
`set signal-thread'
`set sigthread'
`set sigthread'
     This command tells GDB which thread is the `libc' signal thread.
     This command tells GDB which thread is the `libc' signal thread.
     That thread is run when a signal is delivered to a running
     That thread is run when a signal is delivered to a running
     process.  `set sigthread' is the shorthand alias of `set
     process.  `set sigthread' is the shorthand alias of `set
     signal-thread'.
     signal-thread'.
`show signal-thread'
`show signal-thread'
`show sigthread'
`show sigthread'
     These two commands show which thread will run when the inferior is
     These two commands show which thread will run when the inferior is
     delivered a signal.
     delivered a signal.
`set stopped'
`set stopped'
     This commands tells GDB that the inferior process is stopped, as
     This commands tells GDB that the inferior process is stopped, as
     with the `SIGSTOP' signal.  The stopped process can be continued
     with the `SIGSTOP' signal.  The stopped process can be continued
     by delivering a signal to it.
     by delivering a signal to it.
`show stopped'
`show stopped'
     This command shows whether GDB thinks the debuggee is stopped.
     This command shows whether GDB thinks the debuggee is stopped.
`set exceptions'
`set exceptions'
     Use this command to turn off trapping of exceptions in the
     Use this command to turn off trapping of exceptions in the
     inferior.  When exception trapping is off, neither breakpoints nor
     inferior.  When exception trapping is off, neither breakpoints nor
     single-stepping will work.  To restore the default, set exception
     single-stepping will work.  To restore the default, set exception
     trapping on.
     trapping on.
`show exceptions'
`show exceptions'
     Show the current state of trapping exceptions in the inferior.
     Show the current state of trapping exceptions in the inferior.
`set task pause'
`set task pause'
     This command toggles task suspension when GDB has control.
     This command toggles task suspension when GDB has control.
     Setting it to on takes effect immediately, and the task is
     Setting it to on takes effect immediately, and the task is
     suspended whenever GDB gets control.  Setting it to off will take
     suspended whenever GDB gets control.  Setting it to off will take
     effect the next time the inferior is continued.  If this option is
     effect the next time the inferior is continued.  If this option is
     set to off, you can use `set thread default pause on' or `set
     set to off, you can use `set thread default pause on' or `set
     thread pause on' (see below) to pause individual threads.
     thread pause on' (see below) to pause individual threads.
`show task pause'
`show task pause'
     Show the current state of task suspension.
     Show the current state of task suspension.
`set task detach-suspend-count'
`set task detach-suspend-count'
     This command sets the suspend count the task will be left with when
     This command sets the suspend count the task will be left with when
     GDB detaches from it.
     GDB detaches from it.
`show task detach-suspend-count'
`show task detach-suspend-count'
     Show the suspend count the task will be left with when detaching.
     Show the suspend count the task will be left with when detaching.
`set task exception-port'
`set task exception-port'
`set task excp'
`set task excp'
     This command sets the task exception port to which GDB will
     This command sets the task exception port to which GDB will
     forward exceptions.  The argument should be the value of the "send
     forward exceptions.  The argument should be the value of the "send
     rights" of the task.  `set task excp' is a shorthand alias.
     rights" of the task.  `set task excp' is a shorthand alias.
`set noninvasive'
`set noninvasive'
     This command switches GDB to a mode that is the least invasive as
     This command switches GDB to a mode that is the least invasive as
     far as interfering with the inferior is concerned.  This is the
     far as interfering with the inferior is concerned.  This is the
     same as using `set task pause', `set exceptions', and `set
     same as using `set task pause', `set exceptions', and `set
     signals' to values opposite to the defaults.
     signals' to values opposite to the defaults.
`info send-rights'
`info send-rights'
`info receive-rights'
`info receive-rights'
`info port-rights'
`info port-rights'
`info port-sets'
`info port-sets'
`info dead-names'
`info dead-names'
`info ports'
`info ports'
`info psets'
`info psets'
     These commands display information about, respectively, send
     These commands display information about, respectively, send
     rights, receive rights, port rights, port sets, and dead names of
     rights, receive rights, port rights, port sets, and dead names of
     a task.  There are also shorthand aliases: `info ports' for `info
     a task.  There are also shorthand aliases: `info ports' for `info
     port-rights' and `info psets' for `info port-sets'.
     port-rights' and `info psets' for `info port-sets'.
`set thread pause'
`set thread pause'
     This command toggles current thread suspension when GDB has
     This command toggles current thread suspension when GDB has
     control.  Setting it to on takes effect immediately, and the
     control.  Setting it to on takes effect immediately, and the
     current thread is suspended whenever GDB gets control.  Setting it
     current thread is suspended whenever GDB gets control.  Setting it
     to off will take effect the next time the inferior is continued.
     to off will take effect the next time the inferior is continued.
     Normally, this command has no effect, since when GDB has control,
     Normally, this command has no effect, since when GDB has control,
     the whole task is suspended.  However, if you used `set task pause
     the whole task is suspended.  However, if you used `set task pause
     off' (see above), this command comes in handy to suspend only the
     off' (see above), this command comes in handy to suspend only the
     current thread.
     current thread.
`show thread pause'
`show thread pause'
     This command shows the state of current thread suspension.
     This command shows the state of current thread suspension.
`set thread run'
`set thread run'
     This command sets whether the current thread is allowed to run.
     This command sets whether the current thread is allowed to run.
`show thread run'
`show thread run'
     Show whether the current thread is allowed to run.
     Show whether the current thread is allowed to run.
`set thread detach-suspend-count'
`set thread detach-suspend-count'
     This command sets the suspend count GDB will leave on a thread
     This command sets the suspend count GDB will leave on a thread
     when detaching.  This number is relative to the suspend count
     when detaching.  This number is relative to the suspend count
     found by GDB when it notices the thread; use `set thread
     found by GDB when it notices the thread; use `set thread
     takeover-suspend-count' to force it to an absolute value.
     takeover-suspend-count' to force it to an absolute value.
`show thread detach-suspend-count'
`show thread detach-suspend-count'
     Show the suspend count GDB will leave on the thread when detaching.
     Show the suspend count GDB will leave on the thread when detaching.
`set thread exception-port'
`set thread exception-port'
`set thread excp'
`set thread excp'
     Set the thread exception port to which to forward exceptions.  This
     Set the thread exception port to which to forward exceptions.  This
     overrides the port set by `set task exception-port' (see above).
     overrides the port set by `set task exception-port' (see above).
     `set thread excp' is the shorthand alias.
     `set thread excp' is the shorthand alias.
`set thread takeover-suspend-count'
`set thread takeover-suspend-count'
     Normally, GDB's thread suspend counts are relative to the value
     Normally, GDB's thread suspend counts are relative to the value
     GDB finds when it notices each thread.  This command changes the
     GDB finds when it notices each thread.  This command changes the
     suspend counts to be absolute instead.
     suspend counts to be absolute instead.
`set thread default'
`set thread default'
`show thread default'
`show thread default'
     Each of the above `set thread' commands has a `set thread default'
     Each of the above `set thread' commands has a `set thread default'
     counterpart (e.g., `set thread default pause', `set thread default
     counterpart (e.g., `set thread default pause', `set thread default
     exception-port', etc.).  The `thread default' variety of commands
     exception-port', etc.).  The `thread default' variety of commands
     sets the default thread properties for all threads; you can then
     sets the default thread properties for all threads; you can then
     change the properties of individual threads with the non-default
     change the properties of individual threads with the non-default
     commands.
     commands.


File: gdb.info,  Node: Neutrino,  Prev: Hurd Native,  Up: Native
File: gdb.info,  Node: Neutrino,  Prev: Hurd Native,  Up: Native
18.1.7 QNX Neutrino
18.1.7 QNX Neutrino
-------------------
-------------------
GDB provides the following commands specific to the QNX Neutrino target:
GDB provides the following commands specific to the QNX Neutrino target:
`set debug nto-debug'
`set debug nto-debug'
     When set to on, enables debugging messages specific to the QNX
     When set to on, enables debugging messages specific to the QNX
     Neutrino support.
     Neutrino support.
`show debug nto-debug'
`show debug nto-debug'
     Show the current state of QNX Neutrino messages.
     Show the current state of QNX Neutrino messages.


File: gdb.info,  Node: Embedded OS,  Next: Embedded Processors,  Prev: Native,  Up: Configurations
File: gdb.info,  Node: Embedded OS,  Next: Embedded Processors,  Prev: Native,  Up: Configurations
18.2 Embedded Operating Systems
18.2 Embedded Operating Systems
===============================
===============================
This section describes configurations involving the debugging of
This section describes configurations involving the debugging of
embedded operating systems that are available for several different
embedded operating systems that are available for several different
architectures.
architectures.
* Menu:
* Menu:
* VxWorks::                     Using GDB with VxWorks
* VxWorks::                     Using GDB with VxWorks
   GDB includes the ability to debug programs running on various
   GDB includes the ability to debug programs running on various
real-time operating systems.
real-time operating systems.


File: gdb.info,  Node: VxWorks,  Up: Embedded OS
File: gdb.info,  Node: VxWorks,  Up: Embedded OS
18.2.1 Using GDB with VxWorks
18.2.1 Using GDB with VxWorks
-----------------------------
-----------------------------
`target vxworks MACHINENAME'
`target vxworks MACHINENAME'
     A VxWorks system, attached via TCP/IP.  The argument MACHINENAME
     A VxWorks system, attached via TCP/IP.  The argument MACHINENAME
     is the target system's machine name or IP address.
     is the target system's machine name or IP address.
   On VxWorks, `load' links FILENAME dynamically on the current target
   On VxWorks, `load' links FILENAME dynamically on the current target
system as well as adding its symbols in GDB.
system as well as adding its symbols in GDB.
   GDB enables developers to spawn and debug tasks running on networked
   GDB enables developers to spawn and debug tasks running on networked
VxWorks targets from a Unix host.  Already-running tasks spawned from
VxWorks targets from a Unix host.  Already-running tasks spawned from
the VxWorks shell can also be debugged.  GDB uses code that runs on
the VxWorks shell can also be debugged.  GDB uses code that runs on
both the Unix host and on the VxWorks target.  The program `gdb' is
both the Unix host and on the VxWorks target.  The program `gdb' is
installed and executed on the Unix host.  (It may be installed with the
installed and executed on the Unix host.  (It may be installed with the
name `vxgdb', to distinguish it from a GDB for debugging programs on
name `vxgdb', to distinguish it from a GDB for debugging programs on
the host itself.)
the host itself.)
`VxWorks-timeout ARGS'
`VxWorks-timeout ARGS'
     All VxWorks-based targets now support the option `vxworks-timeout'.
     All VxWorks-based targets now support the option `vxworks-timeout'.
     This option is set by the user, and  ARGS represents the number of
     This option is set by the user, and  ARGS represents the number of
     seconds GDB waits for responses to rpc's.  You might use this if
     seconds GDB waits for responses to rpc's.  You might use this if
     your VxWorks target is a slow software simulator or is on the far
     your VxWorks target is a slow software simulator or is on the far
     side of a thin network line.
     side of a thin network line.
   The following information on connecting to VxWorks was current when
   The following information on connecting to VxWorks was current when
this manual was produced; newer releases of VxWorks may use revised
this manual was produced; newer releases of VxWorks may use revised
procedures.
procedures.
   To use GDB with VxWorks, you must rebuild your VxWorks kernel to
   To use GDB with VxWorks, you must rebuild your VxWorks kernel to
include the remote debugging interface routines in the VxWorks library
include the remote debugging interface routines in the VxWorks library
`rdb.a'.  To do this, define `INCLUDE_RDB' in the VxWorks configuration
`rdb.a'.  To do this, define `INCLUDE_RDB' in the VxWorks configuration
file `configAll.h' and rebuild your VxWorks kernel.  The resulting
file `configAll.h' and rebuild your VxWorks kernel.  The resulting
kernel contains `rdb.a', and spawns the source debugging task
kernel contains `rdb.a', and spawns the source debugging task
`tRdbTask' when VxWorks is booted.  For more information on configuring
`tRdbTask' when VxWorks is booted.  For more information on configuring
and remaking VxWorks, see the manufacturer's manual.
and remaking VxWorks, see the manufacturer's manual.
   Once you have included `rdb.a' in your VxWorks system image and set
   Once you have included `rdb.a' in your VxWorks system image and set
your Unix execution search path to find GDB, you are ready to run GDB.
your Unix execution search path to find GDB, you are ready to run GDB.
From your Unix host, run `gdb' (or `vxgdb', depending on your
From your Unix host, run `gdb' (or `vxgdb', depending on your
installation).
installation).
   GDB comes up showing the prompt:
   GDB comes up showing the prompt:
     (vxgdb)
     (vxgdb)
* Menu:
* Menu:
* VxWorks Connection::          Connecting to VxWorks
* VxWorks Connection::          Connecting to VxWorks
* VxWorks Download::            VxWorks download
* VxWorks Download::            VxWorks download
* VxWorks Attach::              Running tasks
* VxWorks Attach::              Running tasks


File: gdb.info,  Node: VxWorks Connection,  Next: VxWorks Download,  Up: VxWorks
File: gdb.info,  Node: VxWorks Connection,  Next: VxWorks Download,  Up: VxWorks
18.2.1.1 Connecting to VxWorks
18.2.1.1 Connecting to VxWorks
..............................
..............................
The GDB command `target' lets you connect to a VxWorks target on the
The GDB command `target' lets you connect to a VxWorks target on the
network.  To connect to a target whose host name is "`tt'", type:
network.  To connect to a target whose host name is "`tt'", type:
     (vxgdb) target vxworks tt
     (vxgdb) target vxworks tt
   GDB displays messages like these:
   GDB displays messages like these:
     Attaching remote machine across net...
     Attaching remote machine across net...
     Connected to tt.
     Connected to tt.
   GDB then attempts to read the symbol tables of any object modules
   GDB then attempts to read the symbol tables of any object modules
loaded into the VxWorks target since it was last booted.  GDB locates
loaded into the VxWorks target since it was last booted.  GDB locates
these files by searching the directories listed in the command search
these files by searching the directories listed in the command search
path (*note Your Program's Environment: Environment.); if it fails to
path (*note Your Program's Environment: Environment.); if it fails to
find an object file, it displays a message such as:
find an object file, it displays a message such as:
     prog.o: No such file or directory.
     prog.o: No such file or directory.
   When this happens, add the appropriate directory to the search path
   When this happens, add the appropriate directory to the search path
with the GDB command `path', and execute the `target' command again.
with the GDB command `path', and execute the `target' command again.


File: gdb.info,  Node: VxWorks Download,  Next: VxWorks Attach,  Prev: VxWorks Connection,  Up: VxWorks
File: gdb.info,  Node: VxWorks Download,  Next: VxWorks Attach,  Prev: VxWorks Connection,  Up: VxWorks
18.2.1.2 VxWorks Download
18.2.1.2 VxWorks Download
.........................
.........................
If you have connected to the VxWorks target and you want to debug an
If you have connected to the VxWorks target and you want to debug an
object that has not yet been loaded, you can use the GDB `load' command
object that has not yet been loaded, you can use the GDB `load' command
to download a file from Unix to VxWorks incrementally.  The object file
to download a file from Unix to VxWorks incrementally.  The object file
given as an argument to the `load' command is actually opened twice:
given as an argument to the `load' command is actually opened twice:
first by the VxWorks target in order to download the code, then by GDB
first by the VxWorks target in order to download the code, then by GDB
in order to read the symbol table.  This can lead to problems if the
in order to read the symbol table.  This can lead to problems if the
current working directories on the two systems differ.  If both systems
current working directories on the two systems differ.  If both systems
have NFS mounted the same filesystems, you can avoid these problems by
have NFS mounted the same filesystems, you can avoid these problems by
using absolute paths.  Otherwise, it is simplest to set the working
using absolute paths.  Otherwise, it is simplest to set the working
directory on both systems to the directory in which the object file
directory on both systems to the directory in which the object file
resides, and then to reference the file by its name, without any path.
resides, and then to reference the file by its name, without any path.
For instance, a program `prog.o' may reside in `VXPATH/vw/demo/rdb' in
For instance, a program `prog.o' may reside in `VXPATH/vw/demo/rdb' in
VxWorks and in `HOSTPATH/vw/demo/rdb' on the host.  To load this
VxWorks and in `HOSTPATH/vw/demo/rdb' on the host.  To load this
program, type this on VxWorks:
program, type this on VxWorks:
     -> cd "VXPATH/vw/demo/rdb"
     -> cd "VXPATH/vw/demo/rdb"
Then, in GDB, type:
Then, in GDB, type:
     (vxgdb) cd HOSTPATH/vw/demo/rdb
     (vxgdb) cd HOSTPATH/vw/demo/rdb
     (vxgdb) load prog.o
     (vxgdb) load prog.o
   GDB displays a response similar to this:
   GDB displays a response similar to this:
     Reading symbol data from wherever/vw/demo/rdb/prog.o... done.
     Reading symbol data from wherever/vw/demo/rdb/prog.o... done.
   You can also use the `load' command to reload an object module after
   You can also use the `load' command to reload an object module after
editing and recompiling the corresponding source file.  Note that this
editing and recompiling the corresponding source file.  Note that this
makes GDB delete all currently-defined breakpoints, auto-displays, and
makes GDB delete all currently-defined breakpoints, auto-displays, and
convenience variables, and to clear the value history.  (This is
convenience variables, and to clear the value history.  (This is
necessary in order to preserve the integrity of debugger's data
necessary in order to preserve the integrity of debugger's data
structures that reference the target system's symbol table.)
structures that reference the target system's symbol table.)


File: gdb.info,  Node: VxWorks Attach,  Prev: VxWorks Download,  Up: VxWorks
File: gdb.info,  Node: VxWorks Attach,  Prev: VxWorks Download,  Up: VxWorks
18.2.1.3 Running Tasks
18.2.1.3 Running Tasks
......................
......................
You can also attach to an existing task using the `attach' command as
You can also attach to an existing task using the `attach' command as
follows:
follows:
     (vxgdb) attach TASK
     (vxgdb) attach TASK
where TASK is the VxWorks hexadecimal task ID.  The task can be running
where TASK is the VxWorks hexadecimal task ID.  The task can be running
or suspended when you attach to it.  Running tasks are suspended at the
or suspended when you attach to it.  Running tasks are suspended at the
time of attachment.
time of attachment.


File: gdb.info,  Node: Embedded Processors,  Next: Architectures,  Prev: Embedded OS,  Up: Configurations
File: gdb.info,  Node: Embedded Processors,  Next: Architectures,  Prev: Embedded OS,  Up: Configurations
18.3 Embedded Processors
18.3 Embedded Processors
========================
========================
This section goes into details specific to particular embedded
This section goes into details specific to particular embedded
configurations.
configurations.
   Whenever a specific embedded processor has a simulator, GDB allows
   Whenever a specific embedded processor has a simulator, GDB allows
to send an arbitrary command to the simulator.
to send an arbitrary command to the simulator.
`sim COMMAND'
`sim COMMAND'
     Send an arbitrary COMMAND string to the simulator.  Consult the
     Send an arbitrary COMMAND string to the simulator.  Consult the
     documentation for the specific simulator in use for information
     documentation for the specific simulator in use for information
     about acceptable commands.
     about acceptable commands.
* Menu:
* Menu:
* ARM::                         ARM RDI
* ARM::                         ARM RDI
* M32R/D::                      Renesas M32R/D
* M32R/D::                      Renesas M32R/D
* M68K::                        Motorola M68K
* M68K::                        Motorola M68K
* MIPS Embedded::               MIPS Embedded
* MIPS Embedded::               MIPS Embedded
* OpenRISC 1000::               OpenRisc 1000
* OpenRISC 1000::               OpenRisc 1000
* PA::                          HP PA Embedded
* PA::                          HP PA Embedded
* PowerPC Embedded::            PowerPC Embedded
* PowerPC Embedded::            PowerPC Embedded
* Sparclet::                    Tsqware Sparclet
* Sparclet::                    Tsqware Sparclet
* Sparclite::                   Fujitsu Sparclite
* Sparclite::                   Fujitsu Sparclite
* Z8000::                       Zilog Z8000
* Z8000::                       Zilog Z8000
* AVR::                         Atmel AVR
* AVR::                         Atmel AVR
* CRIS::                        CRIS
* CRIS::                        CRIS
* Super-H::                     Renesas Super-H
* Super-H::                     Renesas Super-H


File: gdb.info,  Node: ARM,  Next: M32R/D,  Up: Embedded Processors
File: gdb.info,  Node: ARM,  Next: M32R/D,  Up: Embedded Processors
18.3.1 ARM
18.3.1 ARM
----------
----------
`target rdi DEV'
`target rdi DEV'
     ARM Angel monitor, via RDI library interface to ADP protocol.  You
     ARM Angel monitor, via RDI library interface to ADP protocol.  You
     may use this target to communicate with both boards running the
     may use this target to communicate with both boards running the
     Angel monitor, or with the EmbeddedICE JTAG debug device.
     Angel monitor, or with the EmbeddedICE JTAG debug device.
`target rdp DEV'
`target rdp DEV'
     ARM Demon monitor.
     ARM Demon monitor.
   GDB provides the following ARM-specific commands:
   GDB provides the following ARM-specific commands:
`set arm disassembler'
`set arm disassembler'
     This commands selects from a list of disassembly styles.  The
     This commands selects from a list of disassembly styles.  The
     `"std"' style is the standard style.
     `"std"' style is the standard style.
`show arm disassembler'
`show arm disassembler'
     Show the current disassembly style.
     Show the current disassembly style.
`set arm apcs32'
`set arm apcs32'
     This command toggles ARM operation mode between 32-bit and 26-bit.
     This command toggles ARM operation mode between 32-bit and 26-bit.
`show arm apcs32'
`show arm apcs32'
     Display the current usage of the ARM 32-bit mode.
     Display the current usage of the ARM 32-bit mode.
`set arm fpu FPUTYPE'
`set arm fpu FPUTYPE'
     This command sets the ARM floating-point unit (FPU) type.  The
     This command sets the ARM floating-point unit (FPU) type.  The
     argument FPUTYPE can be one of these:
     argument FPUTYPE can be one of these:
    `auto'
    `auto'
          Determine the FPU type by querying the OS ABI.
          Determine the FPU type by querying the OS ABI.
    `softfpa'
    `softfpa'
          Software FPU, with mixed-endian doubles on little-endian ARM
          Software FPU, with mixed-endian doubles on little-endian ARM
          processors.
          processors.
    `fpa'
    `fpa'
          GCC-compiled FPA co-processor.
          GCC-compiled FPA co-processor.
    `softvfp'
    `softvfp'
          Software FPU with pure-endian doubles.
          Software FPU with pure-endian doubles.
    `vfp'
    `vfp'
          VFP co-processor.
          VFP co-processor.
`show arm fpu'
`show arm fpu'
     Show the current type of the FPU.
     Show the current type of the FPU.
`set arm abi'
`set arm abi'
     This command forces GDB to use the specified ABI.
     This command forces GDB to use the specified ABI.
`show arm abi'
`show arm abi'
     Show the currently used ABI.
     Show the currently used ABI.
`set debug arm'
`set debug arm'
     Toggle whether to display ARM-specific debugging messages from the
     Toggle whether to display ARM-specific debugging messages from the
     ARM target support subsystem.
     ARM target support subsystem.
`show debug arm'
`show debug arm'
     Show whether ARM-specific debugging messages are enabled.
     Show whether ARM-specific debugging messages are enabled.
   The following commands are available when an ARM target is debugged
   The following commands are available when an ARM target is debugged
using the RDI interface:
using the RDI interface:
`rdilogfile [FILE]'
`rdilogfile [FILE]'
     Set the filename for the ADP (Angel Debugger Protocol) packet log.
     Set the filename for the ADP (Angel Debugger Protocol) packet log.
     With an argument, sets the log file to the specified FILE.  With
     With an argument, sets the log file to the specified FILE.  With
     no argument, show the current log file name.  The default log file
     no argument, show the current log file name.  The default log file
     is `rdi.log'.
     is `rdi.log'.
`rdilogenable [ARG]'
`rdilogenable [ARG]'
     Control logging of ADP packets.  With an argument of 1 or `"yes"'
     Control logging of ADP packets.  With an argument of 1 or `"yes"'
     enables logging, with an argument 0 or `"no"' disables it.  With
     enables logging, with an argument 0 or `"no"' disables it.  With
     no arguments displays the current setting.  When logging is
     no arguments displays the current setting.  When logging is
     enabled, ADP packets exchanged between GDB and the RDI target
     enabled, ADP packets exchanged between GDB and the RDI target
     device are logged to a file.
     device are logged to a file.
`set rdiromatzero'
`set rdiromatzero'
     Tell GDB whether the target has ROM at address 0.  If on, vector
     Tell GDB whether the target has ROM at address 0.  If on, vector
     catching is disabled, so that zero address can be used.  If off
     catching is disabled, so that zero address can be used.  If off
     (the default), vector catching is enabled.  For this command to
     (the default), vector catching is enabled.  For this command to
     take effect, it needs to be invoked prior to the `target rdi'
     take effect, it needs to be invoked prior to the `target rdi'
     command.
     command.
`show rdiromatzero'
`show rdiromatzero'
     Show the current setting of ROM at zero address.
     Show the current setting of ROM at zero address.
`set rdiheartbeat'
`set rdiheartbeat'
     Enable or disable RDI heartbeat packets.  It is not recommended to
     Enable or disable RDI heartbeat packets.  It is not recommended to
     turn on this option, since it confuses ARM and EPI JTAG interface,
     turn on this option, since it confuses ARM and EPI JTAG interface,
     as well as the Angel monitor.
     as well as the Angel monitor.
`show rdiheartbeat'
`show rdiheartbeat'
     Show the setting of RDI heartbeat packets.
     Show the setting of RDI heartbeat packets.


File: gdb.info,  Node: M32R/D,  Next: M68K,  Prev: ARM,  Up: Embedded Processors
File: gdb.info,  Node: M32R/D,  Next: M68K,  Prev: ARM,  Up: Embedded Processors
18.3.2 Renesas M32R/D and M32R/SDI
18.3.2 Renesas M32R/D and M32R/SDI
----------------------------------
----------------------------------
`target m32r DEV'
`target m32r DEV'
     Renesas M32R/D ROM monitor.
     Renesas M32R/D ROM monitor.
`target m32rsdi DEV'
`target m32rsdi DEV'
     Renesas M32R SDI server, connected via parallel port to the board.
     Renesas M32R SDI server, connected via parallel port to the board.
   The following GDB commands are specific to the M32R monitor:
   The following GDB commands are specific to the M32R monitor:
`set download-path PATH'
`set download-path PATH'
     Set the default path for finding downloadable SREC files.
     Set the default path for finding downloadable SREC files.
`show download-path'
`show download-path'
     Show the default path for downloadable SREC files.
     Show the default path for downloadable SREC files.
`set board-address ADDR'
`set board-address ADDR'
     Set the IP address for the M32R-EVA target board.
     Set the IP address for the M32R-EVA target board.
`show board-address'
`show board-address'
     Show the current IP address of the target board.
     Show the current IP address of the target board.
`set server-address ADDR'
`set server-address ADDR'
     Set the IP address for the download server, which is the GDB's
     Set the IP address for the download server, which is the GDB's
     host machine.
     host machine.
`show server-address'
`show server-address'
     Display the IP address of the download server.
     Display the IP address of the download server.
`upload [FILE]'
`upload [FILE]'
     Upload the specified SREC FILE via the monitor's Ethernet upload
     Upload the specified SREC FILE via the monitor's Ethernet upload
     capability.  If no FILE argument is given, the current executable
     capability.  If no FILE argument is given, the current executable
     file is uploaded.
     file is uploaded.
`tload [FILE]'
`tload [FILE]'
     Test the `upload' command.
     Test the `upload' command.
   The following commands are available for M32R/SDI:
   The following commands are available for M32R/SDI:
`sdireset'
`sdireset'
     This command resets the SDI connection.
     This command resets the SDI connection.
`sdistatus'
`sdistatus'
     This command shows the SDI connection status.
     This command shows the SDI connection status.
`debug_chaos'
`debug_chaos'
     Instructs the remote that M32R/Chaos debugging is to be used.
     Instructs the remote that M32R/Chaos debugging is to be used.
`use_debug_dma'
`use_debug_dma'
     Instructs the remote to use the DEBUG_DMA method of accessing
     Instructs the remote to use the DEBUG_DMA method of accessing
     memory.
     memory.
`use_mon_code'
`use_mon_code'
     Instructs the remote to use the MON_CODE method of accessing
     Instructs the remote to use the MON_CODE method of accessing
     memory.
     memory.
`use_ib_break'
`use_ib_break'
     Instructs the remote to set breakpoints by IB break.
     Instructs the remote to set breakpoints by IB break.
`use_dbt_break'
`use_dbt_break'
     Instructs the remote to set breakpoints by DBT.
     Instructs the remote to set breakpoints by DBT.


File: gdb.info,  Node: M68K,  Next: MIPS Embedded,  Prev: M32R/D,  Up: Embedded Processors
File: gdb.info,  Node: M68K,  Next: MIPS Embedded,  Prev: M32R/D,  Up: Embedded Processors
18.3.3 M68k
18.3.3 M68k
-----------
-----------
The Motorola m68k configuration includes ColdFire support, and a target
The Motorola m68k configuration includes ColdFire support, and a target
command for the following ROM monitor.
command for the following ROM monitor.
`target dbug DEV'
`target dbug DEV'
     dBUG ROM monitor for Motorola ColdFire.
     dBUG ROM monitor for Motorola ColdFire.


File: gdb.info,  Node: MIPS Embedded,  Next: OpenRISC 1000,  Prev: M68K,  Up: Embedded Processors
File: gdb.info,  Node: MIPS Embedded,  Next: OpenRISC 1000,  Prev: M68K,  Up: Embedded Processors
18.3.4 MIPS Embedded
18.3.4 MIPS Embedded
--------------------
--------------------
GDB can use the MIPS remote debugging protocol to talk to a MIPS board
GDB can use the MIPS remote debugging protocol to talk to a MIPS board
attached to a serial line.  This is available when you configure GDB
attached to a serial line.  This is available when you configure GDB
with `--target=mips-idt-ecoff'.
with `--target=mips-idt-ecoff'.
   Use these GDB commands to specify the connection to your target
   Use these GDB commands to specify the connection to your target
board:
board:
`target mips PORT'
`target mips PORT'
     To run a program on the board, start up `gdb' with the name of
     To run a program on the board, start up `gdb' with the name of
     your program as the argument.  To connect to the board, use the
     your program as the argument.  To connect to the board, use the
     command `target mips PORT', where PORT is the name of the serial
     command `target mips PORT', where PORT is the name of the serial
     port connected to the board.  If the program has not already been
     port connected to the board.  If the program has not already been
     downloaded to the board, you may use the `load' command to
     downloaded to the board, you may use the `load' command to
     download it.  You can then use all the usual GDB commands.
     download it.  You can then use all the usual GDB commands.
     For example, this sequence connects to the target board through a
     For example, this sequence connects to the target board through a
     serial port, and loads and runs a program called PROG through the
     serial port, and loads and runs a program called PROG through the
     debugger:
     debugger:
          host$ gdb PROG
          host$ gdb PROG
          GDB is free software and ...
          GDB is free software and ...
          (gdb) target mips /dev/ttyb
          (gdb) target mips /dev/ttyb
          (gdb) load PROG
          (gdb) load PROG
          (gdb) run
          (gdb) run
`target mips HOSTNAME:PORTNUMBER'
`target mips HOSTNAME:PORTNUMBER'
     On some GDB host configurations, you can specify a TCP connection
     On some GDB host configurations, you can specify a TCP connection
     (for instance, to a serial line managed by a terminal
     (for instance, to a serial line managed by a terminal
     concentrator) instead of a serial port, using the syntax
     concentrator) instead of a serial port, using the syntax
     `HOSTNAME:PORTNUMBER'.
     `HOSTNAME:PORTNUMBER'.
`target pmon PORT'
`target pmon PORT'
     PMON ROM monitor.
     PMON ROM monitor.
`target ddb PORT'
`target ddb PORT'
     NEC's DDB variant of PMON for Vr4300.
     NEC's DDB variant of PMON for Vr4300.
`target lsi PORT'
`target lsi PORT'
     LSI variant of PMON.
     LSI variant of PMON.
`target r3900 DEV'
`target r3900 DEV'
     Densan DVE-R3900 ROM monitor for Toshiba R3900 Mips.
     Densan DVE-R3900 ROM monitor for Toshiba R3900 Mips.
`target array DEV'
`target array DEV'
     Array Tech LSI33K RAID controller board.
     Array Tech LSI33K RAID controller board.
GDB also supports these special commands for MIPS targets:
GDB also supports these special commands for MIPS targets:
`set mipsfpu double'
`set mipsfpu double'
`set mipsfpu single'
`set mipsfpu single'
`set mipsfpu none'
`set mipsfpu none'
`set mipsfpu auto'
`set mipsfpu auto'
`show mipsfpu'
`show mipsfpu'
     If your target board does not support the MIPS floating point
     If your target board does not support the MIPS floating point
     coprocessor, you should use the command `set mipsfpu none' (if you
     coprocessor, you should use the command `set mipsfpu none' (if you
     need this, you may wish to put the command in your GDB init file).
     need this, you may wish to put the command in your GDB init file).
     This tells GDB how to find the return value of functions which
     This tells GDB how to find the return value of functions which
     return floating point values.  It also allows GDB to avoid saving
     return floating point values.  It also allows GDB to avoid saving
     the floating point registers when calling functions on the board.
     the floating point registers when calling functions on the board.
     If you are using a floating point coprocessor with only single
     If you are using a floating point coprocessor with only single
     precision floating point support, as on the R4650 processor, use
     precision floating point support, as on the R4650 processor, use
     the command `set mipsfpu single'.  The default double precision
     the command `set mipsfpu single'.  The default double precision
     floating point coprocessor may be selected using `set mipsfpu
     floating point coprocessor may be selected using `set mipsfpu
     double'.
     double'.
     In previous versions the only choices were double precision or no
     In previous versions the only choices were double precision or no
     floating point, so `set mipsfpu on' will select double precision
     floating point, so `set mipsfpu on' will select double precision
     and `set mipsfpu off' will select no floating point.
     and `set mipsfpu off' will select no floating point.
     As usual, you can inquire about the `mipsfpu' variable with `show
     As usual, you can inquire about the `mipsfpu' variable with `show
     mipsfpu'.
     mipsfpu'.
`set timeout SECONDS'
`set timeout SECONDS'
`set retransmit-timeout SECONDS'
`set retransmit-timeout SECONDS'
`show timeout'
`show timeout'
`show retransmit-timeout'
`show retransmit-timeout'
     You can control the timeout used while waiting for a packet, in
     You can control the timeout used while waiting for a packet, in
     the MIPS remote protocol, with the `set timeout SECONDS' command.
     the MIPS remote protocol, with the `set timeout SECONDS' command.
     The default is 5 seconds.  Similarly, you can control the timeout
     The default is 5 seconds.  Similarly, you can control the timeout
     used while waiting for an acknowledgement of a packet with the `set
     used while waiting for an acknowledgement of a packet with the `set
     retransmit-timeout SECONDS' command.  The default is 3 seconds.
     retransmit-timeout SECONDS' command.  The default is 3 seconds.
     You can inspect both values with `show timeout' and `show
     You can inspect both values with `show timeout' and `show
     retransmit-timeout'.  (These commands are _only_ available when
     retransmit-timeout'.  (These commands are _only_ available when
     GDB is configured for `--target=mips-idt-ecoff'.)
     GDB is configured for `--target=mips-idt-ecoff'.)
     The timeout set by `set timeout' does not apply when GDB is
     The timeout set by `set timeout' does not apply when GDB is
     waiting for your program to stop.  In that case, GDB waits forever
     waiting for your program to stop.  In that case, GDB waits forever
     because it has no way of knowing how long the program is going to
     because it has no way of knowing how long the program is going to
     run before stopping.
     run before stopping.
`set syn-garbage-limit NUM'
`set syn-garbage-limit NUM'
     Limit the maximum number of characters GDB should ignore when it
     Limit the maximum number of characters GDB should ignore when it
     tries to synchronize with the remote target.  The default is 10
     tries to synchronize with the remote target.  The default is 10
     characters.  Setting the limit to -1 means there's no limit.
     characters.  Setting the limit to -1 means there's no limit.
`show syn-garbage-limit'
`show syn-garbage-limit'
     Show the current limit on the number of characters to ignore when
     Show the current limit on the number of characters to ignore when
     trying to synchronize with the remote system.
     trying to synchronize with the remote system.
`set monitor-prompt PROMPT'
`set monitor-prompt PROMPT'
     Tell GDB to expect the specified PROMPT string from the remote
     Tell GDB to expect the specified PROMPT string from the remote
     monitor.  The default depends on the target:
     monitor.  The default depends on the target:
    pmon target
    pmon target
          `PMON'
          `PMON'
    ddb target
    ddb target
          `NEC010'
          `NEC010'
    lsi target
    lsi target
          `PMON>'
          `PMON>'
`show monitor-prompt'
`show monitor-prompt'
     Show the current strings GDB expects as the prompt from the remote
     Show the current strings GDB expects as the prompt from the remote
     monitor.
     monitor.
`set monitor-warnings'
`set monitor-warnings'
     Enable or disable monitor warnings about hardware breakpoints.
     Enable or disable monitor warnings about hardware breakpoints.
     This has effect only for the `lsi' target.  When on, GDB will
     This has effect only for the `lsi' target.  When on, GDB will
     display warning messages whose codes are returned by the `lsi'
     display warning messages whose codes are returned by the `lsi'
     PMON monitor for breakpoint commands.
     PMON monitor for breakpoint commands.
`show monitor-warnings'
`show monitor-warnings'
     Show the current setting of printing monitor warnings.
     Show the current setting of printing monitor warnings.
`pmon COMMAND'
`pmon COMMAND'
     This command allows sending an arbitrary COMMAND string to the
     This command allows sending an arbitrary COMMAND string to the
     monitor.  The monitor must be in debug mode for this to work.
     monitor.  The monitor must be in debug mode for this to work.


File: gdb.info,  Node: OpenRISC 1000,  Next: PA,  Prev: MIPS Embedded,  Up: Embedded Processors
File: gdb.info,  Node: OpenRISC 1000,  Next: PA,  Prev: MIPS Embedded,  Up: Embedded Processors
18.3.5 OpenRISC 1000
18.3.5 OpenRISC 1000
--------------------
--------------------
See OR1k Architecture document (`www.opencores.org') for more
See OR1k Architecture document (`www.opencores.org') for more
information about platform and commands.
information about platform and commands.
`target jtag jtag://HOST:PORT'
`target jtag jtag://HOST:PORT'
     Connects to remote JTAG server.  JTAG remote server can be either
     Connects to remote JTAG server.  JTAG remote server can be either
     an or1ksim or JTAG server, connected via parallel port to the
     an or1ksim or JTAG server, connected via parallel port to the
     board.
     board.
     Example: `target jtag jtag://localhost:9999'
     Example: `target jtag jtag://localhost:9999'
`or1ksim COMMAND'
`or1ksim COMMAND'
     If connected to `or1ksim' OpenRISC 1000 Architectural Simulator,
     If connected to `or1ksim' OpenRISC 1000 Architectural Simulator,
     proprietary commands can be executed.
     proprietary commands can be executed.
`info or1k spr'
`info or1k spr'
     Displays spr groups.
     Displays spr groups.
`info or1k spr GROUP'
`info or1k spr GROUP'
`info or1k spr GROUPNO'
`info or1k spr GROUPNO'
     Displays register names in selected group.
     Displays register names in selected group.
`info or1k spr GROUP REGISTER'
`info or1k spr GROUP REGISTER'
`info or1k spr REGISTER'
`info or1k spr REGISTER'
`info or1k spr GROUPNO REGISTERNO'
`info or1k spr GROUPNO REGISTERNO'
`info or1k spr REGISTERNO'
`info or1k spr REGISTERNO'
     Shows information about specified spr register.
     Shows information about specified spr register.
`spr GROUP REGISTER VALUE'
`spr GROUP REGISTER VALUE'
`spr REGISTER VALUE'
`spr REGISTER VALUE'
`spr GROUPNO REGISTERNO VALUE'
`spr GROUPNO REGISTERNO VALUE'
`spr REGISTERNO VALUE'
`spr REGISTERNO VALUE'
     Writes VALUE to specified spr register.
     Writes VALUE to specified spr register.
   Some implementations of OpenRISC 1000 Architecture also have
   Some implementations of OpenRISC 1000 Architecture also have
hardware trace.  It is very similar to GDB trace, except it does not
hardware trace.  It is very similar to GDB trace, except it does not
interfere with normal program execution and is thus much faster.
interfere with normal program execution and is thus much faster.
Hardware breakpoints/watchpoint triggers can be set using:
Hardware breakpoints/watchpoint triggers can be set using:
`$LEA/$LDATA'
`$LEA/$LDATA'
     Load effective address/data
     Load effective address/data
`$SEA/$SDATA'
`$SEA/$SDATA'
     Store effective address/data
     Store effective address/data
`$AEA/$ADATA'
`$AEA/$ADATA'
     Access effective address ($SEA or $LEA) or data ($SDATA/$LDATA)
     Access effective address ($SEA or $LEA) or data ($SDATA/$LDATA)
`$FETCH'
`$FETCH'
     Fetch data
     Fetch data
   When triggered, it can capture low level data, like: `PC', `LSEA',
   When triggered, it can capture low level data, like: `PC', `LSEA',
`LDATA', `SDATA', `READSPR', `WRITESPR', `INSTR'.
`LDATA', `SDATA', `READSPR', `WRITESPR', `INSTR'.
   `htrace' commands:
   `htrace' commands:
`hwatch CONDITIONAL'
`hwatch CONDITIONAL'
     Set hardware watchpoint on combination of Load/Store Effective
     Set hardware watchpoint on combination of Load/Store Effective
     Address(es) or Data.  For example:
     Address(es) or Data.  For example:
     `hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) &&
     `hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) &&
     ($SDATA >= 50)'
     ($SDATA >= 50)'
     `hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) &&
     `hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) &&
     ($SDATA >= 50)'
     ($SDATA >= 50)'
`htrace info'
`htrace info'
     Display information about current HW trace configuration.
     Display information about current HW trace configuration.
`htrace trigger CONDITIONAL'
`htrace trigger CONDITIONAL'
     Set starting criteria for HW trace.
     Set starting criteria for HW trace.
`htrace qualifier CONDITIONAL'
`htrace qualifier CONDITIONAL'
     Set acquisition qualifier for HW trace.
     Set acquisition qualifier for HW trace.
`htrace stop CONDITIONAL'
`htrace stop CONDITIONAL'
     Set HW trace stopping criteria.
     Set HW trace stopping criteria.
`htrace record [DATA]*'
`htrace record [DATA]*'
     Selects the data to be recorded, when qualifier is met and HW
     Selects the data to be recorded, when qualifier is met and HW
     trace was triggered.
     trace was triggered.
`htrace enable'
`htrace enable'
`htrace disable'
`htrace disable'
     Enables/disables the HW trace.
     Enables/disables the HW trace.
`htrace rewind [FILENAME]'
`htrace rewind [FILENAME]'
     Clears currently recorded trace data.
     Clears currently recorded trace data.
     If filename is specified, new trace file is made and any newly
     If filename is specified, new trace file is made and any newly
     collected data will be written there.
     collected data will be written there.
`htrace print [START [LEN]]'
`htrace print [START [LEN]]'
     Prints trace buffer, using current record configuration.
     Prints trace buffer, using current record configuration.
`htrace mode continuous'
`htrace mode continuous'
     Set continuous trace mode.
     Set continuous trace mode.
`htrace mode suspend'
`htrace mode suspend'
     Set suspend trace mode.
     Set suspend trace mode.


File: gdb.info,  Node: PowerPC Embedded,  Next: Sparclet,  Prev: PA,  Up: Embedded Processors
File: gdb.info,  Node: PowerPC Embedded,  Next: Sparclet,  Prev: PA,  Up: Embedded Processors
18.3.6 PowerPC Embedded
18.3.6 PowerPC Embedded
-----------------------
-----------------------
GDB provides the following PowerPC-specific commands:
GDB provides the following PowerPC-specific commands:
`set powerpc soft-float'
`set powerpc soft-float'
`show powerpc soft-float'
`show powerpc soft-float'
     Force GDB to use (or not use) a software floating point calling
     Force GDB to use (or not use) a software floating point calling
     convention.  By default, GDB selects the calling convention based
     convention.  By default, GDB selects the calling convention based
     on the selected architecture and the provided executable file.
     on the selected architecture and the provided executable file.
`set powerpc vector-abi'
`set powerpc vector-abi'
`show powerpc vector-abi'
`show powerpc vector-abi'
     Force GDB to use the specified calling convention for vector
     Force GDB to use the specified calling convention for vector
     arguments and return values.  The valid options are `auto';
     arguments and return values.  The valid options are `auto';
     `generic', to avoid vector registers even if they are present;
     `generic', to avoid vector registers even if they are present;
     `altivec', to use AltiVec registers; and `spe' to use SPE
     `altivec', to use AltiVec registers; and `spe' to use SPE
     registers.  By default, GDB selects the calling convention based
     registers.  By default, GDB selects the calling convention based
     on the selected architecture and the provided executable file.
     on the selected architecture and the provided executable file.
`target dink32 DEV'
`target dink32 DEV'
     DINK32 ROM monitor.
     DINK32 ROM monitor.
`target ppcbug DEV'
`target ppcbug DEV'
`target ppcbug1 DEV'
`target ppcbug1 DEV'
     PPCBUG ROM monitor for PowerPC.
     PPCBUG ROM monitor for PowerPC.
`target sds DEV'
`target sds DEV'
     SDS monitor, running on a PowerPC board (such as Motorola's ADS).
     SDS monitor, running on a PowerPC board (such as Motorola's ADS).
   The following commands specific to the SDS protocol are supported by
   The following commands specific to the SDS protocol are supported by
GDB:
GDB:
`set sdstimeout NSEC'
`set sdstimeout NSEC'
     Set the timeout for SDS protocol reads to be NSEC seconds.  The
     Set the timeout for SDS protocol reads to be NSEC seconds.  The
     default is 2 seconds.
     default is 2 seconds.
`show sdstimeout'
`show sdstimeout'
     Show the current value of the SDS timeout.
     Show the current value of the SDS timeout.
`sds COMMAND'
`sds COMMAND'
     Send the specified COMMAND string to the SDS monitor.
     Send the specified COMMAND string to the SDS monitor.


File: gdb.info,  Node: PA,  Next: PowerPC Embedded,  Prev: OpenRISC 1000,  Up: Embedded Processors
File: gdb.info,  Node: PA,  Next: PowerPC Embedded,  Prev: OpenRISC 1000,  Up: Embedded Processors
18.3.7 HP PA Embedded
18.3.7 HP PA Embedded
---------------------
---------------------
`target op50n DEV'
`target op50n DEV'
     OP50N monitor, running on an OKI HPPA board.
     OP50N monitor, running on an OKI HPPA board.
`target w89k DEV'
`target w89k DEV'
     W89K monitor, running on a Winbond HPPA board.
     W89K monitor, running on a Winbond HPPA board.


File: gdb.info,  Node: Sparclet,  Next: Sparclite,  Prev: PowerPC Embedded,  Up: Embedded Processors
File: gdb.info,  Node: Sparclet,  Next: Sparclite,  Prev: PowerPC Embedded,  Up: Embedded Processors
18.3.8 Tsqware Sparclet
18.3.8 Tsqware Sparclet
-----------------------
-----------------------
GDB enables developers to debug tasks running on Sparclet targets from
GDB enables developers to debug tasks running on Sparclet targets from
a Unix host.  GDB uses code that runs on both the Unix host and on the
a Unix host.  GDB uses code that runs on both the Unix host and on the
Sparclet target.  The program `gdb' is installed and executed on the
Sparclet target.  The program `gdb' is installed and executed on the
Unix host.
Unix host.
`remotetimeout ARGS'
`remotetimeout ARGS'
     GDB supports the option `remotetimeout'.  This option is set by
     GDB supports the option `remotetimeout'.  This option is set by
     the user, and  ARGS represents the number of seconds GDB waits for
     the user, and  ARGS represents the number of seconds GDB waits for
     responses.
     responses.
   When compiling for debugging, include the options `-g' to get debug
   When compiling for debugging, include the options `-g' to get debug
information and `-Ttext' to relocate the program to where you wish to
information and `-Ttext' to relocate the program to where you wish to
load it on the target.  You may also want to add the options `-n' or
load it on the target.  You may also want to add the options `-n' or
`-N' in order to reduce the size of the sections.  Example:
`-N' in order to reduce the size of the sections.  Example:
     sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N
     sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N
   You can use `objdump' to verify that the addresses are what you
   You can use `objdump' to verify that the addresses are what you
intended:
intended:
     sparclet-aout-objdump --headers --syms prog
     sparclet-aout-objdump --headers --syms prog
   Once you have set your Unix execution search path to find GDB, you
   Once you have set your Unix execution search path to find GDB, you
are ready to run GDB.  From your Unix host, run `gdb' (or
are ready to run GDB.  From your Unix host, run `gdb' (or
`sparclet-aout-gdb', depending on your installation).
`sparclet-aout-gdb', depending on your installation).
   GDB comes up showing the prompt:
   GDB comes up showing the prompt:
     (gdbslet)
     (gdbslet)
* Menu:
* Menu:
* Sparclet File::                Setting the file to debug
* Sparclet File::                Setting the file to debug
* Sparclet Connection::          Connecting to Sparclet
* Sparclet Connection::          Connecting to Sparclet
* Sparclet Download::            Sparclet download
* Sparclet Download::            Sparclet download
* Sparclet Execution::           Running and debugging
* Sparclet Execution::           Running and debugging


File: gdb.info,  Node: Sparclet File,  Next: Sparclet Connection,  Up: Sparclet
File: gdb.info,  Node: Sparclet File,  Next: Sparclet Connection,  Up: Sparclet
18.3.8.1 Setting File to Debug
18.3.8.1 Setting File to Debug
..............................
..............................
The GDB command `file' lets you choose with program to debug.
The GDB command `file' lets you choose with program to debug.
     (gdbslet) file prog
     (gdbslet) file prog
   GDB then attempts to read the symbol table of `prog'.  GDB locates
   GDB then attempts to read the symbol table of `prog'.  GDB locates
the file by searching the directories listed in the command search path.
the file by searching the directories listed in the command search path.
If the file was compiled with debug information (option `-g'), source
If the file was compiled with debug information (option `-g'), source
files will be searched as well.  GDB locates the source files by
files will be searched as well.  GDB locates the source files by
searching the directories listed in the directory search path (*note
searching the directories listed in the directory search path (*note
Your Program's Environment: Environment.).  If it fails to find a file,
Your Program's Environment: Environment.).  If it fails to find a file,
it displays a message such as:
it displays a message such as:
     prog: No such file or directory.
     prog: No such file or directory.
   When this happens, add the appropriate directories to the search
   When this happens, add the appropriate directories to the search
paths with the GDB commands `path' and `dir', and execute the `target'
paths with the GDB commands `path' and `dir', and execute the `target'
command again.
command again.


File: gdb.info,  Node: Sparclet Connection,  Next: Sparclet Download,  Prev: Sparclet File,  Up: Sparclet
File: gdb.info,  Node: Sparclet Connection,  Next: Sparclet Download,  Prev: Sparclet File,  Up: Sparclet
18.3.8.2 Connecting to Sparclet
18.3.8.2 Connecting to Sparclet
...............................
...............................
The GDB command `target' lets you connect to a Sparclet target.  To
The GDB command `target' lets you connect to a Sparclet target.  To
connect to a target on serial port "`ttya'", type:
connect to a target on serial port "`ttya'", type:
     (gdbslet) target sparclet /dev/ttya
     (gdbslet) target sparclet /dev/ttya
     Remote target sparclet connected to /dev/ttya
     Remote target sparclet connected to /dev/ttya
     main () at ../prog.c:3
     main () at ../prog.c:3
   GDB displays messages like these:
   GDB displays messages like these:
     Connected to ttya.
     Connected to ttya.


File: gdb.info,  Node: Sparclet Download,  Next: Sparclet Execution,  Prev: Sparclet Connection,  Up: Sparclet
File: gdb.info,  Node: Sparclet Download,  Next: Sparclet Execution,  Prev: Sparclet Connection,  Up: Sparclet
18.3.8.3 Sparclet Download
18.3.8.3 Sparclet Download
..........................
..........................
Once connected to the Sparclet target, you can use the GDB `load'
Once connected to the Sparclet target, you can use the GDB `load'
command to download the file from the host to the target.  The file
command to download the file from the host to the target.  The file
name and load offset should be given as arguments to the `load' command.
name and load offset should be given as arguments to the `load' command.
Since the file format is aout, the program must be loaded to the
Since the file format is aout, the program must be loaded to the
starting address.  You can use `objdump' to find out what this value
starting address.  You can use `objdump' to find out what this value
is.  The load offset is an offset which is added to the VMA (virtual
is.  The load offset is an offset which is added to the VMA (virtual
memory address) of each of the file's sections.  For instance, if the
memory address) of each of the file's sections.  For instance, if the
program `prog' was linked to text address 0x1201000, with data at
program `prog' was linked to text address 0x1201000, with data at
0x12010160 and bss at 0x12010170, in GDB, type:
0x12010160 and bss at 0x12010170, in GDB, type:
     (gdbslet) load prog 0x12010000
     (gdbslet) load prog 0x12010000
     Loading section .text, size 0xdb0 vma 0x12010000
     Loading section .text, size 0xdb0 vma 0x12010000
   If the code is loaded at a different address then what the program
   If the code is loaded at a different address then what the program
was linked to, you may need to use the `section' and `add-symbol-file'
was linked to, you may need to use the `section' and `add-symbol-file'
commands to tell GDB where to map the symbol table.
commands to tell GDB where to map the symbol table.


File: gdb.info,  Node: Sparclet Execution,  Prev: Sparclet Download,  Up: Sparclet
File: gdb.info,  Node: Sparclet Execution,  Prev: Sparclet Download,  Up: Sparclet
18.3.8.4 Running and Debugging
18.3.8.4 Running and Debugging
..............................
..............................
You can now begin debugging the task using GDB's execution control
You can now begin debugging the task using GDB's execution control
commands, `b', `step', `run', etc.  See the GDB manual for the list of
commands, `b', `step', `run', etc.  See the GDB manual for the list of
commands.
commands.
     (gdbslet) b main
     (gdbslet) b main
     Breakpoint 1 at 0x12010000: file prog.c, line 3.
     Breakpoint 1 at 0x12010000: file prog.c, line 3.
     (gdbslet) run
     (gdbslet) run
     Starting program: prog
     Starting program: prog
     Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3
     Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3
     3        char *symarg = 0;
     3        char *symarg = 0;
     (gdbslet) step
     (gdbslet) step
     4        char *execarg = "hello!";
     4        char *execarg = "hello!";
     (gdbslet)
     (gdbslet)


File: gdb.info,  Node: Sparclite,  Next: Z8000,  Prev: Sparclet,  Up: Embedded Processors
File: gdb.info,  Node: Sparclite,  Next: Z8000,  Prev: Sparclet,  Up: Embedded Processors
18.3.9 Fujitsu Sparclite
18.3.9 Fujitsu Sparclite
------------------------
------------------------
`target sparclite DEV'
`target sparclite DEV'
     Fujitsu sparclite boards, used only for the purpose of loading.
     Fujitsu sparclite boards, used only for the purpose of loading.
     You must use an additional command to debug the program.  For
     You must use an additional command to debug the program.  For
     example: target remote DEV using GDB standard remote protocol.
     example: target remote DEV using GDB standard remote protocol.


File: gdb.info,  Node: Z8000,  Next: AVR,  Prev: Sparclite,  Up: Embedded Processors
File: gdb.info,  Node: Z8000,  Next: AVR,  Prev: Sparclite,  Up: Embedded Processors
18.3.10 Zilog Z8000
18.3.10 Zilog Z8000
-------------------
-------------------
When configured for debugging Zilog Z8000 targets, GDB includes a Z8000
When configured for debugging Zilog Z8000 targets, GDB includes a Z8000
simulator.
simulator.
   For the Z8000 family, `target sim' simulates either the Z8002 (the
   For the Z8000 family, `target sim' simulates either the Z8002 (the
unsegmented variant of the Z8000 architecture) or the Z8001 (the
unsegmented variant of the Z8000 architecture) or the Z8001 (the
segmented variant).  The simulator recognizes which architecture is
segmented variant).  The simulator recognizes which architecture is
appropriate by inspecting the object code.
appropriate by inspecting the object code.
`target sim ARGS'
`target sim ARGS'
     Debug programs on a simulated CPU.  If the simulator supports setup
     Debug programs on a simulated CPU.  If the simulator supports setup
     options, specify them via ARGS.
     options, specify them via ARGS.
After specifying this target, you can debug programs for the simulated
After specifying this target, you can debug programs for the simulated
CPU in the same style as programs for your host computer; use the
CPU in the same style as programs for your host computer; use the
`file' command to load a new program image, the `run' command to run
`file' command to load a new program image, the `run' command to run
your program, and so on.
your program, and so on.
   As well as making available all the usual machine registers (*note
   As well as making available all the usual machine registers (*note
Registers: Registers.), the Z8000 simulator provides three additional
Registers: Registers.), the Z8000 simulator provides three additional
items of information as specially named registers:
items of information as specially named registers:
`cycles'
`cycles'
     Counts clock-ticks in the simulator.
     Counts clock-ticks in the simulator.
`insts'
`insts'
     Counts instructions run in the simulator.
     Counts instructions run in the simulator.
`time'
`time'
     Execution time in 60ths of a second.
     Execution time in 60ths of a second.
   You can refer to these values in GDB expressions with the usual
   You can refer to these values in GDB expressions with the usual
conventions; for example, `b fputc if $cycles>5000' sets a conditional
conventions; for example, `b fputc if $cycles>5000' sets a conditional
breakpoint that suspends only after at least 5000 simulated clock ticks.
breakpoint that suspends only after at least 5000 simulated clock ticks.


File: gdb.info,  Node: AVR,  Next: CRIS,  Prev: Z8000,  Up: Embedded Processors
File: gdb.info,  Node: AVR,  Next: CRIS,  Prev: Z8000,  Up: Embedded Processors
18.3.11 Atmel AVR
18.3.11 Atmel AVR
-----------------
-----------------
When configured for debugging the Atmel AVR, GDB supports the following
When configured for debugging the Atmel AVR, GDB supports the following
AVR-specific commands:
AVR-specific commands:
`info io_registers'
`info io_registers'
     This command displays information about the AVR I/O registers.  For
     This command displays information about the AVR I/O registers.  For
     each register, GDB prints its number and value.
     each register, GDB prints its number and value.


File: gdb.info,  Node: CRIS,  Next: Super-H,  Prev: AVR,  Up: Embedded Processors
File: gdb.info,  Node: CRIS,  Next: Super-H,  Prev: AVR,  Up: Embedded Processors
18.3.12 CRIS
18.3.12 CRIS
------------
------------
When configured for debugging CRIS, GDB provides the following
When configured for debugging CRIS, GDB provides the following
CRIS-specific commands:
CRIS-specific commands:
`set cris-version VER'
`set cris-version VER'
     Set the current CRIS version to VER, either `10' or `32'.  The
     Set the current CRIS version to VER, either `10' or `32'.  The
     CRIS version affects register names and sizes.  This command is
     CRIS version affects register names and sizes.  This command is
     useful in case autodetection of the CRIS version fails.
     useful in case autodetection of the CRIS version fails.
`show cris-version'
`show cris-version'
     Show the current CRIS version.
     Show the current CRIS version.
`set cris-dwarf2-cfi'
`set cris-dwarf2-cfi'
     Set the usage of DWARF-2 CFI for CRIS debugging.  The default is
     Set the usage of DWARF-2 CFI for CRIS debugging.  The default is
     `on'.  Change to `off' when using `gcc-cris' whose version is below
     `on'.  Change to `off' when using `gcc-cris' whose version is below
     `R59'.
     `R59'.
`show cris-dwarf2-cfi'
`show cris-dwarf2-cfi'
     Show the current state of using DWARF-2 CFI.
     Show the current state of using DWARF-2 CFI.
`set cris-mode MODE'
`set cris-mode MODE'
     Set the current CRIS mode to MODE.  It should only be changed when
     Set the current CRIS mode to MODE.  It should only be changed when
     debugging in guru mode, in which case it should be set to `guru'
     debugging in guru mode, in which case it should be set to `guru'
     (the default is `normal').
     (the default is `normal').
`show cris-mode'
`show cris-mode'
     Show the current CRIS mode.
     Show the current CRIS mode.


File: gdb.info,  Node: Super-H,  Prev: CRIS,  Up: Embedded Processors
File: gdb.info,  Node: Super-H,  Prev: CRIS,  Up: Embedded Processors
18.3.13 Renesas Super-H
18.3.13 Renesas Super-H
-----------------------
-----------------------
For the Renesas Super-H processor, GDB provides these commands:
For the Renesas Super-H processor, GDB provides these commands:
`regs'
`regs'
     Show the values of all Super-H registers.
     Show the values of all Super-H registers.


File: gdb.info,  Node: Architectures,  Prev: Embedded Processors,  Up: Configurations
File: gdb.info,  Node: Architectures,  Prev: Embedded Processors,  Up: Configurations
18.4 Architectures
18.4 Architectures
==================
==================
This section describes characteristics of architectures that affect all
This section describes characteristics of architectures that affect all
uses of GDB with the architecture, both native and cross.
uses of GDB with the architecture, both native and cross.
* Menu:
* Menu:
* i386::
* i386::
* A29K::
* A29K::
* Alpha::
* Alpha::
* MIPS::
* MIPS::
* HPPA::               HP PA architecture
* HPPA::               HP PA architecture
* SPU::                Cell Broadband Engine SPU architecture
* SPU::                Cell Broadband Engine SPU architecture
* PowerPC::
* PowerPC::


File: gdb.info,  Node: i386,  Next: A29K,  Up: Architectures
File: gdb.info,  Node: i386,  Next: A29K,  Up: Architectures
18.4.1 x86 Architecture-specific Issues
18.4.1 x86 Architecture-specific Issues
---------------------------------------
---------------------------------------
`set struct-convention MODE'
`set struct-convention MODE'
     Set the convention used by the inferior to return `struct's and
     Set the convention used by the inferior to return `struct's and
     `union's from functions to MODE.  Possible values of MODE are
     `union's from functions to MODE.  Possible values of MODE are
     `"pcc"', `"reg"', and `"default"' (the default).  `"default"' or
     `"pcc"', `"reg"', and `"default"' (the default).  `"default"' or
     `"pcc"' means that `struct's are returned on the stack, while
     `"pcc"' means that `struct's are returned on the stack, while
     `"reg"' means that a `struct' or a `union' whose size is 1, 2, 4,
     `"reg"' means that a `struct' or a `union' whose size is 1, 2, 4,
     or 8 bytes will be returned in a register.
     or 8 bytes will be returned in a register.
`show struct-convention'
`show struct-convention'
     Show the current setting of the convention to return `struct's
     Show the current setting of the convention to return `struct's
     from functions.
     from functions.


File: gdb.info,  Node: A29K,  Next: Alpha,  Prev: i386,  Up: Architectures
File: gdb.info,  Node: A29K,  Next: Alpha,  Prev: i386,  Up: Architectures
18.4.2 A29K
18.4.2 A29K
-----------
-----------
`set rstack_high_address ADDRESS'
`set rstack_high_address ADDRESS'
     On AMD 29000 family processors, registers are saved in a separate
     On AMD 29000 family processors, registers are saved in a separate
     "register stack".  There is no way for GDB to determine the extent
     "register stack".  There is no way for GDB to determine the extent
     of this stack.  Normally, GDB just assumes that the stack is
     of this stack.  Normally, GDB just assumes that the stack is
     "large enough".  This may result in GDB referencing memory
     "large enough".  This may result in GDB referencing memory
     locations that do not exist.  If necessary, you can get around
     locations that do not exist.  If necessary, you can get around
     this problem by specifying the ending address of the register
     this problem by specifying the ending address of the register
     stack with the `set rstack_high_address' command.  The argument
     stack with the `set rstack_high_address' command.  The argument
     should be an address, which you probably want to precede with `0x'
     should be an address, which you probably want to precede with `0x'
     to specify in hexadecimal.
     to specify in hexadecimal.
`show rstack_high_address'
`show rstack_high_address'
     Display the current limit of the register stack, on AMD 29000
     Display the current limit of the register stack, on AMD 29000
     family processors.
     family processors.


File: gdb.info,  Node: Alpha,  Next: MIPS,  Prev: A29K,  Up: Architectures
File: gdb.info,  Node: Alpha,  Next: MIPS,  Prev: A29K,  Up: Architectures
18.4.3 Alpha
18.4.3 Alpha
------------
------------
See the following section.
See the following section.


File: gdb.info,  Node: MIPS,  Next: HPPA,  Prev: Alpha,  Up: Architectures
File: gdb.info,  Node: MIPS,  Next: HPPA,  Prev: Alpha,  Up: Architectures
18.4.4 MIPS
18.4.4 MIPS
-----------
-----------
Alpha- and MIPS-based computers use an unusual stack frame, which
Alpha- and MIPS-based computers use an unusual stack frame, which
sometimes requires GDB to search backward in the object code to find
sometimes requires GDB to search backward in the object code to find
the beginning of a function.
the beginning of a function.
   To improve response time (especially for embedded applications, where
   To improve response time (especially for embedded applications, where
GDB may be restricted to a slow serial line for this search) you may
GDB may be restricted to a slow serial line for this search) you may
want to limit the size of this search, using one of these commands:
want to limit the size of this search, using one of these commands:
`set heuristic-fence-post LIMIT'
`set heuristic-fence-post LIMIT'
     Restrict GDB to examining at most LIMIT bytes in its search for
     Restrict GDB to examining at most LIMIT bytes in its search for
     the beginning of a function.  A value of 0 (the default) means
     the beginning of a function.  A value of 0 (the default) means
     there is no limit.  However, except for 0, the larger the limit
     there is no limit.  However, except for 0, the larger the limit
     the more bytes `heuristic-fence-post' must search and therefore
     the more bytes `heuristic-fence-post' must search and therefore
     the longer it takes to run.  You should only need to use this
     the longer it takes to run.  You should only need to use this
     command when debugging a stripped executable.
     command when debugging a stripped executable.
`show heuristic-fence-post'
`show heuristic-fence-post'
     Display the current limit.
     Display the current limit.
These commands are available _only_ when GDB is configured for
These commands are available _only_ when GDB is configured for
debugging programs on Alpha or MIPS processors.
debugging programs on Alpha or MIPS processors.
   Several MIPS-specific commands are available when debugging MIPS
   Several MIPS-specific commands are available when debugging MIPS
programs:
programs:
`set mips abi ARG'
`set mips abi ARG'
     Tell GDB which MIPS ABI is used by the inferior.  Possible values
     Tell GDB which MIPS ABI is used by the inferior.  Possible values
     of ARG are:
     of ARG are:
    `auto'
    `auto'
          The default ABI associated with the current binary (this is
          The default ABI associated with the current binary (this is
          the default).
          the default).
    `o32'
    `o32'
    `o64'
    `o64'
    `n32'
    `n32'
    `n64'
    `n64'
    `eabi32'
    `eabi32'
    `eabi64'
    `eabi64'
    `auto'
    `auto'
`show mips abi'
`show mips abi'
     Show the MIPS ABI used by GDB to debug the inferior.
     Show the MIPS ABI used by GDB to debug the inferior.
`set mipsfpu'
`set mipsfpu'
`show mipsfpu'
`show mipsfpu'
     *Note set mipsfpu: MIPS Embedded.
     *Note set mipsfpu: MIPS Embedded.
`set mips mask-address ARG'
`set mips mask-address ARG'
     This command determines whether the most-significant 32 bits of
     This command determines whether the most-significant 32 bits of
     64-bit MIPS addresses are masked off.  The argument ARG can be
     64-bit MIPS addresses are masked off.  The argument ARG can be
     `on', `off', or `auto'.  The latter is the default setting, which
     `on', `off', or `auto'.  The latter is the default setting, which
     lets GDB determine the correct value.
     lets GDB determine the correct value.
`show mips mask-address'
`show mips mask-address'
     Show whether the upper 32 bits of MIPS addresses are masked off or
     Show whether the upper 32 bits of MIPS addresses are masked off or
     not.
     not.
`set remote-mips64-transfers-32bit-regs'
`set remote-mips64-transfers-32bit-regs'
     This command controls compatibility with 64-bit MIPS targets that
     This command controls compatibility with 64-bit MIPS targets that
     transfer data in 32-bit quantities.  If you have an old MIPS 64
     transfer data in 32-bit quantities.  If you have an old MIPS 64
     target that transfers 32 bits for some registers, like SR and FSR,
     target that transfers 32 bits for some registers, like SR and FSR,
     and 64 bits for other registers, set this option to `on'.
     and 64 bits for other registers, set this option to `on'.
`show remote-mips64-transfers-32bit-regs'
`show remote-mips64-transfers-32bit-regs'
     Show the current setting of compatibility with older MIPS 64
     Show the current setting of compatibility with older MIPS 64
     targets.
     targets.
`set debug mips'
`set debug mips'
     This command turns on and off debugging messages for the
     This command turns on and off debugging messages for the
     MIPS-specific target code in GDB.
     MIPS-specific target code in GDB.
`show debug mips'
`show debug mips'
     Show the current setting of MIPS debugging messages.
     Show the current setting of MIPS debugging messages.


File: gdb.info,  Node: HPPA,  Next: SPU,  Prev: MIPS,  Up: Architectures
File: gdb.info,  Node: HPPA,  Next: SPU,  Prev: MIPS,  Up: Architectures
18.4.5 HPPA
18.4.5 HPPA
-----------
-----------
When GDB is debugging the HP PA architecture, it provides the following
When GDB is debugging the HP PA architecture, it provides the following
special commands:
special commands:
`set debug hppa'
`set debug hppa'
     This command determines whether HPPA architecture-specific
     This command determines whether HPPA architecture-specific
     debugging messages are to be displayed.
     debugging messages are to be displayed.
`show debug hppa'
`show debug hppa'
     Show whether HPPA debugging messages are displayed.
     Show whether HPPA debugging messages are displayed.
`maint print unwind ADDRESS'
`maint print unwind ADDRESS'
     This command displays the contents of the unwind table entry at the
     This command displays the contents of the unwind table entry at the
     given ADDRESS.
     given ADDRESS.


File: gdb.info,  Node: SPU,  Next: PowerPC,  Prev: HPPA,  Up: Architectures
File: gdb.info,  Node: SPU,  Next: PowerPC,  Prev: HPPA,  Up: Architectures
18.4.6 Cell Broadband Engine SPU architecture
18.4.6 Cell Broadband Engine SPU architecture
---------------------------------------------
---------------------------------------------
When GDB is debugging the Cell Broadband Engine SPU architecture, it
When GDB is debugging the Cell Broadband Engine SPU architecture, it
provides the following special commands:
provides the following special commands:
`info spu event'
`info spu event'
     Display SPU event facility status.  Shows current event mask and
     Display SPU event facility status.  Shows current event mask and
     pending event status.
     pending event status.
`info spu signal'
`info spu signal'
     Display SPU signal notification facility status.  Shows pending
     Display SPU signal notification facility status.  Shows pending
     signal-control word and signal notification mode of both signal
     signal-control word and signal notification mode of both signal
     notification channels.
     notification channels.
`info spu mailbox'
`info spu mailbox'
     Display SPU mailbox facility status.  Shows all pending entries,
     Display SPU mailbox facility status.  Shows all pending entries,
     in order of processing, in each of the SPU Write Outbound, SPU
     in order of processing, in each of the SPU Write Outbound, SPU
     Write Outbound Interrupt, and SPU Read Inbound mailboxes.
     Write Outbound Interrupt, and SPU Read Inbound mailboxes.
`info spu dma'
`info spu dma'
     Display MFC DMA status.  Shows all pending commands in the MFC DMA
     Display MFC DMA status.  Shows all pending commands in the MFC DMA
     queue.  For each entry, opcode, tag, class IDs, effective and
     queue.  For each entry, opcode, tag, class IDs, effective and
     local store addresses and transfer size are shown.
     local store addresses and transfer size are shown.
`info spu proxydma'
`info spu proxydma'
     Display MFC Proxy-DMA status.  Shows all pending commands in the
     Display MFC Proxy-DMA status.  Shows all pending commands in the
     MFC Proxy-DMA queue.  For each entry, opcode, tag, class IDs,
     MFC Proxy-DMA queue.  For each entry, opcode, tag, class IDs,
     effective and local store addresses and transfer size are shown.
     effective and local store addresses and transfer size are shown.


File: gdb.info,  Node: PowerPC,  Prev: SPU,  Up: Architectures
File: gdb.info,  Node: PowerPC,  Prev: SPU,  Up: Architectures
18.4.7 PowerPC
18.4.7 PowerPC
--------------
--------------
When GDB is debugging the PowerPC architecture, it provides a set of
When GDB is debugging the PowerPC architecture, it provides a set of
pseudo-registers to enable inspection of 128-bit wide Decimal Floating
pseudo-registers to enable inspection of 128-bit wide Decimal Floating
Point numbers stored in the floating point registers. These values must
Point numbers stored in the floating point registers. These values must
be stored in two consecutive registers, always starting at an even
be stored in two consecutive registers, always starting at an even
register like `f0' or `f2'.
register like `f0' or `f2'.
   The pseudo-registers go from `$dl0' through `$dl15', and are formed
   The pseudo-registers go from `$dl0' through `$dl15', and are formed
by joining the even/odd register pairs `f0' and `f1' for `$dl0', `f2'
by joining the even/odd register pairs `f0' and `f1' for `$dl0', `f2'
and `f3' for `$dl1' and so on.
and `f3' for `$dl1' and so on.


File: gdb.info,  Node: Controlling GDB,  Next: Sequences,  Prev: Configurations,  Up: Top
File: gdb.info,  Node: Controlling GDB,  Next: Sequences,  Prev: Configurations,  Up: Top
19 Controlling GDB
19 Controlling GDB
******************
******************
You can alter the way GDB interacts with you by using the `set'
You can alter the way GDB interacts with you by using the `set'
command.  For commands controlling how GDB displays data, see *Note
command.  For commands controlling how GDB displays data, see *Note
Print Settings: Print Settings.  Other settings are described here.
Print Settings: Print Settings.  Other settings are described here.
* Menu:
* Menu:
* Prompt::                      Prompt
* Prompt::                      Prompt
* Editing::                     Command editing
* Editing::                     Command editing
* Command History::             Command history
* Command History::             Command history
* Screen Size::                 Screen size
* Screen Size::                 Screen size
* Numbers::                     Numbers
* Numbers::                     Numbers
* ABI::                         Configuring the current ABI
* ABI::                         Configuring the current ABI
* Messages/Warnings::           Optional warnings and messages
* Messages/Warnings::           Optional warnings and messages
* Debugging Output::            Optional messages about internal happenings
* Debugging Output::            Optional messages about internal happenings


File: gdb.info,  Node: Prompt,  Next: Editing,  Up: Controlling GDB
File: gdb.info,  Node: Prompt,  Next: Editing,  Up: Controlling GDB
19.1 Prompt
19.1 Prompt
===========
===========
GDB indicates its readiness to read a command by printing a string
GDB indicates its readiness to read a command by printing a string
called the "prompt".  This string is normally `(gdb)'.  You can change
called the "prompt".  This string is normally `(gdb)'.  You can change
the prompt string with the `set prompt' command.  For instance, when
the prompt string with the `set prompt' command.  For instance, when
debugging GDB with GDB, it is useful to change the prompt in one of the
debugging GDB with GDB, it is useful to change the prompt in one of the
GDB sessions so that you can always tell which one you are talking to.
GDB sessions so that you can always tell which one you are talking to.
   _Note:_  `set prompt' does not add a space for you after the prompt
   _Note:_  `set prompt' does not add a space for you after the prompt
you set.  This allows you to set a prompt which ends in a space or a
you set.  This allows you to set a prompt which ends in a space or a
prompt that does not.
prompt that does not.
`set prompt NEWPROMPT'
`set prompt NEWPROMPT'
     Directs GDB to use NEWPROMPT as its prompt string henceforth.
     Directs GDB to use NEWPROMPT as its prompt string henceforth.
`show prompt'
`show prompt'
     Prints a line of the form: `Gdb's prompt is: YOUR-PROMPT'
     Prints a line of the form: `Gdb's prompt is: YOUR-PROMPT'


File: gdb.info,  Node: Editing,  Next: Command History,  Prev: Prompt,  Up: Controlling GDB
File: gdb.info,  Node: Editing,  Next: Command History,  Prev: Prompt,  Up: Controlling GDB
19.2 Command Editing
19.2 Command Editing
====================
====================
GDB reads its input commands via the "Readline" interface.  This GNU
GDB reads its input commands via the "Readline" interface.  This GNU
library provides consistent behavior for programs which provide a
library provides consistent behavior for programs which provide a
command line interface to the user.  Advantages are GNU Emacs-style or
command line interface to the user.  Advantages are GNU Emacs-style or
"vi"-style inline editing of commands, `csh'-like history substitution,
"vi"-style inline editing of commands, `csh'-like history substitution,
and a storage and recall of command history across debugging sessions.
and a storage and recall of command history across debugging sessions.
   You may control the behavior of command line editing in GDB with the
   You may control the behavior of command line editing in GDB with the
command `set'.
command `set'.
`set editing'
`set editing'
`set editing on'
`set editing on'
     Enable command line editing (enabled by default).
     Enable command line editing (enabled by default).
`set editing off'
`set editing off'
     Disable command line editing.
     Disable command line editing.
`show editing'
`show editing'
     Show whether command line editing is enabled.
     Show whether command line editing is enabled.
   *Note Command Line Editing::, for more details about the Readline
   *Note Command Line Editing::, for more details about the Readline
interface.  Users unfamiliar with GNU Emacs or `vi' are encouraged to
interface.  Users unfamiliar with GNU Emacs or `vi' are encouraged to
read that chapter.
read that chapter.


File: gdb.info,  Node: Command History,  Next: Screen Size,  Prev: Editing,  Up: Controlling GDB
File: gdb.info,  Node: Command History,  Next: Screen Size,  Prev: Editing,  Up: Controlling GDB
19.3 Command History
19.3 Command History
====================
====================
GDB can keep track of the commands you type during your debugging
GDB can keep track of the commands you type during your debugging
sessions, so that you can be certain of precisely what happened.  Use
sessions, so that you can be certain of precisely what happened.  Use
these commands to manage the GDB command history facility.
these commands to manage the GDB command history facility.
   GDB uses the GNU History library, a part of the Readline package, to
   GDB uses the GNU History library, a part of the Readline package, to
provide the history facility.  *Note Using History Interactively::, for
provide the history facility.  *Note Using History Interactively::, for
the detailed description of the History library.
the detailed description of the History library.
   To issue a command to GDB without affecting certain aspects of the
   To issue a command to GDB without affecting certain aspects of the
state which is seen by users, prefix it with `server ' (*note Server
state which is seen by users, prefix it with `server ' (*note Server
Prefix::).  This means that this command will not affect the command
Prefix::).  This means that this command will not affect the command
history, nor will it affect GDB's notion of which command to repeat if
history, nor will it affect GDB's notion of which command to repeat if
 is pressed on a line by itself.
 is pressed on a line by itself.
   The server prefix does not affect the recording of values into the
   The server prefix does not affect the recording of values into the
value history; to print a value without recording it into the value
value history; to print a value without recording it into the value
history, use the `output' command instead of the `print' command.
history, use the `output' command instead of the `print' command.
   Here is the description of GDB commands related to command history.
   Here is the description of GDB commands related to command history.
`set history filename FNAME'
`set history filename FNAME'
     Set the name of the GDB command history file to FNAME.  This is
     Set the name of the GDB command history file to FNAME.  This is
     the file where GDB reads an initial command history list, and
     the file where GDB reads an initial command history list, and
     where it writes the command history from this session when it
     where it writes the command history from this session when it
     exits.  You can access this list through history expansion or
     exits.  You can access this list through history expansion or
     through the history command editing characters listed below.  This
     through the history command editing characters listed below.  This
     file defaults to the value of the environment variable
     file defaults to the value of the environment variable
     `GDBHISTFILE', or to `./.gdb_history' (`./_gdb_history' on MS-DOS)
     `GDBHISTFILE', or to `./.gdb_history' (`./_gdb_history' on MS-DOS)
     if this variable is not set.
     if this variable is not set.
`set history save'
`set history save'
`set history save on'
`set history save on'
     Record command history in a file, whose name may be specified with
     Record command history in a file, whose name may be specified with
     the `set history filename' command.  By default, this option is
     the `set history filename' command.  By default, this option is
     disabled.
     disabled.
`set history save off'
`set history save off'
     Stop recording command history in a file.
     Stop recording command history in a file.
`set history size SIZE'
`set history size SIZE'
     Set the number of commands which GDB keeps in its history list.
     Set the number of commands which GDB keeps in its history list.
     This defaults to the value of the environment variable `HISTSIZE',
     This defaults to the value of the environment variable `HISTSIZE',
     or to 256 if this variable is not set.
     or to 256 if this variable is not set.
   History expansion assigns special meaning to the character `!'.
   History expansion assigns special meaning to the character `!'.
*Note Event Designators::, for more details.
*Note Event Designators::, for more details.
   Since `!' is also the logical not operator in C, history expansion
   Since `!' is also the logical not operator in C, history expansion
is off by default. If you decide to enable history expansion with the
is off by default. If you decide to enable history expansion with the
`set history expansion on' command, you may sometimes need to follow
`set history expansion on' command, you may sometimes need to follow
`!' (when it is used as logical not, in an expression) with a space or
`!' (when it is used as logical not, in an expression) with a space or
a tab to prevent it from being expanded.  The readline history
a tab to prevent it from being expanded.  The readline history
facilities do not attempt substitution on the strings `!=' and `!(',
facilities do not attempt substitution on the strings `!=' and `!(',
even when history expansion is enabled.
even when history expansion is enabled.
   The commands to control history expansion are:
   The commands to control history expansion are:
`set history expansion on'
`set history expansion on'
`set history expansion'
`set history expansion'
     Enable history expansion.  History expansion is off by default.
     Enable history expansion.  History expansion is off by default.
`set history expansion off'
`set history expansion off'
     Disable history expansion.
     Disable history expansion.
`show history'
`show history'
`show history filename'
`show history filename'
`show history save'
`show history save'
`show history size'
`show history size'
`show history expansion'
`show history expansion'
     These commands display the state of the GDB history parameters.
     These commands display the state of the GDB history parameters.
     `show history' by itself displays all four states.
     `show history' by itself displays all four states.
`show commands'
`show commands'
     Display the last ten commands in the command history.
     Display the last ten commands in the command history.
`show commands N'
`show commands N'
     Print ten commands centered on command number N.
     Print ten commands centered on command number N.
`show commands +'
`show commands +'
     Print ten commands just after the commands last printed.
     Print ten commands just after the commands last printed.


File: gdb.info,  Node: Screen Size,  Next: Numbers,  Prev: Command History,  Up: Controlling GDB
File: gdb.info,  Node: Screen Size,  Next: Numbers,  Prev: Command History,  Up: Controlling GDB
19.4 Screen Size
19.4 Screen Size
================
================
Certain commands to GDB may produce large amounts of information output
Certain commands to GDB may produce large amounts of information output
to the screen.  To help you read all of it, GDB pauses and asks you for
to the screen.  To help you read all of it, GDB pauses and asks you for
input at the end of each page of output.  Type  when you want to
input at the end of each page of output.  Type  when you want to
continue the output, or `q' to discard the remaining output.  Also, the
continue the output, or `q' to discard the remaining output.  Also, the
screen width setting determines when to wrap lines of output.
screen width setting determines when to wrap lines of output.
Depending on what is being printed, GDB tries to break the line at a
Depending on what is being printed, GDB tries to break the line at a
readable place, rather than simply letting it overflow onto the
readable place, rather than simply letting it overflow onto the
following line.
following line.
   Normally GDB knows the size of the screen from the terminal driver
   Normally GDB knows the size of the screen from the terminal driver
software.  For example, on Unix GDB uses the termcap data base together
software.  For example, on Unix GDB uses the termcap data base together
with the value of the `TERM' environment variable and the `stty rows'
with the value of the `TERM' environment variable and the `stty rows'
and `stty cols' settings.  If this is not correct, you can override it
and `stty cols' settings.  If this is not correct, you can override it
with the `set height' and `set width' commands:
with the `set height' and `set width' commands:
`set height LPP'
`set height LPP'
`show height'
`show height'
`set width CPL'
`set width CPL'
`show width'
`show width'
     These `set' commands specify a screen height of LPP lines and a
     These `set' commands specify a screen height of LPP lines and a
     screen width of CPL characters.  The associated `show' commands
     screen width of CPL characters.  The associated `show' commands
     display the current settings.
     display the current settings.
     If you specify a height of zero lines, GDB does not pause during
     If you specify a height of zero lines, GDB does not pause during
     output no matter how long the output is.  This is useful if output
     output no matter how long the output is.  This is useful if output
     is to a file or to an editor buffer.
     is to a file or to an editor buffer.
     Likewise, you can specify `set width 0' to prevent GDB from
     Likewise, you can specify `set width 0' to prevent GDB from
     wrapping its output.
     wrapping its output.
`set pagination on'
`set pagination on'
`set pagination off'
`set pagination off'
     Turn the output pagination on or off; the default is on.  Turning
     Turn the output pagination on or off; the default is on.  Turning
     pagination off is the alternative to `set height 0'.
     pagination off is the alternative to `set height 0'.
`show pagination'
`show pagination'
     Show the current pagination mode.
     Show the current pagination mode.


File: gdb.info,  Node: Numbers,  Next: ABI,  Prev: Screen Size,  Up: Controlling GDB
File: gdb.info,  Node: Numbers,  Next: ABI,  Prev: Screen Size,  Up: Controlling GDB
19.5 Numbers
19.5 Numbers
============
============
You can always enter numbers in octal, decimal, or hexadecimal in GDB
You can always enter numbers in octal, decimal, or hexadecimal in GDB
by the usual conventions: octal numbers begin with `0', decimal numbers
by the usual conventions: octal numbers begin with `0', decimal numbers
end with `.', and hexadecimal numbers begin with `0x'.  Numbers that
end with `.', and hexadecimal numbers begin with `0x'.  Numbers that
neither begin with `0' or `0x', nor end with a `.' are, by default,
neither begin with `0' or `0x', nor end with a `.' are, by default,
entered in base 10; likewise, the default display for numbers--when no
entered in base 10; likewise, the default display for numbers--when no
particular format is specified--is base 10.  You can change the default
particular format is specified--is base 10.  You can change the default
base for both input and output with the commands described below.
base for both input and output with the commands described below.
`set input-radix BASE'
`set input-radix BASE'
     Set the default base for numeric input.  Supported choices for
     Set the default base for numeric input.  Supported choices for
     BASE are decimal 8, 10, or 16.  BASE must itself be specified
     BASE are decimal 8, 10, or 16.  BASE must itself be specified
     either unambiguously or using the current input radix; for
     either unambiguously or using the current input radix; for
     example, any of
     example, any of
          set input-radix 012
          set input-radix 012
          set input-radix 10.
          set input-radix 10.
          set input-radix 0xa
          set input-radix 0xa
     sets the input base to decimal.  On the other hand, `set
     sets the input base to decimal.  On the other hand, `set
     input-radix 10' leaves the input radix unchanged, no matter what
     input-radix 10' leaves the input radix unchanged, no matter what
     it was, since `10', being without any leading or trailing signs of
     it was, since `10', being without any leading or trailing signs of
     its base, is interpreted in the current radix.  Thus, if the
     its base, is interpreted in the current radix.  Thus, if the
     current radix is 16, `10' is interpreted in hex, i.e. as 16
     current radix is 16, `10' is interpreted in hex, i.e. as 16
     decimal, which doesn't change the radix.
     decimal, which doesn't change the radix.
`set output-radix BASE'
`set output-radix BASE'
     Set the default base for numeric display.  Supported choices for
     Set the default base for numeric display.  Supported choices for
     BASE are decimal 8, 10, or 16.  BASE must itself be specified
     BASE are decimal 8, 10, or 16.  BASE must itself be specified
     either unambiguously or using the current input radix.
     either unambiguously or using the current input radix.
`show input-radix'
`show input-radix'
     Display the current default base for numeric input.
     Display the current default base for numeric input.
`show output-radix'
`show output-radix'
     Display the current default base for numeric display.
     Display the current default base for numeric display.
`set radix [BASE]'
`set radix [BASE]'
`show radix'
`show radix'
     These commands set and show the default base for both input and
     These commands set and show the default base for both input and
     output of numbers.  `set radix' sets the radix of input and output
     output of numbers.  `set radix' sets the radix of input and output
     to the same base; without an argument, it resets the radix back to
     to the same base; without an argument, it resets the radix back to
     its default value of 10.
     its default value of 10.


File: gdb.info,  Node: ABI,  Next: Messages/Warnings,  Prev: Numbers,  Up: Controlling GDB
File: gdb.info,  Node: ABI,  Next: Messages/Warnings,  Prev: Numbers,  Up: Controlling GDB
19.6 Configuring the Current ABI
19.6 Configuring the Current ABI
================================
================================
GDB can determine the "ABI" (Application Binary Interface) of your
GDB can determine the "ABI" (Application Binary Interface) of your
application automatically.  However, sometimes you need to override its
application automatically.  However, sometimes you need to override its
conclusions.  Use these commands to manage GDB's view of the current
conclusions.  Use these commands to manage GDB's view of the current
ABI.
ABI.
   One GDB configuration can debug binaries for multiple operating
   One GDB configuration can debug binaries for multiple operating
system targets, either via remote debugging or native emulation.  GDB
system targets, either via remote debugging or native emulation.  GDB
will autodetect the "OS ABI" (Operating System ABI) in use, but you can
will autodetect the "OS ABI" (Operating System ABI) in use, but you can
override its conclusion using the `set osabi' command.  One example
override its conclusion using the `set osabi' command.  One example
where this is useful is in debugging of binaries which use an alternate
where this is useful is in debugging of binaries which use an alternate
C library (e.g. UCLIBC for GNU/Linux) which does not have the same
C library (e.g. UCLIBC for GNU/Linux) which does not have the same
identifying marks that the standard C library for your platform
identifying marks that the standard C library for your platform
provides.
provides.
`show osabi'
`show osabi'
     Show the OS ABI currently in use.
     Show the OS ABI currently in use.
`set osabi'
`set osabi'
     With no argument, show the list of registered available OS ABI's.
     With no argument, show the list of registered available OS ABI's.
`set osabi ABI'
`set osabi ABI'
     Set the current OS ABI to ABI.
     Set the current OS ABI to ABI.
   Generally, the way that an argument of type `float' is passed to a
   Generally, the way that an argument of type `float' is passed to a
function depends on whether the function is prototyped.  For a
function depends on whether the function is prototyped.  For a
prototyped (i.e. ANSI/ISO style) function, `float' arguments are passed
prototyped (i.e. ANSI/ISO style) function, `float' arguments are passed
unchanged, according to the architecture's convention for `float'.  For
unchanged, according to the architecture's convention for `float'.  For
unprototyped (i.e. K&R style) functions, `float' arguments are first
unprototyped (i.e. K&R style) functions, `float' arguments are first
promoted to type `double' and then passed.
promoted to type `double' and then passed.
   Unfortunately, some forms of debug information do not reliably
   Unfortunately, some forms of debug information do not reliably
indicate whether a function is prototyped.  If GDB calls a function
indicate whether a function is prototyped.  If GDB calls a function
that is not marked as prototyped, it consults `set
that is not marked as prototyped, it consults `set
coerce-float-to-double'.
coerce-float-to-double'.
`set coerce-float-to-double'
`set coerce-float-to-double'
`set coerce-float-to-double on'
`set coerce-float-to-double on'
     Arguments of type `float' will be promoted to `double' when passed
     Arguments of type `float' will be promoted to `double' when passed
     to an unprototyped function.  This is the default setting.
     to an unprototyped function.  This is the default setting.
`set coerce-float-to-double off'
`set coerce-float-to-double off'
     Arguments of type `float' will be passed directly to unprototyped
     Arguments of type `float' will be passed directly to unprototyped
     functions.
     functions.
`show coerce-float-to-double'
`show coerce-float-to-double'
     Show the current setting of promoting `float' to `double'.
     Show the current setting of promoting `float' to `double'.
   GDB needs to know the ABI used for your program's C++ objects.  The
   GDB needs to know the ABI used for your program's C++ objects.  The
correct C++ ABI depends on which C++ compiler was used to build your
correct C++ ABI depends on which C++ compiler was used to build your
application.  GDB only fully supports programs with a single C++ ABI;
application.  GDB only fully supports programs with a single C++ ABI;
if your program contains code using multiple C++ ABI's or if GDB can
if your program contains code using multiple C++ ABI's or if GDB can
not identify your program's ABI correctly, you can tell GDB which ABI
not identify your program's ABI correctly, you can tell GDB which ABI
to use.  Currently supported ABI's include "gnu-v2", for `g++' versions
to use.  Currently supported ABI's include "gnu-v2", for `g++' versions
before 3.0, "gnu-v3", for `g++' versions 3.0 and later, and "hpaCC" for
before 3.0, "gnu-v3", for `g++' versions 3.0 and later, and "hpaCC" for
the HP ANSI C++ compiler.  Other C++ compilers may use the "gnu-v2" or
the HP ANSI C++ compiler.  Other C++ compilers may use the "gnu-v2" or
"gnu-v3" ABI's as well.  The default setting is "auto".
"gnu-v3" ABI's as well.  The default setting is "auto".
`show cp-abi'
`show cp-abi'
     Show the C++ ABI currently in use.
     Show the C++ ABI currently in use.
`set cp-abi'
`set cp-abi'
     With no argument, show the list of supported C++ ABI's.
     With no argument, show the list of supported C++ ABI's.
`set cp-abi ABI'
`set cp-abi ABI'
`set cp-abi auto'
`set cp-abi auto'
     Set the current C++ ABI to ABI, or return to automatic detection.
     Set the current C++ ABI to ABI, or return to automatic detection.


File: gdb.info,  Node: Messages/Warnings,  Next: Debugging Output,  Prev: ABI,  Up: Controlling GDB
File: gdb.info,  Node: Messages/Warnings,  Next: Debugging Output,  Prev: ABI,  Up: Controlling GDB
19.7 Optional Warnings and Messages
19.7 Optional Warnings and Messages
===================================
===================================
By default, GDB is silent about its inner workings.  If you are running
By default, GDB is silent about its inner workings.  If you are running
on a slow machine, you may want to use the `set verbose' command.  This
on a slow machine, you may want to use the `set verbose' command.  This
makes GDB tell you when it does a lengthy internal operation, so you
makes GDB tell you when it does a lengthy internal operation, so you
will not think it has crashed.
will not think it has crashed.
   Currently, the messages controlled by `set verbose' are those which
   Currently, the messages controlled by `set verbose' are those which
announce that the symbol table for a source file is being read; see
announce that the symbol table for a source file is being read; see
`symbol-file' in *Note Commands to Specify Files: Files.
`symbol-file' in *Note Commands to Specify Files: Files.
`set verbose on'
`set verbose on'
     Enables GDB output of certain informational messages.
     Enables GDB output of certain informational messages.
`set verbose off'
`set verbose off'
     Disables GDB output of certain informational messages.
     Disables GDB output of certain informational messages.
`show verbose'
`show verbose'
     Displays whether `set verbose' is on or off.
     Displays whether `set verbose' is on or off.
   By default, if GDB encounters bugs in the symbol table of an object
   By default, if GDB encounters bugs in the symbol table of an object
file, it is silent; but if you are debugging a compiler, you may find
file, it is silent; but if you are debugging a compiler, you may find
this information useful (*note Errors Reading Symbol Files: Symbol
this information useful (*note Errors Reading Symbol Files: Symbol
Errors.).
Errors.).
`set complaints LIMIT'
`set complaints LIMIT'
     Permits GDB to output LIMIT complaints about each type of unusual
     Permits GDB to output LIMIT complaints about each type of unusual
     symbols before becoming silent about the problem.  Set LIMIT to
     symbols before becoming silent about the problem.  Set LIMIT to
     zero to suppress all complaints; set it to a large number to
     zero to suppress all complaints; set it to a large number to
     prevent complaints from being suppressed.
     prevent complaints from being suppressed.
`show complaints'
`show complaints'
     Displays how many symbol complaints GDB is permitted to produce.
     Displays how many symbol complaints GDB is permitted to produce.
   By default, GDB is cautious, and asks what sometimes seems to be a
   By default, GDB is cautious, and asks what sometimes seems to be a
lot of stupid questions to confirm certain commands.  For example, if
lot of stupid questions to confirm certain commands.  For example, if
you try to run a program which is already running:
you try to run a program which is already running:
     (gdb) run
     (gdb) run
     The program being debugged has been started already.
     The program being debugged has been started already.
     Start it from the beginning? (y or n)
     Start it from the beginning? (y or n)
   If you are willing to unflinchingly face the consequences of your own
   If you are willing to unflinchingly face the consequences of your own
commands, you can disable this "feature":
commands, you can disable this "feature":
`set confirm off'
`set confirm off'
     Disables confirmation requests.
     Disables confirmation requests.
`set confirm on'
`set confirm on'
     Enables confirmation requests (the default).
     Enables confirmation requests (the default).
`show confirm'
`show confirm'
     Displays state of confirmation requests.
     Displays state of confirmation requests.
   If you need to debug user-defined commands or sourced files you may
   If you need to debug user-defined commands or sourced files you may
find it useful to enable "command tracing".  In this mode each command
find it useful to enable "command tracing".  In this mode each command
will be printed as it is executed, prefixed with one or more `+'
will be printed as it is executed, prefixed with one or more `+'
symbols, the quantity denoting the call depth of each command.
symbols, the quantity denoting the call depth of each command.
`set trace-commands on'
`set trace-commands on'
     Enable command tracing.
     Enable command tracing.
`set trace-commands off'
`set trace-commands off'
     Disable command tracing.
     Disable command tracing.
`show trace-commands'
`show trace-commands'
     Display the current state of command tracing.
     Display the current state of command tracing.


File: gdb.info,  Node: Debugging Output,  Prev: Messages/Warnings,  Up: Controlling GDB
File: gdb.info,  Node: Debugging Output,  Prev: Messages/Warnings,  Up: Controlling GDB
19.8 Optional Messages about Internal Happenings
19.8 Optional Messages about Internal Happenings
================================================
================================================
GDB has commands that enable optional debugging messages from various
GDB has commands that enable optional debugging messages from various
GDB subsystems; normally these commands are of interest to GDB
GDB subsystems; normally these commands are of interest to GDB
maintainers, or when reporting a bug.  This section documents those
maintainers, or when reporting a bug.  This section documents those
commands.
commands.
`set exec-done-display'
`set exec-done-display'
     Turns on or off the notification of asynchronous commands'
     Turns on or off the notification of asynchronous commands'
     completion.  When on, GDB will print a message when an
     completion.  When on, GDB will print a message when an
     asynchronous command finishes its execution.  The default is off.
     asynchronous command finishes its execution.  The default is off.
`show exec-done-display'
`show exec-done-display'
     Displays the current setting of asynchronous command completion
     Displays the current setting of asynchronous command completion
     notification.
     notification.
`set debug arch'
`set debug arch'
     Turns on or off display of gdbarch debugging info.  The default is
     Turns on or off display of gdbarch debugging info.  The default is
     off
     off
`show debug arch'
`show debug arch'
     Displays the current state of displaying gdbarch debugging info.
     Displays the current state of displaying gdbarch debugging info.
`set debug aix-thread'
`set debug aix-thread'
     Display debugging messages about inner workings of the AIX thread
     Display debugging messages about inner workings of the AIX thread
     module.
     module.
`show debug aix-thread'
`show debug aix-thread'
     Show the current state of AIX thread debugging info display.
     Show the current state of AIX thread debugging info display.
`set debug event'
`set debug event'
     Turns on or off display of GDB event debugging info.  The default
     Turns on or off display of GDB event debugging info.  The default
     is off.
     is off.
`show debug event'
`show debug event'
     Displays the current state of displaying GDB event debugging info.
     Displays the current state of displaying GDB event debugging info.
`set debug expression'
`set debug expression'
     Turns on or off display of debugging info about GDB expression
     Turns on or off display of debugging info about GDB expression
     parsing.  The default is off.
     parsing.  The default is off.
`show debug expression'
`show debug expression'
     Displays the current state of displaying debugging info about GDB
     Displays the current state of displaying debugging info about GDB
     expression parsing.
     expression parsing.
`set debug frame'
`set debug frame'
     Turns on or off display of GDB frame debugging info.  The default
     Turns on or off display of GDB frame debugging info.  The default
     is off.
     is off.
`show debug frame'
`show debug frame'
     Displays the current state of displaying GDB frame debugging info.
     Displays the current state of displaying GDB frame debugging info.
`set debug infrun'
`set debug infrun'
     Turns on or off display of GDB debugging info for running the
     Turns on or off display of GDB debugging info for running the
     inferior.  The default is off.  `infrun.c' contains GDB's runtime
     inferior.  The default is off.  `infrun.c' contains GDB's runtime
     state machine used for implementing operations such as
     state machine used for implementing operations such as
     single-stepping the inferior.
     single-stepping the inferior.
`show debug infrun'
`show debug infrun'
     Displays the current state of GDB inferior debugging.
     Displays the current state of GDB inferior debugging.
`set debug lin-lwp'
`set debug lin-lwp'
     Turns on or off debugging messages from the Linux LWP debug
     Turns on or off debugging messages from the Linux LWP debug
     support.
     support.
`show debug lin-lwp'
`show debug lin-lwp'
     Show the current state of Linux LWP debugging messages.
     Show the current state of Linux LWP debugging messages.
`set debug observer'
`set debug observer'
     Turns on or off display of GDB observer debugging.  This includes
     Turns on or off display of GDB observer debugging.  This includes
     info such as the notification of observable events.
     info such as the notification of observable events.
`show debug observer'
`show debug observer'
     Displays the current state of observer debugging.
     Displays the current state of observer debugging.
`set debug overload'
`set debug overload'
     Turns on or off display of GDB C++ overload debugging info. This
     Turns on or off display of GDB C++ overload debugging info. This
     includes info such as ranking of functions, etc.  The default is
     includes info such as ranking of functions, etc.  The default is
     off.
     off.
`show debug overload'
`show debug overload'
     Displays the current state of displaying GDB C++ overload
     Displays the current state of displaying GDB C++ overload
     debugging info.
     debugging info.
`set debug remote'
`set debug remote'
     Turns on or off display of reports on all packets sent back and
     Turns on or off display of reports on all packets sent back and
     forth across the serial line to the remote machine.  The info is
     forth across the serial line to the remote machine.  The info is
     printed on the GDB standard output stream. The default is off.
     printed on the GDB standard output stream. The default is off.
`show debug remote'
`show debug remote'
     Displays the state of display of remote packets.
     Displays the state of display of remote packets.
`set debug serial'
`set debug serial'
     Turns on or off display of GDB serial debugging info. The default
     Turns on or off display of GDB serial debugging info. The default
     is off.
     is off.
`show debug serial'
`show debug serial'
     Displays the current state of displaying GDB serial debugging info.
     Displays the current state of displaying GDB serial debugging info.
`set debug solib-frv'
`set debug solib-frv'
     Turns on or off debugging messages for FR-V shared-library code.
     Turns on or off debugging messages for FR-V shared-library code.
`show debug solib-frv'
`show debug solib-frv'
     Display the current state of FR-V shared-library code debugging
     Display the current state of FR-V shared-library code debugging
     messages.
     messages.
`set debug target'
`set debug target'
     Turns on or off display of GDB target debugging info. This info
     Turns on or off display of GDB target debugging info. This info
     includes what is going on at the target level of GDB, as it
     includes what is going on at the target level of GDB, as it
     happens. The default is 0.  Set it to 1 to track events, and to 2
     happens. The default is 0.  Set it to 1 to track events, and to 2
     to also track the value of large memory transfers.  Changes to
     to also track the value of large memory transfers.  Changes to
     this flag do not take effect until the next time you connect to a
     this flag do not take effect until the next time you connect to a
     target or use the `run' command.
     target or use the `run' command.
`show debug target'
`show debug target'
     Displays the current state of displaying GDB target debugging info.
     Displays the current state of displaying GDB target debugging info.
`set debugvarobj'
`set debugvarobj'
     Turns on or off display of GDB variable object debugging info. The
     Turns on or off display of GDB variable object debugging info. The
     default is off.
     default is off.
`show debugvarobj'
`show debugvarobj'
     Displays the current state of displaying GDB variable object
     Displays the current state of displaying GDB variable object
     debugging info.
     debugging info.
`set debug xml'
`set debug xml'
     Turns on or off debugging messages for built-in XML parsers.
     Turns on or off debugging messages for built-in XML parsers.
`show debug xml'
`show debug xml'
     Displays the current state of XML debugging messages.
     Displays the current state of XML debugging messages.


File: gdb.info,  Node: Sequences,  Next: Interpreters,  Prev: Controlling GDB,  Up: Top
File: gdb.info,  Node: Sequences,  Next: Interpreters,  Prev: Controlling GDB,  Up: Top
20 Canned Sequences of Commands
20 Canned Sequences of Commands
*******************************
*******************************
Aside from breakpoint commands (*note Breakpoint Command Lists: Break
Aside from breakpoint commands (*note Breakpoint Command Lists: Break
Commands.), GDB provides two ways to store sequences of commands for
Commands.), GDB provides two ways to store sequences of commands for
execution as a unit: user-defined commands and command files.
execution as a unit: user-defined commands and command files.
* Menu:
* Menu:
* Define::             How to define your own commands
* Define::             How to define your own commands
* Hooks::              Hooks for user-defined commands
* Hooks::              Hooks for user-defined commands
* Command Files::      How to write scripts of commands to be stored in a file
* Command Files::      How to write scripts of commands to be stored in a file
* Output::             Commands for controlled output
* Output::             Commands for controlled output


File: gdb.info,  Node: Define,  Next: Hooks,  Up: Sequences
File: gdb.info,  Node: Define,  Next: Hooks,  Up: Sequences
20.1 User-defined Commands
20.1 User-defined Commands
==========================
==========================
A "user-defined command" is a sequence of GDB commands to which you
A "user-defined command" is a sequence of GDB commands to which you
assign a new name as a command.  This is done with the `define'
assign a new name as a command.  This is done with the `define'
command.  User commands may accept up to 10 arguments separated by
command.  User commands may accept up to 10 arguments separated by
whitespace.  Arguments are accessed within the user command via
whitespace.  Arguments are accessed within the user command via
`$arg0...$arg9'.  A trivial example:
`$arg0...$arg9'.  A trivial example:
     define adder
     define adder
       print $arg0 + $arg1 + $arg2
       print $arg0 + $arg1 + $arg2
     end
     end
To execute the command use:
To execute the command use:
     adder 1 2 3
     adder 1 2 3
This defines the command `adder', which prints the sum of its three
This defines the command `adder', which prints the sum of its three
arguments.  Note the arguments are text substitutions, so they may
arguments.  Note the arguments are text substitutions, so they may
reference variables, use complex expressions, or even perform inferior
reference variables, use complex expressions, or even perform inferior
functions calls.
functions calls.
   In addition, `$argc' may be used to find out how many arguments have
   In addition, `$argc' may be used to find out how many arguments have
been passed.  This expands to a number in the range 0...10.
been passed.  This expands to a number in the range 0...10.
     define adder
     define adder
       if $argc == 2
       if $argc == 2
         print $arg0 + $arg1
         print $arg0 + $arg1
       end
       end
       if $argc == 3
       if $argc == 3
         print $arg0 + $arg1 + $arg2
         print $arg0 + $arg1 + $arg2
       end
       end
     end
     end
`define COMMANDNAME'
`define COMMANDNAME'
     Define a command named COMMANDNAME.  If there is already a command
     Define a command named COMMANDNAME.  If there is already a command
     by that name, you are asked to confirm that you want to redefine
     by that name, you are asked to confirm that you want to redefine
     it.
     it.
     The definition of the command is made up of other GDB command
     The definition of the command is made up of other GDB command
     lines, which are given following the `define' command.  The end of
     lines, which are given following the `define' command.  The end of
     these commands is marked by a line containing `end'.
     these commands is marked by a line containing `end'.
`document COMMANDNAME'
`document COMMANDNAME'
     Document the user-defined command COMMANDNAME, so that it can be
     Document the user-defined command COMMANDNAME, so that it can be
     accessed by `help'.  The command COMMANDNAME must already be
     accessed by `help'.  The command COMMANDNAME must already be
     defined.  This command reads lines of documentation just as
     defined.  This command reads lines of documentation just as
     `define' reads the lines of the command definition, ending with
     `define' reads the lines of the command definition, ending with
     `end'.  After the `document' command is finished, `help' on command
     `end'.  After the `document' command is finished, `help' on command
     COMMANDNAME displays the documentation you have written.
     COMMANDNAME displays the documentation you have written.
     You may use the `document' command again to change the
     You may use the `document' command again to change the
     documentation of a command.  Redefining the command with `define'
     documentation of a command.  Redefining the command with `define'
     does not change the documentation.
     does not change the documentation.
`dont-repeat'
`dont-repeat'
     Used inside a user-defined command, this tells GDB that this
     Used inside a user-defined command, this tells GDB that this
     command should not be repeated when the user hits  (*note
     command should not be repeated when the user hits  (*note
     repeat last command: Command Syntax.).
     repeat last command: Command Syntax.).
`help user-defined'
`help user-defined'
     List all user-defined commands, with the first line of the
     List all user-defined commands, with the first line of the
     documentation (if any) for each.
     documentation (if any) for each.
`show user'
`show user'
`show user COMMANDNAME'
`show user COMMANDNAME'
     Display the GDB commands used to define COMMANDNAME (but not its
     Display the GDB commands used to define COMMANDNAME (but not its
     documentation).  If no COMMANDNAME is given, display the
     documentation).  If no COMMANDNAME is given, display the
     definitions for all user-defined commands.
     definitions for all user-defined commands.
`show max-user-call-depth'
`show max-user-call-depth'
`set max-user-call-depth'
`set max-user-call-depth'
     The value of `max-user-call-depth' controls how many recursion
     The value of `max-user-call-depth' controls how many recursion
     levels are allowed in user-defined commands before GDB suspects an
     levels are allowed in user-defined commands before GDB suspects an
     infinite recursion and aborts the command.
     infinite recursion and aborts the command.
   In addition to the above commands, user-defined commands frequently
   In addition to the above commands, user-defined commands frequently
use control flow commands, described in *Note Command Files::.
use control flow commands, described in *Note Command Files::.
   When user-defined commands are executed, the commands of the
   When user-defined commands are executed, the commands of the
definition are not printed.  An error in any command stops execution of
definition are not printed.  An error in any command stops execution of
the user-defined command.
the user-defined command.
   If used interactively, commands that would ask for confirmation
   If used interactively, commands that would ask for confirmation
proceed without asking when used inside a user-defined command.  Many
proceed without asking when used inside a user-defined command.  Many
GDB commands that normally print messages to say what they are doing
GDB commands that normally print messages to say what they are doing
omit the messages when used in a user-defined command.
omit the messages when used in a user-defined command.


File: gdb.info,  Node: Hooks,  Next: Command Files,  Prev: Define,  Up: Sequences
File: gdb.info,  Node: Hooks,  Next: Command Files,  Prev: Define,  Up: Sequences
20.2 User-defined Command Hooks
20.2 User-defined Command Hooks
===============================
===============================
You may define "hooks", which are a special kind of user-defined
You may define "hooks", which are a special kind of user-defined
command.  Whenever you run the command `foo', if the user-defined
command.  Whenever you run the command `foo', if the user-defined
command `hook-foo' exists, it is executed (with no arguments) before
command `hook-foo' exists, it is executed (with no arguments) before
that command.
that command.
   A hook may also be defined which is run after the command you
   A hook may also be defined which is run after the command you
executed.  Whenever you run the command `foo', if the user-defined
executed.  Whenever you run the command `foo', if the user-defined
command `hookpost-foo' exists, it is executed (with no arguments) after
command `hookpost-foo' exists, it is executed (with no arguments) after
that command.  Post-execution hooks may exist simultaneously with
that command.  Post-execution hooks may exist simultaneously with
pre-execution hooks, for the same command.
pre-execution hooks, for the same command.
   It is valid for a hook to call the command which it hooks.  If this
   It is valid for a hook to call the command which it hooks.  If this
occurs, the hook is not re-executed, thereby avoiding infinite
occurs, the hook is not re-executed, thereby avoiding infinite
recursion.
recursion.
   In addition, a pseudo-command, `stop' exists.  Defining
   In addition, a pseudo-command, `stop' exists.  Defining
(`hook-stop') makes the associated commands execute every time
(`hook-stop') makes the associated commands execute every time
execution stops in your program: before breakpoint commands are run,
execution stops in your program: before breakpoint commands are run,
displays are printed, or the stack frame is printed.
displays are printed, or the stack frame is printed.
   For example, to ignore `SIGALRM' signals while single-stepping, but
   For example, to ignore `SIGALRM' signals while single-stepping, but
treat them normally during normal execution, you could define:
treat them normally during normal execution, you could define:
     define hook-stop
     define hook-stop
     handle SIGALRM nopass
     handle SIGALRM nopass
     end
     end
     define hook-run
     define hook-run
     handle SIGALRM pass
     handle SIGALRM pass
     end
     end
     define hook-continue
     define hook-continue
     handle SIGALRM pass
     handle SIGALRM pass
     end
     end
   As a further example, to hook at the beginning and end of the `echo'
   As a further example, to hook at the beginning and end of the `echo'
command, and to add extra text to the beginning and end of the message,
command, and to add extra text to the beginning and end of the message,
you could define:
you could define:
     define hook-echo
     define hook-echo
     echo <<<---
     echo <<<---
     end
     end
     define hookpost-echo
     define hookpost-echo
     echo --->>>\n
     echo --->>>\n
     end
     end
     (gdb) echo Hello World
     (gdb) echo Hello World
     <<<---Hello World--->>>
     <<<---Hello World--->>>
     (gdb)
     (gdb)
   You can define a hook for any single-word command in GDB, but not
   You can define a hook for any single-word command in GDB, but not
for command aliases; you should define a hook for the basic command
for command aliases; you should define a hook for the basic command
name, e.g.  `backtrace' rather than `bt'.  If an error occurs during
name, e.g.  `backtrace' rather than `bt'.  If an error occurs during
the execution of your hook, execution of GDB commands stops and GDB
the execution of your hook, execution of GDB commands stops and GDB
issues a prompt (before the command that you actually typed had a
issues a prompt (before the command that you actually typed had a
chance to run).
chance to run).
   If you try to define a hook which does not match any known command,
   If you try to define a hook which does not match any known command,
you get a warning from the `define' command.
you get a warning from the `define' command.


File: gdb.info,  Node: Command Files,  Next: Output,  Prev: Hooks,  Up: Sequences
File: gdb.info,  Node: Command Files,  Next: Output,  Prev: Hooks,  Up: Sequences
20.3 Command Files
20.3 Command Files
==================
==================
A command file for GDB is a text file made of lines that are GDB
A command file for GDB is a text file made of lines that are GDB
commands.  Comments (lines starting with `#') may also be included.  An
commands.  Comments (lines starting with `#') may also be included.  An
empty line in a command file does nothing; it does not mean to repeat
empty line in a command file does nothing; it does not mean to repeat
the last command, as it would from the terminal.
the last command, as it would from the terminal.
   You can request the execution of a command file with the `source'
   You can request the execution of a command file with the `source'
command:
command:
`source [`-v'] FILENAME'
`source [`-v'] FILENAME'
     Execute the command file FILENAME.
     Execute the command file FILENAME.
   The lines in a command file are generally executed sequentially,
   The lines in a command file are generally executed sequentially,
unless the order of execution is changed by one of the _flow-control
unless the order of execution is changed by one of the _flow-control
commands_ described below.  The commands are not printed as they are
commands_ described below.  The commands are not printed as they are
executed.  An error in any command terminates execution of the command
executed.  An error in any command terminates execution of the command
file and control is returned to the console.
file and control is returned to the console.
   GDB searches for FILENAME in the current directory and then on the
   GDB searches for FILENAME in the current directory and then on the
search path (specified with the `directory' command).
search path (specified with the `directory' command).
   If `-v', for verbose mode, is given then GDB displays each command
   If `-v', for verbose mode, is given then GDB displays each command
as it is executed.  The option must be given before FILENAME, and is
as it is executed.  The option must be given before FILENAME, and is
interpreted as part of the filename anywhere else.
interpreted as part of the filename anywhere else.
   Commands that would ask for confirmation if used interactively
   Commands that would ask for confirmation if used interactively
proceed without asking when used in a command file.  Many GDB commands
proceed without asking when used in a command file.  Many GDB commands
that normally print messages to say what they are doing omit the
that normally print messages to say what they are doing omit the
messages when called from command files.
messages when called from command files.
   GDB also accepts command input from standard input.  In this mode,
   GDB also accepts command input from standard input.  In this mode,
normal output goes to standard output and error output goes to standard
normal output goes to standard output and error output goes to standard
error.  Errors in a command file supplied on standard input do not
error.  Errors in a command file supplied on standard input do not
terminate execution of the command file--execution continues with the
terminate execution of the command file--execution continues with the
next command.
next command.
     gdb < cmds > log 2>&1
     gdb < cmds > log 2>&1
   (The syntax above will vary depending on the shell used.) This
   (The syntax above will vary depending on the shell used.) This
example will execute commands from the file `cmds'. All output and
example will execute commands from the file `cmds'. All output and
errors would be directed to `log'.
errors would be directed to `log'.
   Since commands stored on command files tend to be more general than
   Since commands stored on command files tend to be more general than
commands typed interactively, they frequently need to deal with
commands typed interactively, they frequently need to deal with
complicated situations, such as different or unexpected values of
complicated situations, such as different or unexpected values of
variables and symbols, changes in how the program being debugged is
variables and symbols, changes in how the program being debugged is
built, etc.  GDB provides a set of flow-control commands to deal with
built, etc.  GDB provides a set of flow-control commands to deal with
these complexities.  Using these commands, you can write complex
these complexities.  Using these commands, you can write complex
scripts that loop over data structures, execute commands conditionally,
scripts that loop over data structures, execute commands conditionally,
etc.
etc.
`if'
`if'
`else'
`else'
     This command allows to include in your script conditionally
     This command allows to include in your script conditionally
     executed commands. The `if' command takes a single argument, which
     executed commands. The `if' command takes a single argument, which
     is an expression to evaluate.  It is followed by a series of
     is an expression to evaluate.  It is followed by a series of
     commands that are executed only if the expression is true (its
     commands that are executed only if the expression is true (its
     value is nonzero).  There can then optionally be an `else' line,
     value is nonzero).  There can then optionally be an `else' line,
     followed by a series of commands that are only executed if the
     followed by a series of commands that are only executed if the
     expression was false.  The end of the list is marked by a line
     expression was false.  The end of the list is marked by a line
     containing `end'.
     containing `end'.
`while'
`while'
     This command allows to write loops.  Its syntax is similar to
     This command allows to write loops.  Its syntax is similar to
     `if': the command takes a single argument, which is an expression
     `if': the command takes a single argument, which is an expression
     to evaluate, and must be followed by the commands to execute, one
     to evaluate, and must be followed by the commands to execute, one
     per line, terminated by an `end'.  These commands are called the
     per line, terminated by an `end'.  These commands are called the
     "body" of the loop.  The commands in the body of `while' are
     "body" of the loop.  The commands in the body of `while' are
     executed repeatedly as long as the expression evaluates to true.
     executed repeatedly as long as the expression evaluates to true.
`loop_break'
`loop_break'
     This command exits the `while' loop in whose body it is included.
     This command exits the `while' loop in whose body it is included.
     Execution of the script continues after that `while's `end' line.
     Execution of the script continues after that `while's `end' line.
`loop_continue'
`loop_continue'
     This command skips the execution of the rest of the body of
     This command skips the execution of the rest of the body of
     commands in the `while' loop in whose body it is included.
     commands in the `while' loop in whose body it is included.
     Execution branches to the beginning of the `while' loop, where it
     Execution branches to the beginning of the `while' loop, where it
     evaluates the controlling expression.
     evaluates the controlling expression.
`end'
`end'
     Terminate the block of commands that are the body of `if', `else',
     Terminate the block of commands that are the body of `if', `else',
     or `while' flow-control commands.
     or `while' flow-control commands.


File: gdb.info,  Node: Output,  Prev: Command Files,  Up: Sequences
File: gdb.info,  Node: Output,  Prev: Command Files,  Up: Sequences
20.4 Commands for Controlled Output
20.4 Commands for Controlled Output
===================================
===================================
During the execution of a command file or a user-defined command, normal
During the execution of a command file or a user-defined command, normal
GDB output is suppressed; the only output that appears is what is
GDB output is suppressed; the only output that appears is what is
explicitly printed by the commands in the definition.  This section
explicitly printed by the commands in the definition.  This section
describes three commands useful for generating exactly the output you
describes three commands useful for generating exactly the output you
want.
want.
`echo TEXT'
`echo TEXT'
     Print TEXT.  Nonprinting characters can be included in TEXT using
     Print TEXT.  Nonprinting characters can be included in TEXT using
     C escape sequences, such as `\n' to print a newline.  *No newline
     C escape sequences, such as `\n' to print a newline.  *No newline
     is printed unless you specify one.* In addition to the standard C
     is printed unless you specify one.* In addition to the standard C
     escape sequences, a backslash followed by a space stands for a
     escape sequences, a backslash followed by a space stands for a
     space.  This is useful for displaying a string with spaces at the
     space.  This is useful for displaying a string with spaces at the
     beginning or the end, since leading and trailing spaces are
     beginning or the end, since leading and trailing spaces are
     otherwise trimmed from all arguments.  To print ` and foo = ', use
     otherwise trimmed from all arguments.  To print ` and foo = ', use
     the command `echo \ and foo = \ '.
     the command `echo \ and foo = \ '.
     A backslash at the end of TEXT can be used, as in C, to continue
     A backslash at the end of TEXT can be used, as in C, to continue
     the command onto subsequent lines.  For example,
     the command onto subsequent lines.  For example,
          echo This is some text\n\
          echo This is some text\n\
          which is continued\n\
          which is continued\n\
          onto several lines.\n
          onto several lines.\n
     produces the same output as
     produces the same output as
          echo This is some text\n
          echo This is some text\n
          echo which is continued\n
          echo which is continued\n
          echo onto several lines.\n
          echo onto several lines.\n
`output EXPRESSION'
`output EXPRESSION'
     Print the value of EXPRESSION and nothing but that value: no
     Print the value of EXPRESSION and nothing but that value: no
     newlines, no `$NN = '.  The value is not entered in the value
     newlines, no `$NN = '.  The value is not entered in the value
     history either.  *Note Expressions: Expressions, for more
     history either.  *Note Expressions: Expressions, for more
     information on expressions.
     information on expressions.
`output/FMT EXPRESSION'
`output/FMT EXPRESSION'
     Print the value of EXPRESSION in format FMT.  You can use the same
     Print the value of EXPRESSION in format FMT.  You can use the same
     formats as for `print'.  *Note Output Formats: Output Formats, for
     formats as for `print'.  *Note Output Formats: Output Formats, for
     more information.
     more information.
`printf TEMPLATE, EXPRESSIONS...'
`printf TEMPLATE, EXPRESSIONS...'
     Print the values of one or more EXPRESSIONS under the control of
     Print the values of one or more EXPRESSIONS under the control of
     the string TEMPLATE.  To print several values, make EXPRESSIONS be
     the string TEMPLATE.  To print several values, make EXPRESSIONS be
     a comma-separated list of individual expressions, which may be
     a comma-separated list of individual expressions, which may be
     either numbers or pointers.  Their values are printed as specified
     either numbers or pointers.  Their values are printed as specified
     by TEMPLATE, exactly as a C program would do by executing the code
     by TEMPLATE, exactly as a C program would do by executing the code
     below:
     below:
          printf (TEMPLATE, EXPRESSIONS...);
          printf (TEMPLATE, EXPRESSIONS...);
     As in `C' `printf', ordinary characters in TEMPLATE are printed
     As in `C' `printf', ordinary characters in TEMPLATE are printed
     verbatim, while "conversion specification" introduced by the `%'
     verbatim, while "conversion specification" introduced by the `%'
     character cause subsequent EXPRESSIONS to be evaluated, their
     character cause subsequent EXPRESSIONS to be evaluated, their
     values converted and formatted according to type and style
     values converted and formatted according to type and style
     information encoded in the conversion specifications, and then
     information encoded in the conversion specifications, and then
     printed.
     printed.
     For example, you can print two values in hex like this:
     For example, you can print two values in hex like this:
          printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
          printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
     `printf' supports all the standard `C' conversion specifications,
     `printf' supports all the standard `C' conversion specifications,
     including the flags and modifiers between the `%' character and
     including the flags and modifiers between the `%' character and
     the conversion letter, with the following exceptions:
     the conversion letter, with the following exceptions:
        * The argument-ordering modifiers, such as `2$', are not
        * The argument-ordering modifiers, such as `2$', are not
          supported.
          supported.
        * The modifier `*' is not supported for specifying precision or
        * The modifier `*' is not supported for specifying precision or
          width.
          width.
        * The `'' flag (for separation of digits into groups according
        * The `'' flag (for separation of digits into groups according
          to `LC_NUMERIC'') is not supported.
          to `LC_NUMERIC'') is not supported.
        * The type modifiers `hh', `j', `t', and `z' are not supported.
        * The type modifiers `hh', `j', `t', and `z' are not supported.
        * The conversion letter `n' (as in `%n') is not supported.
        * The conversion letter `n' (as in `%n') is not supported.
        * The conversion letters `a' and `A' are not supported.
        * The conversion letters `a' and `A' are not supported.
     Note that the `ll' type modifier is supported only if the
     Note that the `ll' type modifier is supported only if the
     underlying `C' implementation used to build GDB supports the `long
     underlying `C' implementation used to build GDB supports the `long
     long int' type, and the `L' type modifier is supported only if
     long int' type, and the `L' type modifier is supported only if
     `long double' type is available.
     `long double' type is available.
     As in `C', `printf' supports simple backslash-escape sequences,
     As in `C', `printf' supports simple backslash-escape sequences,
     such as `\n', `\t', `\\', `\"', `\a', and `\f', that consist of
     such as `\n', `\t', `\\', `\"', `\a', and `\f', that consist of
     backslash followed by a single character.  Octal and hexadecimal
     backslash followed by a single character.  Octal and hexadecimal
     escape sequences are not supported.
     escape sequences are not supported.
     Additionally, `printf' supports conversion specifications for DFP
     Additionally, `printf' supports conversion specifications for DFP
     ("Decimal Floating Point") types using the following length
     ("Decimal Floating Point") types using the following length
     modifiers together with a floating point specifier.  letters:
     modifiers together with a floating point specifier.  letters:
        * `H' for printing `Decimal32' types.
        * `H' for printing `Decimal32' types.
        * `D' for printing `Decimal64' types.
        * `D' for printing `Decimal64' types.
        * `DD' for printing `Decimal128' types.
        * `DD' for printing `Decimal128' types.
     If the underlying `C' implementation used to build GDB has support
     If the underlying `C' implementation used to build GDB has support
     for the three length modifiers for DFP types, other modifiers such
     for the three length modifiers for DFP types, other modifiers such
     as width and precision will also be available for GDB to use.
     as width and precision will also be available for GDB to use.
     In case there is no such `C' support, no additional modifiers will
     In case there is no such `C' support, no additional modifiers will
     be available and the value will be printed in the standard way.
     be available and the value will be printed in the standard way.
     Here's an example of printing DFP types using the above conversion
     Here's an example of printing DFP types using the above conversion
     letters:
     letters:
          printf "D32: %Hf - D64: %Df - D128: %DDf\n",1.2345df,1.2E10dd,1.2E1dl
          printf "D32: %Hf - D64: %Df - D128: %DDf\n",1.2345df,1.2E10dd,1.2E1dl


File: gdb.info,  Node: Interpreters,  Next: TUI,  Prev: Sequences,  Up: Top
File: gdb.info,  Node: Interpreters,  Next: TUI,  Prev: Sequences,  Up: Top
21 Command Interpreters
21 Command Interpreters
***********************
***********************
GDB supports multiple command interpreters, and some command
GDB supports multiple command interpreters, and some command
infrastructure to allow users or user interface writers to switch
infrastructure to allow users or user interface writers to switch
between interpreters or run commands in other interpreters.
between interpreters or run commands in other interpreters.
   GDB currently supports two command interpreters, the console
   GDB currently supports two command interpreters, the console
interpreter (sometimes called the command-line interpreter or CLI) and
interpreter (sometimes called the command-line interpreter or CLI) and
the machine interface interpreter (or GDB/MI).  This manual describes
the machine interface interpreter (or GDB/MI).  This manual describes
both of these interfaces in great detail.
both of these interfaces in great detail.
   By default, GDB will start with the console interpreter.  However,
   By default, GDB will start with the console interpreter.  However,
the user may choose to start GDB with another interpreter by specifying
the user may choose to start GDB with another interpreter by specifying
the `-i' or `--interpreter' startup options.  Defined interpreters
the `-i' or `--interpreter' startup options.  Defined interpreters
include:
include:
`console'
`console'
     The traditional console or command-line interpreter.  This is the
     The traditional console or command-line interpreter.  This is the
     most often used interpreter with GDB. With no interpreter
     most often used interpreter with GDB. With no interpreter
     specified at runtime, GDB will use this interpreter.
     specified at runtime, GDB will use this interpreter.
`mi'
`mi'
     The newest GDB/MI interface (currently `mi2').  Used primarily by
     The newest GDB/MI interface (currently `mi2').  Used primarily by
     programs wishing to use GDB as a backend for a debugger GUI or an
     programs wishing to use GDB as a backend for a debugger GUI or an
     IDE.  For more information, see *Note The GDB/MI Interface: GDB/MI.
     IDE.  For more information, see *Note The GDB/MI Interface: GDB/MI.
`mi2'
`mi2'
     The current GDB/MI interface.
     The current GDB/MI interface.
`mi1'
`mi1'
     The GDB/MI interface included in GDB 5.1, 5.2, and 5.3.
     The GDB/MI interface included in GDB 5.1, 5.2, and 5.3.
   The interpreter being used by GDB may not be dynamically switched at
   The interpreter being used by GDB may not be dynamically switched at
runtime.  Although possible, this could lead to a very precarious
runtime.  Although possible, this could lead to a very precarious
situation.  Consider an IDE using GDB/MI.  If a user enters the command
situation.  Consider an IDE using GDB/MI.  If a user enters the command
"interpreter-set console" in a console view, GDB would switch to using
"interpreter-set console" in a console view, GDB would switch to using
the console interpreter, rendering the IDE inoperable!
the console interpreter, rendering the IDE inoperable!
   Although you may only choose a single interpreter at startup, you
   Although you may only choose a single interpreter at startup, you
may execute commands in any interpreter from the current interpreter
may execute commands in any interpreter from the current interpreter
using the appropriate command.  If you are running the console
using the appropriate command.  If you are running the console
interpreter, simply use the `interpreter-exec' command:
interpreter, simply use the `interpreter-exec' command:
     interpreter-exec mi "-data-list-register-names"
     interpreter-exec mi "-data-list-register-names"
   GDB/MI has a similar command, although it is only available in
   GDB/MI has a similar command, although it is only available in
versions of GDB which support GDB/MI version 2 (or greater).
versions of GDB which support GDB/MI version 2 (or greater).


File: gdb.info,  Node: TUI,  Next: Emacs,  Prev: Interpreters,  Up: Top
File: gdb.info,  Node: TUI,  Next: Emacs,  Prev: Interpreters,  Up: Top
22 GDB Text User Interface
22 GDB Text User Interface
**************************
**************************
* Menu:
* Menu:
* TUI Overview::                TUI overview
* TUI Overview::                TUI overview
* TUI Keys::                    TUI key bindings
* TUI Keys::                    TUI key bindings
* TUI Single Key Mode::         TUI single key mode
* TUI Single Key Mode::         TUI single key mode
* TUI Commands::                TUI-specific commands
* TUI Commands::                TUI-specific commands
* TUI Configuration::           TUI configuration variables
* TUI Configuration::           TUI configuration variables
   The GDB Text User Interface (TUI) is a terminal interface which uses
   The GDB Text User Interface (TUI) is a terminal interface which uses
the `curses' library to show the source file, the assembly output, the
the `curses' library to show the source file, the assembly output, the
program registers and GDB commands in separate text windows.  The TUI
program registers and GDB commands in separate text windows.  The TUI
mode is supported only on platforms where a suitable version of the
mode is supported only on platforms where a suitable version of the
`curses' library is available.
`curses' library is available.
   The TUI mode is enabled by default when you invoke GDB as either
   The TUI mode is enabled by default when you invoke GDB as either
`gdbtui' or `gdb -tui'.  You can also switch in and out of TUI mode
`gdbtui' or `gdb -tui'.  You can also switch in and out of TUI mode
while GDB runs by using various TUI commands and key bindings, such as
while GDB runs by using various TUI commands and key bindings, such as
`C-x C-a'.  *Note TUI Key Bindings: TUI Keys.
`C-x C-a'.  *Note TUI Key Bindings: TUI Keys.


File: gdb.info,  Node: TUI Overview,  Next: TUI Keys,  Up: TUI
File: gdb.info,  Node: TUI Overview,  Next: TUI Keys,  Up: TUI
22.1 TUI Overview
22.1 TUI Overview
=================
=================
In TUI mode, GDB can display several text windows:
In TUI mode, GDB can display several text windows:
_command_
_command_
     This window is the GDB command window with the GDB prompt and the
     This window is the GDB command window with the GDB prompt and the
     GDB output.  The GDB input is still managed using readline.
     GDB output.  The GDB input is still managed using readline.
_source_
_source_
     The source window shows the source file of the program.  The
     The source window shows the source file of the program.  The
     current line and active breakpoints are displayed in this window.
     current line and active breakpoints are displayed in this window.
_assembly_
_assembly_
     The assembly window shows the disassembly output of the program.
     The assembly window shows the disassembly output of the program.
_register_
_register_
     This window shows the processor registers.  Registers are
     This window shows the processor registers.  Registers are
     highlighted when their values change.
     highlighted when their values change.
   The source and assembly windows show the current program position by
   The source and assembly windows show the current program position by
highlighting the current line and marking it with a `>' marker.
highlighting the current line and marking it with a `>' marker.
Breakpoints are indicated with two markers.  The first marker indicates
Breakpoints are indicated with two markers.  The first marker indicates
the breakpoint type:
the breakpoint type:
`B'
`B'
     Breakpoint which was hit at least once.
     Breakpoint which was hit at least once.
`b'
`b'
     Breakpoint which was never hit.
     Breakpoint which was never hit.
`H'
`H'
     Hardware breakpoint which was hit at least once.
     Hardware breakpoint which was hit at least once.
`h'
`h'
     Hardware breakpoint which was never hit.
     Hardware breakpoint which was never hit.
   The second marker indicates whether the breakpoint is enabled or not:
   The second marker indicates whether the breakpoint is enabled or not:
`+'
`+'
     Breakpoint is enabled.
     Breakpoint is enabled.
`-'
`-'
     Breakpoint is disabled.
     Breakpoint is disabled.
   The source, assembly and register windows are updated when the
   The source, assembly and register windows are updated when the
current thread changes, when the frame changes, or when the program
current thread changes, when the frame changes, or when the program
counter changes.
counter changes.
   These windows are not all visible at the same time.  The command
   These windows are not all visible at the same time.  The command
window is always visible.  The others can be arranged in several
window is always visible.  The others can be arranged in several
layouts:
layouts:
   * source only,
   * source only,
   * assembly only,
   * assembly only,
   * source and assembly,
   * source and assembly,
   * source and registers, or
   * source and registers, or
   * assembly and registers.
   * assembly and registers.
   A status line above the command window shows the following
   A status line above the command window shows the following
information:
information:
_target_
_target_
     Indicates the current GDB target.  (*note Specifying a Debugging
     Indicates the current GDB target.  (*note Specifying a Debugging
     Target: Targets.).
     Target: Targets.).
_process_
_process_
     Gives the current process or thread number.  When no process is
     Gives the current process or thread number.  When no process is
     being debugged, this field is set to `No process'.
     being debugged, this field is set to `No process'.
_function_
_function_
     Gives the current function name for the selected frame.  The name
     Gives the current function name for the selected frame.  The name
     is demangled if demangling is turned on (*note Print Settings::).
     is demangled if demangling is turned on (*note Print Settings::).
     When there is no symbol corresponding to the current program
     When there is no symbol corresponding to the current program
     counter, the string `??' is displayed.
     counter, the string `??' is displayed.
_line_
_line_
     Indicates the current line number for the selected frame.  When
     Indicates the current line number for the selected frame.  When
     the current line number is not known, the string `??' is displayed.
     the current line number is not known, the string `??' is displayed.
_pc_
_pc_
     Indicates the current program counter address.
     Indicates the current program counter address.


File: gdb.info,  Node: TUI Keys,  Next: TUI Single Key Mode,  Prev: TUI Overview,  Up: TUI
File: gdb.info,  Node: TUI Keys,  Next: TUI Single Key Mode,  Prev: TUI Overview,  Up: TUI
22.2 TUI Key Bindings
22.2 TUI Key Bindings
=====================
=====================
The TUI installs several key bindings in the readline keymaps (*note
The TUI installs several key bindings in the readline keymaps (*note
Command Line Editing::).  The following key bindings are installed for
Command Line Editing::).  The following key bindings are installed for
both TUI mode and the GDB standard mode.
both TUI mode and the GDB standard mode.
`C-x C-a'
`C-x C-a'
`C-x a'
`C-x a'
`C-x A'
`C-x A'
     Enter or leave the TUI mode.  When leaving the TUI mode, the
     Enter or leave the TUI mode.  When leaving the TUI mode, the
     curses window management stops and GDB operates using its standard
     curses window management stops and GDB operates using its standard
     mode, writing on the terminal directly.  When reentering the TUI
     mode, writing on the terminal directly.  When reentering the TUI
     mode, control is given back to the curses windows.  The screen is
     mode, control is given back to the curses windows.  The screen is
     then refreshed.
     then refreshed.
`C-x 1'
`C-x 1'
     Use a TUI layout with only one window.  The layout will either be
     Use a TUI layout with only one window.  The layout will either be
     `source' or `assembly'.  When the TUI mode is not active, it will
     `source' or `assembly'.  When the TUI mode is not active, it will
     switch to the TUI mode.
     switch to the TUI mode.
     Think of this key binding as the Emacs `C-x 1' binding.
     Think of this key binding as the Emacs `C-x 1' binding.
`C-x 2'
`C-x 2'
     Use a TUI layout with at least two windows.  When the current
     Use a TUI layout with at least two windows.  When the current
     layout already has two windows, the next layout with two windows
     layout already has two windows, the next layout with two windows
     is used.  When a new layout is chosen, one window will always be
     is used.  When a new layout is chosen, one window will always be
     common to the previous layout and the new one.
     common to the previous layout and the new one.
     Think of it as the Emacs `C-x 2' binding.
     Think of it as the Emacs `C-x 2' binding.
`C-x o'
`C-x o'
     Change the active window.  The TUI associates several key bindings
     Change the active window.  The TUI associates several key bindings
     (like scrolling and arrow keys) with the active window.  This
     (like scrolling and arrow keys) with the active window.  This
     command gives the focus to the next TUI window.
     command gives the focus to the next TUI window.
     Think of it as the Emacs `C-x o' binding.
     Think of it as the Emacs `C-x o' binding.
`C-x s'
`C-x s'
     Switch in and out of the TUI SingleKey mode that binds single keys
     Switch in and out of the TUI SingleKey mode that binds single keys
     to GDB commands (*note TUI Single Key Mode::).
     to GDB commands (*note TUI Single Key Mode::).
   The following key bindings only work in the TUI mode:
   The following key bindings only work in the TUI mode:
     Scroll the active window one page up.
     Scroll the active window one page up.
     Scroll the active window one page down.
     Scroll the active window one page down.
     Scroll the active window one line up.
     Scroll the active window one line up.
     Scroll the active window one line down.
     Scroll the active window one line down.
     Scroll the active window one column left.
     Scroll the active window one column left.
     Scroll the active window one column right.
     Scroll the active window one column right.
`C-L'
`C-L'
     Refresh the screen.
     Refresh the screen.
   Because the arrow keys scroll the active window in the TUI mode, they
   Because the arrow keys scroll the active window in the TUI mode, they
are not available for their normal use by readline unless the command
are not available for their normal use by readline unless the command
window has the focus.  When another window is active, you must use
window has the focus.  When another window is active, you must use
other readline key bindings such as `C-p', `C-n', `C-b' and `C-f' to
other readline key bindings such as `C-p', `C-n', `C-b' and `C-f' to
control the command window.
control the command window.


File: gdb.info,  Node: TUI Single Key Mode,  Next: TUI Commands,  Prev: TUI Keys,  Up: TUI
File: gdb.info,  Node: TUI Single Key Mode,  Next: TUI Commands,  Prev: TUI Keys,  Up: TUI
22.3 TUI Single Key Mode
22.3 TUI Single Key Mode
========================
========================
The TUI also provides a "SingleKey" mode, which binds several
The TUI also provides a "SingleKey" mode, which binds several
frequently used GDB commands to single keys.  Type `C-x s' to switch
frequently used GDB commands to single keys.  Type `C-x s' to switch
into this mode, where the following key bindings are used:
into this mode, where the following key bindings are used:
`c'
`c'
     continue
     continue
`d'
`d'
     down
     down
`f'
`f'
     finish
     finish
`n'
`n'
     next
     next
`q'
`q'
     exit the SingleKey mode.
     exit the SingleKey mode.
`r'
`r'
     run
     run
`s'
`s'
     step
     step
`u'
`u'
     up
     up
`v'
`v'
     info locals
     info locals
`w'
`w'
     where
     where
   Other keys temporarily switch to the GDB command prompt.  The key
   Other keys temporarily switch to the GDB command prompt.  The key
that was pressed is inserted in the editing buffer so that it is
that was pressed is inserted in the editing buffer so that it is
possible to type most GDB commands without interaction with the TUI
possible to type most GDB commands without interaction with the TUI
SingleKey mode.  Once the command is entered the TUI SingleKey mode is
SingleKey mode.  Once the command is entered the TUI SingleKey mode is
restored.  The only way to permanently leave this mode is by typing `q'
restored.  The only way to permanently leave this mode is by typing `q'
or `C-x s'.
or `C-x s'.


File: gdb.info,  Node: TUI Commands,  Next: TUI Configuration,  Prev: TUI Single Key Mode,  Up: TUI
File: gdb.info,  Node: TUI Commands,  Next: TUI Configuration,  Prev: TUI Single Key Mode,  Up: TUI
22.4 TUI-specific Commands
22.4 TUI-specific Commands
==========================
==========================
The TUI has specific commands to control the text windows.  These
The TUI has specific commands to control the text windows.  These
commands are always available, even when GDB is not in the TUI mode.
commands are always available, even when GDB is not in the TUI mode.
When GDB is in the standard mode, most of these commands will
When GDB is in the standard mode, most of these commands will
automatically switch to the TUI mode.
automatically switch to the TUI mode.
`info win'
`info win'
     List and give the size of all displayed windows.
     List and give the size of all displayed windows.
`layout next'
`layout next'
     Display the next layout.
     Display the next layout.
`layout prev'
`layout prev'
     Display the previous layout.
     Display the previous layout.
`layout src'
`layout src'
     Display the source window only.
     Display the source window only.
`layout asm'
`layout asm'
     Display the assembly window only.
     Display the assembly window only.
`layout split'
`layout split'
     Display the source and assembly window.
     Display the source and assembly window.
`layout regs'
`layout regs'
     Display the register window together with the source or assembly
     Display the register window together with the source or assembly
     window.
     window.
`focus next'
`focus next'
     Make the next window active for scrolling.
     Make the next window active for scrolling.
`focus prev'
`focus prev'
     Make the previous window active for scrolling.
     Make the previous window active for scrolling.
`focus src'
`focus src'
     Make the source window active for scrolling.
     Make the source window active for scrolling.
`focus asm'
`focus asm'
     Make the assembly window active for scrolling.
     Make the assembly window active for scrolling.
`focus regs'
`focus regs'
     Make the register window active for scrolling.
     Make the register window active for scrolling.
`focus cmd'
`focus cmd'
     Make the command window active for scrolling.
     Make the command window active for scrolling.
`refresh'
`refresh'
     Refresh the screen.  This is similar to typing `C-L'.
     Refresh the screen.  This is similar to typing `C-L'.
`tui reg float'
`tui reg float'
     Show the floating point registers in the register window.
     Show the floating point registers in the register window.
`tui reg general'
`tui reg general'
     Show the general registers in the register window.
     Show the general registers in the register window.
`tui reg next'
`tui reg next'
     Show the next register group.  The list of register groups as well
     Show the next register group.  The list of register groups as well
     as their order is target specific.  The predefined register groups
     as their order is target specific.  The predefined register groups
     are the following: `general', `float', `system', `vector', `all',
     are the following: `general', `float', `system', `vector', `all',
     `save', `restore'.
     `save', `restore'.
`tui reg system'
`tui reg system'
     Show the system registers in the register window.
     Show the system registers in the register window.
`update'
`update'
     Update the source window and the current execution point.
     Update the source window and the current execution point.
`winheight NAME +COUNT'
`winheight NAME +COUNT'
`winheight NAME -COUNT'
`winheight NAME -COUNT'
     Change the height of the window NAME by COUNT lines.  Positive
     Change the height of the window NAME by COUNT lines.  Positive
     counts increase the height, while negative counts decrease it.
     counts increase the height, while negative counts decrease it.
`tabset NCHARS'
`tabset NCHARS'
     Set the width of tab stops to be NCHARS characters.
     Set the width of tab stops to be NCHARS characters.


File: gdb.info,  Node: TUI Configuration,  Prev: TUI Commands,  Up: TUI
File: gdb.info,  Node: TUI Configuration,  Prev: TUI Commands,  Up: TUI
22.5 TUI Configuration Variables
22.5 TUI Configuration Variables
================================
================================
Several configuration variables control the appearance of TUI windows.
Several configuration variables control the appearance of TUI windows.
`set tui border-kind KIND'
`set tui border-kind KIND'
     Select the border appearance for the source, assembly and register
     Select the border appearance for the source, assembly and register
     windows.  The possible values are the following:
     windows.  The possible values are the following:
    `space'
    `space'
          Use a space character to draw the border.
          Use a space character to draw the border.
    `ascii'
    `ascii'
          Use ASCII characters `+', `-' and `|' to draw the border.
          Use ASCII characters `+', `-' and `|' to draw the border.
    `acs'
    `acs'
          Use the Alternate Character Set to draw the border.  The
          Use the Alternate Character Set to draw the border.  The
          border is drawn using character line graphics if the terminal
          border is drawn using character line graphics if the terminal
          supports them.
          supports them.
`set tui border-mode MODE'
`set tui border-mode MODE'
`set tui active-border-mode MODE'
`set tui active-border-mode MODE'
     Select the display attributes for the borders of the inactive
     Select the display attributes for the borders of the inactive
     windows or the active window.  The MODE can be one of the
     windows or the active window.  The MODE can be one of the
     following:
     following:
    `normal'
    `normal'
          Use normal attributes to display the border.
          Use normal attributes to display the border.
    `standout'
    `standout'
          Use standout mode.
          Use standout mode.
    `reverse'
    `reverse'
          Use reverse video mode.
          Use reverse video mode.
    `half'
    `half'
          Use half bright mode.
          Use half bright mode.
    `half-standout'
    `half-standout'
          Use half bright and standout mode.
          Use half bright and standout mode.
    `bold'
    `bold'
          Use extra bright or bold mode.
          Use extra bright or bold mode.
    `bold-standout'
    `bold-standout'
          Use extra bright or bold and standout mode.
          Use extra bright or bold and standout mode.


File: gdb.info,  Node: Emacs,  Next: GDB/MI,  Prev: TUI,  Up: Top
File: gdb.info,  Node: Emacs,  Next: GDB/MI,  Prev: TUI,  Up: Top
23 Using GDB under GNU Emacs
23 Using GDB under GNU Emacs
****************************
****************************
A special interface allows you to use GNU Emacs to view (and edit) the
A special interface allows you to use GNU Emacs to view (and edit) the
source files for the program you are debugging with GDB.
source files for the program you are debugging with GDB.
   To use this interface, use the command `M-x gdb' in Emacs.  Give the
   To use this interface, use the command `M-x gdb' in Emacs.  Give the
executable file you want to debug as an argument.  This command starts
executable file you want to debug as an argument.  This command starts
GDB as a subprocess of Emacs, with input and output through a newly
GDB as a subprocess of Emacs, with input and output through a newly
created Emacs buffer.
created Emacs buffer.
   Running GDB under Emacs can be just like running GDB normally except
   Running GDB under Emacs can be just like running GDB normally except
for two things:
for two things:
   * All "terminal" input and output goes through an Emacs buffer,
   * All "terminal" input and output goes through an Emacs buffer,
     called the GUD buffer.
     called the GUD buffer.
     This applies both to GDB commands and their output, and to the
     This applies both to GDB commands and their output, and to the
     input and output done by the program you are debugging.
     input and output done by the program you are debugging.
     This is useful because it means that you can copy the text of
     This is useful because it means that you can copy the text of
     previous commands and input them again; you can even use parts of
     previous commands and input them again; you can even use parts of
     the output in this way.
     the output in this way.
     All the facilities of Emacs' Shell mode are available for
     All the facilities of Emacs' Shell mode are available for
     interacting with your program.  In particular, you can send
     interacting with your program.  In particular, you can send
     signals the usual way--for example, `C-c C-c' for an interrupt,
     signals the usual way--for example, `C-c C-c' for an interrupt,
     `C-c C-z' for a stop.
     `C-c C-z' for a stop.
   * GDB displays source code through Emacs.
   * GDB displays source code through Emacs.
     Each time GDB displays a stack frame, Emacs automatically finds the
     Each time GDB displays a stack frame, Emacs automatically finds the
     source file for that frame and puts an arrow (`=>') at the left
     source file for that frame and puts an arrow (`=>') at the left
     margin of the current line.  Emacs uses a separate buffer for
     margin of the current line.  Emacs uses a separate buffer for
     source display, and splits the screen to show both your GDB session
     source display, and splits the screen to show both your GDB session
     and the source.
     and the source.
     Explicit GDB `list' or search commands still produce output as
     Explicit GDB `list' or search commands still produce output as
     usual, but you probably have no reason to use them from Emacs.
     usual, but you probably have no reason to use them from Emacs.
   We call this "text command mode".  Emacs 22.1, and later, also uses
   We call this "text command mode".  Emacs 22.1, and later, also uses
a graphical mode, enabled by default, which provides further buffers
a graphical mode, enabled by default, which provides further buffers
that can control the execution and describe the state of your program.
that can control the execution and describe the state of your program.
*Note GDB Graphical Interface: (Emacs)GDB Graphical Interface.
*Note GDB Graphical Interface: (Emacs)GDB Graphical Interface.
   If you specify an absolute file name when prompted for the `M-x gdb'
   If you specify an absolute file name when prompted for the `M-x gdb'
argument, then Emacs sets your current working directory to where your
argument, then Emacs sets your current working directory to where your
program resides.  If you only specify the file name, then Emacs sets
program resides.  If you only specify the file name, then Emacs sets
your current working directory to to the directory associated with the
your current working directory to to the directory associated with the
previous buffer.  In this case, GDB may find your program by searching
previous buffer.  In this case, GDB may find your program by searching
your environment's `PATH' variable, but on some operating systems it
your environment's `PATH' variable, but on some operating systems it
might not find the source.  So, although the GDB input and output
might not find the source.  So, although the GDB input and output
session proceeds normally, the auxiliary buffer does not display the
session proceeds normally, the auxiliary buffer does not display the
current source and line of execution.
current source and line of execution.
   The initial working directory of GDB is printed on the top line of
   The initial working directory of GDB is printed on the top line of
the GUD buffer and this serves as a default for the commands that
the GUD buffer and this serves as a default for the commands that
specify files for GDB to operate on.  *Note Commands to Specify Files:
specify files for GDB to operate on.  *Note Commands to Specify Files:
Files.
Files.
   By default, `M-x gdb' calls the program called `gdb'.  If you need
   By default, `M-x gdb' calls the program called `gdb'.  If you need
to call GDB by a different name (for example, if you keep several
to call GDB by a different name (for example, if you keep several
configurations around, with different names) you can customize the
configurations around, with different names) you can customize the
Emacs variable `gud-gdb-command-name' to run the one you want.
Emacs variable `gud-gdb-command-name' to run the one you want.
   In the GUD buffer, you can use these special Emacs commands in
   In the GUD buffer, you can use these special Emacs commands in
addition to the standard Shell mode commands:
addition to the standard Shell mode commands:
`C-h m'
`C-h m'
     Describe the features of Emacs' GUD Mode.
     Describe the features of Emacs' GUD Mode.
`C-c C-s'
`C-c C-s'
     Execute to another source line, like the GDB `step' command; also
     Execute to another source line, like the GDB `step' command; also
     update the display window to show the current file and location.
     update the display window to show the current file and location.
`C-c C-n'
`C-c C-n'
     Execute to next source line in this function, skipping all function
     Execute to next source line in this function, skipping all function
     calls, like the GDB `next' command.  Then update the display window
     calls, like the GDB `next' command.  Then update the display window
     to show the current file and location.
     to show the current file and location.
`C-c C-i'
`C-c C-i'
     Execute one instruction, like the GDB `stepi' command; update
     Execute one instruction, like the GDB `stepi' command; update
     display window accordingly.
     display window accordingly.
`C-c C-f'
`C-c C-f'
     Execute until exit from the selected stack frame, like the GDB
     Execute until exit from the selected stack frame, like the GDB
     `finish' command.
     `finish' command.
`C-c C-r'
`C-c C-r'
     Continue execution of your program, like the GDB `continue'
     Continue execution of your program, like the GDB `continue'
     command.
     command.
`C-c <'
`C-c <'
     Go up the number of frames indicated by the numeric argument
     Go up the number of frames indicated by the numeric argument
     (*note Numeric Arguments: (Emacs)Arguments.), like the GDB `up'
     (*note Numeric Arguments: (Emacs)Arguments.), like the GDB `up'
     command.
     command.
`C-c >'
`C-c >'
     Go down the number of frames indicated by the numeric argument,
     Go down the number of frames indicated by the numeric argument,
     like the GDB `down' command.
     like the GDB `down' command.
   In any source file, the Emacs command `C-x ' (`gud-break')
   In any source file, the Emacs command `C-x ' (`gud-break')
tells GDB to set a breakpoint on the source line point is on.
tells GDB to set a breakpoint on the source line point is on.
   In text command mode, if you type `M-x speedbar', Emacs displays a
   In text command mode, if you type `M-x speedbar', Emacs displays a
separate frame which shows a backtrace when the GUD buffer is current.
separate frame which shows a backtrace when the GUD buffer is current.
Move point to any frame in the stack and type  to make it become
Move point to any frame in the stack and type  to make it become
the current frame and display the associated source in the source
the current frame and display the associated source in the source
buffer.  Alternatively, click `Mouse-2' to make the selected frame
buffer.  Alternatively, click `Mouse-2' to make the selected frame
become the current one.  In graphical mode, the speedbar displays watch
become the current one.  In graphical mode, the speedbar displays watch
expressions.
expressions.
   If you accidentally delete the source-display buffer, an easy way to
   If you accidentally delete the source-display buffer, an easy way to
get it back is to type the command `f' in the GDB buffer, to request a
get it back is to type the command `f' in the GDB buffer, to request a
frame display; when you run under Emacs, this recreates the source
frame display; when you run under Emacs, this recreates the source
buffer if necessary to show you the context of the current frame.
buffer if necessary to show you the context of the current frame.
   The source files displayed in Emacs are in ordinary Emacs buffers
   The source files displayed in Emacs are in ordinary Emacs buffers
which are visiting the source files in the usual way.  You can edit the
which are visiting the source files in the usual way.  You can edit the
files with these buffers if you wish; but keep in mind that GDB
files with these buffers if you wish; but keep in mind that GDB
communicates with Emacs in terms of line numbers.  If you add or delete
communicates with Emacs in terms of line numbers.  If you add or delete
lines from the text, the line numbers that GDB knows cease to
lines from the text, the line numbers that GDB knows cease to
correspond properly with the code.
correspond properly with the code.
   A more detailed description of Emacs' interaction with GDB is given
   A more detailed description of Emacs' interaction with GDB is given
in the Emacs manual (*note Debuggers: (Emacs)Debuggers.).
in the Emacs manual (*note Debuggers: (Emacs)Debuggers.).


File: gdb.info,  Node: GDB/MI,  Next: Annotations,  Prev: Emacs,  Up: Top
File: gdb.info,  Node: GDB/MI,  Next: Annotations,  Prev: Emacs,  Up: Top
24 The GDB/MI Interface
24 The GDB/MI Interface
***********************
***********************
Function and Purpose
Function and Purpose
====================
====================
GDB/MI is a line based machine oriented text interface to GDB and is
GDB/MI is a line based machine oriented text interface to GDB and is
activated by specifying using the `--interpreter' command line option
activated by specifying using the `--interpreter' command line option
(*note Mode Options::).  It is specifically intended to support the
(*note Mode Options::).  It is specifically intended to support the
development of systems which use the debugger as just one small
development of systems which use the debugger as just one small
component of a larger system.
component of a larger system.
   This chapter is a specification of the GDB/MI interface.  It is
   This chapter is a specification of the GDB/MI interface.  It is
written in the form of a reference manual.
written in the form of a reference manual.
   Note that GDB/MI is still under construction, so some of the
   Note that GDB/MI is still under construction, so some of the
features described below are incomplete and subject to change (*note
features described below are incomplete and subject to change (*note
GDB/MI Development and Front Ends: GDB/MI Development and Front Ends.).
GDB/MI Development and Front Ends: GDB/MI Development and Front Ends.).
Notation and Terminology
Notation and Terminology
========================
========================
This chapter uses the following notation:
This chapter uses the following notation:
   * `|' separates two alternatives.
   * `|' separates two alternatives.
   * `[ SOMETHING ]' indicates that SOMETHING is optional: it may or
   * `[ SOMETHING ]' indicates that SOMETHING is optional: it may or
     may not be given.
     may not be given.
   * `( GROUP )*' means that GROUP inside the parentheses may repeat
   * `( GROUP )*' means that GROUP inside the parentheses may repeat
     zero or more times.
     zero or more times.
   * `( GROUP )+' means that GROUP inside the parentheses may repeat
   * `( GROUP )+' means that GROUP inside the parentheses may repeat
     one or more times.
     one or more times.
   * `"STRING"' means a literal STRING.
   * `"STRING"' means a literal STRING.
* Menu:
* Menu:
* GDB/MI Command Syntax::
* GDB/MI Command Syntax::
* GDB/MI Compatibility with CLI::
* GDB/MI Compatibility with CLI::
* GDB/MI Development and Front Ends::
* GDB/MI Development and Front Ends::
* GDB/MI Output Records::
* GDB/MI Output Records::
* GDB/MI Simple Examples::
* GDB/MI Simple Examples::
* GDB/MI Command Description Format::
* GDB/MI Command Description Format::
* GDB/MI Breakpoint Commands::
* GDB/MI Breakpoint Commands::
* GDB/MI Program Context::
* GDB/MI Program Context::
* GDB/MI Thread Commands::
* GDB/MI Thread Commands::
* GDB/MI Program Execution::
* GDB/MI Program Execution::
* GDB/MI Stack Manipulation::
* GDB/MI Stack Manipulation::
* GDB/MI Variable Objects::
* GDB/MI Variable Objects::
* GDB/MI Data Manipulation::
* GDB/MI Data Manipulation::
* GDB/MI Tracepoint Commands::
* GDB/MI Tracepoint Commands::
* GDB/MI Symbol Query::
* GDB/MI Symbol Query::
* GDB/MI File Commands::
* GDB/MI File Commands::
* GDB/MI Target Manipulation::
* GDB/MI Target Manipulation::
* GDB/MI File Transfer Commands::
* GDB/MI File Transfer Commands::
* GDB/MI Miscellaneous Commands::
* GDB/MI Miscellaneous Commands::


File: gdb.info,  Node: GDB/MI Command Syntax,  Next: GDB/MI Compatibility with CLI,  Up: GDB/MI
File: gdb.info,  Node: GDB/MI Command Syntax,  Next: GDB/MI Compatibility with CLI,  Up: GDB/MI
24.1 GDB/MI Command Syntax
24.1 GDB/MI Command Syntax
==========================
==========================
* Menu:
* Menu:
* GDB/MI Input Syntax::
* GDB/MI Input Syntax::
* GDB/MI Output Syntax::
* GDB/MI Output Syntax::


File: gdb.info,  Node: GDB/MI Input Syntax,  Next: GDB/MI Output Syntax,  Up: GDB/MI Command Syntax
File: gdb.info,  Node: GDB/MI Input Syntax,  Next: GDB/MI Output Syntax,  Up: GDB/MI Command Syntax
24.1.1 GDB/MI Input Syntax
24.1.1 GDB/MI Input Syntax
--------------------------
--------------------------
`COMMAND ==>'
`COMMAND ==>'
     `CLI-COMMAND | MI-COMMAND'
     `CLI-COMMAND | MI-COMMAND'
`CLI-COMMAND ==>'
`CLI-COMMAND ==>'
     `[ TOKEN ] CLI-COMMAND NL', where CLI-COMMAND is any existing GDB
     `[ TOKEN ] CLI-COMMAND NL', where CLI-COMMAND is any existing GDB
     CLI command.
     CLI command.
`MI-COMMAND ==>'
`MI-COMMAND ==>'
     `[ TOKEN ] "-" OPERATION ( " " OPTION )* `[' " --" `]' ( " "
     `[ TOKEN ] "-" OPERATION ( " " OPTION )* `[' " --" `]' ( " "
     PARAMETER )* NL'
     PARAMETER )* NL'
`TOKEN ==>'
`TOKEN ==>'
     "any sequence of digits"
     "any sequence of digits"
`OPTION ==>'
`OPTION ==>'
     `"-" PARAMETER [ " " PARAMETER ]'
     `"-" PARAMETER [ " " PARAMETER ]'
`PARAMETER ==>'
`PARAMETER ==>'
     `NON-BLANK-SEQUENCE | C-STRING'
     `NON-BLANK-SEQUENCE | C-STRING'
`OPERATION ==>'
`OPERATION ==>'
     _any of the operations described in this chapter_
     _any of the operations described in this chapter_
`NON-BLANK-SEQUENCE ==>'
`NON-BLANK-SEQUENCE ==>'
     _anything, provided it doesn't contain special characters such as
     _anything, provided it doesn't contain special characters such as
     "-", NL, """ and of course " "_
     "-", NL, """ and of course " "_
`C-STRING ==>'
`C-STRING ==>'
     `""" SEVEN-BIT-ISO-C-STRING-CONTENT """'
     `""" SEVEN-BIT-ISO-C-STRING-CONTENT """'
`NL ==>'
`NL ==>'
     `CR | CR-LF'
     `CR | CR-LF'
Notes:
Notes:
   * The CLI commands are still handled by the MI interpreter; their
   * The CLI commands are still handled by the MI interpreter; their
     output is described below.
     output is described below.
   * The `TOKEN', when present, is passed back when the command
   * The `TOKEN', when present, is passed back when the command
     finishes.
     finishes.
   * Some MI commands accept optional arguments as part of the parameter
   * Some MI commands accept optional arguments as part of the parameter
     list.  Each option is identified by a leading `-' (dash) and may be
     list.  Each option is identified by a leading `-' (dash) and may be
     followed by an optional argument parameter.  Options occur first
     followed by an optional argument parameter.  Options occur first
     in the parameter list and can be delimited from normal parameters
     in the parameter list and can be delimited from normal parameters
     using `--' (this is useful when some parameters begin with a dash).
     using `--' (this is useful when some parameters begin with a dash).
   Pragmatics:
   Pragmatics:
   * We want easy access to the existing CLI syntax (for debugging).
   * We want easy access to the existing CLI syntax (for debugging).
   * We want it to be easy to spot a MI operation.
   * We want it to be easy to spot a MI operation.


File: gdb.info,  Node: GDB/MI Output Syntax,  Prev: GDB/MI Input Syntax,  Up: GDB/MI Command Syntax
File: gdb.info,  Node: GDB/MI Output Syntax,  Prev: GDB/MI Input Syntax,  Up: GDB/MI Command Syntax
24.1.2 GDB/MI Output Syntax
24.1.2 GDB/MI Output Syntax
---------------------------
---------------------------
The output from GDB/MI consists of zero or more out-of-band records
The output from GDB/MI consists of zero or more out-of-band records
followed, optionally, by a single result record.  This result record is
followed, optionally, by a single result record.  This result record is
for the most recent command.  The sequence of output records is
for the most recent command.  The sequence of output records is
terminated by `(gdb)'.
terminated by `(gdb)'.
   If an input command was prefixed with a `TOKEN' then the
   If an input command was prefixed with a `TOKEN' then the
corresponding output for that command will also be prefixed by that same
corresponding output for that command will also be prefixed by that same
TOKEN.
TOKEN.
`OUTPUT ==>'
`OUTPUT ==>'
     `( OUT-OF-BAND-RECORD )* [ RESULT-RECORD ] "(gdb)" NL'
     `( OUT-OF-BAND-RECORD )* [ RESULT-RECORD ] "(gdb)" NL'
`RESULT-RECORD ==>'
`RESULT-RECORD ==>'
     ` [ TOKEN ] "^" RESULT-CLASS ( "," RESULT )* NL'
     ` [ TOKEN ] "^" RESULT-CLASS ( "," RESULT )* NL'
`OUT-OF-BAND-RECORD ==>'
`OUT-OF-BAND-RECORD ==>'
     `ASYNC-RECORD | STREAM-RECORD'
     `ASYNC-RECORD | STREAM-RECORD'
`ASYNC-RECORD ==>'
`ASYNC-RECORD ==>'
     `EXEC-ASYNC-OUTPUT | STATUS-ASYNC-OUTPUT | NOTIFY-ASYNC-OUTPUT'
     `EXEC-ASYNC-OUTPUT | STATUS-ASYNC-OUTPUT | NOTIFY-ASYNC-OUTPUT'
`EXEC-ASYNC-OUTPUT ==>'
`EXEC-ASYNC-OUTPUT ==>'
     `[ TOKEN ] "*" ASYNC-OUTPUT'
     `[ TOKEN ] "*" ASYNC-OUTPUT'
`STATUS-ASYNC-OUTPUT ==>'
`STATUS-ASYNC-OUTPUT ==>'
     `[ TOKEN ] "+" ASYNC-OUTPUT'
     `[ TOKEN ] "+" ASYNC-OUTPUT'
`NOTIFY-ASYNC-OUTPUT ==>'
`NOTIFY-ASYNC-OUTPUT ==>'
     `[ TOKEN ] "=" ASYNC-OUTPUT'
     `[ TOKEN ] "=" ASYNC-OUTPUT'
`ASYNC-OUTPUT ==>'
`ASYNC-OUTPUT ==>'
     `ASYNC-CLASS ( "," RESULT )* NL'
     `ASYNC-CLASS ( "," RESULT )* NL'
`RESULT-CLASS ==>'
`RESULT-CLASS ==>'
     `"done" | "running" | "connected" | "error" | "exit"'
     `"done" | "running" | "connected" | "error" | "exit"'
`ASYNC-CLASS ==>'
`ASYNC-CLASS ==>'
     `"stopped" | OTHERS' (where OTHERS will be added depending on the
     `"stopped" | OTHERS' (where OTHERS will be added depending on the
     needs--this is still in development).
     needs--this is still in development).
`RESULT ==>'
`RESULT ==>'
     ` VARIABLE "=" VALUE'
     ` VARIABLE "=" VALUE'
`VARIABLE ==>'
`VARIABLE ==>'
     ` STRING '
     ` STRING '
`VALUE ==>'
`VALUE ==>'
     ` CONST | TUPLE | LIST '
     ` CONST | TUPLE | LIST '
`CONST ==>'
`CONST ==>'
     `C-STRING'
     `C-STRING'
`TUPLE ==>'
`TUPLE ==>'
     ` "{}" | "{" RESULT ( "," RESULT )* "}" '
     ` "{}" | "{" RESULT ( "," RESULT )* "}" '
`LIST ==>'
`LIST ==>'
     ` "[]" | "[" VALUE ( "," VALUE )* "]" | "[" RESULT ( "," RESULT )*
     ` "[]" | "[" VALUE ( "," VALUE )* "]" | "[" RESULT ( "," RESULT )*
     "]" '
     "]" '
`STREAM-RECORD ==>'
`STREAM-RECORD ==>'
     `CONSOLE-STREAM-OUTPUT | TARGET-STREAM-OUTPUT | LOG-STREAM-OUTPUT'
     `CONSOLE-STREAM-OUTPUT | TARGET-STREAM-OUTPUT | LOG-STREAM-OUTPUT'
`CONSOLE-STREAM-OUTPUT ==>'
`CONSOLE-STREAM-OUTPUT ==>'
     `"~" C-STRING'
     `"~" C-STRING'
`TARGET-STREAM-OUTPUT ==>'
`TARGET-STREAM-OUTPUT ==>'
     `"@" C-STRING'
     `"@" C-STRING'
`LOG-STREAM-OUTPUT ==>'
`LOG-STREAM-OUTPUT ==>'
     `"&" C-STRING'
     `"&" C-STRING'
`NL ==>'
`NL ==>'
     `CR | CR-LF'
     `CR | CR-LF'
`TOKEN ==>'
`TOKEN ==>'
     _any sequence of digits_.
     _any sequence of digits_.
Notes:
Notes:
   * All output sequences end in a single line containing a period.
   * All output sequences end in a single line containing a period.
   * The `TOKEN' is from the corresponding request.  If an execution
   * The `TOKEN' is from the corresponding request.  If an execution
     command is interrupted by the `-exec-interrupt' command, the TOKEN
     command is interrupted by the `-exec-interrupt' command, the TOKEN
     associated with the `*stopped' message is the one of the original
     associated with the `*stopped' message is the one of the original
     execution command, not the one of the interrupt command.
     execution command, not the one of the interrupt command.
   * STATUS-ASYNC-OUTPUT contains on-going status information about the
   * STATUS-ASYNC-OUTPUT contains on-going status information about the
     progress of a slow operation.  It can be discarded.  All status
     progress of a slow operation.  It can be discarded.  All status
     output is prefixed by `+'.
     output is prefixed by `+'.
   * EXEC-ASYNC-OUTPUT contains asynchronous state change on the target
   * EXEC-ASYNC-OUTPUT contains asynchronous state change on the target
     (stopped, started, disappeared).  All async output is prefixed by
     (stopped, started, disappeared).  All async output is prefixed by
     `*'.
     `*'.
   * NOTIFY-ASYNC-OUTPUT contains supplementary information that the
   * NOTIFY-ASYNC-OUTPUT contains supplementary information that the
     client should handle (e.g., a new breakpoint information).  All
     client should handle (e.g., a new breakpoint information).  All
     notify output is prefixed by `='.
     notify output is prefixed by `='.
   * CONSOLE-STREAM-OUTPUT is output that should be displayed as is in
   * CONSOLE-STREAM-OUTPUT is output that should be displayed as is in
     the console.  It is the textual response to a CLI command.  All
     the console.  It is the textual response to a CLI command.  All
     the console output is prefixed by `~'.
     the console output is prefixed by `~'.
   * TARGET-STREAM-OUTPUT is the output produced by the target program.
   * TARGET-STREAM-OUTPUT is the output produced by the target program.
     All the target output is prefixed by `@'.
     All the target output is prefixed by `@'.
   * LOG-STREAM-OUTPUT is output text coming from GDB's internals, for
   * LOG-STREAM-OUTPUT is output text coming from GDB's internals, for
     instance messages that should be displayed as part of an error
     instance messages that should be displayed as part of an error
     log.  All the log output is prefixed by `&'.
     log.  All the log output is prefixed by `&'.
   * New GDB/MI commands should only output LISTS containing VALUES.
   * New GDB/MI commands should only output LISTS containing VALUES.
   *Note GDB/MI Stream Records: GDB/MI Stream Records, for more details
   *Note GDB/MI Stream Records: GDB/MI Stream Records, for more details
about the various output records.
about the various output records.


File: gdb.info,  Node: GDB/MI Compatibility with CLI,  Next: GDB/MI Development and Front Ends,  Prev: GDB/MI Command Syntax,  Up: GDB/MI
File: gdb.info,  Node: GDB/MI Compatibility with CLI,  Next: GDB/MI Development and Front Ends,  Prev: GDB/MI Command Syntax,  Up: GDB/MI
24.2 GDB/MI Compatibility with CLI
24.2 GDB/MI Compatibility with CLI
==================================
==================================
For the developers convenience CLI commands can be entered directly,
For the developers convenience CLI commands can be entered directly,
but there may be some unexpected behaviour.  For example, commands that
but there may be some unexpected behaviour.  For example, commands that
query the user will behave as if the user replied yes, breakpoint
query the user will behave as if the user replied yes, breakpoint
command lists are not executed and some CLI commands, such as `if',
command lists are not executed and some CLI commands, such as `if',
`when' and `define', prompt for further input with `>', which is not
`when' and `define', prompt for further input with `>', which is not
valid MI output.
valid MI output.
   This feature may be removed at some stage in the future and it is
   This feature may be removed at some stage in the future and it is
recommended that front ends use the `-interpreter-exec' command (*note
recommended that front ends use the `-interpreter-exec' command (*note
-interpreter-exec::).
-interpreter-exec::).


File: gdb.info,  Node: GDB/MI Development and Front Ends,  Next: GDB/MI Output Records,  Prev: GDB/MI Compatibility with CLI,  Up: GDB/MI
File: gdb.info,  Node: GDB/MI Development and Front Ends,  Next: GDB/MI Output Records,  Prev: GDB/MI Compatibility with CLI,  Up: GDB/MI
24.3 GDB/MI Development and Front Ends
24.3 GDB/MI Development and Front Ends
======================================
======================================
The application which takes the MI output and presents the state of the
The application which takes the MI output and presents the state of the
program being debugged to the user is called a "front end".
program being debugged to the user is called a "front end".
   Although GDB/MI is still incomplete, it is currently being used by a
   Although GDB/MI is still incomplete, it is currently being used by a
variety of front ends to GDB.  This makes it difficult to introduce new
variety of front ends to GDB.  This makes it difficult to introduce new
functionality without breaking existing usage.  This section tries to
functionality without breaking existing usage.  This section tries to
minimize the problems by describing how the protocol might change.
minimize the problems by describing how the protocol might change.
   Some changes in MI need not break a carefully designed front end, and
   Some changes in MI need not break a carefully designed front end, and
for these the MI version will remain unchanged.  The following is a
for these the MI version will remain unchanged.  The following is a
list of changes that may occur within one level, so front ends should
list of changes that may occur within one level, so front ends should
parse MI output in a way that can handle them:
parse MI output in a way that can handle them:
   * New MI commands may be added.
   * New MI commands may be added.
   * New fields may be added to the output of any MI command.
   * New fields may be added to the output of any MI command.
   * The range of values for fields with specified values, e.g.,
   * The range of values for fields with specified values, e.g.,
     `in_scope' (*note -var-update::) may be extended.
     `in_scope' (*note -var-update::) may be extended.
   If the changes are likely to break front ends, the MI version level
   If the changes are likely to break front ends, the MI version level
will be increased by one.  This will allow the front end to parse the
will be increased by one.  This will allow the front end to parse the
output according to the MI version.  Apart from mi0, new versions of
output according to the MI version.  Apart from mi0, new versions of
GDB will not support old versions of MI and it will be the
GDB will not support old versions of MI and it will be the
responsibility of the front end to work with the new one.
responsibility of the front end to work with the new one.
   The best way to avoid unexpected changes in MI that might break your
   The best way to avoid unexpected changes in MI that might break your
front end is to make your project known to GDB developers and follow
front end is to make your project known to GDB developers and follow
development on  and .
development on  and .
There is also the mailing list ,
There is also the mailing list ,
hosted by the Free Standards Group, which has the aim of creating a
hosted by the Free Standards Group, which has the aim of creating a
more general MI protocol called Debugger Machine Interface (DMI) that
more general MI protocol called Debugger Machine Interface (DMI) that
will become a standard for all debuggers, not just GDB.
will become a standard for all debuggers, not just GDB.


File: gdb.info,  Node: GDB/MI Output Records,  Next: GDB/MI Simple Examples,  Prev: GDB/MI Development and Front Ends,  Up: GDB/MI
File: gdb.info,  Node: GDB/MI Output Records,  Next: GDB/MI Simple Examples,  Prev: GDB/MI Development and Front Ends,  Up: GDB/MI
24.4 GDB/MI Output Records
24.4 GDB/MI Output Records
==========================
==========================
* Menu:
* Menu:
* GDB/MI Result Records::
* GDB/MI Result Records::
* GDB/MI Stream Records::
* GDB/MI Stream Records::
* GDB/MI Out-of-band Records::
* GDB/MI Out-of-band Records::


File: gdb.info,  Node: GDB/MI Result Records,  Next: GDB/MI Stream Records,  Up: GDB/MI Output Records
File: gdb.info,  Node: GDB/MI Result Records,  Next: GDB/MI Stream Records,  Up: GDB/MI Output Records
24.4.1 GDB/MI Result Records
24.4.1 GDB/MI Result Records
----------------------------
----------------------------
In addition to a number of out-of-band notifications, the response to a
In addition to a number of out-of-band notifications, the response to a
GDB/MI command includes one of the following result indications:
GDB/MI command includes one of the following result indications:
`"^done" [ "," RESULTS ]'
`"^done" [ "," RESULTS ]'
     The synchronous operation was successful, `RESULTS' are the return
     The synchronous operation was successful, `RESULTS' are the return
     values.
     values.
`"^running"'
`"^running"'
     The asynchronous operation was successfully started.  The target is
     The asynchronous operation was successfully started.  The target is
     running.
     running.
`"^connected"'
`"^connected"'
     GDB has connected to a remote target.
     GDB has connected to a remote target.
`"^error" "," C-STRING'
`"^error" "," C-STRING'
     The operation failed.  The `C-STRING' contains the corresponding
     The operation failed.  The `C-STRING' contains the corresponding
     error message.
     error message.
`"^exit"'
`"^exit"'
     GDB has terminated.
     GDB has terminated.


File: gdb.info,  Node: GDB/MI Stream Records,  Next: GDB/MI Out-of-band Records,  Prev: GDB/MI Result Records,  Up: GDB/MI Output Records
File: gdb.info,  Node: GDB/MI Stream Records,  Next: GDB/MI Out-of-band Records,  Prev: GDB/MI Result Records,  Up: GDB/MI Output Records
24.4.2 GDB/MI Stream Records
24.4.2 GDB/MI Stream Records
----------------------------
----------------------------
GDB internally maintains a number of output streams: the console, the
GDB internally maintains a number of output streams: the console, the
target, and the log.  The output intended for each of these streams is
target, and the log.  The output intended for each of these streams is
funneled through the GDB/MI interface using "stream records".
funneled through the GDB/MI interface using "stream records".
   Each stream record begins with a unique "prefix character" which
   Each stream record begins with a unique "prefix character" which
identifies its stream (*note GDB/MI Output Syntax: GDB/MI Output
identifies its stream (*note GDB/MI Output Syntax: GDB/MI Output
Syntax.).  In addition to the prefix, each stream record contains a
Syntax.).  In addition to the prefix, each stream record contains a
`STRING-OUTPUT'.  This is either raw text (with an implicit new line)
`STRING-OUTPUT'.  This is either raw text (with an implicit new line)
or a quoted C string (which does not contain an implicit newline).
or a quoted C string (which does not contain an implicit newline).
`"~" STRING-OUTPUT'
`"~" STRING-OUTPUT'
     The console output stream contains text that should be displayed
     The console output stream contains text that should be displayed
     in the CLI console window.  It contains the textual responses to
     in the CLI console window.  It contains the textual responses to
     CLI commands.
     CLI commands.
`"@" STRING-OUTPUT'
`"@" STRING-OUTPUT'
     The target output stream contains any textual output from the
     The target output stream contains any textual output from the
     running target.  This is only present when GDB's event loop is
     running target.  This is only present when GDB's event loop is
     truly asynchronous, which is currently only the case for remote
     truly asynchronous, which is currently only the case for remote
     targets.
     targets.
`"&" STRING-OUTPUT'
`"&" STRING-OUTPUT'
     The log stream contains debugging messages being produced by GDB's
     The log stream contains debugging messages being produced by GDB's
     internals.
     internals.


File: gdb.info,  Node: GDB/MI Out-of-band Records,  Prev: GDB/MI Stream Records,  Up: GDB/MI Output Records
File: gdb.info,  Node: GDB/MI Out-of-band Records,  Prev: GDB/MI Stream Records,  Up: GDB/MI Output Records
24.4.3 GDB/MI Out-of-band Records
24.4.3 GDB/MI Out-of-band Records
---------------------------------
---------------------------------
"Out-of-band" records are used to notify the GDB/MI client of
"Out-of-band" records are used to notify the GDB/MI client of
additional changes that have occurred.  Those changes can either be a
additional changes that have occurred.  Those changes can either be a
consequence of GDB/MI (e.g., a breakpoint modified) or a result of
consequence of GDB/MI (e.g., a breakpoint modified) or a result of
target activity (e.g., target stopped).
target activity (e.g., target stopped).
   The following is a preliminary list of possible out-of-band records.
   The following is a preliminary list of possible out-of-band records.
In particular, the EXEC-ASYNC-OUTPUT records.
In particular, the EXEC-ASYNC-OUTPUT records.
`*stopped,reason="REASON"'
`*stopped,reason="REASON"'
   REASON can be one of the following:
   REASON can be one of the following:
`breakpoint-hit'
`breakpoint-hit'
     A breakpoint was reached.
     A breakpoint was reached.
`watchpoint-trigger'
`watchpoint-trigger'
     A watchpoint was triggered.
     A watchpoint was triggered.
`read-watchpoint-trigger'
`read-watchpoint-trigger'
     A read watchpoint was triggered.
     A read watchpoint was triggered.
`access-watchpoint-trigger'
`access-watchpoint-trigger'
     An access watchpoint was triggered.
     An access watchpoint was triggered.
`function-finished'
`function-finished'
     An -exec-finish or similar CLI command was accomplished.
     An -exec-finish or similar CLI command was accomplished.
`location-reached'
`location-reached'
     An -exec-until or similar CLI command was accomplished.
     An -exec-until or similar CLI command was accomplished.
`watchpoint-scope'
`watchpoint-scope'
     A watchpoint has gone out of scope.
     A watchpoint has gone out of scope.
`end-stepping-range'
`end-stepping-range'
     An -exec-next, -exec-next-instruction, -exec-step,
     An -exec-next, -exec-next-instruction, -exec-step,
     -exec-step-instruction or similar CLI command was accomplished.
     -exec-step-instruction or similar CLI command was accomplished.
`exited-signalled'
`exited-signalled'
     The inferior exited because of a signal.
     The inferior exited because of a signal.
`exited'
`exited'
     The inferior exited.
     The inferior exited.
`exited-normally'
`exited-normally'
     The inferior exited normally.
     The inferior exited normally.
`signal-received'
`signal-received'
     A signal was received by the inferior.
     A signal was received by the inferior.


File: gdb.info,  Node: GDB/MI Simple Examples,  Next: GDB/MI Command Description Format,  Prev: GDB/MI Output Records,  Up: GDB/MI
File: gdb.info,  Node: GDB/MI Simple Examples,  Next: GDB/MI Command Description Format,  Prev: GDB/MI Output Records,  Up: GDB/MI
24.5 Simple Examples of GDB/MI Interaction
24.5 Simple Examples of GDB/MI Interaction
==========================================
==========================================
This subsection presents several simple examples of interaction using
This subsection presents several simple examples of interaction using
the GDB/MI interface.  In these examples, `->' means that the following
the GDB/MI interface.  In these examples, `->' means that the following
line is passed to GDB/MI as input, while `<-' means the output received
line is passed to GDB/MI as input, while `<-' means the output received
from GDB/MI.
from GDB/MI.
   Note the line breaks shown in the examples are here only for
   Note the line breaks shown in the examples are here only for
readability, they don't appear in the real output.
readability, they don't appear in the real output.
Setting a Breakpoint
Setting a Breakpoint
--------------------
--------------------
Setting a breakpoint generates synchronous output which contains
Setting a breakpoint generates synchronous output which contains
detailed information of the breakpoint.
detailed information of the breakpoint.
     -> -break-insert main
     -> -break-insert main
     <- ^done,bkpt={number="1",type="breakpoint",disp="keep",
     <- ^done,bkpt={number="1",type="breakpoint",disp="keep",
         enabled="y",addr="0x08048564",func="main",file="myprog.c",
         enabled="y",addr="0x08048564",func="main",file="myprog.c",
         fullname="/home/nickrob/myprog.c",line="68",times="0"}
         fullname="/home/nickrob/myprog.c",line="68",times="0"}
     <- (gdb)
     <- (gdb)
Program Execution
Program Execution
-----------------
-----------------
Program execution generates asynchronous records and MI gives the
Program execution generates asynchronous records and MI gives the
reason that execution stopped.
reason that execution stopped.
     -> -exec-run
     -> -exec-run
     <- ^running
     <- ^running
     <- (gdb)
     <- (gdb)
     <- *stopped,reason="breakpoint-hit",bkptno="1",thread-id="0",
     <- *stopped,reason="breakpoint-hit",bkptno="1",thread-id="0",
        frame={addr="0x08048564",func="main",
        frame={addr="0x08048564",func="main",
        args=[{name="argc",value="1"},{name="argv",value="0xbfc4d4d4"}],
        args=[{name="argc",value="1"},{name="argv",value="0xbfc4d4d4"}],
        file="myprog.c",fullname="/home/nickrob/myprog.c",line="68"}
        file="myprog.c",fullname="/home/nickrob/myprog.c",line="68"}
     <- (gdb)
     <- (gdb)
     -> -exec-continue
     -> -exec-continue
     <- ^running
     <- ^running
     <- (gdb)
     <- (gdb)
     <- *stopped,reason="exited-normally"
     <- *stopped,reason="exited-normally"
     <- (gdb)
     <- (gdb)
Quitting GDB
Quitting GDB
------------
------------
Quitting GDB just prints the result class `^exit'.
Quitting GDB just prints the result class `^exit'.
     -> (gdb)
     -> (gdb)
     <- -gdb-exit
     <- -gdb-exit
     <- ^exit
     <- ^exit
A Bad Command
A Bad Command
-------------
-------------
Here's what happens if you pass a non-existent command:
Here's what happens if you pass a non-existent command:
     -> -rubbish
     -> -rubbish
     <- ^error,msg="Undefined MI command: rubbish"
     <- ^error,msg="Undefined MI command: rubbish"
     <- (gdb)
     <- (gdb)
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.