⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdb.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<HTML><HEAD><!-- This HTML file has been created by texi2html 1.52     from gdb.texinfo on 24 March 1999 --><TITLE>Debugging with GDB</TITLE></HEAD><BODY><H1>Debugging with GDB</H1><H2>The GNU Source-Level Debugger</H2><H2>Fifth Edition, for GDB version 4.17</H2><H2>April 1998</H2><ADDRESS>Richard M. Stallman and Roland H. Pesch</ADDRESS><P><P><HR><P><P><P>Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998Free Software Foundation, Inc. <P>Published by the Free Software Foundation <BR>59 Temple Place - Suite 330, <BR>Boston, MA 02111-1307 USA <BR>Printed copies are available for $20 each. <BR>ISBN 1-882114-11-6 <BR>                Permission is granted to make and distribute verbatim copies ofthis manual provided the copyright notice and this permission noticeare preserved on all copies.</P><P>Permission is granted to copy and distribute modified versions of thismanual under the conditions for verbatim copying, provided also that theentire resulting derived work is distributed under the terms of apermission notice identical to this one.</P><P>Permission is granted to copy and distribute translations of this manualinto another language, under the above conditions for modified versions.</P><H1><A NAME="SEC1" HREF="gdb_toc.html#TOC1">Note to VxWorks users</A></H1><P>This manual is reference documentation provided by Wind River as a service to our customers.  It was generated directly from the texinfo source included with GDB.</P><P>In the text, the GDB program is always referred to as simply <SAMP>`gdb'</SAMP>.  Wind River ships multiple GDB executables to support various target processor architectures.  These are named as follows:</P><table><tr><td>gdbarm</td><td>ARM licensed architectures (32-bit code)</td></tr><tr><td>gdbhppa</td><td>HP/UX VxSim simulator</td></tr><tr><td>gdbi86</td><td>Intel 80x86 series</td></tr><tr><td>gdbi960</td><td>Intel i960 series</td></tr><tr><td>gdbm68k</td><td>MC68000 family, CPU32, ColdFire</td></tr><tr><td>gdbmips</td><td>MIPS licensed architectures</td></tr><tr><td>gdbppc</td><td>PowerPC family</td></tr><tr><td>gdbsimnt</td><td>Win32 VxSim simulator</td></tr><tr><td>gdbsimso</td><td>Solaris VxSim simulator</td></tr><tr><td>gdbsparc</td><td>SPARC licensed architectures</td></tr><tr><td>gdbthumb</td><td>ARM licensed architectures (16-bit code)</td></tr></table><P>Please refer to the GDB <CODE>help</CODE> command for more detailed information about changes relative to the 4.17 baseline.</P><H1><A NAME="SEC2" HREF="gdb_toc.html#TOC2">Summary of GDB</A></H1><P>The purpose of a debugger such as GDB is to allow you to see what isgoing on "inside" another program while it executes--or what anotherprogram was doing at the moment it crashed.</P><P>GDB can do four main kinds of things (plus other things in support ofthese) to help you catch bugs in the act:</P><UL><LI>Start your program, specifying anything that might affect its behavior.<LI>Make your program stop on specified conditions.<LI>Examine what has happened, when your program has stopped.<LI>Change things in your program, so you can experiment with correcting theeffects of one bug and go on to learn about another.</UL><P>You can use GDB to debug programs written in C or C++.For more information, see section <A HREF="gdb.html#SEC70">Supported languages</A>.</P><H2><A NAME="SEC3" HREF="gdb_toc.html#TOC3">Free software</A></H2><P>GDB is <EM>free software</EM>, protected by the GNU General Public License(GPL).  The GPL gives you the freedom to copy or adapt a licensedprogram--but every person getting a copy also gets with it thefreedom to modify that copy (which means that they must get access tothe source code), and the freedom to distribute further copies.Typical software companies use copyrights to limit your freedoms; theFree Software Foundation uses the GPL to preserve these freedoms.</P><P>Fundamentally, the General Public License is a license which says thatyou have these freedoms and that you cannot take these freedoms awayfrom anyone else.</P><H2><A NAME="SEC4" HREF="gdb_toc.html#TOC4">Contributors to GDB</A></H2><P>Richard Stallman was the original author of GDB, and of many other GNUprograms.  Many others have contributed to its development.  Thissection attempts to credit major contributors.  One of the virtues offree software is that everyone is free to contribute to it; withregret, we cannot actually acknowledge everyone here.  The file<TT>`ChangeLog'</TT> in the GDB distribution approximates a blow-by-blowaccount.</P><P>Changes much prior to version 2.0 are lost in the mists of time.</P><BLOCKQUOTE><P><EM>Plea:</EM> Additions to this section are particularly welcome.  If youor your friends (or enemies, to be evenhanded) have been unfairlyomitted from this list, we would like to add your names!</BLOCKQUOTE><P>So that they may not regard their long labor as thankless, weparticularly thank those who shepherded GDB through major releases:Stan Shebs (release 4.14),Fred Fish (releases 4.13, 4.12, 4.11, 4.10, and 4.9),Stu Grossman and John Gilmore (releases 4.8, 4.7, 4.6, 4.5, and 4.4),John Gilmore (releases 4.3, 4.2, 4.1, 4.0, and 3.9);Jim Kingdon (releases 3.5, 3.4, and 3.3);and Randy Smith (releases 3.2, 3.1, and 3.0).As major maintainer of GDB for some period, eachcontributed significantly to the structure, stability, and capabilitiesof the entire debugger.</P><P>Richard Stallman, assisted at various times by Peter TerMaat, ChrisHanson, and Richard Mlynarik, handled releases through 2.8.</P><P>Michael Tiemann is the author of most of the GNU C++ support in GDB,with significant additional contributions from Per Bothner.  JamesClark wrote the GNU C++ demangler.  Early work on C++ was by PeterTerMaat (who also did much general update work leading to release 3.0).</P><P>GDB 4 uses the BFD subroutine library to examine multipleobject-file formats; BFD was a joint project of David V.Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.</P><P>David Johnson wrote the original COFF support; Pace Willison didthe original support for encapsulated COFF.</P><P>Brent Benson of Harris Computer Systems contributed DWARF 2 support.</P><P>Adam de Boor and Bradley Davis contributed the ISI Optimum V support.Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPSsupport.Jean-Daniel Fekete contributed Sun 386i support.Chris Hanson improved the HP9000 support.Noboyuki Hikichi and Tomoyuki Hasei contributed Sony/News OS 3 support.David Johnson contributed Encore Umax support.Jyrki Kuoppala contributed Altos 3068 support.Jeff Law contributed HP PA and SOM support.Keith Packard contributed NS32K support.Doug Rabson contributed Acorn Risc Machine support.Bob Rusk contributed Harris Nighthawk CX-UX support.Chris Smith contributed Convex support (and Fortran debugging).Jonathan Stone contributed Pyramid support.Michael Tiemann contributed SPARC support.Tim Tucker contributed support for the Gould NP1 and Gould Powernode.Pace Willison contributed Intel 386 support.Jay Vosburgh contributed Symmetry support.</P><P>Rich Schaefer and Peter Schauer helped with support of SunOS sharedlibraries.</P><P>Jay Fenlason and Roland McGrath ensured that GDB and GAS agree aboutseveral machine instruction sets.</P><P>Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped developremote debugging.  Intel Corporation, Wind River Systems, AMD, and ARMcontributed remote debugging modules for the i960, VxWorks, A29K UDI,and RDI targets, respectively.</P><P>Brian Fox is the author of the readline libraries providingcommand-line editing and command history.</P><P>Andrew Beers of SUNY Buffalo wrote the language-switching code,and contributed the Languages chapter of this manual.</P><P>Fred Fish wrote most of the support for Unix System Vr4.  He also enhanced the command-completion support to cover C++ overloadedsymbols.</P><P>Hitachi America, Ltd. sponsored the support for Hitachi microprocessors.</P><P>Kung Hsu, Jeff Law, and Rick Sladkey added support for hardwarewatchpoints.</P><P>Michael Snyder added support for tracepoints.</P><P>Stu Grossman wrote gdbserver.</P><P>Jim Kingdon, Peter Schauer, Ian Taylor, and Stu Grossman madenearly innumerable bug fixes and cleanups throughout GDB.</P><P>Cygnus Solutions has sponsored GDB maintenance and much of itsdevelopment since 1991.</P><H1><A NAME="SEC5" HREF="gdb_toc.html#TOC5">A Sample GDB Session</A></H1><P>You can use this manual at your leisure to read all about GDB.However, a handful of commands are enough to get started using thedebugger.  This chapter illustrates those commands.</P><P>In this sample session, we emphasize user input like this: <B>input</B>,to make it easier to pick out from the surrounding output.</P><P>One of the preliminary versions of GNU <CODE>m4</CODE> (a generic macroprocessor) exhibits the following bug: sometimes, when we change itsquote strings from the default, the commands used to capture one macrodefinition within another stop working.  In the following short <CODE>m4</CODE>session, we define a macro <CODE>foo</CODE> which expands to <CODE>0000</CODE>; wethen use the <CODE>m4</CODE> built-in <CODE>defn</CODE> to define <CODE>bar</CODE> as thesame thing.  However, when we change the open quote string to<CODE>&#60;QUOTE&#62;</CODE> and the close quote string to <CODE>&#60;UNQUOTE&#62;</CODE>, the sameprocedure fails to define a new synonym <CODE>baz</CODE>:</P><PRE>$ <B>cd gnu/m4</B>$ <B>./m4</B><B>define(foo,0000)</B><B>foo</B>0000<B>define(bar,defn(`foo'))</B><B>bar</B>0000<B>changequote(&#60;QUOTE&#62;,&#60;UNQUOTE&#62;)</B><B>define(baz,defn(&#60;QUOTE&#62;foo&#60;UNQUOTE&#62;))</B><B>baz</B><B>C-d</B>m4: End of input: 0: fatal error: EOF in string</PRE><P>Let us use GDB to try to see what is going on.</P><PRE>$ <B>gdb m4</B>GDB is free software and you are welcome to distribute copies of it under certain conditions; type "show copying" to see  the conditions.There is absolutely no warranty for GDB; type "show warranty"  for details.GDB 4.17, Copyright 1995 Free Software Foundation, Inc...(gdb)</PRE><P>GDB reads only enough symbol data to know where to find therest when needed; as a result, the first prompt comes up very quickly.We now tell GDB to use a narrower display width than usual, sothat examples fit in this manual.</P><PRE>(gdb) <B>set width 70</B></PRE><P>We need to see how the <CODE>m4</CODE> built-in <CODE>changequote</CODE> works.Having looked at the source, we know the relevant subroutine is<CODE>m4_changequote</CODE>, so we set a breakpoint there with the GDB<CODE>break</CODE> command.</P><PRE>(gdb) <B>break m4_changequote</B>Breakpoint 1 at 0x62f4: file builtin.c, line 879.</PRE><P>Using the <CODE>run</CODE> command, we start <CODE>m4</CODE> running under GDBcontrol; as long as control does not reach the <CODE>m4_changequote</CODE>subroutine, the program runs as usual:</P><PRE>(gdb) <B>run</B>Starting program: /work/Editorial/gdb/gnu/m4/m4<B>define(foo,0000)</B><B>foo</B>0000</PRE><P>To trigger the breakpoint, we call <CODE>changequote</CODE>.  GDBsuspends execution of <CODE>m4</CODE>, displaying information about thecontext where it stops.</P><PRE><B>changequote(&#60;QUOTE&#62;,&#60;UNQUOTE&#62;)</B>Breakpoint 1, m4_changequote (argc=3, argv=0x33c70)     at builtin.c:879879         if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3))</PRE><P>Now we use the command <CODE>n</CODE> (<CODE>next</CODE>) to advance execution tothe next line of the current function.</P><PRE>(gdb) <B>n</B>882         set_quotes((argc &#62;= 2) ? TOKEN_DATA_TEXT(argv[1])\

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -