Work around MinGW mangling of "host:/path"
[msysgit/historical-msysgit.git] / mingw / info / stabs / Protections.html
blobadc0c118f0900325c2eb62b332fbe2c2a55f90f4
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="Protections">Protections</a>,
13 Next:<a rel="next" accesskey="n" href="Method-Modifiers.html#Method%20Modifiers">Method Modifiers</a>,
14 Previous:<a rel="previous" accesskey="p" href="Member-Type-Descriptor.html#Member%20Type%20Descriptor">Member Type Descriptor</a>,
15 Up:<a rel="up" accesskey="u" href="Cplusplus.html#Cplusplus">Cplusplus</a>
16 <hr><br>
17 </div>
19 <h3 class="section">Protections</h3>
21 <p>In the simple class definition shown above all member data and
22 functions were publicly accessible. The example that follows
23 contrasts public, protected and privately accessible fields and shows
24 how these protections are encoded in C++ stabs.
26 <p>If the character following the <code></code><var>field-name</var><code>:</code> part of the
27 string is <code>/</code>, then the next character is the visibility. <code>0</code>
28 means private, <code>1</code> means protected, and <code>2</code> means public.
29 Debuggers should ignore visibility characters they do not recognize, and
30 assume a reasonable default (such as public) (GDB 4.11 does not, but
31 this should be fixed in the next GDB release). If no visibility is
32 specified the field is public. The visibility <code>9</code> means that the
33 field has been optimized out and is public (there is no way to specify
34 an optimized out field with a private or protected visibility).
35 Visibility <code>9</code> is not supported by GDB 4.11; this should be fixed
36 in the next GDB release.
38 <p>The following C++ source:
40 <pre class="example"> class vis {
41 private:
42 int priv;
43 protected:
44 char prot;
45 public:
46 float pub;
48 </pre>
50 <p>generates the following stab:
52 <pre class="example"> # 128 is N_LSYM
53 .stabs "vis:T19=s12priv:/01,0,32;prot:/12,32,8;pub:12,64,32;;",128,0,0,0
54 </pre>
56 <p><code>vis:T19=s12</code> indicates that type number 19 is a 12 byte structure
57 named <code>vis</code> The <code>priv</code> field has public visibility
58 (<code>/0</code>), type int (<code>1</code>), and offset and size <code>,0,32;</code>.
59 The <code>prot</code> field has protected visibility (<code>/1</code>), type char
60 (<code>2</code>) and offset and size <code>,32,8;</code>. The <code>pub</code> field has
61 type float (<code>12</code>), and offset and size <code>,64,32;</code>.
63 <p>Protections for member functions are signified by one digit embedded in
64 the field part of the stab describing the method. The digit is 0 if
65 private, 1 if protected and 2 if public. Consider the C++ class
66 definition below:
68 <pre class="example"> class all_methods {
69 private:
70 int priv_meth(int in){return in;};
71 protected:
72 char protMeth(char in){return in;};
73 public:
74 float pubMeth(float in){return in;};
76 </pre>
78 <p>It generates the following stab. The digit in question is to the left
79 of an <code>A</code> in each case. Notice also that in this case two symbol
80 descriptors apply to the class name struct tag and struct type.
82 <pre class="display"> .stabs "class_name:sym_desc(struct tag&amp;type)type_def(21)=
83 sym_desc(struct)struct_bytes(1)
84 meth_name::type_def(22)=sym_desc(method)returning(int);
85 :args(int);protection(private)modifier(normal)virtual(no);
86 meth_name::type_def(23)=sym_desc(method)returning(char);
87 :args(char);protection(protected)modifier(normal)virtual(no);
88 meth_name::type_def(24)=sym_desc(method)returning(float);
89 :args(float);protection(public)modifier(normal)virtual(no);;",
90 N_LSYM,NIL,NIL,NIL
91 </pre>
93 <pre class="smallexample"> .stabs "all_methods:Tt21=s1priv_meth::22=##1;:i;0A.;protMeth::23=##2;:c;1A.;
94 pubMeth::24=##12;:f;2A.;;",128,0,0,0
95 </pre>
97 </body></html>