Methods.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1992-2019 Free Software Foundation, Inc.
  4. Contributed by Cygnus Support. Written by Julia Menapace, Jim Kingdon,
  5. and David MacKenzie.
  6. Permission is granted to copy, distribute and/or modify this document
  7. under the terms of the GNU Free Documentation License, Version 1.3 or
  8. any later version published by the Free Software Foundation; with no
  9. Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  10. Texts. A copy of the license is included in the section entitled "GNU
  11. Free Documentation License". -->
  12. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <title>STABS: Methods</title>
  15. <meta name="description" content="STABS: Methods">
  16. <meta name="keywords" content="STABS: Methods">
  17. <meta name="resource-type" content="document">
  18. <meta name="distribution" content="global">
  19. <meta name="Generator" content="makeinfo">
  20. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index">
  23. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  24. <link href="Cplusplus.html#Cplusplus" rel="up" title="Cplusplus">
  25. <link href="Method-Type-Descriptor.html#Method-Type-Descriptor" rel="next" title="Method Type Descriptor">
  26. <link href="Class-Instance.html#Class-Instance" rel="prev" title="Class Instance">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.smallquotation {font-size: smaller}
  31. div.display {margin-left: 3.2em}
  32. div.example {margin-left: 3.2em}
  33. div.indentedblock {margin-left: 3.2em}
  34. div.lisp {margin-left: 3.2em}
  35. div.smalldisplay {margin-left: 3.2em}
  36. div.smallexample {margin-left: 3.2em}
  37. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  38. div.smalllisp {margin-left: 3.2em}
  39. kbd {font-style:oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. pre.smalldisplay {font-family: inherit; font-size: smaller}
  45. pre.smallexample {font-size: smaller}
  46. pre.smallformat {font-family: inherit; font-size: smaller}
  47. pre.smalllisp {font-size: smaller}
  48. span.nocodebreak {white-space:nowrap}
  49. span.nolinebreak {white-space:nowrap}
  50. span.roman {font-family:serif; font-weight:normal}
  51. span.sansserif {font-family:sans-serif; font-weight:normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  57. <a name="Methods"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Method-Type-Descriptor.html#Method-Type-Descriptor" accesskey="n" rel="next">Method Type Descriptor</a>, Previous: <a href="Class-Instance.html#Class-Instance" accesskey="p" rel="prev">Class Instance</a>, Up: <a href="Cplusplus.html#Cplusplus" accesskey="u" rel="up">Cplusplus</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
  61. </div>
  62. <hr>
  63. <a name="Method-Definition"></a>
  64. <h3 class="section">8.6 Method Definition</h3>
  65. <p>The class definition shown above declares Ameth. The C<tt>++</tt> source below
  66. defines Ameth:
  67. </p>
  68. <div class="example">
  69. <pre class="example">int
  70. baseA::Ameth(int in, char other)
  71. {
  72. return in;
  73. };
  74. </pre></div>
  75. <p>This method definition yields three stabs following the code of the
  76. method. One stab describes the method itself and following two describe
  77. its parameters. Although there is only one formal argument all methods
  78. have an implicit argument which is the <code>this</code> pointer. The <code>this</code>
  79. pointer is a pointer to the object on which the method was called. Note
  80. that the method name is mangled to encode the class name and argument
  81. types. Name mangling is described in the <small>ARM</small> (<cite>The Annotated
  82. C++ Reference Manual</cite>, by Ellis and Stroustrup, <small>ISBN</small>
  83. 0-201-51459-1); <samp>gpcompare.texi</samp> in Cygnus GCC distributions
  84. describes the differences between GNU mangling and <small>ARM</small>
  85. mangling.
  86. </p>
  87. <div class="example">
  88. <pre class="example">.stabs &quot;name:symbol_descriptor(global function)return_type(int)&quot;,
  89. N_FUN, NIL, NIL, code_addr_of_method_start
  90. .stabs &quot;Ameth__5baseAic:F1&quot;,36,0,0,_Ameth__5baseAic
  91. </pre></div>
  92. <p>Here is the stab for the <code>this</code> pointer implicit argument. The
  93. name of the <code>this</code> pointer is always <code>this</code>. Type 19, the
  94. <code>this</code> pointer is defined as a pointer to type 20, <code>baseA</code>,
  95. but a stab defining <code>baseA</code> has not yet been emitted. Since the
  96. compiler knows it will be emitted shortly, here it just outputs a cross
  97. reference to the undefined symbol, by prefixing the symbol name with
  98. &lsquo;<samp>xs</samp>&rsquo;.
  99. </p>
  100. <div class="example">
  101. <pre class="example">.stabs &quot;name:sym_desc(register param)type_def(19)=
  102. type_desc(ptr to)type_ref(baseA)=
  103. type_desc(cross-reference to)baseA:&quot;,N_RSYM,NIL,NIL,register_number
  104. .stabs &quot;this:P19=*20=xsbaseA:&quot;,64,0,0,8
  105. </pre></div>
  106. <p>The stab for the explicit integer argument looks just like a parameter
  107. to a C function. The last field of the stab is the offset from the
  108. argument pointer, which in most systems is the same as the frame
  109. pointer.
  110. </p>
  111. <div class="example">
  112. <pre class="example">.stabs &quot;name:sym_desc(value parameter)type_ref(int)&quot;,
  113. N_PSYM,NIL,NIL,offset_from_arg_ptr
  114. .stabs &quot;in:p1&quot;,160,0,0,72
  115. </pre></div>
  116. <p>&lt;&lt; The examples that follow are based on A1.C &gt;&gt;
  117. </p>
  118. <hr>
  119. <div class="header">
  120. <p>
  121. Next: <a href="Method-Type-Descriptor.html#Method-Type-Descriptor" accesskey="n" rel="next">Method Type Descriptor</a>, Previous: <a href="Class-Instance.html#Class-Instance" accesskey="p" rel="prev">Class Instance</a>, Up: <a href="Cplusplus.html#Cplusplus" accesskey="u" rel="up">Cplusplus</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
  122. </div>
  123. </body>
  124. </html>