Work around MinGW mangling of "host:/path"
[msysgit/historical-msysgit.git] / mingw / info / gdb / C-plus-plus-expressions.html
blob3d08d7f82a0a1dcdba941f7a03ebae37058cb0e0
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="C%20plus%20plus%20expressions">C plus plus expressions</a>,
13 Next:<a rel="next" accesskey="n" href="C-Defaults.html#C%20Defaults">C Defaults</a>,
14 Previous:<a rel="previous" accesskey="p" href="C-Constants.html#C%20Constants">C Constants</a>,
15 Up:<a rel="up" accesskey="u" href="C.html#C">C</a>
16 <hr><br>
17 </div>
19 <h5 class="subsubsection">C<tt>++</tt> expressions</h5>
21 GDB expression handling can interpret most C<tt>++</tt> expressions.
23 <blockquote>
24 <em>Warning:</em> GDB can only debug C<tt>++</tt> code if you use the
25 proper compiler. Typically, C<tt>++</tt> debugging depends on the use of
26 additional debugging information in the symbol table, and thus requires
27 special support. In particular, if your compiler generates a.out, MIPS
28 <small>ECOFF</small>, RS/6000 <small>XCOFF</small>, or <small>ELF</small> with stabs extensions to the
29 symbol table, these facilities are all available. (With <small>GNU</small> CC,
30 you can use the <code>-gstabs</code> option to request stabs debugging
31 extensions explicitly.) Where the object code format is standard
32 <small>COFF</small> or <small>DWARF</small> in <small>ELF</small>, on the other hand, most of the C<tt>++</tt>
33 support in GDB does <em>not</em> work.
34 </blockquote>
36 <ol type=1 start=1>
38 <li>Member function calls are allowed; you can use expressions like
40 <pre class="example"> count = aml-&gt;GetOriginal(x, y)
41 </pre>
43 <li>While a member function is active (in the selected stack frame), your
44 expressions have the same namespace available as the member function;
45 that is, GDB allows implicit references to the class instance
46 pointer <code>this</code> following the same rules as C<tt>++</tt>.
48 <li>You can call overloaded functions; GDB resolves the function
49 call to the right definition, with some restrictions. GDB does not
50 perform overload resolution involving user-defined type conversions,
51 calls to constructors, or instantiations of templates that do not exist
52 in the program. It also cannot handle ellipsis argument lists or
53 default arguments.
55 <p>It does perform integral conversions and promotions, floating-point
56 promotions, arithmetic conversions, pointer conversions, conversions of
57 class objects to base classes, and standard conversions such as those of
58 functions or arrays to pointers; it requires an exact match on the
59 number of function arguments.
61 <p>Overload resolution is always performed, unless you have specified
62 <code>set overload-resolution off</code>. See <a href="Debugging-C-plus-plus.html#Debugging%20C%20plus%20plus">GDB features for C<tt>++</tt></a>.
64 <p>You must specify <code>set overload-resolution off</code> in order to use an
65 explicit function signature to call an overloaded function, as in
66 <pre class="smallexample"> p 'foo(char,int)'('x', 13)
67 </pre>
69 <p>The GDB command-completion facility can simplify this;
70 see <a href="Completion.html#Completion">Command completion</a>.
72 </p><li>GDB understands variables declared as C<tt>++</tt> references; you can use
73 them in expressions just as you do in C<tt>++</tt> source--they are automatically
74 dereferenced.
76 <p>In the parameter list shown when GDB displays a frame, the values of
77 reference variables are not displayed (unlike other variables); this
78 avoids clutter, since references are often used for large structures.
79 The <em>address</em> of a reference variable is always shown, unless
80 you have specified <code>set print address off</code>.
82 </p><li>GDB supports the C<tt>++</tt> name resolution operator <code>::</code>--your
83 expressions can use it just as expressions in your program do. Since
84 one scope may be defined in another, you can use <code>::</code> repeatedly if
85 necessary, for example in an expression like
86 <code></code><var>scope1</var><code>::</code><var>scope2</var><code>::</code><var>name</var><code></code>. GDB also allows
87 resolving name scope by reference to source files, in both C and C<tt>++</tt>
88 debugging (see <a href="Variables.html#Variables">Program variables</a>).
89 </ol>
91 <p>In addition, when used with HP's C<tt>++</tt> compiler, GDB supports
92 calling virtual functions correctly, printing out virtual bases of
93 objects, calling functions in a base subobject, casting objects, and
94 invoking user-defined operators.
96 </body></html>