Inheritance.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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: Inheritance</title>
  15. <meta name="description" content="STABS: Inheritance">
  16. <meta name="keywords" content="STABS: Inheritance">
  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="Virtual-Base-Classes.html#Virtual-Base-Classes" rel="next" title="Virtual Base Classes">
  26. <link href="Virtual-Methods.html#Virtual-Methods" rel="prev" title="Virtual Methods">
  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="Inheritance"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Virtual-Base-Classes.html#Virtual-Base-Classes" accesskey="n" rel="next">Virtual Base Classes</a>, Previous: <a href="Virtual-Methods.html#Virtual-Methods" accesskey="p" rel="prev">Virtual Methods</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="Inheritance-1"></a>
  64. <h3 class="section">8.12 Inheritance</h3>
  65. <p>Stabs describing C<tt>++</tt> derived classes include additional sections that
  66. describe the inheritance hierarchy of the class. A derived class stab
  67. also encodes the number of base classes. For each base class it tells
  68. if the base class is virtual or not, and if the inheritance is private
  69. or public. It also gives the offset into the object of the portion of
  70. the object corresponding to each base class.
  71. </p>
  72. <p>This additional information is embedded in the class stab following the
  73. number of bytes in the struct. First the number of base classes
  74. appears bracketed by an exclamation point and a comma.
  75. </p>
  76. <p>Then for each base type there repeats a series: a virtual character, a
  77. visibility character, a number, a comma, another number, and a
  78. semi-colon.
  79. </p>
  80. <p>The virtual character is &lsquo;<samp>1</samp>&rsquo; if the base class is virtual and
  81. &lsquo;<samp>0</samp>&rsquo; if not. The visibility character is &lsquo;<samp>2</samp>&rsquo; if the derivation
  82. is public, &lsquo;<samp>1</samp>&rsquo; if it is protected, and &lsquo;<samp>0</samp>&rsquo; if it is private.
  83. Debuggers should ignore virtual or visibility characters they do not
  84. recognize, and assume a reasonable default (such as public and
  85. non-virtual) (GDB 4.11 does not, but this should be fixed in the next
  86. GDB release).
  87. </p>
  88. <p>The number following the virtual and visibility characters is the offset
  89. from the start of the object to the part of the object pertaining to the
  90. base class.
  91. </p>
  92. <p>After the comma, the second number is a type_descriptor for the base
  93. type. Finally a semi-colon ends the series, which repeats for each
  94. base class.
  95. </p>
  96. <p>The source below defines three base classes <code>A</code>, <code>B</code>, and
  97. <code>C</code> and the derived class <code>D</code>.
  98. </p>
  99. <div class="example">
  100. <pre class="example">class A {
  101. public:
  102. int Adat;
  103. virtual int A_virt (int arg) { return arg; };
  104. };
  105. class B {
  106. public:
  107. int B_dat;
  108. virtual int B_virt (int arg) {return arg; };
  109. };
  110. class C {
  111. public:
  112. int Cdat;
  113. virtual int C_virt (int arg) {return arg; };
  114. };
  115. class D : A, virtual B, public C {
  116. public:
  117. int Ddat;
  118. virtual int A_virt (int arg ) { return arg+1; };
  119. virtual int B_virt (int arg) { return arg+2; };
  120. virtual int C_virt (int arg) { return arg+3; };
  121. virtual int D_virt (int arg) { return arg; };
  122. };
  123. </pre></div>
  124. <p>Class stabs similar to the ones described earlier are generated for
  125. each base class.
  126. </p>
  127. <div class="smallexample">
  128. <pre class="smallexample">.stabs &quot;A:T20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32;
  129. A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;&quot;,128,0,0,0
  130. .stabs &quot;B:Tt25=s8Bdat:1,0,32;$vf25:21,32;B_virt::26=##1;
  131. :i;2A*-2147483647;25;;;~%25;&quot;,128,0,0,0
  132. .stabs &quot;C:Tt28=s8Cdat:1,0,32;$vf28:21,32;C_virt::29=##1;
  133. :i;2A*-2147483647;28;;;~%28;&quot;,128,0,0,0
  134. </pre></div>
  135. <p>In the stab describing derived class <code>D</code> below, the information about
  136. the derivation of this class is encoded as follows.
  137. </p>
  138. <div class="display">
  139. <pre class="display">.stabs &quot;derived_class_name:symbol_descriptors(struct tag&amp;type)=
  140. type_descriptor(struct)struct_bytes(32)!num_bases(3),
  141. base_virtual(no)inheritance_public(no)base_offset(0),
  142. base_class_type_ref(A);
  143. base_virtual(yes)inheritance_public(no)base_offset(NIL),
  144. base_class_type_ref(B);
  145. base_virtual(no)inheritance_public(yes)base_offset(64),
  146. base_class_type_ref(C); &hellip;
  147. </pre></div>
  148. <div class="smallexample">
  149. <pre class="smallexample">.stabs &quot;D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:
  150. 1,160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt:
  151. :32:i;2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;
  152. 28;;D_virt::32:i;2A*-2147483646;31;;;~%20;&quot;,128,0,0,0
  153. </pre></div>
  154. <hr>
  155. <div class="header">
  156. <p>
  157. Next: <a href="Virtual-Base-Classes.html#Virtual-Base-Classes" accesskey="n" rel="next">Virtual Base Classes</a>, Previous: <a href="Virtual-Methods.html#Virtual-Methods" accesskey="p" rel="prev">Virtual Methods</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>
  158. </div>
  159. </body>
  160. </html>