toolchain/gcc-linaro-6.3.1-2017.02-x8.../share/doc/gdb/stabs/Simple-Classes.html

175 lines
8.5 KiB
HTML

<!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: Simple Classes</title>
<meta name="description" content="STABS: Simple Classes">
<meta name="keywords" content="STABS: Simple Classes">
<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="Class-Instance.html#Class-Instance" rel="next" title="Class Instance">
<link href="Basic-Cplusplus-Types.html#Basic-Cplusplus-Types" rel="prev" title="Basic Cplusplus Types">
<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="Simple-Classes"></a>
<div class="header">
<p>
Next: <a href="Class-Instance.html#Class-Instance" accesskey="n" rel="next">Class Instance</a>, Previous: <a href="Basic-Cplusplus-Types.html#Basic-Cplusplus-Types" accesskey="p" rel="prev">Basic Cplusplus Types</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="Simple-Class-Definition"></a>
<h3 class="section">8.4 Simple Class Definition</h3>
<p>The stabs describing C<tt>++</tt> language features are an extension of the
stabs describing C. Stabs representing C<tt>++</tt> class types elaborate
extensively on the stab format used to describe structure types in C.
Stabs representing class type variables look just like stabs
representing C language variables.
</p>
<p>Consider the following very simple class definition.
</p>
<div class="example">
<pre class="example">class baseA {
public:
int Adat;
int Ameth(int in, char other);
};
</pre></div>
<p>The class <code>baseA</code> is represented by two stabs. The first stab describes
the class as a structure type. The second stab describes a structure
tag of the class type. Both stabs are of stab type <code>N_LSYM</code>. Since the
stab is not located between an <code>N_FUN</code> and an <code>N_LBRAC</code> stab this indicates
that the class is defined at file scope. If it were, then the <code>N_LSYM</code>
would signify a local variable.
</p>
<p>A stab describing a C<tt>++</tt> class type is similar in format to a stab
describing a C struct, with each class member shown as a field in the
structure. The part of the struct format describing fields is
expanded to include extra information relevant to C<tt>++</tt> class members.
In addition, if the class has multiple base classes or virtual
functions the struct format outside of the field parts is also
augmented.
</p>
<p>In this simple example the field part of the C<tt>++</tt> class stab
representing member data looks just like the field part of a C struct
stab. The section on protections describes how its format is
sometimes extended for member data.
</p>
<p>The field part of a C<tt>++</tt> class stab representing a member function
differs substantially from the field part of a C struct stab. It
still begins with &lsquo;<samp>name:</samp>&rsquo; but then goes on to define a new type number
for the member function, describe its return type, its argument types,
its protection level, any qualifiers applied to the method definition,
and whether the method is virtual or not. If the method is virtual
then the method description goes on to give the vtable index of the
method, and the type number of the first base class defining the
method.
</p>
<p>When the field name is a method name it is followed by two colons rather
than one. This is followed by a new type definition for the method.
This is a number followed by an equal sign and the type of the method.
Normally this will be a type declared using the &lsquo;<samp>#</samp>&rsquo; type
descriptor; see <a href="Method-Type-Descriptor.html#Method-Type-Descriptor">Method Type Descriptor</a>; static member functions
are declared using the &lsquo;<samp>f</samp>&rsquo; type descriptor instead; see
<a href="Function-Types.html#Function-Types">Function Types</a>.
</p>
<p>The format of an overloaded operator method name differs from that of
other methods. It is &lsquo;<samp>op$::<var>operator-name</var>.</samp>&rsquo; where
<var>operator-name</var> is the operator name such as &lsquo;<samp>+</samp>&rsquo; or &lsquo;<samp>+=</samp>&rsquo;.
The name ends with a period, and any characters except the period can
occur in the <var>operator-name</var> string.
</p>
<p>The next part of the method description represents the arguments to the
method, preceded by a colon and ending with a semi-colon. The types of
the arguments are expressed in the same way argument types are expressed
in C<tt>++</tt> name mangling. In this example an <code>int</code> and a <code>char</code>
map to &lsquo;<samp>ic</samp>&rsquo;.
</p>
<p>This is followed by a number, a letter, and an asterisk or period,
followed by another semicolon. The number indicates the protections
that apply to the member function. Here the 2 means public. The
letter encodes any qualifier applied to the method definition. In
this case, &lsquo;<samp>A</samp>&rsquo; means that it is a normal function definition. The dot
shows that the method is not virtual. The sections that follow
elaborate further on these fields and describe the additional
information present for virtual methods.
</p>
<div class="display">
<pre class="display">.stabs &quot;class_name:sym_desc(type)type_def(20)=type_desc(struct)struct_bytes(4)
field_name(Adat):type(int),bit_offset(0),field_bits(32);
method_name(Ameth)::type_def(21)=type_desc(method)return_type(int);
:arg_types(int char);
protection(public)qualifier(normal)virtual(no);;&quot;
N_LSYM,NIL,NIL,NIL
</pre></div>
<div class="smallexample">
<pre class="smallexample">.stabs &quot;baseA:t20=s4Adat:1,0,32;Ameth::21=##1;:ic;2A.;;&quot;,128,0,0,0
.stabs &quot;class_name:sym_desc(struct tag)&quot;,N_LSYM,NIL,NIL,NIL
.stabs &quot;baseA:T20&quot;,128,0,0,0
</pre></div>
<hr>
<div class="header">
<p>
Next: <a href="Class-Instance.html#Class-Instance" accesskey="n" rel="next">Class Instance</a>, Previous: <a href="Basic-Cplusplus-Types.html#Basic-Cplusplus-Types" accesskey="p" rel="prev">Basic Cplusplus Types</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>