OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [doc/] [libgdb.texinfo] - Diff between revs 107 and 1765

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

Rev 107 Rev 1765
\input texinfo   @c -*-texinfo-*-
\input texinfo   @c -*-texinfo-*-
@c %**start of header
@c %**start of header
@setfilename libgdb.info
@setfilename libgdb.info
@settitle Libgdb
@settitle Libgdb
@setchapternewpage off
@setchapternewpage off
@c %**end of header
@c %**end of header
 
 
@ifinfo
@ifinfo
This file documents libgdb, the GNU symbolic debugger in a library.
This file documents libgdb, the GNU symbolic debugger in a library.
 
 
This is Edition 0.3, Oct 1993, of @cite{Libgdb}.
This is Edition 0.3, Oct 1993, of @cite{Libgdb}.
Copyright 1993 Cygnus Support
Copyright 1993 Cygnus Support
 
 
Permission is granted to make and distribute verbatim copies of
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
this manual provided the copyright notice and this permission notice
are preserved on all copies.
are preserved on all copies.
 
 
@ignore
@ignore
Permission is granted to process this file through TeX and print the
Permission is granted to process this file through TeX and print the
results, provided the printed document carries copying permission
results, provided the printed document carries copying permission
notice identical to this one except for the removal of this paragraph
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).
(this paragraph not being relevant to the printed manual).
 
 
@end ignore
@end ignore
Permission is granted to copy and distribute modified versions of this
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided also that the
manual under the conditions for verbatim copying, provided also that the
entire resulting derived work is distributed under the terms of a
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
permission notice identical to this one.
 
 
Permission is granted to copy and distribute translations of this manual
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions.
into another language, under the above conditions for modified versions.
@end ifinfo
@end ifinfo
 
 
@c  This title page illustrates only one of the
@c  This title page illustrates only one of the
@c  two methods of forming a title page.
@c  two methods of forming a title page.
 
 
@titlepage
@titlepage
@title Libgdb
@title Libgdb
@subtitle Version 0.3
@subtitle Version 0.3
@subtitle Oct 1993
@subtitle Oct 1993
@author Thomas Lord
@author Thomas Lord
 
 
@c  The following two commands
@c  The following two commands
@c  start the copyright page.
@c  start the copyright page.
@page
@page
@vskip 0pt plus 1filll
@vskip 0pt plus 1filll
Permission is granted to make and distribute verbatim copies of
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
this manual provided the copyright notice and this permission notice
are preserved on all copies.
are preserved on all copies.
 
 
Copyright @copyright{} 1993 Cygnus Support
Copyright @copyright{} 1993 Cygnus Support
@end titlepage
@end titlepage
 
 
@ifinfo
@ifinfo
@node Top, Overview, (dir), (dir)
@node Top, Overview, (dir), (dir)
 
 
This info file documents libgdb: an API for GDB, the GNU symbolic debugger.
This info file documents libgdb: an API for GDB, the GNU symbolic debugger.
 
 
@menu
@menu
* Overview::                 The basics of libgdb and this document.
* Overview::                 The basics of libgdb and this document.
* Interpreter::              Libgdb is an Interpreter-Based Server.
* Interpreter::              Libgdb is an Interpreter-Based Server.
* Top Level::                You Provide the Top Level for the Libgdb
* Top Level::                You Provide the Top Level for the Libgdb
                                Command Interpreter .
                                Command Interpreter .
* I/O::                      How the Server's I/O Can be Used.
* I/O::                      How the Server's I/O Can be Used.
* Invoking::                 Invoking the Interpreter, Executing
* Invoking::                 Invoking the Interpreter, Executing
                                Commands.
                                Commands.
