Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / info / stabs / Methods.html
blob28026775101baa191625b03915ba2a5ad5e93d9a
1 <html lang="en">
2 <head>
3 <title>STABS</title>
4 <meta http-equiv="Content-Type" content="text/html">
5 <meta name="description" content="STABS">
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="Methods">Methods</a>,
13 Next:<a rel="next" accesskey="n" href="Method-Type-Descriptor.html#Method%20Type%20Descriptor">Method Type Descriptor</a>,
14 Previous:<a rel="previous" accesskey="p" href="Class-Instance.html#Class%20Instance">Class Instance</a>,
15 Up:<a rel="up" accesskey="u" href="Cplusplus.html#Cplusplus">Cplusplus</a>
16 <hr><br>
17 </div>
19 <h3 class="section">Method Definition</h3>
21 <p>The class definition shown above declares Ameth. The C++ source below
22 defines Ameth:
24 <pre class="example"> int
25 baseA::Ameth(int in, char other)
27 return in;
29 </pre>
31 <p>This method definition yields three stabs following the code of the
32 method. One stab describes the method itself and following two describe
33 its parameters. Although there is only one formal argument all methods
34 have an implicit argument which is the <code>this</code> pointer. The <code>this</code>
35 pointer is a pointer to the object on which the method was called. Note
36 that the method name is mangled to encode the class name and argument
37 types. Name mangling is described in the <small>ARM</small> (<cite>The Annotated
38 C++ Reference Manual</cite>, by Ellis and Stroustrup, <small>ISBN</small>
39 0-201-51459-1); <code>gpcompare.texi</code> in Cygnus GCC distributions
40 describes the differences between GNU mangling and <small>ARM</small>
41 mangling.
43 <pre class="example"> .stabs "name:symbol_descriptor(global function)return_type(int)",
44 N_FUN, NIL, NIL, code_addr_of_method_start
46 .stabs "Ameth__5baseAic:F1",36,0,0,_Ameth__5baseAic
47 </pre>
49 <p>Here is the stab for the <code>this</code> pointer implicit argument. The
50 name of the <code>this</code> pointer is always <code>this</code>. Type 19, the
51 <code>this</code> pointer is defined as a pointer to type 20, <code>baseA</code>,
52 but a stab defining <code>baseA</code> has not yet been emitted. Since the
53 compiler knows it will be emitted shortly, here it just outputs a cross
54 reference to the undefined symbol, by prefixing the symbol name with
55 <code>xs</code>.
57 <pre class="example"> .stabs "name:sym_desc(register param)type_def(19)=
58 type_desc(ptr to)type_ref(baseA)=
59 type_desc(cross-reference to)baseA:",N_RSYM,NIL,NIL,register_number
61 .stabs "this:P19=*20=xsbaseA:",64,0,0,8
62 </pre>
64 <p>The stab for the explicit integer argument looks just like a parameter
65 to a C function. The last field of the stab is the offset from the
66 argument pointer, which in most systems is the same as the frame
67 pointer.
69 <pre class="example"> .stabs "name:sym_desc(value parameter)type_ref(int)",
70 N_PSYM,NIL,NIL,offset_from_arg_ptr
72 .stabs "in:p1",160,0,0,72
73 </pre>
75 <p>&lt;&lt; The examples that follow are based on A1.C &gt;&gt;
77 </body></html>