Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / info / gdb / Invoking-GDB.html
blobaa572c90da87fed7d8cc5bdf07499f2665b3b29c
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="Invoking%20GDB">Invoking GDB</a>,
13 Next:<a rel="next" accesskey="n" href="Quitting-GDB.html#Quitting%20GDB">Quitting GDB</a>,
14 Up:<a rel="up" accesskey="u" href="Invocation.html#Invocation">Invocation</a>
15 <hr><br>
16 </div>
18 <h3 class="section">Invoking GDB</h3>
20 <p>Invoke GDB by running the program <code>gdb</code>. Once started,
21 GDB reads commands from the terminal until you tell it to exit.
23 <p>You can also run <code>gdb</code> with a variety of arguments and options,
24 to specify more of your debugging environment at the outset.
26 <p>The command-line options described here are designed
27 to cover a variety of situations; in some environments, some of these
28 options may effectively be unavailable.
30 <p>The most usual way to start GDB is with one argument,
31 specifying an executable program:
33 <pre class="example"> gdb <var>program</var>
34 </pre>
36 <p>You can also start with both an executable program and a core file
37 specified:
39 <pre class="example"> gdb <var>program</var> <var>core</var>
40 </pre>
42 <p>You can, instead, specify a process ID as a second argument, if you want
43 to debug a running process:
45 <pre class="example"> gdb <var>program</var> 1234
46 </pre>
48 <p>would attach GDB to process <code>1234</code> (unless you also have a file
49 named <code>1234</code>; GDB does check for a core file first).
51 <p>Taking advantage of the second command-line argument requires a fairly
52 complete operating system; when you use GDB as a remote
53 debugger attached to a bare board, there may not be any notion of
54 "process", and there is often no way to get a core dump. GDB
55 will warn you if it is unable to attach or to read core dumps.
57 <p>You can optionally have <code>gdb</code> pass any arguments after the
58 executable file to the inferior using <code>--args</code>. This option stops
59 option processing.
60 <pre class="example"> gdb --args gcc -O2 -c foo.c
61 </pre>
62 This will cause <code>gdb</code> to debug <code>gcc</code>, and to set
63 <code>gcc</code>'s command-line arguments (see <a href="Arguments.html#Arguments">Arguments</a>) to <code>-O2 -c foo.c</code>.
65 <p>You can run <code>gdb</code> without printing the front material, which describes
66 GDB's non-warranty, by specifying <code>-silent</code>:
68 <pre class="smallexample"> gdb -silent
69 </pre>
71 <p>You can further control how GDB starts up by using command-line
72 options. GDB itself can remind you of the options available.
74 <p>Type
76 <pre class="example"> gdb -help
77 </pre>
79 <p>to display all available options and briefly describe their use
80 (<code>gdb -h</code> is a shorter equivalent).
82 <p>All options and command line arguments you give are processed
83 in sequential order. The order makes a difference when the
84 <code>-x</code> option is used.
86 <ul class="menu">
87 <li><a accesskey="1" href="File-Options.html#File%20Options">File Options</a>: Choosing files
88 <li><a accesskey="2" href="Mode-Options.html#Mode%20Options">Mode Options</a>: Choosing modes
89 </ul>
91 </body></html>