gdbint_8.html   [plain text]


<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.51
     from /mnt/apple/gdb/source/gdb.apple/source/gdb/gdb/doc/gdbint.texinfo on 23 November 1999 -->

<TITLE>GDB Internals - GDB Overview</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="gdbint_1.html">first</A>, <A HREF="gdbint_7.html">previous</A>, <A HREF="gdbint_9.html">next</A>, <A HREF="gdbint_16.html">last</A> section, <A HREF="gdbint_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC45" HREF="gdbint_toc.html#TOC45">GDB Overview</A></H1>



<H2><A NAME="SEC46" HREF="gdbint_toc.html#TOC46">Libraries used by GDB</A></H2>

<P>
GDB relies on a number of libraries:

</P>
<DL COMPACT>

<DT><TT>`config/'</TT>
<DD>
Configuration options shared by GDB and all of the libraries it uses.
GDB has it's own much more extensive configuration in <TT>`gdb/config'</TT>.
<DT><TT>`readline/'</TT>
<DD>
Contains the <CODE>-lreadline</CODE> and <CODE>-lhistory</CODE> libraries for
command-line processing.  The <CODE>-lreadline</CODE> library handles 
command-line editing, terminal interface, keymap interfaces, and file
completion; the <CODE>-lhistory</CODE> library handles history processing and
history substitution using csh-style syntax.  For more information, see
<TT>`readline/doc/hist.texi'</TT> and <TT>`readline/doc/rlman.texi'</TT>.
<DT><TT>`bfd/'</TT>
<DD>
BFD is a package which allows applications to use the
same routines to operate on object files whatever the object file
format.  A new object file format can be supported simply by
creating a new BFD back end and adding it to the library.

BFD is split into two parts: the front end, and the back ends (one for
each object file format).

<UL>
<LI>The front end of BFD provides the interface to the user. It manages

memory and various canonical data structures. The front end also
decides which back end to use and when to call back end routines.
<LI>The back ends provide BFD its view of the real world. Each back

end provides a set of calls which the BFD front end can use to maintain
its canonical form. The back ends also may keep around information for
their own use, for greater efficiency.
</UL>

For more information on BFD, see <TT>`bfd/doc/bfd.texi'</TT>.  For
more information on the use of BFD in GDB, @xref{BFD support for GDB}.
<DT><TT>`opcodes/'</TT>
<DD>
A collection of routines to parse/print machine-language instructions
and arguments for a number of processors.
<DT><TT>`mmalloc/'</TT>
<DD>
The gnu <CODE>malloc()</CODE> library.
<DT><TT>`sim/'</TT>
<DD>
Simulators for a number of common microprocessors.  Allows GDB to debug
machine code for architectures for which no CPU is readily available or
which are not yet capable of interacting with GDB directly.  Generally
used to simulate and/or debug embedded systems.
<DT><TT>`texinfo/'</TT>
<DD>
Texinfo is a documentation system that uses a single source file to
produce both online information and printed output.  Most GDB-related
documentation is produced using this system.  For more information, see
<TT>`texinfo/doc/texinfo.texi'</TT>.
<DT><TT>`libiberty/'</TT>
<DD>
Contains the <CODE>-liberty</CODE> library of free software.
It is a collection of subroutines used by various GNU programs,
typically functions that are included in GNU libc, but not in certain
vendor versions of libc.  Example functions provided by <CODE>-liberty</CODE>:
<DL COMPACT>

<DT><CODE>getopt</CODE>
<DD>
get options from command line
<DT><CODE>obstack</CODE>
<DD>
stacks of arbitrarily-sized objects
<DT><CODE>strerror</CODE>
<DD>
error message strings corresponding to errno
<DT><CODE>strtol</CODE>
<DD>
string-to-long conversion
<DT><CODE>strtoul</CODE>
<DD>
string-to-unsigned-long conversion
</DL>
</DL>



<H2><A NAME="SEC47" HREF="gdbint_toc.html#TOC47">GDB Directory Structure</A></H2>

<P>
The sources to GDB itself are currently stored in four subdirectories,
all of which are used to build the final executable:

</P>
<DL COMPACT>

<DT><TT>`gdb/'</TT>
<DD>
The main GDB sources as provided by the FSF.  Changes to this directory
have been kept as small as possible to minimize the effort of merging
them with the FSF sources (though many changes still have been made).
<DT><TT>`gdb-next/'</TT>
<DD>
Apple-specific additions to the GDB source base.  These will eventually
be merged into the <TT>`gdb/'</TT> directory, but are currently kept
separate to make them easier to manage.
<DT><TT>`gdb-4.14/'</TT>
<DD>
GDB sources as modified by NeXT for gdb-4.14.  These are nearly
obsolete, but are kept around until I have merged all of the original
NeXT changes into the new GDB source base.
<DT><TT>`gdb-next-4.14/'</TT>
<DD>
Apple-specific additions to the (nearly obsolete) GDB 4.14 source base.
These are kept around solely for the purpose of building GDB 4.14
binaries when necessary.
</DL>

<P>
Until recently, it was possible to build both GDB 4.17 and the GDB
4.14/4.17 hybrid that shipped with DR1 from the same source tree.  GDB
4.17 was built in <TT>`gdb'</TT> and used files from <TT>`gdb-next'</TT> and
<TT>`gdb/'</TT>, in that order, and GDB 4.14 was built in <TT>`gdb-4.14'</TT>
and used the files from <TT>`gdb-next-4.14/'</TT>, <TT>`gdb-next/'</TT>,
<TT>`gdb-4.14/'</TT>, and <TT>`gdb/'</TT>, also in that order.

</P>
<P>
As of January 8, I have stopped building GDB 4.14 along with GDB 4.17
from the same sources.  I suspect GDB 4.14 will no longer
build from these sources without modification, although I suspect the
necessary changes would be relatively minor.

</P>
<P>
GDB also uses the following subdirectories:

</P>
<DL COMPACT>

<DT><TT>`include/'</TT>
<DD>
Header files shared by GDB and all of the libraries it uses.
These files typically will typically apply to either:

<UL>
<LI>

General operating-system functions (such as symbol reading, IEEE floats, 
etc.) for which GDB and it's libraries want to have a common interface.
<LI>

Interfaces between GDB and one of its libraries (such as
<TT>`remote-sim.h'</TT> and <TT>`libiberty.h'</TT>).
</UL>

<DT><TT>`gdb/config/'</TT>
<DD>
Contains GDB-specific configuration files.  For more information @xref{Config}.

</DL>



<H2><A NAME="SEC48" HREF="gdbint_toc.html#TOC48">Overview of Source Files</A></H2>



<H3><A NAME="SEC49" HREF="gdbint_toc.html#TOC49">Top Level</A></H3>

<DL COMPACT>

<DT><TT>`main.c'</TT>
<DD>
Contains the GDB top-level interpreter.  Parses command-line arguments,
performs GDB initialization, and passes control to command-line interpreter.
<DT><TT>`maint.c'</TT>
<DD>
Collection of utility functions for viewing/debugging the internal state 
of GDB.
<DT><TT>`top.c'</TT>
<DD>
Top-level routine used by GDB.  Evaluates commands, and provides a
number of top-level functions and mechanisms to set general purpose
variables.
<DT><TT>`command.c'</TT>
<DD>
parse and evaluate gdb commands and command documentation
<DT><TT>`printcmd.c'</TT>
<DD>
user commands for printing expressions and displaying memory
</DL>



<H3><A NAME="SEC50" HREF="gdbint_toc.html#TOC50">GDB Targets / Program Control</A></H3>

<DL COMPACT>

