Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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