1 \chapter{Other Debugging Information}
2 \label{chap:otherdebugginginformation}
3 % references to chapter 7 look like {datarep:...}
4 This section describes debugging information that is not
5 represented in the form of debugging information entries and
6 is not contained within a \dotdebuginfo{} section.
8 In the descriptions that follow, these terms are used to
9 specify the representation of DWARF sections:
12 \HFTinitiallength{}, \HFTsectionoffset{} and
13 \HFTsectionlength{}, which are
15 Sections \refersec{datarep:initiallengthvalues} and
16 \refersec{datarep:32bitand64bitdwarfformats}.
23 Section \refersec{datarep:integerrepresentationnames}.
26 \section{Accelerated Access}
27 \label{chap:acceleratedaccess}
29 \textit{A debugger frequently needs to find the debugging information
30 \addtoindexx{accelerated access}
31 for a program entity defined outside of the compilation unit
32 where the debugged program is currently stopped. Sometimes the
33 debugger will know only the name of the entity; sometimes only
34 the address. To find the debugging information associated with
35 a global entity by name, using the DWARF debugging information
36 entries alone, a debugger would need to run through all
37 entries at the highest scope within each compilation unit.}
39 \textit{Similarly, in languages in which the name of a type is
40 required to always refer to the same concrete type (such as
41 C++), a compiler may choose to elide type definitions in
42 all compilation units except one. In this case a debugger
43 needs a rapid way of locating the concrete type definition
44 by name. As with the definition of global data objects, this
45 would require a search of all the top level type definitions
46 of all compilation units in a program.}
49 \textit{To find the debugging information associated with a subroutine,
50 given an address, a debugger can use the low and high PC
51 attributes of the compilation unit entries to quickly narrow
52 down the search, but these attributes only cover the range
53 of addresses for the text associated with a compilation unit
54 entry. To find the debugging information associated with a
55 data object, given an address, an exhaustive search would be
56 needed. Furthermore, any search through debugging information
57 entries for different compilation units within a large program
58 would potentially require the access of many memory pages,
59 probably hurting debugger performance.}
61 To make lookups of program entities (including data objects,
62 functions and types) by name or by address faster, a producer
63 of DWARF information may provide two different types of tables
64 containing information about the debugging information
65 entries owned by a particular compilation unit entry in a
66 more condensed format.
68 \subsection{Lookup by Name}
69 \addtoindexx{lookup!by name}
70 \addtoindexx{accelerated access!by name}
71 For lookup by name, a name index is maintained in a separate
72 object file section named \dotdebugnames{}.
74 \textit{The \dotdebugnames{} section is new in \DWARFVersionV,
75 and supersedes the \dotdebugpubnames{} and \dotdebugpubtypes{}
76 sections of earlier DWARF versions. While \dotdebugnames{} and
77 either \dotdebugpubnames{} and/or \dotdebugpubtypes{} sections
78 cannot both occur in the same compilation unit, both may be
79 found in the set of units that make up an executable or shared
83 primarily of two parts: a list of names, and a list of index
84 entries. A name, such as a subprogram name, type name, or
85 variable name, may have several defining declarations in the
86 debugging information. In this case, the entry for that name in
87 the list of names will refer to a sequence of index entries in
88 the second part of the table, each corresponding to one defining
89 declaration in the \dotdebuginfo{} section.
91 The name index may also contain an optional hash table for faster
94 A relocatable object file may contain a "per-CU" index, which
95 provides an index to the names defined in that compilation
98 An executable or shareable object file may contain either a collection of
99 "per-CU" indexes, simply copied from each relocatable object
100 file, or the linker may produce a "per-module" index by
101 combining the per-CU indexes into a single index that covers
102 the entire load module.
104 \subsubsection{Contents of the Name Index}
105 \label{chap:contentsofthenameindex}
106 The name index must contain an entry for each
107 debugging information entry that defines a
108 named subprogram, label, variable, type, or namespace,
109 subject to the following rules:
112 \item All non-defining declarations (that is,
113 debugging information entries with a
114 \DWATdeclaration{} attribute) are excluded.
116 \item \DWTAGnamespace{} debugging information entries
117 without a \DWATname{} attribute are
118 included with the name
119 \doublequote{\texttt{(anonymous namespace)}}.
121 \item All other debugging information entries
122 without a \DWATname{} attribute are excluded.
124 \item \DWTAGsubprogram{}, \DWTAGinlinedsubroutine{}, and
125 \DWTAGlabel{} debugging information entries
126 without an address attribute (\DWATlowpc{},
127 \DWAThighpc{}, \DWATranges{}, or \DWATentrypc{})
130 \item \DWTAGvariable{} debugging information entries
131 with a \DWATlocation{} attribute that includes a
132 \DWOPaddr{} or \DWOPformtlsaddress{} operator are
133 included; otherwise, they are excluded.
135 \item If a subprogram or inlined subroutine is included, and has a
136 \DWATlinkagename{} attribute, there will be an additional
137 index entry for the linkage name.
141 For the purposes of determining whether a
142 debugging information entry has a particular
143 attribute (such as \DWATname{}), if
144 debugging information entry $A$ has a \DWATspecification{}
145 or \DWATabstractorigin{} attribute pointing to another
146 debugging information entry $B$, any
147 attributes of $B$ are considered to be part of $A$.
149 \textit{The intent of the above rules is to provide the consumer with
150 some assurance that looking up an unqualified name in the index
151 will yield all relevant debugging information entries
152 that provide a defining declaration
153 at global scope for that name.}
155 \textit{A producer may choose to implement additional rules for what
156 names are placed in the index, and may communicate those rules to
157 a cooperating consumer via an augmentation string, described
161 \subsubsection{Structure of the Name Index}
162 \label{chap:structureofthenametindex}
163 Logically, the name index can be viewed as a list of names,
164 with a list of index entries for each name. Each index entry
165 corresponds to a debugging information entry
166 that matches the criteria given in the previous section. For
167 example, if one compilation unit has a function named \texttt{fred}
168 and another has a struct named \texttt{fred}, a lookup for
169 \doublequote{fred} will find the list containing those two index
172 The index section contains eight individual parts, as illustrated in
173 Figure \referfol{fig:nameindexlayoutpart1}.
175 \item A header, describing the layout of the section.
177 \item A list of compile units (CUs) referenced by this index.
179 \item A list of local type units (TUs) referenced by this index
180 that are present in this object file.
182 \item A list of foreign type units (TUs) referenced by this index
183 that are not present in this object file (that is, that have
184 been placed in a \splitDWARFobjectfile{} as described in
185 \refersec{datarep:splitdwarfobjectfiles}).
187 \item An optional hash lookup table.
189 \item The name table.
191 \item An abbreviations table, similar to the one used by the
192 \dotdebuginfo{} section.
194 \item The entry pool, containing a list of index entries for each
195 name in the name list.
201 %\includegraphics[keepaspectratio=true,scale=1.0]{name-index-drawings-6p1}
204 every node/.style={node font=\small, anchor=north west, text height=.8em, text depth=.2em, inner sep=4pt, outer ysep=0},
205 caption/.style={node font=\small \bfseries, text width=90pt},
206 overview/.style={draw, node font=\small, minimum height=28pt, text width=80pt},
207 detail1/.style={draw, minimum height=14pt, text width=116pt},
208 detail2/.style={draw, minimum height=28pt, text width=116pt},
209 detail3/.style={draw, minimum height=48pt, text width=116pt},
210 detail4/.style={draw, minimum height=72pt, text width=116pt},
211 ellip/.style={draw, shape=broken rectangle, minimum height=14pt, text width=116pt},
212 explode/.style={draw=black!50, fill=black!20, line join=bevel},
213 header/.style={fill=headerblue},
214 culist/.style={fill=cutuyellow},
215 buckets/.style={fill=bucketsblue},
216 hashes/.style={fill=hashesgreen},
217 stroffsets/.style={fill=stroffsetspink},
218 entryoffsets/.style={fill=entryoffsetspink},
219 indexentries/.style={fill=indexentriesorange}
222 % Name Table Overview
224 \begin{scope}[start chain=going below, node distance=0]
225 \node [on chain,caption] {Name Index};
226 \node (header) [on chain,overview,header] {Header};
227 \node (culist) [on chain,overview,header] {CU List};
228 \node (ltulist) [on chain,overview,header] {Local TU List};
229 \node (ftulist) [on chain,overview,header] {Foreign TU List};
230 \node (hash) [on chain,overview,header] {Hash Table};
231 \node (names) [on chain,overview,header] {Name Table};
232 \node (abbrev) [on chain,overview,header] {Abbrev Table};
233 \node (pool) [on chain,overview,header] {Entry Pool};
236 % Exploded View of CU List
238 \begin{scope}[start chain=going below, node distance=0, shift={($(header.north east) + (72pt,18pt)$)}]
239 \node (cu0) [on chain,detail1,culist] {offset to CU 0};
240 \node (cu1) [on chain,detail1,culist] {offset to CU 1};
241 \node (cu2) [on chain,ellip,culist] {\dots};
242 \node (cu3) [on chain,detail1,culist] {offset to CU $k - 1$};
245 \begin{scope}[on background layer]
246 \filldraw [explode] (culist.north east) -- (cu0.north west) -- (cu3.south west) -- (culist.south east) -- cycle;
249 \path [decoration={brace,amplitude=6pt}] ([xshift=9pt]cu0.north east)
250 [draw,decorate] -- ([xshift=9pt]cu3.south east)
251 node [midway,right,inner xsep=9pt] {\texttt{comp\_unit\_count} $(= k)$};
253 % Exploded View of Local TU List
255 \begin{scope}[start chain=going below, node distance=0, shift={($(cu3.south west) + (0,-9pt)$)}]
256 \node (ltu0) [on chain,detail1,culist] {offset to TU 0};
257 \node (ltu1) [on chain,detail1,culist] {offset to TU 1};
258 \node (ltu2) [on chain,ellip,culist] {\dots};
259 \node (ltu3) [on chain,detail1,culist] {offset to TU $t - 1$};
262 \begin{scope}[on background layer]
263 \filldraw [explode] (ltulist.north east) -- (ltu0.north west) -- (ltu3.south west) -- (ltulist.south east) -- cycle;
266 \path [decoration={brace,amplitude=6pt}] ([xshift=9pt]ltu0.north east)
267 [draw,decorate] -- ([xshift=9pt]ltu3.south east)
268 node [midway,right,inner xsep=9pt] {\texttt{local\_type\_unit\_count} $(= t)$};
270 % Exploded View of Foreign TU List
272 \begin{scope}[start chain=going below, node distance=0, shift={($(ltu3.south west) + (0,-9pt)$)}]
273 \node (ftu0) [on chain,detail1,culist] {signature of TU $t$};
274 \node (ftu1) [on chain,detail1,culist] {signature of TU $t + 1$};
275 \node (ftu2) [on chain,ellip,culist] {\dots};
276 \node (ftu3) [on chain,detail1,culist] {signature of TU $t + f - 1$};
279 \begin{scope}[on background layer]
280 \filldraw [explode] (ftulist.north east) -- (ftu0.north west) -- (ftu3.south west) -- (ftulist.south east) -- cycle;
283 \path [decoration={brace,amplitude=6pt}] ([xshift=9pt]ftu0.north east)
284 [draw,decorate] -- ([xshift=9pt]ftu3.south east)
285 node [midway,right,inner xsep=9pt] {\texttt{foreign\_type\_unit\_count} $(= f)$};
287 % Exploded View of Hash Table
289 \begin{scope}[start chain=going below, node distance=0, shift={($(ftu3.south west) + (0,-9pt)$)}]
290 \node (hash0) [on chain,detail2,buckets] {Buckets};
291 \node (hash1) [on chain,detail3,hashes] {Hashes};
294 \begin{scope}[on background layer]
295 \filldraw [explode] (hash.north east) -- (hash0.north west) -- (hash1.south west) -- (hash.south east) -- cycle;
298 % Exploded View of Name Table
300 \begin{scope}[start chain=going below, node distance=0, shift={($(hash1.south west) + (0,-9pt)$)}]
301 \node (name0) [on chain,detail3,stroffsets] {String Offsets};
302 \node (name1) [on chain,detail3,entryoffsets] {Entry Offsets};
305 \begin{scope}[on background layer]
306 \filldraw [explode] (names.north east) -- (name0.north west) -- (name1.south west) -- (names.south east) -- cycle;
309 % Exploded View of Entry Pool
311 \begin{scope}[shift={($(name1.south west) + (0,-9pt)$)}]
312 \node (pool0) [detail4,indexentries] {Index Entries};
315 \begin{scope}[on background layer]
316 \filldraw [explode] (pool.north east) -- (pool0.north west) -- (pool0.south west) -- (pool.south east) -- cycle;
320 \path [decoration={brace,amplitude=6pt}] ([xshift=9pt]hash0.north east)
321 [draw,decorate] -- ([xshift=9pt]pool0.south east)
322 node [midway,right,inner xsep=9pt] {\textit{see figure part 2 on next page}};
324 % Arrows pointing to .debug_info
326 \begin{scope}[shift={($(cu0.north east) + (15pt,27pt)$)}]
327 \node (debuginfo) {\textit{.debug\_info}};
330 \path ([xshift=28pt]cu0.center) coordinate (p1);
331 \path ([xshift=14pt]p1) coordinate (c1);
332 \path ([yshift=2pt]debuginfo.west) coordinate (p2);
333 \path ([xshift=-14pt]p2) coordinate (c2);
334 \draw [dashed,{Circle[open]}-{Stealth[]}] (p1) .. controls (c1) and (c2) .. (p2);
336 \path ([xshift=28pt]ltu0.center) coordinate (p3);
337 \path ([xshift=60pt]p3) coordinate (c3);
338 \path ([yshift=-2pt]debuginfo.west) coordinate (p4);
339 \path ([shift={(-21pt,-7pt)}]p4) coordinate (c4);
340 \draw [dashed,{Circle[open]}-{Stealth[]}] (p3) .. controls (c3) and (c4) .. (p4);
344 \caption{Name Index Layout}
345 \label{fig:nameindexlayoutpart1}
352 %\includegraphics[keepaspectratio=true,scale=1.0]{name-index-drawings-6p2}
355 every node/.style={node font=\small, anchor=north west, text height=.8em, text depth=.2em, inner sep=4pt, outer ysep=0},
356 % This diagram has a couple of two-line captions, so set the text depth
357 % to make room for the second line.
358 caption1/.style={node font=\small \bfseries, text depth=1.2em, text width=90pt},
359 caption2/.style={node font=\small \bfseries, text depth=1.2em, text width=41pt},
360 detail1/.style={draw, minimum height=14pt, text width=90pt},
361 detail2/.style={draw, minimum height=14pt, text width=41pt},
362 ellip1/.style={draw, shape=broken rectangle, minimum height=14pt, text width=90pt},
363 ellip2/.style={draw, shape=broken rectangle, minimum height=14pt, text width=41pt},
364 buckets/.style={fill=bucketsblue},
365 hashes/.style={fill=hashesgreen},
366 stroffsets/.style={fill=stroffsetspink},
367 entryoffsets/.style={fill=entryoffsetspink}
372 \begin{scope}[start chain=going below, node distance=0]
373 \node [on chain,caption1] {\\ Buckets};
374 \node (bucket0) [on chain,detail1,buckets] {bucket 0};
375 \node (bucket1) [on chain,detail1,buckets] {bucket 1};
376 \node (bucket2) [on chain,ellip1,buckets] {\dots};
377 \node (bucket3) [on chain,detail1,buckets] {bucket $b - 1$};
380 \path [decoration={brace,amplitude=6pt}] ([xshift=40pt]bucket0.north east)
381 [draw,decorate] -- ([xshift=40pt]bucket3.south east)
382 node [midway,right,inner xsep=9pt] {\texttt{bucket\_count} $(= b)$};
386 \begin{scope}[start chain=going below, node distance=0, shift={($(bucket3.south east) + (18pt,-24pt)$)}]
387 \node (hashes) [on chain,caption1] {\\ Hashes};
388 \node (hash0) [on chain,detail1,hashes] {hash value 1};
389 \node (hash1) [on chain,detail1,hashes] {hash value 2};
390 \node (hash2) [on chain,detail1,hashes] {hash value 3};
391 \node (hash3) [on chain,detail1,hashes] {hash value 4};
392 \node (hash4) [on chain,detail1,hashes] {hash value 5};
393 \node (hash5) [on chain,ellip1,hashes] {\dots};
394 \node (hash6) [on chain,detail1,hashes] {hash value $n$};
399 \begin{scope}[start chain=going below, node distance=0, shift={($(hashes.north east)$)}]
400 \node (strs) [on chain,caption2] {String \\ Offsets};
401 \node (str0) [on chain,detail2,stroffsets] {};
402 \node (str1) [on chain,detail2,stroffsets] {};
403 \node (str2) [on chain,detail2,stroffsets] {};
404 \node (str3) [on chain,detail2,stroffsets] {};
405 \node (str4) [on chain,detail2,stroffsets] {};
406 \node (str5) [on chain,ellip2,stroffsets] {};
407 \node (str6) [on chain,detail2,stroffsets] {};
412 \begin{scope}[start chain=going below, node distance=0, shift={($(strs.north east)$)}]
413 \node (entries) [on chain,caption2] {Entry \\ Offsets};
414 \node (entry0) [on chain,detail2,entryoffsets] {};
415 \node (entry1) [on chain,detail2,entryoffsets] {};
416 \node (entry2) [on chain,detail2,entryoffsets] {};
417 \node (entry3) [on chain,detail2,entryoffsets] {};
418 \node (entry4) [on chain,detail2,entryoffsets] {};
419 \node (entry5) [on chain,ellip2,entryoffsets] {};
420 \node (entry6) [on chain,detail2,entryoffsets] {};
423 \path [decoration={brace,amplitude=6pt}] ([xshift=9pt]entry0.north east)
424 [draw,decorate] -- ([xshift=9pt]entry6.south east)
425 node [midway,right,inner xsep=9pt] {\begin{tabular}{c}
426 \texttt{name\_count} \\
430 % Arrows pointing to .debug_str and entry pool
432 \path (str0.center) coordinate (p1);
433 \path ([xshift=18pt]p1) coordinate (c1);
434 \path ([shift={(36pt,45pt)}]p1) coordinate (p2);
435 \path ([xshift=-18pt]p2) coordinate (c2);
436 \draw [dashed,{Circle[open]}-{Stealth[]}] (p1) .. controls (c1) and (c2) .. (p2) node [anchor=west] {$.debug\_str$};
438 \path (entry0.center) coordinate (p3);
439 \path ([xshift=18pt]p3) coordinate (c3);
440 \path ([shift={(36pt,27pt)}]p3) coordinate (p4);
441 \path ([xshift=-18pt]p4) coordinate (c4);
442 \draw [dashed,{Circle[open]}-{Stealth[]}] (p3) .. controls (c3) and (c4) .. (p4) node [anchor=west] {$entry\ pool$};
444 % Arrows from buckets to hashes
446 \path ([xshift=24pt]bucket0.center) coordinate (p5);
447 \path ([xshift=130pt]p5) coordinate (c5);
448 \path ([xshift=-70pt]hash0.west) coordinate (c6);
449 \draw [dashed,{Circle[open]}-{Stealth[]}] (p5) .. controls (c5) and (c6) .. (hash0.west);
451 \path ([xshift=24pt]bucket1.center) coordinate (p7);
452 \path ([xshift=120pt]p7) coordinate (c7);
453 \path ([xshift=-144pt]hash3.west) coordinate (c8);
454 \draw [dashed,{Circle[open]}-{Stealth[]}] (p7) .. controls (c7) and (c8) .. (hash3.west);
460 %\includegraphics[keepaspectratio=true,scale=1.0]{name-index-drawings-6p3}
462 every node/.style={node font=\small, anchor=north west, text height=.8em, text depth=.2em, inner sep=4pt, outer ysep=0},
463 caption/.style={node font=\small \bfseries, text width=120pt},
464 detail/.style={draw, node font=\small, minimum height=14pt, text width=120pt},
465 ellip/.style={draw, shape=broken rectangle, minimum height=14pt, text width=120pt},
466 explode/.style={draw=black!50, fill=black!20, line join=bevel},
467 indexentries/.style={fill=indexentriesorange}
472 \begin{scope}[start chain=going below, node distance=0]
473 \node [on chain,caption] {Entry Pool};
474 \node (entry0) [on chain,detail,indexentries] {index entry \#1 for ``a''};
475 \node (entry1) [on chain,detail,indexentries] {index entry \#2 for ``a''};
476 \node (entry2) [on chain,ellip,indexentries] {\dots};
477 \node (entry3) [on chain,detail,indexentries] {0 \textit{(end of entries for ``a'')}};
478 \node (entry4) [on chain,detail,indexentries] {index entry \#1 for ``b''};
479 \node (entry5) [on chain,detail,indexentries] {index entry \#2 for ``b''};
480 \node (entry6) [on chain,ellip,indexentries] {\dots};
481 \node (entry7) [on chain,detail,indexentries] {0};
482 \node (entry8) [on chain,detail,indexentries] {index entry \#1 for ``c''};
483 \node (entry9) [on chain,ellip,indexentries] {\dots};
486 % Exploded Index Entry
488 \begin{scope}[start chain=going below, node distance=0, shift={($(entry1.north east) + (60pt,30pt)$)}]
489 \node (abbrev) [on chain,detail,indexentries] {abbrev code};
490 \node (attr1) [on chain,detail,indexentries] {attribute};
491 \node (attr2) [on chain,detail,indexentries] {attribute};
492 \node (attr3) [on chain,ellip,indexentries] {\dots};
493 \node (attr4) [on chain,detail,indexentries] {attribute};
496 \begin{scope}[on background layer]
497 \filldraw [explode] (entry1.north east) -- (abbrev.north west) -- (attr4.south west) -- (entry1.south east) -- cycle;
502 \node (from1) [anchor=east] at ([xshift=-36pt]entry0.west) {\textit{(from name table)}};
503 \draw [dashed,-{Stealth[]}] (from1) -- (entry0.west);
505 \node (from2) [anchor=east] at ([xshift=-36pt]entry4.west) {\textit{(from name table)}};
506 \draw [dashed,-{Stealth[]}] (from2) -- (entry4.west);
508 \node (from2) [anchor=east] at ([xshift=-36pt]entry7.west) {\textit{(from name table)}};
509 \draw [dashed,-{Stealth[]}] (from2) -- (entry7.west);
514 %\caption{Name Index Layout \textit{(concluded)}}
515 Figure~\ref{fig:nameindexlayoutpart1}: Name Index Layout \textit{(concluded)}
516 %\label{fig:nameindexlayoutpart2}
520 The formats of the header and the hash lookup table are described
521 in Section \refersec{chap:datarepresentationofthenameindex}.
523 The list of CUs and the list of local TUs are each an array of
524 offsets, each of which is the offset of a compile unit or a type unit
525 in the \dotdebuginfo{} section. For a per-CU index, there is a single CU
526 entry, and there may be a TU entry for each type unit generated in the
527 same translation unit as the single CU. For a per-module index, there
528 will be one CU entry for each compile unit in the module, and one TU
529 entry for each unique type unit in the module. Each list is indexed
532 The list of foreign TUs is an array of 64-bit (\DWFORMrefsigeight) type
533 signatures, representing types referenced by the index whose
534 definitions have been placed in a different object file (that is, a split
535 DWARF object). This list may be empty.
536 The foreign TU list immediately follows the local TU list
537 and they both use the same index, so that if there are $N$ local TU entries,
538 the index for the first foreign TU is $N$.
540 The name table is logically a table with a row for each unique name in
541 the index, and two columns. The first column contains a reference to
542 the name, as a string. The second column contains the offset within
543 the entry pool of the list of index entries for the name.
546 The abbreviations table describes the formats of the entries in the
547 entry pool. Like the DWARF abbreviations table in the \dotdebugabbrev{}
548 section, it defines one or more abbreviation codes. Each abbreviation
549 code provides a DWARF tag value followed by a list of pairs that
550 defines an attribute and form code used by entries with that
553 The entry pool contains all the index entries, grouped by name. The
554 second column of the name list points to the first index entry for the
555 name, and all the index entries for that name are placed one after the
558 Each index entry begins with an unsigned LEB128 abbreviation code.
559 The abbreviation list for that code provides the DWARF tag value for
560 the entry as well as the set of attributes provided by the entry and
564 The standard attributes are:
566 \item Compilation Unit (CU), a reference to an entry in the list of
567 CUs. In a per-CU index, index entries without this attribute
568 implicitly refer to the single CU.
570 \item Type Unit (TU), a reference to an entry in the list of local
573 \item Debugging information entry offset within the CU or TU.
575 \item Parent debugging information entry,
576 a reference to the index entry for the parent.
577 This is represented as the offset of the entry relative to
578 the start of the entry pool.
580 \item Type hash, an 8-byte hash of the type declaration.
585 It is possible that an indexed debugging information entry
586 has a parent that is not
587 indexed (for example, if its parent does not have a name attribute).
588 In such a case, a parent attribute may point to a nameless index
589 entry (that is, one that cannot be reached from any entry in the
590 name table), or it may point to the nearest ancestor that does
593 A producer may define additional vendor-specific attributes,
594 and a consumer will be able to ignore and skip over any attributes
595 it is not prepared to handle.
598 When an index entry refers to a foreign type unit, it may have
599 attributes for both CU and (foreign) TU. For such entries, the CU
600 attribute gives the consumer a reference to the CU that may be used to
601 locate a \splitDWARFobjectfile{} that contains the type unit.
603 \textit{The type hash attribute, not to be confused with the type signature
604 for a TU, may be provided for type entries whose declarations are not
605 in a type unit, for the convenience of link-time or post-link
606 utilities that wish to de-duplicate type declarations across
607 compilation units. The type hash, however, is computed by the
608 same method as specified for type signatures.}
610 The last entry for each name is followed by a zero byte that
611 terminates the list. There may be gaps between the lists.
613 \subsubsection{Per-CU versus Per-Module Indexes}
614 \label{chap:percuvspermoduleindexes}
615 \textit{In a per-CU index, the CU list may have only a single entry,
616 and index entries may omit the CU attribute. (Cross-module or link-time
617 optimization, however, may produce an object file with several compile
618 units in one object. A compiler in this case may produce a separate
619 index for each CU, or a combined index for all CUs. In the latter
620 case, index entries will require the CU attribute.) Most name table
621 entries may have only a single index entry for each, but sometimes a
622 name may be used in more than one context and will require multiple
623 index entries, each pointing to a different debugging information
626 \textit{When linking object files containing per-CU indexes, the
627 linker may choose to concatenate the indexes as ordinary sections,
628 or it may choose to combine the input indexes into a single
631 \textit{A per-module index will contain a number of CUs, and each index
632 entry contains a CU attribute or a TU attribute to identify which
633 CU or TU contains the debugging information entry being indexed. When a
634 given name is used in multiple CUs or TUs, it will typically have a
635 series of index entries pointing to each CU or TU where it is declared.
636 For example, an index entry for a \addtoindex{C++} namespace needs to
637 list each occurrence, since each CU may contribute additional names to
638 the namespace, and the consumer needs to find them all. On the
639 other hand, some index entries do not need to list more than one
640 definition; for example, with the one-definition rule in \addtoindex{C++},
641 duplicate entries for a function may be omitted, since the consumer
642 only needs to find one declaration. Likewise, a per-module index needs
643 to list only a single copy of a type declaration contained in a type
646 \textit{For the benefit of link-time or post-link utilities that consume
647 per-CU indexes and produce a per-module index, the per-CU index
648 entries provide the tag encoding for the original debugging
649 information entry, and may provide a type hash for certain types that
650 may benefit from de-duplication. For example, the standard declaration
651 of the typedef \texttt{uint32\_t} is likely to occur in many CUs, but a
652 combined per-module index needs to retain only one; a user declaration
653 of a typedef \texttt{mytype} may refer to a different type at each
654 occurrence, and a combined per-module index retains each unique
655 declaration of that type.}
658 \subsubsection{Data Representation of the Name Index}
659 \label{chap:datarepresentationofthenameindex}
660 The name index is placed in a section named \dotdebugnames, and
661 consists of the eight parts described in the following sections.
663 \subsubsubsection{Section Header}
664 \label{chap:sectionheader}
665 The section header contains the following fields:
666 \begin{enumerate}[1. ]
667 \item \texttt{unit\_length} (\livelink{datarep:initiallengthvalues}{initial length}) \\
668 \addttindexx{unit\_length}
669 The length of this contribution to the name index section,
670 not including the length field itself.
672 \item \texttt{version} (\HFTuhalf) \\
673 A version number\addtoindexx{version number!name index table}
674 (see Section \refersec{datarep:nameindextable}).
675 This number is specific to the name index table and is
676 independent of the DWARF version number.
678 \item \textit{padding} (\HFTuhalf) \\
679 Reserved to DWARF (must be zero).
681 \item \texttt{comp\_unit\_count} (\HFTuword) \\
682 The number of CUs in the CU list.
684 \item \texttt{local\_type\_unit\_count} (\HFTuword) \\
685 The number of TUs in the local TU list.
687 \item \texttt{foreign\_type\_unit\_count} (\HFTuword) \\
688 The number of TUs in the foreign TU list.
690 \item \texttt{bucket\_count} (\HFTuword) \\
691 The number of hash buckets in the hash lookup table.
692 If there is no hash lookup table, this field contains 0.
694 \item \texttt{name\_count} (\HFTuword) \\
695 The number of unique names in the index.
697 \item \texttt{abbrev\_table\_size} (\HFTuword) \\
698 The size in bytes of the abbreviations table.
700 \item \texttt{augmentation\_string\_size} (\HFTuword) \\
701 The size in bytes of the augmentation string. This value is
702 rounded up to a multiple of 4.
704 \item \texttt{augmentation\_string} (\HFTaugstring) \\
705 A vendor-specific augmentation string, which provides additional
706 information about the contents of this index. If provided, the string
707 begins with a 4-character vendor ID. The remainder of the
708 string is meant to be read by a cooperating consumer, and its
709 contents and interpretation are not specified here. The
710 string is padded with null characters to a multiple of
711 four bytes in length.
713 \textit{The presence of an unrecognised augmentation string may make it impossible
714 for a consumer to process data in the \dotdebugnames{} section.}
719 \subsubsubsection{List of CUs}
720 The list of CUs immediately follows the header. Each entry in the
721 list is an offset of the corresponding compilation unit
722 in the \dotdebuginfo{} section.
723 In the DWARF-32 format, a section offset is 4 bytes,
724 while in the DWARF-64 format, a section offset is 8 bytes.
726 The total number of entries in the list is given by \texttt{comp\_unit\_count}.
727 There must be at least one CU.
730 \subsubsubsection{List of Local TUs}
731 The list of local TUs immediately follows the list of CUs. Each
732 entry in the list is an offset of the corresponding type unit
733 in the \dotdebuginfo{} section.
734 In the DWARF-32 format, a section offset is 4 bytes,
735 while in the DWARF-64 format, a section offset is 8 bytes.
737 The total number of entries in the list is given by
738 \texttt{local\_type\_unit\_count}. This list may be empty.
740 \subsubsubsection{List of Foreign TUs}
741 The list of foreign TUs immediately follows the list of local TUs.
742 Each entry in the list is a 8-byte type signature (as described by
745 The number of entries in the list is given by \texttt{foreign\_type\_unit\_count}.
746 This list may be empty.
749 \subsubsubsection{Hash Lookup Table}
750 The optional hash lookup table immediately follows the list of type signatures.
752 The hash lookup table is actually two separate arrays: an array of
753 buckets, followed immediately by an array of hashes. The number of
754 entries in the buckets array is given by \texttt{bucket\_count}, and the number
755 of entries in the hashes array is given by \texttt{name\_count}. Each array
756 contains 4-byte unsigned integers.
759 Symbols are entered into the hash table by first computing a hash
760 value from the symbol name. The hash is computed
761 using the "DJB" hash function\addtoindexx{DJB hash function}
762 described in Section \refersec{datarep:nametablehashfunction}.
763 Given a hash value for the symbol,
764 the symbol is entered into a bucket whose index is the hash value
765 modulo \texttt{bucket\_count}. The buckets array is indexed starting at 0.
767 Each bucket contains the index of an entry in the hashes array. The
768 hashes array is indexed starting at 1, and an empty bucket is
769 represented by the value 0.
772 The hashes array contains a sequence of the full hash values for each
773 symbol. All symbols that have the same index into the bucket list
774 follow one another in the hashes array, and the indexed entry in
775 the bucket list refers to the first symbol.
776 When searching for a symbol, the search
777 starts at the index given by the bucket, and continues either until a
778 matching symbol is found or until a hash value from a different bucket
779 is found. If two different symbol names produce the same hash value,
780 that hash value will occur twice in the hashes array. Thus, if a
781 matching hash value is found, but the name does not match, the search
782 continues visiting subsequent entries in the hashes table.
784 When a matching hash value is found in the hashes array, the index of
785 that entry in the hashes array is used to find the corresponding entry
789 \subsubsubsection{Name Table}
790 \label{chap:nametable}
791 The name table immediately follows the hash lookup table. It
792 consists of two arrays: an array of string offsets, followed
793 immediately by an array of entry offsets. The items in both
794 arrays are section offsets: 4-byte unsigned integers for the
795 DWARF-32 format or 8-byte unsigned integers for the DWARF-64
796 format. The string offsets in the first array refer to names in
797 the \dotdebugstr{} (or \dotdebugstrdwo) section. The entry offsets
798 in the second array refer to index entries, and are relative to
799 the start of the entry pool area.
801 These two arrays are indexed starting at 1, and correspond
802 one-to-one with each other. The length of each array is
803 given by \texttt{name\_count}.
805 If there is a hash lookup table, the hashes array corresponds on
806 a one-to-one basis with the string offsets array and with the
809 \textit{If there is no hash lookup table, there is no ordering
810 requirement for the name table.}
813 \subsubsubsection{Abbreviations Table}
814 The abbreviations table immediately follows the name table. This table
815 consists of a series of abbreviation declarations. Its size is given
816 by \texttt{abbrev\_table\_size}.
818 Each abbreviation declaration defines the tag and other attributes for
819 a particular form of index entry. Each declaration starts with an
820 unsigned LEB128 number representing the abbreviation code itself. It
821 is this code that appears at the beginning of an index entry. The
822 abbreviation code must not be 0.
824 The abbreviation code is followed by another unsigned LEB128 number
825 that encodes the tag of the debugging information entry corresponding
828 Following the tag encoding is a series of attribute specifications.
829 Each attribute consists of two parts: an unsigned LEB128 number that
830 represents the index attribute, and another unsigned LEB128 number
831 that represents the attribute's form (as described in
832 Section \refersec{datarep:attributeencodings}). The series of attribute
833 specifications ends with an entry containing 0 for the attribute and
836 The index attributes and their meanings are listed in
837 Table \referfol{tab:indexattributeencodings}.
840 \setlength{\extrarowheight}{0.1cm}
841 \begin{longtable}{l|l}
842 \caption{Index attribute encodings} \label{tab:indexattributeencodings}\\
843 \hline \bfseries Attribute name &\bfseries Meaning \\ \hline
845 \bfseries Attribute name &\bfseries Meaning \\ \hline
847 \hline \emph{Continued on next page}
851 \DWIDXcompileunitTARG & Index of CU \\
852 \DWIDXtypeunitTARG & Index of TU (\mbox{local} or foreign) \\
853 \DWIDXdieoffsetTARG & Offset of DIE within CU or TU \\
854 \DWIDXparentTARG & Index of name \mbox{table} entry for parent \\
855 \DWIDXtypehashTARG & Hash of type \mbox{declaration} \\
859 The abbreviations table ends with an entry consisting of a single 0
860 byte for the abbreviation code. The size of the table given by
861 \texttt{abbrev\_table\_size} may include optional padding following the
864 \subsubsubsection{Entry Pool}
865 The entry pool immediately follows the abbreviations table.
866 Each entry in the entry offsets array in the name table (see
867 Section \ref{chap:nametable})
868 points to an offset in the entry pool, where a series
869 of index entries for that name is located.
872 Each index entry in the series begins with an abbreviation code, and is
873 followed by the attributes described by the abbreviation declaration
874 for that code. The last index entry in the series is followed by a
875 terminating entry whose abbreviation code is 0.
877 Gaps are not allowed between entries in a series (that is, the entries
878 for a single name must all be contiguous), but there may be gaps
881 \textit{For example, a producer/consumer combination may find
882 it useful to maintain alignment.}
884 The size of the entry pool is the remaining size of the contribution to
885 the index section, as defined by the \texttt{unit\_length} header field.
887 \subsection{Lookup by Address}
888 \label{chap:lookupbyaddress}
889 For \addtoindexx{lookup!by address}
890 lookup by address, a table is maintained in a separate
891 \addtoindexx{accelerated access!by address}
892 object file section called
893 \dotdebugaranges{}. The table consists
894 of sets of variable length entries, each set describing the
895 portion of the program\textquoteright{}s address space that is covered by
896 a single compilation unit.
899 Each set begins with a header containing five values:
900 \begin{enumerate}[1. ]
901 \item \texttt{unit\_length} (\livelink{datarep:initiallengthvalues}{initial length}) \\
902 \addttindexx{unit\_length}
903 The length of this contribution to the address lookup section,
904 not including the length field itself.
906 \item \texttt{version} (\HFTuhalf) \\
907 A version number\addtoindexx{version number!address lookup table}
908 (see Section \refersec{datarep:addrssrangetable}).
909 This number is specific to the address lookup table and is
910 independent of the DWARF version number.
912 \item \texttt{debug\_info\_offset} (section offset) \\
914 \addtoindexx{section offset!in .debug\_aranges header}
915 beginning of the \dotdebuginfo{} section of the
916 compilation unit header referenced by the set.
918 \item \texttt{address\_size} (\HFTubyte) \\
919 The \addtoindex{size of an address}
921 \addttindexx{address\_size}
922 the target architecture. For
923 \addtoindexx{address space!segmented}
924 segmented addressing, this is
925 the size of the offset portion of the address.
927 \item \HFNsegmentselectorsize{} (\HFTubyte) \\
928 The size of a segment selector in
929 bytes on the target architecture. If the target system uses
930 a flat address space, this value is 0.
934 This header is followed by a variable number of address range
935 descriptors. Each descriptor is a triple consisting of a
936 segment selector, the beginning address within that segment
937 of a range of text or data covered by some entry owned by
938 the corresponding compilation unit, followed by the non-zero
939 length of that range. A particular set is terminated by an
940 entry consisting of three zeroes.
941 When the \HFNsegmentselectorsize{} value
942 is zero in the header, the segment selector is omitted so that
943 each descriptor is just a pair, including the terminating
944 entry. By scanning the table, a debugger can quickly decide
945 which compilation unit to look in to find the debugging
946 information for an object that has a given address.
948 \textit{If the range of addresses covered by the text and/or data
949 of a compilation unit is not contiguous, then there may be
950 multiple address range descriptors for that compilation unit.}
953 \section{Line Number Information}
954 \label{chap:linenumberinformation}
955 \textit{A source\dash level debugger needs to know how to
956 \addtoindexx{line number information|see{\textit{also} statement list attribute}}
957 associate locations in the source files with the corresponding
958 machine instruction addresses in the executable or the shared
959 object files used by that executable object file. Such an
960 association makes it possible for the debugger user
961 to specify machine instruction addresses in terms of source
962 locations. This is done by specifying the line number
963 and the source file containing the statement. The debugger
964 can also use this information to display locations in terms
965 of the source files and to single step from line to line,
966 or statement to statement.}
968 Line number information generated for a compilation unit is
970 \dotdebugline{} section of an object file, and optionally
971 also in the \dotdebuglinestr{} section, and
972 is referenced by a corresponding compilation unit debugging
974 (see Section \refersec{chap:fullandpartialcompilationunitentries})
975 in the \dotdebuginfo{} section.
977 \textit{Some computer architectures employ more than one instruction
978 set (for example, the ARM
979 \addtoindexx{ARM instruction set architecture}
981 MIPS architectures support
982 \addtoindexx{MIPS instruction set architecture}
983 a 32-bit as well as a 16-bit instruction set). Because the
984 instruction set is a function of the program counter, it is
985 convenient to encode the applicable instruction set in the
986 \dotdebugline{} section as well.}
988 \textit{If space were not a consideration, the information provided
989 in the \dotdebugline{}
990 section could be represented as a large
991 matrix, with one row for each instruction in the emitted
992 object code. The matrix would have columns for:}
994 \item \textit{the source file name}
995 \item \textit{the source line number}
996 \item \textit{the source column number}
997 \item \textit{whether this instruction is the beginning of a source statement}
998 \item \textit{whether this instruction is the beginning of a \addtoindex{basic block}}
999 \item \textit{and so on}
1001 \textit{Such a matrix, however, would be impractically large. We
1002 shrink it with two techniques. First, we delete from
1003 the matrix each row whose file, line, source column and
1004 discriminator\addttindexx{discriminator}
1005 is identical with that of its
1006 predecessors. Any deleted row would never be the beginning of
1007 a source statement. Second, we design a byte-coded language
1008 for a state machine and store a stream of bytes in the object
1009 file instead of the matrix. This language can be much more
1010 compact than the matrix. To the line number information a
1011 consumer must \doublequote{run} the state machine
1012 to generate the matrix for each compilation unit of interest.
1013 The concept of an encoded matrix also leaves
1014 room for expansion. In the future, columns can be added to the
1015 matrix to encode other things that are related to individual
1016 instruction addresses.}
1019 \subsection{Definitions}
1020 \label{chap:definitions}
1021 The following terms are used in the description of the line
1022 number information format:
1024 \begin{longtable} {lP{9cm}}
1026 The hypothetical machine used by a consumer of the line number
1027 information to expand the byte\dash coded
1028 instruction stream into a matrix of
1029 line number information. \\
1031 line number program &
1032 A series of byte\dash coded
1033 line number information instructions representing
1034 one compilation unit. \\
1036 \addtoindex{basic block} &
1037 A sequence of instructions where only the first instruction may be a
1038 branch target and only the last instruction may transfer control. A
1039 subprogram invocation is defined to be an exit from a
1040 \addtoindex{basic block}.
1042 \textit{A \addtoindex{basic block} does not
1043 necessarily correspond to a specific source code
1047 A series of contiguous target machine instructions. One compilation unit
1048 may emit multiple sequences (that is, not all instructions within a
1049 compilation unit are assumed to be contiguous). \\
1053 \subsection{State Machine Registers}
1054 \label{chap:statemachineregisters}
1055 The line number information state machine has a number of
1056 registers as shown in Table \referfol{tab:statemachineregisters}.
1058 \begin{longtable}{l|P{9cm}}
1059 \caption{State machine registers } \label{tab:statemachineregisters} \\
1060 \hline \bfseries Register name&\bfseries Meaning\\ \hline
1062 \bfseries Register name&\bfseries Meaning\\ \hline
1064 \hline \emph{Continued on next page}
1068 \addtoindexi{\texttt{address}}{address register!in line number machine}&
1069 The program\dash counter value corresponding to a machine instruction
1070 generated by the compiler. \\
1072 \addttindex{op\_index} &
1073 An unsigned integer representing the index of an operation within a VLIW
1074 instruction. The index of the first operation is 0. For non-VLIW
1075 architectures, this register will always be 0. \\
1078 An unsigned integer indicating the identity of the source file
1079 corresponding to a machine instruction. \\
1082 An unsigned integer indicating a source line number. Lines are numbered
1083 beginning at 1. The compiler may emit the value 0 in cases where an
1084 instruction cannot be attributed to any source line. \\
1086 \addttindex{column} &
1087 An unsigned integer indicating a column number within a source line.
1088 Columns are numbered beginning at 1. The value 0 is reserved to indicate
1089 that a statement begins at the \doublequote{left edge} of the line. \\
1091 \addttindex{is\_stmt} &
1092 A boolean indicating that the current instruction is a recommended
1093 breakpoint location. A recommended breakpoint location
1094 is intended to \doublequote{represent} a line, a
1095 statement and/or a semantically distinct subpart of a
1098 \addttindex{basic\_block} &
1099 A boolean indicating that the current instruction is the beginning of a
1100 \addtoindex{basic block}. \\
1102 \addttindex{end\_sequence} &
1103 A boolean indicating that the current address is that of the first byte after
1104 the end of a sequence of target machine instructions.
1105 \addttindex{end\_sequence}
1106 terminates a sequence of lines; therefore other information in the same
1107 row is not meaningful. \\
1109 \addttindex{prologue\_end} &
1110 A boolean indicating that the current address is one (of possibly many)
1111 where execution should be suspended for a breakpoint at the entry of a
1114 \addttindex{epilogue\_begin} &
1115 A boolean indicating that the current address is one (of possibly many)
1116 where execution should be suspended for a breakpoint just prior to
1117 the exit of a function. \\
1120 An unsigned integer whose value encodes the applicable
1121 instruction set architecture for the current instruction.
1123 \textit{The encoding of instruction sets should be shared by all
1124 users of a given architecture. It is recommended that this
1125 encoding be defined by the ABI authoring committee for each
1128 \addttindex{discriminator} &
1129 An unsigned integer identifying the block to which the
1130 current instruction belongs. Discriminator values are assigned
1131 arbitrarily by the DWARF producer and serve to distinguish
1132 among multiple blocks that may all be associated with the
1133 same source file, line, and column. Where only one block
1134 exists for a given source position, the discriminator value
1138 The \texttt{address} and \addttindex{op\_index} registers,
1139 taken together, form an \addtoindex{operation pointer} that can
1140 reference any individual operation within the instruction stream.
1142 At the beginning of each sequence within a line number
1143 program, the state of the registers is as show in Table
1144 \refersec{tab:linenumberprograminitiastate}.
1146 \caption{Line number program initial state}
1147 \label{tab:linenumberprograminitiastate}
1149 \begin{tabular}{l|p{9.5cm}}
1151 \texttt{address} & 0 \\
1152 \addttindex{op\_index} & 0 \\
1153 \texttt{file} & 1 \\
1154 \texttt{line} & 1 \\
1155 \texttt{column} & 0 \\
1156 \addttindex{is\_stmt} & determined by \addttindex{default\_is\_stmt}
1157 in the line number program header \\
1158 \addttindex{basic\_block} & \doublequote{false} \addtoindexx{basic block} \\
1159 \addttindex{end\_sequence} & \doublequote{false} \\
1160 \addttindex{prologue\_end} & \doublequote{false} \\
1161 \addttindex{epilogue\_begin} & \doublequote{false} \\
1162 \addttindex{isa} & 0 \\
1163 \addttindex{discriminator} & 0 \\
1171 \addttindex{isa} value 0 specifies that the instruction set is the
1172 architecturally determined default instruction set. This may
1173 be fixed by the ABI, or it may be specified by other means,
1174 for example, by the object file description.}
1177 \subsection{Line Number Program Instructions}
1178 The state machine instructions in a line number program belong to one of three categories:
1180 \begin{enumerate}[1. ]
1181 \item special opcodes \\
1182 These have a \HFTubyte{} opcode field and no operands.\vspace{1ex}
1184 \textit{Most of the instructions in a
1185 line number program are special opcodes.}
1188 \item standard opcodes \\
1189 These have a \HFTubyte{} opcode field which may be followed by zero or more
1190 \addtoindex{LEB128} operands (except for
1191 \mbox{\DWLNSfixedadvancepc,} see
1192 Section \refersec{chap:standardopcodes}).
1193 The opcode implies the number of operands and their meanings, but the
1194 line number program header also specifies the number of operands for
1195 each standard opcode.
1198 \item extended opcodes \\
1199 These have a multiple byte format. The first byte is zero; the next bytes
1200 are an unsigned LEB128\addtoindexx{LEB128!unsigned} integer giving the number of bytes in the
1201 instruction itself (does not include the first zero byte or the size). The
1202 remaining bytes are the instruction itself (which begins with a \HFTubyte{}
1203 extended opcode). \\
1207 \subsection{The Line Number Program Header}
1208 \label{chap:linenumberprogramheader}
1209 The optimal encoding of line number information depends to a
1210 certain degree upon the architecture of the target machine. The
1211 line number program header provides information used by
1212 consumers in decoding the line number program instructions for
1213 a particular compilation unit and also provides information
1214 used throughout the rest of the line number program.
1216 The line number program for each compilation unit begins with
1217 a header containing the following fields in order:
1219 \begin{enumerate}[1. ]
1220 \item \texttt{unit\_length} (\livelink{datarep:initiallengthvalues}{initial length}) \\
1221 \addttindexx{unit\_length}
1222 The size in bytes of the line number information for this
1223 compilation unit, not including the length field itself
1224 (see Section \refersec{datarep:initiallengthvalues}).
1227 \item \texttt{version} (\HFTuhalf) \\
1228 A version number\addtoindexx{version number!line number information}
1229 (see Section \refersec{datarep:linenumberinformation}).
1230 This number is specific to
1231 the line number information and is independent of the DWARF
1234 \item \texttt{address\_size} (\HFTubyte)\\
1235 A 1-byte unsigned integer containing the size in bytes of an
1236 address (or offset portion of an address for segmented addressing)
1237 on the target system.
1239 \textit{The \addttindex{address\_size} field is new in DWARF Version 5.
1240 It is needed to support the common practice of stripping all but
1241 the line number sections (\dotdebugline{} and \dotdebuglinestr{})
1242 from an executable.}
1244 \item \HFNsegmentselectorsize{} (\HFTubyte) \\
1245 A 1-byte unsigned integer containing the size in bytes of a segment
1246 selector on the target system.
1248 \textit{The \HFNsegmentselectorsize{} field is new in DWARF Version 5.
1249 It is needed in combination with the \addttindex{address\_size} field
1250 to accurately characterize the address representation on the target
1254 \item \texttt{header\_length} \\
1255 The number of bytes following the \addttindex{header\_length} field to the
1256 beginning of the first byte of the line number program itself.
1257 In the \thirtytwobitdwarfformat, this is a 4-byte unsigned
1258 length; in the \sixtyfourbitdwarfformat, this field is an
1259 8-byte unsigned length
1260 (see Section \refersec{datarep:32bitand64bitdwarfformats}).
1262 \item \texttt{minimum\_instruction\_length} (\HFTubyte) \\
1263 \addttindexx{minimum\_instruction\_length}
1264 The size in bytes of the smallest target machine
1265 instruction. Line number program opcodes that alter
1266 the \texttt{address} and \addttindex{op\_index}
1267 registers use this and
1268 \addttindex{maximum\_operations\_per\_instruction}
1269 in their calculations.
1272 \item \texttt{maximum\_operations\_per\_instruction} (\HFTubyte) \\
1274 \addttindexx{maximum\_operations\_per\_instruction}
1275 maximum number of individual operations that may be
1276 encoded in an instruction. Line number program opcodes
1277 that alter the \texttt{address} and
1278 \addttindex{op\_index} registers use this and
1279 \addttindex{minimum\_instruction\_length} in their calculations.
1282 architectures, this field is 1, the \addttindex{op\_index} register is always
1283 0, and the \addtoindex{operation pointer} is simply the \texttt{address} register.
1286 \item \texttt{default\_is\_stmt} (\HFTubyte) \\
1287 \addttindexx{default\_is\_stmt}
1288 The initial value of the \addttindex{is\_stmt} register.
1290 \textit{A simple approach
1291 to building line number information when machine instructions
1292 are emitted in an order corresponding to the source program
1293 is to set \addttindex{default\_is\_stmt}
1294 to \doublequote{true} and to not change the
1295 value of the \addttindex{is\_stmt} register
1296 within the line number program.
1297 One matrix entry is produced for each line that has code
1298 generated for it. The effect is that every entry in the
1299 matrix recommends the beginning of each represented line as
1300 a breakpoint location. This is the traditional practice for
1303 \textit{A more sophisticated approach might involve multiple entries in
1304 the matrix for a line number; in this case, at least one entry
1305 (often but not necessarily only one) specifies a recommended
1306 breakpoint location for the line number. \DWLNSnegatestmt{}
1307 opcodes in the line number program control which matrix entries
1308 constitute such a recommendation and
1309 \addttindex{default\_is\_stmt} might
1310 be either \doublequote{true} or \doublequote{false.} This approach might be
1311 used as part of support for debugging optimized code.}
1313 \item \texttt{line\_base} (\HFTsbyte) \\
1314 \addttindexx{line\_base}
1315 This parameter affects the meaning of the special opcodes. See below.
1317 \item \texttt{line\_range} (\HFTubyte) \\
1318 \addttindexx{line\_range}
1319 This parameter affects the meaning of the special opcodes. See below.
1322 \item \texttt{opcode\_base} (\HFTubyte) \\
1324 \addttindexx{opcode\_base}
1325 number assigned to the first special opcode.
1327 \textit{Opcode base is typically one greater than the highest-numbered
1328 \addttindexx{opcode\_base}
1329 standard opcode defined for the specified version of the line
1330 number information (12 in DWARF Versions 3, 4 and 5,
1331 \addtoindexx{DWARF Version 3}
1332 \addtoindexx{DWARF Version 4}
1333 \addtoindexx{DWARF Version 5}
1335 \addtoindexx{DWARF Version 2}
1337 If opcode\_base is less than the typical value,
1338 \addttindexx{opcode\_base}
1339 then standard opcode numbers greater than or equal to the
1340 opcode base are not used in the line number table of this unit
1341 (and the codes are treated as special opcodes). If \texttt{opcode\_base}
1342 is greater than the typical value, then the numbers between
1343 that of the highest standard opcode and the first special
1344 opcode (not inclusive) are used for vendor specific extensions.}
1347 \item \texttt{standard\_opcode\_lengths} (array of \HFTubyte) \\
1348 \addttindexx{standard\_opcode\_lengths}
1349 This array specifies the number of \addtoindex{LEB128} operands for each
1350 of the standard opcodes. The first element of the array
1351 corresponds to the opcode whose value is 1, and the last
1352 element corresponds to the opcode whose value
1353 is \texttt{opcode\_base - 1}.
1355 \textit{By increasing \texttt{opcode\_base}, and adding elements to this array,
1356 \addttindexx{opcode\_base}
1357 new standard opcodes can be added, while allowing consumers who
1358 do not know about these new opcodes to be able to skip them.}
1360 \textit{Codes for vendor specific extensions, if any, are described
1361 just like standard opcodes.}
1363 %%% Save the current enum counter so we can restart later
1364 %%% End this enumeration so the following text is outdented to
1365 %%% the left margin (because it applies to the many following
1367 \newcounter{saveenumi}
1368 \setcounter{saveenumi}{\value{enumi}}
1372 \textit{The remaining fields provide information about the
1373 source files used in the compilation. These fields
1374 have been revised in \DWARFVersionV{} to support these
1378 \textit{To allow new alternative means for a consumer to
1379 check that a file it can access is the same version
1380 as that used in the compilation.}
1382 \textit{To allow a producer to collect file name strings
1383 in a new section (\dotdebuglinestr{}) that can be used
1384 to merge duplicate file name strings.}
1386 \textit{To add the ability for producers to provide
1387 vendor-defined information that can be skipped by a consumer
1388 that is unprepared to process it.}
1391 \begin{enumerate}[1. ]
1392 %%% Resume enumeration count where it left off above
1393 \setcounter{enumi}{\value{saveenumi}}
1394 \item \texttt{directory\_entry\_format\_count} (\HFTubyte) \\
1395 \addttindexx{directory\_entry\_format\_count}
1396 A count of the number of entries that occur in the
1397 following \addttindex{directory\_entry\_format} field.
1400 \item \texttt{directory\_entry\_format} (sequence of ULEB128 pairs) \\
1401 \addttindexx{directory\_entry\_format}
1402 A sequence of directory entry format descriptions.
1403 Each description consists of a pair of ULEB128 values:
1405 \setlength{\itemsep}{0em}
1406 \item A content type code (see
1407 Sections \refersec{chap:standardcontentdescriptions} and
1408 \refersec{chap:vendordefinedcontentdescriptions}).
1410 \item A form code using the attribute form codes
1414 \item \texttt{directories\_count} (ULEB128) \\
1415 \addttindexx{directories\_count}
1416 A count of the number of entries that occur in the
1417 following directories field.
1420 \item \texttt{directories} (sequence of directory names) \\
1421 \addttindexx{directories}
1422 A sequence of directory names and optional related
1423 information. Each entry is encoded as described
1424 by the \addttindex{directory\_entry\_format} field.
1426 Entries in this sequence describe each path that was
1427 searched for included source files in this compilation,
1428 including the compilation directory of the compilation.
1429 (The paths include those directories specified by the
1430 user for the compiler to search and those the compiler
1431 searches without explicit direction.)
1433 The first entry is the current directory of the compilation.
1434 Each additional path entry is either a full path name or
1435 is relative to the current directory of the compilation.
1437 The line number program assigns a number (index) to each
1438 of the directory entries in order, beginning with 0.
1440 \textit{Prior to \DWARFVersionV, the current directory was not
1441 represented in the directories field and a directory index
1442 of 0 implicitly referred to that directory as found in the
1443 \DWATcompdir{} attribute of the compilation unit
1444 debugging information entry.
1445 In \DWARFVersionV, the current directory is explicitly present
1446 in the directories field. This is needed to support the
1447 common practice of stripping all but the line number sections
1448 (\dotdebugline{} and \dotdebuglinestr) from an executable.}
1450 \textit{Note that if a \dotdebuglinestr{} section is present,
1451 both the compilation unit debugging information entry
1452 and the line number header can
1453 share a single copy of the current directory name string.}
1455 \item \texttt{file\_name\_entry\_format\_count} (\HFTubyte) \\
1456 \addttindexx{file\_name\_entry\_format\_count}
1457 A count of the number of file entry format entries that
1458 occur in the following \addttindex{file\_name\_entry\_format} field.
1459 If this field is zero, then the \addttindex{file\_names\_count} field
1460 (see below) must also be zero.
1463 \item \texttt{file\_name\_entry\_format} (sequence of ULEB128 pairs) \\
1464 \addttindexx{file\_name\_entry\_format}
1465 A sequence of file entry format descriptions.
1466 Each description consists of a pair of ULEB128 values:
1468 \setlength{\itemsep}{0em}
1469 \item A content type code (see below)
1470 \item A form code using the attribute form codes
1473 \item \texttt{file\_names\_count} (ULEB128) \\
1474 \addttindexx{file\_names\_count}
1475 A count of the number of file name entries that occur
1476 in the following \addttindex{file\_names} field.
1479 \item \texttt{file\_names} (sequence of file name entries) \\
1480 \addttindexx{file\_names}
1481 A sequence of file names and optional related
1482 information. Each entry is encoded as described
1483 by the \addttindex{file\_name\_entry\_format} field.
1485 Entries in this sequence describe source files that
1486 contribute to the line number information for this
1487 compilation or is used in other contexts, such as in
1488 a declaration coordinate or a macro file inclusion.
1490 The first entry in the sequence is the primary source file
1491 whose file name exactly matches that given in the
1492 \DWATname{} attribute in the compilation unit
1493 debugging information entry.
1495 The line number program references file names in this
1496 sequence beginning with 0, and uses those numbers instead
1497 of file names in the line number program that follows.
1499 \textit{Prior to \DWARFVersionV, the current compilation
1500 file name was not represented in the \addttindex{file\_names}
1501 field. In \DWARFVersionV, the current compilation file name
1502 is explicitly present and has index 0. This is needed to support
1503 the common practice of stripping all but the line number sections
1504 (\dotdebugline{} and \dotdebuglinestr) from an executable.}
1506 \textit{Note that if a \dotdebuglinestr{} section is present,
1507 both the compilation unit debugging information entry
1508 and the line number header can
1509 share a single copy of the current file name string.}
1514 \subsubsection{Standard Content Descriptions}
1515 \label{chap:standardcontentdescriptions}
1516 DWARF-defined content type codes are used to indicate
1517 the type of information that is represented in one
1518 component of an include directory or file name description.
1519 The following type codes are defined.
1520 \begin{enumerate}[1. ]
1522 \item \DWLNCTpathTARG \\
1523 The component is a null-terminated path name string.
1524 If the associated form code is \DWFORMstring{}, then the
1525 string occurs immediately in the containing \texttt{directories}
1526 or \addttindex{file\_names} field. If the form code is \DWFORMlinestrp{},
1528 \DWFORMstrp{} or \DWFORMstrpsup{},
1530 then the string is included in the
1532 \dotdebuglinestr{}, \dotdebugstr{} or supplementary string section, respectively,
1534 and its offset occurs immediately in the containing
1535 \addttindex{directories} or \addttindex{file\_names} field.
1537 In the 32-bit DWARF format, the representation of a
1538 \DWFORMlinestrp{} value is a 4-byte unsigned offset; in the
1539 64-bit DWARF format, it is an 8-byte unsigned offset (see
1540 Section \refersec{datarep:32bitand64bitdwarfformats}).
1542 \textit{Note that this use of \DWFORMlinestrp{} is similar to
1543 \DWFORMstrp{} but refers to the \dotdebuglinestr{} section,
1546 In a \dotdebuglinedwo{} section, the form \DWFORMstrx{} may
1547 also be used. This refers into the \dotdebugstroffsetsdwo{}
1548 section (and indirectly also the \dotdebugstrdwo{} section)
1549 because no \texttt{.debug\_line\_str\_offsets.dwo} or
1550 \texttt{.debug\_line\_str.dwo} sections exist or are defined for
1551 use in split objects. (The form \DWFORMstring{} may also be used,
1552 but this precludes the benefits of string sharing.)
1554 \item \DWLNCTdirectoryindexTARG \\
1555 The unsigned directory index represents an entry in the
1556 directories field of the header. The index is 0 if
1557 the file was found in the current directory of the compilation
1558 (hence, the first directory in the directories field),
1559 1 if it was found in the second directory in the directories
1562 This content code is always paired with one of \DWFORMdataone,
1563 \DWFORMdatatwo{} or \DWFORMudata.
1565 \textit{The optimal form for a producer to use (which results in the
1566 minimum size for the set of \addttindex{include\_index} fields) depends not only
1567 on the number of directories in the directories
1568 field, but potentially on the order in which those directories are
1569 listed and the number of times each is used in the \addttindex{file\_names} field.}
1572 \item \DWLNCTtimestampTARG \\
1573 \DWLNCTtimestampNAME{} indicates that the value is the implementation-defined
1574 time of last modification of the file, or 0 if not available.
1575 It is always paired with one of the forms
1576 \DWFORMudata, \DWFORMdatafour, \DWFORMdataeight{} or \DWFORMblock.
1578 \item \DWLNCTsizeTARG \\
1579 \DWLNCTsizeNAME{} indicates that the value is the unsigned size of the
1580 file in bytes, or 0 if not available. It is paired with one of the
1581 forms \DWFORMudata, \DWFORMdataone, \DWFORMdatatwo, \DWFORMdatafour{}
1582 or \DWFORMdataeight.
1584 \item \DWLNCTMDfiveTARG \\
1585 \DWLNCTMDfiveNAME{} indicates that the value is a 16-byte \MDfive{} digest
1586 of the file contents. It is paired with form \DWFORMdatasixteen.
1589 \textit{An example that uses this line number header format
1590 is found in Appendix \refersec{app:linenumberheaderexample}.}
1592 \subsubsection{Vendor-defined Content Descriptions}
1593 \label{chap:vendordefinedcontentdescriptions}
1594 Vendor-defined content descriptions may be defined using content
1595 type codes in the range \DWLNCTlouserNAME{} to \DWLNCThiuserNAME{}. Each
1596 such code may be combined with one or more forms from the set:
1597 \DWFORMblock, \DWFORMblockone, \DWFORMblocktwo, \DWFORMblockfour,
1598 \DWFORMdataone, \DWFORMdatatwo, \DWFORMdatafour, \DWFORMdataeight,
1600 \DWFORMflag, \DWFORMlinestrp, \DWFORMsdata, \DWFORMsecoffset,
1601 \DWFORMstring, \DWFORMstrp, \DWFORMstrx{} and \DWFORMudata.
1603 \textit{If a consumer encounters a vendor-defined content type that
1604 it does not understand, it should skip the content data as though
1605 it were not present.}
1608 \subsection{The Line Number Program}
1609 \label{chap:linenumberprogram}
1610 As stated before, the goal of a line number program is to build
1611 a matrix representing one compilation unit, which may have
1612 produced multiple sequences of target machine instructions.
1613 Within a sequence, addresses and
1614 \addtoindex{operation pointer}s may only increase.
1615 (Line numbers may decrease in cases of pipeline
1616 scheduling or other optimization.)
1619 \subsubsection{Special Opcodes}
1620 \label{chap:specialopcodes}
1621 Each \HFTubyte{} special opcode has the following effect on the state machine:
1623 \begin{enumerate}[1. ]
1625 \item Add a signed integer to the \texttt{line} register.
1627 \item Modify the \addtoindex{operation pointer} by incrementing the
1628 \texttt{address} and \addttindex{op\_index} registers as described below.
1630 \item Append a row to the matrix using the current values
1631 of the state machine registers.
1633 \item Set the \addttindex{basic\_block} register to \doublequote{false.} \addtoindexx{basic block}
1634 \item Set the \addttindex{prologue\_end} register to \doublequote{false.}
1635 \item Set the \addttindex{epilogue\_begin} register to \doublequote{false.}
1636 \item Set the \addttindex{discriminator} register to 0.
1640 All of the special opcodes do those same seven things; they
1641 differ from one another only in what values they add to the
1642 \texttt{line}, \texttt{address} and \addttindex{op\_index} registers.
1645 \textit{Instead of assigning a fixed meaning to each special opcode,
1646 the line number program uses several parameters in the header
1647 to configure the instruction set. There are two reasons
1648 for this. First, although the opcode space available for
1649 special opcodes ranges from 13 through 255, the lower
1650 bound may increase if one adds new standard opcodes. Thus, the
1651 \texttt{opcode\_base} field of the line number program header gives the
1652 value of the first special opcode. Second, the best choice of
1653 special\dash opcode meanings depends on the target architecture. For
1654 example, for a RISC machine where the compiler\dash generated code
1655 interleaves instructions from different lines to schedule
1656 the pipeline, it is important to be able to add a negative
1657 value to the \texttt{line} register to express the fact that a later
1658 instruction may have been emitted for an earlier source
1659 line. For a machine where pipeline scheduling never occurs,
1660 it is advantageous to trade away the ability to decrease
1661 the \texttt{line} register (a standard opcode provides an alternate
1662 way to decrease the line number) in return for the ability
1663 to add larger positive values to the \texttt{address} register. To
1664 permit this variety of strategies, the line number program
1666 \addttindex{line\_base}
1667 field that specifies the minimum
1668 value which a special opcode can add to the line register
1670 \addttindex{line\_range}
1671 field that defines the range of values it
1672 can add to the line register.}
1675 A special opcode value is chosen based on the amount that needs
1676 to be added to the \texttt{line}, \texttt{address} and \addttindex{op\_index} registers.
1677 The maximum line increment for a special opcode is the value
1679 \addttindex{line\_base}
1680 field in the header, plus the value of the
1681 \addttindex{line\_range} field, minus 1 (line base +
1683 If the desired line increment is greater than the maximum
1684 line increment, a standard opcode must be used instead of a
1685 special opcode. The \addtoindex{operation advance} represents the number
1686 of operations to skip when advancing the \addtoindex{operation pointer}.
1689 The special opcode is then calculated using the following formula:
1692 (\textit{desired line increment} - \addttindex{line\_base}) +
1693 (\addttindex{line\_range} * \textit{operation advance}) + \addttindex{opcode\_base}
1695 If the resulting opcode is greater than 255, a standard opcode
1696 must be used instead.
1698 \textit{When \addttindex{maximum\_operations\_per\_instruction} is 1,
1699 the operation advance is simply the address increment divided by the
1700 \addttindex{minimum\_instruction\_length}.}
1703 To decode a special opcode, subtract the \addttindex{opcode\_base} from
1704 the opcode itself to give the \textit{adjusted opcode}.
1705 The \textit{operation advance}
1706 is the result of the adjusted opcode divided by the
1707 \addttindex{line\_range}. The new \texttt{address} and
1708 \addttindex{op\_index} values are given by
1710 \textit{adjusted opcode} = opcode \dash opcode\_base
1711 \textit{operation advance} = \textit{adjusted opcode} / line\_range
1713 new address = address +
1714 \addttindex{minimum\_instruction\_length} *
1715 ((\addttindex{op\_index} + \addtoindex{operation advance}) / \addttindex{maximum\_operations\_per\_instruction})
1718 (\addttindex{op\_index} + \addtoindex{operation advance}) \% \addttindex{maximum\_operations\_per\_instruction}
1721 \textit{When the \addttindex{maximum\_operations\_per\_instruction}
1723 \texttt{op\_index} is always 0 and these calculations simplify to
1724 those given for addresses in \DWARFVersionIII{} and earlier.}
1726 The amount to increment the line register is the
1727 \addttindex{line\_base} plus
1729 \textit{\addtoindex{adjusted opcode}} modulo the
1730 \addttindex{line\_range}. That
1734 line increment = \addttindex{line\_base} + (\textit{adjusted opcode} \% \addttindex{line\_range})
1737 \textit{See Appendix \refersec{app:linenumberspecialopcodeexample} for an example.}
1741 \subsubsection{Standard Opcodes}
1742 \label{chap:standardopcodes}
1744 The standard opcodes, their applicable operands and the
1745 actions performed by these opcodes are as follows:
1747 \begin{enumerate}[1. ]
1749 \item \textbf{\DWLNScopyTARG} \\
1750 The \DWLNScopyNAME{}
1751 opcode takes no operands. It appends a row
1752 to the matrix using the current values of the state machine
1753 registers. Then it sets the \addttindex{discriminator} register to 0,
1754 and sets the \addttindex{basic\_block},
1755 \addttindex{prologue\_end} and
1756 \addttindex{epilogue\_begin}
1757 registers to \doublequote{false.}
1760 \item \textbf{\DWLNSadvancepcTARG} \\
1761 The \DWLNSadvancepcNAME{}
1762 opcode takes a single unsigned LEB128\addtoindexx{LEB128!unsigned}
1763 operand as the \addtoindex{operation advance} and modifies the \texttt{address}
1764 and \addttindex{op\_index} registers as specified in
1765 Section \refersec{chap:specialopcodes}.
1767 \item \textbf{\DWLNSadvancelineTARG} \\
1768 The \DWLNSadvancelineNAME{}
1769 opcode takes a single signed LEB128\addtoindexx{LEB128!signed}
1770 operand and adds that value to the \texttt{line} register of the
1774 \item \textbf{\DWLNSsetfileTARG} \\
1775 The \DWLNSsetfileNAME{} opcode takes a single
1776 unsigned LEB128\addtoindexx{LEB128!unsigned}
1777 operand and stores it in the \texttt{file} register
1778 of the state machine.
1781 \item \textbf{\DWLNSsetcolumnTARG} \\
1782 The \DWLNSsetcolumnNAME{} opcode takes a
1783 single unsigned LEB128\addtoindexx{LEB128!unsigned} operand
1784 and stores it in the \texttt{column}
1785 register of the state machine.
1788 \item \textbf{\DWLNSnegatestmtTARG} \\
1789 The \DWLNSnegatestmtNAME{} opcode takes no
1790 operands. It sets the \addttindex{is\_stmt} register of the state machine
1791 to the logical negation of its current value.
1794 \item \textbf{\DWLNSsetbasicblockTARG} \\
1795 The \DWLNSsetbasicblockNAME{}
1797 \addtoindexx{basic block}
1799 It sets the \addttindex{basic\_block} register of the
1800 state machine to \doublequote{true.}
1802 \item \textbf{\DWLNSconstaddpcTARG} \\
1803 The \DWLNSconstaddpcNAME{} opcode takes
1804 no operands. It advances the \texttt{address} and \addttindex{op\_index} registers
1805 by the increments corresponding to special opcode 255.
1807 \textit{When the line number program needs to advance the \texttt{address}
1808 by a small amount, it can use a single special opcode,
1809 which occupies a single byte. When it needs to advance the
1810 \texttt{address} by up to twice the range of the last special opcode,
1811 it can use \DWLNSconstaddpc{} followed by a special opcode,
1812 for a total of two bytes. Only if it needs to advance the
1813 address by more than twice that range will it need to use
1814 both \DWLNSadvancepc{} and a special opcode, requiring three
1817 \item \textbf{\DWLNSfixedadvancepcTARG} \\
1818 The \DWLNSfixedadvancepcNAME{} opcode
1819 takes a single \HFTuhalf{} (unencoded) operand and adds it to the
1820 \texttt{address} register of the state machine and sets the \addttindex{op\_index}
1821 register to 0. This is the only standard opcode whose operand
1822 is \textbf{not} a variable length number. It also does
1823 \textbf{not} multiply the
1824 operand by the \addttindex{minimum\_instruction\_length}
1825 field of the header.
1827 \textit{Some assemblers may not be able emit
1828 \DWLNSadvancepc{} or special opcodes because they cannot encode
1829 \addtoindex{LEB128} numbers or judge when
1830 the computation of a special opcode overflows and requires
1831 the use of \DWLNSadvancepc. Such assemblers, however, can
1832 use \DWLNSfixedadvancepc{} instead, sacrificing compression.}
1835 \item \textbf{\DWLNSsetprologueendTARG} \\
1836 The \DWLNSsetprologueendNAME{}
1837 opcode takes no operands. It sets the
1838 \addttindex{prologue\_end} register
1839 to \doublequote{true.}
1841 \textit{When a breakpoint is set on entry to a function, it is
1842 generally desirable for execution to be suspended, not on the
1843 very first instruction of the function, but rather at a point
1844 after the function's frame has been set up, after any language
1845 defined local declaration processing has been completed,
1846 and before execution of the first statement of the function
1847 begins. Debuggers generally cannot properly determine where
1848 this point is. This command allows a compiler to communicate
1849 the location(s) to use.}
1851 \textit{In the case of optimized code, there may be more than one such
1852 location; for example, the code might test for a special case
1853 and make a fast exit prior to setting up the frame.}
1855 \textit{Note that the function to which the
1856 \addtoindex{prologue end} applies cannot
1857 be directly determined from the line number information alone;
1858 it must be determined in combination with the subroutine
1859 information entries of the compilation (including inlined
1863 \item \textbf{\DWLNSsetepiloguebeginTARG} \\
1864 The \DWLNSsetepiloguebeginNAME{} opcode takes no operands. It
1865 sets the \addttindex{epilogue\_begin} register to \doublequote{true.}
1867 \textit{When a breakpoint is set on the exit of a function or execution
1868 steps over the last executable statement of a function, it is
1869 generally desirable to suspend execution after completion of
1870 the last statement but prior to tearing down the frame (so that
1871 local variables can still be examined). Debuggers generally
1872 cannot properly determine where this point is. This command
1873 allows a compiler to communicate the location(s) to use.}
1875 \textit{Note that the function to which the
1876 \addtoindex{epilogue end} applies cannot
1877 be directly determined from the line number information alone;
1878 it must be determined in combination with the subroutine
1879 information entries of the compilation (including inlined
1882 \textit{In the case of a trivial function, both
1883 \addtoindex{prologue end} and
1884 \addtoindex{epilogue begin} may occur at the same address.}
1886 \item \textbf{\DWLNSsetisaTARG} \\
1887 The \DWLNSsetisaNAME{} opcode takes a single
1888 unsigned LEB128\addtoindexx{LEB128!unsigned} operand and stores that value in the
1890 register of the state machine.
1894 \subsubsection{Extended Opcodes}
1895 \label{chap:extendedopcodes}
1897 The extended opcodes are as follows:
1899 \begin{enumerate}[1. ]
1901 \item \textbf{\DWLNEendsequenceTARG} \\
1902 The \DWLNEendsequenceNAME{} opcode takes no operands. It sets the
1903 \addttindex{end\_sequence}
1904 register of the state machine to \doublequote{true} and
1905 appends a row to the matrix using the current values of the
1906 state-machine registers. Then it resets the registers to the
1907 initial values specified above
1908 (see Section \refersec{chap:statemachineregisters}).
1910 number program sequence must end with a \DWLNEendsequence{}
1911 instruction which creates a row whose address is that of the
1912 byte after the last target machine instruction of the sequence.
1915 \item \textbf{\DWLNEsetaddressTARG} \\
1916 The \DWLNEsetaddressNAME{} opcode takes a single relocatable
1917 address as an operand. The size of the operand is the size
1918 of an address on the target machine. It sets the \texttt{address}
1919 register to the value given by the relocatable address and
1920 sets the \addttindex{op\_index} register to 0.
1922 \textit{All of the other line number program opcodes that
1923 affect the \texttt{address} register add a delta to it. This instruction
1924 stores a relocatable value into it instead.}
1926 \item \textbf{\DWLNEsetdiscriminatorTARG} \\
1927 The \DWLNEsetdiscriminatorNAME{}
1928 opcode takes a single
1929 parameter, an unsigned LEB128\addtoindexx{LEB128!unsigned}
1930 integer. It sets the
1931 \addttindex{discriminator} register to the new value.
1935 \textit{The DW\_LNE\_define\_file operation defined
1936 in earlier versions of DWARF is deprecated in \DWARFVersionV.}
1937 \addtoindexx{DW\_LNE\_define\_file (deprecated)}
1939 \textit{Appendix \refersec{app:linenumberprogramexample}
1940 gives some sample line number programs.}
1942 \section{Macro Information}
1943 \label{chap:macroinformation}
1944 \textit{Some languages, such as
1946 \addtoindex{C++}, provide a way to replace
1947 \addtoindexx{macro information}
1948 text in the source program with macros defined either in the
1949 source file itself, or in another file included by the source
1950 file. Because these macros are not themselves defined in the
1951 target language, it is difficult to represent their definitions
1952 using the standard language constructs of DWARF. The debugging
1953 information therefore reflects the state of the source after
1954 the macro definition has been expanded, rather than as the
1955 programmer wrote it. The macro information table provides a way
1956 of preserving the original source in the debugging information.}
1959 Section \refersec{chap:fullandpartialcompilationunitentries},
1960 the macro information for a
1961 given compilation unit is represented in the
1963 section of an object file.
1966 \textit{The \dotdebugmacro{} section is new in
1967 \DWARFVersionV, and supersedes the
1968 \dotdebugmacinfo{} section of earlier DWARF versions.
1969 While \dotdebugmacro{} and \dotdebugmacinfo{}
1970 sections cannot both occur in the same compilation unit, both may be found in the
1971 set of units that make up an executable or shared object file.}
1973 \textit{The representation of debugging information in the \dotdebugmacinfo{} section is specified
1974 in earlier versions of the DWARF standard. Note that the \dotdebugmacinfo{} section does not contain
1975 any headers and does not support sharing of strings or sharing of repeated macro sequences.}
1977 The macro information for each compilation unit consists of one or
1978 more macro units. Each macro unit starts with a header
1979 and is followed by a series of macro information entries or file
1980 inclusion entries. Each entry consists of an opcode followed by
1981 zero or more operands. Each macro unit ends with an entry
1982 containing an opcode of 0.
1984 In all macro information entries,
1985 the line number of the entry is encoded as an
1986 unsigned LEB128 integer.
1989 \subsection{Macro Information Header}
1990 The macro information header contains the following fields:
1992 \begin{enumerate}[1. ]
1993 \item \texttt{version} (\HFTuhalf) \\
1994 A version number (see Section \refersec{datarep:macroinformation}).
1995 This number is specific to the macro information and is independent
1996 of the DWARF version number.
1998 \item \texttt{flags} (\HFTubyte) \\
1999 The bits of the \texttt{flags} field are interpreted as a set
2000 of flags, some of which may indicate that additional fields follow.
2003 The following flags, beginning with the least significant bit, are defined:
2005 \item \HFNoffsetsizeflag \\
2006 If the \HFNoffsetsizeflag{} is zero, the header is for a 32-bit
2007 DWARF format macro section and all offsets are 4 bytes long;
2008 if it is one, the header is for a 64-bit DWARF format macro section
2009 and all offsets are 8 bytes long.
2011 \item \addttindex{debug\_line\_offset\_flag} \\
2012 If the \addttindex{debug\_line\_offset\_flag} is one,
2013 the \addttindex{debug\_line\_offset} field (see below) is present.
2014 If zero, that field is omitted.
2016 \item \addttindex{opcode\_operands\_table\_flag} \\
2017 If the \addttindex{opcode\_operands\_table\_flag} is one,
2018 the \addttindex{opcode\_operands\_table} field (see below) is present.
2019 If zero, that field is omitted.
2022 All other flags are reserved by DWARF.
2024 \item \addttindex{debug\_line\_offset} \\
2025 An offset in the \dotdebugline{} section of the
2026 beginning of the line number information in the containing
2027 compilation, encoded as a 4-byte offset for a 32-bit DWARF
2028 format macro section and an 8-byte offset for a 64-bit DWARF format
2031 \item \addttindex{opcode\_operands\_table} \\
2032 An \texttt{opcode\_operands\_table} describing the operands
2033 of the macro information entry opcodes.
2035 The macro information entries defined in this standard may, but need not, be
2036 described in the table, while other user-defined entry opcodes used in the section
2037 are described there. Vendor extension entry opcodes are
2038 allocated in the range from \DWMACROlouser{} to \DWMACROhiuser. Other
2039 unassigned codes are reserved for future DWARF standards.
2042 The table starts with a 1-byte \texttt{count} of the defined opcodes, followed by
2043 an entry for each of those opcodes. Each entry starts with a 1-byte unsigned
2044 opcode number, followed by unsigned LEB128\addtoindexx{ULEB128} encoded number of operands
2045 and for each operand there is a single unsigned byte describing the form in which
2046 the operand is encoded. The allowed forms are:
2047 \DWFORMblock, \DWFORMblockone, \DWFORMblocktwo, \DWFORMblockfour,
2048 \DWFORMdataone, \DWFORMdatatwo, \DWFORMdatafour, \DWFORMdataeight,
2051 \DWFORMflag, \DWFORMlinestrp, \DWFORMsdata,
2053 \DWFORMsecoffset, \DWFORMstring, \DWFORMstrp{},
2055 \DWFORMstrpsup, \DWFORMstrx{} and \DWFORMudata.
2059 \subsection{Macro Information Entries}
2060 \label{chap:macroinformationentries}
2061 All macro information entries within a \dotdebugmacro{}
2062 section for a given compilation unit appear in the same
2063 order in which the directives were processed by the
2064 compiler (after taking into account the effect of the
2065 macro import directives).
2067 \textit{The source file in which a macro information entry occurs
2068 can be derived by interpreting the sequence of entries from the
2069 beginning of the \dotdebugmacro{} section. \DWMACROstartfile{} and
2070 \DWMACROendfile{} indicate changes in the containing file.}
2072 \subsubsection{Define and Undefine Entries}
2073 \label{chap:defineandundefineentries}
2074 The define and undefine macro entries have multiple forms that
2075 use different representations of their two operands.
2077 While described in pairs below, the forms of define
2078 and undefine entries may be freely intermixed.
2080 \begin{enumerate}[1. ]
2082 \itembfnl{\DWMACROdefineTARG{}, \DWMACROundefTARG{}}
2083 A \DWMACROdefineNAME{} or \DWMACROundefNAME{} entry has two
2084 operands. The first operand encodes the source line number
2085 of the \texttt{\#define} or \texttt{\#undef} macro directive.
2086 The second operand is a null-terminated character
2087 string for the macro being defined or undefined.
2089 The contents of the operands are described below (see Sections
2090 \ref{chap:macrodefinestring} and \referfol{chap:macroundefinestring}).
2092 \itembfnl{\DWMACROdefinestrpTARG{}, \DWMACROundefstrpTARG{}}
2093 A \DWMACROdefinestrpNAME{} or \DWMACROundefstrpNAME{}
2094 entry has two operands. The first operand encodes the source line number
2095 of the \texttt{\#define} or \texttt{\#undef} macro directive.
2096 The second operand consists of an offset into a string table contained in
2097 the \dotdebugstr{} section of the object file. The size of the operand is
2098 given in the header \HFNoffsetsizeflag{} field.
2100 The contents of the operands are described below (see Sections
2101 \ref{chap:macrodefinestring} and \referfol{chap:macroundefinestring}).
2103 \itembfnl{\DWMACROdefinestrxTARG{}, \DWMACROundefstrxTARG{}}
2104 A \DWMACROdefinestrxNAME{} or \DWMACROundefstrxNAME{} entry
2105 has two operands. The first operand encodes the line number
2106 of the \texttt{\#define} or \texttt{\#undef} macro directive.
2107 The second operand identifies a string; it is represented using an
2108 unsigned LEB128\addtoindexx{ULEB128} encoded value,
2109 which is interpreted as a zero-based index into an array of offsets in the
2110 \dotdebugstroffsets{} section.
2112 The contents of the operands are described below (see Sections
2113 \ref{chap:macrodefinestring} and \referfol{chap:macroundefinestring}).
2116 \itembfnl{\DWMACROdefinesupTARG{}, \DWMACROundefsupTARG{}}
2117 A \DWMACROdefinesupNAME{} or \DWMACROundefsupNAME{} entry
2118 has two operands. The first operand encodes the line number
2119 of the \texttt{\#define} or \texttt{\#undef} macro directive.
2120 The second operand identifies a string; it is represented as
2121 an offset into a string table contained in the \dotdebugstr{}
2122 section of the \addtoindex{supplementary object file}.
2123 The size of the operand depends on the macro section header
2124 \HFNoffsetsizeflag{} field.
2126 The contents of the operands are described below (see Sections
2127 \ref{chap:macrodefinestring} and \referfol{chap:macroundefinestring}).
2132 \subsubsection{Macro Define String}
2133 \label{chap:macrodefinestring}
2136 \DWMACROdefinestrp{},
2137 \DWMACROdefinestrx{} or
2139 entry, the value of the
2140 second operand is the name of the macro symbol that is defined
2141 at the indicated source line, followed immediately by the
2142 \addtoindex{macro formal parameter list}
2143 including the surrounding parentheses (in
2144 the case of a function-like macro) followed by the definition
2145 string for the macro. If there is no formal parameter list,
2146 then the name of the defined macro is followed immediately by
2147 its definition string.
2149 In the case of a function-like macro definition, no whitespace
2150 characters appear between the name of the defined
2151 macro and the following left parenthesis. Formal parameters
2152 are separated by a comma without any whitespace.
2154 character separates the right parenthesis that terminates
2155 the formal parameter list and the following definition string.
2157 In the case of a \doublequote{normal} (that is, non-function-like) macro
2158 definition, exactly one space character separates the
2159 name of the defined macro from the following definition text.
2161 \subsubsection{Macro Undefine String}
2162 \label{chap:macroundefinestring}
2165 \DWMACROundefstrp{},
2166 \DWMACROundefstrx{} or
2168 entry, the value of the second string is the name of the pre-processor
2169 symbol that is undefined at the indicated source line.
2171 \subsubsection{Entries for Command Line Options}
2172 \label{chap:entriesforcommandlineoptions}
2173 \DWMACROdefineINDX{}\DWMACROdefinestrpINDX{}\DWMACROdefinestrxINDX
2174 \DWMACROundefINDX{}\DWMACROundefstrpINDX{}\DWMACROundefstrxINDX
2176 generates a define or undefine entry for
2177 each pre-processor symbol which is defined or undefined by
2178 some means other than such a directive
2179 within the compiled source text. In particular, pre-processor
2180 symbol definitions and undefinitions which occur as a
2181 result of command line options (when invoking the compiler)
2182 are represented by their own define and
2185 All such define and undefine entries representing compilation
2186 options appear before the first \DWMACROstartfile{}
2187 entry for that compilation unit
2188 (see Section \referfol{chap:fileinclusionentries})
2189 and encode the value 0 in their line number operands.
2191 \subsection{File Inclusion Entries}
2192 \label{chap:fileinclusionentries}
2194 \subsubsection{Source Include Directives}
2195 \label{chap:sourceincludedirectives}
2197 The following directives describe a source
2198 file inclusion directive (\texttt{\#include} in
2199 \addtoindex{C}/\addtoindex{C++}) and the
2200 ending of an included file.
2202 \begin{enumerate}[1. ]
2204 \itembfnl{\DWMACROstartfileTARG{}}
2205 A \DWMACROstartfileNAME{} entry has two operands. The
2206 first operand encodes the line number of the source line on
2207 which the \texttt{\#include} macro directive occurs.
2208 The second operand encodes a source file name index.
2210 The source file name index is the file number in the
2211 line number information table for the compilation unit.
2213 If a \DWMACROstartfileNAME{} entry is present, the header
2214 contains a reference to the \dotdebugline{} section of
2217 \itembfnl{\DWMACROendfileTARG{}}
2218 A \DWMACROendfileNAME{} entry has no operands. The presence of
2219 the entry marks the end of the current source file inclusion.
2224 When providing macro information in an object file,
2225 a producer generates \DWMACROstartfile{} and
2226 \DWMACROendfile{} entries for the source file submitted to
2227 the compiler for compilation. This \DWMACROstartfile{} entry
2228 has the value 0 in its line number operand and references
2229 the file entry in the line number information table for the
2230 primary source file.
2232 \subsubsection{Importation of Macro Units}
2233 \label{chap:importationofmacrounits}
2234 The import entries make it possible to replicate macro units.
2235 The first form supports replication within the current compilation
2236 and the second form supports replication across separate
2237 executable or shared object files.
2239 \textit{Import entries do not reflect the source program
2240 and, in fact, are not necessary at all. However, they do
2241 provide a mechanism that can be used to reduce redundancy
2242 in the macro information and thereby to save space.}
2244 \begin{enumerate}[1. ]
2246 \itembfnl{\DWMACROimportTARG{}}
2247 A \DWMACROimportNAME{} entry has one operand, an offset into
2248 another part of the \dotdebugmacro{} section that is
2249 the beginning of a target macro unit. The size of the operand
2250 depends on the header \HFNoffsetsizeflag{} field. The
2251 \DWMACROimportNAME{} entry instructs the consumer to
2252 replicate the sequence of entries following the target macro
2253 header which begins at the given
2254 \dotdebugmacro{} offset, up to, but excluding,
2255 the terminating entry with opcode \texttt{0},
2256 as though it occurs in place of the import operation.
2258 \itembfnl{\DWMACROimportsupTARG}
2259 A \DWMACROimportsupNAME{} entry has one operand, an
2260 offset from the start of the \dotdebugmacro{} section in the
2261 \addtoindex{supplementary object file}.
2262 The size of the operand depends on the section header
2263 \HFNoffsetsizeflag{} field.
2264 Apart from the different location in which to find the macro unit,
2265 this entry type is equivalent to \DWMACROimport.
2267 \textit{This entry type is aimed at sharing duplicate
2268 macro units between \dotdebugmacro{}
2269 sections from different executable or shared object files.}
2272 From within the \dotdebugmacro{} section of the
2273 \addtoindex{supplementary object file}, \DWMACROdefinestrp{}
2274 and \DWMACROundefstrp{} entries refer to the
2275 \dotdebugstr{} section of that same supplementary file;
2276 similarly, \DWMACROimport{} entries refer to the
2277 \dotdebugmacro{} section of that same supplementary file.
2283 \section{Call Frame Information}
2284 \label{chap:callframeinformation}
2285 \addtoindexx{unwind|see{virtual unwind}}\addtoindexx{virtual unwind}
2287 \textit{Debuggers often need to be able to view and modify the
2288 state of any subroutine activation that is
2289 \addtoindexx{activation of call frame}
2290 on the call stack. An activation consists of:}
2293 \item \textit{A code location that is within the
2294 subroutine. This location is either the place where the program
2295 stopped when the debugger got control (for example, a breakpoint), or
2296 is a place where a subroutine made a call or was interrupted
2297 by an asynchronous event (for example, a signal).}
2299 \item \textit{An area of memory that is allocated on a stack called a
2300 \doublequote{call frame.} The call frame is identified by an address
2301 on the stack. We refer to this address as the Canonical
2302 Frame Address or CFA. Typically, the CFA is defined to be the
2303 value of the stack pointer at the call site in the previous
2304 frame (which may be different from its value on entry to the
2307 \item \textit{A set of registers that are in use by the subroutine
2308 at the code location.}
2312 \textit{Typically, a set of registers are designated to be preserved
2313 across a call. If a callee wishes to use such a register, it
2314 saves the value that the register had at entry time in its call
2315 frame and restores it on exit. The code that allocates space
2316 on the call frame stack and performs the save operation is
2317 called the subroutine\textquoteright{s} \addtoindex{prologue}, and the code that performs
2318 the restore operation and deallocates the frame is called its
2319 \addtoindex{epilogue}. Typically, the
2320 \addtoindex{prologue} code is physically at the
2321 beginning of a subroutine and the
2322 \addtoindex{epilogue} code is at the end.}
2324 \textit{To be able to view or modify an activation that is not
2325 on the top of the call frame stack, the debugger must
2326 virtually unwind the stack of activations until
2327 it finds the activation of interest. A debugger virtually unwinds
2328 a stack in steps. Starting with the current activation it
2329 virtually restores any registers that were preserved by the
2330 current activation and computes the predecessor\textquoteright{s} CFA and
2331 code location. This has the logical effect of returning from
2332 the current subroutine to its predecessor. We say that the
2333 debugger virtually unwinds the stack because the actual state
2334 of the target process is unchanged.}
2337 \textit{The virtual unwind
2338 operation needs to know where registers are
2339 saved and how to compute the predecessor\textquoteright{s} CFA and code
2340 location. When considering an architecture-independent way
2341 of encoding this information one has to consider a number of
2344 \begin{itemize} % bullet list
2346 \item \textit{Prologue
2347 \addtoindexx{prologue}
2349 \addtoindex{epilogue} code is not always in
2350 distinct \nolink{blocks}
2351 at the beginning and end of a subroutine. It is common
2352 to duplicate the \addtoindex{epilogue} code
2353 at the site of each return
2354 from the code. Sometimes a compiler breaks up the register
2355 save/unsave operations and moves them into the body of the
2356 subroutine to just where they are needed.}
2359 \item \textit{Compilers use different ways to manage the call
2360 frame. Sometimes they use a frame pointer register, sometimes
2363 \item \textit{The algorithm to compute CFA changes as you progress through
2364 the \addtoindex{prologue}
2365 and \addtoindex{epilogue code}.
2366 (By definition, the CFA value
2369 \item \textit{Some subroutines have no call frame.}
2371 \item \textit{Sometimes a register is saved in another register that by
2372 convention does not need to be saved.}
2374 \item \textit{Some architectures have special instructions that perform
2375 some or all of the register management in one instruction,
2376 leaving special information on the stack that indicates how
2377 registers are saved.}
2379 \item \textit{Some architectures treat return address values specially. For
2380 example, in one architecture, the call instruction guarantees
2381 that the low order two bits will be zero and the return
2382 instruction ignores those bits. This leaves two bits of
2383 storage that are available to other uses that must be treated
2390 \subsection{Structure of Call Frame Information}
2391 \label{chap:structureofcallframeinformation}
2393 DWARF supports virtual unwinding by defining an architecture
2394 independent basis for recording how subprograms save and restore
2395 registers during their lifetimes. This basis must be augmented
2396 on some machines with specific information that is defined by
2397 an architecture specific ABI authoring committee, a hardware
2398 vendor, or a compiler producer. The body defining a specific
2399 augmentation is referred to below as the \doublequote{augmenter.}
2402 Abstractly, this mechanism describes a very large table that
2403 has the following structure:
2406 LOC CFA R0 R1 ... RN
2414 The first column indicates an address for every location
2415 that contains code in a program. (In shared object files, this
2416 is an object-relative offset.) The remaining columns contain
2417 virtual unwinding rules that are associated with the indicated
2420 The CFA column defines the rule which computes the Canonical
2421 Frame Address value; it may be either a register and a signed
2422 offset that are added together, or a DWARF expression that
2426 The remaining columns are labelled by register number. This
2427 includes some registers that have special designation on
2428 some architectures such as the PC and the stack pointer
2429 register. (The actual mapping of registers for a particular
2430 architecture is defined by the augmenter.) The register columns
2431 contain rules that describe whether a given register has been
2432 saved and the rule to find the value for the register in the
2436 The register rules are:
2438 \begin{longtable}{lP{9cm}}
2440 &A register that has this rule has no recoverable value in the previous frame.
2441 (By convention, it is not preserved by a callee.) \\
2444 &This register has not been modified from the previous frame. (By convention,
2445 it is preserved by the callee, but the callee has not modified it.) \\
2448 &The previous value of this register is saved at the address CFA+N where CFA
2449 is the current CFA value and N is a signed offset.\\
2452 &The previous value of this register is the value CFA+N where CFA is the
2453 current CFA value and N is a signed offset.\\
2456 &The previous value of this register is stored
2457 in another register numbered R.\\
2460 &The previous value of this register is located at the address produced by
2461 executing the DWARF expression E (see Section \refersec{chap:dwarfexpressions}).\\
2464 &The previous value of this register is the value produced by executing the
2465 DWARF expression E (see Section \refersec{chap:dwarfexpressions}).\\
2468 &The rule is defined externally to this specification by the augmenter.\\
2472 \textit{This table would be extremely large if actually constructed
2473 as described. Most of the entries at any point in the table
2474 are identical to the ones above them. The whole table can be
2475 represented quite compactly by recording just the differences
2476 starting at the beginning address of each subroutine in
2480 The virtual unwind information is encoded in a self-contained
2482 \dotdebugframe{}. Entries in a
2483 \dotdebugframe{} section
2484 are aligned on a multiple of the address size relative to
2485 the start of the section and come in two forms: a Common
2486 \addtoindexx{common information entry}
2487 Information Entry (CIE) and a
2488 \addtoindexx{frame description entry}
2489 Frame Description Entry (FDE).
2491 \textit{If the range of code addresses for a function is not
2492 contiguous, there may be multiple CIEs and FDEs corresponding
2493 to the parts of that function.}
2496 A Common Information Entry holds information that is shared
2497 among many Frame Description Entries. There is at least one
2498 CIE in every non-empty \dotdebugframe{} section. A CIE contains
2499 the following fields, in order:
2500 \begin{enumerate}[1. ]
2501 \item \HFNlength{} (\livelink{datarep:initiallengthvalues}{initial length}) \\
2502 A constant that gives the number of bytes of the CIE structure,
2503 not including the length field itself
2504 (see Section \refersec{datarep:initiallengthvalues}).
2506 size of the \texttt{length} field plus the value of \texttt{length} must be an
2507 integral multiple of the address size.
2509 \item \HFNCIEid{} (4 or 8 bytes, see Section \refersec{datarep:32bitand64bitdwarfformats}) \\
2510 A constant that is used to distinguish CIEs from FDEs.
2512 \item \HFNversion{} (\HFTubyte) \\
2513 A version number\addtoindexx{version number!call frame information}
2514 (see Section \refersec{datarep:callframeinformation}).
2515 This number is specific to the call frame information
2516 and is independent of the DWARF version number.
2519 \item \HFNaugmentation{} (\HFTaugstring) \\
2520 A null-terminated UTF\dash 8 string that identifies the augmentation
2521 to this CIE or to the FDEs that use it. If a reader encounters
2522 an augmentation string that is unexpected, then only the
2523 following fields can be read:
2528 \item CIE: \HFNlength, \HFNCIEid, \HFNversion, \HFNaugmentation
2530 \item FDE: \HFNlength, \HFNCIEpointer, \HFNinitiallocation, \HFNaddressrange
2533 If there is no augmentation, this value is a zero byte.
2536 \textit{The augmentation string allows users to indicate that there
2537 is additional target\dash specific information in the CIE or FDE
2538 which is needed to virtually
2539 unwind a stack frame. For example, this
2540 might be information about dynamically allocated data which
2541 needs to be freed on exit from the routine.}
2543 \textit{Because the \dotdebugframe{} section is useful independently of
2544 any \dotdebuginfo{} section, the augmentation string always uses
2545 UTF\dash 8 encoding.}
2548 \item \HFNaddresssize{} (\HFTubyte) \\
2549 The size of a target address in this CIE and any FDEs that
2550 use it, in bytes. If a compilation unit exists for this frame,
2551 its address size must match the address size here.
2553 \item \HFNsegmentselectorsize{} (\HFTubyte) \\
2554 The size of a segment selector in this CIE and any FDEs that
2557 \item \HFNcodealignmentfactor{} (unsigned LEB128)
2558 \addtoindexx{LEB128!unsigned}\addtoindexx{unsigned LEB128|see{LEB128, unsigned}}
2559 \addtoindexx{code alignment factor} \\
2561 \addtoindexx{\textless caf\textgreater|see{code alignment factor}}
2562 constant that is factored out of all advance location
2564 Section \refersec{chap:rowcreationinstructions}).
2565 The resulting value is
2566 \mbox{\textit{(operand} * \HFNcodealignmentfactor)}.
2568 \item \HFNdataalignmentfactor{} (signed LEB128)
2569 \addtoindexx{LEB128!signed}\addtoindexx{signed LEB128|see{LEB128, signed}} \\
2570 \addtoindexx{data alignment factor}
2572 \addtoindexx{\textless daf\textgreater|see{data alignment factor}}
2573 constant that is factored out of certain offset instructions
2574 (see Sections \refersec{chap:cfadefinitioninstructions} and
2575 \refersec{chap:registerruleinstructions}).
2576 The resulting value is \textit{(operand} *
2577 \HFNdataalignmentfactor).
2579 \item \HFNreturnaddressregister{} (unsigned LEB128)\addtoindexx{LEB128!unsigned} \\
2580 An unsigned LEB128 constant that indicates which column in the
2581 rule table represents the return address of the function. Note
2582 that this column might not correspond to an actual machine
2586 \item \HFNinitialinstructions{} (array of \HFTubyte) \\
2587 A sequence of rules that are interpreted to create the initial
2588 setting of each column in the table.
2590 The default rule for
2591 all columns before interpretation of the initial instructions
2592 is the undefined rule. However, an ABI authoring body or a
2593 compilation system authoring body may specify an alternate
2594 default value for any or all columns.
2596 \item \HFNpadding{} (array of \HFTubyte) \\
2597 Enough \DWCFAnop{} instructions to make the size of this entry
2598 match the length value above.
2602 An FDE contains the following fields, in order:
2603 \begin{enumerate}[1. ]
2604 \item \HFNlength{} (\livelink{datarep:initiallengthvalues}{initial length}) \\
2605 A constant that gives the number of bytes of the header and
2606 instruction stream for this function, not including the length
2608 (see Section \refersec{datarep:initiallengthvalues}).
2609 The size of the \texttt{length} field
2610 plus the value of length must be an integral multiple of the
2613 \item \HFNCIEpointer{} (4 or 8 bytes, see Section \refersec{datarep:32bitand64bitdwarfformats}) \\
2615 \addtoindexx{section offset!in FDE header}
2616 offset into the \dotdebugframe{}
2617 section that denotes
2618 the CIE that is associated with this FDE.
2621 \item \HFNinitiallocation{} (segment selector and target address) \\
2622 The address of the first location associated with this table
2624 If the \HFNsegmentselectorsize{} field of this FDE's CIE is non-zero,
2625 the initial location is preceded by a segment selector of
2629 \item \HFNaddressrange{} (target address) \\
2631 \addtoindexx{target address}
2632 of bytes of program instructions described by this entry.
2634 \item \HFNinstructions{} (array of \HFTubyte) \\
2635 A sequence of table defining instructions that are described
2636 in Section \refersec{chap:callframeinstructions}.
2639 \item \HFNpadding{} (array of \HFTubyte) \\
2640 Enough \DWCFAnop{} instructions
2641 to make the size of this entry match the \HFNlength{} value above.
2645 \subsection{Call Frame Instructions}
2646 \label{chap:callframeinstructions}
2648 Each call frame instruction is defined to take 0 or more
2649 operands. Some of the operands may be encoded as part of the
2651 (see Section \refersec{datarep:callframeinformation}).
2652 The instructions are defined in
2653 the following sections.
2656 Some call frame instructions have operands that are encoded
2657 as DWARF expressions
2658 (see Section \refersec{chap:generaloperations}).
2660 operators cannot be used in such operands:
2665 \DWOPaddrx, \DWOPcalltwo, \DWOPcallfour{}, \DWOPcallref,
2666 \DWOPconsttype, \DWOPconstx, \DWOPconvert, \DWOPdereftype,
2667 \DWOPregvaltype{} and \DWOPreinterpret{}
2669 not allowed in an operand of these instructions because
2670 the call frame information must not depend on other
2674 \item \DWOPpushobjectaddress{} is not meaningful in an operand
2675 of these instructions because there is no object context to
2676 provide a value to push.
2678 \item \DWOPcallframecfa{} is not meaningful in an operand of
2679 these instructions because its use would be circular.
2682 \textit{Call frame instructions to which these restrictions apply
2683 include \DWCFAdefcfaexpression, \DWCFAexpression{}
2684 and \DWCFAvalexpression.}
2687 \subsubsection{Row Creation Instructions}
2688 \label{chap:rowcreationinstructions}
2689 \begin{enumerate}[1. ]
2691 \item \textbf{\DWCFAsetlocTARG} \\
2692 The \DWCFAsetlocNAME{} instruction
2693 takes a single operand that
2694 represents a target address. The required action is to create a
2695 new table row using the specified address as the location. All
2696 other values in the new row are initially identical to the
2697 current row. The new location value is always greater than
2699 If the \HFNsegmentselectorsize{} field of this FDE's
2701 is non-zero, the initial location is preceded by a segment
2702 selector of the given length.
2705 \item \textbf{\DWCFAadvancelocTARG} \\
2706 The \DWCFAadvancelocNAME{} instruction takes a single operand (encoded
2707 with the opcode) that represents a constant delta. The required
2708 action is to create a new table row with a location value that
2709 is computed by taking the current entry\textquoteright s location value
2710 and adding the value of
2711 \textit{delta} * \addttindex{code\_alignment\_factor}.
2712 All other values in the new row are initially identical to the
2716 \item \textbf{\DWCFAadvanceloconeTARG{}} \\
2717 The \DWCFAadvanceloconeNAME{} instruction takes a single \HFTubyte{}
2718 operand that represents a constant delta. This instruction
2719 is identical to \DWCFAadvanceloc{} except for the encoding
2720 and size of the delta operand.
2722 \item \textbf{\DWCFAadvanceloctwoTARG} \\
2723 The \DWCFAadvanceloctwoNAME{} instruction takes a single \HFTuhalf{}
2724 operand that represents a constant delta. This instruction
2725 is identical to \DWCFAadvanceloc{} except for the encoding
2726 and size of the delta operand.
2728 \item \textbf{\DWCFAadvancelocfourTARG} \\
2729 The \DWCFAadvancelocfourNAME{} instruction takes a single \HFTuword{}
2730 operand that represents a constant delta. This instruction
2731 is identical to \DWCFAadvanceloc{} except for the encoding
2732 and size of the delta operand.
2736 \subsubsection{CFA Definition Instructions}
2737 \label{chap:cfadefinitioninstructions}
2738 \begin{enumerate}[1. ]
2740 \item \textbf{\DWCFAdefcfaTARG} \\
2741 The \DWCFAdefcfaNAME{}
2742 instruction takes two unsigned LEB128\addtoindexx{LEB128!unsigned}
2743 operands representing a register number and a (non-factored)
2744 offset. The required action is to define the current CFA rule
2745 to use the provided register and offset.
2748 \item \textbf{\DWCFAdefcfasfTARG} \\
2749 The \DWCFAdefcfasfNAME{} instruction takes two operands:
2750 an unsigned LEB128 value\addtoindexx{LEB128!unsigned}
2751 representing a register number and a
2752 signed LEB128\addtoindexx{LEB128!signed} factored offset. This instruction is identical
2753 to \DWCFAdefcfa{} except that the second operand is signed
2754 and factored. The resulting offset is \textit{factored\_offset} *
2755 \addttindex{data\_alignment\_factor}.
2758 \item \textbf{\DWCFAdefcfaregisterTARG} \\
2759 The \DWCFAdefcfaregisterNAME{}
2760 instruction takes a single
2761 unsigned LEB128\addtoindexx{LEB128!unsigned} operand representing a register number. The
2762 required action is to define the current CFA rule to use
2763 the provided register (but to keep the old offset). This
2764 operation is valid only if the current CFA rule is defined
2765 to use a register and offset.
2769 \item \textbf{\DWCFAdefcfaoffsetTARG} \\
2770 The \DWCFAdefcfaoffsetNAME{} instruction takes a single
2771 unsigned LEB128\addtoindexx{LEB128!unsigned} operand representing a (non-factored)
2772 offset. The required action is to define the current CFA rule
2773 to use the provided offset (but to keep the old register). This
2774 operation is valid only if the current CFA rule is defined
2775 to use a register and offset.
2778 \item \textbf{\DWCFAdefcfaoffsetsfTARG} \\
2779 The \DWCFAdefcfaoffsetsfNAME{} instruction takes a signed
2780 LEB128\addtoindexx{LEB128!signed} operand representing a factored offset. This instruction
2781 is identical to \DWCFAdefcfaoffset{} except that the
2782 operand is signed and factored. The resulting offset is
2783 \textit{factored\_offset} * \addttindex{data\_alignment\_factor}.
2785 is valid only if the current CFA rule is defined to use a
2786 register and offset.
2788 \item \textbf{\DWCFAdefcfaexpressionTARG} \\
2789 The \DWCFAdefcfaexpressionNAME{} instruction takes a
2790 \addtoindexx{exprloc class}
2791 single operand encoded as a
2792 \DWFORMexprloc{} value representing a
2793 DWARF expression. The required action is to establish that
2794 expression as the means by which the current CFA is computed.
2796 \textit{See Section \refersec{chap:callframeinstructions}
2797 regarding restrictions on the DWARF
2798 expression operators that can be used.}
2803 \subsubsection{Register Rule Instructions}
2804 \label{chap:registerruleinstructions}
2805 \begin{enumerate}[1. ]
2807 \item \textbf{\DWCFAundefinedTARG} \\
2808 The \DWCFAundefinedNAME{} instruction takes a single unsigned
2809 LEB128\addtoindexx{LEB128!unsigned} operand that represents a register number. The required
2810 action is to set the rule for the specified register to
2811 \doublequote{undefined.}
2813 \item \textbf{\DWCFAsamevalueTARG} \\
2814 The \DWCFAsamevalueNAME{} instruction takes a single unsigned
2815 LEB128 operand\addtoindexx{LEB128!unsigned} that represents a register number. The required
2816 action is to set the rule for the specified register to
2817 \doublequote{same value.}
2819 \item \textbf{\DWCFAoffsetTARG} \\
2820 The \DWCFAoffsetNAME{} instruction takes two operands: a register
2821 number (encoded with the opcode) and an unsigned LEB128\addtoindexx{LEB128!unsigned}
2822 constant representing a factored offset. The required action
2823 is to change the rule for the register indicated by the
2824 register number to be an offset(N) rule where the value of
2826 \textit{factored offset} * \addttindex{data\_alignment\_factor}.
2829 \item \textbf{\DWCFAoffsetextendedTARG} \\
2830 The \DWCFAoffsetextendedNAME{}
2831 instruction takes two unsigned LEB128\addtoindexx{LEB128!unsigned}
2832 operands representing a register number and a factored
2833 offset. This instruction is identical to
2835 except for the encoding and size of the register operand.
2838 \item \textbf{\DWCFAoffsetextendedsfTARG} \\
2839 The \DWCFAoffsetextendedsfNAME{}
2840 instruction takes two operands:
2841 an unsigned LEB128\addtoindexx{LEB128!unsigned}
2842 value representing a register number and a
2843 signed LEB128 factored offset. This instruction is identical
2844 to \DWCFAoffsetextended{}
2845 except that the second operand is
2846 signed and factored. The resulting offset is
2847 \textit{factored\_offset} * \addttindex{data\_alignment\_factor}.
2850 \item \textbf{\DWCFAvaloffsetTARG} \\
2851 The \DWCFAvaloffsetNAME{}
2852 instruction takes two unsigned
2853 LEB128 operands\addtoindexx{LEB128!unsigned} representing a register number and a
2854 factored offset. The required action is to change the rule
2855 for the register indicated by the register number to be a
2856 val\_offset(N) rule where the value of N is
2857 \textit{factored\_offset} * \addttindex{data\_alignment\_factor}.
2860 \item \textbf{\DWCFAvaloffsetsfTARG} \\
2861 The \DWCFAvaloffsetsfNAME{} instruction takes two operands: an
2862 unsigned LEB128\addtoindexx{LEB128!unsigned} value representing a register number and a
2863 signed LEB128\addtoindexx{LEB128!signed} factored offset. This instruction is identical
2864 to \DWCFAvaloffset{} except that the second operand is signed
2865 and factored. The resulting offset is
2866 \textit{factored\_offset} * \addttindex{data\_alignment\_factor}.
2868 \item \textbf{\DWCFAregisterTARG} \\
2869 The \DWCFAregisterNAME{}
2870 instruction takes two unsigned LEB128\addtoindexx{LEB128!unsigned}
2871 operands representing register numbers. The required action
2872 is to set the rule for the first register to be register(R)
2873 where R is the second register.
2875 \item \textbf{\DWCFAexpressionTARG} \\
2876 The \DWCFAexpressionNAME{} instruction takes two operands: an
2877 unsigned LEB128\addtoindexx{LEB128!unsigned}
2878 value representing a register number, and
2880 value representing a DWARF expression.
2882 required action is to change the rule for the register
2883 indicated by the register number to be an expression(E)
2884 rule where E is the DWARF expression. That is, the DWARF
2885 expression computes the address. The value of the CFA is
2886 pushed on the DWARF evaluation stack prior to execution of
2887 the DWARF expression.
2889 \textit{See Section \refersec{chap:callframeinstructions}
2890 regarding restrictions on the DWARF
2891 expression operators that can be used.}
2894 \item \textbf{\DWCFAvalexpressionTARG} \\
2895 The \DWCFAvalexpressionNAME{} instruction takes two operands:
2896 an unsigned LEB128\addtoindexx{LEB128!unsigned}
2897 value representing a register number, and
2899 value representing a DWARF expression. The
2900 required action is to change the rule for the register
2901 indicated by the register number to be a val\_expression(E)
2902 rule where E is the DWARF expression. That is, the DWARF
2903 expression computes the value of the given register. The value
2904 of the CFA is pushed on the DWARF evaluation stack prior to
2905 execution of the DWARF expression.
2907 \textit{See Section \refersec{chap:callframeinstructions}
2908 regarding restrictions on the DWARF
2909 expression operators that can be used.}
2912 \item \textbf{\DWCFArestoreTARG} \\
2913 The \DWCFArestoreNAME{} instruction takes a single operand (encoded
2914 with the opcode) that represents a register number. The
2915 required action is to change the rule for the indicated
2916 register to the rule assigned it by the \texttt{initial\_instructions}
2920 \item \textbf{\DWCFArestoreextendedTARG} \\
2921 The \DWCFArestoreextendedNAME{}
2922 instruction takes a single unsigned LEB128\addtoindexx{LEB128!unsigned}
2923 operand that represents a register number. This
2924 instruction is identical to \DWCFArestore{} except for the
2925 encoding and size of the register operand.
2929 \subsubsection{Row State Instructions}
2930 \label{chap:rowstateinstructions}
2932 \textit{The next two instructions provide the ability to stack and
2933 retrieve complete register states. They may be useful, for
2934 example, for a compiler that moves \addtoindex{epilogue} code
2936 body of a function.}
2939 \begin{enumerate}[1. ]
2941 \item \textbf{\DWCFArememberstateTARG} \\
2942 The \DWCFArememberstateNAME{} instruction takes no operands. The
2943 required action is to push the set of rules for every register
2944 onto an implicit stack.
2947 \item \textbf{\DWCFArestorestateTARG} \\
2948 The \DWCFArestorestateNAME{} instruction takes no operands. The
2949 required action is to pop the set of rules off the implicit
2950 stack and place them in the current row.
2954 \subsubsection{Padding Instruction}
2955 \label{chap:paddinginstruction}
2956 \begin{enumerate}[1. ]
2957 \item \textbf{\DWCFAnopTARG} \\
2958 The \DWCFAnopNAME{} instruction has no operands and no required
2959 actions. It is used as padding to make a CIE or FDE an
2964 \subsection{Call Frame Instruction Usage}
2965 \label{chap:callframeinstructionusage}
2967 \textit{To determine the virtual unwind rule set for a given location
2968 (L1), search through the FDE headers looking at the
2969 \HFNinitiallocation{} and \HFNaddressrange{} values to see if L1 is
2970 contained in the FDE. If so, then:}
2971 \begin{enumerate}[1. ]
2973 \item \textit{Initialize a register set by reading the
2974 \HFNinitialinstructions{} field of the associated CIE.
2975 Set L2 to the value of the \HFNinitiallocation{} field from the FDE header.}
2978 \item \textit{Read and process the FDE's instruction
2979 sequence until a \DWCFAadvanceloc,
2980 \DWCFAsetloc, or the
2981 end of the instruction stream is encountered.}
2983 \item \textit{ If a \DWCFAadvanceloc{} or \DWCFAsetloc{}
2984 instruction is encountered, then compute a new location value
2985 (L2). If L1 $\geq$ L2 then process the instruction and go back
2989 \item \textit{ The end of the instruction stream can be thought
2990 of as a \DWCFAsetloc{} (\addttindex{initial\_location} + \addttindex{address\_range})
2991 instruction. Note that the FDE is ill-formed if L2 is less
2996 \textit{The rules in the register set now apply to location L1.}
2998 \textit{For an example, see
2999 Appendix \refersec{app:callframeinformationexample}.}
3003 \subsection{Call Frame Calling Address}
3004 \label{chap:callframecallingaddress}
3007 virtually unwinding frames, consumers frequently wish to obtain
3008 the address of the instruction which called a subroutine. This
3009 information is not always provided. Typically, however,
3010 one of the registers in the virtual unwind table is the
3013 If a Return Address register is defined in the virtual
3014 unwind table, and its rule is undefined (for example, by
3015 \DWCFAundefined), then there is no return address and no
3016 call address, and the virtual unwind of stack activations
3017 \addtoindexx{activation of call frame}
3020 \textit{In most cases the return address is in the same context as the
3021 calling address, but that need not be the case, especially if
3022 the producer knows in some way the call never will return. The
3023 context of the 'return address' might be on a different line,
3024 in a different lexical \livelink{chap:lexicalblock}{block},
3025 or past the end of the calling
3026 subroutine. If a consumer were to assume that it was in the
3027 same context as the calling address, the
3028 virtual unwind might fail.}
3031 \textit{For architectures with constant-length instructions where
3032 the return address immediately follows the call instruction,
3033 a simple solution is to subtract the length of an instruction
3034 from the return address to obtain the calling instruction. For
3035 architectures with variable-length instructions (for example, x86),
3036 this is not possible. However, subtracting 1 from the return
3037 address, although not guaranteed to provide the exact calling
3038 address, generally will produce an address within the same
3039 context as the calling address, and that usually is sufficient.}