* Defining Commands::        How New Commands are Created.
* Defining Commands::        How New Commands are Created.
* Variables::                How Builtin Variables are Defined.
* Variables::                How Builtin Variables are Defined.
* Asynchronous::             Scheduling Asynchronous Computations.
* Asynchronous::             Scheduling Asynchronous Computations.
* Commands::                 Debugger Commands for Libgdb Applications
* Commands::                 Debugger Commands for Libgdb Applications
@end menu
@end menu
 
 
@end ifinfo
@end ifinfo
@node    Overview, Interpreter, top,      top
@node    Overview, Interpreter, top,      top
@comment node-name,     next,           previous, up
@comment node-name,     next,           previous, up
@chapter Overview
@chapter Overview
@cindex overview
@cindex overview
@cindex definitions
@cindex definitions
 
 
@heading Function and Purpose
@heading Function and Purpose
 
 
Libgdb is a package which provides an API to the functionality of GDB,
Libgdb is a package which provides an API to the functionality of GDB,
the GNU symbolic debugger.  It is specifically intended to support the
the GNU symbolic debugger.  It is specifically intended to support the
development of a symbolic debugger with a graphic interface.
development of a symbolic debugger with a graphic interface.
 
 
 
 
@heading This Document
@heading This Document
 
 
This document is a specification of the libgdb API.  It is written in
This document is a specification of the libgdb API.  It is written in
the form of a programmer's manual.  So the goal of this document is to
the form of a programmer's manual.  So the goal of this document is to
explain what functions make up the API, and how they can be used in a
explain what functions make up the API, and how they can be used in a
running application.
running application.
 
 
 
 
@heading Terminology
@heading Terminology
 
 
In this document, @dfn{libgdb} refers to a library containing the
In this document, @dfn{libgdb} refers to a library containing the
functions defined herein, @dfn{application} refers to any program built
functions defined herein, @dfn{application} refers to any program built
with that library.
with that library.
 
 
 
 
@heading Dependencies
@heading Dependencies
 
 
Programs which are linked with libgdb must be linked with libbfd,
Programs which are linked with libgdb must be linked with libbfd,
libopcodes, libiberty, and libmmalloc.
libopcodes, libiberty, and libmmalloc.
 
 
@heading Acknowledgments
@heading Acknowledgments
 
 
Essential contributions to this design were made by Stu Grossman, Jim
Essential contributions to this design were made by Stu Grossman, Jim
Kingdon, and Rich Pixley.
Kingdon, and Rich Pixley.
 
 
@node Interpreter, Top Level, Overview, Top
@node Interpreter, Top Level, Overview, Top
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@chapter Libgdb is an Interpreter Based Server
@chapter Libgdb is an Interpreter Based Server
@cindex interpreter
@cindex interpreter
@cindex server
@cindex server
 
 
To understand libgdb, it is necessary to understand how the library is
To understand libgdb, it is necessary to understand how the library is
structured.  Historically, GDB is written as a small interpreter for a
structured.  Historically, GDB is written as a small interpreter for a
simple command language.  The commands of the language perform useful
simple command language.  The commands of the language perform useful
debugging functions.
debugging functions.
 
 
Libgdb is built from GDB by turning the interpreter into a debugging
Libgdb is built from GDB by turning the interpreter into a debugging
server.  The server reads debugging commands from any source and
server.  The server reads debugging commands from any source and
interprets them, directing the output arbitrarily.
interprets them, directing the output arbitrarily.
 
 
In addition to changing GDB from a tty-based program to a server, a
In addition to changing GDB from a tty-based program to a server, a
number of new GDB commands have been added to make the server more
number of new GDB commands have been added to make the server more
useful for a program with a graphic interface.
useful for a program with a graphic interface.
 
 
Finally, libgdb includes provisions for asynchronous processing within
Finally, libgdb includes provisions for asynchronous processing within
the application.
the application.
 
 
Most operations that can be carried out with libgdb involve the GDB
Most operations that can be carried out with libgdb involve the GDB
command interpreter.  The usual mode of operation is that the operation
command interpreter.  The usual mode of operation is that the operation
is expressed as a string of GDB commands, which the interpreter is then
is expressed as a string of GDB commands, which the interpreter is then
invoked to carry out.  The output from commands executed in this manner
invoked to carry out.  The output from commands executed in this manner
can be redirected in a variety of useful ways for further processing by
can be redirected in a variety of useful ways for further processing by
the application.
the application.
 
 
The command interpreter provides an extensive system of hooks so an
The command interpreter provides an extensive system of hooks so an
application can monitor any aspect of the debugging library's state.  An
application can monitor any aspect of the debugging library's state.  An
application can set its own breakpoints and attach commands and
application can set its own breakpoints and attach commands and
conditions to those.  It is possible to attach hooks to any debugger
conditions to those.  It is possible to attach hooks to any debugger
command; the hooks are invoked whenever that command is about to be
command; the hooks are invoked whenever that command is about to be
invoked.  By means of these, the displays of a graphical interface can
invoked.  By means of these, the displays of a graphical interface can
be kept fully up to date at all times.
be kept fully up to date at all times.
 
 
We show you how to define new primitives in the command language.  By
We show you how to define new primitives in the command language.  By
defining new primitives and using them in breakpoint scripts and command
defining new primitives and using them in breakpoint scripts and command
hooks, an application can schedule the execution of arbitrary C-code at
hooks, an application can schedule the execution of arbitrary C-code at
almost any point of interest in the operation of libgdb.
almost any point of interest in the operation of libgdb.
 
 
We show you how to define new GDB convenience variables for which your
We show you how to define new GDB convenience variables for which your
code computes a value on demand.  Referring to such variables in a
code computes a value on demand.  Referring to such variables in a
breakpoint condition is a convenient way to conditionalize breakpoints
breakpoint condition is a convenient way to conditionalize breakpoints
in novel ways.
in novel ways.
 
 
To summarize: in libgdb, the gdb command language is turned into a
To summarize: in libgdb, the gdb command language is turned into a
debugging server.  The server takes commands as input, and the server's
debugging server.  The server takes commands as input, and the server's
output is redirectable.  An application uses libgdb by formatting
output is redirectable.  An application uses libgdb by formatting
debugging commands and invoking the interpreter.  The application might
debugging commands and invoking the interpreter.  The application might
maintain breakpoints, watchpoints and many kinds of hooks.  An application
maintain breakpoints, watchpoints and many kinds of hooks.  An application
can define new primitives for the interpreter.
can define new primitives for the interpreter.
 
 
@node Top Level, I/O, Interpreter, Top
@node Top Level, I/O, Interpreter, Top
@chapter You Provide the Top Level for the Libgdb Command Interpreter
@chapter You Provide the Top Level for the Libgdb Command Interpreter
@cindex {top level}
@cindex {top level}
 
 
When you use libgdb, your code is providing a @dfn{top level} for the
When you use libgdb, your code is providing a @dfn{top level} for the
command language interpreter.  The top level is significant because it
command language interpreter.  The top level is significant because it
provides commands for the the interpreter to execute.  In addition, the
provides commands for the the interpreter to execute.  In addition, the
top level is responsible for handling some kinds of errors, and
top level is responsible for handling some kinds of errors, and
performing certain cleanup operations on behalf of the interpreter.
performing certain cleanup operations on behalf of the interpreter.
 
 
@heading Initialization
@heading Initialization
 
 
Before calling any other libgdb functions, call this:
Before calling any other libgdb functions, call this:
 
 
@deftypefun void gdb_init (void)
@deftypefun void gdb_init (void)
Perform one-time initialization for libgdb.
Perform one-time initialization for libgdb.
@end deftypefun
@end deftypefun
 
 
An application may wish to evaluate specific gdb commands as part of its
An application may wish to evaluate specific gdb commands as part of its
own initialization.  The details of how this can be accomplished are
own initialization.  The details of how this can be accomplished are
explained below.
explained below.
 
 
@heading The Top-Level Loop
@heading The Top-Level Loop
 
 
There is a strong presumption in libgdb that the application has
There is a strong presumption in libgdb that the application has
the form of a loop.  Here is what such a loop might look like:
the form of a loop.  Here is what such a loop might look like:
 
 
@example
@example
while (gdb_still_going ())
while (gdb_still_going ())
  @{
  @{
    if (!GDB_TOP_LEVEL ())
    if (!GDB_TOP_LEVEL ())
      @{
      @{
        char * command;
        char * command;
        gdb_start_top_loop ();
        gdb_start_top_loop ();
        command = process_events ();
        command = process_events ();
        gdb_execute_command (command);
        gdb_execute_command (command);
        gdb_finish_top_loop ();
        gdb_finish_top_loop ();
      @}
      @}
    @}
    @}
