8920ae899184f92b86aaa4a50b0b7a763de08529
[dwarf-doc.git] / dwarf5 / latexdoc / examples.tex
1 \chapter{Examples (Informative)}
2 \label{app:examplesinformative}
3
4 The following sections provide examples that illustrate
5 various aspects of the DWARF debugging information format.
6
7
8 \section{ Compilation Units and Abbreviations Table Example}
9 \label{app:compilationunitsandabbreviationstableexample}
10
11
12 Figure \refersec{fig:compilationunitsandabbreviationstable}
13 depicts the relationship of the abbreviations tables contained
14 \addtoindexx{abbreviations table!example}
15 \addtoindexx{.debug\_abbrev example}
16 \addtoindexx{.debug\_info example}
17 in the \addtoindex{.debug\_abbrev}
18 section to the information contained in
19 the \addtoindex{.debug\_info}
20 section. Values are given in symbolic form,
21 where possible.
22
23 The figure corresponds to the following two trivial source files:
24
25 File myfile.c
26 \begin{lstlisting}[numbers=none]
27 typedef char* POINTER;
28 \end{lstlisting}
29 File myfile2.c
30 \begin{lstlisting}[numbers=none]
31 typedef char* strp;
32 \end{lstlisting}
33
34 % Ensures we get the following float out before we go on.
35 \clearpage
36 \begin{figure}[here]
37 %\centering
38 \begin{minipage}{0.4\textwidth}
39 \centering
40 Compilation Unit \#1: \addtoindex{.debug\_info}
41 \begin{framed}
42 \scriptsize
43 \begin{alltt}
44 \textit{length}
45 4
46 \textit{a1 (abbreviations table offset)}
47 4
48 \vspace{0.01cm}
49 \hrule
50 1
51 "myfile.c"
52 "Best Compiler Corp: Version 1.3"
53 "/home/mydir/src"
54 \livelink{chap:DWLANGC89}{DW\-\_LANG\-\_C89}
55 0x0
56 0x55
57 \livelink{chap:DWFORMsecoffset}{DW\-\_FORM\-\_sec\-\_offset}
58 0x0
59 \vspace{0.01cm}
60 \hrule
61 \textit{e1:}
62 2
63 "char"
64 \livelink{chap:DWATEunsignedchar}{DW\-\_ATE\-\_unsigned\-\_char}
65 1
66 \vspace{0.01cm}
67 \hrule
68 \textit{e2:}
69 3
70 \textit{e1  (debug info offset)}
71 \vspace{0.01cm}
72 \hrule
73 4
74 "POINTER"
75 \textit{e2  (debug info offset)}
76 \vspace{0.01cm}
77 \hrule
78 0
79 \end{alltt}
80 %
81 %
82 \end{framed}
83 Compilation Unit \#2: \addtoindex{.debug\_info}
84 \begin{framed}
85 \scriptsize
86 \begin{alltt}
87 \textit{length}
88 4
89 \textit{a1 (abbreviations table offset)}
90 4
91 \vspace{0.01cm}
92 \hrule
93 ...
94 \vspace{0.01cm}
95 \hrule
96 4
97 "strp"
98 \textit{e2  (debug info offset)}
99 \vspace{0.01cm}
100 \hrule
101 ...
102 \end{alltt}
103 %
104 %
105 \end{framed}
106 \end{minipage}
107 \hfill
108 \begin{minipage}{0.4\textwidth}
109 \centering
110 Abbreviation Table: \addtoindex{.debug\_abbrev}
111 \begin{framed}
112 \scriptsize
113 \begin{alltt}
114 \textit{a1:}
115 1
116 \livelink{chap:DWTAGcompileunit}{DW\-\_TAG\-\_compile\-\_unit}
117 \livelink{chap:DWCHILDRENyes}{DW\-\_CHILDREN\-\_yes}
118 \livelink{chap:DWATname}{DW\-\_AT\-\_name}       \livelink{chap:DWFORMstring}{DW\-\_FORM\-\_string}
119 \livelink{chap:DWATproducer}{DW\-\_AT\-\_producer}   \livelink{chap:DWFORMstring}{DW\-\_FORM\-\_string}
120 \livelink{chap:DWATcompdir}{DW\-\_AT\-\_comp\-\_dir}   \livelink{chap:DWFORMstring}{DW\-\_FORM\-\_string}
121 \livelink{chap:DWATlanguage}{DW\-\_AT\-\_language}   \livelink{chap:DWFORMdata1}{DW\-\_FORM\-\_data1}
122 \livelink{chap:DWATlowpc}{DW\-\_AT\-\_low\-\_pc}     \livelink{chap:DWFORMaddr}{DW\-\_FORM\-\_addr}
123 \livelink{chap:DWAThighpc}{DW\-\_AT\-\_high\-\_pc}    \livelink{chap:DWFORMdata1}{DW\-\_FORM\-\_data1}
124 \livelink{chap:DWATstmtlist}{DW\-\_AT\-\_stmt\-\_list}  \livelink{chap:DWFORMindirect}{DW\-\_FORM\-\_indirect}
125 0
126 \vspace{0.01cm}
127 \hrule
128 2
129 \livelink{chap:DWTAGbasetype}{DW\-\_TAG\-\_base\-\_type}
130 \livelink{chap:DWCHILDRENno}{DW\-\_CHILDREN\-\_no}
131 \livelink{chap:DWATname}{DW\-\_AT\-\_name}       \livelink{chap:DWFORMstring}{DW\-\_FORM\-\_string}
132 \livelink{chap:DWATencoding}{DW\-\_AT\-\_encoding}   \livelink{chap:DWFORMdata1}{DW\-\_FORM\-\_data1}
133 \livelink{chap:DWATbytesize}{DW\-\_AT\-\_byte\-\_size}  \livelink{chap:DWFORMdata1}{DW\-\_FORM\-\_data1}
134 0
135 \vspace{0.01cm}
136 \hrule
137 3
138 \livelink{chap:DWTAGpointertype}{DW\-\_TAG\-\_pointer\-\_type}
139 \livelink{chap:DWCHILDRENno}{DW\-\_CHILDREN\-\_no}
140 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}       \livelink{chap:DWFORMref4}{DW\-\_FORM\-\_ref4}
141 0
142 \vspace{0.01cm}
143 \hrule
144 4
145 \livelink{chap:DWTAGtypedef}{DW\-\_TAG\-\_typedef}
146 \livelink{chap:DWCHILDRENno}{DW\-\_CHILDREN\-\_no}
147 \livelink{chap:DWATname}{DW\-\_AT\-\_name}      \livelink{chap:DWFORMstring}{DW\-\_FORM\-\_string}
148 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}      \livelink{chap:DWFORMrefaddr}{DW\-\_FORM\-\_ref\-\_addr}
149 0
150 \vspace{0.01cm}
151 \hrule
152 0
153 \end{alltt}
154 \end{framed}
155 \end{minipage}
156 \caption{Compilation units and abbreviations table} \label{fig:compilationunitsandabbreviationstable}
157 \end{figure}
158
159 % Ensures we get the above float out before we go on.
160 \clearpage
161
162 \section{Aggregate Examples}
163 \label{app:aggregateexamples}
164
165 The following examples illustrate how to represent some of
166 the more complicated forms of array and record aggregates
167 using DWARF.
168
169 \subsection{Fortran 90 Example}
170 \label{app:fortran90example}
171 Consider the \addtoindex{Fortran 90} source fragment in 
172 \addtoindexx{array type entry!examples}
173 Figure \referfol{fig:fortran90examplesourcefragment}.
174
175 \begin{figure}[here]
176 \begin{lstlisting}
177 type array_ptr
178 real :: myvar
179 real, dimension (:), pointer :: ap
180 end type array_ptr
181 type(array_ptr), allocatable, dimension(:) :: arrays
182 allocate(arrays(20))
183 do i = 1, 20
184 allocate(arrays(i)%ap(i+10))
185 end do
186 \end{lstlisting}
187 \caption{Fortran 90 example: source fragment} \label{fig:fortran90examplesourcefragment}
188 \end{figure}
189
190 For allocatable and pointer arrays, it is essentially required
191 by the \addtoindex{Fortran 90} semantics that each array consist of 
192 \addtoindexx{descriptor!array}
193 two
194 \addtoindexx{array!descriptor for}
195 parts, which we here call 1) the descriptor and 2) the raw
196 data. (A descriptor has often been called a dope vector in
197 other contexts, although it is often a structure of some kind
198 rather than a simple vector.) Because there are two parts,
199 and because the lifetime of the descriptor is necessarily
200 longer than and includes that of the raw data, there must be
201 an address somewhere in the descriptor that points to the
202 raw data when, in fact, there is some (that is, when 
203 the ``variable'' is allocated or associated).
204
205 For concreteness, suppose that a descriptor looks something
206 like the C structure in 
207 Figure \refersec{fig:fortran90exampledescriptorrepresentation}.
208 Note, however, that it is
209 a property of the design that 1) a debugger needs no builtin
210 knowledge of this structure and 2) there does not need to
211 be an explicit representation of this structure in the DWARF
212 input to the 
213 \addtoindexx{Fortran 90}
214 debugger.
215
216 \begin{figure}[here]
217 \begin{lstlisting}
218 struct desc {
219     long el_len; // Element length
220     void * base; // Address of raw data
221     int ptr_assoc : 1; // Pointer is associated flag
222     int ptr_alloc : 1; // Pointer is allocated flag
223     int num_dims  : 6; // Number of dimensions
224     struct dims_str { // For each dimension...  
225         long low_bound;
226         long upper_bound;
227         long stride;
228     } dims[63];
229 };
230 \end{lstlisting}
231 \caption{Fortran 90 example: descriptor representation}
232 \label{fig:fortran90exampledescriptorrepresentation}
233 \end{figure}
234
235
236 In practice, of course, a \doublequote{real} descriptor will have
237 dimension substructures only for as many dimensions as are
238 specified in the \texttt{num\_dims} component. Let us use the notation
239 \texttt{desc\textless n\textgreater}   
240 to indicate a specialization of the \texttt{desc} struct in
241 which \texttt{n} is the bound for the \texttt{dims} component as well as the
242 contents of the \texttt{num\_dims} component.
243
244 Because the arrays considered here come in two parts, it is
245 necessary to distinguish the parts carefully. In particular,
246 the \doublequote{address of the variable} or equivalently, the \doublequote{base
247 address of the object} \emph{always} refers to the descriptor. For
248 arrays that do not come in two parts, an implementation can
249 provide a descriptor anyway, thereby giving it two parts. (This
250 may be convenient for general runtime support unrelated to
251 debugging.) In this case the above vocabulary applies as
252 stated. Alternatively, an implementation can do without a
253 descriptor, in which case the \doublequote{address of the variable},
254 or equivalently the \doublequote{base address of the object}, refers
255 to the \doublequote{raw data} (the real data, the only thing around
256 that can be the object).
257
258 If an object has a descriptor, then the DWARF type for that
259 object will have a 
260 \livelink{chap:DWATdatalocation}{DW\-\_AT\-\_data\-\_location} 
261 attribute. If an object
262 does not have a descriptor, then usually the DWARF type for the
263 object will not have a 
264 \livelink{chap:DWATdatalocation}{DW\-\_AT\-\_data\-\_location}. 
265 (See the following
266 \addtoindex{Ada} example for a case where the type for an object without
267 a descriptor does have a 
268 \livelink{chap:DWATdatalocation}{DW\-\_AT\-\_data\-\_location} attribute. In
269 that case the object doubles as its own descriptor.)
270
271 The \addtoindex{Fortran 90} derived type array\_ptr can now be redescribed
272 in C\dash like terms that expose some of the representation as in
273
274 \begin{lstlisting}[numbers=none]
275 struct array_ptr {
276     float myvar;
277     desc<1> ap;
278 };
279 \end{lstlisting}
280
281 Similarly for variable arrays:
282 \begin{lstlisting}[numbers=none]
283 desc<1> arrays;
284 \end{lstlisting}
285
286 (Recall that \texttt{desc\textless 1\textgreater} 
287 indicates the 1\dash dimensional version of \texttt{desc}.)
288
289 \newpage
290 Finally, the following notation is useful:
291 \begin{enumerate}[1. ]
292 \item  sizeof(type): size in bytes of entities of the given type
293 \item offset(type, comp): offset in bytes of the comp component
294 within an entity of the given type
295 \end{enumerate}
296
297 The DWARF description is shown 
298 \addtoindexx{Fortran 90}
299 in Figure \refersec{fig:fortran90exampledwarfdescription}.
300
301 \begin{figure}[h]
302 \figurepart{1}{2}
303 \begin{dwflisting}
304 \begin{alltt}
305 ! Description for type of 'ap'
306 !
307 1\$: \livelink{chap:DWTAGarraytype}{DW\-\_TAG\-\_array\-\_type}
308         ! No name, default (Fortran) ordering, default stride
309         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to REAL)
310         \livelink{chap:DWATassociated}{DW\-\_AT\-\_associated}(expression= ! Test 'ptr\_assoc' \nolink{flag}
311             \livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address}
312             \livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<n>    ! where n == offset(ptr\_assoc)
313             \livelink{chap:DWOPplus}{DW\-\_OP\-\_plus}
314             \livelink{chap:DWOPderef}{DW\-\_OP\-\_deref}
315             \livelink{chap:DWOPlit1}{DW\-\_OP\-\_lit1}      ! mask for 'ptr\_assoc' \nolink{flag}
316             \livelink{chap:DWOPand}{DW\-\_OP\-\_and})
317         \livelink{chap:DWATdatalocation}{DW\-\_AT\-\_data\-\_location}(expression= ! Get raw data address
318             \livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address}
319             \livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<n>    ! where n == offset(base)
320             \livelink{chap:DWOPplus}{DW\-\_OP\-\_plus}
321             \livelink{chap:DWOPderef}{DW\-\_OP\-\_deref})    ! Type of index of array 'ap'
322 2\$:     \livelink{chap:DWTAGsubrangetype}{DW\-\_TAG\-\_subrange\-\_type}
323             ! No name, default stride
324             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to INTEGER)
325             \livelink{chap:DWATlowerbound}{DW\-\_AT\-\_lower\-\_bound}(expression=
326                 \livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address}
327                 \livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<n> ! where n ==
328                              !  offset(desc, dims) +
329                              !  offset(dims\_str, lower\_bound)
330                 \livelink{chap:DWOPplus}{DW\-\_OP\-\_plus}
331                 \livelink{chap:DWOPderef}{DW\-\_OP\-\_deref})
332             \livelink{chap:DWATupperbound}{DW\-\_AT\-\_upper\-\_bound}(expression=
333                 \livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address}
334                 \livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<n> ! where n ==
335                              !  offset(desc, dims) +
336                              !  offset(dims\_str, upper\_bound)
337                 \livelink{chap:DWOPplus}{DW\-\_OP\-\_plus}
338                 \livelink{chap:DWOPderef}{DW\-\_OP\-\_deref})
339             !  Note: for the m'th dimension, the second operator becomes
340             !  \livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<x> where
341             !       x == offset(desc, dims)          +
342             !                (m-1)*sizeof(dims\_str) +
343             !                 offset(dims\_str, [lower|upper]\_bound)
344             !  That is, the expression does not get longer for each successive 
345             !  dimension (other than to express the larger offsets involved).
346 \end{alltt}
347 \end{dwflisting}
348 \caption{Fortran 90 example: DWARF description}
349 \label{fig:fortran90exampledwarfdescription}
350 \end{figure}
351
352 \begin{figure}
353 \figurepart{2}{2}
354 \begin{dwflisting}
355 \begin{alltt}
356 3\$: \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type}
357         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("array\_ptr")
358         \livelink{chap:DWATbytesize}{DW\-\_AT\-\_byte\-\_size}(constant sizeof(REAL) + sizeof(desc<1>))
359 4\$:     \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
360             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("myvar")
361             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to REAL)
362             \livelink{chap:DWATdatamemberlocation}{DW\-\_AT\-\_data\-\_member\-\_location}(constant 0)
363 5\$:     \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
364             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("ap");
365             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
366             \livelink{chap:DWATdatamemberlocation}{DW\-\_AT\-\_data\-\_member\-\_location}(constant sizeof(REAL))
367 6\$: \livelink{chap:DWTAGarraytype}{DW\-\_TAG\-\_array\-\_type}
368         ! No name, default (Fortran) ordering, default stride
369         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 3\$)
370         \livelink{chap:DWATallocated}{DW\-\_AT\-\_allocated}(expression=     ! Test 'ptr\_alloc' \nolink{flag}
371             \livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address}
372             \livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<n>                ! where n == offset(ptr\_alloc)
373             \livelink{chap:DWOPplus}{DW\-\_OP\-\_plus}
374             \livelink{chap:DWOPderef}{DW\-\_OP\-\_deref}
375             \livelink{chap:DWOPlit}{DW\-\_OP\-\_lit2}                  ! Mask for 'ptr\_alloc' \nolink{flag}
376             \livelink{chap:DWOPand}{DW\-\_OP\-\_and})
377         \livelink{chap:DWATdatalocation}{DW\-\_AT\-\_data\-\_location}(expression= ! Get raw data address
378             \livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address}
379             \livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<n>                ! where n = offset(base)
380             \livelink{chap:DWOPplus}{DW\-\_OP\-\_plus}
381             \livelink{chap:DWOPderef}{DW\-\_OP\-\_deref})
382 7\$:     \livelink{chap:DWTAGsubrangetype}{DW\-\_TAG\-\_subrange\-\_type}
383             ! No name, default stride
384             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to INTEGER)
385             \livelink{chap:DWATlowerbound}{DW\-\_AT\-\_lower\-\_bound}(expression=
386                 \livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address}
387                 \livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<n>            ! where n == ...
388                 \livelink{chap:DWOPplus}{DW\-\_OP\-\_plus}
389                 \livelink{chap:DWOPderef}{DW\-\_OP\-\_deref})
390             \livelink{chap:DWATupperbound}{DW\-\_AT\-\_upper\-\_bound}(expression=
391                 \livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address}
392                 \livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<n>            ! where n == ...
393                 \livelink{chap:DWOPplus}{DW\-\_OP\-\_plus}
394                 \livelink{chap:DWOPderef}{DW\-\_OP\-\_deref})
395 8\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
396         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("arrays")
397         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 6\$)
398         \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(expression=
399             ...as appropriate...) ! Assume static allocation
400 \end{alltt}
401 \end{dwflisting}
402 \begin{center}
403
404 Figure~\ref{fig:fortran90exampledwarfdescription} Fortran 90 example: DWARF description \textit{(concluded)}
405 \end{center}
406 \end{figure}
407
408 Suppose 
409 \addtoindexx{Fortran 90 example}
410 the program is stopped immediately following completion
411 of the do loop. Suppose further that the user enters the
412 following debug command:
413
414 \begin{lstlisting}[numbers=none]
415 debug> print arrays(5)%ap(2)
416 \end{lstlisting}
417
418 Interpretation of this expression proceeds as follows:
419 \begin{enumerate}[1. ]
420
421 \item Lookup name arrays. We find that it is a variable,
422 whose type is given by the unnamed type at 6\$. Notice that
423 the type is an array type.
424
425
426 \item Find the 5$^{th}$ element of that array object. To do array
427 indexing requires several pieces of information:
428 \begin{enumerate}[a) ]
429
430 \item  the address of the array data
431
432 \item the lower bounds of the array \\
433 % Using plain [] here gives trouble.
434 \lbrack To check that 5 is within bounds would require the upper
435 bound too, but we will skip that for this example. \rbrack
436
437 \item the stride 
438
439 \end{enumerate}
440
441 For a), check for a \livelink{chap:DWATdatalocation}{DW\-\_AT\-\_data\-\_location} attribute. Since
442 there is one, go execute the expression, whose result is
443 the address needed. The object address used in this case
444 is the object we are working on, namely the variable named
445 arrays, whose address was found in step 1. (Had there been
446 no \livelink{chap:DWATdatalocation}{DW\-\_AT\-\_data\-\_location} attribute, the desired address would
447 be the same as the address from step 1.)
448
449 For b), for each dimension of the array (only one
450 in this case), go interpret the usual lower bound
451 attribute. Again this is an expression, which again begins
452 with \livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address}. This object is 
453 \textbf{still} arrays,
454 from step 1, because we have not begun to actually perform
455 any indexing yet.
456
457 For c), the default stride applies. Since there is no
458 \livelink{chap:DWATbytestride}{DW\-\_AT\-\_byte\-\_stride} attribute, use the size of the array element
459 type, which is the size of type array\_ptr (at 3\$).
460
461 \clearpage
462
463 Having acquired all the necessary data, perform the indexing
464 operation in the usual manner--which has nothing to do with
465 any of the attributes involved up to now. Those just provide
466 the actual values used in the indexing step.
467
468 The result is an object within the memory that was dynamically
469 allocated for arrays.
470
471 \item  Find the ap component of the object just identified,
472 whose type is array\_ptr.
473
474 This is a conventional record component lookup and
475 interpretation. It happens that the ap component in this case
476 begins at offset 4 from the beginning of the containing object.
477 Component ap has the unnamed array type defined at 1\$ in the
478 symbol table.
479
480 \item  Find the second element of the array object found in step 3. To do array indexing requires
481 several pieces of information:
482 \begin{enumerate}[a) ]
483 \item  the address of the array storage
484
485 \item  the lower bounds of the array \\
486 % Using plain [] here gives trouble.
487 \lbrack To check that 2 is within bounds we would require the upper
488 bound too, but we will skip that for this example \rbrack
489
490 \item  the stride
491
492 \end{enumerate}
493 \end{enumerate}
494
495 This is just like step 2), so the details are omitted. Recall
496 that because the DWARF type 1\$ has a \livelink{chap:DWATdatalocation}{DW\-\_AT\-\_data\-\_location},
497 the address that results from step 4) is that of a
498 descriptor, and that address is the address pushed by the
499 \livelink{chap:DWOPpushobjectaddress}{DW\-\_OP\-\_push\-\_object\-\_address} operations in 1\$ and 2\$.
500
501 Note: we happen to be accessing a pointer array here instead
502 of an allocatable array; but because there is a common
503 underlying representation, the mechanics are the same. There
504 could be completely different descriptor arrangements and the
505 mechanics would still be the same---only the stack machines
506 would be different.
507
508
509
510 \subsection{Ada Example}
511 \label{app:adaexample}
512
513 Figure \refersec{fig:adaexamplesourcefragment}
514 illustrates two kinds of \addtoindex{Ada} 
515 parameterized array, one embedded in a record.
516
517
518 \begin{figure}[here]
519 \begin{lstlisting}
520 M : INTEGER := <exp>;
521 VEC1 : array (1..M) of INTEGER;
522 subtype TEENY is INTEGER range 1..100;
523 type ARR is array (INTEGER range <>) of INTEGER;
524 type REC2(N : TEENY := 100) is record
525     VEC2 : ARR(1..N);
526 end record;
527
528 OBJ2B : REC2;
529 \end{lstlisting}
530 \caption{Ada 90 example: source fragment}
531 \label{fig:adaexamplesourcefragment}
532 \end{figure}
533
534 VEC1 illustrates an (unnamed) array type where the upper bound
535 of the first and only dimension is determined at runtime. 
536 \addtoindex{Ada}
537 semantics require that the value of an array bound is fixed at
538 the time the array type is elaborated (where elaboration refers
539 to the runtime executable aspects of type processing). For
540 the purposes of this example, we assume that there are no
541 other assignments to M so that it safe for the REC1 type
542 description to refer directly to that variable (rather than
543 a compiler generated copy).
544
545 REC2 illustrates another array type (the unnamed type of
546 component VEC2) where the upper bound of the first and only
547 bound is also determined at runtime. In this case, the upper
548 bound is contained in a discriminant of the containing record
549 type. (A \textit{discriminant} is a component of a record whose value
550 cannot be changed independently of the rest of the record
551 because that value is potentially used in the specification
552 of other components of the record.)
553
554 The DWARF description is shown in 
555 Figure \refersec{fig:adaexampledwarfdescription}.
556
557
558 Interesting aspects about this example are:
559 \begin{enumerate}[1. ]
560 \item The array VEC2 is ``immediately'' contained within structure
561 REC2 (there is no intermediate descriptor or indirection),
562 which is reflected in the absence of a \livelink{chap:DWATdatalocation}{DW\-\_AT\-\_data\-\_location}
563 attribute on the array type at 28\$.
564
565 \item One of the bounds of VEC2 is nonetheless dynamic and part of
566 the same containing record. It is described as a reference to
567 a member, and the location of the upper bound is determined
568 as for any member. That is, the location is determined using
569 an address calculation relative to the base of the containing
570 object.  
571
572 A consumer must notice that the referenced bound is a
573 member of the same containing object and implicitly push the
574 base address of the containing object just as for accessing
575 a data member generally.
576
577 \item The lack of a subtype concept in DWARF means that DWARF types
578 serve the role of subtypes and must replicate information from
579 what should be the parent type. For this reason, DWARF for
580 the unconstrained array type ARR is not needed for the purposes
581 of this example and therefore is not shown.
582 \end{enumerate}
583
584 \begin{figure}[p]
585 \begin{dwflisting}
586 \begin{alltt}
587 11\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
588         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("M")
589         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to INTEGER)
590 12\$: \livelink{chap:DWTAGarraytype}{DW\-\_TAG\-\_array\-\_type}
591         ! No name, default (\addtoindex{Ada}) order, default stride
592         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to INTEGER)
593 13\$:    \livelink{chap:DWTAGsubrangetype}{DW\-\_TAG\-\_subrange\-\_type}
594             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to INTEGER)
595             \livelink{chap:DWATlowerbound}{DW\-\_AT\-\_lower\-\_bound}(constant 1)
596             \livelink{chap:DWATupperbound}{DW\-\_AT\-\_upper\-\_bound}(reference to variable M at 11\$)
597 14\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
598         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("VEC1")
599         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to array type at 12\$)
600      . . .
601 21\$: \livelink{chap:DWTAGsubrangetype}{DW\-\_TAG\-\_subrange\-\_type}
602         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("TEENY")
603         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to INTEGER)
604         \livelink{chap:DWATlowerbound}{DW\-\_AT\-\_lower\-\_bound}(constant 1)
605         \livelink{chap:DWATupperbound}{DW\-\_AT\-\_upper\-\_bound}(constant 100)
606      . . .
607 26\$: \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type}
608         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("REC2")
609 27\$:    \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
610             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("N")
611             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to subtype TEENY at 21\$)
612             \livelink{chap:DWATdatamemberlocation}{DW\-\_AT\-\_data\-\_member\-\_location}(constant 0)
613 28\$:    \livelink{chap:DWTAGarraytype}{DW\-\_TAG\-\_array\-\_type}
614             ! No name, default (\addtoindex{Ada}) order, default stride
615             ! Default data location
616             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to INTEGER)
617 29\$:        \livelink{chap:DWTAGsubrangetype}{DW\-\_TAG\-\_subrange\-\_type}
618                 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to subrange TEENY at 21\$)
619                 \livelink{chap:DWATlowerbound}{DW\-\_AT\-\_lower\-\_bound}(constant 1)
620                 \livelink{chap:DWATupperbound}{DW\-\_AT\-\_upper\-\_bound}(reference to member N at 27\$)
621 30\$:    \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
622             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("VEC2")
623             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to array "subtype" at 28\$)
624             \livelink{chap:DWATdatamemberlocation}{DW\-\_AT\-\_data\-\_member\-\_location}(machine=
625                 \livelink{chap:DWOPlit}{DW\-\_OP\-\_lit}<n> ! where n == offset(REC2, VEC2)
626                 \livelink{chap:DWOPplus}{DW\-\_OP\-\_plus})
627      . . .
628 41\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
629         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("OBJ2B")
630         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to REC2 at 26\$)
631         \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...as appropriate...)
632 \end{alltt}
633 \end{dwflisting}
634 \caption{Ada 90 example: DWARF description}
635 \label{fig:adaexampledwarfdescription}
636 \end{figure}
637
638 \clearpage
639
640 \subsection{Pascal Example}
641 \label{app:pascalexample}
642 The Pascal \addtoindexx{Pascal example} source in 
643 Figure \referfol{fig:packedrecordexamplesourcefragment}
644 is used to illustrate the representation of packed unaligned
645 \addtoindex{bit fields}.
646
647 \begin{figure}[here]
648 \begin{lstlisting}
649 TYPE T : PACKED RECORD                  ! bit size is 2
650          F5 : BOOLEAN;                  ! bit offset is 0
651          F6 : BOOLEAN;                  ! bit offset is 1
652          END;
653 VAR V :  PACKED RECORD
654          F1 : BOOLEAN;                  ! bit offset is 0
655          F2 : PACKED RECORD             ! bit offset is 1
656               F3 : INTEGER;             ! bit offset is 0 in F2, 1 in V
657               END;
658          F4 : PACKED ARRAY [0..1] OF T; ! bit offset is 33
659          F7 : T;                        ! bit offset is 37
660          END;
661 \end{lstlisting}
662 \caption{Packed record example: source fragment}
663 \label{fig:packedrecordexamplesourcefragment}
664 \end{figure}
665
666 The DWARF representation in 
667 Figure \refersec{fig:packedrecordexampledwarfdescription} 
668 is appropriate. 
669 \livelink{chap:DWTAGpackedtype}{DW\-\_TAG\-\_packed\-\_type} entries could be added to
670 better represent the source, but these do not otherwise affect
671 the example and are omitted for clarity. Note that this same
672 representation applies to both typical big\dash \ and 
673 little\dash endian
674 architectures using the conventions described in 
675 Section \refersec{chap:datamemberentries}.
676
677 \begin{figure}[p]
678 \figurepart{1}{2}
679 \begin{dwflisting}
680 % DWARF4 had some entries here as \livelink{chap:DWATmember}{DW_AT_member} .
681 % Those are fixed here to \livelink{chap:DWTAGmember}{DW_TAG_member}
682 \begin{alltt}
683 10\$: \livelink{chap:DWTAGbasetype}{DW\_TAG\_base\_type}
684         \livelink{chap:DWATname}{DW\_AT\_name}("BOOLEAN")
685             ...
686 11\$: \livelink{chap:DWTAGbasetype}{DW\_TAG\_base\_type}
687         \livelink{chap:DWATname}{DW\_AT\_name}("INTEGER")
688             ...
689 20\$: \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type}
690         \livelink{chap:DWATname}{DW\_AT\_name}("T")
691         \livelink{chap:DWATbitsize}{DW\_AT\_bit\_size}(2)
692         \livelink{chap:DWTAGmember}{DW\_TAG\_member}
693             \livelink{chap:DWATname}{DW\_AT\_name}("F5")
694             \livelink{chap:DWATtype}{DW\_AT\_type}(reference to 10$)
695             \livelink{chap:DWATdatabitoffset}{DW\_AT\_data\_bit\_offset}(0)        ! may be omitted
696             \livelink{chap:DWATbitsize}{DW\_AT\_bit\_size}(1)
697         \livelink{chap:DWTAGmember}{DW\_TAG\_member}
698             \livelink{chap:DWATname}{DW\_AT\_name}("F6")
699             \livelink{chap:DWATtype}{DW\_AT\_type}(reference to 10$)
700             \livelink{chap:DWATdatabitoffset}{DW\_AT\_data\_bit\_offset}(1)
701             \livelink{chap:DWATbitsize}{DW\_AT\_bit\_size}(1)
702 21\$: \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type}                  ! anonymous type for F2
703         \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
704             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("F3")
705             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 11\$)
706 22\$: \livelink{chap:DWTAGarraytype}{DW\-\_TAG\-\_array\-\_type}                      ! anonymous type for F4
707         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 20\$)
708         \livelink{chap:DWTAGsubrangetype}{DW\-\_TAG\-\_subrange\-\_type}
709             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 11\$)
710             \livelink{chap:DWATlowerbound}{DW\-\_AT\-\_lower\-\_bound}(0)
711             \livelink{chap:DWATupperbound}{DW\-\_AT\-\_upper\-\_bound}(1)
712         \livelink{chap:DWATbitstride}{DW\-\_AT\-\_bit\-\_stride}(2)
713         \livelink{chap:DWATbitsize}{DW\-\_AT\-\_bit\-\_size}(4) \addtoindexx{bit size attribute}
714 23\$: \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type}                  ! anonymous type for V
715         \livelink{chap:DWATbitsize}{DW\-\_AT\-\_bit\-\_size}(39) \addtoindexx{bit size attribute}
716         \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
717             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("F1")
718             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 10\$)
719             \livelink{chap:DWATdatabitoffset}{DW\-\_AT\-\_data\-\_bit\-\_offset}(0)        ! may be omitted
720             \livelink{chap:DWATbitsize}{DW\-\_AT\-\_bit\-\_size}(1) ! may be omitted
721         \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
722             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("F2")
723             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 21\$)
724             \livelink{chap:DWATdatabitoffset}{DW\-\_AT\-\_data\-\_bit\-\_offset}(1)
725             \livelink{chap:DWATbitsize}{DW\-\_AT\-\_bit\-\_size}(32) ! may be omitted
726         \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
727             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("F4")
728             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 22\$)
729             \livelink{chap:DWATdatabitoffset}{DW\-\_AT\-\_data\-\_bit\-\_offset}(33)
730             \livelink{chap:DWATbitsize}{DW\-\_AT\-\_bit\-\_size}(4) ! may be omitted
731 \end{alltt}
732 \end{dwflisting}
733 \caption{Packed record example: DWARF description}
734 \label{fig:packedrecordexampledwarfdescription}
735 \end{figure}
736
737 \begin{figure}[p]
738 \figurepart{2}{2}
739 \begin{dwflisting}
740 \begin{alltt}
741         \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
742             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("F7")
743             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 20\$)    ! type T
744             \livelink{chap:DWATdatabitoffset}{DW\-\_AT\-\_data\-\_bit\-\_offset}(37)
745             \livelink{chap:DWATbitsize}{DW\-\_AT\-\_bit\-\_size}(2) \addtoindexx{bit size attribute}              ! may be omitted
746      \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
747         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("V")
748         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 23\$)
749         \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...)
750         ...
751 \end{alltt}
752 \end{dwflisting}
753 \begin{center}
754 Figure~\ref{fig:packedrecordexampledwarfdescription}: Packed record example: DWARF description \textit{(concluded)}
755 \end{center}
756 \end{figure}
757
758 \section{Namespace Example}
759 \label{app:namespaceexample}
760
761 The \addtoindex{C++} example in 
762 Figure \refersec{fig:namespaceexamplesourcefragment}
763 is used 
764 \addtoindexx{namespace (C++)!example}
765 to illustrate the representation of namespaces.
766 The DWARF representation in 
767 Figure \refersec{fig:namespaceexampledwarfdescription}
768 is appropriate.
769
770 \begin{figure}[p]
771 \begin{lstlisting}
772 namespace {
773     int i;
774 }
775 namespace A {
776     namespace B {
777         int j;
778         int   myfunc (int a);
779         float myfunc (float f) { return f - 2.0; }
780         int   myfunc2(int a)   { return a + 2; }
781     }
782 }
783 namespace Y {
784     using A::B::j;         // (1) using declaration
785     int foo;
786 }
787 using A::B::j;             // (2) using declaration
788 namespace Foo = A::B;      // (3) namespace alias
789 using Foo::myfunc;         // (4) using declaration
790 using namespace Foo;       // (5) using directive
791 namespace A {
792     namespace B {
793         using namespace Y; // (6) using directive
794         int k;
795     }
796 }
797 int Foo::myfunc(int a)
798 {
799     i = 3;
800     j = 4;
801     return myfunc2(3) + j + i + a + 2;
802 }
803 \end{lstlisting}
804 \caption{Namespace example: source fragment}
805 \label{fig:namespaceexamplesourcefragment}
806 \end{figure}
807
808
809 \begin{figure}[p]
810 \figurepart{1}{2}
811 \begin{dwflisting}
812 \begin{alltt}
813
814 1\$:  \livelink{chap:DWTAGbasetype}{DW\-\_TAG\-\_base\-\_type}
815         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("int")
816         ...
817 2\$:  \livelink{chap:DWTAGbasetype}{DW\-\_TAG\-\_base\-\_type}
818         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("float")
819         ...
820 6\$:  \livelink{chap:DWTAGnamespace}{DW\-\_TAG\-\_namespace}
821         ! no \livelink{chap:DWATname}{DW\-\_AT\-\_name} attribute
822 7\$:
823         \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
824             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("i")
825             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
826             \livelink{chap:DWATlocation}{DW\-\_AT\-\_location} ...
827             ...
828 10\$: \livelink{chap:DWTAGnamespace}{DW\-\_TAG\-\_namespace}
829         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("A")
830 20\$:    \livelink{chap:DWTAGnamespace}{DW\-\_TAG\-\_namespace}
831             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("B")
832 30\$:        \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
833                 \livelink{chap:DWATname}{DW\-\_AT\-\_name}("j")
834                 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
835                 \livelink{chap:DWATlocation}{DW\-\_AT\-\_location} ...
836                 ...
837 34\$:        \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
838                 \livelink{chap:DWATname}{DW\-\_AT\-\_name}("myfunc")
839                 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
840                 ...
841 36\$:        \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
842                 \livelink{chap:DWATname}{DW\-\_AT\-\_name}("myfunc")
843                 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 2\$)
844                 ...
845 38\$:        \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
846                 \livelink{chap:DWATname}{DW\-\_AT\-\_name}("myfunc2")
847                 \livelink{chap:DWATlowpc}{DW\-\_AT\-\_low\-\_pc} ...
848                 \livelink{chap:DWAThighpc}{DW\-\_AT\-\_high\-\_pc} ...
849                 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
850                 ...
851 \end{alltt}
852 \end{dwflisting}
853 \caption{Namespace example: DWARF description}
854 \label{fig:namespaceexampledwarfdescription}
855 \end{figure}
856
857 \begin{figure}
858 \figurepart{2}{2}
859 \begin{dwflisting}
860 \begin{alltt}
861 40\$: \livelink{chap:DWTAGnamespace}{DW\-\_TAG\-\_namespace}
862         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("Y")
863         \livelink{chap:DWTAGimporteddeclaration}{DW\-\_TAG\-\_imported\-\_declaration}            ! (1) using-declaration
864             \livelink{chap:DWATimport}{DW\-\_AT\-\_import}(reference to 30\$)
865         \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
866             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("foo")
867             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
868             \livelink{chap:DWATlocation}{DW\-\_AT\-\_location} ...
869             ...
870      \livelink{chap:DWTAGimporteddeclaration}{DW\-\_TAG\-\_imported\-\_declaration}               ! (2) using declaration
871         \livelink{chap:DWATimport}{DW\-\_AT\-\_import}(reference to 30\$)
872         \livelink{chap:DWTAGimporteddeclaration}{DW\-\_TAG\-\_imported\-\_declaration}            ! (3) namespace alias
873             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("Foo")
874             \livelink{chap:DWATimport}{DW\-\_AT\-\_import}(reference to 20\$)
875         \livelink{chap:DWTAGimporteddeclaration}{DW\-\_TAG\-\_imported\-\_declaration}            ! (4) using declaration
876             \livelink{chap:DWATimport}{DW\-\_AT\-\_import}(reference to 34\$)     !     - part 1
877         \livelink{chap:DWTAGimporteddeclaration}{DW\-\_TAG\-\_imported\-\_declaration}            ! (4) using declaration
878             \livelink{chap:DWATimport}{DW\-\_AT\-\_import}(reference to 36\$)     !     - part 2
879         \livelink{chap:DWTAGimportedmodule}{DW\-\_TAG\-\_imported\-\_module}                 ! (5) using directive
880             \livelink{chap:DWATimport}{DW\-\_AT\-\_import}(reference to 20\$)
881         \livelink{chap:DWTAGnamespace}{DW\-\_TAG\-\_namespace}
882             \livelink{chap:DWATextension}{DW\-\_AT\-\_extension}(reference to 10\$)
883             \livelink{chap:DWTAGnamespace}{DW\-\_TAG\-\_namespace}
884                 \livelink{chap:DWATextension}{DW\-\_AT\-\_extension}(reference to 20\$)
885                 \livelink{chap:DWTAGimportedmodule}{DW\-\_TAG\-\_imported\-\_module}         ! (6) using directive
886                     \livelink{chap:DWATimport}{DW\-\_AT\-\_import}(reference to 40\$)
887                 \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
888                     \livelink{chap:DWATname}{DW\-\_AT\-\_name}("k")
889                     \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
890                     \livelink{chap:DWATlocation}{DW\-\_AT\-\_location} ...
891                     ...
892 60\$: \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
893         \livelink{chap:DWATspecification}{DW\-\_AT\-\_specification}(reference to 34\$)
894         \livelink{chap:DWATlowpc}{DW\-\_AT\-\_low\-\_pc} ...
895         \livelink{chap:DWAThighpc}{DW\-\_AT\-\_high\-\_pc} ...
896         ...
897 \end{alltt}
898 \end{dwflisting}
899 \begin{center}
900 Figure~\ref{fig:namespaceexampledwarfdescription}: Namespace example: DWARF description \textit{(concluded)}
901 \end{center}
902 \end{figure}
903
904 \section{Member Function Example}
905 \label{app:memberfunctionexample}
906
907 Consider the member function example fragment in 
908 Figure \refersec{fig:memberfunctionexamplesourcefragment}.
909 The DWARF representation in 
910 Figure \refersec{fig:memberfunctionexampledwarfdescription}
911 is appropriate.
912
913 \begin{figure}[Here]
914 \begin{lstlisting}
915 class A
916 {
917     void func1(int x1);
918     void func2() const;
919     static void func3(int x3);
920 };
921 void A::func1(int x) {}
922 \end{lstlisting}
923 \caption{Member function example: source fragment}
924 \label{fig:memberfunctionexamplesourcefragment}
925 \end{figure}
926
927 \begin{figure}[h]
928 \figurepart{1}{2}
929 \begin{dwflisting}
930 \begin{alltt}
931 1\$: \livelink{chap:DWTAGunspecifiedtype}{DW\-\_TAG\-\_unspecified\-\_type}
932         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("void")
933                 ...
934 2\$: \livelink{chap:DWTAGbasetype}{DW\-\_TAG\-\_base\-\_type}
935         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("int")
936         ...
937 3\$: \livelink{chap:DWTAGclasstype}{DW\-\_TAG\-\_class\-\_type}
938         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("A")
939         ...
940 4\$:    \livelink{chap:DWTAGpointertype}{DW\-\_TAG\-\_pointer\-\_type}
941             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 3\$)
942             ...
943 5\$:    \livelink{chap:DWTAGconsttype}{DW\-\_TAG\-\_const\-\_type}
944             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 3\$)
945             ...
946 6\$:    \livelink{chap:DWTAGpointertype}{DW\-\_TAG\-\_pointer\-\_type}
947             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 5\$)
948             ...
949
950 7\$:    \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
951             \livelink{chap:DWATdeclaration}{DW\-\_AT\-\_declaration}
952             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("func1")
953             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
954             \livelink{chap:DWATobjectpointer}{DW\-\_AT\-\_object\-\_pointer}(reference to 8\$) \addtoindexx{object pointer attribute}
955                 ! References a formal parameter in this 
956                 ! member function
957             ...
958 \end{alltt}
959 \end{dwflisting}
960 \caption{Member function example: DWARF description}
961 \label{fig:memberfunctionexampledwarfdescription}
962 \end{figure}
963
964 \begin{figure}[p]
965 \figurepart{2}{2}
966 \begin{dwflisting}
967 \begin{alltt}
968 8\$:        \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
969                 \livelink{chap:DWATartificial}{DW\-\_AT\-\_artificial}(true)
970                 \livelink{chap:DWATname}{DW\-\_AT\-\_name}("this")
971                 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 4\$)
972                     ! Makes type of 'this' as 'A*' =>
973                     ! func1 has not been marked const 
974                     ! or volatile
975                 \livelink{chap:DWATlocation}{DW\-\_AT\-\_location} ...
976                 ...
977 9\$:        \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
978                 \livelink{chap:DWATname}{DW\-\_AT\-\_name}(x1)
979                 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 2\$)
980                 ...
981 10\$:    \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
982              \livelink{chap:DWATdeclaration}{DW\-\_AT\-\_declaration}
983              \livelink{chap:DWATname}{DW\-\_AT\-\_name}("func2")
984              \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
985              \livelink{chap:DWATobjectpointer}{DW\-\_AT\-\_object\-\_pointer}(reference to 11\$) \addtoindexx{object pointer attribute}
986              ! References a formal parameter in this 
987              ! member function
988              ...
989 11\$:        \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
990                  \livelink{chap:DWATartificial}{DW\-\_AT\-\_artificial}(true)
991                  \livelink{chap:DWATname}{DW\-\_AT\-\_name}("this")
992                  \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 6\$)
993                  ! Makes type of 'this' as 'A const*' =>
994                  !     func2 marked as const
995                  \livelink{chap:DWATlocation}{DW\-\_AT\-\_location} ...
996                  ...
997 12\$:    \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
998              \livelink{chap:DWATdeclaration}{DW\-\_AT\-\_declaration}
999              \livelink{chap:DWATname}{DW\-\_AT\-\_name}("func3")
1000              \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
1001              ...
1002                  ! No object pointer reference formal parameter
1003                  ! implies func3 is static
1004 13\$:        \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1005                  \livelink{chap:DWATname}{DW\-\_AT\-\_name}(x3)
1006                  \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 2\$)
1007                  ...
1008 \end{alltt}
1009 \end{dwflisting}
1010 \begin{center}
1011 Figure~\ref{fig:memberfunctionexampledwarfdescription}: Member function example: DWARF description \textit{(concluded)}
1012 \end{center}
1013 \end{figure}
1014
1015 \clearpage
1016 \section{Line Number Program Example}
1017 \label{app:linenumberprogramexample}
1018
1019 Consider the simple source file and the resulting machine
1020 code for the Intel 8086 processor in 
1021 Figure \refersec{fig:linenumberprogramexamplemachinecode}.
1022
1023 \begin{figure}[here]
1024 \begin{lstlisting}
1025 1: int
1026 2: main()
1027     0x239: push pb
1028     0x23a: mov bp,sp
1029 3: {
1030 4: printf("Omit needless words\n");
1031     0x23c: mov ax,0xaa
1032     0x23f: push ax
1033     0x240: call _printf
1034     0x243: pop cx
1035 5: exit(0);
1036     0x244: xor ax,ax
1037     0x246: push ax
1038     0x247: call _exit
1039     0x24a: pop cx
1040 6: }
1041     0x24b: pop bp
1042     0x24c: ret
1043 7: 0x24d:
1044 \end{lstlisting}
1045 \caption{Line number program example: machine code}
1046 \label{fig:linenumberprogramexamplemachinecode}
1047 \end{figure}
1048
1049 Suppose the line number program header includes the following
1050 (header fields not needed 
1051 \addtoindexx{line\_base}
1052 below 
1053 \addtoindexx{line\_range}
1054 are 
1055 \addtoindexx{opcode\_base}
1056 not 
1057 \addtoindexx{minumum\_instruction\_length}
1058 shown):
1059 \begin{alltt}
1060     version                       4
1061     minimum_instruction_length    1
1062     opcode_base                  10   ! Opcodes 10-12 not needed
1063     line_base                     1
1064     line_range                   15
1065 \end{alltt}
1066
1067
1068 Table \refersec{tab:linenumberprogramexampleoneencoding}
1069 shows one encoding of the line number program, which occupies
1070 12 bytes (the opcode SPECIAL(\textit{m},\textit{n}) indicates the special opcode
1071 generated for a line increment of \textit{m} and an address increment
1072 of \textit{n}).
1073
1074 \newpage
1075 \begin{centering}
1076 \setlength{\extrarowheight}{0.1cm}
1077 \begin{longtable}{l|l|l}
1078   \caption{Line number program example: one \mbox{encoding}}
1079   \label{tab:linenumberprogramexampleoneencoding} \\
1080   \hline \bfseries Opcode &\bfseries Operand &\bfseries Byte Stream \\ \hline
1081 \endfirsthead
1082   \bfseries Opcode &\bfseries Operand &\bfseries Byte Stream\\ \hline
1083 \endhead
1084   \hline \emph{Continued on next page}
1085 \endfoot
1086   \hline
1087 \endlastfoot
1088 \livelink{chap:DWLNSadvancepc}{DW\-\_LNS\-\_advance\-\_pc}&LEB128(0x239)&0x2, 0xb9, 0x04 \\
1089 SPECIAL(2, 0)& &0xb  \\
1090 SPECIAL(2, 3)& &0x38 \\
1091 SPECIAL(1, 8)& &0x82 \\
1092 SPECIAL(1, 7)& &0x73 \\
1093 \livelink{chap:DWLNSadvancepc}{DW\-\_LNS\-\_advance\-\_pc}&LEB128(2)&0x2, 0x2 \\
1094 \livelink{chap:DWLNEendsequence}{DW\-\_LNE\-\_end\-\_sequence} &&0x0, 0x1, 0x1 \\
1095 \end{longtable}
1096 \end{centering}
1097
1098
1099 Table \refersec{tab:linenumberprogramexamplealternateencoding}
1100 shows an alternate 
1101 encoding of the same program using 
1102 standard opcodes to advance
1103 the program counter; 
1104 this encoding occupies 22 bytes.
1105
1106 \begin{centering}
1107 \setlength{\extrarowheight}{0.1cm}
1108 \begin{longtable}{l|l|l}
1109   \caption{Line number program example: alternate encoding} 
1110   \label{tab:linenumberprogramexamplealternateencoding} \\
1111   \hline \bfseries Opcode &\bfseries Operand &\bfseries Byte Stream \\ \hline
1112 \endfirsthead
1113   \bfseries Opcode &\bfseries Operand &\bfseries Byte Stream\\ \hline
1114 \endhead
1115   \hline \emph{Continued on next page}
1116 \endfoot
1117   \hline
1118 \endlastfoot
1119 \livelink{chap:DWLNSfixedadvancepc}{DW\-\_LNS\-\_fixed\-\_advance\-\_pc}&0x239&0x9, 0x39, 0x2        \\
1120 SPECIAL(2, 0)&& 0xb        \\
1121 \livelink{chap:DWLNSfixedadvancepc}{DW\-\_LNS\-\_fixed\-\_advance\-\_pc}&0x3&0x9, 0x3, 0x0        \\
1122 SPECIAL(2, 0)&&0xb        \\
1123 \livelink{chap:DWLNSfixedadvancepc}{DW\-\_LNS\-\_fixed\-\_advance\-\_pc}&0x8&0x9, 0x8, 0x0        \\
1124 SPECIAL(1, 0)&& 0xa        \\
1125 \livelink{chap:DWLNSfixedadvancepc}{DW\-\_LNS\-\_fixed\-\_advance\-\_pc}&0x7&0x9, 0x7, 0x0        \\
1126 SPECIAL(1, 0) && 0xa        \\
1127 \livelink{chap:DWLNSfixedadvancepc}{DW\-\_LNS\-\_fixed\-\_advance\-\_pc}&0x2&0x9, 0x2, 0x0        \\
1128 \livelink{chap:DWLNEendsequence}{DW\-\_LNE\-\_end\-\_sequence}&&0x0, 0x1, 0x1        \\
1129 \end{longtable}
1130 \end{centering}
1131
1132
1133 \section{Call Frame Information Example}
1134 \label{app:callframeinformationexample}
1135
1136 The following example uses a hypothetical RISC machine in
1137 the style of the Motorola 88000.
1138 \begin{itemize}
1139 \item Memory is byte addressed.
1140
1141 \item Instructions are all 4 bytes each and word aligned.
1142
1143 \item Instruction operands are typically of the form:
1144 \begin{alltt}
1145     <destination.reg>, <source.reg>, <constant>
1146 \end{alltt}
1147
1148 \item The address for the load and store instructions is computed
1149 by adding the contents of the
1150 source register with the constant.
1151
1152 \item There are 8 4\dash byte registers:
1153 \begin{alltt}
1154     R0 always 0
1155     R1 holds return address on call
1156     R2-R3 temp registers (not preserved on call)
1157     R4-R6 preserved on call
1158     R7 stack pointer.
1159 \end{alltt}
1160
1161 \item  The stack grows in the negative direction.
1162
1163 \item The architectural ABI committee specifies that the
1164 stack pointer (R7) is the same as the CFA
1165
1166 \end{itemize}
1167
1168 Figure \referfol{fig:callframeinformationexamplemachinecodefragments}
1169 shows two code fragments from a subroutine called
1170 foo that uses a frame pointer (in addition to the stack
1171 pointer). The first column values are byte addresses. 
1172 % The \space is so we get a space after >
1173 \textless fs\textgreater\ denotes the stack frame size in bytes, namely 12.
1174
1175
1176 \begin{figure}[here]
1177 \begin{lstlisting}
1178        ;; start prologue
1179 foo    sub R7, R7, <fs>        ; Allocate frame
1180 foo+4  store R1, R7, (<fs>-4)  ; Save the return address
1181 foo+8  store R6, R7, (<fs>-8)  ; Save R6
1182 foo+12 add R6, R7, 0           ; R6 is now the Frame ptr
1183 foo+16 store R4, R6, (<fs>-12) ; Save a preserved reg
1184        ;; This subroutine does not change R5
1185        ...
1186        ;; Start epilogue (R7 is returned to entry value)
1187 foo+64 load R4, R6, (<fs>-12)  ; Restore R4
1188 foo+68 load R6, R7, (<fs>-8)   ; Restore R6
1189 foo+72 load R1, R7, (<fs>-4)   ; Restore return address
1190 foo+76 add R7, R7, <fs>        ; Deallocate frame
1191 foo+80 jump R1 ; Return
1192 foo+84
1193 \end{lstlisting}
1194 \caption{Call frame information example: machine code fragments}
1195 \label{fig:callframeinformationexamplemachinecodefragments}
1196 \end{figure}
1197
1198
1199 An abstract table 
1200 (see Section \refersec{chap:structureofcallframeinformation}) 
1201 for the foo subroutine is shown in 
1202 Table \referfol{tab:callframeinformationexampleconceptualmatrix}.
1203 Corresponding fragments from the
1204 \addtoindex{.debug\_frame} section are shown in 
1205 Table \refersec{tab:callframeinformationexamplecommoninformationentryencoding}.
1206
1207 The following notations apply in 
1208 Table \refersec{tab:callframeinformationexampleconceptualmatrix}:
1209
1210 \begin{alltt}
1211 1. R8 is the return address
1212 2. s = same\_value rule
1213 3. u = undefined rule
1214 4. rN = register(N) rule
1215 5. cN = offset(N) rule
1216 6. a = architectural rule
1217 \end{alltt}
1218
1219 \begin{centering}
1220 \setlength{\extrarowheight}{0.1cm}
1221 \begin{longtable}{l|llllllllll}
1222   \caption{Call frame information example: conceptual matrix} 
1223   \label{tab:callframeinformationexampleconceptualmatrix} \\
1224   \hline \bfseries Location & \bfseries CFA & \bfseries R0 & \bfseries R1 & \bfseries R2 & \bfseries R3 & \bfseries R4 & \bfseries R5 & \bfseries R6 & \bfseries R7 & \bfseries R8 \\ \hline
1225 \endfirsthead
1226   \bfseries Location &\bfseries CFA &\bfseries R0 & \bfseries R1 & \bfseries R2 &\bfseries R3 &\bfseries R4 &\bfseries R5 &\bfseries R6 &\bfseries R7 &\bfseries R8\\ \hline
1227 \endhead
1228   \hline \emph{Continued on next page}
1229 \endfoot
1230   \hline
1231 \endlastfoot
1232 foo&[R7]+0&s&u&u&u&s&s&s&a&r1 \\
1233 foo+4&[R7]+fs&s&u&u&u&s&s&s&a&r1 \\
1234 foo+8&[R7]+fs&s&u&u&u&s&s&s&a&c-4 \\
1235 foo+12&[R7]+fs&s&u&u&u&s&s&c-8&a&c-4 \\
1236 foo+16&[R6]+fs&s&u&u&u&s&s&c-8&a&c-4 \\
1237 foo+20&[R6]+fs&s&u&u&u&c-12&s&c-8&a&c-4 \\
1238 ...&&&&&&&&&& \\
1239 foo+64&[R6]+fs&s&u&u&u&c-12&s&c-8&a&c-4 \\
1240 foo+68&[R6]+fs&s&u&u&u&s&s&c-8&a&c-4  \\
1241 foo+72&[R7]+fs&s&u&u&u&s&s&s&a&c-4  \\
1242 foo+76&[R7]+fs&s&u&u&u&s&s&s&a&r1 \\
1243 foo+80&[R7]+0&s&u&u&u&s&s&s&a&r1 \\
1244 \end{longtable}
1245 \end{centering}
1246
1247 \clearpage      % ?????
1248
1249 \begin{centering}
1250 \setlength{\extrarowheight}{0.1cm}
1251 \begin{longtable}{l|ll}
1252   \caption{Call frame information example: common information entry encoding} 
1253   \label{tab:callframeinformationexamplecommoninformationentryencoding} 
1254   \\
1255   \hline \bfseries Address &\bfseries Value &\bfseries Comment \\ \hline
1256 \endfirsthead
1257   \bfseries Address &\bfseries Value &\bfseries Comment \\ \hline
1258 \endhead
1259   \hline \emph{Continued on next page}
1260 \endfoot
1261   \hline
1262 \endlastfoot
1263 cie&36&length    \\
1264 cie+4&\xffffffff&CIE\_id    \\
1265 cie+8&4&version    \\
1266 cie+9&0&augmentation     \\
1267 cie+10&4&address size    \\
1268 cie+11&0&segment size    \\
1269 cie+12&4&code\_alignment\_factor, \textless caf \textgreater    \\
1270 cie+13&-4&data\_alignment\_factor, \textless daf \textgreater    \\
1271 cie+14&8&R8 is the return addr.    \\
1272 cie+15&\livelink{chap:DWCFAdefcfa}{DW\-\_CFA\-\_def\-\_cfa} (7, 0)&CFA = [R7]+0    \\
1273 cie+18&\livelink{chap:DWCFAsamevalue}{DW\-\_CFA\-\_same\-\_value} (0)&R0 not modified (=0)    \\
1274 cie+20&\livelink{chap:DWCFAundefined}{DW\-\_CFA\-\_undefined} (1)&R1 scratch    \\
1275 cie+22&\livelink{chap:DWCFAundefined}{DW\-\_CFA\-\_undefined} (2)&R2 scratch    \\
1276 cie+24&\livelink{chap:DWCFAundefined}{DW\-\_CFA\-\_undefined} (3)&R3 scratch    \\
1277 cie+26&\livelink{chap:DWCFAsamevalue}{DW\-\_CFA\-\_same\-\_value} (4)&R4 preserve    \\
1278 cie+28&\livelink{chap:DWCFAsamevalue}{DW\-\_CFA\-\_same\-\_value} (5)&R5 preserve    \\
1279 cie+30&\livelink{chap:DWCFAsamevalue}{DW\-\_CFA\-\_same\-\_value} (6)&R6 preserve    \\
1280 cie+32&\livelink{chap:DWCFAsamevalue}{DW\-\_CFA\-\_same\-\_value} (7)&R7 preserve    \\
1281 cie+34&\livelink{chap:DWCFAregister}{DW\-\_CFA\-\_register} (8, 1)&R8 is in R1    \\
1282 cie+37&\livelink{chap:DWCFAnop}{DW\-\_CFA\-\_nop} &padding    \\
1283 cie+38&\livelink{chap:DWCFAnop}{DW\-\_CFA\-\_nop} &padding \\
1284 cie+39& \livelink{chap:DWCFAnop}{DW\-\_CFA\-\_nop}&padding  \\
1285 cie+40 &&  \\
1286 \end{longtable}
1287 \end{centering}
1288
1289
1290 The following notations apply in 
1291 Table \refersec{tab:callframeinformationexampleframedescriptionentryencoding}:
1292
1293 \begin{alltt}
1294 1. <fs>  = frame size
1295 2. <caf> = code alignment factor
1296 3. <daf> = data alignment factor
1297 \end{alltt}
1298
1299
1300 \begin{centering}
1301 \setlength{\extrarowheight}{0.1cm}
1302 \begin{longtable}{l|ll}
1303   \caption{Call frame information example: frame description entry encoding} 
1304   \label{tab:callframeinformationexampleframedescriptionentryencoding} \\
1305   \hline \bfseries Address &\bfseries Value &\bfseries Comment \\ \hline
1306 \endfirsthead
1307   \bfseries Address &\bfseries Value &\bfseries Comment \\ \hline
1308 \endhead
1309   \hline \emph{Continued on next page}
1310 \endfoot
1311   \hline
1312 \endlastfoot
1313 fde&40&length \\
1314 fde+4&cie&CIE\_ptr \\
1315 fde+8&foo&initial\_location \\
1316 fde+12&84&address\_range \\
1317 fde+16&\livelink{chap:DWCFAadvanceloc}{DW\-\_CFA\-\_advance\-\_loc}(1)&instructions \\
1318 fde+17&\livelink{chap:DWCFAdefcfaoffset}{DW\-\_CFA\-\_def\-\_cfa\-\_offset}(12)& \textless fs\textgreater \\
1319 fde+19&\livelink{chap:DWCFAadvanceloc}{DW\-\_CFA\-\_advance\-\_loc}(1)&4/\textless caf\textgreater \\
1320 fde+20&\livelink{chap:DWCFAoffset}{DW\-\_CFA\-\_offset}(8,1)&-4/\textless daf\textgreater (2nd parameter) \\
1321 fde+22&\livelink{chap:DWCFAadvanceloc}{DW\-\_CFA\-\_advance\-\_loc}(1)& \\
1322 fde+23&\livelink{chap:DWCFAoffset}{DW\-\_CFA\-\_offset}(6,2)&-8/\textless daf\textgreater (2nd parameter)  \\
1323 fde+25&\livelink{chap:DWCFAadvanceloc}{DW\-\_CFA\-\_advance\-\_loc}(1) & \\
1324 fde+26&\livelink{chap:DWCFAdefcfaregister}{DW\-\_CFA\-\_def\-\_cfa\-\_register}(6) & \\
1325 fde+28&\livelink{chap:DWCFAadvanceloc}{DW\-\_CFA\-\_advance\-\_loc}(1) & \\
1326 fde+29&\livelink{chap:DWCFAoffset}{DW\-\_CFA\-\_offset}(4,3)&-12/\textless daf\textgreater (2nd parameter) \\
1327 fde+31&\livelink{chap:DWCFAadvanceloc}{DW\-\_CFA\-\_advance\-\_loc}(12)&44/\textless caf\textgreater \\
1328 fde+32&\livelink{chap:DWCFArestore}{DW\-\_CFA\-\_restore}(4)& \\
1329 fde+33&\livelink{chap:DWCFAadvanceloc}{DW\-\_CFA\-\_advance\-\_loc}(1) & \\
1330 fde+34&\livelink{chap:DWCFArestore}{DW\-\_CFA\-\_restore}(6) & \\
1331 fde+35&\livelink{chap:DWCFAdefcfaregister}{DW\-\_CFA\-\_def\-\_cfa\-\_register}(7)  & \\
1332 fde+37&\livelink{chap:DWCFAadvanceloc}{DW\-\_CFA\-\_advance\-\_loc}(1) & \\
1333 fde+38&\livelink{chap:DWCFArestore}{DW\-\_CFA\-\_restore}(8) &\\
1334 fde+39&\livelink{chap:DWCFAadvanceloc}{DW\-\_CFA\-\_advance\-\_loc}(1) &\\
1335 fde+40&\livelink{chap:DWCFAdefcfaoffset}{DW\-\_CFA\-\_def\-\_cfa\-\_offset}(0)  &\\
1336 fde+42&\livelink{chap:DWCFAnop}{DW\-\_CFA\-\_nop}&padding \\
1337 fde+43&\livelink{chap:DWCFAnop}{DW\-\_CFA\-\_nop}&padding \\
1338 fde+44 && \\
1339 \end{longtable}
1340 \end{centering}
1341
1342 \section{Inlining Examples}
1343 \label{app:inliningexamples}
1344 The pseudo\dash source in 
1345 Figure \referfol{fig:inliningexamplespseudosourcefragment}
1346 is used to illustrate the
1347 \addtoindexx{inlined subprogram call!examples}
1348 use of DWARF to describe inlined subroutine calls. This
1349 example involves a nested subprogram INNER that makes uplevel
1350 references to the formal parameter and local variable of the
1351 containing subprogram OUTER.
1352
1353 \begin{figure}[here]
1354 \begin{lstlisting}
1355 inline procedure OUTER (OUTER_FORMAL : integer) =
1356     begin
1357     OUTER_LOCAL : integer;
1358     procedure INNER (INNER_FORMAL : integer) =
1359         begin
1360         INNER_LOCAL : integer;
1361         print(INNER_FORMAL + OUTER_LOCAL);
1362         end;
1363     INNER(OUTER_LOCAL);
1364     ...
1365     INNER(31);
1366     end;
1367 ! Call OUTER
1368 !
1369 OUTER(7);
1370 \end{lstlisting}
1371 \caption{Inlining examples: pseudo-source fragmment} 
1372 \label{fig:inliningexamplespseudosourcefragment}
1373 \end{figure}
1374
1375
1376 There are several approaches that a compiler might take to
1377 inlining for this sort of example. This presentation considers
1378 three such approaches, all of which involve inline expansion
1379 of subprogram OUTER. (If OUTER is not inlined, the inlining
1380 reduces to a simpler single level subset of the two level
1381 approaches considered here.)
1382
1383 The approaches are:
1384 \begin{enumerate}[1. ]
1385 \item  Inline both OUTER and INNER in all cases
1386
1387 \item Inline OUTER, multiple INNERs \\
1388 Treat INNER as a non\dash inlinable part of OUTER, compile and
1389 call a distinct normal version of INNER defined within each
1390 inlining of OUTER.
1391
1392 \item Inline OUTER, one INNER \\
1393 Compile INNER as a single normal subprogram which is called
1394 from every inlining of OUTER.
1395 \end{enumerate}
1396
1397 This discussion does not consider why a compiler might choose
1398 one of these approaches; it considers only how to describe
1399 the result.
1400
1401 In the examples that follow in this section, the debugging
1402 information entries are given mnemonic labels of the following
1403 form
1404 \begin{verbatim}
1405     <io>.<ac>.<n>.<s>
1406 \end{verbatim}
1407 where
1408 \begin{description}
1409 \item[\textless io\textgreater]
1410 is either INNER or OUTER to indicate to which
1411 subprogram the debugging information entry applies, 
1412 \item[\textless ac\textgreater]
1413 is either AI or CI to indicate ``abstract instance'' or
1414 ``concrete instance'' respectively, 
1415 \item[\textless n\textgreater]
1416 is the number of the
1417 alternative being considered, and 
1418 \item[\textless s\textgreater]
1419 is a sequence number that
1420 distinguishes the individual entries. 
1421 \end{description}
1422 There is no implication
1423 that symbolic labels, nor any particular naming convention,
1424 are required in actual use.
1425
1426 For conciseness, declaration coordinates and call coordinates are omitted.
1427
1428 \subsection{Alternative \#1: inline both OUTER and INNER}
1429 \label{app:inlinebothouterandinner}
1430
1431 A suitable abstract instance for an alternative where both
1432 OUTER and INNER are always inlined is shown in 
1433 Figure \refersec{fig:inliningexample1abstractinstance}.
1434
1435 Notice in 
1436 Figure \refersec{fig:inliningexample1abstractinstance} 
1437 that the debugging information entry for
1438 INNER (labelled INNER.AI.1.1) is nested in (is a child of)
1439 that for OUTER (labelled OUTER.AI.1.1). Nonetheless, the
1440 abstract instance tree for INNER is considered to be separate
1441 and distinct from that for OUTER.
1442
1443 The call of OUTER shown in 
1444 Figure \refersec{fig:inliningexamplespseudosourcefragment}
1445 might be described as
1446 shown in 
1447 Figure \refersec{fig:inliningexample1concreteinstance}.
1448
1449
1450 \begin{figure}[p]
1451 \begin{dwflisting}
1452 \begin{alltt}
1453     ! Abstract instance for OUTER
1454     ! \addtoindexx{abstract instance!example}
1455 OUTER.AI.1.1:
1456     \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
1457         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("OUTER")
1458         \livelink{chap:DWATinline}{DW\-\_AT\-\_inline}(\livelink{chap:DWINLdeclaredinlined}{DW\-\_INL\-\_declared\-\_inlined})
1459         ! No low/high PCs
1460 OUTER.AI.1.2:
1461         \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1462             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("OUTER\_FORMAL")
1463             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to integer)
1464             ! No location
1465 OUTER.AI.1.3:
1466         \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1467             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("OUTER\_LOCAL")
1468             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to integer)
1469             ! No location
1470         !
1471         ! Abstract instance for INNER
1472         !
1473 INNER.AI.1.1:
1474         \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
1475             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("INNER")
1476             \livelink{chap:DWATinline}{DW\-\_AT\-\_inline}(\livelink{chap:DWINLdeclaredinlined}{DW\-\_INL\-\_declared\-\_inlined})
1477             ! No low/high PCs
1478 INNER.AI.1.2:
1479             \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1480                 \livelink{chap:DWATname}{DW\-\_AT\-\_name}("INNER\_FORMAL")
1481                 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to integer)
1482                 ! No location
1483 INNER.AI.1.3:
1484             \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1485                 \livelink{chap:DWATname}{DW\-\_AT\-\_name}("INNER\_LOCAL")
1486                 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to integer)
1487                 ! No location
1488             ...
1489             0
1490         ! No \livelink{chap:DWTAGinlinedsubroutine}{DW\-\_TAG\-\_inlined\-\_subroutine} (concrete instance)
1491         ! for INNER corresponding to calls of INNER
1492         ...
1493         0
1494 \end{alltt}
1495 \end{dwflisting}
1496 \caption{Inlining example \#1: abstract instance}
1497 \label{fig:inliningexample1abstractinstance}
1498 \end{figure}
1499
1500 \begin{figure}[p]
1501 \begin{dwflisting}
1502 \begin{alltt}
1503 ! Concrete instance for call "OUTER(7)"
1504 ! \addtoindexx{concrete instance!example}
1505 OUTER.CI.1.1:
1506     \livelink{chap:DWTAGinlinedsubroutine}{DW\-\_TAG\-\_inlined\-\_subroutine}
1507         ! No name
1508         \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to OUTER.AI.1.1)
1509         \livelink{chap:DWATlowpc}{DW\-\_AT\-\_low\-\_pc}(...)
1510         \livelink{chap:DWAThighpc}{DW\-\_AT\-\_high\-\_pc}(...)
1511 OUTER.CI.1.2:
1512         \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1513             ! No name
1514             \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to OUTER.AI.1.2)
1515             \livelink{chap:DWATconstvalue}{DW\-\_AT\-\_const\-\_value}(7)
1516 OUTER.CI.1.3:
1517         \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1518             ! No name
1519             \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to OUTER.AI.1.3)
1520             \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...)
1521         !
1522         ! No \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram} (abstract instance) for INNER
1523         !
1524         ! Concrete instance for call INNER(OUTER\_LOCAL)
1525         !
1526 INNER.CI.1.1:
1527         \livelink{chap:DWTAGinlinedsubroutine}{DW\-\_TAG\-\_inlined\-\_subroutine}
1528             ! No name
1529             \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to INNER.AI.1.1)
1530             \livelink{chap:DWATlowpc}{DW\-\_AT\-\_low\-\_pc}(...)
1531             \livelink{chap:DWAThighpc}{DW\-\_AT\-\_high\-\_pc}(...)
1532             \livelink{chap:DWATstaticlink}{DW\-\_AT\-\_static\-\_link}(...)
1533 INNER.CI.1.2:
1534             \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1535                 ! No name
1536                 \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to INNER.AI.1.2)
1537                 \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...)
1538 INNER.CI.1.3:
1539              \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1540                 ! No name
1541                 \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to INNER.AI.1.3)
1542                 \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...)
1543             ...
1544             0
1545         ! Another concrete instance of INNER within OUTER
1546         ! for the call "INNER(31)"
1547         ...
1548         0
1549 \end{alltt}
1550 \end{dwflisting}
1551 \caption{Inlining example \#1: concrete instance}
1552 \label{fig:inliningexample1concreteinstance}
1553 \end{figure}
1554
1555 \subsection{Alternative \#2: Inline OUTER, multiple INNERs}
1556 \label{app:inlineoutermultiipleinners}
1557
1558
1559 In the second alternative we assume that subprogram INNER
1560 is not inlinable for some reason, but subprogram OUTER is
1561 inlinable. 
1562 \addtoindexx{concrete instance!example}
1563 Each concrete inlined instance of OUTER has its
1564 own normal instance of INNER. 
1565 The abstract instance for OUTER,
1566 \addtoindexx{abstract instance!example}
1567 which includes INNER, is shown in 
1568 Figure \refersec{fig:inliningexample2abstractinstance}.
1569
1570 Note that the debugging information in this Figure differs from
1571 that in 
1572 Figure \refersec{fig:inliningexample1abstractinstance}
1573 in that INNER lacks a 
1574 \livelink{chap:DWATinline}{DW\-\_AT\-\_inline} attribute
1575 and therefore is not a distinct abstract instance. INNER
1576 is merely an out\dash of\dash line routine that is part of OUTER\textquoteright s
1577 abstract instance. This is reflected in the Figure by
1578 \addtoindexx{abstract instance!example}
1579 the fact that the labels for INNER use the substring OUTER
1580 instead of INNER.
1581
1582 A resulting 
1583 \addtoindexx{concrete instance!example}
1584 concrete inlined instance of OUTER is shown in
1585 Figure \refersec{fig:inliningexample2concreteinstance}.
1586
1587 Notice in 
1588 Figure \refersec{fig:inliningexample2concreteinstance}.
1589 that OUTER is expanded as a concrete
1590 \addtoindexx{concrete instance!example}
1591 inlined instance, and that INNER is nested within it as a
1592 concrete out\dash of\dash line subprogram. Because INNER is cloned
1593 for each inline expansion of OUTER, only the invariant
1594 attributes of INNER 
1595 (for example, \livelink{chap:DWATname}{DW\-\_AT\-\_name}) are specified
1596 in the abstract instance of OUTER, and the low\dash level,
1597 \addtoindexx{abstract instance!example}
1598 instance\dash specific attributes of INNER (for example,
1599 \livelink{chap:DWATlowpc}{DW\-\_AT\-\_low\-\_pc}) are specified in 
1600 each concrete instance of OUTER.
1601 \addtoindexx{concrete instance!example}
1602 The several calls of INNER within OUTER are compiled as normal
1603 calls to the instance of INNER that is specific to the same
1604 instance of OUTER that contains the calls.
1605
1606 \begin{figure}[t]
1607 \begin{dwflisting}
1608 \begin{alltt}
1609     ! Abstract instance for OUTER
1610     ! \addtoindex{abstract instance}
1611 OUTER.AI.2.1:
1612     \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
1613         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("OUTER")
1614         \livelink{chap:DWATinline}{DW\-\_AT\-\_inline}(\livelink{chap:DWINLdeclaredinlined}{DW\-\_INL\-\_declared\-\_inlined})
1615         ! No low/high PCs
1616 OUTER.AI.2.2:
1617         \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1618             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("OUTER\_FORMAL")
1619             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to integer)
1620             ! No location
1621 OUTER.AI.2.3:
1622         \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1623             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("OUTER\_LOCAL")
1624             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to integer)
1625             ! No location
1626         !
1627         ! Nested out-of-line INNER subprogram
1628         !
1629 OUTER.AI.2.4:
1630         \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
1631             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("INNER")
1632             ! No \livelink{chap:DWATinline}{DW\-\_AT\-\_inline}
1633             ! No low/high PCs, frame\_base, etc.
1634 OUTER.AI.2.5:
1635             \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1636                 \livelink{chap:DWATname}{DW\-\_AT\-\_name}("INNER\_FORMAL")
1637                 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to integer)
1638                 ! No location
1639 OUTER.AI.2.6:
1640             \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1641                 \livelink{chap:DWATname}{DW\-\_AT\-\_name}("INNER\_LOCAL")
1642                 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to integer)
1643                 ! No location
1644             ...
1645             0
1646         ...
1647         0
1648 \end{alltt}
1649 \end{dwflisting}
1650 \caption{Inlining example \#2: abstract instance}
1651 \label{fig:inliningexample2abstractinstance}
1652 \end{figure}
1653
1654 \begin{figure}[t]
1655 \begin{dwflisting}
1656 \begin{alltt}
1657
1658     ! Concrete instance for call "OUTER(7)"
1659     !
1660 OUTER.CI.2.1:
1661     \livelink{chap:DWTAGinlinedsubroutine}{DW\-\_TAG\-\_inlined\-\_subroutine}
1662         ! No name
1663         \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to OUTER.AI.2.1)
1664         \livelink{chap:DWATlowpc}{DW\-\_AT\-\_low\-\_pc}(...)
1665         \livelink{chap:DWAThighpc}{DW\-\_AT\-\_high\-\_pc}(...)
1666 OUTER.CI.2.2:
1667         \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1668             ! No name
1669             \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to OUTER.AI.2.2)
1670             \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...)
1671 OUTER.CI.2.3:
1672         \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1673             ! No name
1674             \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to OUTER.AI.2.3)
1675             \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...)
1676         !
1677         ! Nested out-of-line INNER subprogram
1678         !
1679 OUTER.CI.2.4:
1680         \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
1681             ! No name
1682             \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to OUTER.AI.2.4)
1683             \livelink{chap:DWATlowpc}{DW\-\_AT\-\_low\-\_pc}(...)
1684             \livelink{chap:DWAThighpc}{DW\-\_AT\-\_high\-\_pc}(...)
1685             \livelink{chap:DWATframebase}{DW\-\_AT\-\_frame\-\_base}(...)
1686             \livelink{chap:DWATstaticlink}{DW\-\_AT\-\_static\-\_link}(...)
1687 OUTER.CI.2.5:
1688             \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1689                 ! No name
1690                 \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to OUTER.AI.2.5)
1691                 \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...)
1692 OUTER.CI.2.6:
1693             \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1694                 ! No name
1695                 \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to OUTER.AT.2.6)
1696                 \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...)
1697             ...
1698             0
1699         ...
1700         0
1701 \end{alltt}
1702 \end{dwflisting}
1703 \caption{Inlining example \#2: concrete instance}
1704 \label{fig:inliningexample2concreteinstance}
1705 \end{figure}
1706
1707 \subsection{Alternative \#3: inline OUTER, one normal INNER}
1708 \label{app:inlineouteronenormalinner}
1709
1710 In the third approach, one normal subprogram for INNER is
1711 compiled which is called from all concrete inlined instances of
1712 \addtoindexx{concrete instance!example}
1713 \addtoindexx{abstract instance!example}
1714 OUTER. The abstract instance for OUTER is shown in 
1715 Figure \refersec{fig:inliningexample3abstractinstance}.
1716
1717 The most distinctive aspect of that Figure is that subprogram
1718 INNER exists only within the abstract instance of OUTER,
1719 and not in OUTER\textquoteright s concrete instance. In the abstract
1720 \addtoindexx{concrete instance!example}
1721 \addtoindexx{abstract instance!example}
1722 instance of OUTER, the description of INNER has the full
1723 complement of attributes that would be expected for a
1724 normal subprogram. 
1725 While attributes such as 
1726 \livelink{chap:DWATlowpc}{DW\-\_AT\-\_low\-\_pc},
1727 \livelink{chap:DWAThighpc}{DW\-\_AT\-\_high\-\_pc}, 
1728 \livelink{chap:DWATlocation}{DW\-\_AT\-\_location},
1729 and so on, typically are omitted
1730 \addtoindexx{high PC attribute}
1731 from 
1732 \addtoindexx{low PC attribute}
1733 an 
1734 \addtoindexx{location attribute}
1735 abstract instance because they are not invariant across
1736 instances of the containing abstract instance, in this case
1737 those same attributes are included precisely because they are
1738 invariant -- there is only one subprogram INNER to be described
1739 and every description is the same.
1740
1741 A concrete inlined instance of OUTER is illustrated in
1742 Figure \refersec{fig:inliningexample3concreteinstance}.
1743
1744 Notice in 
1745 Figure \refersec{fig:inliningexample3abstractinstance}
1746 that there is no DWARF representation for
1747 INNER at all; the representation of INNER does not vary across
1748 instances of OUTER and the abstract instance of OUTER includes
1749 the complete description of INNER, so that the description of
1750 INNER may be (and for reasons of space efficiency, should be)
1751 omitted from each 
1752 \addtoindexx{concrete instance!example}
1753 concrete instance of OUTER.
1754
1755 There is one aspect of this approach that is problematical from
1756 the DWARF perspective. The single compiled instance of INNER
1757 is assumed to access up\dash level variables of OUTER; however,
1758 those variables may well occur at varying positions within
1759 the frames that contain the 
1760 \addtoindexx{concrete instance!example}
1761 concrete inlined instances. A
1762 compiler might implement this in several ways, including the
1763 use of additional compiler generated parameters that provide
1764 reference parameters for the up\dash level variables, or a compiler
1765 generated static link like parameter that points to the group
1766 of up\dash level entities, among other possibilities. In either of
1767 these cases, the DWARF description for the location attribute
1768 of each uplevel variable needs to be different if accessed
1769 from within INNER compared to when accessed from within the
1770 instances of OUTER. An implementation is likely to require
1771 vendor\dash specific DWARF attributes and/or debugging information
1772 entries to describe such cases.
1773
1774 Note that in C++, a member function of a class defined within
1775 a function definition does not require any vendor\dash specific
1776 extensions because the C++ language disallows access to
1777 entities that would give rise to this problem. (Neither extern
1778 variables nor static members require any form of static link
1779 for accessing purposes.)
1780
1781 \begin{figure}[t]
1782 \begin{dwflisting}
1783 \begin{alltt}
1784     ! Abstract instance for OUTER
1785     ! \addtoindexx{abstract instance!example}
1786 OUTER.AI.3.1:
1787     \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
1788         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("OUTER")
1789         \livelink{chap:DWATinline}{DW\-\_AT\-\_inline}(\livelink{chap:DWINLdeclaredinlined}{DW\-\_INL\-\_declared\-\_inlined})
1790         ! No low/high PCs
1791 OUTER.AI.3.2:
1792         \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1793             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("OUTER\_FORMAL")
1794             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to integer)
1795             ! No location
1796 OUTER.AI.3.3:
1797         \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1798             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("OUTER\_LOCAL")
1799             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to integer)
1800             ! No location
1801         !
1802         ! Normal INNER
1803         !
1804 OUTER.AI.3.4:
1805         \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
1806             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("INNER")
1807             \livelink{chap:DWATlowpc}{DW\-\_AT\-\_low\-\_pc}(...)
1808             \livelink{chap:DWAThighpc}{DW\-\_AT\-\_high\-\_pc}(...)
1809             \livelink{chap:DWATframebase}{DW\-\_AT\-\_frame\-\_base}(...)
1810             \livelink{chap:DWATstaticlink}{DW\-\_AT\-\_static\-\_link}(...)
1811 OUTER.AI.3.5:
1812             \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1813                 \livelink{chap:DWATname}{DW\-\_AT\-\_name}("INNER\_FORMAL")
1814                 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to integer)
1815                 \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...)
1816 OUTER.AI.3.6:
1817             \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1818                 \livelink{chap:DWATname}{DW\-\_AT\-\_name}("INNER\_LOCAL")
1819                 \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to integer)
1820                 \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...)
1821             ...
1822             0
1823         ...
1824         0
1825 \end{alltt}
1826 \end{dwflisting}
1827 \caption{Inlining example \#3: abstract instance}
1828 \label{fig:inliningexample3abstractinstance}
1829 \end{figure}
1830
1831 \begin{figure}[t]
1832 \begin{dwflisting}
1833 \begin{alltt}
1834     ! Concrete instance for call "OUTER(7)"
1835     ! \addtoindexx{concrete instance!example}
1836 OUTER.CI.3.1:
1837     \livelink{chap:DWTAGinlinedsubroutine}{DW\-\_TAG\-\_inlined\-\_subroutine}
1838         ! No name
1839         \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to OUTER.AI.3.1)
1840         \livelink{chap:DWATlowpc}{DW\-\_AT\-\_low\-\_pc}(...)
1841         \livelink{chap:DWAThighpc}{DW\-\_AT\-\_high\-\_pc}(...)
1842         \livelink{chap:DWATframebase}{DW\-\_AT\-\_frame\-\_base}(...)
1843 OUTER.CI.3.2:
1844         \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1845             ! No name
1846             \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to OUTER.AI.3.2)
1847             ! No type
1848             \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...)
1849 OUTER.CI.3.3:
1850         \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1851             ! No name
1852             \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to OUTER.AI.3.3)
1853             ! No type
1854             \livelink{chap:DWATlocation}{DW\-\_AT\-\_location}(...)
1855         ! No \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram} for "INNER"
1856         ...
1857         0
1858 \end{alltt}
1859 \end{dwflisting}
1860 \caption{Inlining example \#3: concrete instance}
1861 \label{fig:inliningexample3concreteinstance}
1862 \end{figure}
1863
1864 \clearpage
1865 \section{Constant Expression Example}
1866 \label{app:constantexpressionexample}
1867 C++ generalizes the notion of constant expressions to include
1868 constant expression user-defined literals and functions.
1869 The constant declarations in Figure \refersec{fig:constantexpressionscsource}
1870 can be represented as illustrated in 
1871 Figure \refersec{fig:constantexpressionsdwarfdescription}.
1872
1873
1874 \begin{figure}[here]
1875 \begin{lstlisting}[numbers=none]
1876 constexpr double mass = 9.8;
1877 constexpr int square (int x) { return x * x; }
1878 float arr[square(9)]; // square() called and inlined
1879 \end{lstlisting}
1880 \caption{Constant expressions: C++ source} \label{fig:constantexpressionscsource}
1881 \end{figure}
1882
1883
1884 \begin{figure}[!h]
1885 \begin{dwflisting}
1886 \begin{alltt}
1887         ! For variable mass
1888         !
1889 1\$:     \livelink{chap:DWTAGconsttype}{DW\-\_TAG\-\_const\-\_type}
1890             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "double")
1891 2\$:     \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1892             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("mass")
1893             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
1894             \livelink{chap:DWATconstexpr}{DW\-\_AT\-\_const\-\_expr}(true)
1895             \livelink{chap:DWATconstvalue}{DW\-\_AT\-\_const\-\_value}(9.8)
1896         ! Abstract instance for square
1897         !
1898 10\$:    \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
1899             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("square")
1900             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "int")
1901             \livelink{chap:DWATinline}{DW\-\_AT\-\_inline}(\livelink{chap:DWINLinlined}{DW\-\_INL\-\_inlined})
1902 11\$:    \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1903             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("x")
1904             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "int")
1905         ! Concrete instance for square(9)
1906         ! \addtoindexx{concrete instance!example}
1907 20\$:    \livelink{chap:DWTAGinlinedsubroutine}{DW\-\_TAG\-\_inlined\-\_subroutine}
1908             \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to 10\$)
1909             \livelink{chap:DWATconstexpr}{DW\-\_AT\-\_const\-\_expr}(present)
1910             \livelink{chap:DWATconstvalue}{DW\-\_AT\-\_const\-\_value}(81)
1911         \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
1912             \livelink{chap:DWATabstractorigin}{DW\-\_AT\-\_abstract\-\_origin}(reference to 11\$)
1913             \livelink{chap:DWATconstvalue}{DW\-\_AT\-\_const\-\_value}(9)
1914         ! Anonymous array type for arr
1915         !
1916 30\$:    \livelink{chap:DWTAGarraytype}{DW\-\_TAG\-\_array\-\_type}
1917         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "float")
1918             \livelink{chap:DWATbytesize}{DW\-\_AT\-\_byte\-\_size}(324) ! 81*4
1919         \livelink{chap:DWTAGsubrangetype}{DW\-\_TAG\-\_subrange\-\_type}
1920             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "int")
1921             \livelink{chap:DWATupperbound}{DW\-\_AT\-\_upper\-\_bound}(reference to 20\$)
1922         ! Variable arr
1923         !
1924 40\$:    \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1925             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("arr")
1926             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 30\$)
1927 \end{alltt}
1928 \end{dwflisting}
1929 \caption{Constant expressions: DWARF description}
1930 \label{fig:constantexpressionsdwarfdescription}
1931 \end{figure}
1932
1933 \section{Unicode Character Example}
1934 \label{app:unicodecharacterexample}
1935 \addtoindexx{Unicode|see {\textit{also} UTF-8}}
1936 The \addtoindex{Unicode} character encodings in
1937 Figure \refersec{fig:unicodecharacterexamplesource}
1938 can be described in DWARF as illustrated in 
1939 Figure \refersec{fig:unicodecharacterexampledwarfdescription}.
1940
1941 \begin{figure}[!h]
1942 \begin{lstlisting}[numbers=none]
1943 // C++ source
1944 //
1945 char16_t chr_a = u'h';
1946 char32_t chr_b = U'h';
1947 \end{lstlisting}
1948 \caption{Unicode character example: source}
1949 \label{fig:unicodecharacterexamplesource}
1950 \end{figure}
1951
1952 \begin{figure}[h]
1953 \begin{dwflisting}
1954 \begin{alltt}
1955
1956 ! DWARF description
1957 !
1958 1\$: \livelink{chap:DWTAGbasetype}{DW\-\_TAG\-\_base\-\_type}
1959         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("char16\_t")
1960         \livelink{chap:DWATencoding}{DW\-\_AT\-\_encoding}(\livelink{chap:DWATEUTF}{DW\-\_ATE\-\_UTF})
1961         \livelink{chap:DWATbytesize}{DW\-\_AT\-\_byte\-\_size}(2)
1962 2\$: \livelink{chap:DWTAGbasetype}{DW\-\_TAG\-\_base\-\_type}
1963         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("char32\_t")
1964         \livelink{chap:DWATencoding}{DW\-\_AT\-\_encoding}(\livelink{chap:DWATEUTF}{DW\-\_ATE\-\_UTF})
1965         \livelink{chap:DWATbytesize}{DW\-\_AT\-\_byte\-\_size}(4)
1966 3\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1967         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("chr\_a")
1968         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 1\$)
1969 4\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
1970         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("chr\_b")
1971         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 2\$)
1972 \end{alltt}
1973 \end{dwflisting}
1974 \caption{Unicode character example: DWARF description}
1975 \label{fig:unicodecharacterexampledwarfdescription}
1976 \end{figure}
1977
1978
1979 \section{Type-Safe Enumeration Example}
1980 \label{app:typesafeenumerationexample}
1981
1982 The \addtoindex{C++} type\dash safe enumerations in
1983 \addtoindexx{type-safe enumeration}
1984 Figure \refersec{fig:ctypesafeenumerationexamplesource}
1985 can be described in DWARF as illustrated in 
1986 Figure \refersec{fig:ctypesafeenumerationexampledwarf}.
1987
1988 \begin{figure}[H]
1989 \begin{lstlisting}[numbers=none]
1990 // C++ source
1991 //
1992 enum class E { E1, E2=100 };
1993 E e1;
1994 \end{lstlisting}
1995 \caption{Type-safe enumeration example: source}
1996 \label{fig:ctypesafeenumerationexamplesource}
1997 \end{figure}
1998
1999 \begin{figure}[H]
2000 \begin{dwflisting}
2001 \begin{alltt}
2002 ! DWARF description
2003 !
2004 11\$: \livelink{chap:DWTAGenumerationtype}{DW\-\_TAG\-\_enumeration\-\_type}
2005         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("E")
2006         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "int")
2007         \livelink{chap:DWATenumclass}{DW\-\_AT\-\_enum\-\_class}(present)
2008 12\$:   \livelink{chap:DWTAGenumerator}{DW\-\_TAG\-\_enumerator}
2009             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("E1")
2010             \livelink{chap:DWATconstvalue}{DW\-\_AT\-\_const\-\_value}(0)
2011 13\$:
2012          \livelink{chap:DWTAGenumerator}{DW\-\_TAG\-\_enumerator}
2013             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("E2")
2014             \livelink{chap:DWATconstvalue}{DW\-\_AT\-\_const\-\_value}(100)
2015 14\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
2016         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("e1")
2017         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 11\$)
2018 \end{alltt}
2019 \end{dwflisting}
2020 \caption{Type-safe enumeration example: DWARF description}
2021 \label{fig:ctypesafeenumerationexampledwarf}
2022 \end{figure}
2023
2024
2025 \clearpage
2026 \section{Template Examples}
2027 \label{app:templateexample}
2028
2029 The C++ template example in
2030 Figure \refersec{fig:ctemplateexample1source}
2031 can be described in DWARF as illustrated in 
2032 Figure \refersec{fig:ctemplateexample1dwarf}.
2033
2034 \begin{figure}[h]
2035 \begin{lstlisting}
2036 // C++ source
2037 //
2038 template<class T>
2039 struct wrapper {
2040     T comp;
2041 };
2042 wrapper<int> obj;
2043 \end{lstlisting}
2044 \caption{C++ template example \#1: source}
2045 \label{fig:ctemplateexample1source}
2046 \end{figure}
2047
2048 \begin{figure}[h]
2049 \begin{dwflisting}
2050 \begin{alltt}
2051 ! DWARF description
2052 !
2053 11\$: \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type}
2054         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("wrapper")
2055 12\$: \livelink{chap:DWTAGtemplatetypeparameter}{DW\-\_TAG\-\_template\-\_type\-\_parameter}
2056         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("T")
2057         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "int")
2058 13\$ \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
2059         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("comp")
2060         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 12\$)
2061 14\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
2062         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("obj")
2063         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 11\$)
2064 \end{alltt}
2065 \end{dwflisting}
2066 \caption{C++ template example \#1: DWARF description}
2067 \label{fig:ctemplateexample1dwarf}
2068 \end{figure}
2069
2070 The actual type of the component comp is int, but in the DWARF
2071 the type references the
2072 \livelink{chap:DWTAGtemplatetypeparameter}{DW\-\_TAG\-\_template\-\_type\-\_parameter}
2073 for T, which in turn references int. This implies that in the
2074 original template comp was of type T and that was replaced
2075 with int in the instance. There exist situations where it is
2076 not possible for the DWARF to imply anything about the nature
2077 of the original template. 
2078
2079 \needlines{10}
2080 Consider the C++ template source in
2081 Figure \refersec{fig:ctemplateexample2source}
2082 and the DWARF that can describe it in
2083 Figure \refersec{fig:ctemplateexample2dwarf}.
2084
2085 \begin{figure}[!h]
2086 \begin{lstlisting}
2087 // C++ source
2088 //
2089     template<class T>
2090     struct wrapper {
2091         T comp;
2092     };
2093     template<class U>
2094     void consume(wrapper<U> formal)
2095     {
2096         ...
2097     }
2098     wrapper<int> obj;
2099     consume(obj);
2100 \end{lstlisting}
2101 \caption{C++ template example \#2: source}
2102 \label{fig:ctemplateexample2source}
2103 \end{figure}
2104
2105 \begin{figure}[h]
2106 \begin{dwflisting}
2107 \begin{alltt}
2108 ! DWARF description
2109 !
2110 11\$: \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type}
2111         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("wrapper")
2112 12\$:   \livelink{chap:DWTAGtemplatetypeparameter}{DW\-\_TAG\-\_template\-\_type\-\_parameter}
2113             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("T")
2114             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "int")
2115 13\$    \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
2116             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("comp")
2117             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 12\$)
2118 14\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
2119         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("obj")
2120         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 11\$)
2121 21\$: \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram}
2122         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("consume")
2123 22\$:   \livelink{chap:DWTAGtemplatetypeparameter}{DW\-\_TAG\-\_template\-\_type\-\_parameter}
2124             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("U")
2125             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "int")
2126 23\$:   \livelink{chap:DWTAGformalparameter}{DW\-\_TAG\-\_formal\-\_parameter}
2127             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("formal")
2128             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 11\$)
2129 \end{alltt}
2130 \end{dwflisting}
2131 \caption{C++ template example \#2: DWARF description}
2132 \label{fig:ctemplateexample2dwarf}
2133 \end{figure}
2134
2135 In the \livelink{chap:DWTAGsubprogram}{DW\-\_TAG\-\_subprogram} 
2136 entry for the instance of consume, U is described as int. 
2137 The type of formal is \texttt{wrapper\textless U\textgreater} in
2138 the source. DWARF only represents instantiations of templates;
2139 there is no entry which represents \texttt{wrapper\textless U\textgreater} 
2140 which is neither
2141 a template parameter nor a template instantiation. The type
2142 of formal is described as \texttt{wrapper\textless int\textgreater},
2143 the instantiation of \texttt{wrapper\textless U\textgreater},
2144 in the \livelink{chap:DWATtype}{DW\-\_AT\-\_type} attribute at 
2145 23\$. 
2146 There is no
2147 description of the relationship between template type parameter
2148 T at 12\$ and U at 22\$ which was used to instantiate
2149 \texttt{wrapper\textless U\textgreater}.
2150
2151 A consequence of this is that the DWARF information would
2152 not distinguish between the existing example and one where
2153 the formal of consume were declared in the source to be
2154 \texttt{wrapper\textless int\textgreater}.
2155
2156
2157 \section{Template Alias Examples}
2158 \label{app:templatealiasexample}
2159
2160 The \addtoindex{C++} template alias shown in
2161 Figure \refersec{fig:ctemplatealiasexample1source}
2162 can be described in DWARF as illustrated 
2163 \addtoindexx{template alias example} in 
2164 Figure \refersec{fig:ctemplatealiasexample1dwarf}.
2165
2166 \begin{figure}[h]
2167 \begin{lstlisting}
2168 // C++ source, template alias example 1
2169 //
2170 template<typename T, typename U>
2171 struct Alpha {
2172     T tango;
2173     U uniform;
2174 };
2175 template<typename V> using Beta = Alpha<V,V>;
2176 Beta<long> b;
2177 \end{lstlisting}
2178 \caption{C++ template alias example \#1: source}
2179 \label{fig:ctemplatealiasexample1source}
2180 \end{figure}
2181
2182 \begin{figure}[h]
2183 \addtoindexx{template alias example 1}
2184 \begin{dwflisting}
2185 \begin{alltt}
2186 ! DWARF representation for variable 'b'
2187 !
2188 20\$: \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type}
2189         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("Alpha")
2190 21\$:   \livelink{chap:DWTAGtemplatetypeparameter}{DW\-\_TAG\-\_template\-\_type\-\_parameter}
2191             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("T")
2192             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "long")
2193 22\$:   \livelink{chap:DWTAGtemplatetypeparameter}{DW\-\_TAG\-\_template\-\_type\-\_parameter}
2194             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("U")
2195             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "long")
2196 23\$:   \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
2197             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("tango")
2198             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 21\$)
2199 24\$:   \livelink{chap:DWTAGmember}{DW\-\_TAG\-\_member}
2200             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("uniform")
2201             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 22\$)
2202 25\$: \livelink{chap:DWTAGtemplatealias}{DW\-\_TAG\-\_template\-\_alias}
2203         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("Beta")
2204         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 20\$)
2205 26\$:   \livelink{chap:DWTAGtemplatetypeparameter}{DW\-\_TAG\-\_template\-\_type\-\_parameter}
2206             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("V")
2207             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "long")
2208 27\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
2209         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("b")
2210         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 25\$)
2211 \end{alltt}
2212 \end{dwflisting}
2213 \caption{C++ template alias example \#1: DWARF description}
2214 \label{fig:ctemplatealiasexample1dwarf}
2215 \end{figure}
2216
2217 Similarly, the \addtoindex{C++} template alias shown in
2218 Figure \refersec{fig:ctemplatealiasexample2source}
2219 can be described in DWARF as illustrated 
2220 \addtoindexx{template alias example} in 
2221 Figure \refersec{fig:ctemplatealiasexample2dwarf}.
2222
2223 \begin{figure}[h]
2224 \begin{lstlisting}
2225 // C++ source, template alias example 2
2226 //
2227 template<class TX> struct X { };
2228 template<class TY> struct Y { };
2229 template<class T> using Z = Y<T>;
2230 X<Y<int>> y;
2231 X<Z<int>> z;
2232 \end{lstlisting}
2233 \caption{C++ template alias example \#2: source}
2234 \label{fig:ctemplatealiasexample2source}
2235 \end{figure}
2236
2237 \begin{figure}[h]
2238 \addtoindexx{template alias example 2}
2239 \begin{dwflisting}
2240 \begin{alltt}
2241 ! DWARF representation for X<Y<int>>
2242 !
2243 30\$: \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type}
2244         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("Y")
2245 31\$:   \livelink{chap:DWTAGtemplatetypeparameter}{DW\-\_TAG\-\_template\-\_type\-\_parameter}
2246             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("TY")
2247             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "int")
2248 32\$: \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type}
2249         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("X")
2250 33\$:   \livelink{chap:DWTAGtemplatetypeparameter}{DW\-\_TAG\-\_template\-\_type\-\_parameter}
2251             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("TX")
2252             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 30\$)
2253
2254 ! DWARF representation for X<Z<int>>
2255 !
2256 40\$: \livelink{chap:DWTAGtemplatealias}{DW\-\_TAG\-\_template\-\_alias}
2257 using Z = Y<int>;
2258         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("Z")
2259         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 30\$)
2260 41\$:   \livelink{chap:DWTAGtemplatetypeparameter}{DW\-\_TAG\-\_template\-\_type\-\_parameter}
2261             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("T")
2262             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to "int")
2263 42\$: \livelink{chap:DWTAGstructuretype}{DW\-\_TAG\-\_structure\-\_type}
2264         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("X")
2265 43\$:   \livelink{chap:DWTAGtemplatetypeparameter}{DW\-\_TAG\-\_template\-\_type\-\_parameter}
2266             \livelink{chap:DWATname}{DW\-\_AT\-\_name}("TX")
2267             \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to 40\$)
2268 ! Note that 32\$ and 42\$ are actually the same type
2269 !
2270 50\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
2271         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("y")
2272         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to \$32)
2273 51\$: \livelink{chap:DWTAGvariable}{DW\-\_TAG\-\_variable}
2274         \livelink{chap:DWATname}{DW\-\_AT\-\_name}("z")
2275         \livelink{chap:DWATtype}{DW\-\_AT\-\_type}(reference to \$42)
2276 \end{alltt}
2277 \end{dwflisting}
2278 \caption{C++ template alias example \#2: DWARF description}
2279 \label{fig:ctemplatealiasexample2dwarf}
2280 \end{figure}