Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / info / gdb / Signals.html
blob1191439f809a7c2a12b5f2aa1f84b0ffe716f7b3
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="Signals">Signals</a>,
13 Next:<a rel="next" accesskey="n" href="Thread-Stops.html#Thread%20Stops">Thread Stops</a>,
14 Previous:<a rel="previous" accesskey="p" href="Continuing-and-Stepping.html#Continuing%20and%20Stepping">Continuing and Stepping</a>,
15 Up:<a rel="up" accesskey="u" href="Stopping.html#Stopping">Stopping</a>
16 <hr><br>
17 </div>
19 <h3 class="section">Signals</h3>
21 <p>A signal is an asynchronous event that can happen in a program. The
22 operating system defines the possible kinds of signals, and gives each
23 kind a name and a number. For example, in Unix <code>SIGINT</code> is the
24 signal a program gets when you type an interrupt character (often <kbd>C-c</kbd>);
25 <code>SIGSEGV</code> is the signal a program gets from referencing a place in
26 memory far away from all the areas in use; <code>SIGALRM</code> occurs when
27 the alarm clock timer goes off (which happens only if your program has
28 requested an alarm).
30 <p>Some signals, including <code>SIGALRM</code>, are a normal part of the
31 functioning of your program. Others, such as <code>SIGSEGV</code>, indicate
32 errors; these signals are <dfn>fatal</dfn> (they kill your program immediately) if the
33 program has not specified in advance some other way to handle the signal.
34 <code>SIGINT</code> does not indicate an error in your program, but it is normally
35 fatal so it can carry out the purpose of the interrupt: to kill the program.
37 GDB has the ability to detect any occurrence of a signal in your
38 program. You can tell GDB in advance what to do for each kind of
39 signal.
41 <p>Normally, GDB is set up to let the non-erroneous signals like
42 <code>SIGALRM</code> be silently passed to your program
43 (so as not to interfere with their role in the program's functioning)
44 but to stop your program immediately whenever an error signal happens.
45 You can change these settings with the <code>handle</code> command.
47 <dl>
48 <dt><code>info signals</code>
49 <dd><dt><code>info handle</code>
50 <dd>Print a table of all the kinds of signals and how GDB has been told to
51 handle each one. You can use this to see the signal numbers of all
52 the defined types of signals.
54 <p><code>info handle</code> is an alias for <code>info signals</code>.
56 <br><dt><code>handle </code><var>signal</var><code> </code><var>keywords</var><code>...</code>
57 <dd>Change the way GDB handles signal <var>signal</var>. <var>signal</var>
58 can be the number of a signal or its name (with or without the
59 <code>SIG</code> at the beginning); a list of signal numbers of the form
60 <code></code><var>low</var><code>-</code><var>high</var><code></code>; or the word <code>all</code>, meaning all the
61 known signals. The <var>keywords</var> say what change to make.
62 </dl>
64 <p>The keywords allowed by the <code>handle</code> command can be abbreviated.
65 Their full names are:
67 <dl>
68 <dt><code>nostop</code>
69 <dd>GDB should not stop your program when this signal happens. It may
70 still print a message telling you that the signal has come in.
72 <br><dt><code>stop</code>
73 <dd>GDB should stop your program when this signal happens. This implies
74 the <code>print</code> keyword as well.
76 <br><dt><code>print</code>
77 <dd>GDB should print a message when this signal happens.
79 <br><dt><code>noprint</code>
80 <dd>GDB should not mention the occurrence of the signal at all. This
81 implies the <code>nostop</code> keyword as well.
83 <br><dt><code>pass</code>
84 <dd><dt><code>noignore</code>
85 <dd>GDB should allow your program to see this signal; your program
86 can handle the signal, or else it may terminate if the signal is fatal
87 and not handled. <code>pass</code> and <code>noignore</code> are synonyms.
89 <br><dt><code>nopass</code>
90 <dd><dt><code>ignore</code>
91 <dd>GDB should not allow your program to see this signal.
92 <code>nopass</code> and <code>ignore</code> are synonyms.
93 </dl>
95 <p>When a signal stops your program, the signal is not visible to the
96 program until you
97 continue. Your program sees the signal then, if <code>pass</code> is in
98 effect for the signal in question <em>at that time</em>. In other words,
99 after GDB reports a signal, you can use the <code>handle</code>
100 command with <code>pass</code> or <code>nopass</code> to control whether your
101 program sees that signal when you continue.
103 <p>The default is set to <code>nostop</code>, <code>noprint</code>, <code>pass</code> for
104 non-erroneous signals such as <code>SIGALRM</code>, <code>SIGWINCH</code> and
105 <code>SIGCHLD</code>, and to <code>stop</code>, <code>print</code>, <code>pass</code> for the
106 erroneous signals.
108 <p>You can also use the <code>signal</code> command to prevent your program from
109 seeing a signal, or cause it to see a signal it normally would not see,
110 or to give it any signal at any time. For example, if your program stopped
111 due to some sort of memory reference error, you might store correct
112 values into the erroneous variables and continue, hoping to see more
113 execution; but your program would probably terminate immediately as
114 a result of the fatal signal once it saw the signal. To prevent this,
115 you can continue with <code>signal 0</code>. See <a href="Signaling.html#Signaling">Giving your program a signal</a>.
117 </body></html>