Protections.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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: Protections</title>
  15. <meta name="description" content="STABS: Protections">
  16. <meta name="keywords" content="STABS: Protections">
  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-Modifiers.html#Method-Modifiers" rel="next" title="Method Modifiers">
  26. <link href="Member-Type-Descriptor.html#Member-Type-Descriptor" rel="prev" title="Member Type Descriptor">
  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="Protections"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Method-Modifiers.html#Method-Modifiers" accesskey="n" rel="next">Method Modifiers</a>, Previous: <a href="Member-Type-Descriptor.html#Member-Type-Descriptor" accesskey="p" rel="prev">Member Type Descriptor</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="Protections-1"></a>
  64. <h3 class="section">8.9 Protections</h3>
  65. <p>In the simple class definition shown above all member data and
  66. functions were publicly accessible. The example that follows
  67. contrasts public, protected and privately accessible fields and shows
  68. how these protections are encoded in C<tt>++</tt> stabs.
  69. </p>
  70. <p>If the character following the &lsquo;<samp><var>field-name</var>:</samp>&rsquo; part of the
  71. string is &lsquo;<samp>/</samp>&rsquo;, then the next character is the visibility. &lsquo;<samp>0</samp>&rsquo;
  72. means private, &lsquo;<samp>1</samp>&rsquo; means protected, and &lsquo;<samp>2</samp>&rsquo; means public.
  73. Debuggers should ignore visibility characters they do not recognize, and
  74. assume a reasonable default (such as public) (GDB 4.11 does not, but
  75. this should be fixed in the next GDB release). If no visibility is
  76. specified the field is public. The visibility &lsquo;<samp>9</samp>&rsquo; means that the
  77. field has been optimized out and is public (there is no way to specify
  78. an optimized out field with a private or protected visibility).
  79. Visibility &lsquo;<samp>9</samp>&rsquo; is not supported by GDB 4.11; this should be fixed
  80. in the next GDB release.
  81. </p>
  82. <p>The following C<tt>++</tt> source:
  83. </p>
  84. <div class="example">
  85. <pre class="example">class vis {
  86. private:
  87. int priv;
  88. protected:
  89. char prot;
  90. public:
  91. float pub;
  92. };
  93. </pre></div>
  94. <p>generates the following stab:
  95. </p>
  96. <div class="example">
  97. <pre class="example"># <span class="roman">128 is N_LSYM</span>
  98. .stabs &quot;vis:T19=s12priv:/01,0,32;prot:/12,32,8;pub:12,64,32;;&quot;,128,0,0,0
  99. </pre></div>
  100. <p>&lsquo;<samp>vis:T19=s12</samp>&rsquo; indicates that type number 19 is a 12 byte structure
  101. named <code>vis</code> The <code>priv</code> field has public visibility
  102. (&lsquo;<samp>/0</samp>&rsquo;), type int (&lsquo;<samp>1</samp>&rsquo;), and offset and size &lsquo;<samp>,0,32;</samp>&rsquo;.
  103. The <code>prot</code> field has protected visibility (&lsquo;<samp>/1</samp>&rsquo;), type char
  104. (&lsquo;<samp>2</samp>&rsquo;) and offset and size &lsquo;<samp>,32,8;</samp>&rsquo;. The <code>pub</code> field has
  105. type float (&lsquo;<samp>12</samp>&rsquo;), and offset and size &lsquo;<samp>,64,32;</samp>&rsquo;.
  106. </p>
  107. <p>Protections for member functions are signified by one digit embedded in
  108. the field part of the stab describing the method. The digit is 0 if
  109. private, 1 if protected and 2 if public. Consider the C<tt>++</tt> class
  110. definition below:
  111. </p>
  112. <div class="example">
  113. <pre class="example">class all_methods {
  114. private:
  115. int priv_meth(int in){return in;};
  116. protected:
  117. char protMeth(char in){return in;};
  118. public:
  119. float pubMeth(float in){return in;};
  120. };
  121. </pre></div>
  122. <p>It generates the following stab. The digit in question is to the left
  123. of an &lsquo;<samp>A</samp>&rsquo; in each case. Notice also that in this case two symbol
  124. descriptors apply to the class name struct tag and struct type.
  125. </p>
  126. <div class="display">
  127. <pre class="display">.stabs &quot;class_name:sym_desc(struct tag&amp;type)type_def(21)=
  128. sym_desc(struct)struct_bytes(1)
  129. meth_name::type_def(22)=sym_desc(method)returning(int);
  130. :args(int);protection(private)modifier(normal)virtual(no);
  131. meth_name::type_def(23)=sym_desc(method)returning(char);
  132. :args(char);protection(protected)modifier(normal)virtual(no);
  133. meth_name::type_def(24)=sym_desc(method)returning(float);
  134. :args(float);protection(public)modifier(normal)virtual(no);;&quot;,
  135. N_LSYM,NIL,NIL,NIL
  136. </pre></div>
  137. <div class="smallexample">
  138. <pre class="smallexample">.stabs &quot;all_methods:Tt21=s1priv_meth::22=##1;:i;0A.;protMeth::23=##2;:c;1A.;
  139. pubMeth::24=##12;:f;2A.;;&quot;,128,0,0,0
  140. </pre></div>
  141. <hr>
  142. <div class="header">
  143. <p>
  144. Next: <a href="Method-Modifiers.html#Method-Modifiers" accesskey="n" rel="next">Method Modifiers</a>, Previous: <a href="Member-Type-Descriptor.html#Member-Type-Descriptor" accesskey="p" rel="prev">Member Type Descriptor</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>
  145. </div>
  146. </body>
  147. </html>