@end example
@end example
 
 
The function @code{gdb_still_going} returns 1 until the gdb command
The function @code{gdb_still_going} returns 1 until the gdb command
`quit' is run.
`quit' is run.
 
 
The macro @code{GDB_TOP_LEVEL} invokes setjmp to set the top level error
The macro @code{GDB_TOP_LEVEL} invokes setjmp to set the top level error
handler.  When a command results in an error, the interpreter exits with
handler.  When a command results in an error, the interpreter exits with
a longjmp. There is nothing special libgdb requires of the top level
a longjmp. There is nothing special libgdb requires of the top level
error handler other than it be present and that it restart the top level
error handler other than it be present and that it restart the top level
loop.  Errors are explained in detail in a later chapter.
loop.  Errors are explained in detail in a later chapter.
 
 
Each time through the top level loop two important things happen: a
Each time through the top level loop two important things happen: a
debugger command is constructed on the basis of user input, and the
debugger command is constructed on the basis of user input, and the
interpreter is invoked to execute that command.  In the sample code, the
interpreter is invoked to execute that command.  In the sample code, the
call to the imaginary function @code{process_events} represents the
call to the imaginary function @code{process_events} represents the
point at which a graphical interface should read input events until
point at which a graphical interface should read input events until
ready to execute a debugger command.  The call to
ready to execute a debugger command.  The call to
@code{gdb_execute_command} invokes the command interpreter (what happens
@code{gdb_execute_command} invokes the command interpreter (what happens
to the output from the command will be explained later).
to the output from the command will be explained later).
 
 
Libgdb manages some resources using the top-level loop.  The primary
Libgdb manages some resources using the top-level loop.  The primary
reason for this is error-handling: even if a command terminates with an
reason for this is error-handling: even if a command terminates with an
error, it may already have allocated resources which need to be freed.
error, it may already have allocated resources which need to be freed.
The freeing of such resources takes place at the top-level, regardless
The freeing of such resources takes place at the top-level, regardless
of how the the command exits.  The calls to @code{gdb_start_top_loop}
of how the the command exits.  The calls to @code{gdb_start_top_loop}
and @code{gdb_finish_top_loop} let libgdb know when it is safe to
and @code{gdb_finish_top_loop} let libgdb know when it is safe to
perform operations associated with these resources.
perform operations associated with these resources.
 
 
@heading Breakpoint Commands
@heading Breakpoint Commands
 
 
Breakpoint commands are scripts of GDB operations associated with
Breakpoint commands are scripts of GDB operations associated with
particular breakpoints.  When a breakpoint is reached, its associated
particular breakpoints.  When a breakpoint is reached, its associated
commands are executed.
commands are executed.
 
 
Breakpoint commands are invoked by the libgdb function
Breakpoint commands are invoked by the libgdb function
@code{gdb_finish_top_loop}.
@code{gdb_finish_top_loop}.
 
 
Notice that if control returns to the top-level error handler, the
Notice that if control returns to the top-level error handler, the
execution of breakpoint commands is bypassed.  This can happen as a
execution of breakpoint commands is bypassed.  This can happen as a
result of errors during either @code{gdb_execute_command} or
result of errors during either @code{gdb_execute_command} or
@code{gdb_finish_top_loop}.
@code{gdb_finish_top_loop}.
 
 
@heading Application Initialization
@heading Application Initialization
 
 
Sometimes it is inconvenient to execute commands via a command loop for
Sometimes it is inconvenient to execute commands via a command loop for
example, the commands an application uses to initialize itself.  An
example, the commands an application uses to initialize itself.  An
alternative to @code{execute_command} is @code{execute_catching_errors}.
alternative to @code{execute_command} is @code{execute_catching_errors}.
When @code{execute_catching_errors} is used, no top level error handler
When @code{execute_catching_errors} is used, no top level error handler
need be in effect, and it is not necessary to call
need be in effect, and it is not necessary to call
@code{gdb_start_top_loop} or @code{gdb_finish_top_loop}.
@code{gdb_start_top_loop} or @code{gdb_finish_top_loop}.
 
 
 
 
@heading Cleanup
@heading Cleanup
 
 
The debugger command ``quit'' performs all necessary cleanup for libgdb.
The debugger command ``quit'' performs all necessary cleanup for libgdb.
After it has done so, it changes the return value of
After it has done so, it changes the return value of
@code{gdb_still_going} to 0 and returns to the top level error handler.
@code{gdb_still_going} to 0 and returns to the top level error handler.
 
 
 
 
@node I/O, Invoking, Top Level, Top
@node I/O, Invoking, Top Level, Top
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@chapter How the Server's I/O Can be Used
@chapter How the Server's I/O Can be Used
@cindex I/O
@cindex I/O
 
 
In the last chapter it was pointed out that a libgdb application is
In the last chapter it was pointed out that a libgdb application is
responsible for providing commands for the interpreter to execute.
responsible for providing commands for the interpreter to execute.
However some commands require further input (for example, the ``quit''
However some commands require further input (for example, the ``quit''
command might ask for confirmation).  Almost all commands produce output
command might ask for confirmation).  Almost all commands produce output
of some kind.  The purpose of this section is to explain how libgdb
of some kind.  The purpose of this section is to explain how libgdb
performs its I/O, and how an application can take advantage of
performs its I/O, and how an application can take advantage of
this.
this.
 
 
 
 
@heading I/O Vectors
@heading I/O Vectors
 
 
Libgdb has no fixed strategy for I/O.  Instead, all operations are
Libgdb has no fixed strategy for I/O.  Instead, all operations are
performed by functions called via structures of function pointers.
performed by functions called via structures of function pointers.
Applications supply theses structures and can change them at any
Applications supply theses structures and can change them at any
time.
time.
 
 
@deftp Type {struct gdb_input_vector}
@deftp Type {struct gdb_input_vector}
@deftpx Type {struct gdb_output_vector}
@deftpx Type {struct gdb_output_vector}
These structures contain a set of function pointers.  Each function
These structures contain a set of function pointers.  Each function
determines how a particular type of i/o is performed.  The details of
determines how a particular type of i/o is performed.  The details of
these strucutres are explained below.
these strucutres are explained below.
 
 
The application allocates these structures, initializes them to all bits
The application allocates these structures, initializes them to all bits
zero, fills in the function pointers, and then registers names for them
zero, fills in the function pointers, and then registers names for them
them with libgdb.
them with libgdb.
@end deftp
@end deftp
 
 
@deftypefun void gdb_name_input_vector (@var{name}, @var{vec})
@deftypefun void gdb_name_input_vector (@var{name}, @var{vec})
@deftypefunx void gdb_remove_input_vector (@var{name}, @var{vec})
@deftypefunx void gdb_remove_input_vector (@var{name}, @var{vec})
@deftypefunx void gdb_name_output_vector (@var{name}, @var{vec})
@deftypefunx void gdb_name_output_vector (@var{name}, @var{vec})
@deftypefunx void gdb_remove_input_vector (@var{name}, @var{vec})
@deftypefunx void gdb_remove_input_vector (@var{name}, @var{vec})
@example
@example
  char * @var{name};
  char * @var{name};
  struct gdb_output_vector * @var{vec};
  struct gdb_output_vector * @var{vec};
