Work around MinGW mangling of "host:/path"
[msysgit/historical-msysgit.git] / mingw / info / gdb / Source-Path.html
blob845c895f4b71c41db4aba3085f8e873c94354462
1 <html lang="en">
2 <head>
3 <title>Debugging with GDB</title>
4 <meta http-equiv="Content-Type" content="text/html">
5 <meta name="description" content="Debugging with GDB">
6 <meta name="generator" content="makeinfo 4.3">
7 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
8 </head>
9 <body>
10 <div class="node">
11 <p>
12 Node:<a name="Source%20Path">Source Path</a>,
13 Next:<a rel="next" accesskey="n" href="Machine-Code.html#Machine%20Code">Machine Code</a>,
14 Previous:<a rel="previous" accesskey="p" href="Search.html#Search">Search</a>,
15 Up:<a rel="up" accesskey="u" href="Source.html#Source">Source</a>
16 <hr><br>
17 </div>
19 <h3 class="section">Specifying source directories</h3>
21 <p>Executable programs sometimes do not record the directories of the source
22 files from which they were compiled, just the names. Even when they do,
23 the directories could be moved between the compilation and your debugging
24 session. GDB has a list of directories to search for source files;
25 this is called the <dfn>source path</dfn>. Each time GDB wants a source file,
26 it tries all the directories in the list, in the order they are present
27 in the list, until it finds a file with the desired name. Note that
28 the executable search path is <em>not</em> used for this purpose. Neither is
29 the current working directory, unless it happens to be in the source
30 path.
32 <p>If GDB cannot find a source file in the source path, and the
33 object program records a directory, GDB tries that directory
34 too. If the source path is empty, and there is no record of the
35 compilation directory, GDB looks in the current directory as a
36 last resort.
38 <p>Whenever you reset or rearrange the source path, GDB clears out
39 any information it has cached about where source files are found and where
40 each line is in the file.
42 <p>When you start GDB, its source path includes only <code>cdir</code>
43 and <code>cwd</code>, in that order.
44 To add other directories, use the <code>directory</code> command.
46 <dl>
47 <dt><code>directory </code><var>dirname</var><code> ...</code>
48 <dd><br><dt><code>dir </code><var>dirname</var><code> ...</code>
49 <dd>Add directory <var>dirname</var> to the front of the source path. Several
50 directory names may be given to this command, separated by <code>:</code>
51 (<code>;</code> on MS-DOS and MS-Windows, where <code>:</code> usually appears as
52 part of absolute file names) or
53 whitespace. You may specify a directory that is already in the source
54 path; this moves it forward, so GDB searches it sooner.
56 <p>You can use the string <code>$cdir</code> to refer to the compilation
57 directory (if one is recorded), and <code>$cwd</code> to refer to the current
58 working directory. <code>$cwd</code> is not the same as <code>.</code>--the former
59 tracks the current working directory as it changes during your GDB
60 session, while the latter is immediately expanded to the current
61 directory at the time you add an entry to the source path.
63 <br><dt><code>directory</code>
64 <dd>Reset the source path to empty again. This requires confirmation.
66 <br><dt><code>show directories</code>
67 <dd>Print the source path: show which directories it contains.
68 </dl>
70 <p>If your source path is cluttered with directories that are no longer of
71 interest, GDB may sometimes cause confusion by finding the wrong
72 versions of source. You can correct the situation as follows:
74 <ol type=1 start=1>
75 <li>Use <code>directory</code> with no argument to reset the source path to empty.
77 <li>Use <code>directory</code> with suitable arguments to reinstall the
78 directories you want in the source path. You can add all the
79 directories in one command.
80 </ol>
82 </body></html>