hc
2023-11-06 15ade055295d13f95d49e3d99b09f3bbfb4a43e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1992-2017 Free Software Foundation, Inc.
Contributed by Cygnus Support.  Written by Julia Menapace, Jim Kingdon,
and David MacKenzie.
 
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts.  A copy of the license is included in the section entitled "GNU
Free Documentation License". -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>STABS: Inheritance</title>
 
<meta name="description" content="STABS: Inheritance">
<meta name="keywords" content="STABS: Inheritance">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Cplusplus.html#Cplusplus" rel="up" title="Cplusplus">
<link href="Virtual-Base-Classes.html#Virtual-Base-Classes" rel="next" title="Virtual Base Classes">
<link href="Virtual-Methods.html#Virtual-Methods" rel="prev" title="Virtual Methods">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
 
 
</head>
 
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Inheritance"></a>
<div class="header">
<p>
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>
</div>
<hr>
<a name="Inheritance-1"></a>
<h3 class="section">8.12 Inheritance</h3>
 
<p>Stabs describing C<tt>++</tt> derived classes include additional sections that
describe the inheritance hierarchy of the class.  A derived class stab
also encodes the number of base classes.  For each base class it tells
if the base class is virtual or not, and if the inheritance is private
or public.  It also gives the offset into the object of the portion of
the object corresponding to each base class.
</p>
<p>This additional information is embedded in the class stab following the
number of bytes in the struct.  First the number of base classes
appears bracketed by an exclamation point and a comma.
</p>
<p>Then for each base type there repeats a series: a virtual character, a
visibility character, a number, a comma, another number, and a
semi-colon.
</p>
<p>The virtual character is &lsquo;<samp>1</samp>&rsquo; if the base class is virtual and
&lsquo;<samp>0</samp>&rsquo; if not.  The visibility character is &lsquo;<samp>2</samp>&rsquo; if the derivation
is public, &lsquo;<samp>1</samp>&rsquo; if it is protected, and &lsquo;<samp>0</samp>&rsquo; if it is private.
Debuggers should ignore virtual or visibility characters they do not
recognize, and assume a reasonable default (such as public and
non-virtual) (GDB 4.11 does not, but this should be fixed in the next
GDB release).
</p>
<p>The number following the virtual and visibility characters is the offset
from the start of the object to the part of the object pertaining to the
base class.
</p>
<p>After the comma, the second number is a type_descriptor for the base
type.  Finally a semi-colon ends the series, which repeats for each
base class.
</p>
<p>The source below defines three base classes <code>A</code>, <code>B</code>, and
<code>C</code> and the derived class <code>D</code>.
</p>
 
<div class="example">
<pre class="example">class A {
public:
        int Adat;
        virtual int A_virt (int arg) { return arg; };
};
 
class B {
public:
        int B_dat;
        virtual int B_virt (int arg) {return arg; };
};
 
class C {
public:
        int Cdat;
        virtual int C_virt (int arg) {return arg; };
};
 
class D : A, virtual B, public C {
public:
        int Ddat;
        virtual int A_virt (int arg ) { return arg+1; };
        virtual int B_virt (int arg)  { return arg+2; };
        virtual int C_virt (int arg)  { return arg+3; };
        virtual int D_virt (int arg)  { return arg; };
};
</pre></div>
 
<p>Class stabs similar to the ones described earlier are generated for
each base class.
</p>
<div class="smallexample">
<pre class="smallexample">.stabs &quot;A:T20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32;
        A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;&quot;,128,0,0,0
 
.stabs &quot;B:Tt25=s8Bdat:1,0,32;$vf25:21,32;B_virt::26=##1;
        :i;2A*-2147483647;25;;;~%25;&quot;,128,0,0,0
 
.stabs &quot;C:Tt28=s8Cdat:1,0,32;$vf28:21,32;C_virt::29=##1;
        :i;2A*-2147483647;28;;;~%28;&quot;,128,0,0,0
</pre></div>
 
<p>In the stab describing derived class <code>D</code> below, the information about
the derivation of this class is encoded as follows.
</p>
<div class="display">
<pre class="display">.stabs &quot;derived_class_name:symbol_descriptors(struct tag&amp;type)=
        type_descriptor(struct)struct_bytes(32)!num_bases(3),
        base_virtual(no)inheritance_public(no)base_offset(0),
        base_class_type_ref(A);
        base_virtual(yes)inheritance_public(no)base_offset(NIL),
        base_class_type_ref(B);
        base_virtual(no)inheritance_public(yes)base_offset(64),
        base_class_type_ref(C); &hellip;
</pre></div>
 
<div class="smallexample">
<pre class="smallexample">.stabs &quot;D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:
        1,160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt:
        :32:i;2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;
        28;;D_virt::32:i;2A*-2147483646;31;;;~%20;&quot;,128,0,0,0
</pre></div>
 
<hr>
<div class="header">
<p>
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>
</div>
 
 
 
</body>
</html>