Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / info / gdb / Expressions.html
blob57490aeffae85c95b076f0313c54f234639baadd
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="Expressions">Expressions</a>,
13 Next:<a rel="next" accesskey="n" href="Variables.html#Variables">Variables</a>,
14 Up:<a rel="up" accesskey="u" href="Data.html#Data">Data</a>
15 <hr><br>
16 </div>
18 <h3 class="section">Expressions</h3>
20 <p><code>print</code> and many other GDB commands accept an expression and
21 compute its value. Any kind of constant, variable or operator defined
22 by the programming language you are using is valid in an expression in
23 GDB. This includes conditional expressions, function calls, casts
24 and string constants. It unfortunately does not include symbols defined
25 by preprocessor <code>#define</code> commands.
27 GDB supports array constants in expressions input by
28 the user. The syntax is {<var>element</var>, <var>element</var><small class="dots">...</small>}. For example,
29 you can use the command <code>print {1, 2, 3}</code> to build up an array in
30 memory that is <code>malloc</code>ed in the target program.
32 <p>Because C is so widespread, most of the expressions shown in examples in
33 this manual are in C. See <a href="Languages.html#Languages">Using GDB with Different Languages</a>, for information on how to use expressions in other
34 languages.
36 <p>In this section, we discuss operators that you can use in GDB
37 expressions regardless of your programming language.
39 <p>Casts are supported in all languages, not just in C, because it is so
40 useful to cast a number into a pointer in order to examine a structure
41 at that address in memory.
43 GDB supports these operators, in addition to those common
44 to programming languages:
46 <dl>
47 <dt><code>@</code>
48 <dd><code>@</code> is a binary operator for treating parts of memory as arrays.
49 See <a href="Arrays.html#Arrays">Artificial arrays</a>, for more information.
51 <br><dt><code>::</code>
52 <dd><code>::</code> allows you to specify a variable in terms of the file or
53 function where it is defined. See <a href="Variables.html#Variables">Program variables</a>.
55 <br><dt><code>{</code><var>type</var><code>} </code><var>addr</var><code></code>
56 <dd>Refers to an object of type <var>type</var> stored at address <var>addr</var> in
57 memory. <var>addr</var> may be any expression whose value is an integer or
58 pointer (but parentheses are required around binary operators, just as in
59 a cast). This construct is allowed regardless of what kind of data is
60 normally supposed to reside at <var>addr</var>.
61 </dl>
63 </body></html>