@end example
@end example
These functions are used to give and remove names to i/o vectors.  Note
These functions are used to give and remove names to i/o vectors.  Note
that if a name is used twice, the most recent definition applies.
that if a name is used twice, the most recent definition applies.
@end deftypefun
@end deftypefun
 
 
 
 
 
 
@subheading Output
@subheading Output
 
 
An output vector is a structure with at least these fields:
An output vector is a structure with at least these fields:
 
 
@example
@example
struct gdb_output_vector
struct gdb_output_vector
@{
@{
  /* output */
  /* output */
  void (*put_string) (struct gdb_output_vector *, char * str);
  void (*put_string) (struct gdb_output_vector *, char * str);
@}
@}
@end example
@end example
 
 
Use the function @code{memset} or something equivalent to initialize an
Use the function @code{memset} or something equivalent to initialize an
output vector to all bits zero.  Then fill in the function pointer with
output vector to all bits zero.  Then fill in the function pointer with
your function.
your function.
 
 
A debugger command can produce three kinds of output: error messages
A debugger command can produce three kinds of output: error messages
(such as when trying to delete a non-existent breakpoint), informational
(such as when trying to delete a non-existent breakpoint), informational
messages (such as the notification printed when a breakpoint is hit),
messages (such as the notification printed when a breakpoint is hit),
and the output specifically requested by a command (for example, the
and the output specifically requested by a command (for example, the
value printed by the ``print'' command).  At any given time, then,
value printed by the ``print'' command).  At any given time, then,
libgdb has three output vectors.  These are called the @dfn{error},
libgdb has three output vectors.  These are called the @dfn{error},
@dfn{info}, @dfn{value} vector respectively.
@dfn{info}, @dfn{value} vector respectively.
 
 
@subheading Input
@subheading Input
 
 
@example
@example
struct gdb_input_vector
struct gdb_input_vector
@{
@{
  int (*query) (struct gdb_input_vector *,
  int (*query) (struct gdb_input_vector *,
                char * prompt,
                char * prompt,
                int quit_allowed);
                int quit_allowed);
  int * (*selection) (struct gdb_input_vector *,
  int * (*selection) (struct gdb_input_vector *,
                      char * prompt,
                      char * prompt,
                      char ** choices);
                      char ** choices);
  char * (*read_string) (struct gdb_input_vector *,
  char * (*read_string) (struct gdb_input_vector *,
                         char * prompt);
                         char * prompt);
  char ** (*read_strings) (struct gdb_input_vector *,
  char ** (*read_strings) (struct gdb_input_vector *,
                           char * prompt);
                           char * prompt);
@}
@}
@end example
@end example
 
 
Use the function @code{memset} or something equivalent to initialize an
Use the function @code{memset} or something equivalent to initialize an
input vector to all bits zero.  Then fill in the function pointers with
input vector to all bits zero.  Then fill in the function pointers with
your functions.
your functions.
 
 
There are four kinds of input requests explicitly made by libgdb.
There are four kinds of input requests explicitly made by libgdb.
 
 
A @dfn{query} is a yes or no question.  The user can respond to a query
A @dfn{query} is a yes or no question.  The user can respond to a query
with an affirmative or negative answer, or by telling gdb to abort the
with an affirmative or negative answer, or by telling gdb to abort the
command (in some cases an abort is not permitted).  Query should return
command (in some cases an abort is not permitted).  Query should return
'y' or 'n' or 0 to abort.
'y' or 'n' or 0 to abort.
 
 
A @dfn{selection} is a list of options from which the user selects a subset.
A @dfn{selection} is a list of options from which the user selects a subset.
Selections should return a NULL terminated array of integers, which are
Selections should return a NULL terminated array of integers, which are
indexes into the array of choices.  It can return NULL instead to abort
indexes into the array of choices.  It can return NULL instead to abort
the command.  The array returned by this function will be passed to
the command.  The array returned by this function will be passed to
@code{free} by libgdb.
@code{free} by libgdb.
 
 
A @dfn{read_string} asks the user to supply an arbitrary string.  It may
A @dfn{read_string} asks the user to supply an arbitrary string.  It may
return NULL to abort the command.  The string returned by @code{read_string}
return NULL to abort the command.  The string returned by @code{read_string}
should be allocated by @code{malloc}; it will be freed by libgdb.
should be allocated by @code{malloc}; it will be freed by libgdb.
 
 
A @dfn{read_strings} asks the user to supply multiple lines of input
A @dfn{read_strings} asks the user to supply multiple lines of input
(for example, the body of a command created using `define').  It, too,
(for example, the body of a command created using `define').  It, too,
may return NULL to abort.  The array and the strings returned by this
may return NULL to abort.  The array and the strings returned by this
function will be freed by libgdb.
function will be freed by libgdb.
 
 
@heading I/O Redirection from the Application Top-Level
@heading I/O Redirection from the Application Top-Level
 
 
@deftypefun struct gdb_io_vecs gdb_set_io (struct gdb_io_vecs *)
@deftypefun struct gdb_io_vecs gdb_set_io (struct gdb_io_vecs *)
@example
@example
 
 
struct gdb_io_vecs
struct gdb_io_vecs
@{
@{
  struct gdb_input_vector * input;
  struct gdb_input_vector * input;
  struct gdb_output_vector * error;
  struct gdb_output_vector * error;
  struct gdb_output_vector * info;
  struct gdb_output_vector * info;
  struct gdb_output_vector * value;
  struct gdb_output_vector * value;
@}
@}
@end example
@end example
 
 
This establishes a new set of i/o vectors, and returns the old setting.
This establishes a new set of i/o vectors, and returns the old setting.
Any of the pointers in this structure may be NULL, indicating that the
Any of the pointers in this structure may be NULL, indicating that the
current value should be used.
current value should be used.
 
 
This function is useful for setting up i/o vectors before any libgdb
This function is useful for setting up i/o vectors before any libgdb
commands have been invoked (hence before any input or output has taken
commands have been invoked (hence before any input or output has taken
place).
place).
@end deftypefun
@end deftypefun
 
 
It is explained in a later chapter how to redirect output temporarily.
It is explained in a later chapter how to redirect output temporarily.
(@xref{Invoking}.)
(@xref{Invoking}.)
 
 
@heading I/O Redirection in Debugger Commands
@heading I/O Redirection in Debugger Commands
 
 
A libgdb application creates input and output vectors and assigns them names.
A libgdb application creates input and output vectors and assigns them names.
Which input and output vectors are used by libgdb is established by
Which input and output vectors are used by libgdb is established by
executing these debugger commands:
executing these debugger commands:
 
 
@defun {set input-vector} name
@defun {set input-vector} name
@defunx {set error-output-vector} name
@defunx {set error-output-vector} name
@defunx {set info-output-vector} name
@defunx {set info-output-vector} name
@defunx {set value-output-vector} name
@defunx {set value-output-vector} name
Choose an I/O vector by name.
Choose an I/O vector by name.
@end defun
@end defun
 
 
 
 
A few debugger commands are for use only within commands defined using
A few debugger commands are for use only within commands defined using
the debugger command `define' (they have no effect at other times).
the debugger command `define' (they have no effect at other times).
These commands exist so that an application can maintain hooks which
These commands exist so that an application can maintain hooks which
redirect output without affecting the global I/O vectors.
redirect output without affecting the global I/O vectors.
 
 
@defun with-input-vector name
@defun with-input-vector name
@defunx with-error-output-vector name
@defunx with-error-output-vector name
@defunx with-info-output-vector name
@defunx with-info-output-vector name
@defunx with-value-output-vector name
@defunx with-value-output-vector name
Set an I/O vector, but only temporarily.  The setting has effect only
Set an I/O vector, but only temporarily.  The setting has effect only
within the command definition in which it occurs.
within the command definition in which it occurs.
@end defun
@end defun
 
 
 
 
@heading Initial Conditions
@heading Initial Conditions
 
 
When libgdb is initialized, a set of default I/O vectors is put in
When libgdb is initialized, a set of default I/O vectors is put in
place.  The default vectors are called @code{default-input-vector},
place.  The default vectors are called @code{default-input-vector},
@code{default-output-vector}, &c.
@code{default-output-vector}, &c.
 
 
The default query function always returns `y'.  Other input functions
The default query function always returns `y'.  Other input functions
always abort.  The default output functions discard output silently.
always abort.  The default output functions discard output silently.
 
 
 
 
@node Invoking, Defining Commands, I/O, Top
@node Invoking, Defining Commands, I/O, Top
@chapter Invoking the Interpreter, Executing Commands
@chapter Invoking the Interpreter, Executing Commands
@cindex {executing commands}
@cindex {executing commands}
@cindex {invoking the interpreter}
@cindex {invoking the interpreter}
 
 
This section introduces the libgdb functions which invoke the command
This section introduces the libgdb functions which invoke the command
interpreter.
interpreter.
 
 
@deftypefun void gdb_execute_command (@var{command})
@deftypefun void gdb_execute_command (@var{command})
@example
@example
char * @var{command};
char * @var{command};
@end example
@end example
Interpret the argument debugger command.  An error handler must be set
Interpret the argument debugger command.  An error handler must be set
when this function is called. (@xref{Top Level}.)
when this function is called. (@xref{Top Level}.)
@end deftypefun
@end deftypefun
 
 
It is possible to override the current I/O vectors for the duration of a
It is possible to override the current I/O vectors for the duration of a
single command:
single command:
 
 
@deftypefun void gdb_execute_with_io (@var{command}, @var{vecs})
@deftypefun void gdb_execute_with_io (@var{command}, @var{vecs})
@example
@example
char * @var{command};
char * @var{command};
struct gdb_io_vecs * @var{vecs};
struct gdb_io_vecs * @var{vecs};
 
 
struct gdb_io_vecs
struct gdb_io_vecs
@{
@{
  struct gdb_input_vector * input;
  struct gdb_input_vector * input;
  struct gdb_output_vector * error;
  struct gdb_output_vector * error;
  struct gdb_output_vector * info;
  struct gdb_output_vector * info;
  struct gdb_output_vector * value;
  struct gdb_output_vector * value;
@}
@}
@end example
@end example
 
 
Execute @var{command}, temporarily using the i/o vectors in @var{vecs}.
Execute @var{command}, temporarily using the i/o vectors in @var{vecs}.
 
 
Any of the vectors may be NULL, indicating that the current value should
Any of the vectors may be NULL, indicating that the current value should
be used.  An error handler must be in place when this function is used.
be used.  An error handler must be in place when this function is used.
@end deftypefun
@end deftypefun
 
 
@deftypefun {struct gdb_str_output} gdb_execute_for_strings (@var{cmd})
@deftypefun {struct gdb_str_output} gdb_execute_for_strings (@var{cmd})
@example
@example
char * cmd;
char * cmd;
@end example
@end example
@deftypefunx {struct gdb_str_output} gdb_execute_for_strings2 (@var{cmd}, @var{input})
@deftypefunx {struct gdb_str_output} gdb_execute_for_strings2 (@var{cmd}, @var{input})
@example
@example
char * cmd;
char * cmd;
struct gdb_input_vector * input;
struct gdb_input_vector * input;
@end example
@end example
@page
@page
@example
@example
struct gdb_str_output
struct gdb_str_output
@{
@{
  char * error;
  char * error;
  char * info;
  char * info;
  char * value;
  char * value;
@};
@};
@end example
@end example
 
 
Execute @var{cmd}, collecting its output as strings.  If no error
Execute @var{cmd}, collecting its output as strings.  If no error
occurs, all three strings will be present in the structure, the
occurs, all three strings will be present in the structure, the
empty-string rather than NULL standing for no output of a particular
empty-string rather than NULL standing for no output of a particular
kind.
kind.
 
 
If the command aborts with an error, then the @code{value} field will be
If the command aborts with an error, then the @code{value} field will be
NULL, though the other two strings will be present.
NULL, though the other two strings will be present.
 
 
In all cases, the strings returned are allocated by malloc and should be
In all cases, the strings returned are allocated by malloc and should be
freed by the caller.
freed by the caller.
 
 
The first form listed uses the current input vector, but overrides the
The first form listed uses the current input vector, but overrides the
current output vector.  The second form additionally allows the input
current output vector.  The second form additionally allows the input
vector to be overridden.
vector to be overridden.
 
 
This function does not require that an error handler be installed.
This function does not require that an error handler be installed.
@end deftypefun
@end deftypefun
 
 
@deftypefun void execute_catching_errors (@var{command})
@deftypefun void execute_catching_errors (@var{command})
@example
@example
char * @var{command};
char * @var{command};
@end example
@end example
Like @code{execute_command} except that no error handler is required.
Like @code{execute_command} except that no error handler is required.
@end deftypefun
@end deftypefun
 
 
@deftypefun void execute_with_text (@var{command}, @var{text})
@deftypefun void execute_with_text (@var{command}, @var{text})
@example
@example
char * @var{command};
char * @var{command};
char ** @var{text};
char ** @var{text};
@end example
@end example
Like @code{execute_catching_errors}, except that the input vector is
Like @code{execute_catching_errors}, except that the input vector is
overridden.  The new input vector handles only calls to @code{query} (by
overridden.  The new input vector handles only calls to @code{query} (by
returning 'y') and calls to @code{read_strings} by returning a copy of
returning 'y') and calls to @code{read_strings} by returning a copy of
@var{text} and the strings it points to.
@var{text} and the strings it points to.
 
 
This form of execute_command is useful for commands like @code{define},
This form of execute_command is useful for commands like @code{define},
@code{document}, and @code{commands}.
@code{document}, and @code{commands}.
@end deftypefun
@end deftypefun
 
 
 
 
 
 
@node Defining Commands, Variables, Invoking, Top
@node Defining Commands, Variables, Invoking, Top
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@chapter How New Commands are Created
@chapter How New Commands are Created
@cindex {commands, defining}
@cindex {commands, defining}
 
 
Applications are, of course, free to take advantage of the existing GDB
Applications are, of course, free to take advantage of the existing GDB
macro definition capability (the @code{define} and @code{document}
macro definition capability (the @code{define} and @code{document}
functions).
functions).
 
 
In addition, an application can add new primitives to the GDB command
In addition, an application can add new primitives to the GDB command
language.
language.
 
 
@deftypefun void gdb_define_app_command (@var{name}, @var{fn}, @var{doc})
@deftypefun void gdb_define_app_command (@var{name}, @var{fn}, @var{doc})
@example
@example
char * @var{name};
char * @var{name};
gdb_cmd_fn @var{fn};
gdb_cmd_fn @var{fn};
char * @var{doc};
char * @var{doc};
 
 
typedef void (*gdb_cmd_fn) (char * args);
typedef void (*gdb_cmd_fn) (char * args);
@end example
@end example
 
 
Create a new command call @var{name}.  The new command is in the
Create a new command call @var{name}.  The new command is in the
@code{application} help class.  When invoked, the command-line arguments
@code{application} help class.  When invoked, the command-line arguments
to the command are passed as a single string.
to the command are passed as a single string.
 
 
Calling this function twice with the same name replaces an earlier
Calling this function twice with the same name replaces an earlier
definition, but application commands can not replace builtin commands of
definition, but application commands can not replace builtin commands of
the same name.
the same name.
 
 
The documentation string of the command is set to a copy the string
The documentation string of the command is set to a copy the string
@var{doc}.
@var{doc}.
@end deftypefun
@end deftypefun
 
 
@node Variables, Asynchronous, Defining Commands, Top
@node Variables, Asynchronous, Defining Commands, Top
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@chapter How Builtin Variables are Defined
@chapter How Builtin Variables are Defined
@cindex {variables, defining}
@cindex {variables, defining}
 
 
Convenience variables provide a way for values maintained by libgdb to
Convenience variables provide a way for values maintained by libgdb to
be referenced in expressions (e.g. @code{$bpnum}).  Libgdb includes a
be referenced in expressions (e.g. @code{$bpnum}).  Libgdb includes a
means by which the application can define new, integer valued
means by which the application can define new, integer valued
convenience variables:
convenience variables:
@page
@page
@deftypefun void gdb_define_int_var (@var{name}, @var{fn}, @var{fn_arg})
@deftypefun void gdb_define_int_var (@var{name}, @var{fn}, @var{fn_arg})
@example
@example
char * @var{name};
char * @var{name};
int (*@var{fn}) (void *);
int (*@var{fn}) (void *);
void * @var{fn_arg};
void * @var{fn_arg};
@end example
@end example
This function defines (or undefines) a convenience variable called @var{name}.
This function defines (or undefines) a convenience variable called @var{name}.
If @var{fn} is NULL, the variable becomes undefined.  Otherwise,
If @var{fn} is NULL, the variable becomes undefined.  Otherwise,
@var{fn} is a function which, when passed @var{fn_arg} returns the value
@var{fn} is a function which, when passed @var{fn_arg} returns the value
of the newly defined variable.
of the newly defined variable.
 
 
No libgdb functions should be called by @var{fn}.
No libgdb functions should be called by @var{fn}.
@end deftypefun
@end deftypefun
 
 
One use for this function is to create breakpoint conditions computed in
One use for this function is to create breakpoint conditions computed in
novel ways.  This is done by defining a convenience variable and
novel ways.  This is done by defining a convenience variable and
referring to that variable in a breakpoint condition expression.
referring to that variable in a breakpoint condition expression.
 
 
 
 
@node Asynchronous, Commands, Variables, Top
@node Asynchronous, Commands, Variables, Top
@chapter Scheduling Asynchronous Computations
@chapter Scheduling Asynchronous Computations
@cindex asynchronous
@cindex asynchronous
 
 
 
 
A running libgdb function can take a long time.  Libgdb includes a hook
A running libgdb function can take a long time.  Libgdb includes a hook
so that an application can run intermittently during long debugger
so that an application can run intermittently during long debugger
operations.
operations.
 
 
@deftypefun void gdb_set_poll_fn (@var{fn}, @var{fn_arg})
@deftypefun void gdb_set_poll_fn (@var{fn}, @var{fn_arg})
@example
@example
void (*@var{fn})(void * fn_arg, int (*gdb_poll)());
void (*@var{fn})(void * fn_arg, int (*gdb_poll)());
void * @var{fn_arg};
void * @var{fn_arg};
@end example
@end example
Arrange to call @var{fn} periodically during lengthy debugger operations.
Arrange to call @var{fn} periodically during lengthy debugger operations.
If @var{fn} is NULL, polling is turned off.  @var{fn} should take two
If @var{fn} is NULL, polling is turned off.  @var{fn} should take two
arguments: an opaque pointer passed as @var{fn_arg} to
arguments: an opaque pointer passed as @var{fn_arg} to
@code{gdb_set_poll_fn}, and a function pointer.  The function pointer
@code{gdb_set_poll_fn}, and a function pointer.  The function pointer
passed to @var{fn} is provided by libgdb and points to a function that
passed to @var{fn} is provided by libgdb and points to a function that
returns 0 when the poll function should return.  That is, when
returns 0 when the poll function should return.  That is, when
@code{(*gdb_poll)()} returns 0, libgdb is ready to continue @var{fn}
@code{(*gdb_poll)()} returns 0, libgdb is ready to continue @var{fn}
should return quickly.
should return quickly.
 
 
It is possible that @code{(*gdb_poll)()} will return 0 the first time it
It is possible that @code{(*gdb_poll)()} will return 0 the first time it
is called, so it is reasonable for an application to do minimal processing
is called, so it is reasonable for an application to do minimal processing
before checking whether to return.
before checking whether to return.
 
 
No libgdb functions should be called from an application's poll function,
No libgdb functions should be called from an application's poll function,
with one exception: @code{gdb_request_quit}.
with one exception: @code{gdb_request_quit}.
@end deftypefun
@end deftypefun
 
 
 
 
@deftypefun void gdb_request_quit (void)
@deftypefun void gdb_request_quit (void)
This function, if called from a poll function, requests that the
This function, if called from a poll function, requests that the
currently executing libgdb command be interrupted as soon as possible,
currently executing libgdb command be interrupted as soon as possible,
and that control be returned to the top-level via an error.
and that control be returned to the top-level via an error.
 
 
The quit is not immediate.  It will not occur until at least after the
The quit is not immediate.  It will not occur until at least after the
application's poll function returns.
application's poll function returns.
@end deftypefun
@end deftypefun
 
 
@node Commands, Top, Asynchronous, Top
@node Commands, Top, Asynchronous, Top
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@chapter Debugger Commands for Libgdb Applications
@chapter Debugger Commands for Libgdb Applications
 
 
The debugger commands available to libgdb applications are the same commands
The debugger commands available to libgdb applications are the same commands
available interactively via GDB.  This section is an overview of the
available interactively via GDB.  This section is an overview of the
commands newly created as part of libgdb.
commands newly created as part of libgdb.
 
 
This section is not by any means a complete reference to the GDB command
This section is not by any means a complete reference to the GDB command
language.  See the GDB manual for such a reference.
language.  See the GDB manual for such a reference.
 
 
@menu
@menu
* Command Hooks::    Setting Hooks to Execute With Debugger Commands.
* Command Hooks::    Setting Hooks to Execute With Debugger Commands.
* View Commands::    View Commands Mirror Show Commands
* View Commands::    View Commands Mirror Show Commands
* Breakpoints::      The Application Can Have Its Own Breakpoints
* Breakpoints::      The Application Can Have Its Own Breakpoints
@end menu
@end menu
 
 
@node Command Hooks, View Commands, Commands, Commands
@node Command Hooks, View Commands, Commands, Commands
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@section Setting Hooks to Execute With Debugger Commands.
@section Setting Hooks to Execute With Debugger Commands.
 
 
Debugger commands support hooks.  A command hook is executed just before
Debugger commands support hooks.  A command hook is executed just before
the interpreter invokes the hooked command.
the interpreter invokes the hooked command.
 
 
There are two hooks allowed for every command.  By convention, one hook
There are two hooks allowed for every command.  By convention, one hook
is for use by users, the other is for use by the application.
is for use by users, the other is for use by the application.
 
 
A user hook is created for a command XYZZY by using
A user hook is created for a command XYZZY by using
@code{define-command} to create a command called @code{hook-XYZZY}.
@code{define-command} to create a command called @code{hook-XYZZY}.
 
 
An application hook is created for a command XYZZY by using
An application hook is created for a command XYZZY by using
@code{define-command} to create a command called @code{apphook-XYZZY}.
@code{define-command} to create a command called @code{apphook-XYZZY}.
 
 
Application hooks are useful for interfaces which wish to continuously
Application hooks are useful for interfaces which wish to continuously
monitor certain aspects of debugger state.  The application can set a
monitor certain aspects of debugger state.  The application can set a
hook on all commands that might modify the watched state.  When the hook
hook on all commands that might modify the watched state.  When the hook
is executed, it can use i/o redirection to notify parts of the
is executed, it can use i/o redirection to notify parts of the
application that previous data may be out of date.  After the top-level loop
application that previous data may be out of date.  After the top-level loop
resumes, the application can recompute any values that may have changed.
resumes, the application can recompute any values that may have changed.
(@xref{I/O}.)
(@xref{I/O}.)
 
 
@node View Commands, Breakpoints, Command Hooks, Commands
@node View Commands, Breakpoints, Command Hooks, Commands
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@section View Commands Mirror Show Commands
@section View Commands Mirror Show Commands
 
 
The GDB command language contains many @code{set} and @code{show}
The GDB command language contains many @code{set} and @code{show}
commands.  These commands are used to modify or examine parameters to
commands.  These commands are used to modify or examine parameters to
the debugger.
the debugger.
 
 
It is difficult to get the current state of a parameter from the
It is difficult to get the current state of a parameter from the
@code{show} command because @code{show} is very verbose.
@code{show} command because @code{show} is very verbose.
 
 
@example
@example
(gdb) show check type
(gdb) show check type
Type checking is "auto; currently off".
Type checking is "auto; currently off".
(gdb) show width
(gdb) show width
Number of characters gdb thinks are in a line is 80.
Number of characters gdb thinks are in a line is 80.
@end example
@end example
 
 
For every @code{show} command, libgdb includes a @code{view} command.
For every @code{show} command, libgdb includes a @code{view} command.
@code{view} is like @code{show} without the verbose commentary:
@code{view} is like @code{show} without the verbose commentary:
 
 
@example
@example
(gdb) view check type
(gdb) view check type
auto; currently off
auto; currently off
(gdb) view width
(gdb) view width
80
80
@end example
@end example
 
 
(The precise format of the ouput from @code{view} is subject to change.
(The precise format of the ouput from @code{view} is subject to change.
In particular, @code{view} may one-day print values which can be used as
In particular, @code{view} may one-day print values which can be used as
arguments to the corresponding @code{set} command.)
arguments to the corresponding @code{set} command.)
 
 
@node Breakpoints, Structured Output, View Commands, Commands
@node Breakpoints, Structured Output, View Commands, Commands
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@section The Application Can Have Its Own Breakpoints
@section The Application Can Have Its Own Breakpoints
 
 
The GDB breakpoint commands were written with a strong presumption that
The GDB breakpoint commands were written with a strong presumption that
all breakpoints are managed by a human user.  Therefore, the command
all breakpoints are managed by a human user.  Therefore, the command
language contains commands like `delete' which affect all breakpoints
language contains commands like `delete' which affect all breakpoints
without discrimination.
without discrimination.
 
 
In libgdb, there is added support for breakpoints and watchpoints which
In libgdb, there is added support for breakpoints and watchpoints which
are set by the application and which should not be affected by ordinary,
are set by the application and which should not be affected by ordinary,
indiscriminate commands.  These are called @dfn{protected} breakpoints.
indiscriminate commands.  These are called @dfn{protected} breakpoints.
 
 
@deffn {Debugger Command} break-protected ...
@deffn {Debugger Command} break-protected ...
@deffnx {Debugger Command} watch-protected ...
@deffnx {Debugger Command} watch-protected ...
These work like @code{break} and @code{watch} except that the resulting
These work like @code{break} and @code{watch} except that the resulting
breakpoint is given a negative number.  Negative numbered breakpoints do
breakpoint is given a negative number.  Negative numbered breakpoints do
not appear in the output of @code{info breakpoints} but do in that of
not appear in the output of @code{info breakpoints} but do in that of
@code{info all-breakpoints}.  Negative numbered breakpoints are not
@code{info all-breakpoints}.  Negative numbered breakpoints are not
affected by commands which ordinarily affect `all' breakpoints (e.g.
affected by commands which ordinarily affect `all' breakpoints (e.g.
@code{delete} with no arguments).
@code{delete} with no arguments).
 
 
Note that libgdb itself creates protected breakpoints, so programs
Note that libgdb itself creates protected breakpoints, so programs
should not rely on being able to allocate particular protected
should not rely on being able to allocate particular protected
breakpoint numbers for themselves.
breakpoint numbers for themselves.
@end deffn
@end deffn
 
 
More than one breakpoint may be set at a given location.  Libgdb adds
More than one breakpoint may be set at a given location.  Libgdb adds
the concept of @dfn{priority} to breakpoints.  A priority is an integer,
the concept of @dfn{priority} to breakpoints.  A priority is an integer,
assigned to each breakpoint.  When a breakpoint is reached, the
assigned to each breakpoint.  When a breakpoint is reached, the
conditions of all breakpoints at the same location are evaluated in
conditions of all breakpoints at the same location are evaluated in
order of ascending priority.  When breakpoint commands are executed,
order of ascending priority.  When breakpoint commands are executed,
they are also executed in ascending priority (until all have been
they are also executed in ascending priority (until all have been
executed, an error occurs, or one set of commands continues the
executed, an error occurs, or one set of commands continues the
target).
target).
 
 
@deffn {Debugger Command} priority n bplist
@deffn {Debugger Command} priority n bplist
Set the priority for breakpoints @var{bplist} to @var{n}.
Set the priority for breakpoints @var{bplist} to @var{n}.
By default, breakpoints are assigned a priority of zero.
By default, breakpoints are assigned a priority of zero.
@end deffn
@end deffn
 
 
@node Structured Output, Commands, Breakpoints, Commands
@node Structured Output, Commands, Breakpoints, Commands
@comment  node-name,  next,  previous,  up
@comment  node-name,  next,  previous,  up
@section  Structured Output, The @code{Explain} Command
@section  Structured Output, The @code{Explain} Command
 
 
(This section may be subject to considerable revision.)
(This section may be subject to considerable revision.)
 
 
When GDB prints a the value of an expression, the printed representation
When GDB prints a the value of an expression, the printed representation
contains information that can be usefully fed back into future commands
contains information that can be usefully fed back into future commands
and expressions.  For example,
and expressions.  For example,
 
 
@example
@example
(gdb) print foo
(gdb) print foo
$16 = @{v = 0x38ae0, v_length = 40@}
$16 = @{v = 0x38ae0, v_length = 40@}
@end example
@end example
 
 
On the basis of this output, a user knows, for example, that
On the basis of this output, a user knows, for example, that
@code{$16.v} refers to a pointer valued @code{0x38ae0}
@code{$16.v} refers to a pointer valued @code{0x38ae0}
 
 
A new output command helps to make information like this available to
A new output command helps to make information like this available to
the application.
the application.
 
 
@deffn {Debugger Command} explain expression
@deffn {Debugger Command} explain expression
@deffnx {Debugger Command} explain /format expression
@deffnx {Debugger Command} explain /format expression
Print the value of @var{expression} in the manner of the @code{print}
Print the value of @var{expression} in the manner of the @code{print}
command, but embed that output in a list syntax containing information
command, but embed that output in a list syntax containing information
about the structure of the output.
about the structure of the output.
@end deffn
@end deffn
 
 
As an example, @code{explain argv} might produce this output:
As an example, @code{explain argv} might produce this output:
 
 
@example
@example
(exp-attribute
(exp-attribute
   ((expression "$19")
   ((expression "$19")
    (type "char **")
    (type "char **")
    (address "48560")
    (address "48560")
    (deref-expression "*$19"))
    (deref-expression "*$19"))
   "$19 = 0x3800\n")
   "$19 = 0x3800\n")
