Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Inheritance.html 7.4KB

il y a 3 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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-2020 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 6.5, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  15. <title>Inheritance (STABS)</title>
  16. <meta name="description" content="Inheritance (STABS)">
  17. <meta name="keywords" content="Inheritance (STABS)">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  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.indentedblock {margin-right: 0em}
  31. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  32. blockquote.smallquotation {font-size: smaller}
  33. div.display {margin-left: 3.2em}
  34. div.example {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  49. span.roman {font-family: initial; font-weight: normal}
  50. span.sansserif {font-family: sans-serif; font-weight: normal}
  51. ul.no-bullet {list-style: none}
  52. -->
  53. </style>
  54. </head>
  55. <body lang="en">
  56. <a name="Inheritance"></a>
  57. <div class="header">
  58. <p>
  59. 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>
  60. </div>
  61. <hr>
  62. <a name="Inheritance-1"></a>
  63. <h3 class="section">8.12 Inheritance</h3>
  64. <p>Stabs describing C<tt>++</tt> derived classes include additional sections that
  65. describe the inheritance hierarchy of the class. A derived class stab
  66. also encodes the number of base classes. For each base class it tells
  67. if the base class is virtual or not, and if the inheritance is private
  68. or public. It also gives the offset into the object of the portion of
  69. the object corresponding to each base class.
  70. </p>
  71. <p>This additional information is embedded in the class stab following the
  72. number of bytes in the struct. First the number of base classes
  73. appears bracketed by an exclamation point and a comma.
  74. </p>
  75. <p>Then for each base type there repeats a series: a virtual character, a
  76. visibility character, a number, a comma, another number, and a
  77. semi-colon.
  78. </p>
  79. <p>The virtual character is &lsquo;<samp>1</samp>&rsquo; if the base class is virtual and
  80. &lsquo;<samp>0</samp>&rsquo; if not. The visibility character is &lsquo;<samp>2</samp>&rsquo; if the derivation
  81. is public, &lsquo;<samp>1</samp>&rsquo; if it is protected, and &lsquo;<samp>0</samp>&rsquo; if it is private.
  82. Debuggers should ignore virtual or visibility characters they do not
  83. recognize, and assume a reasonable default (such as public and
  84. non-virtual) (GDB 4.11 does not, but this should be fixed in the next
  85. GDB release).
  86. </p>
  87. <p>The number following the virtual and visibility characters is the offset
  88. from the start of the object to the part of the object pertaining to the
  89. base class.
  90. </p>
  91. <p>After the comma, the second number is a type_descriptor for the base
  92. type. Finally a semi-colon ends the series, which repeats for each
  93. base class.
  94. </p>
  95. <p>The source below defines three base classes <code>A</code>, <code>B</code>, and
  96. <code>C</code> and the derived class <code>D</code>.
  97. </p>
  98. <div class="example">
  99. <pre class="example">class A {
  100. public:
  101. int Adat;
  102. virtual int A_virt (int arg) { return arg; };
  103. };
  104. class B {
  105. public:
  106. int B_dat;
  107. virtual int B_virt (int arg) {return arg; };
  108. };
  109. class C {
  110. public:
  111. int Cdat;
  112. virtual int C_virt (int arg) {return arg; };
  113. };
  114. class D : A, virtual B, public C {
  115. public:
  116. int Ddat;
  117. virtual int A_virt (int arg ) { return arg+1; };
  118. virtual int B_virt (int arg) { return arg+2; };
  119. virtual int C_virt (int arg) { return arg+3; };
  120. virtual int D_virt (int arg) { return arg; };
  121. };
  122. </pre></div>
  123. <p>Class stabs similar to the ones described earlier are generated for
  124. each base class.
  125. </p>
  126. <div class="smallexample">
  127. <pre class="smallexample">.stabs &quot;A:T20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32;
  128. A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;&quot;,128,0,0,0
  129. .stabs &quot;B:Tt25=s8Bdat:1,0,32;$vf25:21,32;B_virt::26=##1;
  130. :i;2A*-2147483647;25;;;~%25;&quot;,128,0,0,0
  131. .stabs &quot;C:Tt28=s8Cdat:1,0,32;$vf28:21,32;C_virt::29=##1;
  132. :i;2A*-2147483647;28;;;~%28;&quot;,128,0,0,0
  133. </pre></div>
  134. <p>In the stab describing derived class <code>D</code> below, the information about
  135. the derivation of this class is encoded as follows.
  136. </p>
  137. <div class="display">
  138. <pre class="display">.stabs &quot;derived_class_name:symbol_descriptors(struct tag&amp;type)=
  139. type_descriptor(struct)struct_bytes(32)!num_bases(3),
  140. base_virtual(no)inheritance_public(no)base_offset(0),
  141. base_class_type_ref(A);
  142. base_virtual(yes)inheritance_public(no)base_offset(NIL),
  143. base_class_type_ref(B);
  144. base_virtual(no)inheritance_public(yes)base_offset(64),
  145. base_class_type_ref(C); &hellip;
  146. </pre></div>
  147. <div class="smallexample">
  148. <pre class="smallexample">.stabs &quot;D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:
  149. 1,160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt:
  150. :32:i;2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;
  151. 28;;D_virt::32:i;2A*-2147483646;31;;;~%20;&quot;,128,0,0,0
  152. </pre></div>
  153. <hr>
  154. <div class="header">
  155. <p>
  156. 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>
  157. </div>
  158. </body>
  159. </html>