aarch64-none-linux-gnu-12.2.1/share/doc/gdb/GDB_002fMI-File-Commands.html
2025-04-27 10:37:43 +08:00

412 lines
18 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2022 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Free Software" and "Free Software Needs
Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
and with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: "You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom." -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Debugging with GDB: GDB/MI File Commands</title>
<meta name="description" content="Debugging with GDB: GDB/MI File Commands">
<meta name="keywords" content="Debugging with GDB: GDB/MI File Commands">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="GDB_002fMI.html#GDB_002fMI" rel="up" title="GDB/MI">
<link href="GDB_002fMI-Target-Manipulation.html#GDB_002fMI-Target-Manipulation" rel="next" title="GDB/MI Target Manipulation">
<link href="GDB_002fMI-Symbol-Query.html#GDB_002fMI-Symbol-Query" rel="previous" title="GDB/MI Symbol Query">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="GDB_002fMI-File-Commands"></a>
<div class="header">
<p>
Next: <a href="GDB_002fMI-Target-Manipulation.html#GDB_002fMI-Target-Manipulation" accesskey="n" rel="next">GDB/MI Target Manipulation</a>, Previous: <a href="GDB_002fMI-Symbol-Query.html#GDB_002fMI-Symbol-Query" accesskey="p" rel="previous">GDB/MI Symbol Query</a>, Up: <a href="GDB_002fMI.html#GDB_002fMI" accesskey="u" rel="up">GDB/MI</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="GDB_002fMI-File-Commands-1"></a>
<h3 class="section">27.19 <small>GDB/MI</small> File Commands</h3>
<p>This section describes the GDB/MI commands to specify executable file names
and to read in and obtain symbol table information.
</p>
<a name="The-_002dfile_002dexec_002dand_002dsymbols-Command"></a>
<h4 class="subheading">The <code>-file-exec-and-symbols</code> Command</h4>
<a name="index-_002dfile_002dexec_002dand_002dsymbols"></a>
<a name="Synopsis-87"></a>
<h4 class="subsubheading">Synopsis</h4>
<div class="smallexample">
<pre class="smallexample"> -file-exec-and-symbols <var>file</var>
</pre></div>
<p>Specify the executable file to be debugged. This file is the one from
which the symbol table is also read. If no file is specified, the
command clears the executable and symbol information. If breakpoints
are set when using this command with no arguments, <small>GDB</small> will produce
error messages. Otherwise, no output is produced, except a completion
notification.
</p>
<a name="GDB-Command-69"></a>
<h4 class="subsubheading"><small>GDB</small> Command</h4>
<p>The corresponding <small>GDB</small> command is &lsquo;<samp>file</samp>&rsquo;.
</p>
<a name="Example-69"></a>
<h4 class="subsubheading">Example</h4>
<div class="smallexample">
<pre class="smallexample">(gdb)
-file-exec-and-symbols /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
^done
(gdb)
</pre></div>
<a name="The-_002dfile_002dexec_002dfile-Command"></a>
<h4 class="subheading">The <code>-file-exec-file</code> Command</h4>
<a name="index-_002dfile_002dexec_002dfile"></a>
<a name="Synopsis-88"></a>
<h4 class="subsubheading">Synopsis</h4>
<div class="smallexample">
<pre class="smallexample"> -file-exec-file <var>file</var>
</pre></div>
<p>Specify the executable file to be debugged. Unlike
&lsquo;<samp>-file-exec-and-symbols</samp>&rsquo;, the symbol table is <em>not</em> read
from this file. If used without argument, <small>GDB</small> clears the information
about the executable file. No output is produced, except a completion
notification.
</p>
<a name="GDB-Command-70"></a>
<h4 class="subsubheading"><small>GDB</small> Command</h4>
<p>The corresponding <small>GDB</small> command is &lsquo;<samp>exec-file</samp>&rsquo;.
</p>
<a name="Example-70"></a>
<h4 class="subsubheading">Example</h4>
<div class="smallexample">
<pre class="smallexample">(gdb)
-file-exec-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
^done
(gdb)
</pre></div>
<a name="The-_002dfile_002dlist_002dexec_002dsource_002dfile-Command"></a>
<h4 class="subheading">The <code>-file-list-exec-source-file</code> Command</h4>
<a name="index-_002dfile_002dlist_002dexec_002dsource_002dfile"></a>
<a name="Synopsis-89"></a>
<h4 class="subsubheading">Synopsis</h4>
<div class="smallexample">
<pre class="smallexample"> -file-list-exec-source-file
</pre></div>
<p>List the line number, the current source file, and the absolute path
to the current source file for the current executable. The macro
information field has a value of &lsquo;<samp>1</samp>&rsquo; or &lsquo;<samp>0</samp>&rsquo; depending on
whether or not the file includes preprocessor macro information.
</p>
<a name="GDB-Command-71"></a>
<h4 class="subsubheading"><small>GDB</small> Command</h4>
<p>The <small>GDB</small> equivalent is &lsquo;<samp>info source</samp>&rsquo;
</p>
<a name="Example-71"></a>
<h4 class="subsubheading">Example</h4>
<div class="smallexample">
<pre class="smallexample">(gdb)
123-file-list-exec-source-file
123^done,line=&quot;1&quot;,file=&quot;foo.c&quot;,fullname=&quot;/home/bar/foo.c,macro-info=&quot;1&quot;
(gdb)
</pre></div>
<a name="The-_002dfile_002dlist_002dexec_002dsource_002dfiles-Command"></a>
<h4 class="subheading">The <code>-file-list-exec-source-files</code> Command</h4>
<a name="index-info-sources-1"></a>
<a name="index-_002dfile_002dlist_002dexec_002dsource_002dfiles"></a>
<a name="Synopsis-90"></a>
<h4 class="subsubheading">Synopsis</h4>
<div class="smallexample">
<pre class="smallexample"> -file-list-exec-source-files <span class="roman">[</span> <var>--group-by-objfile</var> <span class="roman">]</span>
<span class="roman">[</span> <var>--dirname</var> <span class="roman">|</span> <var>--basename</var> <span class="roman">]</span>
<span class="roman">[</span> -- <span class="roman">]</span>
<span class="roman">[</span> <var>regexp</var> <span class="roman">]</span>
</pre></div>
<p>This command returns information about the source files <small>GDB</small>
knows about, it will output both the filename and fullname (absolute
file name) of a source file, though the fullname can be elided if this
information is not known to <small>GDB</small>.
</p>
<p>With no arguments this command returns a list of source files. Each
source file is represented by a tuple with the fields; <var>file</var>,
<var>fullname</var>, and <var>debug-fully-read</var>. The <var>file</var> is the
display name for the file, while <var>fullname</var> is the absolute name
of the file. The <var>fullname</var> field can be elided if the absolute
name of the source file can&rsquo;t be computed. The field
<var>debug-fully-read</var> will be a string, either <code>true</code> or
<code>false</code>. When <code>true</code>, this indicates the full debug
information for the compilation unit describing this file has been
read in. When <code>false</code>, the full debug information has not yet
been read in. While reading in the full debug information it is
possible that <small>GDB</small> could become aware of additional source
files.
</p>
<p>The optional <var>regexp</var> can be used to filter the list of source
files returned. The <var>regexp</var> will be matched against the full
source file name. The matching is case-sensitive, except on operating
systems that have case-insensitive filesystem (e.g.,
MS-Windows). &lsquo;<samp>--</samp>&rsquo; can be used before <var>regexp</var> to prevent
<small>GDB</small> interpreting <var>regexp</var> as a command option (e.g. if
<var>regexp</var> starts with &lsquo;<samp>-</samp>&rsquo;).
</p>
<p>If <code>--dirname</code> is provided, then <var>regexp</var> is matched only
against the directory name of each source file. If <code>--basename</code>
is provided, then <var>regexp</var> is matched against the basename of each
source file. Only one of <code>--dirname</code> or <code>--basename</code> may be
given, and if either is given then <var>regexp</var> is required.
</p>
<p>If <code>--group-by-objfile</code> is used then the format of the results is
changed. The results will now be a list of tuples, with each tuple
representing an object file (executable or shared library) loaded into
<small>GDB</small>. The fields of these tuples are; <var>filename</var>,
<var>debug-info</var>, and <var>sources</var>. The <var>filename</var> is the
absolute name of the object file, <var>debug-info</var> is a string with
one of the following values:
</p>
<dl compact="compact">
<dt><code>none</code></dt>
<dd><p>This object file has no debug information.
</p></dd>
<dt><code>partially-read</code></dt>
<dd><p>This object file has debug information, but it is not fully read in
yet. When it is read in later, GDB might become aware of additional
source files.
</p></dd>
<dt><code>fully-read</code></dt>
<dd><p>This object file has debug information, and this information is fully
read into GDB. The list of source files is complete.
</p></dd>
</dl>
<p>The <var>sources</var> is a list or tuples, with each tuple describing a
single source file with the same fields as described previously. The
<var>sources</var> list can be empty for object files that have no debug
information.
</p>
<a name="GDB-Command-72"></a>
<h4 class="subsubheading"><small>GDB</small> Command</h4>
<p>The <small>GDB</small> equivalent is &lsquo;<samp>info sources</samp>&rsquo;.
<code>gdbtk</code> has an analogous command &lsquo;<samp>gdb_listfiles</samp>&rsquo;.
</p>
<a name="Example-72"></a>
<h4 class="subsubheading">Example</h4>
<div class="smallexample">
<pre class="smallexample">(gdb)
-file-list-exec-source-files
^done,files=[{file=&quot;foo.c&quot;,fullname=&quot;/home/foo.c&quot;,debug-fully-read=&quot;true&quot;},
{file=&quot;/home/bar.c&quot;,fullname=&quot;/home/bar.c&quot;,debug-fully-read=&quot;true&quot;},
{file=&quot;gdb_could_not_find_fullpath.c&quot;,debug-fully-read=&quot;true&quot;}]
(gdb)
-file-list-exec-source-files
^done,files=[{file=&quot;test.c&quot;,
fullname=&quot;/tmp/info-sources/test.c&quot;,
debug-fully-read=&quot;true&quot;},
{file=&quot;/usr/include/stdc-predef.h&quot;,
fullname=&quot;/usr/include/stdc-predef.h&quot;,
debug-fully-read=&quot;true&quot;},
{file=&quot;header.h&quot;,
fullname=&quot;/tmp/info-sources/header.h&quot;,
debug-fully-read=&quot;true&quot;},
{file=&quot;helper.c&quot;,
fullname=&quot;/tmp/info-sources/helper.c&quot;,
debug-fully-read=&quot;true&quot;}]
(gdb)
-file-list-exec-source-files -- \\.c
^done,files=[{file=&quot;test.c&quot;,
fullname=&quot;/tmp/info-sources/test.c&quot;,
debug-fully-read=&quot;true&quot;},
{file=&quot;helper.c&quot;,
fullname=&quot;/tmp/info-sources/helper.c&quot;,
debug-fully-read=&quot;true&quot;}]
(gdb)
-file-list-exec-source-files --group-by-objfile
^done,files=[{filename=&quot;/tmp/info-sources/test.x&quot;,
debug-info=&quot;fully-read&quot;,
sources=[{file=&quot;test.c&quot;,
fullname=&quot;/tmp/info-sources/test.c&quot;,
debug-fully-read=&quot;true&quot;},
{file=&quot;/usr/include/stdc-predef.h&quot;,
fullname=&quot;/usr/include/stdc-predef.h&quot;,
debug-fully-read=&quot;true&quot;},
{file=&quot;header.h&quot;,
fullname=&quot;/tmp/info-sources/header.h&quot;,
debug-fully-read=&quot;true&quot;}]},
{filename=&quot;/lib64/ld-linux-x86-64.so.2&quot;,
debug-info=&quot;none&quot;,
sources=[]},
{filename=&quot;system-supplied DSO at 0x7ffff7fcf000&quot;,
debug-info=&quot;none&quot;,
sources=[]},
{filename=&quot;/tmp/info-sources/libhelper.so&quot;,
debug-info=&quot;fully-read&quot;,
sources=[{file=&quot;helper.c&quot;,
fullname=&quot;/tmp/info-sources/helper.c&quot;,
debug-fully-read=&quot;true&quot;},
{file=&quot;/usr/include/stdc-predef.h&quot;,
fullname=&quot;/usr/include/stdc-predef.h&quot;,
debug-fully-read=&quot;true&quot;},
{file=&quot;header.h&quot;,
fullname=&quot;/tmp/info-sources/header.h&quot;,
debug-fully-read=&quot;true&quot;}]},
{filename=&quot;/lib64/libc.so.6&quot;,
debug-info=&quot;none&quot;,
sources=[]}]
</pre></div>
<a name="The-_002dfile_002dlist_002dshared_002dlibraries-Command"></a>
<h4 class="subheading">The <code>-file-list-shared-libraries</code> Command</h4>
<a name="index-_002dfile_002dlist_002dshared_002dlibraries"></a>
<a name="Synopsis-91"></a>
<h4 class="subsubheading">Synopsis</h4>
<div class="smallexample">
<pre class="smallexample"> -file-list-shared-libraries [ <var>regexp</var> ]
</pre></div>
<p>List the shared libraries in the program.
With a regular expression <var>regexp</var>, only those libraries whose
names match <var>regexp</var> are listed.
</p>
<a name="GDB-Command-73"></a>
<h4 class="subsubheading"><small>GDB</small> Command</h4>
<p>The corresponding <small>GDB</small> command is &lsquo;<samp>info shared</samp>&rsquo;. The fields
have a similar meaning to the <code>=library-loaded</code> notification.
The <code>ranges</code> field specifies the multiple segments belonging to this
library. Each range has the following fields:
</p>
<dl compact="compact">
<dt>&lsquo;<samp>from</samp>&rsquo;</dt>
<dd><p>The address defining the inclusive lower bound of the segment.
</p></dd>
<dt>&lsquo;<samp>to</samp>&rsquo;</dt>
<dd><p>The address defining the exclusive upper bound of the segment.
</p></dd>
</dl>
<a name="Example-73"></a>
<h4 class="subsubheading">Example</h4>
<div class="smallexample">
<pre class="smallexample">(gdb)
-file-list-exec-source-files
^done,shared-libraries=[
{id=&quot;/lib/libfoo.so&quot;,target-name=&quot;/lib/libfoo.so&quot;,host-name=&quot;/lib/libfoo.so&quot;,symbols-loaded=&quot;1&quot;,thread-group=&quot;i1&quot;,ranges=[{from=&quot;0x72815989&quot;,to=&quot;0x728162c0&quot;}]},
{id=&quot;/lib/libbar.so&quot;,target-name=&quot;/lib/libbar.so&quot;,host-name=&quot;/lib/libbar.so&quot;,symbols-loaded=&quot;1&quot;,thread-group=&quot;i1&quot;,ranges=[{from=&quot;0x76ee48c0&quot;,to=&quot;0x76ee9160&quot;}]}]
(gdb)
</pre></div>
<a name="The-_002dfile_002dsymbol_002dfile-Command"></a>
<h4 class="subheading">The <code>-file-symbol-file</code> Command</h4>
<a name="index-_002dfile_002dsymbol_002dfile"></a>
<a name="Synopsis-92"></a>
<h4 class="subsubheading">Synopsis</h4>
<div class="smallexample">
<pre class="smallexample"> -file-symbol-file <var>file</var>
</pre></div>
<p>Read symbol table info from the specified <var>file</var> argument. When
used without arguments, clears <small>GDB</small>&rsquo;s symbol table info. No output is
produced, except for a completion notification.
</p>
<a name="GDB-Command-74"></a>
<h4 class="subsubheading"><small>GDB</small> Command</h4>
<p>The corresponding <small>GDB</small> command is &lsquo;<samp>symbol-file</samp>&rsquo;.
</p>
<a name="Example-74"></a>
<h4 class="subsubheading">Example</h4>
<div class="smallexample">
<pre class="smallexample">(gdb)
-file-symbol-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
^done
(gdb)
</pre></div>
<hr>
<div class="header">
<p>
Next: <a href="GDB_002fMI-Target-Manipulation.html#GDB_002fMI-Target-Manipulation" accesskey="n" rel="next">GDB/MI Target Manipulation</a>, Previous: <a href="GDB_002fMI-Symbol-Query.html#GDB_002fMI-Symbol-Query" accesskey="p" rel="previous">GDB/MI Symbol Query</a>, Up: <a href="GDB_002fMI.html#GDB_002fMI" accesskey="u" rel="up">GDB/MI</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>