<DT><TT>`target.c'</TT>
<DD>
Defines the target abstraction, used to encapsulate all communications
between GDB and a target.  See the comments in <TT>`target.h'</TT> for more
information.
<DT><TT>`exec.c'</TT>
<DD>
Interface between executable files and the 'target' abstraction.  Allows
GDB to inspect/analyze executable images, without necessarily having a
debuggable process available.
<DT><TT>`corefile.c'</TT>
<DD>
Interface between core images and the 'target' abstraction.  Allows GDB
to inspect/analyze memory and register dumps from corefile images.  Not
used in GDB 4.14.
<DT><TT>`thread.c'</TT>
<DD>
Interface between GDB and multiply-threaded subprocesses.  Not currently 
used by either GDB 4.14 or GDB 4.17.
<DT><TT>`fork-child.c'</TT>
<DD>
Code to create an inferior process on UNIX systems.
<DT><TT>`infcmd.c'</TT>
<DD>
User-level commands for inspecting/controlling the state of process
execution.  Commands such as 'step', 'next', 'finish', and 'continue' go
here.
<DT><TT>`inflow.c'</TT>
<DD>
Handles terminal modes and signal handling for UNIX child processes.
<DT><TT>`infrun.c'</TT>
<DD>
Target-independent code to control the execution of an inferior process.
Handles breakpoints, signal handling, shared library handling (on some
systems), as well as far too many other things.  Contains
<CODE>wait_for_inferior</CODE>, probably the hairiest function in all of GDB.
<DT><TT>`inftarg.c'</TT>
<DD>
Interface between the GDB 'target' abstraction and UNIX child processes.
Many of the functions in the file are overridden (via macros) in the
<CODE>nextstep-*</CODE> functions.
</DL>



<H3><A NAME="SEC51" HREF="gdbint_toc.html#TOC51">Types, Values, and Expressions</A></H3>

<P>
A <CODE>type</CODE> is the fundamental data structure in GDB for representing
type information.  Each <CODE>type</CODE> structure is associated with a
particular object file, with the exception of a few pre-created type
structures used for backwards compatibility with other parts of GDB.
GDB provides a number of "fundamental" data types; more complex data
types can be represented by nesting <CODE>type</CODE> structures within each
other.  See section <A HREF="gdbint_8.html#SEC51">Types, Values, and Expressions</A> for more information.

</P>
<P>
A <CODE>value</CODE> is the GDB data structure for representing both R- and
L-values of any type.  A <CODE>value</CODE> contains a pointer to a GDB
<CODE>type</CODE> structure, as well as a region of memory containing the
value's contents (for an R-value) or address (for an L-value).

</P>
<P>
A <CODE>expression</CODE> is the GDB data structure for all expressions in all
programming languages.  Expressions can be parsed and evaluated
interactively according to the current language syntax, can be used by
breakpoints and watchpoints to compute values, and can cause execution
to take place within a target process (by evaluating function
expressions).  Expressions are parsed, evaluated, and printed using the
language-dispatching mechanisms described in <TT>`language.c'</TT> and
section <A HREF="gdbint_8.html#SEC55">Language-Specific Sources</A>.

</P>
<P>
GDB source files to manipulate <CODE>type</CODE> structures:

</P>
<DL COMPACT>

<DT><TT>`typeprint.c'</TT>
<DD>
Prints type information structures in readable form.  Interfaces to the
language-specific type printing routines described in
section <A HREF="gdbint_8.html#SEC55">Language-Specific Sources</A>.
<DT><TT>`gdbtypes.c'</TT>
<DD>
Fundamental type definitions used by GDB.
</DL>

<P>
GDB source files to manipulate <CODE>expression</CODE> structures:

</P>
<DL COMPACT>

<DT><TT>`parse.c'</TT>
<DD>
Parse expressions typed at the command-line into <CODE>expression</CODE>.
Interfaces to the language-specific expression parsing routines described
in section <A HREF="gdbint_8.html#SEC55">Language-Specific Sources</A>.
<DT><TT>`eval.c'</TT>
<DD>
Evaluates <CODE>expression</CODE> structures in the current execution context.
<DT><TT>`expprint.c'</TT>
<DD>
Prints <CODE>expression</CODE> structures in readable (infix) form.
Interfaces to the language-specific type printing routines described in
section <A HREF="gdbint_8.html#SEC55">Language-Specific Sources</A>.
</DL>

