288 lines
13 KiB
HTML
288 lines
13 KiB
HTML
<HTML>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<!-- Created on October, 18 2002 by texi2html 1.64 -->
|
|
<!--
|
|
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
|
|
Karl Berry <karl@freefriends.org>
|
|
Olaf Bachmann <obachman@mathematik.uni-kl.de>
|
|
and many others.
|
|
Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
|
|
Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
|
|
|
|
-->
|
|
<HEAD>
|
|
<TITLE>GDB Internals: libgdb</TITLE>
|
|
|
|
<META NAME="description" CONTENT="GDB Internals: libgdb">
|
|
<META NAME="keywords" CONTENT="GDB Internals: libgdb">
|
|
<META NAME="resource-type" CONTENT="document">
|
|
<META NAME="distribution" CONTENT="global">
|
|
<META NAME="Generator" CONTENT="texi2html 1.64">
|
|
|
|
</HEAD>
|
|
|
|
<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
|
|
|
|
<A NAME="SEC27"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_4.html#SEC26"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC28"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_6.html#SEC37"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint.html#SEC_Top"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_6.html#SEC37"> >> </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint.html#SEC_Top">Top</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_toc.html#SEC_Contents">Contents</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_19.html#SEC186">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H1> 5. libgdb </H1>
|
|
<!--docid::SEC27::-->
|
|
<P>
|
|
|
|
<HR SIZE="6">
|
|
<A NAME="SEC28"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC27"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC29"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC27"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC27"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_6.html#SEC37"> >> </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint.html#SEC_Top">Top</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_toc.html#SEC_Contents">Contents</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_19.html#SEC186">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H2> 5.1 libgdb 1.0 </H2>
|
|
<!--docid::SEC28::-->
|
|
<CODE>libgdb</CODE> 1.0 was an abortive project of years ago. The theory was
|
|
to provide an API to GDB's functionality.
|
|
<P>
|
|
|
|
<HR SIZE="6">
|
|
<A NAME="SEC29"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC28"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC30"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC30"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC27"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_6.html#SEC37"> >> </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint.html#SEC_Top">Top</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_toc.html#SEC_Contents">Contents</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_19.html#SEC186">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H2> 5.2 libgdb 2.0 </H2>
|
|
<!--docid::SEC29::-->
|
|
<CODE>libgdb</CODE> 2.0 is an ongoing effort to update GDB so that is
|
|
better able to support graphical and other environments.
|
|
<P>
|
|
|
|
Since <CODE>libgdb</CODE> development is on-going, its architecture is still
|
|
evolving. The following components have so far been identified:
|
|
</P><P>
|
|
|
|
<UL>
|
|
<LI>
|
|
Observer - <TT>`gdb-events.h'</TT>.
|
|
<LI>
|
|
Builder - <TT>`ui-out.h'</TT>
|
|
<LI>
|
|
Event Loop - <TT>`event-loop.h'</TT>
|
|
<LI>
|
|
Library - <TT>`gdb.h'</TT>
|
|
</UL>
|
|
<P>
|
|
|
|
The model that ties these components together is described below.
|
|
</P><P>
|
|
|
|
<HR SIZE="6">
|
|
<A NAME="SEC30"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC29"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC31"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC31"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC27"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_6.html#SEC37"> >> </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint.html#SEC_Top">Top</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_toc.html#SEC_Contents">Contents</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_19.html#SEC186">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H2> 5.3 The <CODE>libgdb</CODE> Model </H2>
|
|
<!--docid::SEC30::-->
|
|
<P>
|
|
|
|
A client of <CODE>libgdb</CODE> interacts with the library in two ways.
|
|
</P><P>
|
|
|
|
<UL>
|
|
<LI>
|
|
As an observer (using <TT>`gdb-events'</TT>) receiving notifications from
|
|
<CODE>libgdb</CODE> of any internal state changes (break point changes, run
|
|
state, etc).
|
|
<LI>
|
|
As a client querying <CODE>libgdb</CODE> (using the <TT>`ui-out'</TT> builder) to
|
|
obtain various status values from GDB.
|
|
</UL>
|
|
<P>
|
|
|
|
Since <CODE>libgdb</CODE> could have multiple clients (e.g. a GUI supporting
|
|
the existing GDB CLI), those clients must co-operate when
|
|
controlling <CODE>libgdb</CODE>. In particular, a client must ensure that
|
|
<CODE>libgdb</CODE> is idle (i.e. no other client is using <CODE>libgdb</CODE>)
|
|
before responding to a <TT>`gdb-event'</TT> by making a query.
|
|
</P><P>
|
|
|
|
<HR SIZE="6">
|
|
<A NAME="SEC31"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC30"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC32"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC32"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC27"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_6.html#SEC37"> >> </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint.html#SEC_Top">Top</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_toc.html#SEC_Contents">Contents</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_19.html#SEC186">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H2> 5.4 CLI support </H2>
|
|
<!--docid::SEC31::-->
|
|
<P>
|
|
|
|
At present GDB's CLI is very much entangled in with the core of
|
|
<CODE>libgdb</CODE>. Consequently, a client wishing to include the CLI in
|
|
their interface needs to carefully co-ordinate its own and the CLI's
|
|
requirements.
|
|
</P><P>
|
|
|
|
It is suggested that the client set <CODE>libgdb</CODE> up to be bi-modal
|
|
(alternate between CLI and client query modes). The notes below sketch
|
|
out the theory:
|
|
</P><P>
|
|
|
|
<UL>
|
|
<LI>
|
|
The client registers itself as an observer of <CODE>libgdb</CODE>.
|
|
<LI>
|
|
The client create and install <CODE>cli-out</CODE> builder using its own
|
|
versions of the <CODE>ui-file</CODE> <CODE>gdb_stderr</CODE>, <CODE>gdb_stdtarg</CODE> and
|
|
<CODE>gdb_stdout</CODE> streams.
|
|
<LI>
|
|
The client creates a separate custom <CODE>ui-out</CODE> builder that is only
|
|
used while making direct queries to <CODE>libgdb</CODE>.
|
|
</UL>
|
|
<P>
|
|
|
|
When the client receives input intended for the CLI, it simply passes it
|
|
along. Since the <CODE>cli-out</CODE> builder is installed by default, all
|
|
the CLI output in response to that command is routed (pronounced rooted)
|
|
through to the client controlled <CODE>gdb_stdout</CODE> et. al. streams.
|
|
At the same time, the client is kept abreast of internal changes by
|
|
virtue of being a <CODE>libgdb</CODE> observer.
|
|
</P><P>
|
|
|
|
The only restriction on the client is that it must wait until
|
|
<CODE>libgdb</CODE> becomes idle before initiating any queries (using the
|
|
client's custom builder).
|
|
</P><P>
|
|
|
|
<HR SIZE="6">
|
|
<A NAME="SEC32"></A>
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC31"> < </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_6.html#SEC37"> > </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC27"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC27"> Up </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_6.html#SEC37"> >> </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint.html#SEC_Top">Top</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_toc.html#SEC_Contents">Contents</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_19.html#SEC186">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<H2> 5.5 <CODE>libgdb</CODE> components </H2>
|
|
<!--docid::SEC32::-->
|
|
<P>
|
|
|
|
<A NAME="SEC33"></A>
|
|
<H3> Observer - <TT>`gdb-events.h'</TT> </H3>
|
|
<!--docid::SEC33::-->
|
|
<TT>`gdb-events'</TT> provides the client with a very raw mechanism that can
|
|
be used to implement an observer. At present it only allows for one
|
|
observer and that observer must, internally, handle the need to delay
|
|
the processing of any event notifications until after <CODE>libgdb</CODE> has
|
|
finished the current command.
|
|
<P>
|
|
|
|
<A NAME="SEC34"></A>
|
|
<H3> Builder - <TT>`ui-out.h'</TT> </H3>
|
|
<!--docid::SEC34::-->
|
|
<TT>`ui-out'</TT> provides the infrastructure necessary for a client to
|
|
create a builder. That builder is then passed down to <CODE>libgdb</CODE>
|
|
when doing any queries.
|
|
<P>
|
|
|
|
<A NAME="SEC35"></A>
|
|
<H3> Event Loop - <TT>`event-loop.h'</TT> </H3>
|
|
<!--docid::SEC35::-->
|
|
<TT>`event-loop'</TT>, currently non-re-entrant, provides a simple event
|
|
loop. A client would need to either plug its self into this loop or,
|
|
implement a new event-loop that GDB would use.
|
|
<P>
|
|
|
|
The event-loop will eventually be made re-entrant. This is so that
|
|
can better handle the problem of some commands blocking
|
|
instead of returning.
|
|
</P><P>
|
|
|
|
<A NAME="SEC36"></A>
|
|
<H3> Library - <TT>`gdb.h'</TT> </H3>
|
|
<!--docid::SEC36::-->
|
|
<TT>`libgdb'</TT> is the most obvious component of this system. It provides
|
|
the query interface. Each function is parameterized by a <CODE>ui-out</CODE>
|
|
builder. The result of the query is constructed using that builder
|
|
before the query function returns.
|
|
<P>
|
|
|
|
<A NAME="Symbol Handling"></A>
|
|
</P><P>
|
|
|
|
<HR SIZE="6">
|
|
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
|
|
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_5.html#SEC27"> << </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_6.html#SEC37"> >> </A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint.html#SEC_Top">Top</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_toc.html#SEC_Contents">Contents</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_19.html#SEC186">Index</A>]</TD>
|
|
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdbint_abt.html#SEC_About"> ? </A>]</TD>
|
|
</TR></TABLE>
|
|
<BR>
|
|
<FONT SIZE="-1">
|
|
|
|
<address>
|
|
|
|
<p>Please send FSF & GNU inquiries & questions to <a
|
|
href="mailto:gnu@gnu.org">gnu@gnu.org</a>. There are also <a
|
|
href="http://www.gnu.org/home.html#ContactInfo">other ways to
|
|
contact</a> the FSF.</p>
|
|
|
|
<p>These pages are maintained by <a
|
|
href="http://www.gnu.org/software/gdb/">the GDB developers</a>.</p>
|
|
|
|
<p>Copyright Free Software Foundation, Inc., 59 Temple Place - Suite
|
|
330, Boston, MA 02111, USA.</p>
|
|
|
|
<p>Verbatim copying and distribution of this entire article is
|
|
permitted in any medium, provided this notice is preserved.</p>
|
|
|
|
</address>
|
|
|
|
This document was generated
|
|
by <I>GDB Administrator</I> on <I>October, 18 2002</I>
|
|
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
|
|
"><I>texi2html</I></A>
|
|
|
|
</BODY>
|
|
</HTML>
|