the section group
is discarded.
-
\end{enumerate}
The \addtoindex{C++} source
\addtoindexx{DWARF duplicate elimination!C++ example}
in
-Section \refersec{app:duplicateeliminationexample1csource}
+Figure \refersec{fig:duplicateeliminationexample1csource}
is used to illustrate the DWARF
representation intended to allow duplicate elimination.
-\paragraph{Duplicate elimination example 1: C++ Source}
-\label{app:duplicateeliminationexample1csource}
-
-File wa.h
-
-\begin{lstlisting}
+\begin{figure}[t]
+\textbf{File wa.h:}
+\begin{lstlisting}[numbers=none]
struct A {
int i;
};
\end{lstlisting}
-
-File wa.C
-
-\begin{lstlisting}
+\textbf{File wa.c:}
+\begin{lstlisting}[numbers=none]
#include "wa.h";
int
f(A &a)
return a.i + 2;
}
\end{lstlisting}
+\caption{Duplicate elimination example \#1: C++ Source}
+\label{fig:duplicateeliminationexample1csource}
+\end{figure}
-
-section \refersec{app:duplicateeliminationexample1dwarfsectiongroup}
+Figure \refersec{fig:duplicateeliminationexample1dwarfsectiongroup}
shows the \addtoindex{section group} corresponding to the included file
wa.h.
-
-\paragraph{Duplicate elimination example 1: DWARF section group}
-
-\label{app:duplicateeliminationexample1dwarfsectiongroup}
+\begin{figure}
+\begin{dwflisting}
% FIXME: the DWFORMrefn could use rethinking
\begin{alltt}
==== Section group name:
! compact form \livetarg{chap:DWFORMrefn}{DW\-\_FORM\-\_refn}
! for n 1,2,4, or 8 can be used)
\end{alltt}
+\end{dwflisting}
+\caption{Duplicate elimination example 1: DWARF section group}
+\label{fig:duplicateeliminationexample1dwarfsectiongroup}
+\end{figure}
-
-Figure \refersec{app:duplicateeliminationexample1primarycompilationunit}
+Figure \refersec{fig:duplicateeliminationexample1primarycompilationunit}
shows the ``normal'' DWARF sections, which are not part of
any \addtoindex{section group},
and how they make use of the information
in the \addtoindex{section group} shown above.
-\paragraph{Duplicate elimination example 1: primary compilation unit}
-\label{app:duplicateeliminationexample1primarycompilationunit}
+\begin{figure}
+\begin{dwflisting}
\begin{alltt}
== section .text
[generated code for function f]
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to .L1)
...
\end{alltt}
+\end{dwflisting}
+\caption{Duplicate elimination example \#1: primary compilation unit}
+\label{fig:duplicateeliminationexample1primarycompilationunit}
+\end{figure}
This example uses \livelink{chap:DWTAGcompileunit}{DW\-\_TAG\-\_compile\-\_unit} for the \addtoindex{section group},
implying that the contents of the compilation unit are
For a \addtoindex{Fortran}
\addtoindexx{DWARF duplicate elimination!Fortran example}
example, consider
-Figure \refersec{app:duplicateeliminationexample2fortransource}.
-
-
-\paragraph{Duplicate elimination example 2: Fortran source}
-\label{app:duplicateeliminationexample2fortransource}
+Figure \refersec{fig:duplicateeliminationexample2fortransource}.
-File CommonStuff.fh
+\begin{figure}
+\textbf{File CommonStuff.fh}
\addtoindexx{Fortran}
-
-\begin{lstlisting}
+\begin{lstlisting}[numbers=none]
IMPLICIT INTEGER(A-Z)
COMMON /Common1/ C(100)
PARAMETER(SEVEN = 7)
\end{lstlisting}
-File Func.f
-\begin{lstlisting}
-
+\textbf{File Func.f}
+\begin{lstlisting}[numbers=none]
FUNCTION FOO (N)
INCLUDE 'CommonStuff.fh'
FOO = C(N + SEVEN)
RETURN
END
\end{lstlisting}
+\caption{Duplicate elimination example \#2: Fortran source}
+\label{fig:duplicateeliminationexample2fortransource}
+\end{figure}
-Section \refersec{app:duplicateeliminationexample2dwarfsectiongroup}
+Figure \refersec{fig:duplicateeliminationexample2dwarfsectiongroup}
shows the \addtoindex{section group}
corresponding to the included file
\addtoindexx{Fortran example}
CommonStuff.fh.
-\paragraph{Duplicate elimination example 2: DWARF section group}
-\label{app:duplicateeliminationexample2dwarfsectiongroup}
-
+\begin{figure}
+\begin{dwflisting}
\begin{alltt}
==== Section group name:
! base type INTEGER
\livelink{chap:DWATconstvalue}{DW\-\_AT\-\_const\-\_value}(constant 7)
\end{alltt}
+\end{dwflisting}
+\caption{Duplicate elimination example 2: DWARF section group}
+\label{fig:duplicateeliminationexample2dwarfsectiongroup}
+\end{figure}
-Section \refersec{app:duplicateeliminationexample2primaryunit}
+Figure \refersec{fig:duplicateeliminationexample2primaryunit}
shows the sections for the primary compilation unit.
-
-
-\paragraph{Duplicate elimination example 2: primary unit }
-\label{app:duplicateeliminationexample2primaryunit}
+\begin{figure}
+\begin{dwflisting}
\begin{alltt}
== section .text
[code for function Foo]
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to DW.f90.F90\$main.f.2)
! base type INTEGER
\end{alltt}
+\end{dwflisting}
+\caption{Duplicate elimination example \#2: primary unit}
+\label{fig:duplicateeliminationexample2primaryunit}
+\end{figure}
A companion main program is shown in
-Section \refersec{app:duplicateeliminationexample2companionsource}
+Figure \refersec{fig:duplicateeliminationexample2companionsource}
-\paragraph{Duplicate elimination example 2: companion source }
-\label{app:duplicateeliminationexample2companionsource}
-
-File Main.f
-
-\begin{lstlisting}
+\begin{figure}
+\textbf{File Main.f:}
+\begin{lstlisting}[numbers=none]
INCLUDE 'CommonStuff.fh'
C(50) = 8
PRINT *, 'Result = ', FOO(50 - SEVEN)
END
\end{lstlisting}
+\caption{Duplicate elimination example \#2: companion source }
+\label{fig:duplicateeliminationexample2companionsource}
+\end{figure}
That main program results in an object file that
contained a duplicate of the \addtoindex{section group} named
corresponding to the
included file as well as the remainder of the main subprogram
as shown in
-Section \refersec{app:duplicateeliminationexample2companiondwarf}.
-
-\paragraph{Duplicate elimination example 2: companion DWARF }
-\label{app:duplicateeliminationexample2companiondwarf}
+Figure \refersec{fig:duplicateeliminationexample2companiondwarf}.
+\begin{figure}
+\begin{dwflisting}
\begin{alltt}
== section \addtoindex{.debug\_info}
\livelink{chap:DWTAGcompileunit}{DW\-\_TAG\-\_compile\-\_unit}
DW.myf90.CommonStuff.fh.654321.3)
...
\end{alltt}
-
+\end{dwflisting}
+\caption{Duplicate elimination example 2: companion DWARF }
+\label{fig:duplicateeliminationexample2companiondwarf}
+\end{figure}
This example uses \livelink{chap:DWTAGpartialunit}{DW\-\_TAG\-\_partial\-\_unit} for the \addtoindex{section group}
because the included declarations are not independently
valid as a \addtoindex{C} example. However, it is prudent to include
a \livelink{chap:DWTAGimportedunit}{DW\-\_TAG\-\_imported\-\_unit}
in the primary unit
-(see Figure \refersec{app:duplicateeliminationexample1primarycompilationunit})
+(see Figure \refersec{fig:duplicateeliminationexample1primarycompilationunit})
with an \livelink{chap:DWATimport}{DW\-\_AT\-\_import} attribute that refers to the proper unit
in the \addtoindex{section group}.
\addtoindexx{type signature!example computation}
consider a \addtoindex{C++} header file
containing the type definitions shown
-in Section \refersec{app:typesignatureexamplescsource}.
+in Figure \refersec{fig:typesignatureexamplescsource}.
-\subsubsection{ Type signature examples: C++ source}
-\label{app:typesignatureexamplescsource}
+\begin{figure}
\begin{lstlisting}
namespace N {
- struct B;
-
- struct C {
- int x;
- int y;
- };
-
- class A {
- public:
- A(int v);
- int v();
- private:
- int v_;
- struct A *next;
- struct B *bp;
- struct C c;
- };
-
- }
+ struct B;
+
+ struct C {
+ int x;
+ int y;
+ };
+
+ class A {
+ public:
+ A(int v);
+ int v();
+ private:
+ int v_;
+ struct A *next;
+ struct B *bp;
+ struct C c;
+ };
+}
\end{lstlisting}
+\caption{Type signature examples: C++ source}
+\label{fig:typesignatureexamplescsource}
+\end{figure}
Next, consider one possible representation of the DWARF
information that describes the type “struct C” as shown
in
-\refersec{app:typesignaturecomputation1dwarfrepresentation}:
+\refersec{fig:typesignaturecomputation1dwarfrepresentation}:
-\subsubsection{Type signature computation 1: DWARF representation}
-\label{app:typesignaturecomputation1dwarfrepresentation}
+\begin{figure}
+\begin{dwflisting}
% We keep the : (colon) away from the attribute so tokenizing in the python tools
% does not result in adding : into the attribute name.
\begin{alltt}
\livelink{chap:DWATencoding}{DW\-\_AT\-\_encoding} : \livelink{chap:DWATEsigned}{DW\-\_ATE\-\_signed}
\livelink{chap:DWATname}{DW\-\_AT\-\_name} : "int"
\end{alltt}
+\end{dwflisting}
+\caption{Type signature computation \#1: DWARF representation}
+\label{fig:typesignaturecomputation1dwarfrepresentation}
+\end{figure}
In computing a signature for the type N::C, flatten the type
\addtoindexx{type signature}
outlined in
Section \refersec{datarep:typesignaturecomputation}.
The result is shown in
-Section \refersec{app:typesignaturecomputation1flattenedbytestream}.
-
-\subsubsection{Type signature computation 1: flattened byte stream}
-\label{app:typesignaturecomputation1flattenedbytestream}
+Figure \refersec{fig:typesignaturecomputation1flattenedbytestream}.
+\begin{figure}
+\begin{dwflisting}
\begin{alltt}
// Step 2: 'C' \livelink{chap:DWTAGnamespace}{DW\-\_TAG\-\_namespace} "N"
0x43 0x39 0x4e 0x00
// Step 7: End of \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type} "C"
0x00
\end{alltt}
+\end{dwflisting}
+\caption{Type signature computation \#1: flattened byte stream}
+\label{fig:typesignaturecomputation1flattenedbytestream}
+\end{figure}
Running an \addtoindex{MD5 hash} over this byte stream, and taking the
low\dash order 64 bits, yields the final signature:
Next, consider a representation of the DWARF information that
describes the type ``class A'' as shown in
-Section \refersec{app:typesignaturecomputation2dwarfrepresentation}.
-
-
-\subsubsection{Type signature computation 2: DWARF representation}
-\label{app:typesignaturecomputation2dwarfrepresentation}
+Figure \refersec{fig:typesignaturecomputation2dwarfrepresentation}.
+\begin{figure}
+\figurepart{1}{2}
+\begin{dwflisting}
\begin{alltt}
\livelink{chap:DWTAGtypeunit}{DW\-\_TAG\-\_type\-\_unit}
\livelink{chap:DWATlanguage}{DW\-\_AT\-\_language} : \livelink{chap:DWLANGCplusplus}{DW\-\_LANG\-\_C\-\_plus\-\_plus} (4)
\livelink{chap:DWTAGnamespace}{DW\-\_TAG\-\_namespace}
- \livelink{chap:DWATname}{DW\-\_AT\-\_name} : "N"
+ \livelink{chap:DWATname}{DW\-\_AT\-\_name} : "N"
L1:
\livelink{chap:DWTAGclasstype}{DW\-\_TAG\-\_class\-\_type}
\livelink{chap:DWATname}{DW\-\_AT\-\_name} : "A"
\livelink{chap:DWATtype}{DW\-\_AT\-\_type} : 0xd28081e8 dcf5070a (signature for struct C)
\livelink{chap:DWATdatamemberlocation}{DW\-\_AT\-\_data\-\_member\-\_location} : 12
\livelink{chap:DWATaccessibility}{DW\-\_AT\-\_accessibility} : \livelink{chap:DWACCESSprivate}{DW\-\_ACCESS\-\_private}
- \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
+\end{alltt}
+\end{dwflisting}
+\caption{Type signature computation \#2: DWARF representation}
+\label{fig:typesignaturecomputation2dwarfrepresentation}
+\end{figure}
+
+\begin{figure}
+\figurepart{2}{2}
+\begin{dwflisting}
+\begin{alltt}
+ \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
\livelink{chap:DWATexternal}{DW\-\_AT\-\_external} : 1
\livelink{chap:DWATname}{DW\-\_AT\-\_name} : "A"
\livelink{chap:DWATdeclfile}{DW\-\_AT\-\_decl\-\_file} : 1
\livelink{chap:DWATname}{DW\-\_AT\-\_name} : "B"
\livelink{chap:DWATdeclaration}{DW\-\_AT\-\_declaration} : 1
\end{alltt}
+\end{dwflisting}
+\begin{center}
+Figure~\ref{fig:typesignaturecomputation2dwarfrepresentation} Type signature computation \#2: DWARF representation \textit{(concluded)}
+\end{center}
+\end{figure}
In this example, the structure types N::A and N::C have each
been placed in separate
outlined in
Section \refersec{datarep:typesignaturecomputation}.
The result is shown in
-Section \refersec{app:typesignatureexample2flattenedbytestream}.
+Figure \refersec{fig:typesignatureexample2flattenedbytestream}.
-\subsubsection{Type signature example 2: flattenedbytestream}
-\label{app:typesignatureexample2flattenedbytestream}
+\begin{figure}
+\figurepart{1}{3}
+\begin{dwflisting}
% DWARF4 had a \livelink{chap:DWATnamespace}{DW_AT_namespace} below,
% but this error is fixed here to be \livelink{chap:DWTAGnamespace}{DW_TAG_namespace}.
\begin{alltt}
0x41 0x32 0x0d 0x03
// Step 4: 'A' \livelink{chap:DWATdatamemberlocation}{DW\-\_AT\-\_data\-\_member\-\_location} \livelink{chap:DWFORMsdata}{DW\-\_FORM\-\_sdata} 4
0x41 0x38 0x0d 0x04
+\end{alltt}
+\end{dwflisting}
+\caption{Type signature example \#2: flattened byte stream}
+\label{fig:typesignatureexample2flattenedbytestream}
+\end{figure}
+
+\begin{figure}
+\figurepart{2}{3}
+\begin{dwflisting}
+\begin{alltt}
// Step 6: 'T' \livelink{chap:DWATtype}{DW\-\_AT\-\_type} (type \#3)
0x54 0x49
// Step 3: 'D' \livelink{chap:DWTAGpointertype}{DW\-\_TAG\-\_pointer\-\_type}
0x41 0x03 0x08 0x63 0x00
// Step 4: 'A' \livelink{chap:DWATaccessibility}{DW\-\_AT\-\_accessibility} \livelink{chap:DWFORMsdata}{DW\-\_FORM\-\_sdata} \livelink{chap:DWACCESSprivate}{DW\-\_ACCESS\-\_private}
0x41 0x32 0x0d 0x03
+\end{alltt}
+\end{dwflisting}
+\begin{center}
+Figure~\ref{fig:typesignatureexample2flattenedbytestream} Type signature example \#2: flattened byte stream \textit{(continued)}
+\end{center}
+\end{figure}
+
+\begin{figure}
+\figurepart{3}{3}
+\begin{dwflisting}
+\begin{alltt}
// Step 4: 'A' \livelink{chap:DWATdatamemberlocation}{DW\-\_AT\-\_data\-\_member\-\_location} \livelink{chap:DWFORMsdata}{DW\-\_FORM\-\_sdata} 12
0x41 0x38 0x0d 0x0c
// Step 6: 'T' \livelink{chap:DWATtype}{DW\-\_AT\-\_type} (type \#5)
// Step 7: End of \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type} "A"
0x00
\end{alltt}
+\end{dwflisting}
+\begin{center}
+Figure~\ref{fig:typesignatureexample2flattenedbytestream} Type signature example \#2: flattened byte stream \textit{(concluded)}
+\end{center}
+\end{figure}
Running an \addtoindex{MD5 hash} over this byte stream, and taking the
low-order 64 bits, yields the final signature: 0xd6d160f5
A source file that includes this header file may declare a
variable of type N::A, and its DWARF information may look
-that shown in
-Section \refersec{app:typesignatureexampleusage}.
-
-
-\subsubsection{Type signature example usage}
-\label{app:typesignatureexampleusage}
+like that shown in
+Figure \refersec{fig:typesignatureexampleusage}.
+\begin{figure}
+\begin{dwflisting}
\begin{alltt}
\livelink{chap:DWTAGcompileunit}{DW\-\_TAG\-\_compile\-\_unit}
...
\livelink{chap:DWATlocation}{DW\-\_AT\-\_location} : ...
...
\end{alltt}
+\end{dwflisting}
+\caption{Type signature example usage}
+\label{fig:typesignatureexampleusage}
+\end{figure}
\subsection{Type Signature Computation Grammar}
\label{app:typesignaturecomputationgrammar}
: 'R' at-code back-ref // Back-reference
// to visited type
: 'T' at-code signature // Recursive type
+
children // Step 7
: child children
: '0'
child
: 'S' tag-code string
: signature
+
tag-code
: <ULEB128>
+
at-code
: <ULEB128>
+
form-encoded-value
: \livelink{chap:DWFORMsdata}{DW\-\_FORM\-\_sdata} value \addtoindexx{constant class}
: \livelink{chap:DWFORMflag}{DW\-\_FORM\-\_flag} value \addtoindexx{flag class}
: 'x0c'
\livelink{chap:DWFORMsdata}{DW\-\_FORM\-\_sdata} \addtoindexx{constant class}
: 'x0d'
+
value
: <SLEB128>
+
\nolink{block}
: <ULEB128> <fixed-length-block>
// The ULEB128 gives the length of the \nolink{block}
back-ref
: <ULEB128>
+
string
: <null-terminated-string>
+
empty
:
\end{alltt}
The figure corresponds to the following two trivial source files:
File myfile.c
-\begin{lstlisting}
+\begin{lstlisting}[numbers=none]
typedef char* POINTER;
\end{lstlisting}
File myfile2.c
-\begin{lstlisting}
+\begin{lstlisting}[numbers=none]
typedef char* strp;
\end{lstlisting}
The \addtoindex{Fortran 90} derived type array\_ptr can now be redescribed
in C\dash like terms that expose some of the representation as in
-\begin{lstlisting}
+\begin{lstlisting}[numbers=none]
struct array_ptr {
float myvar;
desc<1> ap;
\end{lstlisting}
Similarly for variable arrays:
-\begin{lstlisting}
+\begin{lstlisting}[numbers=none]
desc<1> arrays;
\end{lstlisting}
(Recall that \texttt{desc\textless 1\textgreater}
indicates the 1\dash dimensional version of \texttt{desc}.)
+\newpage
Finally, the following notation is useful:
-
\begin{enumerate}[1.]
\item sizeof(type): size in bytes of entities of the given type
-
\item offset(type, comp): offset in bytes of the comp component
within an entity of the given type
\end{enumerate}
-
The DWARF description is shown
\addtoindexx{Fortran 90}
-in
-Section \refersec{app:fortran90exampledwarfdescription}.
-
-\subsection{Fortran 90 example: DWARF description}
-\label{app:fortran90exampledwarfdescription}
+in Figure \refersec{fig:fortran90exampledwarfdescription}.
+\begin{figure}[b]
+\begin{dwflisting}
\begin{alltt}
! Description for type of 'ap'
-
+!
1\$: \livelink{chap:DWTAGarraytype}{DW\-\_TAG\-\_array\-\_type}
! No name, default (Fortran) ordering, default stride
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to REAL)
\livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<n> ! where n == offset(base)
\livelink{chap:DWOPplus}{DW\-\_OP\-\_plus}
\livelink{chap:DWOPderef}{DW\-\_OP\-\_deref}) ! Type of index of array 'ap'
-2\$: \livelink{chap:DWTAGsubrangetype}{DW\-\_TAG\-\_subrange\-\_type}
+\end{alltt}
+\end{dwflisting}
+\caption{Fortran 90 example: DWARF description}
+\label{fig:fortran90exampledwarfdescription}
+\end{figure}
+
+\begin{figure}
+\begin{dwflisting}
+\begin{alltt}
+2\$: \livelink{chap:DWTAGsubrangetype}{DW\-\_TAG\-\_subrange\-\_type}
! No name, default stride
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to INTEGER)
\livelink{chap:DWATlowerbound}{DW\-\_AT\-\_lower\-\_bound}(expression=
- \livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address}
+ \livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address}
\livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<n> ! where n ==
! offset(desc, dims) +
! offset(dims\_str, lower\_bound)
\livelink{chap:DWOPderef}{DW\-\_OP\-\_deref})
! Note: for the m'th dimension, the second operator becomes
! \livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<x> where
- ! x == offset(desc, dims) +
- ! (m-1)*sizeof(dims\_str) +
- ! offset(dims\_str, [lower|upper]\_bound)
- ! That is, the expression does not get longer for each
- ! successive dimension (other than to express the larger
- ! offsets involved).
+ ! x == offset(desc, dims) +
+ ! (m-1)*sizeof(dims\_str) +
+ ! offset(dims\_str, [lower|upper]\_bound)
+ ! That is, the expression does not get longer for each successive
+ ! dimension (other than to express the larger offsets involved).
3\$: \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type}
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("array\_ptr")
\livelink{chap:DWATbytesize}{DW\-\_AT\-\_byte\-\_size}(constant sizeof(REAL) + sizeof(desc<1>))
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("ap");
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
\livelink{chap:DWATdatamemberlocation}{DW\-\_AT\-\_data\-\_member\-\_location}(constant sizeof(REAL))
-
6\$: \livelink{chap:DWTAGarraytype}{DW\-\_TAG\-\_array\-\_type}
! No name, default (Fortran) ordering, default stride
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 3\$)
\livelink{chap:DWATallocated}{DW\-\_AT\-\_allocated}(expression=
- ! Test 'ptr\_alloc' \nolink{flag}
+ ! Test 'ptr\_alloc' \nolink{flag}
\livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address}
\livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<n> ! where n == offset(ptr\_alloc)
\livelink{chap:DWOPplus}{DW\-\_OP\-\_plus}
\livelink{chap:DWOPderef}{DW\-\_OP\-\_deref}
\livetarg{chap:DWOPlit2}{DW\-\_OP\-\_lit2}
- ! mask for 'ptr\_alloc' \nolink{flag}
+ ! Mask for 'ptr\_alloc' \nolink{flag}
\livelink{chap:DWOPand}{DW\-\_OP\-\_and})
+\end{alltt}
+\end{dwflisting}
+\begin{center}
+Figure~\ref{fig:fortran90exampledwarfdescription} Fortran 90 example: DWARF description \textit{(continued)}
+\end{center}
+\end{figure}
+
+\begin{figure}
+\begin{dwflisting}
+\begin{alltt}
\livelink{chap:DWATdatalocation}{DW\-\_AT\-\_data\-\_location}(expression= ! Get raw data address
\livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address}
\livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<n> ! where n = offset(base)
\livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(expression=
...as appropriate...) ! Assume static allocation
\end{alltt}
+\end{dwflisting}
+\begin{center}
-\subsection{Fortran 90 example continued: DWARF description}
-\label{app:fortran90examplecontinueddwarfdescription}
+Figure~\ref{fig:fortran90exampledwarfdescription} Fortran 90 example: DWARF description \textit{(concluded)}
+\end{center}
+\end{figure}
Suppose
\addtoindexx{Fortran 90 example}
of the do loop. Suppose further that the user enters the
following debug command:
-\begin{lstlisting}
+\begin{lstlisting}[numbers=none]
debug> print arrays(5)%ap(2)
\end{lstlisting}
of an allocatable array; but because there is a common
underlying representation, the mechanics are the same. There
could be completely different descriptor arrangements and the
-mechanics would still be the same — only the stack machines
+mechanics would still be the same---only the stack machines
would be different.
of other components of the record.)
The DWARF description is shown in
-Section \refersec{app:adaexampledwarfdescription}
+Figure \refersec{fig:adaexampledwarfdescription}.
Interesting aspects about this example are:
of this example and therefore not shown.
\end{enumerate}
-\subsubsection{Ada example: DWARF description}
-\label{app:adaexampledwarfdescription}
-
+\begin{figure}[p]
+\begin{dwflisting}
\begin{alltt}
11\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("M")
. . .
26\$: \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type}
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("REC2")
-27\$: \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
+27\$: \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("N")
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to subtype TEENY at 21\$)
\livelink{chap:DWATdatamemberlocation}{DW\-\_AT\-\_data\-\_member\-\_location}(constant 0)
! No name, default (\addtoindex{Ada}) order, default stride
! Default data location
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to INTEGER)
-29\$: \livelink{chap:DWTAGsubrangetype}{DW\-\_TAG\-\_subrange\-\_type}
+29\$: \livelink{chap:DWTAGsubrangetype}{DW\-\_TAG\-\_subrange\-\_type}
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to subrange TEENY at 21\$)
\livelink{chap:DWATlowerbound}{DW\-\_AT\-\_lower\-\_bound}(constant 1)
\livelink{chap:DWATupperbound}{DW\-\_AT\-\_upper\-\_bound}(reference to member N at 27\$)
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("OBJ2B")
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to REC2 at 26\$)
\livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...as appropriate...)
-
\end{alltt}
+\end{dwflisting}
+\caption{Ada 90 example: DWARF description}
+\label{fig:adaexampledwarfdescription}
+\end{figure}
\subsection{Pascal Example}
\label{app:pascalexample}
\begin{figure}[here]
\begin{lstlisting}
-TYPE T : PACKED RECORD ! bit size is 2
- F5 : BOOLEAN; ! bit offset is 0
- F6 : BOOLEAN; ! bit offset is 1
+TYPE T : PACKED RECORD ! bit size is 2
+ F5 : BOOLEAN; ! bit offset is 0
+ F6 : BOOLEAN; ! bit offset is 1
END;
VAR V : PACKED RECORD
- F1 : BOOLEAN; ! bit offset is 0
- F2 : PACKED RECORD ! bit offset is 1
- F3 : INTEGER; ! bit offset is 0 in F2, 1 in V
+ F1 : BOOLEAN; ! bit offset is 0
+ F2 : PACKED RECORD ! bit offset is 1
+ F3 : INTEGER; ! bit offset is 0 in F2, 1 in V
END;
F4 : PACKED ARRAY [0..1] OF T; ! bit offset is 33
- F7 : T; ! bit offset is 37
+ F7 : T; ! bit offset is 37
END;
\end{lstlisting}
\caption{Packed record example: source fragment}
\end{figure}
The DWARF representation in
-Section \refersec{app:packedrecordexampledwarfdescription}
-is
-appropriate.
+Figure \refersec{fig:packedrecordexampledwarfdescription}
+is appropriate.
\livelink{chap:DWTAGpackedtype}{DW\-\_TAG\-\_packed\-\_type} entries could be added to
better represent the source, but these do not otherwise affect
the example and are omitted for clarity. Note that this same
Section \refersec{chap:datamemberentries}.
-\subsection{Packed record example: DWARF description}
-\label{app:packedrecordexampledwarfdescription}
+\begin{figure}[p]
+\begin{dwflisting}
% DWARF4 had some entries here as \livelink{chap:DWATmember}{DW_AT_member} .
% Those are fixed here to \livelink{chap:DWTAGmember}{DW_TAG_member}
\begin{alltt}
\livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...)
...
\end{alltt}
+\end{dwflisting}
+\caption{Packed record example: DWARF description}
+\label{fig:packedrecordexampledwarfdescription}
+\end{figure}
\section{Namespace Example}
\label{app:namespaceexample}
-
-The C++ example in
-Figure \referfol{fig:namespaceexamplesourcefragment}
+The \addtoindex{C++} example in
+Figure \refersec{fig:namespaceexamplesourcefragment}
is used
\addtoindexx{namespace (C++)!example}
to illustrate the representation of namespaces.
+The DWARF representation in
+Figure \refersec{fig:namespaceexampledwarfdescription}
+is appropriate.
-\begin{figure}[here]
+\begin{figure}[p]
\begin{lstlisting}
namespace {
int i;
\end{figure}
-The DWARF representation in
-Section \referfol{app:namespaceexampledwarfdescription}
-is appropriate.
-
-\subsection{Namespace example: DWARF description}
-\label{app:namespaceexampledwarfdescription}
+\begin{figure}[p]
+\begin{dwflisting}
\begin{alltt}
1\$: \livelink{chap:DWTAGbasetype}{DW\-\_TAG\-\_base\-\_type}
\livelink{chap:DWAThighpc}{DW\-\_AT\-\_high\-\_pc} ...
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
...
+\end{alltt}
+\end{dwflisting}
+\caption{Namespace example: DWARF description}
+\label{fig:namespaceexampledwarfdescription}
+\end{figure}
+\begin{figure}
+\begin{dwflisting}
+\begin{alltt}
40\$: \livelink{chap:DWTAGnamespace}{DW\-\_TAG\-\_namespace}
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("Y")
\livelink{chap:DWTAGimporteddeclaration}{DW\-\_TAG\-\_imported\-\_declaration} ! (1) using-declaration
\livelink{chap:DWAThighpc}{DW\-\_AT\-\_high\-\_pc} ...
...
\end{alltt}
+\end{dwflisting}
+\begin{center}
+Figure~\ref{fig:namespaceexampledwarfdescription}: Namespace example: DWARF description \textit{(concluded)}
+\end{center}
+\end{figure}
\section{Member Function Example}
\label{app:memberfunctionexample}
Consider the member function example fragment in
-Figure \referfol{fig:memberfunctionexamplesourcefragment}.
+Figure \refersec{fig:memberfunctionexamplesourcefragment}.
-\begin{figure}[here]
+\begin{figure}[Here]
\begin{lstlisting}
class A
{
\label{fig:memberfunctionexamplesourcefragment}
\end{figure}
-
-
The DWARF representation in
-Section \refersec{app:memberfunctionexampledwarfdescription}
+Section \refersec{fig:memberfunctionexampledwarfdescription}
is appropriate.
-\subsection{Member function example: DWARF description}
-\label{app:memberfunctionexampledwarfdescription}
-
-
+\begin{figure}[h]
+\begin{dwflisting}
\begin{alltt}
1\$: \livelink{chap:DWTAGunspecifiedtype}{DW\-\_TAG\-\_unspecified\-\_type}
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("void")
! References a formal parameter in this
! member function
...
+\end{alltt}
+\end{dwflisting}
+\caption{Member function example: DWARF description}
+\label{fig:memberfunctionexampledwarfdescription}
+\end{figure}
+
+\begin{figure}[p]
+\begin{dwflisting}
+\begin{alltt}
8\$: \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
\livelink{chap:DWATartificial}{DW\-\_AT\-\_artificial}(true)
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("this")
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 2\$)
...
\end{alltt}
+\end{dwflisting}
+\begin{center}
+Figure~\ref{fig:memberfunctionexampledwarfdescription}: Member function example: DWARF description \textit{(concluded)}
+\end{center}
+\end{figure}
+\clearpage
\section{Line Number Program Example}
\label{app:linenumberprogramexample}
Consider the simple source file and the resulting machine
code for the Intel 8086 processor in
-Figure \referfol{fig:linenumberprogramexamplemachinecode}.
+Figure \refersec{fig:linenumberprogramexamplemachinecode}.
\begin{figure}[here]
\begin{lstlisting}
\end{figure}
Suppose the line number program header includes the following
-(header fields not
-needed
+(header fields not needed
\addtoindexx{line\_base}
below
\addtoindexx{line\_range}
not
\addtoindexx{minumum\_instruction\_length}
shown):
-
-
\begin{alltt}
-version 4
-minimum_instruction_length 1
-opcode_base 10 ! Opcodes 10-12 not needed
-line_base 1
-line_range 15
+ version 4
+ minimum_instruction_length 1
+ opcode_base 10 ! Opcodes 10-12 not needed
+ line_base 1
+ line_range 15
\end{alltt}
-Table \referfol{tab:linenumberprogramexampleoneencoding}
+Table \refersec{tab:linenumberprogramexampleoneencoding}
shows one encoding of the line number program, which occupies
12 bytes (the opcode SPECIAL(m,n) indicates the special opcode
generated for a line increment of m and an address increment
of n).
-
+\newpage
\begin{centering}
\setlength{\extrarowheight}{0.1cm}
\begin{longtable}{lll}
\end{centering}
-Table \referfol{tab:linenumberprogramexamplealternateencoding}
+Table \refersec{tab:linenumberprogramexamplealternateencoding}
shows an alternate
encoding of the same program using
standard opcodes to advance
The following example uses a hypothetical RISC machine in
the style of the Motorola 88000.
-
\begin{itemize}
\item Memory is byte addressed.
\item Instructions are all 4 bytes each and word aligned.
\item Instruction operands are typically of the form:
-
\begin{alltt}
-<destination.reg>, <source.reg>, <constant>
+ <destination.reg>, <source.reg>, <constant>
\end{alltt}
\item The address for the load and store instructions is computed
source register with the constant.
\item There are 8 4\dash byte registers:
-
\begin{alltt}
-R0 always 0
-R1 holds return address on call
-R2-R3 temp registers (not preserved on call)
-R4-R6 preserved on call
-R7 stack pointer.
+ R0 always 0
+ R1 holds return address on call
+ R2-R3 temp registers (not preserved on call)
+ R4-R6 preserved on call
+ R7 stack pointer.
\end{alltt}
\item The stack grows in the negative direction.
\begin{centering}
\setlength{\extrarowheight}{0.1cm}
\begin{longtable}{lllllllllll}
- \caption{Call frame inforation example: conceptual matrix}
+ \caption{Call frame information example: conceptual matrix}
\label{tab:callframeinformationexampleconceptualmatrix} \\
\hline \bfseries Location & \bfseries CFA & \bfseries R0 & \bfseries R1 & \bfseries R2 & \bfseries R3 & \bfseries R4 & \bfseries R5 & \bfseries R6 & \bfseries R7 & \bfseries R8 \\ \hline
\endfirsthead
A suitable abstract instance for an alternative where both
OUTER and INNER are always inlined is shown in
-Figure \refersec{app:inliningexample1abstractinstance}
+Figure \refersec{fig:inliningexample1abstractinstance}.
Notice in
-Section \refersec{app:inliningexample1abstractinstance}
+Figure \refersec{fig:inliningexample1abstractinstance}
that the debugging information entry for
INNER (labelled INNER.AI.1.1) is nested in (is a child of)
that for OUTER (labelled OUTER.AI.1.1). Nonetheless, the
Figure \refersec{fig:inliningexamplespseudosourcefragment}
might be described as
shown in
-Section \refersec{app:inliningexample1concreteinstance}.
+Figure \refersec{fig:inliningexample1concreteinstance}.
-\subsubsection{Inlining example \#1: abstract instance}
-\label{app:inliningexample1abstractinstance}
+\begin{figure}[p]
+\begin{dwflisting}
\begin{alltt}
! Abstract instance for OUTER
! \addtoindexx{abstract instance!example}
...
0
\end{alltt}
+\end{dwflisting}
+\caption{Inlining example \#1: abstract instance}
+\label{fig:inliningexample1abstractinstance}
+\end{figure}
-
-\subsubsection{Inlining example \#1: concrete instance}
-\label{app:inliningexample1concreteinstance}
+\begin{figure}[p]
+\begin{dwflisting}
\begin{alltt}
! Concrete instance for call "OUTER(7)"
! \addtoindexx{concrete instance!example}
...
0
\end{alltt}
+\end{dwflisting}
+\caption{Inlining example \#1: concrete instance}
+\label{fig:inliningexample1concreteinstance}
+\end{figure}
\subsection{Alternative 2: Inline OUTER, multiple INNERs}
\label{app:inlineoutermultiipleinners}
The abstract instance for OUTER,
\addtoindexx{abstract instance!example}
which includes INNER, is shown in
-Section \refersec{app:inliningexample2abstractinstance}.
+Figure \refersec{fig:inliningexample2abstractinstance}.
Note that the debugging information in this Figure differs from
that in
-Section \refersec{app:inliningexample1abstractinstance}
+Figure \refersec{fig:inliningexample1abstractinstance}
in that INNER lacks a
\livelink{chap:DWATinline}{DW\-\_AT\-\_inline} attribute
and therefore is not a distinct abstract instance. INNER
is merely an out\dash of\dash line routine that is part of OUTER’s
-abstract instance. This is reflected in the Figure 70 by
+abstract instance. This is reflected in the Figure by
\addtoindexx{abstract instance!example}
the fact that the labels for INNER use the substring OUTER
instead of INNER.
A resulting
\addtoindexx{concrete instance!example}
concrete inlined instance of OUTER is shown in
-Section \referfol{app:inliningexample2concreteinstance}.
+Figure \refersec{fig:inliningexample2concreteinstance}.
Notice in
-Section \referfol{app:inliningexample2concreteinstance}.
+Figure \refersec{fig:inliningexample2concreteinstance}.
that OUTER is expanded as a concrete
\addtoindexx{concrete instance!example}
inlined instance, and that INNER is nested within it as a
calls to the instance of INNER that is specific to the same
instance of OUTER that contains the calls.
-
-\subsubsection{Inlining example 2: abstract instance}
-\label{app:inliningexample2abstractinstance}
+\begin{figure}[t]
+\begin{dwflisting}
\begin{alltt}
! Abstract instance for OUTER
! \addtoindex{abstract instance}
...
0
\end{alltt}
+\end{dwflisting}
+\caption{Inlining example \#2: abstract instance}
+\label{fig:inliningexample2abstractinstance}
+\end{figure}
-\subsubsection{Inlining example 2: concrete instance}
-\label{app:inliningexample2concreteinstance}
+\begin{figure}[t]
+\begin{dwflisting}
\begin{alltt}
! Concrete instance for call "OUTER(7)"
...
0
\end{alltt}
+\end{dwflisting}
+\caption{Inlining example \#2: concrete instance}
+\label{fig:inliningexample2concreteinstance}
+\end{figure}
\subsection{Alternative 3: inline OUTER, one normal INNER}
\label{app:inlineouteronenormalinner}
\addtoindexx{concrete instance!example}
\addtoindexx{abstract instance!example}
OUTER. The abstract instance for OUTER is shown in
-Section \refersec{app:inliningexample3abstractinstance}.
+Figure \refersec{fig:inliningexample3abstractinstance}.
The most distinctive aspect of that Figure is that subprogram
INNER exists only within the abstract instance of OUTER,
and every description is the same.
A concrete inlined instance of OUTER is illustrated in
-\refersec{app:inliningexample3concreteinstance}.
+Figure \refersec{fig:inliningexample3concreteinstance}.
Notice in
-\refersec{app:inliningexample3abstractinstance}
+Figure \refersec{fig:inliningexample3abstractinstance}
that there is no DWARF representation for
INNER at all; the representation of INNER does not vary across
instances of OUTER and the abstract instance of OUTER includes
variables nor static members require any form of static link
for accessing purposes.)
-\subsubsection{Inlining example 3: abstract instance}
-\label{app:inliningexample3abstractinstance}
+\begin{figure}[t]
+\begin{dwflisting}
\begin{alltt}
! Abstract instance for OUTER
! \addtoindexx{abstract instance!example}
...
0
\end{alltt}
+\end{dwflisting}
+\caption{Inlining example \#3: abstract instance}
+\label{fig:inliningexample3abstractinstance}
+\end{figure}
-
-\subsubsection{Inlining example 3: concrete instance}
-\label{app:inliningexample3concreteinstance}
+\begin{figure}[t]
+\begin{dwflisting}
\begin{alltt}
! Concrete instance for call "OUTER(7)"
! \addtoindexx{concrete instance!example}
...
0
\end{alltt}
+\end{dwflisting}
+\caption{Inlining example \#3: concrete instance}
+\label{fig:inliningexample3concreteinstance}
+\end{figure}
+\clearpage
\section{Constant Expression Example}
\label{app:constantexpressionexample}
C++ generalizes the notion of constant expressions to include
constant expression user-defined literals and functions.
+The constant declarations in Figure \refersec{fig:constantexpressionscsource}
+can be represented as illustrated in
+Figure \refersec{fig:constantexpressionsdwarfdescription}.
+
\begin{figure}[here]
-\begin{lstlisting}
+\begin{lstlisting}[numbers=none]
constexpr double mass = 9.8;
constexpr int square (int x) { return x * x; }
float arr[square(9)]; // square() called and inlined
\caption{Constant expressions: C++ source} \label{fig:constantexpressionscsource}
\end{figure}
-These declarations can be represented as illustrated in
-Section \refersec{app:constantexpressionsdwarfdescription}.
-
-\subsection{Constant expressions: DWARF description}
-\label{app:constantexpressionsdwarfdescription}
+\begin{figure}[h]
+\begin{dwflisting}
\begin{alltt}
-
- ! For variable mass
- !
-1\$: \livelink{chap:DWTAGconsttype}{DW\-\_TAG\-\_const\-\_type}
- \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "double")
-2\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
- \livelink{chap:DWATname}{DW\-\_AT\-\_name}("mass")
- \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
- \livelink{chap:DWATconstexpr}{DW\-\_AT\-\_const\-\_expr}(true)
- \livelink{chap:DWATconstvalue}{DW\-\_AT\-\_const\-\_value}(9.8)
- ! Abstract instance for square
- !
-10\$: \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
- \livelink{chap:DWATname}{DW\-\_AT\-\_name}("square")
- \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "int")
- \livelink{chap:DWATinline}{DW\-\_AT\-\_inline}(\livelink{chap:DWINLinlined}{DW\-\_INL\-\_inlined})
-11\$: \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
+ ! For variable mass
+ !
+1\$: \livelink{chap:DWTAGconsttype}{DW\-\_TAG\-\_const\-\_type}
+ \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "double")
+2\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
+ \livelink{chap:DWATname}{DW\-\_AT\-\_name}("mass")
+ \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
+ \livelink{chap:DWATconstexpr}{DW\-\_AT\-\_const\-\_expr}(true)
+ \livelink{chap:DWATconstvalue}{DW\-\_AT\-\_const\-\_value}(9.8)
+ ! Abstract instance for square
+ !
+10\$: \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
+ \livelink{chap:DWATname}{DW\-\_AT\-\_name}("square")
+ \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "int")
+ \livelink{chap:DWATinline}{DW\-\_AT\-\_inline}(\livelink{chap:DWINLinlined}{DW\-\_INL\-\_inlined})
+11\$: \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("x")
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "int")
- ! Concrete instance for square(9)
- ! \addtoindexx{concrete instance!example}
-20\$: \livelink{chap:DWTAGinlinedsubroutine}{DW\-\_TAG\-\_inlined\-\_subroutine}
- \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to 10\$)
- \livelink{chap:DWATconstexpr}{DW\-\_AT\-\_const\-\_expr}(present)
- \livelink{chap:DWATconstvalue}{DW\-\_AT\-\_const\-\_value}(81)
+ ! Concrete instance for square(9)
+ ! \addtoindexx{concrete instance!example}
+20\$: \livelink{chap:DWTAGinlinedsubroutine}{DW\-\_TAG\-\_inlined\-\_subroutine}
+ \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to 10\$)
+ \livelink{chap:DWATconstexpr}{DW\-\_AT\-\_const\-\_expr}(present)
+ \livelink{chap:DWATconstvalue}{DW\-\_AT\-\_const\-\_value}(81)
\livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
\livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to 11\$)
\livelink{chap:DWATconstvalue}{DW\-\_AT\-\_const\-\_value}(9)
- ! Anonymous array type for arr
- !
-30\$: \livelink{chap:DWTAGarraytype}{DW\-\_TAG\-\_array\-\_type}
+ ! Anonymous array type for arr
+ !
+30\$: \livelink{chap:DWTAGarraytype}{DW\-\_TAG\-\_array\-\_type}
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "float")
- \livelink{chap:DWATbytesize}{DW\-\_AT\-\_byte\-\_size}(324) ! 81*4
+ \livelink{chap:DWATbytesize}{DW\-\_AT\-\_byte\-\_size}(324) ! 81*4
\livelink{chap:DWTAGsubrangetype}{DW\-\_TAG\-\_subrange\-\_type}
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "int")
\livelink{chap:DWATupperbound}{DW\-\_AT\-\_upper\-\_bound}(reference to 20\$)
- ! Variable arr
- !
-40\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
- \livelink{chap:DWATname}{DW\-\_AT\-\_name}("arr")
- \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 30\$)
+ ! Variable arr
+ !
+40\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
+ \livelink{chap:DWATname}{DW\-\_AT\-\_name}("arr")
+ \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 30\$)
\end{alltt}
-
+\end{dwflisting}
+\caption{Constant expressions: DWARF description}
+\label{fig:constantexpressionsdwarfdescription}
+\end{figure}
\section{Unicode Character Example}
\label{app:unicodecharacterexample}
\addtoindexx{Unicode|see {\textit{also} UTF-8}}
-\addtoindex{Unicode} character encodings can be described in DWARF as
-illustrated in
-Section \refersec{app:unicodecharacterexamplesub}.
+The \addtoindex{Unicode} character encodings in
+Figure \refersec{fig:unicodecharacterexamplesource}
+can be described in DWARF as illustrated in
+Figure \refersec{fig:unicodecharacterexampledwarfdescription}.
-\begin{lstlisting}
+\begin{figure}[h]
+\begin{lstlisting}[numbers=none]
// C++ source
//
char16_t chr_a = u'h';
char32_t chr_b = U'h';
\end{lstlisting}
+\caption{Unicode character example: source}
+\label{fig:unicodecharacterexamplesource}
+\end{figure}
-\subsection{Unicode Character Example}
-\label{app:unicodecharacterexamplesub}
+\begin{figure}[h]
+\begin{dwflisting}
\begin{alltt}
! DWARF description
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("chr\_b")
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 2\$)
\end{alltt}
-
+\end{dwflisting}
+\caption{Unicode character example: DWARF description}
+\label{fig:unicodecharacterexampledwarfdescription}
+\end{figure}
\section{Type-Safe Enumeration Example}
\label{app:typesafeenumerationexample}
-
-C++ type\dash safe enumerations
+The \addtoindex{C++} type\dash safe enumerations in
\addtoindexx{type-safe enumeration}
+Figure \refersec{fig:ctypesafeenumerationexamplesource}
can be described in DWARF as illustrated in
-Section \refersec{app:ctypesafeenumerationexample}.
+Figure \refersec{fig:ctypesafeenumerationexampledwarf}.
-\begin{lstlisting}
+\begin{figure}[H]
+\begin{lstlisting}[numbers=none]
// C++ source
//
enum class E { E1, E2=100 };
E e1;
\end{lstlisting}
+\caption{Type-safe enumeration example: source}
+\label{fig:ctypesafeenumerationexamplesource}
+\end{figure}
-\subsection{C++ type-safe enumeration example}
-\label{app:ctypesafeenumerationexample}
+\begin{figure}[H]
+\begin{dwflisting}
\begin{alltt}
! DWARF description
!
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("e1")
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 11\$)
\end{alltt}
+\end{dwflisting}
+\caption{Type-safe enumeration example: DWARF description}
+\label{fig:ctypesafeenumerationexampledwarf}
+\end{figure}
-\section{Template Example}
-\label{app:templateexample}
-
-C++ templates can be described in DWARF as illustrated in
-Section \refersec{app:ctemplateexample1}.
+\section{Template Examples}
+\label{app:templateexample}
+The C++ template example in
+Figure \refersec{fig:ctemplateexample1source}
+can be described in DWARF as illustrated in
+Figure \refersec{fig:ctemplateexample1dwarf}.
+\begin{figure}[h]
\begin{lstlisting}
// C++ source
//
};
wrapper<int> obj;
\end{lstlisting}
+\caption{C++ template example \#1: source}
+\label{fig:ctemplateexample1source}
+\end{figure}
-\subsection{C++ template example 1}
-\label{app:ctemplateexample1}
+\begin{figure}[h]
+\begin{dwflisting}
\begin{alltt}
! DWARF description
!
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("obj")
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 11\$)
\end{alltt}
+\end{dwflisting}
+\caption{C++ template example \#1: DWARF description}
+\label{fig:ctemplateexample1dwarf}
+\end{figure}
The actual type of the component comp is int, but in the DWARF
-the type references the \livelink{chap:DWTAGtemplatetypeparameter}{DW\-\_TAG\-\_template\-\_type\-\_parameter} for
-T, which in turn references int. This implies that in the
+the type references the
+\livelink{chap:DWTAGtemplatetypeparameter}{DW\-\_TAG\-\_template\-\_type\-\_parameter}
+for T, which in turn references int. This implies that in the
original template comp was of type T and that was replaced
-with int in the instance. There exist situations where it is
+with int in the instance. There exist situations where it is
not possible for the DWARF to imply anything about the nature
of the original template.
-Consider following C++ source and DWARF
-that can describe it in
-Section \refersec{app:ctemplateexample2}.
-
+Consider the C++ template source in
+Figure \refersec{fig:ctemplateexample2source}
+and the DWARF that can describe it in
+Figure \refersec{fig:ctemplateexample2dwarf}.
+\begin{figure}[h]
\begin{lstlisting}
// C++ source
//
wrapper<int> obj;
consume(obj);
\end{lstlisting}
+\caption{C++ template example \#2: source}
+\label{ctemplateexample2source}
+\end{figure}
-\subsection{C++ template example 2}
-\label{app:ctemplateexample2}
+\begin{figure}[h]
+\begin{dwflisting}
\begin{alltt}
! DWARF description
!
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("formal")
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 11\$)
\end{alltt}
+\end{dwflisting}
+\caption{C++ template example \#2: DWARF description}
+\label{fig:ctemplateexample2dwarf}
+\end{figure}
In the \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
entry for the instance of consume, U is described as int.
\section{Template Alias Examples}
\label{app:templatealiasexample}
-C++ template aliases can be described in DWARF as illustrated
-\addtoindexx{template alias example}
-in
-Section \refersec{app:templatealiasexample1}
-and
-Section \refersec{app:templatealiasexample2}.
-
+The \addtoindex{C++} template alias shown in
+Figure \refersec{fig:ctemplatealiasexample1source}
+can be described in DWARF as illustrated
+\addtoindexx{template alias example} in
+Figure \refersec{fig:ctemplatealiasexample1dwarf}.
+\begin{figure}[h]
\begin{lstlisting}
// C++ source, template alias example 1
//
template<typename V> using Beta = Alpha<V,V>;
Beta<long> b;
\end{lstlisting}
+\caption{C++ template alias example \#1: source}
+\label{fig:ctemplatealiasexample1source}
+\end{figure}
-
-\subsection{template alias example 1}
+\begin{figure}[h]
\addtoindexx{template alias example 1}
-\label{app:templatealiasexample1}
+\begin{dwflisting}
\begin{alltt}
! DWARF representation for variable 'b'
!
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("b")
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 25\$)
\end{alltt}
+\end{dwflisting}
+\caption{C++ template alias example \#1: DWARF description}
+\label{fig:ctemplatealiasexample1dwarf}
+\end{figure}
+Similarly, the \addtoindex{C++} template alias shown in
+Figure \refersec{fig:ctemplatealiasexample2source}
+can be described in DWARF as illustrated
+\addtoindexx{template alias example} in
+Figure \refersec{fig:ctemplatealiasexample2dwarf}.
+\begin{figure}[h]
\begin{lstlisting}
// C++ source, template alias example 2
//
X<Y<int>> y;
X<Z<int>> z;
\end{lstlisting}
+\caption{C++ template alias example \#2: source}
+\label{fig:ctemplatealiasexample2source}
+\end{figure}
-
-\subsection{template alias example 2}
+\begin{figure}[h]
\addtoindexx{template alias example 2}
-\label{app:templatealiasexample2}
+\begin{dwflisting}
\begin{alltt}
! DWARF representation for X<Y<int>>
!
\livelink{chap:DWATname}{DW\-\_AT\-\_name}("z")
\livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to \$42)
\end{alltt}
+\end{dwflisting}
+\caption{C++ template alias example \#2: DWARF description}
+\label{fig:ctemplatealiasexample2dwarf}
+\end{figure}
\ No newline at end of file