<P>
GDB source files to manipulate <CODE>value</CODE> structures:

</P>
<DL COMPACT>

<DT><TT>`valarith.c'</TT>
<DD>
perform arithmetic operations on values
<DT><TT>`valops.c'</TT>
<DD>
perform non-arithmetic operations on values
<DT><TT>`valprint.c'</TT>
<DD>
print functions for values
<DT><TT>`values.c'</TT>
<DD>
low-level packing/unpacking of value objects to/from raw format
</DL>
<DL COMPACT>

<DT><TT>`findvar.c'</TT>
<DD>
resolve variables to their value structures (as appropriate to
the current stack environment).
</DL>



<H3><A NAME="SEC52" HREF="gdbint_toc.html#TOC52">Stack Analysis</A></H3>

<DL COMPACT>

<DT><TT>`blockframe.c'</TT>
<DD>
machine-independent code to analyze stack frames
<DT><TT>`stack.c'</TT>
<DD>
machine-independent stack frame analysis, user-level commands to manage
and inspect the stack.
</DL>



<H3><A NAME="SEC53" HREF="gdbint_toc.html#TOC53">Breakpoints</A></H3>

<DL COMPACT>

<DT><TT>`breakpoint.c'</TT>
<DD>
Machine-independent breakpoint code.  Handles and dispatches all forms
of breakpoints, including hardware breakpoints, software breakpoints,
hardware and software watchpoints, and shared library breakpoints.
Contains top-level commands to set, inspect, and manipulate breakpoints
and watchpoints.  Provides routine to read memory from inferior,
replacing any memory that may have been overwritten by a breakpoint with 
its saved value.
<DT><TT>`mem-break.c'</TT>
<DD>
Implements software breakpoints.  To set a breakpoint at a given
location, GDB saves the instruction at that location and inserts a
software trap instruction in its place.
</DL>



<H3><A NAME="SEC54" HREF="gdbint_toc.html#TOC54">Symbol File Management</A></H3>

<P>
The following files allow GDB to parse and manage symbol information in
a variety of formats.  For an overview of GDB object file and symbol
handling, @xref{Symbol Tables}.

</P>
<DL COMPACT>

<DT><TT>`objfiles.c'</TT>
<DD>
create/destroy/manage objfile structures
<DT><TT>`symfile.c'</TT>
<DD>
top-level commands to handle objfiles, also handles overlays (unused)
<DT><TT>`symmisc.c'</TT>
<DD>
various objfile and (p)symtab utilities (mainly debugging)
<DT><TT>`symtab.c'</TT>
<DD>
basic symbol table utilities (mainly lookup)
</DL>

<DL COMPACT>

<DT><TT>`minsyms.c'</TT>
<DD>
manage minimal symbol tables
<DT><TT>`buildsym.c'</TT>
<DD>
build complete symbol data structures
</DL>

<P>
The following source files provide symbol-reading interfaces for various
file formats.  Although all these files are compiled into GDB for Mac OS
X, only the first three (<TT>`stabsread'</TT>, <TT>`dbxread'</TT>, and
<TT>`machoread'</TT>) are actively used by the rest of GDB.

</P>
<DL COMPACT>

<DT><TT>`stabsread.c'</TT>
<DD>
common stabs parsing routines
<DT><TT>`dbxread.c'</TT>
<DD>
read DBX (stabs) symbol files
<DT><TT>`machoread.c'</TT>
<DD>
read Mach-O (stabs) symbol files
<DT><TT>`nlmread.c'</TT>
<DD>
read Netware NLM symbol files (unused)
<DT><TT>`os9kread.c'</TT>
<DD>
read OS9/OS9K symbol files (unused)
<DT><TT>`dwarf2read.c'</TT>
<DD>
read DWARF2 symbol files (unused)
<DT><TT>`dwarfread.c'</TT>
<DD>
read DWARF symbol files (unused)
<DT><TT>`elfread.c'</TT>
<DD>
read ELF symbol files (unused)
<DT><TT>`coffread.c'</TT>
<DD>
read COFF symbol files (unused)
<DT><TT>`mdebugread.c'</TT>
<DD>
read ECOFF symbol files (unused)
<DT><TT>`mipsread.c'</TT>
<DD>
read MIPS symbol files (unused)
</DL>



