Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / info / gdb / Range-Checking.html
blob3004cfaf2effb69ab94b7355b07ba4f3c436a849
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="Range%20Checking">Range Checking</a>,
13 Previous:<a rel="previous" accesskey="p" href="Type-Checking.html#Type%20Checking">Type Checking</a>,
14 Up:<a rel="up" accesskey="u" href="Checks.html#Checks">Checks</a>
15 <hr><br>
16 </div>
18 <h4 class="subsection">An overview of range checking</h4>
20 <p>In some languages (such as Modula-2), it is an error to exceed the
21 bounds of a type; this is enforced with run-time checks. Such range
22 checking is meant to ensure program correctness by making sure
23 computations do not overflow, or indices on an array element access do
24 not exceed the bounds of the array.
26 <p>For expressions you use in GDB commands, you can tell
27 GDB to treat range errors in one of three ways: ignore them,
28 always treat them as errors and abandon the expression, or issue
29 warnings but evaluate the expression anyway.
31 <p>A range error can result from numerical overflow, from exceeding an
32 array index bound, or when you type a constant that is not a member
33 of any type. Some languages, however, do not treat overflows as an
34 error. In many implementations of C, mathematical overflow causes the
35 result to "wrap around" to lower values--for example, if <var>m</var> is
36 the largest integer value, and <var>s</var> is the smallest, then
38 <pre class="example"> <var>m</var> + 1 =&gt; <var>s</var>
39 </pre>
41 <p>This, too, is specific to individual languages, and in some cases
42 specific to individual compilers or machines. See <a href="Support.html#Support">Supported languages</a>, for further details on specific languages.
44 GDB provides some additional commands for controlling the range checker:
46 <dl>
47 <dt><code>set check range auto</code>
48 <dd>Set range checking on or off based on the current working language.
49 See <a href="Support.html#Support">Supported languages</a>, for the default settings for
50 each language.
52 <br><dt><code>set check range on</code>
53 <dd><dt><code>set check range off</code>
54 <dd>Set range checking on or off, overriding the default setting for the
55 current working language. A warning is issued if the setting does not
56 match the language default. If a range error occurs and range checking is on,
57 then a message is printed and evaluation of the expression is aborted.
59 <br><dt><code>set check range warn</code>
60 <dd>Output messages when the GDB range checker detects a range error,
61 but attempt to evaluate the expression anyway. Evaluating the
62 expression may still be impossible for other reasons, such as accessing
63 memory that the process does not own (a typical example from many Unix
64 systems).
66 <br><dt><code>show range</code>
67 <dd>Show the current setting of the range checker, and whether or not it is
68 being set automatically by GDB.
69 </dl>
71 </body></html>