@end example
@end example
 
 
The syntax of output from @code{explain} is:
The syntax of output from @code{explain} is:
 
 
@example
@example
<explanation> :=    <quoted-string>
<explanation> :=    <quoted-string>
                  | (exp-concat <explanation> <explanation>*)
                  | (exp-concat <explanation> <explanation>*)
                  | (exp-attribute <property-list> <explanation>)
                  | (exp-attribute <property-list> <explanation>)
 
 
<property-list> := ( <property-pair>* )
<property-list> := ( <property-pair>* )
 
 
<property-pair> := ( <property-name> <quoted-string> )
<property-pair> := ( <property-name> <quoted-string> )
@end example
@end example
 
 
The string-concatenation of all of the @code{<quoted-string>} (except
The string-concatenation of all of the @code{<quoted-string>} (except
those in property lists) yields the output generated by the equivalent
those in property lists) yields the output generated by the equivalent
@code{print} command.  Quoted strings may contain quotes and backslashes
@code{print} command.  Quoted strings may contain quotes and backslashes
if they are escaped by backslash.  "\n" in a quoted string stands for
if they are escaped by backslash.  "\n" in a quoted string stands for
newline; unescaped newlines do not occur within the strings output by
newline; unescaped newlines do not occur within the strings output by
@code{explain}.
@code{explain}.
 
 
Property names are made up of alphabetic characters, dashes, and
Property names are made up of alphabetic characters, dashes, and
underscores.
underscores.
 
 
The set of properties is open-ended.  As GDB acquires support for new
The set of properties is open-ended.  As GDB acquires support for new
source languages and other new capabilities, new property types may be
source languages and other new capabilities, new property types may be
added to the output of this command.  Future commands may offer
added to the output of this command.  Future commands may offer
applications some selectivity concerning which properties are reported.
applications some selectivity concerning which properties are reported.
 
 
The initial set of properties defined includes:
The initial set of properties defined includes:
 
 
@itemize @bullet
@itemize @bullet
@item @code{expression}
@item @code{expression}
 
 
This is an expression, such as @code{$42} or @code{$42.x}.  The
This is an expression, such as @code{$42} or @code{$42.x}.  The
expression can be used to refer to the value printed in the attributed
expression can be used to refer to the value printed in the attributed
part of the string.
part of the string.
 
 
@item @code{type}
@item @code{type}
 
 
This is a user-readable name for the type of the attributed value.
This is a user-readable name for the type of the attributed value.
 
 
@item @code{address}
@item @code{address}
 
 
If the value is stored in a target register, this is a register number.
If the value is stored in a target register, this is a register number.
If the value is stored in a GDB convenience variable, this is an integer
If the value is stored in a GDB convenience variable, this is an integer
that is unique among all the convenience variables.  Otherwise, this is
that is unique among all the convenience variables.  Otherwise, this is
the address in the target where the value is stored.
the address in the target where the value is stored.
 
 
@item @code{deref-expression}
@item @code{deref-expression}
 
 
If the attributed value is a pointer type, this is an expression that
If the attributed value is a pointer type, this is an expression that
refers to the dereferenced value.
refers to the dereferenced value.
@end itemize
@end itemize
 
 
Here is a larger example, using the same object passed to @code{print}
Here is a larger example, using the same object passed to @code{print}
in an earlier example of this section.
in an earlier example of this section.
 
 
@example
@example
(gdb) explain foo
(gdb) explain foo
(exp-attribute
(exp-attribute
  ( (expression "$16")
  ( (expression "$16")
    (type "struct bytecode_vector")
    (type "struct bytecode_vector")
    (address 14336) )
    (address 14336) )
  (exp-concat
  (exp-concat
    "$16 = @{"
    "$16 = @{"
    (exp-attribute
    (exp-attribute
      ( (expression "$16.v")
      ( (expression "$16.v")
        (type "char *")
        (type "char *")
        (address 14336)
        (address 14336)
        (deref-expression "*$16.v") )
        (deref-expression "*$16.v") )
      "v = 0x38ae0")
      "v = 0x38ae0")
    (exp-attribute
    (exp-attribute
      ( (expression "$16.v_length")
      ( (expression "$16.v_length")
        (type "int")
        (type "int")
        (address 14340) )
        (address 14340) )
      ", v_length = 40")
      ", v_length = 40")
     "@}\n"))
     "@}\n"))
@end example
@end example
 
 
It is undefined how libgdb will indent these lines of output or
It is undefined how libgdb will indent these lines of output or
where newlines will be included.
where newlines will be included.
 
 
@bye
@bye
 
 

powered by: WebSVN 2.1.0

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