<H3><A NAME="SEC55" HREF="gdbint_toc.html#TOC55">Language-Specific Sources</A></H3>

<P>
The following files are used to provide language-specific expression
evaluation and printing support.  The file <VAR>lang</VAR>-exp handles
expression parsing, <VAR>lang</VAR>-typeprint
prints human-readable versions of GDB 'type' structures, and
<VAR>lang</VAR>-valprint prints human-readable versions of GDB 'value'
structures, and <VAR>lang</VAR>-lang provides general language-specific
support functions.  For more information on language-specific support in
GDB, @xref{Languages}.

</P>
<DL COMPACT>

<DT><CODE>C</CODE>
<DD>
<TT>`c-exp'</TT>, <TT>`c-lang'</TT>, <TT>`c-typeprint'</TT>, <TT>`c-valprint'</TT>
<DT><CODE>C++</CODE>
<DD>
<TT>`cp-valprint'</TT>
<DT><CODE>Objective-C</CODE>
<DD>
<TT>`objc-exp'</TT>, <TT>`objc-lang'</TT>, <TT>`objc'</TT>
<DT><CODE>Chill</CODE>
<DD>
<TT>`ch-exp'</TT>, <TT>`ch-lang'</TT>, <TT>`ch-typeprint'</TT>, <TT>`ch-valprint'</TT>
<DT><CODE>Fortran</CODE>
<DD>
<TT>`f-exp'</TT>, <TT>`f-lang'</TT>, <TT>`f-typeprint'</TT>, <TT>`f-valprint'</TT>
<DT><CODE>Java</CODE>
<DD>
<TT>`jv-exp'</TT>, <TT>`jv-lang'</TT>, <TT>`jv-typeprint'</TT>, <TT>`jv-valprint'</TT>
<DT><CODE>Modula II</CODE>
<DD>
<TT>`m2-exp'</TT>, <TT>`m2-lang'</TT>, <TT>`m2-typeprint'</TT>, <TT>`m2-valprint'</TT>
<DT><CODE>Scheme</CODE>
<DD>
<TT>`scm-exp'</TT>, <TT>`scm-lang'</TT>, <TT>`scm-valprint'</TT>
</DL>



<H3><A NAME="SEC56" HREF="gdbint_toc.html#TOC56">Kernel Debugging</A></H3>

<DL COMPACT>

