| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <html> |
| <!-- Copyright (C) 1992-2015 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: Enumerations</title> |
| |
| <meta name="description" content="STABS: Enumerations"> |
| <meta name="keywords" content="STABS: Enumerations"> |
| <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="Types.html#Types" rel="up" title="Types"> |
| <link href="Structures.html#Structures" rel="next" title="Structures"> |
| <link href="Strings.html#Strings" rel="prev" title="Strings"> |
| <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="Enumerations"></a> |
| <div class="header"> |
| <p> |
| Next: <a href="Structures.html#Structures" accesskey="n" rel="next">Structures</a>, Previous: <a href="Strings.html#Strings" accesskey="p" rel="prev">Strings</a>, Up: <a href="Types.html#Types" accesskey="u" rel="up">Types</a> [<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="Enumerations-1"></a> |
| <h3 class="section">5.7 Enumerations</h3> |
| |
| <p>Enumerations are defined with the ‘<samp>e</samp>’ type descriptor. |
| </p> |
| <p>The source line below declares an enumeration type at file scope. |
| The type definition is located after the <code>N_RBRAC</code> that marks the end of |
| the previous procedure’s block scope, and before the <code>N_FUN</code> that marks |
| the beginning of the next procedure’s block scope. Therefore it does not |
| describe a block local symbol, but a file local one. |
| </p> |
| <p>The source line: |
| </p> |
| <div class="example"> |
| <pre class="example">enum e_places {first,second=3,last}; |
| </pre></div> |
| |
| <p>generates the following stab: |
| </p> |
| <div class="example"> |
| <pre class="example">.stabs "e_places:T22=efirst:0,second:3,last:4,;",128,0,0,0 |
| </pre></div> |
| |
| <p>The symbol descriptor (‘<samp>T</samp>’) says that the stab describes a |
| structure, enumeration, or union tag. The type descriptor ‘<samp>e</samp>’, |
| following the ‘<samp>22=</samp>’ of the type definition narrows it down to an |
| enumeration type. Following the ‘<samp>e</samp>’ is a list of the elements of |
| the enumeration. The format is ‘<samp><var>name</var>:<var>value</var>,</samp>’. The |
| list of elements ends with ‘<samp>;</samp>’. The fact that <var>value</var> is |
| specified as an integer can cause problems if the value is large. GCC |
| 2.5.2 tries to output it in octal in that case with a leading zero, |
| which is probably a good thing, although GDB 4.11 supports octal only in |
| cases where decimal is perfectly good. Negative decimal values are |
| supported by both GDB and dbx. |
| </p> |
| <p>There is no standard way to specify the size of an enumeration type; it |
| is determined by the architecture (normally all enumerations types are |
| 32 bits). Type attributes can be used to specify an enumeration type of |
| another size for debuggers which support them; see <a href="String-Field.html#String-Field">String Field</a>. |
| </p> |
| <p>Enumeration types are unusual in that they define symbols for the |
| enumeration values (<code>first</code>, <code>second</code>, and <code>third</code> in the |
| above example), and even though these symbols are visible in the file as |
| a whole (rather than being in a more local namespace like structure |
| member names), they are defined in the type definition for the |
| enumeration type rather than each having their own symbol. In order to |
| be fast, GDB will only get symbols from such types (in its initial scan |
| of the stabs) if the type is the first thing defined after a ‘<samp>T</samp>’ or |
| ‘<samp>t</samp>’ symbol descriptor (the above example fulfills this |
| requirement). If the type does not have a name, the compiler should |
| emit it in a nameless stab (see <a href="String-Field.html#String-Field">String Field</a>); GCC does this. |
| </p> |
| <hr> |
| <div class="header"> |
| <p> |
| Next: <a href="Structures.html#Structures" accesskey="n" rel="next">Structures</a>, Previous: <a href="Strings.html#Strings" accesskey="p" rel="prev">Strings</a>, Up: <a href="Types.html#Types" accesskey="u" rel="up">Types</a> [<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> |