1 .. _amdgpu-dwarf-extensions-for-heterogeneous-debugging:
3 ********************************************
4 DWARF Extensions For Heterogeneous Debugging
5 ********************************************
12 This document describes **provisional extensions** to DWARF Version 5
13 [:ref:`DWARF <amdgpu-dwarf-DWARF>`] to support heterogeneous debugging. It is
14 not currently fully implemented and is subject to change.
16 .. _amdgpu-dwarf-introduction:
21 AMD [:ref:`AMD <amdgpu-dwarf-AMD>`] has been working on supporting heterogeneous
22 computing through the AMD Radeon Open Compute Platform (ROCm) [:ref:`AMD-ROCm
23 <amdgpu-dwarf-AMD-ROCm>`]. A heterogeneous computing program can be written in a
24 high level language such as C++ or Fortran with OpenMP pragmas, OpenCL, or HIP
25 (a portable C++ programming environment for heterogeneous computing [:ref:`HIP
26 <amdgpu-dwarf-HIP>`]). A heterogeneous compiler and runtime allows a program to
27 execute on multiple devices within the same native process. Devices could
28 include CPUs, GPUs, DSPs, FPGAs, or other special purpose accelerators.
29 Currently HIP programs execute on systems with CPUs and GPUs.
31 ROCm is fully open sourced and includes contributions to open source projects
32 such as LLVM for compilation [:ref:`LLVM <amdgpu-dwarf-LLVM>`] and GDB for
33 debugging [:ref:`GDB <amdgpu-dwarf-GDB>`], as well as collaboration with other
34 third party projects such as the GCC compiler [:ref:`GCC <amdgpu-dwarf-GCC>`]
35 and the Perforce TotalView HPC debugger [:ref:`Perforce-TotalView
36 <amdgpu-dwarf-Perforce-TotalView>`].
38 To support debugging heterogeneous programs several features that are not
39 provided by current DWARF Version 5 [:ref:`DWARF <amdgpu-dwarf-DWARF>`] have
40 been identified. This document contains a collection of extensions to address
41 providing those features.
43 The :ref:`amdgpu-dwarf-motivation` section describes the issues that are being
44 addressed for heterogeneous computing. That is followed by the
45 :ref:`amdgpu-dwarf-changes-relative-to-dwarf-version-5` section containing the
46 textual changes for the extensions relative to the DWARF Version 5 standard.
47 Then there is an :ref:`amdgpu-dwarf-examples` section that links to the AMD GPU
48 specific usage of the extensions that includes an example. Finally, there is a
49 :ref:`amdgpu-dwarf-references` section. There are a number of notes included
50 that raise open questions, or provide alternative approaches considered. The
51 extensions seek to be general in nature and backwards compatible with DWARF
52 Version 5. The goal is to be applicable to meeting the needs of any
53 heterogeneous system and not be vendor or architecture specific.
55 A fundamental aspect of the extensions is that it allows DWARF expression
56 location descriptions as stack elements. The extensions are based on DWARF
57 Version 5 and maintains compatibility with DWARF Version 5. After attempting
58 several alternatives, the current thinking is that such extensions to DWARF
59 Version 5 are the simplest and cleanest ways to support debugging optimized GPU
60 code. It also appears to be generally useful and may be able to address other
61 reported DWARF issues, as well as being helpful in providing better optimization
62 support for non-GPU code.
64 General feedback on these extensions is sought, together with suggestions on how
65 to clarify, simplify, or organize them. If their is general interest then some
66 or all of these extensions could be submitted as future DWARF proposals.
68 We are in the process of modifying LLVM and GDB to support these extensions
69 which is providing experience and insights. We plan to upstream the changes to
70 those projects for any final form of the extensions.
72 The author very much appreciates the input provided so far by many others which
73 has been incorporated into this current version.
75 .. _amdgpu-dwarf-motivation:
80 This document presents a set of backwards compatible extensions to DWARF Version
81 5 [:ref:`DWARF <amdgpu-dwarf-DWARF>`] to support heterogeneous debugging.
83 The remainder of this section provides motivation for each extension in
84 terms of heterogeneous debugging on commercially available AMD GPU hardware
85 (AMDGPU). The goal is to add support to the AMD [:ref:`AMD <amdgpu-dwarf-AMD>`]
86 open source Radeon Open Compute Platform (ROCm) [:ref:`AMD-ROCm
87 <amdgpu-dwarf-AMD-ROCm>`] which is an implementation of the industry standard
88 for heterogeneous computing devices defined by the Heterogeneous System
89 Architecture (HSA) Foundation [:ref:`HSA <amdgpu-dwarf-HSA>`]. ROCm includes the
90 LLVM compiler [:ref:`LLVM <amdgpu-dwarf-LLVM>`] with upstreamed support for
91 AMDGPU [:ref:`AMDGPU-LLVM <amdgpu-dwarf-AMDGPU-LLVM>`]. The goal is to also add
92 the GDB debugger [:ref:`GDB <amdgpu-dwarf-GDB>`] with upstreamed support for
93 AMDGPU [:ref:`AMD-ROCgdb <amdgpu-dwarf-AMD-ROCgdb>`]. In addition, the goal is
94 to work with third parties to enable support for AMDGPU debugging in the GCC
95 compiler [:ref:`GCC <amdgpu-dwarf-GCC>`] and the Perforce TotalView HPC debugger
96 [:ref:`Perforce-TotalView <amdgpu-dwarf-Perforce-TotalView>`].
98 However, the extensions are intended to be vendor and architecture neutral. They
99 are believed to apply to other heterogeneous hardware devices including GPUs,
100 DSPs, FPGAs, and other specialized hardware. These collectively include similar
101 characteristics and requirements as AMDGPU devices. Some of the extension can
102 also apply to traditional CPU hardware that supports large vector registers.
103 Compilers can map source languages and extensions that describe large scale
104 parallel execution onto the lanes of the vector registers. This is common in
105 programming languages used in ML and HPC. The extensions also include improved
106 support for optimized code on any architecture. Some of the generalizations may
107 also benefit other issues that have been raised.
109 The extensions have evolved through collaboration with many individuals and
110 active prototyping within the GDB debugger and LLVM compiler. Input has also
111 been very much appreciated from the developers working on the Perforce TotalView
112 HPC Debugger and GCC compiler.
114 The AMDGPU has several features that require additional DWARF functionality in
115 order to support optimized code.
117 AMDGPU optimized code may spill vector registers to non-global address space
118 memory, and this spilling may be done only for lanes that are active on entry
119 to the subprogram. To support this, a location description that can be created
120 as a masked select is required. See ``DW_OP_LLVM_select_bit_piece``.
122 Since the active lane mask may be held in a register, a way to get the value
123 of a register on entry to a subprogram is required. To support this an
124 operation that returns the caller value of a register as specified by the Call
125 Frame Information (CFI) is required. See ``DW_OP_LLVM_call_frame_entry_reg``
126 and :ref:`amdgpu-dwarf-call-frame-information`.
128 Current DWARF uses an empty expression to indicate an undefined location
129 description. Since the masked select composite location description operation
130 takes more than one location description, it is necessary to have an explicit
131 way to specify an undefined location description. Otherwise it is not possible
132 to specify that a particular one of the input location descriptions is
133 undefined. See ``DW_OP_LLVM_undefined``.
135 CFI describes restoring callee saved registers that are spilled. Currently CFI
136 only allows a location description that is a register, memory address, or
137 implicit location description. AMDGPU optimized code may spill scalar
138 registers into portions of vector registers. This requires extending CFI to
139 allow any location description. See
140 :ref:`amdgpu-dwarf-call-frame-information`.
142 The vector registers of the AMDGPU are represented as their full wavefront
143 size, meaning the wavefront size times the dword size. This reflects the
144 actual hardware and allows the compiler to generate DWARF for languages that
145 map a thread to the complete wavefront. It also allows more efficient DWARF to
146 be generated to describe the CFI as only a single expression is required for
147 the whole vector register, rather than a separate expression for each lane's
148 dword of the vector register. It also allows the compiler to produce DWARF
149 that indexes the vector register if it spills scalar registers into portions
150 of a vector register.
152 Since DWARF stack value entries have a base type and AMDGPU registers are a
153 vector of dwords, the ability to specify that a base type is a vector is
154 required. See ``DW_AT_LLVM_vector_size``.
156 If the source language is mapped onto the AMDGPU wavefronts in a SIMT manner,
157 then the variable DWARF location expressions must compute the location for a
158 single lane of the wavefront. Therefore, a DWARF operation is required to denote
159 the current lane, much like ``DW_OP_push_object_address`` denotes the current
160 object. The ``DW_OP_*piece`` operations only allow literal indices. Therefore, a
161 way to use a computed offset of an arbitrary location description (such as a
162 vector register) is required. See ``DW_OP_LLVM_push_lane``,
163 ``DW_OP_LLVM_offset``, ``DW_OP_LLVM_offset_uconst``, and
164 ``DW_OP_LLVM_bit_offset``.
166 If the source language is mapped onto the AMDGPU wavefronts in a SIMT manner
167 the compiler can use the AMDGPU execution mask register to control which lanes
168 are active. To describe the conceptual location of non-active lanes a DWARF
169 expression is needed that can compute a per lane PC. For efficiency, this is
170 done for the wavefront as a whole. This expression benefits by having a masked
171 select composite location description operation. This requires an attribute
172 for source location of each lane. The AMDGPU may update the execution mask for
173 whole wavefront operations and so needs an attribute that computes the current
174 active lane mask. See ``DW_OP_LLVM_select_bit_piece``, ``DW_OP_LLVM_extend``,
175 ``DW_AT_LLVM_lane_pc``, and ``DW_AT_LLVM_active_lane``.
177 AMDGPU needs to be able to describe addresses that are in different kinds of
178 memory. Optimized code may need to describe a variable that resides in pieces
179 that are in different kinds of storage which may include parts of registers,
180 memory that is in a mixture of memory kinds, implicit values, or be undefined.
181 DWARF has the concept of segment addresses. However, the segment cannot be
182 specified within a DWARF expression, which is only able to specify the offset
183 portion of a segment address. The segment index is only provided by the entity
184 that specifies the DWARF expression. Therefore, the segment index is a
185 property that can only be put on complete objects, such as a variable. That
186 makes it only suitable for describing an entity (such as variable or
187 subprogram code) that is in a single kind of memory. Therefore, AMDGPU uses
188 the DWARF concept of address spaces. For example, a variable may be allocated
189 in a register that is partially spilled to the call stack which is in the
190 private address space, and partially spilled to the local address space.
192 DWARF uses the concept of an address in many expression operations but does not
193 define how it relates to address spaces. For example,
194 ``DW_OP_push_object_address`` pushes the address of an object. Other contexts
195 implicitly push an address on the stack before evaluating an expression. For
196 example, the ``DW_AT_use_location`` attribute of the
197 ``DW_TAG_ptr_to_member_type``. The expression that uses the address needs to
198 do so in a general way and not need to be dependent on the address space of
199 the address. For example, a pointer to member value may want to be applied to
200 an object that may reside in any address space.
202 The number of registers and the cost of memory operations is much higher for
203 AMDGPU than a typical CPU. The compiler attempts to optimize whole variables
204 and arrays into registers. Currently DWARF only allows
205 ``DW_OP_push_object_address`` and related operations to work with a global
206 memory location. To support AMDGPU optimized code it is required to generalize
207 DWARF to allow any location description to be used. This allows registers, or
208 composite location descriptions that may be a mixture of memory, registers, or
209 even implicit values.
211 DWARF Version 5 does not allow location descriptions to be entries on the
212 DWARF stack. They can only be the final result of the evaluation of a DWARF
213 expression. However, by allowing a location description to be a first-class
214 entry on the DWARF stack it becomes possible to compose expressions containing
215 both values and location descriptions naturally. It allows objects to be
216 located in any kind of memory address space, in registers, be implicit values,
217 be undefined, or a composite of any of these. By extending DWARF carefully,
218 all existing DWARF expressions can retain their current semantic meaning.
219 DWARF has implicit conversions that convert from a value that represents an
220 address in the default address space to a memory location description. This
221 can be extended to allow a default address space memory location description
222 to be implicitly converted back to its address value. This allows all DWARF
223 Version 5 expressions to retain their same meaning, while adding the ability
224 to explicitly create memory location descriptions in non-default address
225 spaces and generalizing the power of composite location descriptions to any
226 kind of location description. See :ref:`amdgpu-dwarf-operation-expressions`.
228 To allow composition of composite location descriptions, an explicit operation
229 that indicates the end of the definition of a composite location description
230 is required. This can be implied if the end of a DWARF expression is reached,
231 allowing current DWARF expressions to remain legal. See
232 ``DW_OP_LLVM_piece_end``.
234 The ``DW_OP_plus`` and ``DW_OP_minus`` can be defined to operate on a memory
235 location description in the default target architecture specific address space
236 and a generic type value to produce an updated memory location description. This
237 allows them to continue to be used to offset an address. To generalize
238 offsetting to any location description, including location descriptions that
239 describe when bytes are in registers, are implicit, or a composite of these, the
240 ``DW_OP_LLVM_offset``, ``DW_OP_LLVM_offset_uconst``, and
241 ``DW_OP_LLVM_bit_offset`` offset operations are added. Unlike ``DW_OP_plus``,
242 ``DW_OP_plus_uconst``, and ``DW_OP_minus`` arithmetic operations, these do not
243 define that integer overflow causes wrap-around. The offset operations can
244 operate on location storage of any size. For example, implicit location storage
245 could be any number of bits in size. It is simpler to define offsets that exceed
246 the size of the location storage as being an evaluation error, than having to
247 force an implementation to support potentially infinite precision offsets to
248 allow it to correctly track a series of positive and negative offsets that may
249 transiently overflow or underflow, but end up in range. This is simple for the
250 arithmetic operations as they are defined in terms of two's compliment
251 arithmetic on a base type of a fixed size.
253 Having the offset operations allows ``DW_OP_push_object_address`` to push a
254 location description that may be in a register, or be an implicit value, and the
255 DWARF expression of ``DW_TAG_ptr_to_member_type`` can contain them to offset
256 within it. ``DW_OP_LLVM_bit_offset`` generalizes DWARF to work with bit fields
257 which is not possible in DWARF Version 5.
259 The DWARF ``DW_OP_xderef*`` operations allow a value to be converted into an
260 address of a specified address space which is then read. But it provides no
261 way to create a memory location description for an address in the non-default
262 address space. For example, AMDGPU variables can be allocated in the local
263 address space at a fixed address. It is required to have an operation to
264 create an address in a specific address space that can be used to define the
265 location description of the variable. Defining this operation to produce a
266 location description allows the size of addresses in an address space to be
267 larger than the generic type. See ``DW_OP_LLVM_form_aspace_address``.
269 If the ``DW_OP_LLVM_form_aspace_address`` operation had to produce a value
270 that can be implicitly converted to a memory location description, then it
271 would be limited to the size of the generic type which matches the size of the
272 default address space. Its value would be undefined and likely not match any
273 value in the actual program. By making the result a location description, it
274 allows a consumer great freedom in how it implements it. The implicit
275 conversion back to a value can be limited only to the default address space to
276 maintain compatibility with DWARF Version 5. For other address spaces the
277 producer can use the new operations that explicitly specify the address space.
279 ``DW_OP_breg*`` treats the register as containing an address in the default
280 address space. It is required to be able to specify the address space of the
281 register value. See ``DW_OP_LLVM_aspace_bregx``.
283 Similarly, ``DW_OP_implicit_pointer`` treats its implicit pointer value as
284 being in the default address space. It is required to be able to specify the
285 address space of the pointer value. See
286 ``DW_OP_LLVM_aspace_implicit_pointer``.
288 Almost all uses of addresses in DWARF are limited to defining location
289 descriptions, or to be dereferenced to read memory. The exception is
290 ``DW_CFA_val_offset`` which uses the address to set the value of a register.
291 By defining the CFA DWARF expression as being a memory location description,
292 it can maintain what address space it is, and that can be used to convert the
293 offset address back to an address in that address space. See
294 :ref:`amdgpu-dwarf-call-frame-information`.
296 This approach allows all existing DWARF to have the identical semantics. It
297 allows the compiler to explicitly specify the address space it is using. For
298 example, a compiler could choose to access private memory in a swizzled manner
299 when mapping a source language to a wavefront in a SIMT manner, or to access
300 it in an unswizzled manner if mapping the same language with the wavefront
301 being the thread. It also allows the compiler to mix the address space it uses
302 to access private memory. For example, for SIMT it can still spill entire
303 vector registers in an unswizzled manner, while using a swizzled private
304 memory for SIMT variable access. This approach allows memory location
305 descriptions for different address spaces to be combined using the regular
306 ``DW_OP_*piece`` operations.
308 Location descriptions are an abstraction of storage, they give freedom to the
309 consumer on how to implement them. They allow the address space to encode lane
310 information so they can be used to read memory with only the memory
311 description and no extra arguments. The same set of operations can operate on
312 locations independent of their kind of storage. The ``DW_OP_deref*`` therefore
313 can be used on any storage kind. ``DW_OP_xderef*`` is unnecessary, except to
314 become a more compact way to convert a non-default address space address
315 followed by dereferencing it.
317 In DWARF Version 5 a location description is defined as a single location
318 description or a location list. A location list is defined as either
319 effectively an undefined location description or as one or more single
320 location descriptions to describe an object with multiple places. The
321 ``DW_OP_push_object_address`` and ``DW_OP_call*`` operations can put a
322 location description on the stack. Furthermore, debugger information entry
323 attributes such as ``DW_AT_data_member_location``, ``DW_AT_use_location``, and
324 ``DW_AT_vtable_elem_location`` are defined as pushing a location description
325 on the expression stack before evaluating the expression. However, DWARF
326 Version 5 only allows the stack to contain values and so only a single memory
327 address can be on the stack which makes these incapable of handling location
328 descriptions with multiple places, or places other than memory. Since these
329 extensions allow the stack to contain location descriptions, the operations are
330 generalized to support location descriptions that can have multiple places.
331 This is backwards compatible with DWARF Version 5 and allows objects with
332 multiple places to be supported. For example, the expression that describes
333 how to access the field of an object can be evaluated with a location
334 description that has multiple places and will result in a location description
335 with multiple places as expected. With this change, the separate DWARF Version
336 5 sections that described DWARF expressions and location lists have been
337 unified into a single section that describes DWARF expressions in general.
338 This unification seems to be a natural consequence and a necessity of allowing
339 location descriptions to be part of the evaluation stack.
341 For those familiar with the definition of location descriptions in DWARF Version
342 5, the definitions in these extensions are presented differently, but does
343 in fact define the same concept with the same fundamental semantics. However,
344 it does so in a way that allows the concept to extend to support address
345 spaces, bit addressing, the ability for composite location descriptions to be
346 composed of any kind of location description, and the ability to support
347 objects located at multiple places. Collectively these changes expand the set
348 of processors that can be supported and improves support for optimized code.
350 Several approaches were considered, and the one presented appears to be the
351 cleanest and offers the greatest improvement of DWARF's ability to support
352 optimized code. Examining the GDB debugger and LLVM compiler, it appears only
353 to require modest changes as they both already have to support general use of
354 location descriptions. It is anticipated that will also be the case for other
355 debuggers and compilers.
357 As an experiment, GDB was modified to evaluate DWARF Version 5 expressions
358 with location descriptions as stack entries and implicit conversions. All GDB
359 tests have passed, except one that turned out to be an invalid test by DWARF
360 Version 5 rules. The code in GDB actually became simpler as all evaluation was
361 on the stack and there was no longer a need to maintain a separate structure
362 for the location description result. This gives confidence of the backwards
365 Since the AMDGPU supports languages such as OpenCL [:ref:`OpenCL
366 <amdgpu-dwarf-OpenCL>`], there is a need to define source language address
367 classes so they can be used in a consistent way by consumers. It would also be
368 desirable to add support for using them in defining language types rather than
369 the current target architecture specific address spaces. See
370 :ref:`amdgpu-dwarf-segment_addresses`.
372 A ``DW_AT_LLVM_augmentation`` attribute is added to a compilation unit
373 debugger information entry to indicate that there is additional target
374 architecture specific information in the debugging information entries of that
375 compilation unit. This allows a consumer to know what extensions are present
376 in the debugger information entries as is possible with the augmentation
377 string of other sections. The format that should be used for the augmentation
378 string in the lookup by name table and CFI Common Information Entry is also
379 recommended to allow a consumer to parse the string when it contains
380 information from multiple vendors.
382 The AMDGPU supports programming languages that include online compilation
383 where the source text may be created at runtime. Therefore, a way to embed the
384 source text in the debug information is required. For example, the OpenCL
385 language runtime supports online compilation. See
386 :ref:`amdgpu-dwarf-line-number-information`.
388 Support to allow MD5 checksums to be optionally present in the line table is
389 added. This allows linking together compilation units where some have MD5
390 checksums and some do not. In DWARF Version 5 the file timestamp and file size
391 can be optional, but if the MD5 checksum is present it must be valid for all
392 files. See :ref:`amdgpu-dwarf-line-number-information`.
394 Support is added for the HIP programming language [:ref:`HIP
395 <amdgpu-dwarf-HIP>`] which is supported by the AMDGPU. See
396 :ref:`amdgpu-dwarf-language-names`.
398 The following sections provide the definitions for the additional operations,
399 as well as clarifying how existing expression operations, CFI operations, and
400 attributes behave with respect to generalized location descriptions that
401 support address spaces and location descriptions that support multiple places.
402 It has been defined such that it is backwards compatible with DWARF Version 5.
403 The definitions are intended to fully define well-formed DWARF in a consistent
404 style based on the DWARF Version 5 specification. Non-normative text is shown
407 The names for the new operations, attributes, and constants include "\
408 ``LLVM``\ " and are encoded with vendor specific codes so these extensions can
409 be implemented as an LLVM vendor extension to DWARF Version 5. If accepted these
410 names would not include the "\ ``LLVM``\ " and would not use encodings in the
413 The extensions are described in
414 :ref:`amdgpu-dwarf-changes-relative-to-dwarf-version-5` and are
415 organized to follow the section ordering of DWARF Version 5. It includes notes
416 to indicate the corresponding DWARF Version 5 sections to which they pertain.
417 Other notes describe additional changes that may be worth considering, and to
420 .. _amdgpu-dwarf-changes-relative-to-dwarf-version-5:
422 Changes Relative to DWARF Version 5
423 ===================================
433 This augments DWARF Version 5 section 2.2 and Table 2.2.
435 The following table provides the additional attributes. See
436 :ref:`amdgpu-dwarf-debugging-information-entry-attributes`.
438 .. table:: Attribute names
439 :name: amdgpu-dwarf-attribute-names-table
441 =========================== ====================================
443 =========================== ====================================
444 ``DW_AT_LLVM_active_lane`` SIMD or SIMT active lanes
445 ``DW_AT_LLVM_augmentation`` Compilation unit augmentation string
446 ``DW_AT_LLVM_lane_pc`` SIMD or SIMT lane program location
447 ``DW_AT_LLVM_lanes`` SIMD or SIMT thread lane count
448 ``DW_AT_LLVM_vector_size`` Base type vector size
449 =========================== ====================================
451 .. _amdgpu-dwarf-expressions:
458 This section, and its nested sections, replaces DWARF Version 5 section 2.5
459 and section 2.6. The new DWARF expression operation extensions are defined as
460 well as clarifying the extensions to already existing DWARF Version 5
461 operations. It is based on the text of the existing DWARF Version 5 standard.
463 DWARF expressions describe how to compute a value or specify a location.
465 *The evaluation of a DWARF expression can provide the location of an object, the
466 value of an array bound, the length of a dynamic string, the desired value
469 If the evaluation of a DWARF expression does not encounter an error, then it can
470 either result in a value (see :ref:`amdgpu-dwarf-expression-value`) or a
471 location description (see :ref:`amdgpu-dwarf-location-description`). When a
472 DWARF expression is evaluated, it may be specified whether a value or location
473 description is required as the result kind.
475 If a result kind is specified, and the result of the evaluation does not match
476 the specified result kind, then the implicit conversions described in
477 :ref:`amdgpu-dwarf-memory-location-description-operations` are performed if
478 valid. Otherwise, the DWARF expression is ill-formed.
480 If the evaluation of a DWARF expression encounters an evaluation error, then the
481 result is an evaluation error.
485 Decided to define the concept of an evaluation error. An alternative is to
486 introduce an undefined value base type in a similar way to location
487 descriptions having an undefined location description. Then operations that
488 encounter an evaluation error can return the undefined location description or
489 value with an undefined base type.
491 All operations that act on values would return an undefined entity if given an
492 undefined value. The expression would then always evaluate to completion, and
493 can be tested to determine if it is an undefined entity.
495 However, this would add considerable additional complexity and does not match
496 that GDB throws an exception when these evaluation errors occur.
498 If a DWARF expression is ill-formed, then the result is undefined.
500 The following sections detail the rules for when a DWARF expression is
501 ill-formed or results in an evaluation error.
503 A DWARF expression can either be encoded as an operation expression (see
504 :ref:`amdgpu-dwarf-operation-expressions`), or as a location list expression
505 (see :ref:`amdgpu-dwarf-location-list-expressions`).
507 .. _amdgpu-dwarf-expression-evaluation-context:
509 DWARF Expression Evaluation Context
510 +++++++++++++++++++++++++++++++++++
512 A DWARF expression is evaluated in a context that can include a number of
513 context elements. If multiple context elements are specified then they must be
514 self consistent or the result of the evaluation is undefined. The context
515 elements that can be specified are:
517 *A current result kind*
519 The kind of result required by the DWARF expression evaluation. If specified
520 it can be a location description or a value.
524 The target architecture thread identifier of the source program thread of
525 execution for which a user presented expression is currently being evaluated.
527 It is required for operations that are related to target architecture threads.
529 *For example, the* ``DW_OP_form_tls_address`` *operation and*
530 ``DW_OP_LLVM_form_aspace_address`` *operation when given an address space that
535 The target architecture lane identifier of the source program thread of
536 execution for which a user presented expression is currently being evaluated.
537 This applies to languages that are implemented using a SIMD or SIMT execution
540 It is required for operations that are related to target architecture lanes.
542 *For example, the* ``DW_OP_LLVM_push_lane`` *operation and*
543 ``DW_OP_LLVM_form_aspace_address`` *operation when given an address space that
546 If specified, it must be consistent with any specified current thread and
547 current target architecture. It is consistent with a thread if it identifies a
548 lane of the thread. It is consistent with a target architecture if it is a
549 valid lane identifier of the target architecture. Otherwise the result is
552 *A current call frame*
554 The target architecture call frame identifier. It identifies a call frame that
555 corresponds to an active invocation of a subprogram in the current thread. It
556 is identified by its address on the call stack. The address is referred to as
557 the Canonical Frame Address (CFA). The call frame information is used to
558 determine the CFA for the call frames of the current thread's call stack (see
559 :ref:`amdgpu-dwarf-call-frame-information`).
561 It is required for operations that specify target architecture registers to
562 support virtual unwinding of the call stack.
564 *For example, the* ``DW_OP_*reg*`` *operations.*
566 If specified, it must be an active call frame in the current thread. If the
567 current lane is specified, then that lane must have been active on entry to
568 the call frame (see the ``DW_AT_LLVM_lane_pc`` attribute). Otherwise the
571 If it is the currently executing call frame, then it is termed the top call
574 *A current program location*
576 The target architecture program location corresponding to the current call
577 frame of the current thread.
579 The program location of the top call frame is the target architecture program
580 counter for the current thread. The call frame information is used to obtain
581 the value of the return address register to determine the program location of
582 the other call frames (see :ref:`amdgpu-dwarf-call-frame-information`).
584 It is required for the evaluation of location list expressions to select
585 amongst multiple program location ranges. It is required for operations that
586 specify target architecture registers to support virtual unwinding of the call
587 stack (see :ref:`amdgpu-dwarf-call-frame-information`).
591 * If the current lane is not specified:
593 * If the current call frame is the top call frame, it must be the current
594 target architecture program location.
596 * If the current call frame F is not the top call frame, it must be the
597 program location associated with the call site in the current caller frame
598 F that invoked the callee frame.
600 * If the current lane is specified and the architecture program location LPC
601 computed by the ``DW_AT_LLVM_lane_pc`` attribute for the current lane is not
602 the undefined location description (indicating the lane was not active on
603 entry to the call frame), it must be LPC.
605 * Otherwise the result is undefined.
607 *A current compilation unit*
609 The compilation unit debug information entry that contains the DWARF expression
612 It is required for operations that reference debug information associated with
613 the same compilation unit, including indicating if such references use the
614 32-bit or 64-bit DWARF format. It can also provide the default address space
615 address size if no current target architecture is specified.
617 *For example, the* ``DW_OP_constx`` *and* ``DW_OP_addrx`` *operations.*
619 *Note that this compilation unit may not be the same as the compilation unit
620 determined from the loaded code object corresponding to the current program
621 location. For example, the evaluation of the expression E associated with a
622 ``DW_AT_location`` attribute of the debug information entry operand of the
623 ``DW_OP_call*`` operations is evaluated with the compilation unit that
624 contains E and not the one that contains the ``DW_OP_call*`` operation
627 *A current target architecture*
629 The target architecture.
631 It is required for operations that specify target architecture specific
634 *For example, target architecture specific entities include DWARF register
635 identifiers, DWARF lane identifiers, DWARF address space identifiers, the
636 default address space, and the address space address sizes.*
640 * If the current thread is specified, then the current target architecture
641 must be the same as the target architecture of the current thread.
643 * If the current compilation unit is specified, then the current target
644 architecture default address space address size must be the same as he
645 ``address_size`` field in the header of the current compilation unit and any
646 associated entry in the ``.debug_aranges`` section.
648 * If the current program location is specified, then the current target
649 architecture must be the same as the target architecture of any line number
650 information entry (see :ref:`amdgpu-dwarf-line-number-information`)
651 corresponding to the current program location.
653 * If the current program location is specified, then the current target
654 architecture default address space address size must be the same as he
655 ``address_size`` field in the header of any entry corresponding to the
656 current program location in the ``.debug_addr``, ``.debug_line``,
657 ``.debug_rnglists``, ``.debug_rnglists.dwo``, ``.debug_loclists``, and
658 ``.debug_loclists.dwo`` sections.
660 * Otherwise the result is undefined.
664 The location description of a program object.
666 It is required for the ``DW_OP_push_object_address`` operation.
668 *For example, the* ``DW_AT_data_location`` *attribute on type debug
669 information entries specifies the the program object corresponding to a
670 runtime descriptor as the current object when it evaluates its associated
673 The result is undefined if the location descriptor is invalid (see
674 :ref:`amdgpu-dwarf-location-description`).
678 This is a list of values or location descriptions that will be pushed on the
679 operation expression evaluation stack in the order provided before evaluation
680 of an operation expression starts.
682 Some debugger information entries have attributes that evaluate their DWARF
683 expression value with initial stack entries. In all other cases the initial
686 The result is undefined if any location descriptors are invalid (see
687 :ref:`amdgpu-dwarf-location-description`).
689 If the evaluation requires a context element that is not specified, then the
690 result of the evaluation is an error.
692 *A DWARF expression for the location description may be able to be evaluated
693 without a thread, lane, call frame, program location, or architecture context.
694 For example, the location of a global variable may be able to be evaluated
695 without such context. If the expression evaluates with an error then it may
696 indicate the variable has been optimized and so requires more context.*
698 *The DWARF expression for call frame information (see
699 :ref:`amdgpu-dwarf-call-frame-information`) operations are restricted to those
700 that do not require the compilation unit context to be specified.*
702 The DWARF is ill-formed if all the ``address_size`` fields in the headers of all
703 the entries in the ``.debug_info``, ``.debug_addr``, ``.debug_line``,
704 ``.debug_rnglists``, ``.debug_rnglists.dwo``, ``.debug_loclists``, and
705 ``.debug_loclists.dwo`` sections corresponding to any given program location do
708 .. _amdgpu-dwarf-expression-value:
710 DWARF Expression Value
711 ++++++++++++++++++++++
713 A value has a type and a literal value. It can represent a literal value of any
714 supported base type of the target architecture. The base type specifies the
715 size, encoding, and endianity of the literal value.
719 It may be desirable to add an implicit pointer base type encoding. It would be
720 used for the type of the value that is produced when the ``DW_OP_deref*``
721 operation retrieves the full contents of an implicit pointer location storage
722 created by the ``DW_OP_implicit_pointer`` or
723 ``DW_OP_LLVM_aspace_implicit_pointer`` operations. The literal value would
724 record the debugging information entry and byte displacement specified by the
725 associated ``DW_OP_implicit_pointer`` or
726 ``DW_OP_LLVM_aspace_implicit_pointer`` operations.
728 There is a distinguished base type termed the generic type, which is an integral
729 type that has the size of an address in the target architecture default address
730 space, a target architecture defined endianity, and unspecified signedness.
732 *The generic type is the same as the unspecified type used for stack operations
733 defined in DWARF Version 4 and before.*
735 An integral type is a base type that has an encoding of ``DW_ATE_signed``,
736 ``DW_ATE_signed_char``, ``DW_ATE_unsigned``, ``DW_ATE_unsigned_char``,
737 ``DW_ATE_boolean``, or any target architecture defined integral encoding in the
738 inclusive range ``DW_ATE_lo_user`` to ``DW_ATE_hi_user``.
742 It is unclear if ``DW_ATE_address`` is an integral type. GDB does not seem to
743 consider it as integral.
745 .. _amdgpu-dwarf-location-description:
747 DWARF Location Description
748 ++++++++++++++++++++++++++
750 *Debugging information must provide consumers a way to find the location of
751 program variables, determine the bounds of dynamic arrays and strings, and
752 possibly to find the base address of a subprogram’s call frame or the return
753 address of a subprogram. Furthermore, to meet the needs of recent computer
754 architectures and optimization techniques, debugging information must be able to
755 describe the location of an object whose location changes over the object’s
756 lifetime, and may reside at multiple locations simultaneously during parts of an
759 Information about the location of program objects is provided by location
762 Location descriptions can consist of one or more single location descriptions.
764 A single location description specifies the location storage that holds a
765 program object and a position within the location storage where the program
766 object starts. The position within the location storage is expressed as a bit
767 offset relative to the start of the location storage.
769 A location storage is a linear stream of bits that can hold values. Each
770 location storage has a size in bits and can be accessed using a zero-based bit
771 offset. The ordering of bits within a location storage uses the bit numbering
772 and direction conventions that are appropriate to the current language on the
775 There are five kinds of location storage:
777 *memory location storage*
778 Corresponds to the target architecture memory address spaces.
780 *register location storage*
781 Corresponds to the target architecture registers.
783 *implicit location storage*
784 Corresponds to fixed values that can only be read.
786 *undefined location storage*
787 Indicates no value is available and therefore cannot be read or written.
789 *composite location storage*
790 Allows a mixture of these where some bits come from one location storage and
791 some from another location storage, or from disjoint parts of the same
796 It may be better to add an implicit pointer location storage kind used by the
797 ``DW_OP_implicit_pointer`` and ``DW_OP_LLVM_aspace_implicit_pointer``
798 operations. It would specify the debugger information entry and byte offset
799 provided by the operations.
801 *Location descriptions are a language independent representation of addressing
802 rules. They are created using DWARF operation expressions of arbitrary
803 complexity. They can be the result of evaluating a debugger information entry
804 attribute that specifies an operation expression. In this usage they can
805 describe the location of an object as long as its lifetime is either static or
806 the same as the lexical block (see DWARF Version 5 section 3.5) that owns it,
807 and it does not move during its lifetime. They can be the result of evaluating a
808 debugger information entry attribute that specifies a location list expression.
809 In this usage they can describe the location of an object that has a limited
810 lifetime, changes its location during its lifetime, or has multiple locations
811 over part or all of its lifetime.*
813 If a location description has more than one single location description, the
814 DWARF expression is ill-formed if the object value held in each single location
815 description's position within the associated location storage is not the same
816 value, except for the parts of the value that are uninitialized.
818 *A location description that has more than one single location description can
819 only be created by a location list expression that has overlapping program
820 location ranges, or certain expression operations that act on a location
821 description that has more than one single location description. There are no
822 operation expression operations that can directly create a location description
823 with more than one single location description.*
825 *A location description with more than one single location description can be
826 used to describe objects that reside in more than one piece of storage at the
827 same time. An object may have more than one location as a result of
828 optimization. For example, a value that is only read may be promoted from memory
829 to a register for some region of code, but later code may revert to reading the
830 value from memory as the register may be used for other purposes. For the code
831 region where the value is in a register, any change to the object value must be
832 made in both the register and the memory so both regions of code will read the
835 *A consumer of a location description with more than one single location
836 description can read the object's value from any of the single location
837 descriptions (since they all refer to location storage that has the same value),
838 but must write any changed value to all the single location descriptions.*
840 The evaluation of an expression may require context elements to create a
841 location description. If such a location description is accessed, the storage it
842 denotes is that associated with the context element values specified when the
843 location description was created, which may differ from the context at the time
846 *For example, creating a register location description requires the thread
847 context: the location storage is for the specified register of that thread.
848 Creating a memory location description for an address space may required a
849 thread and a lane context: the location storage is the memory associated with
850 that thread and lane.*
852 If any of the context elements required to create a location description change,
853 the location description becomes invalid and accessing it is undefined.
855 *Examples of context that can invalidate a location description are:*
857 * *The thread context is required and execution causes the thread to terminate.*
858 * *The call frame context is required and further execution causes the call
859 frame to return to the calling frame.*
860 * *The program location is required and further execution of the thread occurs.
861 That could change the location list entry or call frame information entry that
863 * *An operation uses call frame information:*
865 * *Any of the frames used in the virtual call frame unwinding return.*
866 * *The top call frame is used, the program location is used to select the call
867 frame information entry, and further execution of the thread occurs.*
869 *A DWARF expression can be used to compute a location description for an object.
870 A subsequent DWARF expression evaluation can be given the object location
871 description as the object context or initial stack context to compute a
872 component of the object. The final result is undefined if the object location
873 description becomes invalid between the two expression evaluations.*
875 A change of a thread's program location may not make a location description
876 invalid, yet may still render it as no longer meaningful. Accessing such a
877 location description, or using it as the object context or initial stack context
878 of an expression evaluation, may produce an undefined result.
880 *For example, a location description may specify a register that no longer holds
881 the intended program object after a program location change. One way to avoid
882 such problems is to recompute location descriptions associated with threads when
883 their program locations change.*
885 .. _amdgpu-dwarf-operation-expressions:
887 DWARF Operation Expressions
888 +++++++++++++++++++++++++++
890 An operation expression is comprised of a stream of operations, each consisting
891 of an opcode followed by zero or more operands. The number of operands is
892 implied by the opcode.
894 Operations represent a postfix operation on a simple stack machine. Each stack
895 entry can hold either a value or a location description. Operations can act on
896 entries on the stack, including adding entries and removing entries. If the kind
897 of a stack entry does not match the kind required by the operation and is not
898 implicitly convertible to the required kind (see
899 :ref:`amdgpu-dwarf-memory-location-description-operations`), then the DWARF
900 operation expression is ill-formed.
902 Evaluation of an operation expression starts with an empty stack on which the
903 entries from the initial stack provided by the context are pushed in the order
904 provided. Then the operations are evaluated, starting with the first operation
905 of the stream. Evaluation continues until either an operation has an evaluation
906 error, or until one past the last operation of the stream is reached.
908 The result of the evaluation is:
910 * If an operation has an evaluation error, or an operation evaluates an
911 expression that has an evaluation error, then the result is an evaluation
914 * If the current result kind specifies a location description, then:
916 * If the stack is empty, the result is a location description with one
917 undefined location description.
919 *This rule is for backwards compatibility with DWARF Version 5 which has no
920 explicit operation to create an undefined location description, and uses an
921 empty operation expression for this purpose.*
923 * If the top stack entry is a location description, or can be converted
924 to one (see :ref:`amdgpu-dwarf-memory-location-description-operations`),
925 then the result is that, possibly converted, location description. Any other
926 entries on the stack are discarded.
928 * Otherwise the DWARF expression is ill-formed.
932 Could define this case as returning an implicit location description as
933 if the ``DW_OP_implicit`` operation is performed.
935 * If the current result kind specifies a value, then:
937 * If the top stack entry is a value, or can be converted to one (see
938 :ref:`amdgpu-dwarf-memory-location-description-operations`), then the result
939 is that, possibly converted, value. Any other entries on the stack are
942 * Otherwise the DWARF expression is ill-formed.
944 * If the current result kind is not specified, then:
946 * If the stack is empty, the result is a location description with one
947 undefined location description.
949 *This rule is for backwards compatibility with DWARF Version 5 which has no
950 explicit operation to create an undefined location description, and uses an
951 empty operation expression for this purpose.*
955 This rule is consistent with the rule above for when a location
956 description is requested. However, GDB appears to report this as an error
957 and no GDB tests appear to cause an empty stack for this case.
959 * Otherwise, the top stack entry is returned. Any other entries on the stack
962 An operation expression is encoded as a byte block with some form of prefix that
963 specifies the byte count. It can be used:
965 * as the value of a debugging information entry attribute that is encoded using
966 class ``exprloc`` (see DWARF Version 5 section 7.5.5),
968 * as the operand to certain operation expression operations,
970 * as the operand to certain call frame information operations (see
971 :ref:`amdgpu-dwarf-call-frame-information`),
973 * and in location list entries (see
974 :ref:`amdgpu-dwarf-location-list-expressions`).
976 .. _amdgpu-dwarf-stack-operations:
981 The following operations manipulate the DWARF stack. Operations that index the
982 stack assume that the top of the stack (most recently added entry) has index 0.
983 They allow the stack entries to be either a value or location description.
985 If any stack entry accessed by a stack operation is an incomplete composite
986 location description (see
987 :ref:`amdgpu-dwarf-composite-location-description-operations`), then the DWARF
988 expression is ill-formed.
992 These operations now support stack entries that are values and location
997 If it is desired to also make them work with incomplete composite location
998 descriptions, then would need to define that the composite location storage
999 specified by the incomplete composite location description is also replicated
1000 when a copy is pushed. This ensures that each copy of the incomplete composite
1001 location description can update the composite location storage they specify
1006 ``DW_OP_dup`` duplicates the stack entry at the top of the stack.
1010 ``DW_OP_drop`` pops the stack entry at the top of the stack and discards it.
1014 ``DW_OP_pick`` has a single unsigned 1-byte operand that represents an index
1015 I. A copy of the stack entry with index I is pushed onto the stack.
1019 ``DW_OP_over`` pushes a copy of the entry with index 1.
1021 *This is equivalent to a ``DW_OP_pick 1`` operation.*
1025 ``DW_OP_swap`` swaps the top two stack entries. The entry at the top of the
1026 stack becomes the second stack entry, and the second stack entry becomes the
1031 ``DW_OP_rot`` rotates the first three stack entries. The entry at the top of
1032 the stack becomes the third stack entry, the second entry becomes the top of
1033 the stack, and the third entry becomes the second entry.
1035 .. _amdgpu-dwarf-control-flow-operations:
1037 Control Flow Operations
1038 #######################
1040 The following operations provide simple control of the flow of a DWARF operation
1045 ``DW_OP_nop`` is a place holder. It has no effect on the DWARF stack
1048 2. ``DW_OP_le``, ``DW_OP_ge``, ``DW_OP_eq``, ``DW_OP_lt``, ``DW_OP_gt``,
1053 The same as in DWARF Version 5 section 2.5.1.5.
1057 ``DW_OP_skip`` is an unconditional branch. Its single operand is a 2-byte
1058 signed integer constant. The 2-byte constant is the number of bytes of the
1059 DWARF expression to skip forward or backward from the current operation,
1060 beginning after the 2-byte constant.
1062 If the updated position is at one past the end of the last operation, then
1063 the operation expression evaluation is complete.
1065 Otherwise, the DWARF expression is ill-formed if the updated operation
1066 position is not in the range of the first to last operation inclusive, or
1067 not at the start of an operation.
1071 ``DW_OP_bra`` is a conditional branch. Its single operand is a 2-byte signed
1072 integer constant. This operation pops the top of stack. If the value popped
1073 is not the constant 0, the 2-byte constant operand is the number of bytes of
1074 the DWARF operation expression to skip forward or backward from the current
1075 operation, beginning after the 2-byte constant.
1077 If the updated position is at one past the end of the last operation, then
1078 the operation expression evaluation is complete.
1080 Otherwise, the DWARF expression is ill-formed if the updated operation
1081 position is not in the range of the first to last operation inclusive, or
1082 not at the start of an operation.
1084 5. ``DW_OP_call2, DW_OP_call4, DW_OP_call_ref``
1086 ``DW_OP_call2``, ``DW_OP_call4``, and ``DW_OP_call_ref`` perform DWARF
1087 procedure calls during evaluation of a DWARF expression.
1089 ``DW_OP_call2`` and ``DW_OP_call4``, have one operand that is, respectively,
1090 a 2-byte or 4-byte unsigned offset DR that represents the byte offset of a
1091 debugging information entry D relative to the beginning of the current
1094 ``DW_OP_call_ref`` has one operand that is a 4-byte unsigned value in the
1095 32-bit DWARF format, or an 8-byte unsigned value in the 64-bit DWARF format,
1096 that represents the byte offset DR of a debugging information entry D
1097 relative to the beginning of the ``.debug_info`` section that contains the
1098 current compilation unit. D may not be in the current compilation unit.
1102 DWARF Version 5 states that DR can be an offset in a ``.debug_info``
1103 section other than the one that contains the current compilation unit. It
1104 states that relocation of references from one executable or shared object
1105 file to another must be performed by the consumer. But given that DR is
1106 defined as an offset in a ``.debug_info`` section this seems impossible.
1107 If DR was defined as an implementation defined value, then the consumer
1108 could choose to interpret the value in an implementation defined manner to
1109 reference a debug information in another executable or shared object.
1111 In ELF the ``.debug_info`` section is in a non-\ ``PT_LOAD`` segment so
1112 standard dynamic relocations cannot be used. But even if they were loaded
1113 segments and dynamic relocations were used, DR would need to be the
1114 address of D, not an offset in a ``.debug_info`` section. That would also
1115 need DR to be the size of a global address. So it would not be possible to
1116 use the 32-bit DWARF format in a 64-bit global address space. In addition,
1117 the consumer would need to determine what executable or shared object the
1118 relocated address was in so it could determine the containing compilation
1121 GDB only interprets DR as an offset in the ``.debug_info`` section that
1122 contains the current compilation unit.
1124 This comment also applies to ``DW_OP_implicit_pointer`` and
1125 ``DW_OP_LLVM_aspace_implicit_pointer``.
1127 *Operand interpretation of* ``DW_OP_call2``\ *,* ``DW_OP_call4``\ *, and*
1128 ``DW_OP_call_ref`` *is exactly like that for* ``DW_FORM_ref2``\ *,
1129 ``DW_FORM_ref4``\ *, and* ``DW_FORM_ref_addr``\ *, respectively.*
1131 The call operation is evaluated by:
1133 * If D has a ``DW_AT_location`` attribute that is encoded as a ``exprloc``
1134 that specifies an operation expression E, then execution of the current
1135 operation expression continues from the first operation of E. Execution
1136 continues until one past the last operation of E is reached, at which
1137 point execution continues with the operation following the call operation.
1138 The operations of E are evaluated with the same current context, except
1139 current compilation unit is the one that contains D and the stack is the
1140 same as that being used by the call operation. After the call operation
1141 has been evaluated, the stack is therefore as it is left by the evaluation
1142 of the operations of E. Since E is evaluated on the same stack as the call
1143 operation, E can use, and/or remove entries already on the stack, and can
1144 add new entries to the stack.
1146 *Values on the stack at the time of the call may be used as parameters by
1147 the called expression and values left on the stack by the called expression
1148 may be used as return values by prior agreement between the calling and
1149 called expressions.*
1151 * If D has a ``DW_AT_location`` attribute that is encoded as a ``loclist`` or
1152 ``loclistsptr``, then the specified location list expression E is
1153 evaluated. The evaluation of E uses the current context, except the result
1154 kind is a location description, the compilation unit is the one that
1155 contains D, and the initial stack is empty. The location description
1156 result is pushed on the stack.
1160 This rule avoids having to define how to execute a matched location list
1161 entry operation expression on the same stack as the call when there are
1162 multiple matches. But it allows the call to obtain the location
1163 description for a variable or formal parameter which may use a location
1166 An alternative is to treat the case when D has a ``DW_AT_location``
1167 attribute that is encoded as a ``loclist`` or ``loclistsptr``, and the
1168 specified location list expression E' matches a single location list
1169 entry with operation expression E, the same as the ``exprloc`` case and
1170 evaluate on the same stack.
1172 But this is not attractive as if the attribute is for a variable that
1173 happens to end with a non-singleton stack, it will not simply put a
1174 location description on the stack. Presumably the intent of using
1175 ``DW_OP_call*`` on a variable or formal parameter debugger information
1176 entry is to push just one location description on the stack. That
1177 location description may have more than one single location description.
1179 The previous rule for ``exprloc`` also has the same problem as normally
1180 a variable or formal parameter location expression may leave multiple
1181 entries on the stack and only return the top entry.
1183 GDB implements ``DW_OP_call*`` by always executing E on the same stack.
1184 If the location list has multiple matching entries, it simply picks the
1185 first one and ignores the rest. This seems fundamentally at odds with
1186 the desire to supporting multiple places for variables.
1188 So, it feels like ``DW_OP_call*`` should both support pushing a location
1189 description on the stack for a variable or formal parameter, and also
1190 support being able to execute an operation expression on the same stack.
1191 Being able to specify a different operation expression for different
1192 program locations seems a desirable feature to retain.
1194 A solution to that is to have a distinct ``DW_AT_LLVM_proc`` attribute
1195 for the ``DW_TAG_dwarf_procedure`` debugging information entry. Then the
1196 ``DW_AT_location`` attribute expression is always executed separately
1197 and pushes a location description (that may have multiple single
1198 location descriptions), and the ``DW_AT_LLVM_proc`` attribute expression
1199 is always executed on the same stack and can leave anything on the
1202 The ``DW_AT_LLVM_proc`` attribute could have the new classes
1203 ``exprproc``, ``loclistproc``, and ``loclistsptrproc`` to indicate that
1204 the expression is executed on the same stack. ``exprproc`` is the same
1205 encoding as ``exprloc``. ``loclistproc`` and ``loclistsptrproc`` are the
1206 same encoding as their non-\ ``proc`` counterparts, except the DWARF is
1207 ill-formed if the location list does not match exactly one location list
1208 entry and a default entry is required. These forms indicate explicitly
1209 that the matched single operation expression must be executed on the
1210 same stack. This is better than ad hoc special rules for ``loclistproc``
1211 and ``loclistsptrproc`` which are currently clearly defined to always
1212 return a location description. The producer then explicitly indicates
1213 the intent through the attribute classes.
1215 Such a change would be a breaking change for how GDB implements
1216 ``DW_OP_call*``. However, are the breaking cases actually occurring in
1217 practice? GDB could implement the current approach for DWARF Version 5,
1218 and the new semantics for DWARF Version 6 which has been done for some
1221 Another option is to limit the execution to be on the same stack only to
1222 the evaluation of an expression E that is the value of a
1223 ``DW_AT_location`` attribute of a ``DW_TAG_dwarf_procedure`` debugging
1224 information entry. The DWARF would be ill-formed if E is a location list
1225 expression that does not match exactly one location list entry. In all
1226 other cases the evaluation of an expression E that is the value of a
1227 ``DW_AT_location`` attribute would evaluate E with the current context,
1228 except the result kind is a location description, the compilation unit
1229 is the one that contains D, and the initial stack is empty. The location
1230 description result is pushed on the stack.
1232 * If D has a ``DW_AT_const_value`` attribute with a value V, then it is as
1233 if a ``DW_OP_implicit_value V`` operation was executed.
1235 *This allows a call operation to be used to compute the location
1236 description for any variable or formal parameter regardless of whether the
1237 producer has optimized it to a constant. This is consistent with the
1238 ``DW_OP_implicit_pointer`` operation.*
1242 Alternatively, could deprecate using ``DW_AT_const_value`` for
1243 ``DW_TAG_variable`` and ``DW_TAG_formal_parameter`` debugger information
1244 entries that are constants and instead use ``DW_AT_location`` with an
1245 operation expression that results in a location description with one
1246 implicit location description. Then this rule would not be required.
1248 * Otherwise, there is no effect and no changes are made to the stack.
1252 In DWARF Version 5, if D does not have a ``DW_AT_location`` then
1253 ``DW_OP_call*`` is defined to have no effect. It is unclear that this is
1254 the right definition as a producer should be able to rely on using
1255 ``DW_OP_call*`` to get a location description for any non-\
1256 ``DW_TAG_dwarf_procedure`` debugging information entries. Also, the
1257 producer should not be creating DWARF with ``DW_OP_call*`` to a
1258 ``DW_TAG_dwarf_procedure`` that does not have a ``DW_AT_location``
1259 attribute. So, should this case be defined as an ill-formed DWARF
1262 *The* ``DW_TAG_dwarf_procedure`` *debugging information entry can be used to
1263 define DWARF procedures that can be called.*
1265 .. _amdgpu-dwarf-value-operations:
1270 This section describes the operations that push values on the stack.
1272 Each value stack entry has a type and a literal value and can represent a
1273 literal value of any supported base type of the target architecture. The base
1274 type specifies the size, encoding, and endianity of the literal value.
1276 The base type of value stack entries can be the distinguished generic type.
1278 .. _amdgpu-dwarf-literal-operations:
1283 The following operations all push a literal value onto the DWARF stack.
1285 Operations other than ``DW_OP_const_type`` push a value V with the generic type.
1286 If V is larger than the generic type, then V is truncated to the generic type
1287 size and the low-order bits used.
1289 1. ``DW_OP_lit0``, ``DW_OP_lit1``, ..., ``DW_OP_lit31``
1291 ``DW_OP_lit<N>`` operations encode an unsigned literal value N from 0
1292 through 31, inclusive. They push the value N with the generic type.
1294 2. ``DW_OP_const1u``, ``DW_OP_const2u``, ``DW_OP_const4u``, ``DW_OP_const8u``
1296 ``DW_OP_const<N>u`` operations have a single operand that is a 1, 2, 4, or
1297 8-byte unsigned integer constant U, respectively. They push the value U with
1300 3. ``DW_OP_const1s``, ``DW_OP_const2s``, ``DW_OP_const4s``, ``DW_OP_const8s``
1302 ``DW_OP_const<N>s`` operations have a single operand that is a 1, 2, 4, or
1303 8-byte signed integer constant S, respectively. They push the value S with
1308 ``DW_OP_constu`` has a single unsigned LEB128 integer operand N. It pushes
1309 the value N with the generic type.
1313 ``DW_OP_consts`` has a single signed LEB128 integer operand N. It pushes the
1314 value N with the generic type.
1318 ``DW_OP_constx`` has a single unsigned LEB128 integer operand that
1319 represents a zero-based index into the ``.debug_addr`` section relative to
1320 the value of the ``DW_AT_addr_base`` attribute of the associated compilation
1321 unit. The value N in the ``.debug_addr`` section has the size of the generic
1322 type. It pushes the value N with the generic type.
1324 *The* ``DW_OP_constx`` *operation is provided for constants that require
1325 link-time relocation but should not be interpreted by the consumer as a
1326 relocatable address (for example, offsets to thread-local storage).*
1328 9. ``DW_OP_const_type``
1330 ``DW_OP_const_type`` has three operands. The first is an unsigned LEB128
1331 integer DR that represents the byte offset of a debugging information entry
1332 D relative to the beginning of the current compilation unit, that provides
1333 the type T of the constant value. The second is a 1-byte unsigned integral
1334 constant S. The third is a block of bytes B, with a length equal to S.
1336 TS is the bit size of the type T. The least significant TS bits of B are
1337 interpreted as a value V of the type D. It pushes the value V with the type
1340 The DWARF is ill-formed if D is not a ``DW_TAG_base_type`` debugging
1341 information entry in the current compilation unit, or if TS divided by 8
1342 (the byte size) and rounded up to a whole number is not equal to S.
1344 *While the size of the byte block B can be inferred from the type D
1345 definition, it is encoded explicitly into the operation so that the
1346 operation can be parsed easily without reference to the* ``.debug_info``
1349 10. ``DW_OP_LLVM_push_lane`` *New*
1351 ``DW_OP_LLVM_push_lane`` pushes the target architecture lane identifier of
1352 the current lane as a value with the generic type.
1354 *For languages that are implemented using a SIMD or SIMT execution model,
1355 this is the lane number that corresponds to the source language thread of
1356 execution upon which the user is focused.*
1358 .. _amdgpu-dwarf-arithmetic-logical-operations:
1360 Arithmetic and Logical Operations
1361 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1365 This section is the same as DWARF Version 5 section 2.5.1.4.
1367 .. _amdgpu-dwarf-type-conversions-operations:
1369 Type Conversion Operations
1370 ^^^^^^^^^^^^^^^^^^^^^^^^^^
1374 This section is the same as DWARF Version 5 section 2.5.1.6.
1376 .. _amdgpu-dwarf-general-operations:
1378 Special Value Operations
1379 ^^^^^^^^^^^^^^^^^^^^^^^^
1381 There are these special value operations currently defined:
1383 1. ``DW_OP_regval_type``
1385 ``DW_OP_regval_type`` has two operands. The first is an unsigned LEB128
1386 integer that represents a register number R. The second is an unsigned
1387 LEB128 integer DR that represents the byte offset of a debugging information
1388 entry D relative to the beginning of the current compilation unit, that
1389 provides the type T of the register value.
1391 The operation is equivalent to performing ``DW_OP_regx R; DW_OP_deref_type
1396 Should DWARF allow the type T to be a larger size than the size of the
1397 register R? Restricting a larger bit size avoids any issue of conversion
1398 as the, possibly truncated, bit contents of the register is simply
1399 interpreted as a value of T. If a conversion is wanted it can be done
1400 explicitly using a ``DW_OP_convert`` operation.
1402 GDB has a per register hook that allows a target specific conversion on a
1403 register by register basis. It defaults to truncation of bigger registers.
1404 Removing use of the target hook does not cause any test failures in common
1405 architectures. If the compiler for a target architecture did want some
1406 form of conversion, including a larger result type, it could always
1407 explicitly used the ``DW_OP_convert`` operation.
1409 If T is a larger type than the register size, then the default GDB
1410 register hook reads bytes from the next register (or reads out of bounds
1411 for the last register!). Removing use of the target hook does not cause
1412 any test failures in common architectures (except an illegal hand written
1413 assembly test). If a target architecture requires this behavior, these
1414 extensions allow a composite location description to be used to combine
1419 S is the bit size of the generic type divided by 8 (the byte size) and
1420 rounded up to a whole number. DR is the offset of a hypothetical debug
1421 information entry D in the current compilation unit for a base type of the
1424 The operation is equivalent to performing ``DW_OP_deref_type S, DR``.
1426 3. ``DW_OP_deref_size``
1428 ``DW_OP_deref_size`` has a single 1-byte unsigned integral constant that
1429 represents a byte result size S.
1431 TS is the smaller of the generic type bit size and S scaled by 8 (the byte
1432 size). If TS is smaller than the generic type bit size then T is an unsigned
1433 integral type of bit size TS, otherwise T is the generic type. DR is the
1434 offset of a hypothetical debug information entry D in the current
1435 compilation unit for a base type T.
1439 Truncating the value when S is larger than the generic type matches what
1440 GDB does. This allows the generic type size to not be an integral byte
1441 size. It does allow S to be arbitrarily large. Should S be restricted to
1442 the size of the generic type rounded up to a multiple of 8?
1444 The operation is equivalent to performing ``DW_OP_deref_type S, DR``, except
1445 if T is not the generic type, the value V pushed is zero-extended to the
1446 generic type bit size and its type changed to the generic type.
1448 4. ``DW_OP_deref_type``
1450 ``DW_OP_deref_type`` has two operands. The first is a 1-byte unsigned
1451 integral constant S. The second is an unsigned LEB128 integer DR that
1452 represents the byte offset of a debugging information entry D relative to
1453 the beginning of the current compilation unit, that provides the type T of
1456 TS is the bit size of the type T.
1458 *While the size of the pushed value V can be inferred from the type T, it is
1459 encoded explicitly as the operand S so that the operation can be parsed
1460 easily without reference to the* ``.debug_info`` *section.*
1464 It is unclear why the operand S is needed. Unlike ``DW_OP_const_type``,
1465 the size is not needed for parsing. Any evaluation needs to get the base
1466 type T to push with the value to know its encoding and bit size.
1468 It pops one stack entry that must be a location description L.
1470 A value V of TS bits is retrieved from the location storage LS specified by
1471 one of the single location descriptions SL of L.
1473 *If L, or the location description of any composite location description
1474 part that is a subcomponent of L, has more than one single location
1475 description, then any one of them can be selected as they are required to
1476 all have the same value. For any single location description SL, bits are
1477 retrieved from the associated storage location starting at the bit offset
1478 specified by SL. For a composite location description, the retrieved bits
1479 are the concatenation of the N bits from each composite location part PL,
1480 where N is limited to the size of PL.*
1482 V is pushed on the stack with the type T.
1486 This definition makes it an evaluation error if L is a register location
1487 description that has less than TS bits remaining in the register storage.
1488 Particularly since these extensions extend location descriptions to have
1489 a bit offset, it would be odd to define this as performing sign extension
1490 based on the type, or be target architecture dependent, as the number of
1491 remaining bits could be any number. This matches the GDB implementation
1492 for ``DW_OP_deref_type``.
1494 These extensions define ``DW_OP_*breg*`` in terms of
1495 ``DW_OP_regval_type``. ``DW_OP_regval_type`` is defined in terms of
1496 ``DW_OP_regx``, which uses a 0 bit offset, and ``DW_OP_deref_type``.
1497 Therefore, it requires the register size to be greater or equal to the
1498 address size of the address space. This matches the GDB implementation for
1501 The DWARF is ill-formed if D is not in the current compilation unit, D is
1502 not a ``DW_TAG_base_type`` debugging information entry, or if TS divided by
1503 8 (the byte size) and rounded up to a whole number is not equal to S.
1507 This definition allows the base type to be a bit size since there seems no
1508 reason to restrict it.
1510 It is an evaluation error if any bit of the value is retrieved from the
1511 undefined location storage or the offset of any bit exceeds the size of the
1512 location storage LS specified by any single location description SL of L.
1514 See :ref:`amdgpu-dwarf-implicit-location-descriptions` for special rules
1515 concerning implicit location descriptions created by the
1516 ``DW_OP_implicit_pointer`` and ``DW_OP_LLVM_implicit_aspace_pointer``
1519 5. ``DW_OP_xderef`` *Deprecated*
1521 ``DW_OP_xderef`` pops two stack entries. The first must be an integral type
1522 value that represents an address A. The second must be an integral type
1523 value that represents a target architecture specific address space
1526 The operation is equivalent to performing ``DW_OP_swap;
1527 DW_OP_LLVM_form_aspace_address; DW_OP_deref``. The value V retrieved is left
1528 on the stack with the generic type.
1530 *This operation is deprecated as the* ``DW_OP_LLVM_form_aspace_address``
1531 *operation can be used and provides greater expressiveness.*
1533 6. ``DW_OP_xderef_size`` *Deprecated*
1535 ``DW_OP_xderef_size`` has a single 1-byte unsigned integral constant that
1536 represents a byte result size S.
1538 It pops two stack entries. The first must be an integral type value that
1539 represents an address A. The second must be an integral type value that
1540 represents a target architecture specific address space identifier AS.
1542 The operation is equivalent to performing ``DW_OP_swap;
1543 DW_OP_LLVM_form_aspace_address; DW_OP_deref_size S``. The zero-extended
1544 value V retrieved is left on the stack with the generic type.
1546 *This operation is deprecated as the* ``DW_OP_LLVM_form_aspace_address``
1547 *operation can be used and provides greater expressiveness.*
1549 7. ``DW_OP_xderef_type`` *Deprecated*
1551 ``DW_OP_xderef_type`` has two operands. The first is a 1-byte unsigned
1552 integral constant S. The second operand is an unsigned LEB128 integer DR
1553 that represents the byte offset of a debugging information entry D relative
1554 to the beginning of the current compilation unit, that provides the type T
1555 of the result value.
1557 It pops two stack entries. The first must be an integral type value that
1558 represents an address A. The second must be an integral type value that
1559 represents a target architecture specific address space identifier AS.
1561 The operation is equivalent to performing ``DW_OP_swap;
1562 DW_OP_LLVM_form_aspace_address; DW_OP_deref_type S R``. The value V
1563 retrieved is left on the stack with the type D.
1565 *This operation is deprecated as the* ``DW_OP_LLVM_form_aspace_address``
1566 *operation can be used and provides greater expressiveness.*
1568 8. ``DW_OP_entry_value`` *Deprecated*
1570 ``DW_OP_entry_value`` pushes the value of an expression that is evaluated in
1571 the context of the calling frame.
1573 *It may be used to determine the value of arguments on entry to the current
1574 call frame provided they are not clobbered.*
1576 It has two operands. The first is an unsigned LEB128 integer S. The second
1577 is a block of bytes, with a length equal S, interpreted as a DWARF
1578 operation expression E.
1580 E is evaluated with the current context, except the result kind is
1581 unspecified, the call frame is the one that called the current frame, the
1582 program location is the call site in the calling frame, the object is
1583 unspecified, and the initial stack is empty. The calling frame information
1584 is obtained by virtually unwinding the current call frame using the call
1585 frame information (see :ref:`amdgpu-dwarf-call-frame-information`).
1587 If the result of E is a location description L (see
1588 :ref:`amdgpu-dwarf-register-location-descriptions`), and the last operation
1589 executed by E is a ``DW_OP_reg*`` for register R with a target architecture
1590 specific base type of T, then the contents of the register are retrieved as
1591 if a ``DW_OP_deref_type DR`` operation was performed where DR is the offset
1592 of a hypothetical debug information entry in the current compilation unit
1593 for T. The resulting value V s pushed on the stack.
1595 *Using* ``DW_OP_reg*`` *provides a more compact form for the case where the
1596 value was in a register on entry to the subprogram.*
1600 It is unclear how this provides a more compact expression, as
1601 ``DW_OP_regval_type`` could be used which is marginally larger.
1603 If the result of E is a value V, then V is pushed on the stack.
1605 Otherwise, the DWARF expression is ill-formed.
1607 *The* ``DW_OP_entry_value`` *operation is deprecated as its main usage is
1608 provided by other means. DWARF Version 5 added the*
1609 ``DW_TAG_call_site_parameter`` *debugger information entry for call sites
1610 that has* ``DW_AT_call_value``\ *,* ``DW_AT_call_data_location``\ *, and*
1611 ``DW_AT_call_data_value`` *attributes that provide DWARF expressions to
1612 compute actual parameter values at the time of the call, and requires the
1613 producer to ensure the expressions are valid to evaluate even when virtually
1614 unwound. The* ``DW_OP_LLVM_call_frame_entry_reg`` *operation provides access
1615 to registers in the virtually unwound calling frame.*
1619 GDB only implements ``DW_OP_entry_value`` when E is exactly
1620 ``DW_OP_reg*`` or ``DW_OP_breg*; DW_OP_deref*``.
1622 .. _amdgpu-dwarf-location-description-operations:
1624 Location Description Operations
1625 ###############################
1627 This section describes the operations that push location descriptions on the
1630 General Location Description Operations
1631 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1633 1. ``DW_OP_LLVM_offset`` *New*
1635 ``DW_OP_LLVM_offset`` pops two stack entries. The first must be an integral
1636 type value that represents a byte displacement B. The second must be a
1637 location description L.
1639 It adds the value of B scaled by 8 (the byte size) to the bit offset of each
1640 single location description SL of L, and pushes the updated L.
1642 It is an evaluation error if the updated bit offset of any SL is less than 0
1643 or greater than or equal to the size of the location storage specified by
1646 2. ``DW_OP_LLVM_offset_uconst`` *New*
1648 ``DW_OP_LLVM_offset_uconst`` has a single unsigned LEB128 integer operand
1649 that represents a byte displacement B.
1651 The operation is equivalent to performing ``DW_OP_constu B;
1652 DW_OP_LLVM_offset``.
1654 *This operation is supplied specifically to be able to encode more field
1655 displacements in two bytes than can be done with* ``DW_OP_lit*;
1656 DW_OP_LLVM_offset``\ *.*
1660 Should this be named ``DW_OP_LLVM_offset_uconst`` to match
1661 ``DW_OP_plus_uconst``, or ``DW_OP_LLVM_offset_constu`` to match
1664 3. ``DW_OP_LLVM_bit_offset`` *New*
1666 ``DW_OP_LLVM_bit_offset`` pops two stack entries. The first must be an
1667 integral type value that represents a bit displacement B. The second must be
1668 a location description L.
1670 It adds the value of B to the bit offset of each single location description
1671 SL of L, and pushes the updated L.
1673 It is an evaluation error if the updated bit offset of any SL is less than 0
1674 or greater than or equal to the size of the location storage specified by
1677 4. ``DW_OP_push_object_address``
1679 ``DW_OP_push_object_address`` pushes the location description L of the
1682 *This object may correspond to an independent variable that is part of a
1683 user presented expression that is being evaluated. The object location
1684 description may be determined from the variable's own debugging information
1685 entry or it may be a component of an array, structure, or class whose
1686 address has been dynamically determined by an earlier step during user
1687 expression evaluation.*
1689 *This operation provides explicit functionality (especially for arrays
1690 involving descriptions) that is analogous to the implicit push of the base
1691 location description of a structure prior to evaluation of a
1692 ``DW_AT_data_member_location`` to access a data member of a structure.*
1696 This operation could be removed and the object location description
1697 specified as the initial stack as for ``DW_AT_data_member_location``.
1699 The only attribute that specifies a current object is
1700 ``DW_AT_data_location`` so the non-normative text seems to overstate how
1701 this is being used. Or are there other attributes that need to state they
1704 5. ``DW_OP_LLVM_call_frame_entry_reg`` *New*
1706 ``DW_OP_LLVM_call_frame_entry_reg`` has a single unsigned LEB128 integer
1707 operand that represents a target architecture register number R.
1709 It pushes a location description L that holds the value of register R on
1710 entry to the current subprogram as defined by the call frame information
1711 (see :ref:`amdgpu-dwarf-call-frame-information`).
1713 *If there is no call frame information defined, then the default rules for
1714 the target architecture are used. If the register rule is* undefined\ *, then
1715 the undefined location description is pushed. If the register rule is* same
1716 value\ *, then a register location description for R is pushed.*
1718 .. _amdgpu-dwarf-undefined-location-description-operations:
1720 Undefined Location Description Operations
1721 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1723 *The undefined location storage represents a piece or all of an object that is
1724 present in the source but not in the object code (perhaps due to optimization).
1725 Neither reading nor writing to the undefined location storage is meaningful.*
1727 An undefined location description specifies the undefined location storage.
1728 There is no concept of the size of the undefined location storage, nor of a bit
1729 offset for an undefined location description. The ``DW_OP_LLVM_*offset``
1730 operations leave an undefined location description unchanged. The
1731 ``DW_OP_*piece`` operations can explicitly or implicitly specify an undefined
1732 location description, allowing any size and offset to be specified, and results
1733 in a part with all undefined bits.
1735 1. ``DW_OP_LLVM_undefined`` *New*
1737 ``DW_OP_LLVM_undefined`` pushes a location description L that comprises one
1738 undefined location description SL.
1740 .. _amdgpu-dwarf-memory-location-description-operations:
1742 Memory Location Description Operations
1743 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1745 Each of the target architecture specific address spaces has a corresponding
1746 memory location storage that denotes the linear addressable memory of that
1747 address space. The size of each memory location storage corresponds to the range
1748 of the addresses in the corresponding address space.
1750 *It is target architecture defined how address space location storage maps to
1751 target architecture physical memory. For example, they may be independent
1752 memory, or more than one location storage may alias the same physical memory
1753 possibly at different offsets and with different interleaving. The mapping may
1754 also be dictated by the source language address classes.*
1756 A memory location description specifies a memory location storage. The bit
1757 offset corresponds to a bit position within a byte of the memory. Bits accessed
1758 using a memory location description, access the corresponding target
1759 architecture memory starting at the bit position within the byte specified by
1762 A memory location description that has a bit offset that is a multiple of 8 (the
1763 byte size) is defined to be a byte address memory location description. It has a
1764 memory byte address A that is equal to the bit offset divided by 8.
1766 A memory location description that does not have a bit offset that is a multiple
1767 of 8 (the byte size) is defined to be a bit field memory location description.
1768 It has a bit position B equal to the bit offset modulo 8, and a memory byte
1769 address A equal to the bit offset minus B that is then divided by 8.
1771 The address space AS of a memory location description is defined to be the
1772 address space that corresponds to the memory location storage associated with
1773 the memory location description.
1775 A location description that is comprised of one byte address memory location
1776 description SL is defined to be a memory byte address location description. It
1777 has a byte address equal to A and an address space equal to AS of the
1780 ``DW_ASPACE_none`` is defined as the target architecture default address space.
1782 If a stack entry is required to be a location description, but it is a value V
1783 with the generic type, then it is implicitly converted to a location description
1784 L with one memory location description SL. SL specifies the memory location
1785 storage that corresponds to the target architecture default address space with a
1786 bit offset equal to V scaled by 8 (the byte size).
1790 If it is wanted to allow any integral type value to be implicitly converted to
1791 a memory location description in the target architecture default address
1794 If a stack entry is required to be a location description, but is a value V
1795 with an integral type, then it is implicitly converted to a location
1796 description L with a one memory location description SL. If the type size of
1797 V is less than the generic type size, then the value V is zero extended to
1798 the size of the generic type. The least significant generic type size bits
1799 are treated as a twos-complement unsigned value to be used as an address A.
1800 SL specifies memory location storage corresponding to the target
1801 architecture default address space with a bit offset equal to A scaled by 8
1804 The implicit conversion could also be defined as target architecture specific.
1805 For example, GDB checks if V is an integral type. If it is not it gives an
1806 error. Otherwise, GDB zero-extends V to 64 bits. If the GDB target defines a
1807 hook function, then it is called. The target specific hook function can modify
1808 the 64-bit value, possibly sign extending based on the original value type.
1809 Finally, GDB treats the 64-bit value V as a memory location address.
1811 If a stack entry is required to be a location description, but it is an implicit
1812 pointer value IPV with the target architecture default address space, then it is
1813 implicitly converted to a location description with one single location
1814 description specified by IPV. See
1815 :ref:`amdgpu-dwarf-implicit-location-descriptions`.
1819 Is this rule required for DWARF Version 5 backwards compatibility? If not, it
1820 can be eliminated, and the producer can use
1821 ``DW_OP_LLVM_form_aspace_address``.
1823 If a stack entry is required to be a value, but it is a location description L
1824 with one memory location description SL in the target architecture default
1825 address space with a bit offset B that is a multiple of 8, then it is implicitly
1826 converted to a value equal to B divided by 8 (the byte size) with the generic
1831 ``DW_OP_addr`` has a single byte constant value operand, which has the size
1832 of the generic type, that represents an address A.
1834 It pushes a location description L with one memory location description SL
1835 on the stack. SL specifies the memory location storage corresponding to the
1836 target architecture default address space with a bit offset equal to A
1837 scaled by 8 (the byte size).
1839 *If the DWARF is part of a code object, then A may need to be relocated. For
1840 example, in the ELF code object format, A must be adjusted by the difference
1841 between the ELF segment virtual address and the virtual address at which the
1846 ``DW_OP_addrx`` has a single unsigned LEB128 integer operand that represents
1847 a zero-based index into the ``.debug_addr`` section relative to the value of
1848 the ``DW_AT_addr_base`` attribute of the associated compilation unit. The
1849 address value A in the ``.debug_addr`` section has the size of the generic
1852 It pushes a location description L with one memory location description SL
1853 on the stack. SL specifies the memory location storage corresponding to the
1854 target architecture default address space with a bit offset equal to A
1855 scaled by 8 (the byte size).
1857 *If the DWARF is part of a code object, then A may need to be relocated. For
1858 example, in the ELF code object format, A must be adjusted by the difference
1859 between the ELF segment virtual address and the virtual address at which the
1862 3. ``DW_OP_LLVM_form_aspace_address`` *New*
1864 ``DW_OP_LLVM_form_aspace_address`` pops top two stack entries. The first
1865 must be an integral type value that represents a target architecture
1866 specific address space identifier AS. The second must be an integral type
1867 value that represents an address A.
1869 The address size S is defined as the address bit size of the target
1870 architecture specific address space that corresponds to AS.
1872 A is adjusted to S bits by zero extending if necessary, and then treating the
1873 least significant S bits as a twos-complement unsigned value A'.
1875 It pushes a location description L with one memory location description SL
1876 on the stack. SL specifies the memory location storage LS that corresponds
1877 to AS with a bit offset equal to A' scaled by 8 (the byte size).
1879 If AS is an address space that is specific to context elements, then LS
1880 corresponds to the location storage associated with the current context.
1882 *For example, if AS is for per thread storage then LS is the location
1883 storage for the current thread. For languages that are implemented using a
1884 SIMD or SIMT execution model, then if AS is for per lane storage then LS is
1885 the location storage for the current lane of the current thread. Therefore,
1886 if L is accessed by an operation, the location storage selected when the
1887 location description was created is accessed, and not the location storage
1888 associated with the current context of the access operation.*
1890 The DWARF expression is ill-formed if AS is not one of the values defined by
1891 the target architecture specific ``DW_ASPACE_*`` values.
1893 See :ref:`amdgpu-dwarf-implicit-location-descriptions` for special rules
1894 concerning implicit pointer values produced by dereferencing implicit
1895 location descriptions created by the ``DW_OP_implicit_pointer`` and
1896 ``DW_OP_LLVM_implicit_aspace_pointer`` operations.
1898 4. ``DW_OP_form_tls_address``
1900 ``DW_OP_form_tls_address`` pops one stack entry that must be an integral
1901 type value and treats it as a thread-local storage address TA.
1903 It pushes a location description L with one memory location description SL
1904 on the stack. SL is the target architecture specific memory location
1905 description that corresponds to the thread-local storage address TA.
1907 The meaning of the thread-local storage address TA is defined by the
1908 run-time environment. If the run-time environment supports multiple
1909 thread-local storage blocks for a single thread, then the block
1910 corresponding to the executable or shared library containing this DWARF
1913 *Some implementations of C, C++, Fortran, and other languages support a
1914 thread-local storage class. Variables with this storage class have distinct
1915 values and addresses in distinct threads, much as automatic variables have
1916 distinct values and addresses in each subprogram invocation. Typically,
1917 there is a single block of storage containing all thread-local variables
1918 declared in the main executable, and a separate block for the variables
1919 declared in each shared library. Each thread-local variable can then be
1920 accessed in its block using an identifier. This identifier is typically a
1921 byte offset into the block and pushed onto the DWARF stack by one of the*
1922 ``DW_OP_const*`` *operations prior to the* ``DW_OP_form_tls_address``
1923 *operation. Computing the address of the appropriate block can be complex
1924 (in some cases, the compiler emits a function call to do it), and difficult
1925 to describe using ordinary DWARF location descriptions. Instead of forcing
1926 complex thread-local storage calculations into the DWARF expressions, the*
1927 ``DW_OP_form_tls_address`` *allows the consumer to perform the computation
1928 based on the target architecture specific run-time environment.*
1930 5. ``DW_OP_call_frame_cfa``
1932 ``DW_OP_call_frame_cfa`` pushes the location description L of the Canonical
1933 Frame Address (CFA) of the current subprogram, obtained from the call frame
1934 information on the stack. See :ref:`amdgpu-dwarf-call-frame-information`.
1936 *Although the value of the* ``DW_AT_frame_base`` *attribute of the debugger
1937 information entry corresponding to the current subprogram can be computed
1938 using a location list expression, in some cases this would require an
1939 extensive location list because the values of the registers used in
1940 computing the CFA change during a subprogram execution. If the call frame
1941 information is present, then it already encodes such changes, and it is
1942 space efficient to reference that using the* ``DW_OP_call_frame_cfa``
1947 ``DW_OP_fbreg`` has a single signed LEB128 integer operand that represents a
1948 byte displacement B.
1950 The location description L for the *frame base* of the current subprogram is
1951 obtained from the ``DW_AT_frame_base`` attribute of the debugger information
1952 entry corresponding to the current subprogram as described in
1953 :ref:`amdgpu-dwarf-debugging-information-entry-attributes`.
1955 The location description L is updated as if the ``DW_OP_LLVM_offset_uconst
1956 B`` operation was applied. The updated L is pushed on the stack.
1958 7. ``DW_OP_breg0``, ``DW_OP_breg1``, ..., ``DW_OP_breg31``
1960 The ``DW_OP_breg<N>`` operations encode the numbers of up to 32 registers,
1961 numbered from 0 through 31, inclusive. The register number R corresponds to
1962 the N in the operation name.
1964 They have a single signed LEB128 integer operand that represents a byte
1967 The address space identifier AS is defined as the one corresponding to the
1968 target architecture specific default address space.
1970 The address size S is defined as the address bit size of the target
1971 architecture specific address space corresponding to AS.
1973 The contents of the register specified by R are retrieved as if a
1974 ``DW_OP_regval_type R, DR`` operation was performed where DR is the offset
1975 of a hypothetical debug information entry in the current compilation unit
1976 for an unsigned integral base type of size S bits. B is added and the least
1977 significant S bits are treated as an unsigned value to be used as an address
1980 They push a location description L comprising one memory location
1981 description LS on the stack. LS specifies the memory location storage that
1982 corresponds to AS with a bit offset equal to A scaled by 8 (the byte size).
1986 ``DW_OP_bregx`` has two operands. The first is an unsigned LEB128 integer
1987 that represents a register number R. The second is a signed LEB128
1988 integer that represents a byte displacement B.
1990 The action is the same as for ``DW_OP_breg<N>``, except that R is used as
1991 the register number and B is used as the byte displacement.
1993 9. ``DW_OP_LLVM_aspace_bregx`` *New*
1995 ``DW_OP_LLVM_aspace_bregx`` has two operands. The first is an unsigned
1996 LEB128 integer that represents a register number R. The second is a signed
1997 LEB128 integer that represents a byte displacement B. It pops one stack
1998 entry that is required to be an integral type value that represents a target
1999 architecture specific address space identifier AS.
2001 The action is the same as for ``DW_OP_breg<N>``, except that R is used as
2002 the register number, B is used as the byte displacement, and AS is used as
2003 the address space identifier.
2005 The DWARF expression is ill-formed if AS is not one of the values defined by
2006 the target architecture specific ``DW_ASPACE_*`` values.
2010 Could also consider adding ``DW_OP_aspace_breg0, DW_OP_aspace_breg1, ...,
2011 DW_OP_aspace_bref31`` which would save encoding size.
2013 .. _amdgpu-dwarf-register-location-descriptions:
2015 Register Location Description Operations
2016 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2018 There is a register location storage that corresponds to each of the target
2019 architecture registers. The size of each register location storage corresponds
2020 to the size of the corresponding target architecture register.
2022 A register location description specifies a register location storage. The bit
2023 offset corresponds to a bit position within the register. Bits accessed using a
2024 register location description access the corresponding target architecture
2025 register starting at the specified bit offset.
2027 1. ``DW_OP_reg0``, ``DW_OP_reg1``, ..., ``DW_OP_reg31``
2029 ``DW_OP_reg<N>`` operations encode the numbers of up to 32 registers,
2030 numbered from 0 through 31, inclusive. The target architecture register
2031 number R corresponds to the N in the operation name.
2033 The operation is equivalent to performing ``DW_OP_regx R``.
2037 ``DW_OP_regx`` has a single unsigned LEB128 integer operand that represents
2038 a target architecture register number R.
2040 If the current call frame is the top call frame, it pushes a location
2041 description L that specifies one register location description SL on the
2042 stack. SL specifies the register location storage that corresponds to R with
2043 a bit offset of 0 for the current thread.
2045 If the current call frame is not the top call frame, call frame information
2046 (see :ref:`amdgpu-dwarf-call-frame-information`) is used to determine the
2047 location description that holds the register for the current call frame and
2048 current program location of the current thread. The resulting location
2049 description L is pushed.
2051 *Note that if call frame information is used, the resulting location
2052 description may be register, memory, or undefined.*
2054 *An implementation may evaluate the call frame information immediately, or
2055 may defer evaluation until L is accessed by an operation. If evaluation is
2056 deferred, R and the current context can be recorded in L. When accessed, the
2057 recorded context is used to evaluate the call frame information, not the
2058 current context of the access operation.*
2060 *These operations obtain a register location. To fetch the contents of a
2061 register, it is necessary to use* ``DW_OP_regval_type``\ *, use one of the*
2062 ``DW_OP_breg*`` *register-based addressing operations, or use* ``DW_OP_deref*``
2063 *on a register location description.*
2065 .. _amdgpu-dwarf-implicit-location-descriptions:
2067 Implicit Location Description Operations
2068 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2070 Implicit location storage represents a piece or all of an object which has no
2071 actual location in the program but whose contents are nonetheless known, either
2072 as a constant or can be computed from other locations and values in the program.
2074 An implicit location description specifies an implicit location storage. The bit
2075 offset corresponds to a bit position within the implicit location storage. Bits
2076 accessed using an implicit location description, access the corresponding
2077 implicit storage value starting at the bit offset.
2079 1. ``DW_OP_implicit_value``
2081 ``DW_OP_implicit_value`` has two operands. The first is an unsigned LEB128
2082 integer that represents a byte size S. The second is a block of bytes with a
2083 length equal to S treated as a literal value V.
2085 An implicit location storage LS is created with the literal value V and a
2088 It pushes location description L with one implicit location description SL
2089 on the stack. SL specifies LS with a bit offset of 0.
2091 2. ``DW_OP_stack_value``
2093 ``DW_OP_stack_value`` pops one stack entry that must be a value V.
2095 An implicit location storage LS is created with the literal value V using
2096 the size, encoding, and enianity specified by V's base type.
2098 It pushes a location description L with one implicit location description SL
2099 on the stack. SL specifies LS with a bit offset of 0.
2101 *The* ``DW_OP_stack_value`` *operation specifies that the object does not
2102 exist in memory, but its value is nonetheless known. In this form, the
2103 location description specifies the actual value of the object, rather than
2104 specifying the memory or register storage that holds the value.*
2106 See :ref:`amdgpu-dwarf-implicit-location-descriptions` for special rules
2107 concerning implicit pointer values produced by dereferencing implicit
2108 location descriptions created by the ``DW_OP_implicit_pointer`` and
2109 ``DW_OP_LLVM_implicit_aspace_pointer`` operations.
2113 Since location descriptions are allowed on the stack, the
2114 ``DW_OP_stack_value`` operation no longer terminates the DWARF operation
2115 expression execution as in DWARF Version 5.
2117 3. ``DW_OP_implicit_pointer``
2119 *An optimizing compiler may eliminate a pointer, while still retaining the
2120 value that the pointer addressed.* ``DW_OP_implicit_pointer`` *allows a
2121 producer to describe this value.*
2123 ``DW_OP_implicit_pointer`` *specifies an object is a pointer to the target
2124 architecture default address space that cannot be represented as a real
2125 pointer, even though the value it would point to can be described. In this
2126 form, the location description specifies a debugging information entry that
2127 represents the actual location description of the object to which the
2128 pointer would point. Thus, a consumer of the debug information would be able
2129 to access the dereferenced pointer, even when it cannot access the pointer
2132 ``DW_OP_implicit_pointer`` has two operands. The first operand is a 4-byte
2133 unsigned value in the 32-bit DWARF format, or an 8-byte unsigned value in
2134 the 64-bit DWARF format, that represents the byte offset DR of a debugging
2135 information entry D relative to the beginning of the ``.debug_info`` section
2136 that contains the current compilation unit. The second operand is a signed
2137 LEB128 integer that represents a byte displacement B.
2139 *Note that D may not be in the current compilation unit.*
2141 *The first operand interpretation is exactly like that for*
2142 ``DW_FORM_ref_addr``\ *.*
2144 The address space identifier AS is defined as the one corresponding to the
2145 target architecture specific default address space.
2147 The address size S is defined as the address bit size of the target
2148 architecture specific address space corresponding to AS.
2150 An implicit location storage LS is created with the debugging information
2151 entry D, address space AS, and size of S.
2153 It pushes a location description L that comprises one implicit location
2154 description SL on the stack. SL specifies LS with a bit offset of 0.
2156 It is an evaluation error if a ``DW_OP_deref*`` operation pops a location
2157 description L', and retrieves S bits, such that any retrieved bits come from
2158 an implicit location storage that is the same as LS, unless both the
2159 following conditions are met:
2161 1. All retrieved bits come from an implicit location description that
2162 refers to an implicit location storage that is the same as LS.
2164 *Note that all bits do not have to come from the same implicit location
2165 description, as L' may involve composite location descriptors.*
2167 2. The bits come from consecutive ascending offsets within their respective
2168 implicit location storage.
2170 *These rules are equivalent to retrieving the complete contents of LS.*
2172 If both the above conditions are met, then the value V pushed by the
2173 ``DW_OP_deref*`` operation is an implicit pointer value IPV with a target
2174 architecture specific address space of AS, a debugging information entry of
2175 D, and a base type of T. If AS is the target architecture default address
2176 space, then T is the generic type. Otherwise, T is a target architecture
2177 specific integral type with a bit size equal to S.
2179 If IPV is either implicitly converted to a location description (only done
2180 if AS is the target architecture default address space) or used by
2181 ``DW_OP_LLVM_form_aspace_address`` (only done if the address space popped by
2182 ``DW_OP_LLVM_form_aspace_address`` is AS), then the resulting location
2185 * If D has a ``DW_AT_location`` attribute, the DWARF expression E from the
2186 ``DW_AT_location`` attribute is evaluated with the current context, except
2187 that the result kind is a location description, the compilation unit is
2188 the one that contains D, the object is unspecified, and the initial stack
2189 is empty. RL is the expression result.
2191 *Note that E is evaluated with the context of the expression accessing
2192 IPV, and not the context of the expression that contained the*
2193 ``DW_OP_implicit_pointer`` *or* ``DW_OP_LLVM_aspace_implicit_pointer``
2194 *operation that created L.*
2196 * If D has a ``DW_AT_const_value`` attribute, then an implicit location
2197 storage RLS is created from the ``DW_AT_const_value`` attribute's value
2198 with a size matching the size of the ``DW_AT_const_value`` attribute's
2199 value. RL comprises one implicit location description SRL. SRL specifies
2200 RLS with a bit offset of 0.
2204 If using ``DW_AT_const_value`` for variables and formal parameters is
2205 deprecated and instead ``DW_AT_location`` is used with an implicit
2206 location description, then this rule would not be required.
2208 * Otherwise, it is an evaluation error.
2210 The bit offset of RL is updated as if the ``DW_OP_LLVM_offset_uconst B``
2211 operation was applied.
2213 If a ``DW_OP_stack_value`` operation pops a value that is the same as IPV,
2214 then it pushes a location description that is the same as L.
2216 It is an evaluation error if LS or IPV is accessed in any other manner.
2218 *The restrictions on how an implicit pointer location description created
2219 by* ``DW_OP_implicit_pointer`` *and* ``DW_OP_LLVM_aspace_implicit_pointer``
2220 *can be used are to simplify the DWARF consumer. Similarly, for an implicit
2221 pointer value created by* ``DW_OP_deref*`` *and* ``DW_OP_stack_value``\ .*
2223 4. ``DW_OP_LLVM_aspace_implicit_pointer`` *New*
2225 ``DW_OP_LLVM_aspace_implicit_pointer`` has two operands that are the same as
2226 for ``DW_OP_implicit_pointer``.
2228 It pops one stack entry that must be an integral type value that represents
2229 a target architecture specific address space identifier AS.
2231 The location description L that is pushed on the stack is the same as for
2232 ``DW_OP_implicit_pointer``, except that the address space identifier used is
2235 The DWARF expression is ill-formed if AS is not one of the values defined by
2236 the target architecture specific ``DW_ASPACE_*`` values.
2240 This definition of ``DW_OP_LLVM_aspace_implicit_pointer`` may change when
2241 full support for address classes is added as required for languages such
2244 *Typically a* ``DW_OP_implicit_pointer`` *or*
2245 ``DW_OP_LLVM_aspace_implicit_pointer`` *operation is used in a DWARF expression
2246 E*\ :sub:`1` *of a* ``DW_TAG_variable`` *or* ``DW_TAG_formal_parameter``
2247 *debugging information entry D*\ :sub:`1`\ *'s* ``DW_AT_location`` *attribute.
2248 The debugging information entry referenced by the* ``DW_OP_implicit_pointer``
2249 *or* ``DW_OP_LLVM_aspace_implicit_pointer`` *operations is typically itself a*
2250 ``DW_TAG_variable`` *or* ``DW_TAG_formal_parameter`` *debugging information
2251 entry D*\ :sub:`2` *whose* ``DW_AT_location`` *attribute gives a second DWARF
2252 expression E*\ :sub:`2`\ *.*
2254 *D*\ :sub:`1` *and E*\ :sub:`1` *are describing the location of a pointer type
2255 object. D*\ :sub:`2` *and E*\ :sub:`2` *are describing the location of the
2256 object pointed to by that pointer object.*
2258 *However, D*\ :sub:`2` *may be any debugging information entry that contains a*
2259 ``DW_AT_location`` *or* ``DW_AT_const_value`` *attribute (for example,*
2260 ``DW_TAG_dwarf_procedure``\ *). By using E*\ :sub:`2`\ *, a consumer can
2261 reconstruct the value of the object when asked to dereference the pointer
2262 described by E*\ :sub:`1` *which contains the* ``DW_OP_implicit_pointer`` or
2263 ``DW_OP_LLVM_aspace_implicit_pointer`` *operation.*
2265 .. _amdgpu-dwarf-composite-location-description-operations:
2267 Composite Location Description Operations
2268 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2270 A composite location storage represents an object or value which may be
2271 contained in part of another location storage or contained in parts of more
2272 than one location storage.
2274 Each part has a part location description L and a part bit size S. L can have
2275 one or more single location descriptions SL. If there are more than one SL then
2276 that indicates that part is located in more than one place. The bits of each
2277 place of the part comprise S contiguous bits from the location storage LS
2278 specified by SL starting at the bit offset specified by SL. All the bits must
2279 be within the size of LS or the DWARF expression is ill-formed.
2281 A composite location storage can have zero or more parts. The parts are
2282 contiguous such that the zero-based location storage bit index will range over
2283 each part with no gaps between them. Therefore, the size of a composite location
2284 storage is the sum of the size of its parts. The DWARF expression is ill-formed
2285 if the size of the contiguous location storage is larger than the size of the
2286 memory location storage corresponding to the largest target architecture
2287 specific address space.
2289 A composite location description specifies a composite location storage. The bit
2290 offset corresponds to a bit position within the composite location storage.
2292 There are operations that create a composite location storage.
2294 There are other operations that allow a composite location storage to be
2295 incrementally created. Each part is created by a separate operation. There may
2296 be one or more operations to create the final composite location storage. A
2297 series of such operations describes the parts of the composite location storage
2298 that are in the order that the associated part operations are executed.
2300 To support incremental creation, a composite location storage can be in an
2301 incomplete state. When an incremental operation operates on an incomplete
2302 composite location storage, it adds a new part, otherwise it creates a new
2303 composite location storage. The ``DW_OP_LLVM_piece_end`` operation explicitly
2304 makes an incomplete composite location storage complete.
2306 A composite location description that specifies a composite location storage
2307 that is incomplete is termed an incomplete composite location description. A
2308 composite location description that specifies a composite location storage that
2309 is complete is termed a complete composite location description.
2311 If the top stack entry is a location description that has one incomplete
2312 composite location description SL after the execution of an operation expression
2313 has completed, SL is converted to a complete composite location description.
2315 *Note that this conversion does not happen after the completion of an operation
2316 expression that is evaluated on the same stack by the* ``DW_OP_call*``
2317 *operations. Such executions are not a separate evaluation of an operation
2318 expression, but rather the continued evaluation of the same operation expression
2319 that contains the* ``DW_OP_call*`` *operation.*
2321 If a stack entry is required to be a location description L, but L has an
2322 incomplete composite location description, then the DWARF expression is
2323 ill-formed. The exception is for the operations involved in incrementally
2324 creating a composite location description as described below.
2326 *Note that a DWARF operation expression may arbitrarily compose composite
2327 location descriptions from any other location description, including those that
2328 have multiple single location descriptions, and those that have composite
2329 location descriptions.*
2331 *The incremental composite location description operations are defined to be
2332 compatible with the definitions in DWARF Version 5.*
2336 ``DW_OP_piece`` has a single unsigned LEB128 integer that represents a byte
2339 The action is based on the context:
2341 * If the stack is empty, then a location description L comprised of one
2342 incomplete composite location description SL is pushed on the stack.
2344 An incomplete composite location storage LS is created with a single part
2345 P. P specifies a location description PL and has a bit size of S scaled by
2346 8 (the byte size). PL is comprised of one undefined location description
2349 SL specifies LS with a bit offset of 0.
2351 * Otherwise, if the top stack entry is a location description L comprised of
2352 one incomplete composite location description SL, then the incomplete
2353 composite location storage LS that SL specifies is updated to append a new
2354 part P. P specifies a location description PL and has a bit size of S
2355 scaled by 8 (the byte size). PL is comprised of one undefined location
2356 description PSL. L is left on the stack.
2358 * Otherwise, if the top stack entry is a location description or can be
2359 converted to one, then it is popped and treated as a part location
2360 description PL. Then:
2362 * If the top stack entry (after popping PL) is a location description L
2363 comprised of one incomplete composite location description SL, then the
2364 incomplete composite location storage LS that SL specifies is updated to
2365 append a new part P. P specifies the location description PL and has a
2366 bit size of S scaled by 8 (the byte size). L is left on the stack.
2368 * Otherwise, a location description L comprised of one incomplete
2369 composite location description SL is pushed on the stack.
2371 An incomplete composite location storage LS is created with a single
2372 part P. P specifies the location description PL and has a bit size of S
2373 scaled by 8 (the byte size).
2375 SL specifies LS with a bit offset of 0.
2377 * Otherwise, the DWARF expression is ill-formed
2379 *Many compilers store a single variable in sets of registers or store a
2380 variable partially in memory and partially in registers.* ``DW_OP_piece``
2381 *provides a way of describing where a part of a variable is located.*
2383 *If a non-0 byte displacement is required, the* ``DW_OP_LLVM_offset``
2384 *operation can be used to update the location description before using it as
2385 the part location description of a* ``DW_OP_piece`` *operation.*
2387 *The evaluation rules for the* ``DW_OP_piece`` *operation allow it to be
2388 compatible with the DWARF Version 5 definition.*
2392 Since these extensions allow location descriptions to be entries on the
2393 stack, a simpler operation to create composite location descriptions could
2394 be defined. For example, just one operation that specifies how many parts,
2395 and pops pairs of stack entries for the part size and location
2396 description. Not only would this be a simpler operation and avoid the
2397 complexities of incomplete composite location descriptions, but it may
2398 also have a smaller encoding in practice. However, the desire for
2399 compatibility with DWARF Version 5 is likely a stronger consideration.
2401 2. ``DW_OP_bit_piece``
2403 ``DW_OP_bit_piece`` has two operands. The first is an unsigned LEB128
2404 integer that represents the part bit size S. The second is an unsigned
2405 LEB128 integer that represents a bit displacement B.
2407 The action is the same as for ``DW_OP_piece``, except that any part created
2408 has the bit size S, and the location description PL of any created part is
2409 updated as if the ``DW_OP_constu B; DW_OP_LLVM_bit_offset`` operations were
2412 ``DW_OP_bit_piece`` *is used instead of* ``DW_OP_piece`` *when the piece to
2413 be assembled is not byte-sized or is not at the start of the part location
2416 *If a computed bit displacement is required, the* ``DW_OP_LLVM_bit_offset``
2417 *operation can be used to update the location description before using it as
2418 the part location description of a* ``DW_OP_bit_piece`` *operation.*
2422 The bit offset operand is not needed as ``DW_OP_LLVM_bit_offset`` can be
2423 used on the part's location description.
2425 3. ``DW_OP_LLVM_piece_end`` *New*
2427 If the top stack entry is not a location description L comprised of one
2428 incomplete composite location description SL, then the DWARF expression is
2431 Otherwise, the incomplete composite location storage LS specified by SL is
2432 updated to be a complete composite location description with the same parts.
2434 4. ``DW_OP_LLVM_extend`` *New*
2436 ``DW_OP_LLVM_extend`` has two operands. The first is an unsigned LEB128
2437 integer that represents the element bit size S. The second is an unsigned
2438 LEB128 integer that represents a count C.
2440 It pops one stack entry that must be a location description and is treated
2441 as the part location description PL.
2443 A location description L comprised of one complete composite location
2444 description SL is pushed on the stack.
2446 A complete composite location storage LS is created with C identical parts
2447 P. Each P specifies PL and has a bit size of S.
2449 SL specifies LS with a bit offset of 0.
2451 The DWARF expression is ill-formed if the element bit size or count are 0.
2453 5. ``DW_OP_LLVM_select_bit_piece`` *New*
2455 ``DW_OP_LLVM_select_bit_piece`` has two operands. The first is an unsigned
2456 LEB128 integer that represents the element bit size S. The second is an
2457 unsigned LEB128 integer that represents a count C.
2459 It pops three stack entries. The first must be an integral type value that
2460 represents a bit mask value M. The second must be a location description
2461 that represents the one-location description L1. The third must be a
2462 location description that represents the zero-location description L0.
2464 A complete composite location storage LS is created with C parts P\ :sub:`N`
2465 ordered in ascending N from 0 to C-1 inclusive. Each P\ :sub:`N` specifies
2466 location description PL\ :sub:`N` and has a bit size of S.
2468 PL\ :sub:`N` is as if the ``DW_OP_LLVM_bit_offset N*S`` operation was
2469 applied to PLX\ :sub:`N`\ .
2471 PLX\ :sub:`N` is the same as L0 if the N\ :sup:`th` least significant bit of
2472 M is a zero, otherwise it is the same as L1.
2474 A location description L comprised of one complete composite location
2475 description SL is pushed on the stack. SL specifies LS with a bit offset of
2478 The DWARF expression is ill-formed if S or C are 0, or if the bit size of M
2481 .. _amdgpu-dwarf-location-list-expressions:
2483 DWARF Location List Expressions
2484 +++++++++++++++++++++++++++++++
2486 *To meet the needs of recent computer architectures and optimization techniques,
2487 debugging information must be able to describe the location of an object whose
2488 location changes over the object’s lifetime, and may reside at multiple
2489 locations during parts of an object's lifetime. Location list expressions are
2490 used in place of operation expressions whenever the object whose location is
2491 being described has these requirements.*
2493 A location list expression consists of a series of location list entries. Each
2494 location list entry is one of the following kinds:
2496 *Bounded location description*
2498 This kind of location list entry provides an operation expression that
2499 evaluates to the location description of an object that is valid over a
2500 lifetime bounded by a starting and ending address. The starting address is the
2501 lowest address of the address range over which the location is valid. The
2502 ending address is the address of the first location past the highest address
2503 of the address range.
2505 The location list entry matches when the current program location is within
2508 There are several kinds of bounded location description entries which differ
2509 in the way that they specify the starting and ending addresses.
2511 *Default location description*
2513 This kind of location list entry provides an operation expression that
2514 evaluates to the location description of an object that is valid when no
2515 bounded location description entry applies.
2517 The location list entry matches when the current program location is not
2518 within the range of any bounded location description entry.
2522 This kind of location list entry provides an address to be used as the base
2523 address for beginning and ending address offsets given in certain kinds of
2524 bounded location description entries. The applicable base address of a bounded
2525 location description entry is the address specified by the closest preceding
2526 base address entry in the same location list. If there is no preceding base
2527 address entry, then the applicable base address defaults to the base address
2528 of the compilation unit (see DWARF Version 5 section 3.1.1).
2530 In the case of a compilation unit where all of the machine code is contained
2531 in a single contiguous section, no base address entry is needed.
2535 This kind of location list entry marks the end of the location list
2538 The address ranges defined by the bounded location description entries of a
2539 location list expression may overlap. When they do, they describe a situation in
2540 which an object exists simultaneously in more than one place.
2542 If all of the address ranges in a given location list expression do not
2543 collectively cover the entire range over which the object in question is
2544 defined, and there is no following default location description entry, it is
2545 assumed that the object is not available for the portion of the range that is
2548 The result of the evaluation of a DWARF location list expression is:
2550 * If the current program location is not specified, then it is an evaluation
2555 If the location list only has a single default entry, should that be
2556 considered a match if there is no program location? If there are non-default
2557 entries then it seems it has to be an evaluation error when there is no
2558 program location as that indicates the location depends on the program
2559 location which is not known.
2561 * If there are no matching location list entries, then the result is a location
2562 description that comprises one undefined location description.
2564 * Otherwise, the operation expression E of each matching location list entry is
2565 evaluated with the current context, except that the result kind is a location
2566 description, the object is unspecified, and the initial stack is empty. The
2567 location list entry result is the location description returned by the
2570 The result is a location description that is comprised of the union of the
2571 single location descriptions of the location description result of each
2572 matching location list entry.
2574 A location list expression can only be used as the value of a debugger
2575 information entry attribute that is encoded using class ``loclist`` or
2576 ``loclistsptr`` (see DWARF Version 5 section 7.5.5). The value of the attribute
2577 provides an index into a separate object file section called ``.debug_loclists``
2578 or ``.debug_loclists.dwo`` (for split DWARF object files) that contains the
2579 location list entries.
2581 A ``DW_OP_call*`` and ``DW_OP_implicit_pointer`` operation can be used to
2582 specify a debugger information entry attribute that has a location list
2583 expression. Several debugger information entry attributes allow DWARF
2584 expressions that are evaluated with an initial stack that includes a location
2585 description that may originate from the evaluation of a location list
2588 *This location list representation, the* ``loclist`` *and* ``loclistsptr``
2589 *class, and the related* ``DW_AT_loclists_base`` *attribute are new in DWARF
2590 Version 5. Together they eliminate most, or all of the code object relocations
2591 previously needed for location list expressions.*
2595 The rest of this section is the same as DWARF Version 5 section 2.6.2.
2597 .. _amdgpu-dwarf-segment_addresses:
2604 This augments DWARF Version 5 section 2.12.
2606 DWARF address classes are used for source languages that have the concept of
2607 memory spaces. They are used in the ``DW_AT_address_class`` attribute for
2608 pointer type, reference type, subprogram, and subprogram type debugger
2609 information entries.
2611 Each DWARF address class is conceptually a separate source language memory space
2612 with its own lifetime and aliasing rules. DWARF address classes are used to
2613 specify the source language memory spaces that pointer type and reference type
2614 values refer, and to specify the source language memory space in which variables
2617 The set of currently defined source language DWARF address classes, together
2618 with source language mappings, is given in
2619 :ref:`amdgpu-dwarf-address-class-table`.
2621 Vendor defined source language address classes may be defined using codes in the
2622 range ``DW_ADDR_LLVM_lo_user`` to ``DW_ADDR_LLVM_hi_user``.
2624 .. table:: Address class
2625 :name: amdgpu-dwarf-address-class-table
2627 ========================= ============ ========= ========= =========
2628 Address Class Name Meaning C/C++ OpenCL CUDA/HIP
2629 ========================= ============ ========= ========= =========
2630 ``DW_ADDR_none`` generic *default* generic *default*
2631 ``DW_ADDR_LLVM_global`` global global
2632 ``DW_ADDR_LLVM_constant`` constant constant constant
2633 ``DW_ADDR_LLVM_group`` thread-group local shared
2634 ``DW_ADDR_LLVM_private`` thread private
2635 ``DW_ADDR_LLVM_lo_user``
2636 ``DW_ADDR_LLVM_hi_user``
2637 ========================= ============ ========= ========= =========
2639 DWARF address spaces correspond to target architecture specific linear
2640 addressable memory areas. They are used in DWARF expression location
2641 descriptions to describe in which target architecture specific memory area data
2644 *Target architecture specific DWARF address spaces may correspond to hardware
2645 supported facilities such as memory utilizing base address registers, scratchpad
2646 memory, and memory with special interleaving. The size of addresses in these
2647 address spaces may vary. Their access and allocation may be hardware managed
2648 with each thread or group of threads having access to independent storage. For
2649 these reasons they may have properties that do not allow them to be viewed as
2650 part of the unified global virtual address space accessible by all threads.*
2652 *It is target architecture specific whether multiple DWARF address spaces are
2653 supported and how source language DWARF address classes map to target
2654 architecture specific DWARF address spaces. A target architecture may map
2655 multiple source language DWARF address classes to the same target architecture
2656 specific DWARF address class. Optimization may determine that variable lifetime
2657 and access pattern allows them to be allocated in faster scratchpad memory
2658 represented by a different DWARF address space.*
2660 Although DWARF address space identifiers are target architecture specific,
2661 ``DW_ASPACE_none`` is a common address space supported by all target
2664 DWARF address space identifiers are used by:
2666 * The DWARF expression operations: ``DW_OP_LLVM_aspace_bregx``,
2667 ``DW_OP_LLVM_form_aspace_address``, ``DW_OP_LLVM_implicit_aspace_pointer``,
2668 and ``DW_OP_xderef*``.
2670 * The CFI instructions: ``DW_CFA_LLVM_def_aspace_cfa`` and
2671 ``DW_CFA_LLVM_def_aspace_cfa_sf``.
2675 With the definition of DWARF address classes and DWARF address spaces in these
2676 extensions, DWARF Version 5 table 2.7 needs to be updated. It seems it is an
2677 example of DWARF address spaces and not DWARF address classes.
2681 With the expanded support for DWARF address spaces in these extensions, it may
2682 be worth examining if DWARF segments can be eliminated and DWARF address
2683 spaces used instead.
2685 That may involve extending DWARF address spaces to also be used to specify
2686 code locations. In target architectures that use different memory areas for
2687 code and data this would seem a natural use for DWARF address spaces. This
2688 would allow DWARF expression location descriptions to be used to describe the
2689 location of subprograms and entry points that are used in expressions
2690 involving subprogram pointer type values.
2692 Currently, DWARF expressions assume data and code resides in the same default
2693 DWARF address space, and only the address ranges in DWARF location list
2694 entries and in the ``.debug_aranges`` section for accelerated access for
2695 addresses allow DWARF segments to be used to distinguish.
2699 Currently, DWARF defines address class values as being target architecture
2700 specific. It is unclear how language specific memory spaces are intended to be
2701 represented in DWARF using these.
2703 For example, OpenCL defines memory spaces (called address spaces in OpenCL)
2704 for ``global``, ``local``, ``constant``, and ``private``. These are part of
2705 the type system and are modifiers to pointer types. In addition, OpenCL
2706 defines ``generic`` pointers that can reference either the ``global``,
2707 ``local``, or ``private`` memory spaces. To support the OpenCL language the
2708 debugger would want to support casting pointers between the ``generic`` and
2709 other memory spaces, querying what memory space a ``generic`` pointer value is
2710 currently referencing, and possibly using pointer casting to form an address
2711 for a specific memory space out of an integral value.
2713 The method to use to dereference a pointer type or reference type value is
2714 defined in DWARF expressions using ``DW_OP_xderef*`` which uses a target
2715 architecture specific address space.
2717 DWARF defines the ``DW_AT_address_class`` attribute on pointer type and
2718 reference type debugger information entries. It specifies the method to use to
2719 dereference them. Why is the value of this not the same as the address space
2720 value used in ``DW_OP_xderef*``? In both cases it is target architecture
2721 specific and the architecture presumably will use the same set of methods to
2722 dereference pointers in both cases.
2724 Since ``DW_AT_address_class`` uses a target architecture specific value, it
2725 cannot in general capture the source language memory space type modifier
2726 concept. On some architectures all source language memory space modifiers may
2727 actually use the same method for dereferencing pointers.
2729 One possibility is for DWARF to add an ``DW_TAG_LLVM_address_class_type``
2730 debugger information entry type modifier that can be applied to a pointer type
2731 and reference type. The ``DW_AT_address_class`` attribute could be re-defined
2732 to not be target architecture specific and instead define generalized language
2733 values (as presented above for DWARF address classes in the table
2734 :ref:`amdgpu-dwarf-address-class-table`) that will support OpenCL and other
2735 languages using memory spaces. The ``DW_AT_address_class`` attribute could be
2736 defined to not be applied to pointer types or reference types, but instead
2737 only to the new ``DW_TAG_LLVM_address_class_type`` type modifier debugger
2740 If a pointer type or reference type is not modified by
2741 ``DW_TAG_LLVM_address_class_type`` or if ``DW_TAG_LLVM_address_class_type``
2742 has no ``DW_AT_address_class`` attribute, then the pointer type or reference
2743 type would be defined to use the ``DW_ADDR_none`` address class as currently.
2744 Since modifiers can be chained, it would need to be defined if multiple
2745 ``DW_TAG_LLVM_address_class_type`` modifiers were legal, and if so if the
2746 outermost one is the one that takes precedence.
2748 A target architecture implementation that supports multiple address spaces
2749 would need to map ``DW_ADDR_none`` appropriately to support CUDA-like
2750 languages that have no address classes in the type system but do support
2751 variable allocation in address classes. Such variable allocation would result
2752 in the variable's location description needing an address space.
2754 The approach presented in :ref:`amdgpu-dwarf-address-class-table` is to define
2755 the default ``DW_ADDR_none`` to be the generic address class and not the
2756 global address class. This matches how CLANG and LLVM have added support for
2757 CUDA-like languages on top of existing C++ language support. This allows all
2758 addresses to be generic by default which matches CUDA-like languages.
2760 An alternative approach is to define ``DW_ADDR_none`` as being the global
2761 address class and then change ``DW_ADDR_LLVM_global`` to
2762 ``DW_ADDR_LLVM_generic``. This would match the reality that languages that do
2763 not support multiple memory spaces only have one default global memory space.
2764 Generally, in these languages if they expose that the target architecture
2765 supports multiple address spaces, the default one is still the global memory
2766 space. Then a language that does support multiple memory spaces has to
2767 explicitly indicate which pointers have the added ability to reference more
2768 than the global memory space. However, compilers generating DWARF for
2769 CUDA-like languages would then have to define every CUDA-like language pointer
2770 type or reference type using ``DW_TAG_LLVM_address_class_type`` with a
2771 ``DW_AT_address_class`` attribute of ``DW_ADDR_LLVM_generic`` to match the
2774 A new ``DW_AT_LLVM_address_space`` attribute could be defined that can be
2775 applied to pointer type, reference type, subprogram, and subprogram type to
2776 describe how objects having the given type are dereferenced or called (the
2777 role that ``DW_AT_address_class`` currently provides). The values of
2778 ``DW_AT_address_space`` would be target architecture specific and the same as
2779 used in ``DW_OP_xderef*``.
2783 Some additional changes will be made to support languages such as OpenCL/SyCL
2784 that allow address class pointer casting and queries.
2786 This requires the compiler to provide the mapping from address space to
2787 address class which may be runtime and not target architecture dependent. Some
2788 implementations may have a one-to-one mapping from source language address
2789 class to target architecture address space, and some may have a many-to-one
2790 mapping which requires knowledge of the address class when determining if
2791 pointer address class casts are allowed.
2793 The changes will likely add an attribute that has an expression provided by
2794 the compiler to map from address class to address space. The
2795 ``DW_OP_implicit_pointer`` and ``DW_OP_LLVM_aspace_implicit_pointer``
2796 operations may be changed as the current IPV definition may not provide enough
2797 information when used to cast between address classes. Other attributes and
2798 operations may be needed. The legal casts between address classes may need to
2799 be defined on a per language address class basis.
2801 .. _amdgpu-dwarf-debugging-information-entry-attributes:
2803 Debugging Information Entry Attributes
2804 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2808 This section provides changes to existing debugger information entry
2809 attributes and defines attributes added by these extensions. These would be
2810 incorporated into the appropriate DWARF Version 5 chapter 2 sections.
2812 1. ``DW_AT_location``
2814 Any debugging information entry describing a data object (which includes
2815 variables and parameters) or common blocks may have a ``DW_AT_location``
2816 attribute, whose value is a DWARF expression E.
2818 The result of the attribute is obtained by evaluating E with a context that
2819 has a result kind of a location description, an unspecified object, the
2820 compilation unit that contains E, an empty initial stack, and other context
2821 elements corresponding to the source language thread of execution upon which
2822 the user is focused, if any. The result of the evaluation is the location
2823 description of the base of the data object.
2825 See :ref:`amdgpu-dwarf-control-flow-operations` for special evaluation rules
2826 used by the ``DW_OP_call*`` operations.
2830 Delete the description of how the ``DW_OP_call*`` operations evaluate a
2831 ``DW_AT_location`` attribute as that is now described in the operations.
2835 See the discussion about the ``DW_AT_location`` attribute in the
2836 ``DW_OP_call*`` operation. Having each attribute only have a single
2837 purpose and single execution semantics seems desirable. It makes it easier
2838 for the consumer that no longer have to track the context. It makes it
2839 easier for the producer as it can rely on a single semantics for each
2842 For that reason, limiting the ``DW_AT_location`` attribute to only
2843 supporting evaluating the location description of an object, and using a
2844 different attribute and encoding class for the evaluation of DWARF
2845 expression *procedures* on the same operation expression stack seems
2848 2. ``DW_AT_const_value``
2852 Could deprecate using the ``DW_AT_const_value`` attribute for
2853 ``DW_TAG_variable`` or ``DW_TAG_formal_parameter`` debugger information
2854 entries that have been optimized to a constant. Instead,
2855 ``DW_AT_location`` could be used with a DWARF expression that produces an
2856 implicit location description now that any location description can be
2857 used within a DWARF expression. This allows the ``DW_OP_call*`` operations
2858 to be used to push the location description of any variable regardless of
2859 how it is optimized.
2861 3. ``DW_AT_frame_base``
2863 A ``DW_TAG_subprogram`` or ``DW_TAG_entry_point`` debugger information entry
2864 may have a ``DW_AT_frame_base`` attribute, whose value is a DWARF expression
2867 The result of the attribute is obtained by evaluating E with a context that
2868 has a result kind of a location description, an unspecified object, the
2869 compilation unit that contains E, an empty initial stack, and other context
2870 elements corresponding to the source language thread of execution upon which
2871 the user is focused, if any.
2873 The DWARF is ill-formed if E contains an ``DW_OP_fbreg`` operation, or the
2874 resulting location description L is not comprised of one single location
2877 If SL a register location description for register R, then L is replaced
2878 with the result of evaluating a ``DW_OP_bregx R, 0`` operation. This
2879 computes the frame base memory location description in the target
2880 architecture default address space.
2882 *This allows the more compact* ``DW_OPreg*`` *to be used instead of*
2883 ``DW_OP_breg* 0``\ *.*
2887 This rule could be removed and require the producer to create the required
2888 location description directly using ``DW_OP_call_frame_cfa``,
2889 ``DW_OP_breg*``, or ``DW_OP_LLVM_aspace_bregx``. This would also then
2890 allow a target to implement the call frames within a large register.
2892 Otherwise, the DWARF is ill-formed if SL is not a memory location
2893 description in any of the target architecture specific address spaces.
2895 The resulting L is the *frame base* for the subprogram or entry point.
2897 *Typically, E will use the* ``DW_OP_call_frame_cfa`` *operation or be a
2898 stack pointer register plus or minus some offset.*
2900 4. ``DW_AT_data_member_location``
2902 For a ``DW_AT_data_member_location`` attribute there are two cases:
2904 1. If the attribute is an integer constant B, it provides the offset in
2905 bytes from the beginning of the containing entity.
2907 The result of the attribute is obtained by evaluating a
2908 ``DW_OP_LLVM_offset B`` operation with an initial stack comprising the
2909 location description of the beginning of the containing entity. The
2910 result of the evaluation is the location description of the base of the
2913 *If the beginning of the containing entity is not byte aligned, then the
2914 beginning of the member entry has the same bit displacement within a
2917 2. Otherwise, the attribute must be a DWARF expression E which is evaluated
2918 with a context that has a result kind of a location description, an
2919 unspecified object, the compilation unit that contains E, an initial
2920 stack comprising the location description of the beginning of the
2921 containing entity, and other context elements corresponding to the
2922 source language thread of execution upon which the user is focused, if
2923 any. The result of the evaluation is the location description of the
2924 base of the member entry.
2928 The beginning of the containing entity can now be any location
2929 description, including those with more than one single location
2930 description, and those with single location descriptions that are of any
2931 kind and have any bit offset.
2933 5. ``DW_AT_use_location``
2935 The ``DW_TAG_ptr_to_member_type`` debugging information entry has a
2936 ``DW_AT_use_location`` attribute whose value is a DWARF expression E. It is
2937 used to compute the location description of the member of the class to which
2938 the pointer to member entry points.
2940 *The method used to find the location description of a given member of a
2941 class, structure, or union is common to any instance of that class,
2942 structure, or union and to any instance of the pointer to member type. The
2943 method is thus associated with the pointer to member type, rather than with
2944 each object that has a pointer to member type.*
2946 The ``DW_AT_use_location`` DWARF expression is used in conjunction with the
2947 location description for a particular object of the given pointer to member
2948 type and for a particular structure or class instance.
2950 The result of the attribute is obtained by evaluating E with a context that
2951 has a result kind of a location description, an unspecified object, the
2952 compilation unit that contains E, an initial stack comprising two entries,
2953 and other context elements corresponding to the source language thread of
2954 execution upon which the user is focused, if any. The first stack entry is
2955 the value of the pointer to member object itself. The second stack entry is
2956 the location description of the base of the entire class, structure, or
2957 union instance containing the member whose location is being calculated. The
2958 result of the evaluation is the location description of the member of the
2959 class to which the pointer to member entry points.
2961 6. ``DW_AT_data_location``
2963 The ``DW_AT_data_location`` attribute may be used with any type that
2964 provides one or more levels of hidden indirection and/or run-time parameters
2965 in its representation. Its value is a DWARF operation expression E which
2966 computes the location description of the data for an object. When this
2967 attribute is omitted, the location description of the data is the same as
2968 the location description of the object.
2970 The result of the attribute is obtained by evaluating E with a context that
2971 has a result kind of a location description, an object that is the location
2972 description of the data descriptor, the compilation unit that contains E, an
2973 empty initial stack, and other context elements corresponding to the source
2974 language thread of execution upon which the user is focused, if any. The
2975 result of the evaluation is the location description of the base of the
2978 *E will typically involve an operation expression that begins with a*
2979 ``DW_OP_push_object_address`` *operation which loads the location
2980 description of the object which can then serve as a description in
2981 subsequent calculation.*
2985 Since ``DW_AT_data_member_location``, ``DW_AT_use_location``, and
2986 ``DW_AT_vtable_elem_location`` allow both operation expressions and
2987 location list expressions, why does ``DW_AT_data_location`` not allow
2988 both? In all cases they apply to data objects so less likely that
2989 optimization would cause different operation expressions for different
2990 program location ranges. But if supporting for some then should be for
2993 It seems odd this attribute is not the same as
2994 ``DW_AT_data_member_location`` in having an initial stack with the
2995 location description of the object since the expression has to need it.
2997 7. ``DW_AT_vtable_elem_location``
2999 An entry for a virtual function also has a ``DW_AT_vtable_elem_location``
3000 attribute whose value is a DWARF expression E.
3002 The result of the attribute is obtained by evaluating E with a context that
3003 has a result kind of a location description, an unspecified object, the
3004 compilation unit that contains E, an initial stack comprising the location
3005 description of the object of the enclosing type, and other context elements
3006 corresponding to the source language thread of execution upon which the user
3007 is focused, if any. The result of the evaluation is the location description
3008 of the slot for the function within the virtual function table for the
3011 8. ``DW_AT_static_link``
3013 If a ``DW_TAG_subprogram`` or ``DW_TAG_entry_point`` debugger information
3014 entry is lexically nested, it may have a ``DW_AT_static_link`` attribute,
3015 whose value is a DWARF expression E.
3017 The result of the attribute is obtained by evaluating E with a context that
3018 has a result kind of a location description, an unspecified object, the
3019 compilation unit that contains E, an empty initial stack, and other context
3020 elements corresponding to the source language thread of execution upon which
3021 the user is focused, if any. The result of the evaluation is the location
3022 description L of the *canonical frame address* (see
3023 :ref:`amdgpu-dwarf-call-frame-information`) of the relevant call frame of
3024 the subprogram instance that immediately lexically encloses the current call
3025 frame's subprogram or entry point.
3027 The DWARF is ill-formed if L is is not comprised of one memory location
3028 description for one of the target architecture specific address spaces.
3030 9. ``DW_AT_return_addr``
3032 A ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or
3033 ``DW_TAG_entry_point`` debugger information entry may have a
3034 ``DW_AT_return_addr`` attribute, whose value is a DWARF expression E.
3036 The result of the attribute is obtained by evaluating E with a context that
3037 has a result kind of a location description, an unspecified object, the
3038 compilation unit that contains E, an empty initial stack, and other context
3039 elements corresponding to the source language thread of execution upon which
3040 the user is focused, if any. The result of the evaluation is the location
3041 description L of the place where the return address for the current call
3042 frame's subprogram or entry point is stored.
3044 The DWARF is ill-formed if L is not comprised of one memory location
3045 description for one of the target architecture specific address spaces.
3049 It is unclear why ``DW_TAG_inlined_subroutine`` has a
3050 ``DW_AT_return_addr`` attribute but not a ``DW_AT_frame_base`` or
3051 ``DW_AT_static_link`` attribute. Seems it would either have all of them or
3052 none. Since inlined subprograms do not have a call frame it seems they
3053 would have none of these attributes.
3055 10. ``DW_AT_call_value``, ``DW_AT_call_data_location``, and
3056 ``DW_AT_call_data_value``
3058 A ``DW_TAG_call_site_parameter`` debugger information entry may have a
3059 ``DW_AT_call_value`` attribute, whose value is a DWARF operation expression
3062 The result of the ``DW_AT_call_value`` attribute is obtained by evaluating
3063 E\ :sub:`1` with a context that has a result kind of a value, an unspecified
3064 object, the compilation unit that contains E, an empty initial stack, and
3065 other context elements corresponding to the source language thread of
3066 execution upon which the user is focused, if any. The resulting value V\
3067 :sub:`1` is the value of the parameter at the time of the call made by the
3070 For parameters passed by reference, where the code passes a pointer to a
3071 location which contains the parameter, or for reference type parameters, the
3072 ``DW_TAG_call_site_parameter`` debugger information entry may also have a
3073 ``DW_AT_call_data_location`` attribute whose value is a DWARF operation
3074 expression E\ :sub:`2`\ , and a ``DW_AT_call_data_value`` attribute whose
3075 value is a DWARF operation expression E\ :sub:`3`\ .
3077 The value of the ``DW_AT_call_data_location`` attribute is obtained by
3078 evaluating E\ :sub:`2` with a context that has a result kind of a location
3079 description, an unspecified object, the compilation unit that contains E, an
3080 empty initial stack, and other context elements corresponding to the source
3081 language thread of execution upon which the user is focused, if any. The
3082 resulting location description L\ :sub:`2` is the location where the
3083 referenced parameter lives during the call made by the call site. If E\
3084 :sub:`2` would just be a ``DW_OP_push_object_address``, then the
3085 ``DW_AT_call_data_location`` attribute may be omitted.
3087 The value of the ``DW_AT_call_data_value`` attribute is obtained by
3088 evaluating E\ :sub:`3` with a context that has a result kind of a value, an
3089 unspecified object, the compilation unit that contains E, an empty initial
3090 stack, and other context elements corresponding to the source language
3091 thread of execution upon which the user is focused, if any. The resulting
3092 value V\ :sub:`3` is the value in L\ :sub:`2` at the time of the call made
3095 The result of these attributes is undefined if the current call frame is
3096 not for the subprogram containing the ``DW_TAG_call_site_parameter``
3097 debugger information entry or the current program location is not for the
3098 call site containing the ``DW_TAG_call_site_parameter`` debugger information
3099 entry in the current call frame.
3101 *The consumer may have to virtually unwind to the call site (see*
3102 :ref:`amdgpu-dwarf-call-frame-information`\ *) in order to evaluate these
3103 attributes. This will ensure the source language thread of execution upon
3104 which the user is focused corresponds to the call site needed to evaluate
3107 If it is not possible to avoid the expressions of these attributes from
3108 accessing registers or memory locations that might be clobbered by the
3109 subprogram being called by the call site, then the associated attribute
3110 should not be provided.
3112 *The reason for the restriction is that the parameter may need to be
3113 accessed during the execution of the callee. The consumer may virtually
3114 unwind from the called subprogram back to the caller and then evaluate the
3115 attribute expressions. The call frame information (see*
3116 :ref:`amdgpu-dwarf-call-frame-information`\ *) will not be able to restore
3117 registers that have been clobbered, and clobbered memory will no longer have
3118 the value at the time of the call.*
3120 11. ``DW_AT_LLVM_lanes`` *New*
3122 For languages that are implemented using a SIMD or SIMT execution model, a
3123 ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or
3124 ``DW_TAG_entry_point`` debugger information entry may have a
3125 ``DW_AT_LLVM_lanes`` attribute whose value is an integer constant that is
3126 the number of lanes per thread. This is the static number of lanes per
3127 thread. It is not the dynamic number of lanes with which the thread was
3128 initiated, for example, due to smaller or partial work-groups.
3130 If not present, the default value of 1 is used.
3132 The DWARF is ill-formed if the value is 0.
3134 12. ``DW_AT_LLVM_lane_pc`` *New*
3136 For languages that are implemented using a SIMD or SIMT execution model, a
3137 ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or
3138 ``DW_TAG_entry_point`` debugging information entry may have a
3139 ``DW_AT_LLVM_lane_pc`` attribute whose value is a DWARF expression E.
3141 The result of the attribute is obtained by evaluating E with a context that
3142 has a result kind of a location description, an unspecified object, the
3143 compilation unit that contains E, an empty initial stack, and other context
3144 elements corresponding to the source language thread of execution upon which
3145 the user is focused, if any.
3147 The resulting location description L is for a thread lane count sized vector
3148 of generic type elements. The thread lane count is the value of the
3149 ``DW_AT_LLVM_lanes`` attribute. Each element holds the conceptual program
3150 location of the corresponding lane, where the least significant element
3151 corresponds to the first target architecture specific lane identifier and so
3152 forth. If the lane was not active when the current subprogram was called,
3153 its element is an undefined location description.
3155 ``DW_AT_LLVM_lane_pc`` *allows the compiler to indicate conceptually where
3156 each lane of a SIMT thread is positioned even when it is in divergent
3157 control flow that is not active.*
3159 *Typically, the result is a location description with one composite location
3160 description with each part being a location description with either one
3161 undefined location description or one memory location description.*
3163 If not present, the thread is not being used in a SIMT manner, and the
3164 thread's current program location is used.
3166 13. ``DW_AT_LLVM_active_lane`` *New*
3168 For languages that are implemented using a SIMD or SIMT execution model, a
3169 ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or
3170 ``DW_TAG_entry_point`` debugger information entry may have a
3171 ``DW_AT_LLVM_active_lane`` attribute whose value is a DWARF expression E.
3173 The result of the attribute is obtained by evaluating E with a context that
3174 has a result kind of a value, an unspecified object, the compilation unit
3175 that contains E, an empty initial stack, and other context elements
3176 corresponding to the source language thread of execution upon which the user
3179 The DWARF is ill-formed if the resulting value V is not an integral value.
3181 The resulting V is a bit mask of active lanes for the current program
3182 location. The N\ :sup:`th` least significant bit of the mask corresponds to
3183 the N\ :sup:`th` lane. If the bit is 1 the lane is active, otherwise it is
3186 *Some targets may update the target architecture execution mask for regions
3187 of code that must execute with different sets of lanes than the current
3188 active lanes. For example, some code must execute with all lanes made
3189 temporarily active.* ``DW_AT_LLVM_active_lane`` *allows the compiler to
3190 provide the means to determine the source language active lanes.*
3192 If not present and ``DW_AT_LLVM_lanes`` is greater than 1, then the target
3193 architecture execution mask is used.
3195 14. ``DW_AT_LLVM_vector_size`` *New*
3197 A ``DW_TAG_base_type`` debugger information entry for a base type T may have
3198 a ``DW_AT_LLVM_vector_size`` attribute whose value is an integer constant
3199 that is the vector type size N.
3201 The representation of a vector base type is as N contiguous elements, each
3202 one having the representation of a base type T' that is the same as T
3203 without the ``DW_AT_LLVM_vector_size`` attribute.
3205 If a ``DW_TAG_base_type`` debugger information entry does not have a
3206 ``DW_AT_LLVM_vector_size`` attribute, then the base type is not a vector
3209 The DWARF is ill-formed if N is not greater than 0.
3213 LLVM has mention of a non-upstreamed debugger information entry that is
3214 intended to support vector types. However, that was not for a base type so
3215 would not be suitable as the type of a stack value entry. But perhaps that
3216 could be replaced by using this attribute.
3218 15. ``DW_AT_LLVM_augmentation`` *New*
3220 A ``DW_TAG_compile_unit`` debugger information entry for a compilation unit
3221 may have a ``DW_AT_LLVM_augmentation`` attribute, whose value is an
3222 augmentation string.
3224 *The augmentation string allows producers to indicate that there is
3225 additional vendor or target specific information in the debugging
3226 information entries. For example, this might be information about the
3227 version of vendor specific extensions that are being used.*
3229 If not present, or if the string is empty, then the compilation unit has no
3230 augmentation string.
3232 The format for the augmentation string is:
3234 | ``[``\ *vendor*\ ``:v``\ *X*\ ``.``\ *Y*\ [\ ``:``\ *options*\ ]\ ``]``\ *
3236 Where *vendor* is the producer, ``vX.Y`` specifies the major X and minor Y
3237 version number of the extensions used, and *options* is an optional string
3238 providing additional information about the extensions. The version number
3239 must conform to semantic versioning [:ref:`SEMVER <amdgpu-dwarf-SEMVER>`].
3240 The *options* string must not contain the "\ ``]``\ " character.
3246 [abc:v0.0][def:v1.2:feature-a=on,feature-b=3]
3248 Program Scope Entities
3249 ----------------------
3251 .. _amdgpu-dwarf-language-names:
3258 This augments DWARF Version 5 section 3.1.1 and Table 3.1.
3260 Additional language codes defined for use with the ``DW_AT_language`` attribute
3261 are defined in :ref:`amdgpu-dwarf-language-names-table`.
3263 .. table:: Language Names
3264 :name: amdgpu-dwarf-language-names-table
3266 ==================== =============================
3267 Language Name Meaning
3268 ==================== =============================
3269 ``DW_LANG_LLVM_HIP`` HIP Language.
3270 ==================== =============================
3272 The HIP language [:ref:`HIP <amdgpu-dwarf-HIP>`] can be supported by extending
3275 Other Debugger Information
3276 --------------------------
3281 .. _amdgpu-dwarf-lookup-by-name:
3286 Contents of the Name Index
3287 ##########################
3291 The following provides changes to DWARF Version 5 section 6.1.1.1.
3293 The rule for debugger information entries included in the name index in the
3294 optional ``.debug_names`` section is extended to also include named
3295 ``DW_TAG_variable`` debugging information entries with a ``DW_AT_location``
3296 attribute that includes a ``DW_OP_LLVM_form_aspace_address`` operation.
3298 The name index must contain an entry for each debugging information entry that
3299 defines a named subprogram, label, variable, type, or namespace, subject to the
3302 * ``DW_TAG_variable`` debugging information entries with a ``DW_AT_location``
3303 attribute that includes a ``DW_OP_addr``, ``DW_OP_LLVM_form_aspace_address``,
3304 or ``DW_OP_form_tls_address`` operation are included; otherwise, they are
3307 Data Representation of the Name Index
3308 #####################################
3315 The following provides an addition to DWARF Version 5 section 6.1.1.4.1 item
3316 14 ``augmentation_string``.
3318 A null-terminated UTF-8 vendor specific augmentation string, which provides
3319 additional information about the contents of this index. If provided, the
3320 recommended format for augmentation string is:
3322 | ``[``\ *vendor*\ ``:v``\ *X*\ ``.``\ *Y*\ [\ ``:``\ *options*\ ]\ ``]``\ *
3324 Where *vendor* is the producer, ``vX.Y`` specifies the major X and minor Y
3325 version number of the extensions used in the DWARF of the compilation unit, and
3326 *options* is an optional string providing additional information about the
3327 extensions. The version number must conform to semantic versioning [:ref:`SEMVER
3328 <amdgpu-dwarf-SEMVER>`]. The *options* string must not contain the "\ ``]``\ "
3335 [abc:v0.0][def:v1.2:feature-a=on,feature-b=3]
3339 This is different to the definition in DWARF Version 5 but is consistent with
3340 the other augmentation strings and allows multiple vendor extensions to be
3343 .. _amdgpu-dwarf-line-number-information:
3345 Line Number Information
3346 ~~~~~~~~~~~~~~~~~~~~~~~
3348 The Line Number Program Header
3349 ++++++++++++++++++++++++++++++
3351 Standard Content Descriptions
3352 #############################
3356 This augments DWARF Version 5 section 6.2.4.1.
3358 .. _amdgpu-dwarf-line-number-information-dw-lnct-llvm-source:
3360 1. ``DW_LNCT_LLVM_source``
3362 The component is a null-terminated UTF-8 source text string with "\ ``\n``\
3363 " line endings. This content code is paired with the same forms as
3364 ``DW_LNCT_path``. It can be used for file name entries.
3366 The value is an empty null-terminated string if no source is available. If
3367 the source is available but is an empty file then the value is a
3368 null-terminated single "\ ``\n``\ ".
3370 *When the source field is present, consumers can use the embedded source
3371 instead of attempting to discover the source on disk using the file path
3372 provided by the* ``DW_LNCT_path`` *field. When the source field is absent,
3373 consumers can access the file to get the source text.*
3375 *This is particularly useful for programming languages that support runtime
3376 compilation and runtime generation of source text. In these cases, the
3377 source text does not reside in any permanent file. For example, the OpenCL
3378 language [:ref:`OpenCL <amdgpu-dwarf-OpenCL>`] supports online compilation.*
3380 2. ``DW_LNCT_LLVM_is_MD5``
3382 ``DW_LNCT_LLVM_is_MD5`` indicates if the ``DW_LNCT_MD5`` content kind, if
3383 present, is valid: when 0 it is not valid and when 1 it is valid. If
3384 ``DW_LNCT_LLVM_is_MD5`` content kind is not present, and ``DW_LNCT_MD5``
3385 content kind is present, then the MD5 checksum is valid.
3387 ``DW_LNCT_LLVM_is_MD5`` is always paired with the ``DW_FORM_udata`` form.
3389 *This allows a compilation unit to have a mixture of files with and without
3390 MD5 checksums. This can happen when multiple relocatable files are linked
3393 .. _amdgpu-dwarf-call-frame-information:
3395 Call Frame Information
3396 ~~~~~~~~~~~~~~~~~~~~~~
3400 This section provides changes to existing call frame information and defines
3401 instructions added by these extensions. Additional support is added for
3402 address spaces. Register unwind DWARF expressions are generalized to allow any
3403 location description, including those with composite and implicit location
3406 These changes would be incorporated into the DWARF Version 5 section 6.1.
3408 .. _amdgpu-dwarf-structure_of-call-frame-information:
3410 Structure of Call Frame Information
3411 +++++++++++++++++++++++++++++++++++
3413 The register rules are:
3416 A register that has this rule has no recoverable value in the previous frame.
3417 The previous value of this register is the undefined location description (see
3418 :ref:`amdgpu-dwarf-undefined-location-description-operations`).
3420 *By convention, the register is not preserved by a callee.*
3423 This register has not been modified from the previous caller frame.
3425 If the current frame is the top frame, then the previous value of this
3426 register is the location description L that specifies one register location
3427 description SL. SL specifies the register location storage that corresponds to
3428 the register with a bit offset of 0 for the current thread.
3430 If the current frame is not the top frame, then the previous value of this
3431 register is the location description obtained using the call frame information
3432 for the callee frame and callee program location invoked by the current caller
3433 frame for the same register.
3435 *By convention, the register is preserved by the callee, but the callee has
3439 N is a signed byte offset. The previous value of this register is saved at the
3440 location description computed as if the DWARF operation expression
3441 ``DW_OP_LLVM_offset N`` is evaluated with the current context, except the
3442 result kind is a location description, the compilation unit is unspecified,
3443 the object is unspecified, and an initial stack comprising the location
3444 description of the current CFA (see
3445 :ref:`amdgpu-dwarf-operation-expressions`).
3448 N is a signed byte offset. The previous value of this register is the memory
3449 byte address of the location description computed as if the DWARF operation
3450 expression ``DW_OP_LLVM_offset N`` is evaluated with the current context,
3451 except the result kind is a location description, the compilation unit is
3452 unspecified, the object is unspecified, and an initial stack comprising the
3453 location description of the current CFA (see
3454 :ref:`amdgpu-dwarf-operation-expressions`).
3456 The DWARF is ill-formed if the CFA location description is not a memory byte
3457 address location description, or if the register size does not match the size
3458 of an address in the address space of the current CFA location description.
3460 *Since the CFA location description is required to be a memory byte address
3461 location description, the value of val_offset(N) will also be a memory byte
3462 address location description since it is offsetting the CFA location
3463 description by N bytes. Furthermore, the value of val_offset(N) will be a
3464 memory byte address in the same address space as the CFA location
3469 Should DWARF allow the address size to be a different size to the size of
3470 the register? Requiring them to be the same bit size avoids any issue of
3471 conversion as the bit contents of the register is simply interpreted as a
3472 value of the address.
3474 GDB has a per register hook that allows a target specific conversion on a
3475 register by register basis. It defaults to truncation of bigger registers,
3476 and to actually reading bytes from the next register (or reads out of bounds
3477 for the last register) for smaller registers. There are no GDB tests that
3478 read a register out of bounds (except an illegal hand written assembly
3482 This register has been stored in another register numbered R.
3484 The previous value of this register is the location description obtained using
3485 the call frame information for the current frame and current program location
3488 The DWARF is ill-formed if the size of this register does not match the size
3489 of register R or if there is a cyclic dependency in the call frame
3494 Should this also allow R to be larger than this register? If so is the value
3495 stored in the low order bits and it is undefined what is stored in the
3499 The previous value of this register is located at the location description
3500 produced by evaluating the DWARF operation expression E (see
3501 :ref:`amdgpu-dwarf-operation-expressions`).
3503 E is evaluated with the current context, except the result kind is a location
3504 description, the compilation unit is unspecified, the object is unspecified,
3505 and an initial stack comprising the location description of the current CFA
3506 (see :ref:`amdgpu-dwarf-operation-expressions`).
3509 The previous value of this register is the value produced by evaluating the
3510 DWARF operation expression E (see :ref:`amdgpu-dwarf-operation-expressions`).
3512 E is evaluated with the current context, except the result kind is a value,
3513 the compilation unit is unspecified, the object is unspecified, and an initial
3514 stack comprising the location description of the current CFA (see
3515 :ref:`amdgpu-dwarf-operation-expressions`).
3517 The DWARF is ill-formed if the resulting value type size does not match the
3522 This has limited usefulness as the DWARF expression E can only produce
3523 values up to the size of the generic type. This is due to not allowing any
3524 operations that specify a type in a CFI operation expression. This makes it
3525 unusable for registers that are larger than the generic type. However,
3526 *expression(E)* can be used to create an implicit location description of
3530 The rule is defined externally to this specification by the augmenter.
3532 A Common Information Entry (CIE) holds information that is shared among many
3533 Frame Description Entries (FDE). There is at least one CIE in every non-empty
3534 ``.debug_frame`` section. A CIE contains the following fields, in order:
3536 1. ``length`` (initial length)
3538 A constant that gives the number of bytes of the CIE structure, not
3539 including the length field itself. The size of the length field plus the
3540 value of length must be an integral multiple of the address size specified
3541 in the ``address_size`` field.
3543 2. ``CIE_id`` (4 or 8 bytes, see
3544 :ref:`amdgpu-dwarf-32-bit-and-64-bit-dwarf-formats`)
3546 A constant that is used to distinguish CIEs from FDEs.
3548 In the 32-bit DWARF format, the value of the CIE id in the CIE header is
3549 0xffffffff; in the 64-bit DWARF format, the value is 0xffffffffffffffff.
3551 3. ``version`` (ubyte)
3553 A version number. This number is specific to the call frame information and
3554 is independent of the DWARF version number.
3556 The value of the CIE version number is 4.
3560 Would this be increased to 5 to reflect the changes in these extensions?
3562 4. ``augmentation`` (sequence of UTF-8 characters)
3564 A null-terminated UTF-8 string that identifies the augmentation to this CIE
3565 or to the FDEs that use it. If a reader encounters an augmentation string
3566 that is unexpected, then only the following fields can be read:
3568 * CIE: length, CIE_id, version, augmentation
3569 * FDE: length, CIE_pointer, initial_location, address_range
3571 If there is no augmentation, this value is a zero byte.
3573 *The augmentation string allows users to indicate that there is additional
3574 vendor and target architecture specific information in the CIE or FDE which
3575 is needed to virtually unwind a stack frame. For example, this might be
3576 information about dynamically allocated data which needs to be freed on exit
3579 *Because the* ``.debug_frame`` *section is useful independently of any*
3580 ``.debug_info`` *section, the augmentation string always uses UTF-8
3583 The recommended format for the augmentation string is:
3585 | ``[``\ *vendor*\ ``:v``\ *X*\ ``.``\ *Y*\ [\ ``:``\ *options*\ ]\ ``]``\ *
3587 Where *vendor* is the producer, ``vX.Y`` specifies the major X and minor Y
3588 version number of the extensions used, and *options* is an optional string
3589 providing additional information about the extensions. The version number
3590 must conform to semantic versioning [:ref:`SEMVER <amdgpu-dwarf-SEMVER>`].
3591 The *options* string must not contain the "\ ``]``\ " character.
3597 [abc:v0.0][def:v1.2:feature-a=on,feature-b=3]
3599 5. ``address_size`` (ubyte)
3601 The size of a target address in this CIE and any FDEs that use it, in bytes.
3602 If a compilation unit exists for this frame, its address size must match the
3605 6. ``segment_selector_size`` (ubyte)
3607 The size of a segment selector in this CIE and any FDEs that use it, in
3610 7. ``code_alignment_factor`` (unsigned LEB128)
3612 A constant that is factored out of all advance location instructions (see
3613 :ref:`amdgpu-dwarf-row-creation-instructions`). The resulting value is
3614 ``(operand * code_alignment_factor)``.
3616 8. ``data_alignment_factor`` (signed LEB128)
3618 A constant that is factored out of certain offset instructions (see
3619 :ref:`amdgpu-dwarf-cfa-definition-instructions` and
3620 :ref:`amdgpu-dwarf-register-rule-instructions`). The resulting value is
3621 ``(operand * data_alignment_factor)``.
3623 9. ``return_address_register`` (unsigned LEB128)
3625 An unsigned LEB128 constant that indicates which column in the rule table
3626 represents the return address of the subprogram. Note that this column might
3627 not correspond to an actual machine register.
3629 The value of the return address register is used to determine the program
3630 location of the caller frame. The program location of the top frame is the
3631 target architecture program counter value of the current thread.
3633 10. ``initial_instructions`` (array of ubyte)
3635 A sequence of rules that are interpreted to create the initial setting of
3636 each column in the table.
3638 The default rule for all columns before interpretation of the initial
3639 instructions is the undefined rule. However, an ABI authoring body or a
3640 compilation system authoring body may specify an alternate default value for
3643 11. ``padding`` (array of ubyte)
3645 Enough ``DW_CFA_nop`` instructions to make the size of this entry match the
3648 An FDE contains the following fields, in order:
3650 1. ``length`` (initial length)
3652 A constant that gives the number of bytes of the header and instruction
3653 stream for this subprogram, not including the length field itself. The size
3654 of the length field plus the value of length must be an integral multiple of
3657 2. ``CIE_pointer`` (4 or 8 bytes, see
3658 :ref:`amdgpu-dwarf-32-bit-and-64-bit-dwarf-formats`)
3660 A constant offset into the ``.debug_frame`` section that denotes the CIE
3661 that is associated with this FDE.
3663 3. ``initial_location`` (segment selector and target address)
3665 The address of the first location associated with this table entry. If the
3666 segment_selector_size field of this FDE’s CIE is non-zero, the initial
3667 location is preceded by a segment selector of the given length.
3669 4. ``address_range`` (target address)
3671 The number of bytes of program instructions described by this entry.
3673 5. ``instructions`` (array of ubyte)
3675 A sequence of table defining instructions that are described in
3676 :ref:`amdgpu-dwarf-call-frame-instructions`.
3678 6. ``padding`` (array of ubyte)
3680 Enough ``DW_CFA_nop`` instructions to make the size of this entry match the
3683 .. _amdgpu-dwarf-call-frame-instructions:
3685 Call Frame Instructions
3686 +++++++++++++++++++++++
3688 Some call frame instructions have operands that are encoded as DWARF operation
3689 expressions E (see :ref:`amdgpu-dwarf-operation-expressions`). The DWARF
3690 operations that can be used in E have the following restrictions:
3692 * ``DW_OP_addrx``, ``DW_OP_call2``, ``DW_OP_call4``, ``DW_OP_call_ref``,
3693 ``DW_OP_const_type``, ``DW_OP_constx``, ``DW_OP_convert``,
3694 ``DW_OP_deref_type``, ``DW_OP_fbreg``, ``DW_OP_implicit_pointer``,
3695 ``DW_OP_regval_type``, ``DW_OP_reinterpret``, and ``DW_OP_xderef_type``
3696 operations are not allowed because the call frame information must not depend
3697 on other debug sections.
3699 * ``DW_OP_push_object_address`` is not allowed because there is no object
3700 context to provide a value to push.
3702 * ``DW_OP_LLVM_push_lane`` is not allowed because the call frame instructions
3703 describe the actions for the whole thread, not the lanes independently.
3705 * ``DW_OP_call_frame_cfa`` and ``DW_OP_entry_value`` are not allowed because
3706 their use would be circular.
3708 * ``DW_OP_LLVM_call_frame_entry_reg`` is not allowed if evaluating E causes a
3709 circular dependency between ``DW_OP_LLVM_call_frame_entry_reg`` operations.
3711 *For example, if a register R1 has a* ``DW_CFA_def_cfa_expression``
3712 *instruction that evaluates a* ``DW_OP_LLVM_call_frame_entry_reg`` *operation
3713 that specifies register R2, and register R2 has a*
3714 ``DW_CFA_def_cfa_expression`` *instruction that that evaluates a*
3715 ``DW_OP_LLVM_call_frame_entry_reg`` *operation that specifies register R1.*
3717 *Call frame instructions to which these restrictions apply include*
3718 ``DW_CFA_def_cfa_expression``\ *,* ``DW_CFA_expression``\ *, and*
3719 ``DW_CFA_val_expression``\ *.*
3721 .. _amdgpu-dwarf-row-creation-instructions:
3723 Row Creation Instructions
3724 #########################
3728 These instructions are the same as in DWARF Version 5 section 6.4.2.1.
3730 .. _amdgpu-dwarf-cfa-definition-instructions:
3732 CFA Definition Instructions
3733 ###########################
3735 1. ``DW_CFA_def_cfa``
3737 The ``DW_CFA_def_cfa`` instruction takes two unsigned LEB128 operands
3738 representing a register number R and a (non-factored) byte displacement B.
3739 AS is set to the target architecture default address space identifier. The
3740 required action is to define the current CFA rule to be the result of
3741 evaluating the DWARF operation expression ``DW_OP_constu AS;
3742 DW_OP_aspace_bregx R, B`` as a location description.
3744 2. ``DW_CFA_def_cfa_sf``
3746 The ``DW_CFA_def_cfa_sf`` instruction takes two operands: an unsigned LEB128
3747 value representing a register number R and a signed LEB128 factored byte
3748 displacement B. AS is set to the target architecture default address space
3749 identifier. The required action is to define the current CFA rule to be the
3750 result of evaluating the DWARF operation expression ``DW_OP_constu AS;
3751 DW_OP_aspace_bregx R, B*data_alignment_factor`` as a location description.
3753 *The action is the same as* ``DW_CFA_def_cfa``\ *, except that the second
3754 operand is signed and factored.*
3756 3. ``DW_CFA_LLVM_def_aspace_cfa`` *New*
3758 The ``DW_CFA_LLVM_def_aspace_cfa`` instruction takes three unsigned LEB128
3759 operands representing a register number R, a (non-factored) byte
3760 displacement B, and a target architecture specific address space identifier
3761 AS. The required action is to define the current CFA rule to be the result
3762 of evaluating the DWARF operation expression ``DW_OP_constu AS;
3763 DW_OP_aspace_bregx R, B`` as a location description.
3765 If AS is not one of the values defined by the target architecture specific
3766 ``DW_ASPACE_*`` values then the DWARF expression is ill-formed.
3768 4. ``DW_CFA_LLVM_def_aspace_cfa_sf`` *New*
3770 The ``DW_CFA_def_cfa_sf`` instruction takes three operands: an unsigned
3771 LEB128 value representing a register number R, a signed LEB128 factored byte
3772 displacement B, and an unsigned LEB128 value representing a target
3773 architecture specific address space identifier AS. The required action is to
3774 define the current CFA rule to be the result of evaluating the DWARF
3775 operation expression ``DW_OP_constu AS; DW_OP_aspace_bregx R,
3776 B*data_alignment_factor`` as a location description.
3778 If AS is not one of the values defined by the target architecture specific
3779 ``DW_ASPACE_*`` values, then the DWARF expression is ill-formed.
3781 *The action is the same as* ``DW_CFA_aspace_def_cfa``\ *, except that the
3782 second operand is signed and factored.*
3784 5. ``DW_CFA_def_cfa_register``
3786 The ``DW_CFA_def_cfa_register`` instruction takes a single unsigned LEB128
3787 operand representing a register number R. The required action is to define
3788 the current CFA rule to be the result of evaluating the DWARF operation
3789 expression ``DW_OP_constu AS; DW_OP_aspace_bregx R, B`` as a location
3790 description. B and AS are the old CFA byte displacement and address space
3793 If the subprogram has no current CFA rule, or the rule was defined by a
3794 ``DW_CFA_def_cfa_expression`` instruction, then the DWARF is ill-formed.
3796 6. ``DW_CFA_def_cfa_offset``
3798 The ``DW_CFA_def_cfa_offset`` instruction takes a single unsigned LEB128
3799 operand representing a (non-factored) byte displacement B. The required
3800 action is to define the current CFA rule to be the result of evaluating the
3801 DWARF operation expression ``DW_OP_constu AS; DW_OP_aspace_bregx R, B`` as a
3802 location description. R and AS are the old CFA register number and address
3805 If the subprogram has no current CFA rule, or the rule was defined by a
3806 ``DW_CFA_def_cfa_expression`` instruction, then the DWARF is ill-formed.
3808 7. ``DW_CFA_def_cfa_offset_sf``
3810 The ``DW_CFA_def_cfa_offset_sf`` instruction takes a signed LEB128 operand
3811 representing a factored byte displacement B. The required action is to
3812 define the current CFA rule to be the result of evaluating the DWARF
3813 operation expression ``DW_OP_constu AS; DW_OP_aspace_bregx R,
3814 B*data_alignment_factor`` as a location description. R and AS are the old
3815 CFA register number and address space respectively.
3817 If the subprogram has no current CFA rule, or the rule was defined by a
3818 ``DW_CFA_def_cfa_expression`` instruction, then the DWARF is ill-formed.
3820 *The action is the same as* ``DW_CFA_def_cfa_offset``\ *, except that the
3821 operand is signed and factored.*
3823 8. ``DW_CFA_def_cfa_expression``
3825 The ``DW_CFA_def_cfa_expression`` instruction takes a single operand encoded
3826 as a ``DW_FORM_exprloc`` value representing a DWARF operation expression E.
3827 The required action is to define the current CFA rule to be the result of
3828 evaluating E with the current context, except the result kind is a location
3829 description, the compilation unit is unspecified, the object is unspecified,
3830 and an empty initial stack.
3832 *See* :ref:`amdgpu-dwarf-call-frame-instructions` *regarding restrictions on
3833 the DWARF expression operations that can be used in E.*
3835 The DWARF is ill-formed if the result of evaluating E is not a memory byte
3836 address location description.
3838 .. _amdgpu-dwarf-register-rule-instructions:
3840 Register Rule Instructions
3841 ##########################
3843 1. ``DW_CFA_undefined``
3845 The ``DW_CFA_undefined`` instruction takes a single unsigned LEB128 operand
3846 that represents a register number R. The required action is to set the rule
3847 for the register specified by R to ``undefined``.
3849 2. ``DW_CFA_same_value``
3851 The ``DW_CFA_same_value`` instruction takes a single unsigned LEB128 operand
3852 that represents a register number R. The required action is to set the rule
3853 for the register specified by R to ``same value``.
3855 3. ``DW_CFA_offset``
3857 The ``DW_CFA_offset`` instruction takes two operands: a register number R
3858 (encoded with the opcode) and an unsigned LEB128 constant representing a
3859 factored displacement B. The required action is to change the rule for the
3860 register specified by R to be an *offset(B\*data_alignment_factor)* rule.
3864 Seems this should be named ``DW_CFA_offset_uf`` since the offset is
3867 4. ``DW_CFA_offset_extended``
3869 The ``DW_CFA_offset_extended`` instruction takes two unsigned LEB128
3870 operands representing a register number R and a factored displacement B.
3871 This instruction is identical to ``DW_CFA_offset``, except for the encoding
3872 and size of the register operand.
3876 Seems this should be named ``DW_CFA_offset_extended_uf`` since the
3877 displacement is unsigned factored.
3879 5. ``DW_CFA_offset_extended_sf``
3881 The ``DW_CFA_offset_extended_sf`` instruction takes two operands: an
3882 unsigned LEB128 value representing a register number R and a signed LEB128
3883 factored displacement B. This instruction is identical to
3884 ``DW_CFA_offset_extended``, except that B is signed.
3886 6. ``DW_CFA_val_offset``
3888 The ``DW_CFA_val_offset`` instruction takes two unsigned LEB128 operands
3889 representing a register number R and a factored displacement B. The required
3890 action is to change the rule for the register indicated by R to be a
3891 *val_offset(B\*data_alignment_factor)* rule.
3895 Seems this should be named ``DW_CFA_val_offset_uf`` since the displacement
3896 is unsigned factored.
3900 An alternative is to define ``DW_CFA_val_offset`` to implicitly use the
3901 target architecture default address space, and add another operation that
3902 specifies the address space.
3904 7. ``DW_CFA_val_offset_sf``
3906 The ``DW_CFA_val_offset_sf`` instruction takes two operands: an unsigned
3907 LEB128 value representing a register number R and a signed LEB128 factored
3908 displacement B. This instruction is identical to ``DW_CFA_val_offset``,
3909 except that B is signed.
3911 8. ``DW_CFA_register``
3913 The ``DW_CFA_register`` instruction takes two unsigned LEB128 operands
3914 representing register numbers R1 and R2 respectively. The required action is
3915 to set the rule for the register specified by R1 to be a *register(R2)* rule.
3917 9. ``DW_CFA_expression``
3919 The ``DW_CFA_expression`` instruction takes two operands: an unsigned LEB128
3920 value representing a register number R, and a ``DW_FORM_block`` value
3921 representing a DWARF operation expression E. The required action is to
3922 change the rule for the register specified by R to be an *expression(E)*
3925 *That is, E computes the location description where the register value can
3928 *See* :ref:`amdgpu-dwarf-call-frame-instructions` *regarding restrictions on
3929 the DWARF expression operations that can be used in E.*
3931 10. ``DW_CFA_val_expression``
3933 The ``DW_CFA_val_expression`` instruction takes two operands: an unsigned
3934 LEB128 value representing a register number R, and a ``DW_FORM_block`` value
3935 representing a DWARF operation expression E. The required action is to
3936 change the rule for the register specified by R to be a *val_expression(E)*
3939 *That is, E computes the value of register R.*
3941 *See* :ref:`amdgpu-dwarf-call-frame-instructions` *regarding restrictions on
3942 the DWARF expression operations that can be used in E.*
3944 If the result of evaluating E is not a value with a base type size that
3945 matches the register size, then the DWARF is ill-formed.
3947 11. ``DW_CFA_restore``
3949 The ``DW_CFA_restore`` instruction takes a single operand (encoded with the
3950 opcode) that represents a register number R. The required action is to
3951 change the rule for the register specified by R to the rule assigned it by
3952 the ``initial_instructions`` in the CIE.
3954 12. ``DW_CFA_restore_extended``
3956 The ``DW_CFA_restore_extended`` instruction takes a single unsigned LEB128
3957 operand that represents a register number R. This instruction is identical
3958 to ``DW_CFA_restore``, except for the encoding and size of the register
3961 Row State Instructions
3962 ######################
3966 These instructions are the same as in DWARF Version 5 section 6.4.2.4.
3973 These instructions are the same as in DWARF Version 5 section 6.4.2.5.
3975 Call Frame Instruction Usage
3976 ++++++++++++++++++++++++++++
3980 The same as in DWARF Version 5 section 6.4.3.
3982 .. _amdgpu-dwarf-call-frame-calling-address:
3984 Call Frame Calling Address
3985 ++++++++++++++++++++++++++
3989 The same as in DWARF Version 5 section 6.4.4.
3994 .. _amdgpu-dwarf-32-bit-and-64-bit-dwarf-formats:
3996 32-Bit and 64-Bit DWARF Formats
3997 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4001 This augments DWARF Version 5 section 7.4.
4003 1. Within the body of the ``.debug_info`` section, certain forms of attribute
4004 value depend on the choice of DWARF format as follows. For the 32-bit DWARF
4005 format, the value is a 4-byte unsigned integer; for the 64-bit DWARF format,
4006 the value is an 8-byte unsigned integer.
4008 .. table:: ``.debug_info`` section attribute form roles
4009 :name: amdgpu-dwarf-debug-info-section-attribute-form-roles-table
4011 ================================== ===================================
4013 ================================== ===================================
4014 DW_FORM_line_strp offset in ``.debug_line_str``
4015 DW_FORM_ref_addr offset in ``.debug_info``
4016 DW_FORM_sec_offset offset in a section other than
4017 ``.debug_info`` or ``.debug_str``
4018 DW_FORM_strp offset in ``.debug_str``
4019 DW_FORM_strp_sup offset in ``.debug_str`` section of
4020 supplementary object file
4021 DW_OP_call_ref offset in ``.debug_info``
4022 DW_OP_implicit_pointer offset in ``.debug_info``
4023 DW_OP_LLVM_aspace_implicit_pointer offset in ``.debug_info``
4024 ================================== ===================================
4026 Format of Debugging Information
4027 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4034 This augments DWARF Version 5 section 7.5.4 and Table 7.5.
4036 The following table gives the encoding of the additional debugging information
4039 .. table:: Attribute encodings
4040 :name: amdgpu-dwarf-attribute-encodings-table
4042 ================================== ====== ===================================
4043 Attribute Name Value Classes
4044 ================================== ====== ===================================
4045 DW_AT_LLVM_active_lane 0x3e08 exprloc, loclist
4046 DW_AT_LLVM_augmentation 0x3e09 string
4047 DW_AT_LLVM_lanes 0x3e0a constant
4048 DW_AT_LLVM_lane_pc 0x3e0b exprloc, loclist
4049 DW_AT_LLVM_vector_size 0x3e0c constant
4050 ================================== ====== ===================================
4057 Rename DWARF Version 5 section 7.7 to reflect the unification of location
4058 descriptions into DWARF expressions.
4060 Operation Expressions
4061 +++++++++++++++++++++
4065 Rename DWARF Version 5 section 7.7.1 and delete section 7.7.2 to reflect the
4066 unification of location descriptions into DWARF expressions.
4068 This augments DWARF Version 5 section 7.7.1 and Table 7.9.
4070 The following table gives the encoding of the additional DWARF expression
4073 .. table:: DWARF Operation Encodings
4074 :name: amdgpu-dwarf-operation-encodings-table
4076 ================================== ===== ======== ===============================
4077 Operation Code Number Notes
4080 ================================== ===== ======== ===============================
4081 DW_OP_LLVM_form_aspace_address 0xe1 0
4082 DW_OP_LLVM_push_lane 0xe2 0
4083 DW_OP_LLVM_offset 0xe3 0
4084 DW_OP_LLVM_offset_uconst 0xe4 1 ULEB128 byte displacement
4085 DW_OP_LLVM_bit_offset 0xe5 0
4086 DW_OP_LLVM_call_frame_entry_reg 0xe6 1 ULEB128 register number
4087 DW_OP_LLVM_undefined 0xe7 0
4088 DW_OP_LLVM_aspace_bregx 0xe8 2 ULEB128 register number,
4089 ULEB128 byte displacement
4090 DW_OP_LLVM_aspace_implicit_pointer 0xe9 2 4-byte or 8-byte offset of DIE,
4091 SLEB128 byte displacement
4092 DW_OP_LLVM_piece_end 0xea 0
4093 DW_OP_LLVM_extend 0xeb 2 ULEB128 bit size,
4095 DW_OP_LLVM_select_bit_piece 0xec 2 ULEB128 bit size,
4097 ================================== ===== ======== ===============================
4099 Location List Expressions
4100 +++++++++++++++++++++++++
4104 Rename DWARF Version 5 section 7.7.3 to reflect that location lists are a kind
4105 of DWARF expression.
4112 This augments DWARF Version 5 section 7.12 and Table 7.17.
4114 The following table gives the encoding of the additional DWARF languages.
4116 .. table:: Language encodings
4117 :name: amdgpu-dwarf-language-encodings-table
4119 ==================== ====== ===================
4120 Language Name Value Default Lower Bound
4121 ==================== ====== ===================
4122 ``DW_LANG_LLVM_HIP`` 0x8100 0
4123 ==================== ====== ===================
4125 Address Class and Address Space Encodings
4126 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4130 This replaces DWARF Version 5 section 7.13.
4132 The encodings of the constants used for the currently defined address classes
4133 are given in :ref:`amdgpu-dwarf-address-class-encodings-table`.
4135 .. table:: Address class encodings
4136 :name: amdgpu-dwarf-address-class-encodings-table
4138 ========================== ======
4139 Address Class Name Value
4140 ========================== ======
4141 ``DW_ADDR_none`` 0x0000
4142 ``DW_ADDR_LLVM_global`` 0x0001
4143 ``DW_ADDR_LLVM_constant`` 0x0002
4144 ``DW_ADDR_LLVM_group`` 0x0003
4145 ``DW_ADDR_LLVM_private`` 0x0004
4146 ``DW_ADDR_LLVM_lo_user`` 0x8000
4147 ``DW_ADDR_LLVM_hi_user`` 0xffff
4148 ========================== ======
4150 Line Number Information
4151 ~~~~~~~~~~~~~~~~~~~~~~~
4155 This augments DWARF Version 5 section 7.22 and Table 7.27.
4157 The following table gives the encoding of the additional line number header
4160 .. table:: Line number header entry format encodings
4161 :name: amdgpu-dwarf-line-number-header-entry-format-encodings-table
4163 ==================================== ====================
4164 Line number header entry format name Value
4165 ==================================== ====================
4166 ``DW_LNCT_LLVM_source`` 0x2001
4167 ``DW_LNCT_LLVM_is_MD5`` 0x2002
4168 ==================================== ====================
4170 Call Frame Information
4171 ~~~~~~~~~~~~~~~~~~~~~~
4175 This augments DWARF Version 5 section 7.24 and Table 7.29.
4177 The following table gives the encoding of the additional call frame information
4180 .. table:: Call frame instruction encodings
4181 :name: amdgpu-dwarf-call-frame-instruction-encodings-table
4183 ============================= ====== ====== ================ ================ =====================
4184 Instruction High 2 Low 6 Operand 1 Operand 2 Operand 3
4186 ============================= ====== ====== ================ ================ =====================
4187 DW_CFA_LLVM_def_aspace_cfa 0 0x30 ULEB128 register ULEB128 offset ULEB128 address space
4188 DW_CFA_LLVM_def_aspace_cfa_sf 0 0x31 ULEB128 register SLEB128 offset ULEB128 address space
4189 ============================= ====== ====== ================ ================ =====================
4191 Attributes by Tag Value (Informative)
4192 -------------------------------------
4196 This augments DWARF Version 5 Appendix A and Table A.1.
4198 The following table provides the additional attributes that are applicable to
4199 debugger information entries.
4201 .. table:: Attributes by tag value
4202 :name: amdgpu-dwarf-attributes-by-tag-value-table
4204 ============================= =============================
4205 Tag Name Applicable Attributes
4206 ============================= =============================
4207 ``DW_TAG_base_type`` * ``DW_AT_LLVM_vector_size``
4208 ``DW_TAG_compile_unit`` * ``DW_AT_LLVM_augmentation``
4209 ``DW_TAG_entry_point`` * ``DW_AT_LLVM_active_lane``
4210 * ``DW_AT_LLVM_lane_pc``
4211 * ``DW_AT_LLVM_lanes``
4212 ``DW_TAG_inlined_subroutine`` * ``DW_AT_LLVM_active_lane``
4213 * ``DW_AT_LLVM_lane_pc``
4214 * ``DW_AT_LLVM_lanes``
4215 ``DW_TAG_subprogram`` * ``DW_AT_LLVM_active_lane``
4216 * ``DW_AT_LLVM_lane_pc``
4217 * ``DW_AT_LLVM_lanes``
4218 ============================= =============================
4220 .. _amdgpu-dwarf-examples:
4225 The AMD GPU specific usage of the features in these extensions, including
4226 examples, is available at *User Guide for AMDGPU Backend* section
4227 :ref:`amdgpu-dwarf-debug-information`.
4231 Change examples to use ``DW_OP_LLVM_offset`` instead of ``DW_OP_add`` when
4232 acting on a location description.
4234 Need to provide examples of new features.
4236 .. _amdgpu-dwarf-references:
4241 .. _amdgpu-dwarf-AMD:
4243 1. [AMD] `Advanced Micro Devices <https://www.amd.com/>`__
4245 .. _amdgpu-dwarf-AMD-ROCm:
4247 2. [AMD-ROCm] `AMD ROCm Platform <https://rocm-documentation.readthedocs.io>`__
4249 .. _amdgpu-dwarf-AMD-ROCgdb:
4251 3. [AMD-ROCgdb] `AMD ROCm Debugger (ROCgdb) <https://github.com/ROCm-Developer-Tools/ROCgdb>`__
4253 .. _amdgpu-dwarf-AMDGPU-LLVM:
4255 4. [AMDGPU-LLVM] `User Guide for AMDGPU LLVM Backend <https://llvm.org/docs/AMDGPUUsage.html>`__
4257 .. _amdgpu-dwarf-CUDA:
4259 5. [CUDA] `Nvidia CUDA Language <https://docs.nvidia.com/cuda/cuda-c-programming-guide/>`__
4261 .. _amdgpu-dwarf-DWARF:
4263 6. [DWARF] `DWARF Debugging Information Format <http://dwarfstd.org/>`__
4265 .. _amdgpu-dwarf-ELF:
4267 7. [ELF] `Executable and Linkable Format (ELF) <http://www.sco.com/developers/gabi/>`__
4269 .. _amdgpu-dwarf-GCC:
4271 8. [GCC] `GCC: The GNU Compiler Collection <https://www.gnu.org/software/gcc/>`__
4273 .. _amdgpu-dwarf-GDB:
4275 9. [GDB] `GDB: The GNU Project Debugger <https://www.gnu.org/software/gdb/>`__
4277 .. _amdgpu-dwarf-HIP:
4279 10. [HIP] `HIP Programming Guide <https://rocm-documentation.readthedocs.io/en/latest/Programming_Guides/Programming-Guides.html#hip-programing-guide>`__
4281 .. _amdgpu-dwarf-HSA:
4283 11. [HSA] `Heterogeneous System Architecture (HSA) Foundation <http://www.hsafoundation.com/>`__
4285 .. _amdgpu-dwarf-LLVM:
4287 12. [LLVM] `The LLVM Compiler Infrastructure <https://llvm.org/>`__
4289 .. _amdgpu-dwarf-OpenCL:
4291 13. [OpenCL] `The OpenCL Specification Version 2.0 <http://www.khronos.org/registry/cl/specs/opencl-2.0.pdf>`__
4293 .. _amdgpu-dwarf-Perforce-TotalView:
4295 14. [Perforce-TotalView] `Perforce TotalView HPC Debugging Software <https://totalview.io/products/totalview>`__
4297 .. _amdgpu-dwarf-SEMVER:
4299 15. [SEMVER] `Semantic Versioning <https://semver.org/>`__