<DT><TT>`remote-kdp.c'</TT>
<DD>
interface gdb 'target' interface to a remote Mac OS X kernel via KDP
<DT><TT>`kdp-udp.c'</TT>
<DD>
communications library for KDP
<DT><TT>`remote-utils.c'</TT>
<DD>
more serial-line support (unused)
<DT><TT>`remote.c'</TT>
<DD>
generic serial-line debugging (unused)
<DT><TT>`ser-tcp.c'</TT>
<DD>
treat TCP connection as serial line (unused)
<DT><TT>`ser-unix.c'</TT>
<DD>
interface to unix serial ports (unused)
<DT><TT>`serial.c'</TT>
<DD>
implement generic serial routines (unused)
</DL>



<H3><A NAME="SEC57" HREF="gdbint_toc.html#TOC57">Sources Specific to Mac OS X</A></H3>

<DL COMPACT>

<DT><TT>`nextstep-nat-dyld.c'</TT>
<DD>
handle dyld debugging messages and take action (mainly load symfiles)
<DT><TT>`nextstep-nat-inferior.c'</TT>
<DD>
interface between GDB 'target' abstraction and Mach process control
functions
<DT><TT>`nextstep-nat-mutils.c'</TT>
<DD>
mach functions to read/write memory, other manipulations
<DT><TT>`nextstep-nat-sigthread.c'</TT>
<DD>
create/manage thread to detect signals sent to the inferior process
<DT><TT>`nextstep-nat-threads.c'</TT>
<DD>
interface gdb 'target' interface to a running Mac OS X process on the same machine

<DT><TT>`nextstep-tdep.c'</TT>
<DD>
extra functions needed for all nextstep targets (empty)
<DT><TT>`nextstep-xdep.c'</TT>
<DD>
extra functions needed for nextstep hosts (empty)
</DL>



<H3><A NAME="SEC58" HREF="gdbint_toc.html#TOC58">PowerPC-specific Sources</A></H3>

<DL COMPACT>

<DT><TT>`ppc-frameinfo.c'</TT>
<DD>
determine/print PPC stack frame info (find prologue, etc)
<DT><TT>`ppc-frameops.c'</TT>
<DD>
basic PPC stack frame operations (push dummy, push args, pop, find saved regs)
<DT><TT>`ppc-next-tcore.c'</TT>
<DD>
fetch/store PPC registers to/from running Mach thread
<DT><TT>`ppc-next-tdep.c'</TT>
<DD>
fetch/store PPC registers from Mach data structure
<DT><TT>`ppc-tdep.c'</TT>
<DD>
PPC analysis functions used by rest of GDB 
</DL>



<H3><A NAME="SEC59" HREF="gdbint_toc.html#TOC59">Miscellaneous</A></H3>

<DL COMPACT>

<DT><TT>`demangle'</TT>
<DD>
Allow user to explicitly select function name demangling style
(e.g. 'k+r', 'lucid', 'GNU').

<DT><TT>`language'</TT>
<DD>
Multiple-language support for GDB.  Contains dispatch tables to the
language-specific routines, routines to detect the language of a source
file / object module, and explicit commands to print/set the current
language environment.

<DT><TT>`source'</TT>
<DD>
View and navigate through source files.  Also responsible for directory
search path mechanisms.

</DL>



<H3><A NAME="SEC60" HREF="gdbint_toc.html#TOC60">Assorted Utilities</A></H3>

<DL COMPACT>

<DT><TT>`bcache'</TT>
<DD>
efficiency additions for obstack
<DT><TT>`gnu-regex'</TT>
<DD>
regular expression library
<DT><TT>`dcache'</TT>
<DD>
caches inferior memory accesses (for remote targets)
<DT><TT>`complaints'</TT>
<DD>
error-printing for symbol file reading
allows error messages to be printed only once
per operation, rather than repeated incessantly
<DT><TT>`copying'</TT>
<DD>
prints license/warranty information
<DT><TT>`version'</TT>
<DD>
automatically generated, contains version string
<DT><TT>`annotate'</TT>
<DD>
convenience functions to print annotations for libgdb
<DT><TT>`environ'</TT>
<DD>
utilities to read/modify the process environment
<DT><TT>`utils'</TT>
<DD>
Utilities used by GDB.  Provides routines to provide formatted output,
memory management, and data conversion routines.
</DL>

<P><HR><P>
Go to the <A HREF="gdbint_1.html">first</A>, <A HREF="gdbint_7.html">previous</A>, <A HREF="gdbint_9.html">next</A>, <A HREF="gdbint_16.html">last</A> section, <A HREF="gdbint_toc.html">table of contents</A>.
</BODY>
</HTML>