1e24f5f31STony.. _amdgpu-dwarf-extensions-for-heterogeneous-debugging: 2e24f5f31STony 3e24f5f31STony******************************************** 4e24f5f31STonyDWARF Extensions For Heterogeneous Debugging 5e24f5f31STony******************************************** 6e24f5f31STony 7e24f5f31STony.. contents:: 8e24f5f31STony :local: 9e24f5f31STony 10e24f5f31STony.. warning:: 11e24f5f31STony 12e24f5f31STony This document describes **provisional extensions** to DWARF Version 5 13e24f5f31STony [:ref:`DWARF <amdgpu-dwarf-DWARF>`] to support heterogeneous debugging. It is 14e24f5f31STony not currently fully implemented and is subject to change. 15e24f5f31STony 16e24f5f31STony.. _amdgpu-dwarf-introduction: 17e24f5f31STony 180ac939f3STony Tye1. Introduction 190ac939f3STony Tye=============== 20e24f5f31STony 21e24f5f31STonyAMD [:ref:`AMD <amdgpu-dwarf-AMD>`] has been working on supporting heterogeneous 220ac939f3STony Tyecomputing. A heterogeneous computing program can be written in a high level 230ac939f3STony Tyelanguage such as C++ or Fortran with OpenMP pragmas, OpenCL, or HIP (a portable 240ac939f3STony TyeC++ programming environment for heterogeneous computing [:ref:`HIP 25e24f5f31STony<amdgpu-dwarf-HIP>`]). A heterogeneous compiler and runtime allows a program to 26e24f5f31STonyexecute on multiple devices within the same native process. Devices could 27e24f5f31STonyinclude CPUs, GPUs, DSPs, FPGAs, or other special purpose accelerators. 28e24f5f31STonyCurrently HIP programs execute on systems with CPUs and GPUs. 29e24f5f31STony 300ac939f3STony TyeThe AMD [:ref:`AMD <amdgpu-dwarf-AMD>`] ROCm platform [:ref:`AMD-ROCm 310ac939f3STony Tye<amdgpu-dwarf-AMD-ROCm>`] is an implementation of the industry standard for 320ac939f3STony Tyeheterogeneous computing devices defined by the Heterogeneous System Architecture 330ac939f3STony Tye(HSA) Foundation [:ref:`HSA <amdgpu-dwarf-HSA>`]. It is open sourced and 340ac939f3STony Tyeincludes contributions to open source projects such as LLVM [:ref:`LLVM 350ac939f3STony Tye<amdgpu-dwarf-LLVM>`] for compilation and GDB for debugging [:ref:`GDB 360ac939f3STony Tye<amdgpu-dwarf-GDB>`]. 370ac939f3STony Tye 380ac939f3STony TyeThe LLVM compiler has upstream support for commercially available AMD GPU 390ac939f3STony Tyehardware (AMDGPU) [:ref:`AMDGPU-LLVM <amdgpu-dwarf-AMDGPU-LLVM>`]. The open 400ac939f3STony Tyesource ROCgdb [:ref:`AMD-ROCgdb <amdgpu-dwarf-AMD-ROCgdb>`] GDB based debugger 410ac939f3STony Tyealso has support for AMDGPU which is being upstreamed. Support for AMDGPU is 420ac939f3STony Tyealso being added by third parties to the GCC [:ref:`GCC <amdgpu-dwarf-GCC>`] 430ac939f3STony Tyecompiler and the Perforce TotalView HPC Debugger [:ref:`Perforce-TotalView 44e24f5f31STony<amdgpu-dwarf-Perforce-TotalView>`]. 45e24f5f31STony 46e24f5f31STonyTo support debugging heterogeneous programs several features that are not 47e24f5f31STonyprovided by current DWARF Version 5 [:ref:`DWARF <amdgpu-dwarf-DWARF>`] have 480ac939f3STony Tyebeen identified. The :ref:`amdgpu-dwarf-extensions` section gives an overview of 490ac939f3STony Tyethe extensions devised to address the missing features. The extensions seek to 500ac939f3STony Tyebe general in nature and backwards compatible with DWARF Version 5. Their goal 510ac939f3STony Tyeis to be applicable to meeting the needs of any heterogeneous system and not be 520ac939f3STony Tyevendor or architecture specific. That is followed by appendix 530ac939f3STony Tye:ref:`amdgpu-dwarf-changes-relative-to-dwarf-version-5` which contains the 54e24f5f31STonytextual changes for the extensions relative to the DWARF Version 5 standard. 550ac939f3STony TyeThere are a number of notes included that raise open questions, or provide 560ac939f3STony Tyealternative approaches that may be worth considering. Then appendix 573138fda3STony Tye:ref:`amdgpu-dwarf-further-examples` links to the AMD GPU specific usage of the 580ac939f3STony Tyeextensions that includes an example. Finally, appendix 590ac939f3STony Tye:ref:`amdgpu-dwarf-references` provides references to further information. 60e24f5f31STony 610ac939f3STony Tye.. _amdgpu-dwarf-extensions: 62e24f5f31STony 630fde0f41STony Tye2. Extensions 640ac939f3STony Tye============= 65e24f5f31STony 660ac939f3STony TyeThe extensions continue to evolve through collaboration with many individuals and 67e24f5f31STonyactive prototyping within the GDB debugger and LLVM compiler. Input has also 68e24f5f31STonybeen very much appreciated from the developers working on the Perforce TotalView 69e24f5f31STonyHPC Debugger and GCC compiler. 70e24f5f31STony 710ac939f3STony TyeThe inputs provided and insights gained so far have been incorporated into this 720ac939f3STony Tyecurrent version. The plan is to participate in upstreaming the work and 730ac939f3STony Tyeaddressing any feedback. If there is general interest then some or all of these 740ac939f3STony Tyeextensions could be submitted as future DWARF standard proposals. 75e24f5f31STony 760ac939f3STony TyeThe general principles in designing the extensions have been: 77e24f5f31STony 780ac939f3STony Tye1. Be backwards compatible with the DWARF Version 5 [:ref:`DWARF 790ac939f3STony Tye <amdgpu-dwarf-DWARF>`] standard. 80e24f5f31STony 810ac939f3STony Tye2. Be vendor and architecture neutral. They are intended to apply to other 820ac939f3STony Tye heterogeneous hardware devices including GPUs, DSPs, FPGAs, and other 830ac939f3STony Tye specialized hardware. These collectively include similar characteristics and 840ac939f3STony Tye requirements as AMDGPU devices. 850ac939f3STony Tye 860ac939f3STony Tye3. Provide improved optimization support for non-GPU code. For example, some 870ac939f3STony Tye extensions apply to traditional CPU hardware that supports large vector 880ac939f3STony Tye registers. Compilers can map source languages, and source language 890ac939f3STony Tye extensions, that describe large scale parallel execution, onto the lanes of 900ac939f3STony Tye the vector registers. This is common in programming languages used in ML and 910ac939f3STony Tye HPC. 920ac939f3STony Tye 930ac939f3STony Tye4. Fully define well-formed DWARF in a consistent style based on the DWARF 940ac939f3STony Tye Version 5 specification. 950ac939f3STony Tye 960ac939f3STony TyeIt is possible that some of the generalizations may also benefit other DWARF 970ac939f3STony Tyeissues that have been raised. 980ac939f3STony Tye 990ac939f3STony TyeThe remainder of this section enumerates the extensions and provides motivation 1000ac939f3STony Tyefor each in terms of heterogeneous debugging. 1010ac939f3STony Tye 1020ac939f3STony Tye.. _amdgpu-dwarf-allow-location-description-on-the-dwarf-evaluation-stack: 1030ac939f3STony Tye 1040ac939f3STony Tye2.1 Allow Location Description on the DWARF Expression Stack 1050ac939f3STony Tye------------------------------------------------------------ 1060ac939f3STony Tye 1070ac939f3STony TyeDWARF Version 5 does not allow location descriptions to be entries on the DWARF 1080ac939f3STony Tyeexpression stack. They can only be the final result of the evaluation of a DWARF 1090ac939f3STony Tyeexpression. However, by allowing a location description to be a first-class 1100ac939f3STony Tyeentry on the DWARF expression stack it becomes possible to compose expressions 1110ac939f3STony Tyecontaining both values and location descriptions naturally. It allows objects to 1120ac939f3STony Tyebe located in any kind of memory address space, in registers, be implicit 1130ac939f3STony Tyevalues, be undefined, or a composite of any of these. 1140ac939f3STony Tye 1150ac939f3STony TyeBy extending DWARF carefully, all existing DWARF expressions can retain their 1160ac939f3STony Tyecurrent semantic meaning. DWARF has implicit conversions that convert from a 1170ac939f3STony Tyevalue that represents an address in the default address space to a memory 1180ac939f3STony Tyelocation description. This can be extended to allow a default address space 1190ac939f3STony Tyememory location description to be implicitly converted back to its address 1200ac939f3STony Tyevalue. This allows all DWARF Version 5 expressions to retain their same meaning, 1210ac939f3STony Tyewhile enabling the ability to explicitly create memory location descriptions in 1220ac939f3STony Tyenon-default address spaces and generalizing the power of composite location 1230ac939f3STony Tyedescriptions to any kind of location description. 1240ac939f3STony Tye 1250ac939f3STony TyeFor those familiar with the definition of location descriptions in DWARF Version 1260ac939f3STony Tye5, the definitions in these extensions are presented differently, but does in 1270ac939f3STony Tyefact define the same concept with the same fundamental semantics. However, it 1280ac939f3STony Tyedoes so in a way that allows the concept to extend to support address spaces, 1290ac939f3STony Tyebit addressing, the ability for composite location descriptions to be composed 1300ac939f3STony Tyeof any kind of location description, and the ability to support objects located 1310ac939f3STony Tyeat multiple places. Collectively these changes expand the set of architectures 1320ac939f3STony Tyethat can be supported and improves support for optimized code. 1330ac939f3STony Tye 1340ac939f3STony TyeSeveral approaches were considered, and the one presented, together with the 1350ac939f3STony Tyeextensions it enables, appears to be the simplest and cleanest one that offers 1360ac939f3STony Tyethe greatest improvement of DWARF's ability to support debugging optimized GPU 1370ac939f3STony Tyeand non-GPU code. Examining the GDB debugger and LLVM compiler, it appears only 1380ac939f3STony Tyeto require modest changes as they both already have to support general use of 1390ac939f3STony Tyelocation descriptions. It is anticipated that will also be the case for other 1400ac939f3STony Tyedebuggers and compilers. 1410ac939f3STony Tye 1420ac939f3STony TyeGDB has been modified to evaluate DWARF Version 5 expressions with location 1430ac939f3STony Tyedescriptions as stack entries and with implicit conversions. All GDB tests have 1440ac939f3STony Tyepassed, except one that turned out to be an invalid test case by DWARF Version 5 1450ac939f3STony Tyerules. The code in GDB actually became simpler as all evaluation is done on a 1460ac939f3STony Tyesingle stack and there was no longer a need to maintain a separate structure for 1470ac939f3STony Tyethe location description results. This gives confidence in backwards 1480ac939f3STony Tyecompatibility. 1490ac939f3STony Tye 1500ac939f3STony TyeSee :ref:`amdgpu-dwarf-expressions` and nested sections. 1510ac939f3STony Tye 1520ac939f3STony TyeThis extension is separately described at *Allow Location Descriptions on the 1530ac939f3STony TyeDWARF Expression Stack* [:ref:`AMDGPU-DWARF-LOC 1540ac939f3STony Tye<amdgpu-dwarf-AMDGPU-DWARF-LOC>`]. 1550ac939f3STony Tye 1560ac939f3STony Tye2.2 Generalize CFI to Allow Any Location Description Kind 1570ac939f3STony Tye--------------------------------------------------------- 158e24f5f31STony 159e24f5f31STonyCFI describes restoring callee saved registers that are spilled. Currently CFI 160e24f5f31STonyonly allows a location description that is a register, memory address, or 1610ac939f3STony Tyeimplicit location description. AMDGPU optimized code may spill scalar registers 1620ac939f3STony Tyeinto portions of vector registers. This requires extending CFI to allow any 1630ac939f3STony Tyelocation description kind to be supported. 1640ac939f3STony Tye 1650ac939f3STony TyeSee :ref:`amdgpu-dwarf-call-frame-information`. 1660ac939f3STony Tye 1670ac939f3STony Tye2.3 Generalize DWARF Operation Expressions to Support Multiple Places 1680ac939f3STony Tye--------------------------------------------------------------------- 1690ac939f3STony Tye 1700ac939f3STony TyeIn DWARF Version 5 a location description is defined as a single location 1710ac939f3STony Tyedescription or a location list. A location list is defined as either 1720ac939f3STony Tyeeffectively an undefined location description or as one or more single 1730ac939f3STony Tyelocation descriptions to describe an object with multiple places. 1740ac939f3STony Tye 1750ac939f3STony TyeWith 1760ac939f3STony Tye:ref:`amdgpu-dwarf-allow-location-description-on-the-dwarf-evaluation-stack`, 1770ac939f3STony Tyethe ``DW_OP_push_object_address`` and ``DW_OP_call*`` operations can put a 1780ac939f3STony Tyelocation description on the stack. Furthermore, debugger information entry 1790ac939f3STony Tyeattributes such as ``DW_AT_data_member_location``, ``DW_AT_use_location``, and 1800ac939f3STony Tye``DW_AT_vtable_elem_location`` are defined as pushing a location description on 1810ac939f3STony Tyethe expression stack before evaluating the expression. 1820ac939f3STony Tye 1830ac939f3STony TyeDWARF Version 5 only allows the stack to contain values and so only a single 1840ac939f3STony Tyememory address can be on the stack. This makes these operations and attributes 1850ac939f3STony Tyeincapable of handling location descriptions with multiple places, or places 1860ac939f3STony Tyeother than memory. 1870ac939f3STony Tye 1880ac939f3STony TyeSince 1890ac939f3STony Tye:ref:`amdgpu-dwarf-allow-location-description-on-the-dwarf-evaluation-stack` 1900ac939f3STony Tyeallows the stack to contain location descriptions, the operations are 1910ac939f3STony Tyegeneralized to support location descriptions that can have multiple places. This 1920ac939f3STony Tyeis backwards compatible with DWARF Version 5 and allows objects with multiple 1930ac939f3STony Tyeplaces to be supported. For example, the expression that describes how to access 1940ac939f3STony Tyethe field of an object can be evaluated with a location description that has 1950ac939f3STony Tyemultiple places and will result in a location description with multiple places. 1960ac939f3STony Tye 1970ac939f3STony TyeWith this change, the separate DWARF Version 5 sections that described DWARF 1980ac939f3STony Tyeexpressions and location lists are unified into a single section that describes 1990ac939f3STony TyeDWARF expressions in general. This unification is a natural consequence of, and 2000ac939f3STony Tyea necessity of, allowing location descriptions to be part of the evaluation 2010ac939f3STony Tyestack. 2020ac939f3STony Tye 2030ac939f3STony TyeSee :ref:`amdgpu-dwarf-location-description`. 2040ac939f3STony Tye 2050ac939f3STony Tye2.4 Generalize Offsetting of Location Descriptions 2060ac939f3STony Tye-------------------------------------------------- 2070ac939f3STony Tye 2080ac939f3STony TyeThe ``DW_OP_plus`` and ``DW_OP_minus`` operations can be defined to operate on a 2090ac939f3STony Tyememory location description in the default target architecture specific address 2100ac939f3STony Tyespace and a generic type value to produce an updated memory location 2110ac939f3STony Tyedescription. This allows them to continue to be used to offset an address. 2120ac939f3STony Tye 2130ac939f3STony TyeTo generalize offsetting to any location description, including location 2140ac939f3STony Tyedescriptions that describe when bytes are in registers, are implicit, or a 2150ac939f3STony Tyecomposite of these, the ``DW_OP_LLVM_offset``, ``DW_OP_LLVM_offset_uconst``, and 2160ac939f3STony Tye``DW_OP_LLVM_bit_offset`` offset operations are added. 2170ac939f3STony Tye 2180ac939f3STony TyeThe offset operations can operate on location storage of any size. For example, 2190ac939f3STony Tyeimplicit location storage could be any number of bits in size. It is simpler to 2200ac939f3STony Tyedefine offsets that exceed the size of the location storage as being an 2210ac939f3STony Tyeevaluation error, than having to force an implementation to support potentially 2220ac939f3STony Tyeinfinite precision offsets to allow it to correctly track a series of positive 2230ac939f3STony Tyeand negative offsets that may transiently overflow or underflow, but end up in 2240ac939f3STony Tyerange. This is simple for the arithmetic operations as they are defined in terms 225a9f9f3dfSSpriteof two's complement arithmetic on a base type of a fixed size. Therefore, the 2260ac939f3STony Tyeoffset operation define that integer overflow is ill-formed. This is in contrast 2270ac939f3STony Tyeto the ``DW_OP_plus``, ``DW_OP_plus_uconst``, and ``DW_OP_minus`` arithmetic 2280ac939f3STony Tyeoperations which define that it causes wrap-around. 2290ac939f3STony Tye 2300ac939f3STony TyeHaving the offset operations allows ``DW_OP_push_object_address`` to push a 2310ac939f3STony Tyelocation description that may be in a register, or be an implicit value. The 2320ac939f3STony TyeDWARF expression of ``DW_TAG_ptr_to_member_type`` can use the offset operations 2330ac939f3STony Tyewithout regard to what kind of location description was pushed. 2340ac939f3STony Tye 2350ac939f3STony TyeSince 2360ac939f3STony Tye:ref:`amdgpu-dwarf-allow-location-description-on-the-dwarf-evaluation-stack` has 2370ac939f3STony Tyegeneralized location storage to be bit indexable, ``DW_OP_LLVM_bit_offset`` 2380ac939f3STony Tyegeneralizes DWARF to work with bit fields. This is generally not possible in 2390ac939f3STony TyeDWARF Version 5. 2400ac939f3STony Tye 2410ac939f3STony TyeThe ``DW_OP_*piece`` operations only allow literal indices. A way to use a 2420ac939f3STony Tyecomputed offset of an arbitrary location description (such as a vector register) 2430ac939f3STony Tyeis required. The offset operations provide this ability since they can be used 2440ac939f3STony Tyeto compute a location description on the stack. 2450ac939f3STony Tye 246817f64e7STony TyeIt could be possible to define ``DW_OP_plus``, ``DW_OP_plus_uconst``, and 247817f64e7STony Tye``DW_OP_minus`` to operate on location descriptions to avoid needing 248817f64e7STony Tye``DW_OP_LLVM_offset`` and ``DW_OP_LLVM_offset_uconst``. However, this is not 249817f64e7STony Tyeproposed since currently the arithmetic operations are defined to require values 250817f64e7STony Tyeof the same base type and produces a result with the same base type. Allowing 251817f64e7STony Tyethese operations to act on location descriptions would permit the first operand 252817f64e7STony Tyeto be a location description and the second operand to be an integral value 253817f64e7STony Tyetype, or vice versa, and return a location description. This complicates the 254817f64e7STony Tyerules for implicit conversions between default address space memory location 255817f64e7STony Tyedescriptions and generic base type values. Currently the rules would convert 256817f64e7STony Tyesuch a location description to the memory address value and then perform two's 257817f64e7STony Tyecompliment wrap around arithmetic. If the result was used as a location 258817f64e7STony Tyedescription, it would be implicitly converted back to a default address space 259817f64e7STony Tyememory location description. This is different to the overflow rules on location 260817f64e7STony Tyedescriptions. To allow control, an operation that converts a memory location 261817f64e7STony Tyedescription to an address integral type value would be required. Keeping a 262817f64e7STony Tyeseparation of location description operations and arithmetic operations avoids 263817f64e7STony Tyethis semantic complexity. 264817f64e7STony Tye 2650ac939f3STony TyeSee ``DW_OP_LLVM_offset``, ``DW_OP_LLVM_offset_uconst``, and 2660ac939f3STony Tye``DW_OP_LLVM_bit_offset`` in 2670ac939f3STony Tye:ref:`amdgpu-dwarf-general-location-description-operations`. 2680ac939f3STony Tye 2690ac939f3STony Tye2.5 Generalize Creation of Undefined Location Descriptions 2700ac939f3STony Tye---------------------------------------------------------- 2710ac939f3STony Tye 2720ac939f3STony TyeCurrent DWARF uses an empty expression to indicate an undefined location 2730ac939f3STony Tyedescription. Since 2740ac939f3STony Tye:ref:`amdgpu-dwarf-allow-location-description-on-the-dwarf-evaluation-stack` 2750ac939f3STony Tyeallows location descriptions to be created on the stack, it is necessary to have 2760ac939f3STony Tyean explicit way to specify an undefined location description. 2770ac939f3STony Tye 2780ac939f3STony TyeFor example, the ``DW_OP_LLVM_select_bit_piece`` (see 2790ac939f3STony Tye:ref:`amdgpu-dwarf-support-for-divergent-control-flow-of-simt-hardware`) 2800ac939f3STony Tyeoperation takes more than one location description on the stack. Without this 2810ac939f3STony Tyeability, it is not possible to specify that a particular one of the input 2820ac939f3STony Tyelocation descriptions is undefined. 2830ac939f3STony Tye 2840ac939f3STony TyeSee the ``DW_OP_LLVM_undefined`` operation in 2850ac939f3STony Tye:ref:`amdgpu-dwarf-undefined-location-description-operations`. 2860ac939f3STony Tye 2870ac939f3STony Tye2.6 Generalize Creation of Composite Location Descriptions 2880ac939f3STony Tye---------------------------------------------------------- 2890ac939f3STony Tye 2900ac939f3STony TyeTo allow composition of composite location descriptions, an explicit operation 2910ac939f3STony Tyethat indicates the end of the definition of a composite location description is 2920ac939f3STony Tyerequired. This can be implied if the end of a DWARF expression is reached, 2930ac939f3STony Tyeallowing current DWARF expressions to remain legal. 2940ac939f3STony Tye 2950ac939f3STony TyeSee ``DW_OP_LLVM_piece_end`` in 2960ac939f3STony Tye:ref:`amdgpu-dwarf-composite-location-description-operations`. 2970ac939f3STony Tye 2980ac939f3STony Tye2.7 Generalize DWARF Base Objects to Allow Any Location Description Kind 2990ac939f3STony Tye------------------------------------------------------------------------ 3000ac939f3STony Tye 3010ac939f3STony TyeThe number of registers and the cost of memory operations is much higher for 3020ac939f3STony TyeAMDGPU than a typical CPU. The compiler attempts to optimize whole variables and 3030ac939f3STony Tyearrays into registers. 3040ac939f3STony Tye 3050ac939f3STony TyeCurrently DWARF only allows ``DW_OP_push_object_address`` and related operations 3060ac939f3STony Tyeto work with a global memory location. To support AMDGPU optimized code it is 3070ac939f3STony Tyerequired to generalize DWARF to allow any location description to be used. This 3080ac939f3STony Tyeallows registers, or composite location descriptions that may be a mixture of 3090ac939f3STony Tyememory, registers, or even implicit values. 3100ac939f3STony Tye 3110ac939f3STony TyeSee ``DW_OP_push_object_address`` in 3120ac939f3STony Tye:ref:`amdgpu-dwarf-general-location-description-operations`. 3130ac939f3STony Tye 3140ac939f3STony Tye2.8 General Support for Address Spaces 3150ac939f3STony Tye-------------------------------------- 3160ac939f3STony Tye 3170ac939f3STony TyeAMDGPU needs to be able to describe addresses that are in different kinds of 3180ac939f3STony Tyememory. Optimized code may need to describe a variable that resides in pieces 3190ac939f3STony Tyethat are in different kinds of storage which may include parts of registers, 3200ac939f3STony Tyememory that is in a mixture of memory kinds, implicit values, or be undefined. 3210ac939f3STony Tye 3220ac939f3STony TyeDWARF has the concept of segment addresses. However, the segment cannot be 3230ac939f3STony Tyespecified within a DWARF expression, which is only able to specify the offset 3240ac939f3STony Tyeportion of a segment address. The segment index is only provided by the entity 3250ac939f3STony Tyethat specifies the DWARF expression. Therefore, the segment index is a property 3260ac939f3STony Tyethat can only be put on complete objects, such as a variable. That makes it only 3270ac939f3STony Tyesuitable for describing an entity (such as variable or subprogram code) that is 3280ac939f3STony Tyein a single kind of memory. 3290ac939f3STony Tye 330e60d1239STony TyeAMDGPU uses multiple address spaces. For example, a variable may be allocated in 331e60d1239STony Tyea register that is partially spilled to the call stack which is in the private 332e60d1239STony Tyeaddress space, and partially spilled to the local address space. DWARF mentions 333e60d1239STony Tyeaddress spaces, for example as an argument to the ``DW_OP_xderef*`` operations. 334e60d1239STony TyeA new section that defines address spaces is added (see 335e60d1239STony Tye:ref:`amdgpu-dwarf-address-spaces`). 336e60d1239STony Tye 337e60d1239STony TyeA new attribute ``DW_AT_LLVM_address_space`` is added to pointer and reference 338e60d1239STony Tyetypes (see :ref:`amdgpu-dwarf-type-modifier-entries`). This allows the compiler 339e60d1239STony Tyeto specify which address space is being used to represent the pointer or 340e60d1239STony Tyereference type. 3410ac939f3STony Tye 3420ac939f3STony TyeDWARF uses the concept of an address in many expression operations but does not 3430ac939f3STony Tyedefine how it relates to address spaces. For example, 3440ac939f3STony Tye``DW_OP_push_object_address`` pushes the address of an object. Other contexts 3450ac939f3STony Tyeimplicitly push an address on the stack before evaluating an expression. For 3460ac939f3STony Tyeexample, the ``DW_AT_use_location`` attribute of the 3470ac939f3STony Tye``DW_TAG_ptr_to_member_type``. The expression belongs to a source language type 3480ac939f3STony Tyewhich may apply to objects allocated in different kinds of storage. Therefore, 3490ac939f3STony Tyeit is desirable that the expression that uses the address can do so without 3500ac939f3STony Tyeregard to what kind of storage it specifies, including the address space of a 3510ac939f3STony Tyememory location description. For example, a pointer to member value may want to 3520ac939f3STony Tyebe applied to an object that may reside in any address space. 3530ac939f3STony Tye 3540ac939f3STony TyeThe DWARF ``DW_OP_xderef*`` operations allow a value to be converted into an 3550ac939f3STony Tyeaddress of a specified address space which is then read. But it provides no 3560ac939f3STony Tyeway to create a memory location description for an address in the non-default 3570ac939f3STony Tyeaddress space. For example, AMDGPU variables can be allocated in the local 3580ac939f3STony Tyeaddress space at a fixed address. 3590ac939f3STony Tye 3600ac939f3STony TyeThe ``DW_OP_LLVM_form_aspace_address`` (see 3610ac939f3STony Tye:ref:`amdgpu-dwarf-memory-location-description-operations`) operation is defined 3620ac939f3STony Tyeto create a memory location description from an address and address space. If 3630ac939f3STony Tyecan be used to specify the location of a variable that is allocated in a 3640ac939f3STony Tyespecific address space. This allows the size of addresses in an address space to 3650ac939f3STony Tyebe larger than the generic type. It also allows a consumer great implementation 3660ac939f3STony Tyefreedom. It allows the implicit conversion back to a value to be limited only to 3670ac939f3STony Tyethe default address space to maintain compatibility with DWARF Version 5. For 3680ac939f3STony Tyeother address spaces the producer can use the new operations that explicitly 3690ac939f3STony Tyespecify the address space. 3700ac939f3STony Tye 3710ac939f3STony TyeIn contrast, if the ``DW_OP_LLVM_form_aspace_address`` operation had been 3720ac939f3STony Tyedefined to produce a value, and an implicit conversion to a memory location 3730ac939f3STony Tyedescription was defined, then it would be limited to the size of the generic 3740ac939f3STony Tyetype (which matches the size of the default address space). An implementation 3750ac939f3STony Tyewould likely have to use *reserved ranges* of value to represent different 3760ac939f3STony Tyeaddress spaces. Such a value would likely not match any address value in the 3770ac939f3STony Tyeactual hardware. That would require the consumer to have special treatment for 3780ac939f3STony Tyesuch values. 3790ac939f3STony Tye 3800ac939f3STony Tye``DW_OP_breg*`` treats the register as containing an address in the default 3810ac939f3STony Tyeaddress space. A ``DW_OP_LLVM_aspace_bregx`` (see 3820ac939f3STony Tye:ref:`amdgpu-dwarf-memory-location-description-operations`) operation is added 3830ac939f3STony Tyeto allow the address space of the address held in a register to be specified. 3840ac939f3STony Tye 3850ac939f3STony TyeSimilarly, ``DW_OP_implicit_pointer`` treats its implicit pointer value as being 3860ac939f3STony Tyein the default address space. A ``DW_OP_LLVM_aspace_implicit_pointer`` 3870ac939f3STony Tye(:ref:`amdgpu-dwarf-implicit-location-description-operations`) operation is 3880ac939f3STony Tyeadded to allow the address space to be specified. 3890ac939f3STony Tye 3900ac939f3STony TyeAlmost all uses of addresses in DWARF are limited to defining location 3910ac939f3STony Tyedescriptions, or to be dereferenced to read memory. The exception is 3920ac939f3STony Tye``DW_CFA_val_offset`` which uses the address to set the value of a register. In 3930ac939f3STony Tyeorder to support address spaces, the CFA DWARF expression is defined to be a 3940ac939f3STony Tyememory location description. This allows it to specify an address space which is 3950ac939f3STony Tyeused to convert the offset address back to an address in that address space. See 396e24f5f31STony:ref:`amdgpu-dwarf-call-frame-information`. 397e24f5f31STony 3980ac939f3STony TyeThis approach of extending memory location descriptions to support address 3990ac939f3STony Tyespaces, allows all existing DWARF Version 5 expressions to have the identical 4000ac939f3STony Tyesemantics. It allows the compiler to explicitly specify the address space it is 4010ac939f3STony Tyeusing. For example, a compiler could choose to access private memory in a 4020ac939f3STony Tyeswizzled manner when mapping a source language thread to the lane of a wavefront 4030ac939f3STony Tyein a SIMT manner. Or a compiler could choose to access it in an unswizzled 4040ac939f3STony Tyemanner if mapping the same language with the wavefront being the thread. 4050ac939f3STony Tye 4060ac939f3STony TyeIt also allows the compiler to mix the address space it uses to access private 4070ac939f3STony Tyememory. For example, for SIMT it can still spill entire vector registers in an 4080ac939f3STony Tyeunswizzled manner, while using a swizzled private memory for SIMT variable 4090ac939f3STony Tyeaccess. 4100ac939f3STony Tye 4110ac939f3STony TyeThis approach also allows memory location descriptions for different address 4120ac939f3STony Tyespaces to be combined using the regular ``DW_OP_*piece`` operations. 4130ac939f3STony Tye 4140ac939f3STony TyeLocation descriptions are an abstraction of storage. They give freedom to the 4150ac939f3STony Tyeconsumer on how to implement them. They allow the address space to encode lane 4160ac939f3STony Tyeinformation so they can be used to read memory with only the memory location 4170ac939f3STony Tyedescription and no extra information. The same set of operations can operate on 4180ac939f3STony Tyelocations independent of their kind of storage. The ``DW_OP_deref*`` therefore 4190ac939f3STony Tyecan be used on any storage kind, including memory location descriptions of 4200ac939f3STony Tyedifferent address spaces. Therefore, the ``DW_OP_xderef*`` operations are 4210ac939f3STony Tyeunnecessary, except to become a more compact way to encode a non-default address 4220ac939f3STony Tyespace address followed by dereferencing it. See 4230ac939f3STony Tye:ref:`amdgpu-dwarf-general-operations`. 4240ac939f3STony Tye 4250ac939f3STony Tye2.9 Support for Vector Base Types 4260ac939f3STony Tye--------------------------------- 4270ac939f3STony Tye 428e24f5f31STonyThe vector registers of the AMDGPU are represented as their full wavefront 429e24f5f31STonysize, meaning the wavefront size times the dword size. This reflects the 430e24f5f31STonyactual hardware and allows the compiler to generate DWARF for languages that 431e24f5f31STonymap a thread to the complete wavefront. It also allows more efficient DWARF to 432e24f5f31STonybe generated to describe the CFI as only a single expression is required for 433e24f5f31STonythe whole vector register, rather than a separate expression for each lane's 434e24f5f31STonydword of the vector register. It also allows the compiler to produce DWARF 435e24f5f31STonythat indexes the vector register if it spills scalar registers into portions 436b9496efbSvnalamotof a vector register. 437e24f5f31STony 438e24f5f31STonySince DWARF stack value entries have a base type and AMDGPU registers are a 439e24f5f31STonyvector of dwords, the ability to specify that a base type is a vector is 4400ac939f3STony Tyerequired. 4410ac939f3STony Tye 442817f64e7STony TyeSee ``DW_AT_LLVM_vector_size`` in :ref:`amdgpu-dwarf-base-type-entries`. 4430ac939f3STony Tye 4440ac939f3STony Tye.. _amdgpu-dwarf-operation-to-create-vector-composite-location-descriptions: 4450ac939f3STony Tye 4460ac939f3STony Tye2.10 DWARF Operations to Create Vector Composite Location Descriptions 4470ac939f3STony Tye---------------------------------------------------------------------- 4480ac939f3STony Tye 4490ac939f3STony TyeAMDGPU optimized code may spill vector registers to non-global address space 4500ac939f3STony Tyememory, and this spilling may be done only for SIMT lanes that are active on 4510e42df40STony Tyeentry to the subprogram. To support this the CFI rule for the partially spilled 4520e42df40STony Tyeregister needs to use an expression that uses the EXEC register as a bit mask to 4530e42df40STony Tyeselect between the register (for inactive lanes) and the stack spill location 4540e42df40STony Tye(for active lanes that are spilled). This needs to evaluate to a location 4550e42df40STony Tyedescription, and not a value, as a debugger needs to change the value if the 4560e42df40STony Tyeuser assigns to the variable. 4570ac939f3STony Tye 4580e42df40STony TyeAnother usage is to create an expression that evaluates to provide a vector of 4590e42df40STony Tyelogical PCs for active and inactive lanes in a SIMT execution model. Again the 4600e42df40STony TyeEXEC register is used to select between active and inactive PC values. In order 4610e42df40STony Tyeto represent a vector of PC values, a way to create a composite location 4620e42df40STony Tyedescription that is a vector of a single location is used. 4630e42df40STony Tye 4640e42df40STony TyeIt may be possible to use existing DWARF to incrementally build the composite 4650e42df40STony Tyelocation description, possibly using the DWARF operations for control flow to 4660e42df40STony Tyecreate a loop. However, for the AMDGPU that would require loop iteration of 64. 4670e42df40STony TyeA concern is that the resulting DWARF would have a significant size and would be 4680e42df40STony Tyereasonably common as it is needed for every vector register that is spilled in a 4690e42df40STony Tyefunction. AMDGPU can have up to 512 vector registers. Another concern is the 4700e42df40STony Tyetime taken to evaluate such non-trivial expressions repeatedly. 4710e42df40STony Tye 4720e42df40STony TyeTo avoid these issues, a composite location description that can be created as a 4730e42df40STony Tyemasked select is proposed. In addition, an operation that creates a composite 4740ac939f3STony Tyelocation description that is a vector on another location description is needed. 4750e42df40STony TyeThese operations generate the composite location description using a single 4760e42df40STony TyeDWARF operation that combines all lanes of the vector in one step. The DWARF 4770e42df40STony Tyeexpression is more compact, and can be evaluated by a consumer far more 4780e42df40STony Tyeefficiently. 4790ac939f3STony Tye 4800ac939f3STony TyeAn example that uses these operations is referenced in the 4813138fda3STony Tye:ref:`amdgpu-dwarf-further-examples` appendix. 4820ac939f3STony Tye 4830ac939f3STony TyeSee ``DW_OP_LLVM_select_bit_piece`` and ``DW_OP_LLVM_extend`` in 4840ac939f3STony Tye:ref:`amdgpu-dwarf-composite-location-description-operations`. 4850ac939f3STony Tye 4860ac939f3STony Tye2.11 DWARF Operation to Access Call Frame Entry Registers 4870ac939f3STony Tye--------------------------------------------------------- 4880ac939f3STony Tye 4890ac939f3STony TyeAs described in 4900ac939f3STony Tye:ref:`amdgpu-dwarf-operation-to-create-vector-composite-location-descriptions`, 4910ac939f3STony Tyea DWARF expression involving the set of SIMT lanes active on entry to a 4920ac939f3STony Tyesubprogram is required. The SIMT active lane mask may be held in a register that 4930ac939f3STony Tyeis modified as the subprogram executes. However, its value may be saved on entry 4940ac939f3STony Tyeto the subprogram. 4950ac939f3STony Tye 4960ac939f3STony TyeThe Call Frame Information (CFI) already encodes such register saving, so it is 4970ac939f3STony Tyemore efficient to provide an operation to return the location of a saved 4980ac939f3STony Tyeregister than have to generate a loclist to describe the same information. This 4990ac939f3STony Tyeis now possible since 5000ac939f3STony Tye:ref:`amdgpu-dwarf-allow-location-description-on-the-dwarf-evaluation-stack` 5010ac939f3STony Tyeallows location descriptions on the stack. 5020ac939f3STony Tye 5030ac939f3STony TyeSee ``DW_OP_LLVM_call_frame_entry_reg`` in 5040ac939f3STony Tye:ref:`amdgpu-dwarf-general-location-description-operations` and 5050ac939f3STony Tye:ref:`amdgpu-dwarf-call-frame-information`. 5060ac939f3STony Tye 5070ac939f3STony Tye2.12 Support for Source Languages Mapped to SIMT Hardware 5080ac939f3STony Tye--------------------------------------------------------- 509e24f5f31STony 510e24f5f31STonyIf the source language is mapped onto the AMDGPU wavefronts in a SIMT manner, 511e24f5f31STonythen the variable DWARF location expressions must compute the location for a 512e24f5f31STonysingle lane of the wavefront. Therefore, a DWARF operation is required to denote 513e24f5f31STonythe current lane, much like ``DW_OP_push_object_address`` denotes the current 5148ba5043dSTony Tyeobject. See ``DW_OP_LLVM_push_lane`` in :ref:`amdgpu-dwarf-literal-operations`. 515e24f5f31STony 5168ba5043dSTony TyeIn addition, a way is needed for the compiler to communicate how many source 5178ba5043dSTony Tyelanguage threads of execution are mapped to a target architecture thread's SIMT 5188ba5043dSTony Tyelanes. See ``DW_AT_LLVM_lanes`` in :ref:`amdgpu-dwarf-low-level-information`. 519e24f5f31STony 5200ac939f3STony Tye.. _amdgpu-dwarf-support-for-divergent-control-flow-of-simt-hardware: 521e24f5f31STony 5220ac939f3STony Tye2.13 Support for Divergent Control Flow of SIMT Hardware 5230ac939f3STony Tye-------------------------------------------------------- 524e24f5f31STony 5250ac939f3STony TyeIf the source language is mapped onto the AMDGPU wavefronts in a SIMT manner the 5260ac939f3STony Tyecompiler can use the AMDGPU execution mask register to control which lanes are 5270ac939f3STony Tyeactive. To describe the conceptual location of non-active lanes requires an 5280ac939f3STony Tyeattribute that has an expression that computes the source location PC for each 5290ac939f3STony Tyelane. 530e24f5f31STony 5310ac939f3STony TyeFor efficiency, the expression calculates the source location the wavefront as a 5320ac939f3STony Tyewhole. This can be done using the ``DW_OP_LLVM_select_bit_piece`` (see 5330ac939f3STony Tye:ref:`amdgpu-dwarf-operation-to-create-vector-composite-location-descriptions`) 5340ac939f3STony Tyeoperation. 535e24f5f31STony 5360ac939f3STony TyeThe AMDGPU may update the execution mask to perform whole wavefront operations. 5370ac939f3STony TyeTherefore, there is a need for an attribute that computes the current active 5380ac939f3STony Tyelane mask. This can have an expression that may evaluate to the SIMT active lane 5390ac939f3STony Tyemask register or to a saved mask when in whole wavefront execution mode. 540e24f5f31STony 5410ac939f3STony TyeAn example that uses these attributes is referenced in the 5423138fda3STony Tye:ref:`amdgpu-dwarf-further-examples` appendix. 543e24f5f31STony 5440ac939f3STony TyeSee ``DW_AT_LLVM_lane_pc`` and ``DW_AT_LLVM_active_lane`` in 5450ac939f3STony Tye:ref:`amdgpu-dwarf-composite-location-description-operations`. 546e24f5f31STony 5473138fda3STony Tye2.14 Define Source Language Memory Classes 5480ac939f3STony Tye------------------------------------------- 549e24f5f31STony 5500ac939f3STony TyeAMDGPU supports languages, such as OpenCL [:ref:`OpenCL <amdgpu-dwarf-OpenCL>`], 5513138fda3STony Tyethat define source language memory classes. Support is added to define language 5523138fda3STony Tyespecific memory spaces so they can be used in a consistent way by consumers. 553e24f5f31STony 5543138fda3STony TyeSupport for using memory spaces in defining source language types and data 5553138fda3STony Tyeobject allocation is also added. 556e24f5f31STony 5573138fda3STony TyeSee :ref:`amdgpu-dwarf-memory-spaces`. 558e24f5f31STony 5590ac939f3STony Tye2.15 Define Augmentation Strings to Support Multiple Extensions 5600ac939f3STony Tye--------------------------------------------------------------- 561e24f5f31STony 5620ac939f3STony TyeA ``DW_AT_LLVM_augmentation`` attribute is added to a compilation unit debugger 5630ac939f3STony Tyeinformation entry to indicate that there is additional target architecture 5640ac939f3STony Tyespecific information in the debugging information entries of that compilation 5650ac939f3STony Tyeunit. This allows a consumer to know what extensions are present in the debugger 5660ac939f3STony Tyeinformation entries as is possible with the augmentation string of other 5670ac939f3STony Tyesections. See . 568e24f5f31STony 5690ac939f3STony TyeThe format that should be used for an augmentation string is also recommended. 5700ac939f3STony TyeThis allows a consumer to parse the string when it contains information from 5710ac939f3STony Tyemultiple vendors. Augmentation strings occur in the ``DW_AT_LLVM_augmentation`` 5720ac939f3STony Tyeattribute, in the lookup by name table, and in the CFI Common Information Entry 5730ac939f3STony Tye(CIE). 574e24f5f31STony 5750ac939f3STony TyeSee :ref:`amdgpu-dwarf-full-and-partial-compilation-unit-entries`, 5760ac939f3STony Tye:ref:`amdgpu-dwarf-name-index-section-header`, and 5770ac939f3STony Tye:ref:`amdgpu-dwarf-structure_of-call-frame-information`. 578e24f5f31STony 5790ac939f3STony Tye2.16 Support Embedding Source Text for Online Compilation 5800ac939f3STony Tye--------------------------------------------------------- 581e24f5f31STony 5820ac939f3STony TyeAMDGPU supports programming languages that include online compilation where the 5830ac939f3STony Tyesource text may be created at runtime. For example, the OpenCL and HIP language 5840ac939f3STony Tyeruntimes support online compilation. To support is, a way to embed the source 5850ac939f3STony Tyetext in the debug information is provided. 586e24f5f31STony 5870ac939f3STony TyeSee :ref:`amdgpu-dwarf-line-number-information`. 588e24f5f31STony 5890ac939f3STony Tye2.17 Allow MD5 Checksums to be Optionally Present 5900ac939f3STony Tye------------------------------------------------- 591e24f5f31STony 5920ac939f3STony TyeIn DWARF Version 5 the file timestamp and file size can be optional, but if the 5930ac939f3STony TyeMD5 checksum is present it must be valid for all files. This is a problem if 5940ac939f3STony Tyeusing link time optimization to combine compilation units where some have MD5 5950ac939f3STony Tyechecksums and some do not. Therefore, sSupport to allow MD5 checksums to be 5960ac939f3STony Tyeoptionally present in the line table is added. 597e24f5f31STony 5980ac939f3STony TyeSee :ref:`amdgpu-dwarf-line-number-information`. 599e24f5f31STony 6000ac939f3STony Tye2.18 Add the HIP Programing Language 6010ac939f3STony Tye------------------------------------ 602e24f5f31STony 6030ac939f3STony TyeThe HIP programming language [:ref:`HIP <amdgpu-dwarf-HIP>`], which is supported 6040ac939f3STony Tyeby the AMDGPU, is added. 605e24f5f31STony 6060ac939f3STony TyeSee :ref:`amdgpu-dwarf-language-names-table`. 607e24f5f31STony 6088ba5043dSTony Tye2.19 Support for Source Language Optimizations that Result in Concurrent Iteration Execution 6098ba5043dSTony Tye-------------------------------------------------------------------------------------------- 6108ba5043dSTony Tye 6118ba5043dSTony TyeA compiler can perform loop optimizations that result in the generated code 6128ba5043dSTony Tyeexecuting multiple iterations concurrently. For example, software pipelining 6138ba5043dSTony Tyeschedules multiple iterations in an interleaved fashion to allow the 6148ba5043dSTony Tyeinstructions of one iteration to hide the latencies of the instructions of 6158ba5043dSTony Tyeanother iteration. Another example is vectorization that can exploit SIMD 6168ba5043dSTony Tyehardware to allow a single instruction to execute multiple iterations using 6178ba5043dSTony Tyevector registers. 6188ba5043dSTony Tye 6198ba5043dSTony TyeNote that although this is similar to SIMT execution, the way a client debugger 6208ba5043dSTony Tyeuses the information is fundamentally different. In SIMT execution the debugger 6218ba5043dSTony Tyeneeds to present the concurrent execution as distinct source language threads 6228ba5043dSTony Tyethat the user can list and switch focus between. With iteration concurrency 6238ba5043dSTony Tyeoptimizations, such as software pipelining and vectorized SIMD, the debugger 6248ba5043dSTony Tyemust not present the concurrency as distinct source language threads. Instead, 6258ba5043dSTony Tyeit must inform the user that multiple loop iterations are executing in parallel 6268ba5043dSTony Tyeand allow the user to select between them. 6278ba5043dSTony Tye 6288ba5043dSTony TyeIn general, SIMT execution fixes the number of concurrent executions per target 6298ba5043dSTony Tyearchitecture thread. However, both software pipelining and SIMD vectorization 6308ba5043dSTony Tyemay vary the number of concurrent iterations for different loops executed by a 6318ba5043dSTony Tyesingle source language thread. 6328ba5043dSTony Tye 6338ba5043dSTony TyeIt is possible for the compiler to use both SIMT concurrency and iteration 6348ba5043dSTony Tyeconcurrency techniques in the code of a single source language thread. 6358ba5043dSTony Tye 6368ba5043dSTony TyeTherefore, a DWARF operation is required to denote the current concurrent 6378ba5043dSTony Tyeiteration instance, much like ``DW_OP_push_object_address`` denotes the current 6388ba5043dSTony Tyeobject. See ``DW_OP_LLVM_push_iteration`` in 6398ba5043dSTony Tye:ref:`amdgpu-dwarf-literal-operations`. 6408ba5043dSTony Tye 6418ba5043dSTony TyeIn addition, a way is needed for the compiler to communicate how many source 6428ba5043dSTony Tyelanguage loop iterations are executing concurrently. See 6438ba5043dSTony Tye``DW_AT_LLVM_iterations`` in :ref:`amdgpu-dwarf-low-level-information`. 6448ba5043dSTony Tye 6458ba5043dSTony Tye2.20 DWARF Operation to Create Runtime Overlay Composite Location Description 6468ba5043dSTony Tye----------------------------------------------------------------------------- 6478ba5043dSTony Tye 6488ba5043dSTony TyeIt is common in SIMD vectorization for the compiler to generate code that 6498ba5043dSTony Tyepromotes portions of an array into vector registers. For example, if the 6508ba5043dSTony Tyehardware has vector registers with 8 elements, and 8 wide SIMD instructions, the 6518ba5043dSTony Tyecompiler may vectorize a loop so that is executes 8 iterations concurrently for 6528ba5043dSTony Tyeeach vectorized loop iteration. 6538ba5043dSTony Tye 6548ba5043dSTony TyeOn the first iteration of the generated vectorized loop, iterations 0 to 7 of 6558ba5043dSTony Tyethe source language loop will be executed using SIMD instructions. Then on the 6568ba5043dSTony Tyenext iteration of the generated vectorized loop, iteration 8 to 15 will be 6578ba5043dSTony Tyeexecuted, and so on. 6588ba5043dSTony Tye 6598ba5043dSTony TyeIf the source language loop accesses an array element based on the loop 6608ba5043dSTony Tyeiteration index, the compiler may read the element into a register for the 6618ba5043dSTony Tyeduration of that iteration. Next iteration it will read the next element into 6628ba5043dSTony Tyethe register, and so on. With SIMD, this generalizes to the compiler reading 6638ba5043dSTony Tyearray elements 0 to 7 into a vector register on the first vectorized loop 6648ba5043dSTony Tyeiteration, then array elements 8 to 15 on the next iteration, and so on. 6658ba5043dSTony Tye 6668ba5043dSTony TyeThe DWARF location description for the array needs to express that all elements 6678ba5043dSTony Tyeare in memory, except the slice that has been promoted to the vector register. 6688ba5043dSTony TyeThe starting position of the slice is a runtime value based on the iteration 6698ba5043dSTony Tyeindex modulo the vectorization size. This cannot be expressed by ``DW_OP_piece`` 6708ba5043dSTony Tyeand ``DW_OP_bit_piece`` which only allow constant offsets to be expressed. 6718ba5043dSTony Tye 6728ba5043dSTony TyeTherefore, a new operator is defined that takes two location descriptions, an 6738ba5043dSTony Tyeoffset and a size, and creates a composite that effectively uses the second 6748ba5043dSTony Tyelocation description as an overlay of the first, positioned according to the 6758ba5043dSTony Tyeoffset and size. See ``DW_OP_LLVM_overlay`` and ``DW_OP_LLVM_bit_overlay`` in 6768ba5043dSTony Tye:ref:`amdgpu-dwarf-composite-location-description-operations`. 6778ba5043dSTony Tye 6780fde0f41STony TyeConsider an array that has been partially registerized such that the currently 6790fde0f41STony Tyeprocessed elements are held in registers, whereas the remainder of the array 6800fde0f41STony Tyeremains in memory. Consider the loop in this C function, for example: 6810fde0f41STony Tye 6820fde0f41STony Tye.. code:: 6830fde0f41STony Tye :number-lines: 6840fde0f41STony Tye 6850fde0f41STony Tye extern void foo(uint32_t dst[], uint32_t src[], int len) { 6860fde0f41STony Tye for (int i = 0; i < len; ++i) 6870fde0f41STony Tye dst[i] += src[i]; 6880fde0f41STony Tye } 6890fde0f41STony Tye 6900fde0f41STony TyeInside the loop body, the machine code loads ``src[i]`` and ``dst[i]`` into 6910fde0f41STony Tyeregisters, adds them, and stores the result back into ``dst[i]``. 6920fde0f41STony Tye 6930fde0f41STony TyeConsidering the location of ``dst`` and ``src`` in the loop body, the elements 6940fde0f41STony Tye``dst[i]`` and ``src[i]`` would be located in registers, all other elements are 6950fde0f41STony Tyelocated in memory. Let register ``R0`` contain the base address of ``dst``, 6960fde0f41STony Tyeregister ``R1`` contain ``i``, and register ``R2`` contain the registerized 6970fde0f41STony Tye``dst[i]`` element. We can describe the location of ``dst`` as a memory location 6980fde0f41STony Tyewith a register location overlaid at a runtime offset involving ``i``: 6990fde0f41STony Tye 7000fde0f41STony Tye.. code:: 7010fde0f41STony Tye :number-lines: 7020fde0f41STony Tye 7030fde0f41STony Tye // 1. Memory location description of dst elements located in memory: 7040fde0f41STony Tye DW_OP_breg0 0 7050fde0f41STony Tye 7060fde0f41STony Tye // 2. Register location description of element dst[i] is located in R2: 7070fde0f41STony Tye DW_OP_reg2 7080fde0f41STony Tye 7090fde0f41STony Tye // 3. Offset of the register within the memory of dst: 7100fde0f41STony Tye DW_OP_breg1 0 7110fde0f41STony Tye DW_OP_lit4 7120fde0f41STony Tye DW_OP_mul 7130fde0f41STony Tye 7140fde0f41STony Tye // 4. The size of the register element: 7150fde0f41STony Tye DW_OP_lit4 7160fde0f41STony Tye 7170fde0f41STony Tye // 5. Make a composite location description for dst that is the memory #1 with 7180fde0f41STony Tye // the register #2 positioned as an overlay at offset #3 of size #4: 7190fde0f41STony Tye DW_OP_LLVM_overlay 7200fde0f41STony Tye 721e60d1239STony Tye2.21 Support for Source Language Memory Spaces 722e60d1239STony Tye---------------------------------------------- 723e60d1239STony Tye 724e60d1239STony TyeAMDGPU supports languages, such as OpenCL, that define source language memory 725e60d1239STony Tyespaces. Support is added to define language specific memory spaces so they can 726e60d1239STony Tyebe used in a consistent way by consumers. See :ref:`amdgpu-dwarf-memory-spaces`. 727e60d1239STony Tye 728e60d1239STony TyeA new attribute ``DW_AT_LLVM_memory_space`` is added to support using memory 729e60d1239STony Tyespaces in defining source language pointer and reference types (see 730e60d1239STony Tye:ref:`amdgpu-dwarf-type-modifier-entries`) and data object allocation (see 731e60d1239STony Tye:ref:`amdgpu-dwarf-data-object-entries`). 732e60d1239STony Tye 733a4fb7f60SScott Linder2.22 Expression Operation Vendor Extensibility Opcode 734a4fb7f60SScott Linder----------------------------------------------------- 735a4fb7f60SScott Linder 736a4fb7f60SScott LinderThe vendor extension encoding space for DWARF expression operations 737a4fb7f60SScott Linderaccommodates only 32 unique operations. In practice, the lack of a central 738a4fb7f60SScott Linderregistry and a desire for backwards compatibility means vendor extensions are 739a4fb7f60SScott Lindernever retired, even when standard versions are accepted into DWARF proper. This 740a4fb7f60SScott Linderhas produced a situation where the effective encoding space available for new 741a4fb7f60SScott Lindervendor extensions is miniscule today. 742a4fb7f60SScott Linder 743a4fb7f60SScott LinderTo expand this encoding space a new DWARF operation ``DW_OP_LLVM_user`` is 744a4fb7f60SScott Linderadded which acts as a "prefix" for vendor extensions. It is followed by a 745a4fb7f60SScott LinderULEB128 encoded vendor extension opcode, which is then followed by the operands 746a4fb7f60SScott Linderof the corresponding vendor extension operation. 747a4fb7f60SScott Linder 748a4fb7f60SScott LinderThis approach allows all remaining operations defined in these extensions to be 749a4fb7f60SScott Linderencoded without conflicting with existing vendor extensions. 750a4fb7f60SScott Linder 751a4fb7f60SScott LinderSee ``DW_OP_LLVM_user`` in :ref:`amdgpu-dwarf-vendor-extensions-operations`. 752a4fb7f60SScott Linder 753e24f5f31STony.. _amdgpu-dwarf-changes-relative-to-dwarf-version-5: 754e24f5f31STony 7550ac939f3STony TyeA. Changes Relative to DWARF Version 5 7560ac939f3STony Tye====================================== 757e24f5f31STony 7580ac939f3STony Tye.. note:: 759e24f5f31STony 7600ac939f3STony Tye This appendix provides changes relative to DWARF Version 5. It has been 7610ac939f3STony Tye defined such that it is backwards compatible with DWARF Version 5. 7620ac939f3STony Tye Non-normative text is shown in *italics*. The section numbers generally 7630ac939f3STony Tye correspond to those in the DWARF Version 5 standard unless specified 7640ac939f3STony Tye otherwise. Definitions are given for the additional operations, as well as 7650ac939f3STony Tye clarifying how existing expression operations, CFI operations, and attributes 7660ac939f3STony Tye behave with respect to generalized location descriptions that support address 7670ac939f3STony Tye spaces and multiple places. 7680ac939f3STony Tye 7690ac939f3STony Tye The names for the new operations, attributes, and constants include "\ 770a4fb7f60SScott Linder ``LLVM``\ " and are encoded with vendor specific codes so these extensions 771a4fb7f60SScott Linder can be implemented as an LLVM vendor extension to DWARF Version 5. New 772a4fb7f60SScott Linder operations other than ``DW_OP_LLVM_user`` are "prefixed" by 773a4fb7f60SScott Linder ``DW_OP_LLVM_user`` to make enough encoding space available for their 774a4fb7f60SScott Linder implementation. 7750ac939f3STony Tye 7760ac939f3STony Tye .. note:: 7770ac939f3STony Tye 7780ac939f3STony Tye Notes are included to describe how the changes are to be applied to the 7790ac939f3STony Tye DWARF Version 5 standard. They also describe rational and issues that may 7800ac939f3STony Tye need further consideration. 7810ac939f3STony Tye 7820ac939f3STony TyeA.2 General Description 7830ac939f3STony Tye----------------------- 7840ac939f3STony Tye 7850ac939f3STony TyeA.2.2 Attribute Types 7860ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~ 787e24f5f31STony 788e24f5f31STony.. note:: 789e24f5f31STony 790e24f5f31STony This augments DWARF Version 5 section 2.2 and Table 2.2. 791e24f5f31STony 7920ac939f3STony TyeThe following table provides the additional attributes. 793e24f5f31STony 794e24f5f31STony.. table:: Attribute names 795e24f5f31STony :name: amdgpu-dwarf-attribute-names-table 796e24f5f31STony 7973138fda3STony Tye ============================ ==================================== 798e24f5f31STony Attribute Usage 7993138fda3STony Tye ============================ ==================================== 8008ba5043dSTony Tye ``DW_AT_LLVM_active_lane`` SIMT active lanes (see :ref:`amdgpu-dwarf-low-level-information`) 8010ac939f3STony Tye ``DW_AT_LLVM_augmentation`` Compilation unit augmentation string (see :ref:`amdgpu-dwarf-full-and-partial-compilation-unit-entries`) 8028ba5043dSTony Tye ``DW_AT_LLVM_lane_pc`` SIMT lane program location (see :ref:`amdgpu-dwarf-low-level-information`) 8038ba5043dSTony Tye ``DW_AT_LLVM_lanes`` SIMT lane count (see :ref:`amdgpu-dwarf-low-level-information`) 8048ba5043dSTony Tye ``DW_AT_LLVM_iterations`` Concurrent iteration count (see :ref:`amdgpu-dwarf-low-level-information`) 8050ac939f3STony Tye ``DW_AT_LLVM_vector_size`` Base type vector size (see :ref:`amdgpu-dwarf-base-type-entries`) 8063138fda3STony Tye ``DW_AT_LLVM_address_space`` Architecture specific address space (see :ref:`amdgpu-dwarf-address-spaces`) 8073138fda3STony Tye ``DW_AT_LLVM_memory_space`` Pointer or reference types (see 5.3 "Type Modifier Entries") 8083138fda3STony Tye Data objects (see 4.1 "Data Object Entries") 8093138fda3STony Tye ============================ ==================================== 810e24f5f31STony 811e24f5f31STony.. _amdgpu-dwarf-expressions: 812e24f5f31STony 8130ac939f3STony TyeA.2.5 DWARF Expressions 8140ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~ 815e24f5f31STony 816e24f5f31STony.. note:: 817e24f5f31STony 818e24f5f31STony This section, and its nested sections, replaces DWARF Version 5 section 2.5 819e24f5f31STony and section 2.6. The new DWARF expression operation extensions are defined as 820e24f5f31STony well as clarifying the extensions to already existing DWARF Version 5 821e24f5f31STony operations. It is based on the text of the existing DWARF Version 5 standard. 822e24f5f31STony 823e24f5f31STonyDWARF expressions describe how to compute a value or specify a location. 824e24f5f31STony 825e24f5f31STony*The evaluation of a DWARF expression can provide the location of an object, the 826e24f5f31STonyvalue of an array bound, the length of a dynamic string, the desired value 827e24f5f31STonyitself, and so on.* 828e24f5f31STony 829e24f5f31STonyIf the evaluation of a DWARF expression does not encounter an error, then it can 830e24f5f31STonyeither result in a value (see :ref:`amdgpu-dwarf-expression-value`) or a 831e24f5f31STonylocation description (see :ref:`amdgpu-dwarf-location-description`). When a 832e24f5f31STonyDWARF expression is evaluated, it may be specified whether a value or location 833e24f5f31STonydescription is required as the result kind. 834e24f5f31STony 835e24f5f31STonyIf a result kind is specified, and the result of the evaluation does not match 836e24f5f31STonythe specified result kind, then the implicit conversions described in 837e24f5f31STony:ref:`amdgpu-dwarf-memory-location-description-operations` are performed if 838e24f5f31STonyvalid. Otherwise, the DWARF expression is ill-formed. 839e24f5f31STony 840e24f5f31STonyIf the evaluation of a DWARF expression encounters an evaluation error, then the 841e24f5f31STonyresult is an evaluation error. 842e24f5f31STony 843e24f5f31STony.. note:: 844e24f5f31STony 845e24f5f31STony Decided to define the concept of an evaluation error. An alternative is to 846e24f5f31STony introduce an undefined value base type in a similar way to location 847e24f5f31STony descriptions having an undefined location description. Then operations that 848e24f5f31STony encounter an evaluation error can return the undefined location description or 849e24f5f31STony value with an undefined base type. 850e24f5f31STony 851e24f5f31STony All operations that act on values would return an undefined entity if given an 852e24f5f31STony undefined value. The expression would then always evaluate to completion, and 853e24f5f31STony can be tested to determine if it is an undefined entity. 854e24f5f31STony 855e24f5f31STony However, this would add considerable additional complexity and does not match 856e24f5f31STony that GDB throws an exception when these evaluation errors occur. 857e24f5f31STony 858e24f5f31STonyIf a DWARF expression is ill-formed, then the result is undefined. 859e24f5f31STony 860e24f5f31STonyThe following sections detail the rules for when a DWARF expression is 861e24f5f31STonyill-formed or results in an evaluation error. 862e24f5f31STony 863e8fa9014SKazu HirataA DWARF expression can either be encoded as an operation expression (see 864e24f5f31STony:ref:`amdgpu-dwarf-operation-expressions`), or as a location list expression 865e24f5f31STony(see :ref:`amdgpu-dwarf-location-list-expressions`). 866e24f5f31STony 867e24f5f31STony.. _amdgpu-dwarf-expression-evaluation-context: 868e24f5f31STony 8690ac939f3STony TyeA.2.5.1 DWARF Expression Evaluation Context 8700ac939f3STony Tye+++++++++++++++++++++++++++++++++++++++++++ 871e24f5f31STony 872e24f5f31STonyA DWARF expression is evaluated in a context that can include a number of 873e24f5f31STonycontext elements. If multiple context elements are specified then they must be 874e24f5f31STonyself consistent or the result of the evaluation is undefined. The context 875e24f5f31STonyelements that can be specified are: 876e24f5f31STony 877e24f5f31STony*A current result kind* 878e24f5f31STony 879e24f5f31STony The kind of result required by the DWARF expression evaluation. If specified 880e24f5f31STony it can be a location description or a value. 881e24f5f31STony 882e24f5f31STony*A current thread* 883e24f5f31STony 8848ba5043dSTony Tye The target architecture thread identifier. For source languages that are not 8858ba5043dSTony Tye implemented using a SIMT execution model, this corresponds to the source 8868ba5043dSTony Tye program thread of execution for which a user presented expression is currently 8878ba5043dSTony Tye being evaluated. For source languages that are implemented using a SIMT 8888ba5043dSTony Tye execution model, this together with the current lane corresponds to the source 8898ba5043dSTony Tye program thread of execution for which a user presented expression is currently 8908ba5043dSTony Tye being evaluated. 891e24f5f31STony 892e24f5f31STony It is required for operations that are related to target architecture threads. 893e24f5f31STony 8940ac939f3STony Tye *For example, the* ``DW_OP_regval_type`` *operation, or the* 8950ac939f3STony Tye ``DW_OP_form_tls_address`` *and* ``DW_OP_LLVM_form_aspace_address`` 8968ba5043dSTony Tye *operations when given an address space that is target architecture thread 8978ba5043dSTony Tye specific.* 898e24f5f31STony 899e24f5f31STony*A current lane* 900e24f5f31STony 9018ba5043dSTony Tye The 0 based SIMT lane identifier to be used in evaluating a user presented 9028ba5043dSTony Tye expression. This applies to source languages that are implemented for a target 9038ba5043dSTony Tye architecture using a SIMT execution model. These implementations map source 9048ba5043dSTony Tye language threads of execution to lanes of the target architecture threads. 905e24f5f31STony 9068ba5043dSTony Tye It is required for operations that are related to SIMT lanes. 907e24f5f31STony 908e24f5f31STony *For example, the* ``DW_OP_LLVM_push_lane`` *operation and* 909e24f5f31STony ``DW_OP_LLVM_form_aspace_address`` *operation when given an address space that 9108ba5043dSTony Tye is SIMT lane specific.* 911e24f5f31STony 9128ba5043dSTony Tye If specified, it must be consistent with the value of the ``DW_AT_LLVM_lanes`` 9138ba5043dSTony Tye attribute of the subprogram corresponding to context's frame and program 9148ba5043dSTony Tye location. It is consistent if the value is greater than or equal to 0 and less 9158ba5043dSTony Tye than the, possibly default, value of the ``DW_AT_LLVM_lanes`` attribute. 9168ba5043dSTony Tye Otherwise the result is undefined. 9178ba5043dSTony Tye 9188ba5043dSTony Tye*A current iteration* 9198ba5043dSTony Tye 9208ba5043dSTony Tye The 0 based source language iteration instance to be used in evaluating a user 9218ba5043dSTony Tye presented expression. This applies to target architectures that support 9228ba5043dSTony Tye optimizations that result in executing multiple source language loop iterations 9238ba5043dSTony Tye concurrently. 9248ba5043dSTony Tye 9258ba5043dSTony Tye *For example, software pipelining and SIMD vectorization.* 9268ba5043dSTony Tye 9278ba5043dSTony Tye It is required for operations that are related to source language loop 9288ba5043dSTony Tye iterations. 9298ba5043dSTony Tye 9308ba5043dSTony Tye *For example, the* ``DW_OP_LLVM_push_iteration`` *operation.* 9318ba5043dSTony Tye 9328ba5043dSTony Tye If specified, it must be consistent with the value of the 9338ba5043dSTony Tye ``DW_AT_LLVM_iterations`` attribute of the subprogram corresponding to 9348ba5043dSTony Tye context's frame and program location. It is consistent if the value is greater 9358ba5043dSTony Tye than or equal to 0 and less than the, possibly default, value of the 9368ba5043dSTony Tye ``DW_AT_LLVM_iterations`` attribute. Otherwise the result is undefined. 937e24f5f31STony 938e24f5f31STony*A current call frame* 939e24f5f31STony 940e24f5f31STony The target architecture call frame identifier. It identifies a call frame that 941e24f5f31STony corresponds to an active invocation of a subprogram in the current thread. It 942e24f5f31STony is identified by its address on the call stack. The address is referred to as 943e24f5f31STony the Canonical Frame Address (CFA). The call frame information is used to 944e24f5f31STony determine the CFA for the call frames of the current thread's call stack (see 945e24f5f31STony :ref:`amdgpu-dwarf-call-frame-information`). 946e24f5f31STony 947e24f5f31STony It is required for operations that specify target architecture registers to 948e24f5f31STony support virtual unwinding of the call stack. 949e24f5f31STony 950e24f5f31STony *For example, the* ``DW_OP_*reg*`` *operations.* 951e24f5f31STony 952e24f5f31STony If specified, it must be an active call frame in the current thread. If the 953e24f5f31STony current lane is specified, then that lane must have been active on entry to 954e24f5f31STony the call frame (see the ``DW_AT_LLVM_lane_pc`` attribute). Otherwise the 955e24f5f31STony result is undefined. 956e24f5f31STony 957e24f5f31STony If it is the currently executing call frame, then it is termed the top call 958e24f5f31STony frame. 959e24f5f31STony 960e24f5f31STony*A current program location* 961e24f5f31STony 962e24f5f31STony The target architecture program location corresponding to the current call 963e24f5f31STony frame of the current thread. 964e24f5f31STony 965e24f5f31STony The program location of the top call frame is the target architecture program 966e24f5f31STony counter for the current thread. The call frame information is used to obtain 967e24f5f31STony the value of the return address register to determine the program location of 968e24f5f31STony the other call frames (see :ref:`amdgpu-dwarf-call-frame-information`). 969e24f5f31STony 970e24f5f31STony It is required for the evaluation of location list expressions to select 971e24f5f31STony amongst multiple program location ranges. It is required for operations that 972e24f5f31STony specify target architecture registers to support virtual unwinding of the call 973e24f5f31STony stack (see :ref:`amdgpu-dwarf-call-frame-information`). 974e24f5f31STony 975e24f5f31STony If specified: 976e24f5f31STony 977e24f5f31STony * If the current lane is not specified: 978e24f5f31STony 979e24f5f31STony * If the current call frame is the top call frame, it must be the current 980e24f5f31STony target architecture program location. 981e24f5f31STony 982e24f5f31STony * If the current call frame F is not the top call frame, it must be the 983e24f5f31STony program location associated with the call site in the current caller frame 984e24f5f31STony F that invoked the callee frame. 985e24f5f31STony 986e24f5f31STony * If the current lane is specified and the architecture program location LPC 987e24f5f31STony computed by the ``DW_AT_LLVM_lane_pc`` attribute for the current lane is not 988e24f5f31STony the undefined location description (indicating the lane was not active on 989e24f5f31STony entry to the call frame), it must be LPC. 990e24f5f31STony 991e24f5f31STony * Otherwise the result is undefined. 992e24f5f31STony 993e24f5f31STony*A current compilation unit* 994e24f5f31STony 995e24f5f31STony The compilation unit debug information entry that contains the DWARF expression 996e24f5f31STony being evaluated. 997e24f5f31STony 998e24f5f31STony It is required for operations that reference debug information associated with 999e24f5f31STony the same compilation unit, including indicating if such references use the 1000e24f5f31STony 32-bit or 64-bit DWARF format. It can also provide the default address space 1001e24f5f31STony address size if no current target architecture is specified. 1002e24f5f31STony 1003e24f5f31STony *For example, the* ``DW_OP_constx`` *and* ``DW_OP_addrx`` *operations.* 1004e24f5f31STony 1005e24f5f31STony *Note that this compilation unit may not be the same as the compilation unit 1006e24f5f31STony determined from the loaded code object corresponding to the current program 10070ac939f3STony Tye location. For example, the evaluation of the expression E associated with a* 10080ac939f3STony Tye ``DW_AT_location`` *attribute of the debug information entry operand of the* 10090ac939f3STony Tye ``DW_OP_call*`` *operations is evaluated with the compilation unit that 10100ac939f3STony Tye contains E and not the one that contains the* ``DW_OP_call*`` *operation 1011e24f5f31STony expression.* 1012e24f5f31STony 1013e24f5f31STony*A current target architecture* 1014e24f5f31STony 1015e24f5f31STony The target architecture. 1016e24f5f31STony 1017e24f5f31STony It is required for operations that specify target architecture specific 1018e24f5f31STony entities. 1019e24f5f31STony 1020e24f5f31STony *For example, target architecture specific entities include DWARF register 1021e24f5f31STony identifiers, DWARF lane identifiers, DWARF address space identifiers, the 1022e24f5f31STony default address space, and the address space address sizes.* 1023e24f5f31STony 1024e24f5f31STony If specified: 1025e24f5f31STony 1026817f64e7STony Tye * If the current frame is specified, then the current target architecture must 1027817f64e7STony Tye be the same as the target architecture of the current frame. 1028817f64e7STony Tye 1029817f64e7STony Tye * If the current frame is specified and is the top frame, and if the current 1030817f64e7STony Tye thread is specified, then the current target architecture must be the same 1031817f64e7STony Tye as the target architecture of the current thread. 1032e24f5f31STony 1033e24f5f31STony * If the current compilation unit is specified, then the current target 10340ac939f3STony Tye architecture default address space address size must be the same as the 1035e24f5f31STony ``address_size`` field in the header of the current compilation unit and any 1036e24f5f31STony associated entry in the ``.debug_aranges`` section. 1037e24f5f31STony 1038e24f5f31STony * If the current program location is specified, then the current target 1039e24f5f31STony architecture must be the same as the target architecture of any line number 1040e24f5f31STony information entry (see :ref:`amdgpu-dwarf-line-number-information`) 1041e24f5f31STony corresponding to the current program location. 1042e24f5f31STony 1043e24f5f31STony * If the current program location is specified, then the current target 10440ac939f3STony Tye architecture default address space address size must be the same as the 1045e24f5f31STony ``address_size`` field in the header of any entry corresponding to the 1046e24f5f31STony current program location in the ``.debug_addr``, ``.debug_line``, 1047e24f5f31STony ``.debug_rnglists``, ``.debug_rnglists.dwo``, ``.debug_loclists``, and 1048e24f5f31STony ``.debug_loclists.dwo`` sections. 1049e24f5f31STony 1050e24f5f31STony * Otherwise the result is undefined. 1051e24f5f31STony 1052e24f5f31STony*A current object* 1053e24f5f31STony 1054e24f5f31STony The location description of a program object. 1055e24f5f31STony 1056e24f5f31STony It is required for the ``DW_OP_push_object_address`` operation. 1057e24f5f31STony 1058e24f5f31STony *For example, the* ``DW_AT_data_location`` *attribute on type debug 10590ac939f3STony Tye information entries specifies the program object corresponding to a runtime 10600ac939f3STony Tye descriptor as the current object when it evaluates its associated expression.* 1061e24f5f31STony 1062817f64e7STony Tye The result is undefined if the location description is invalid (see 1063e24f5f31STony :ref:`amdgpu-dwarf-location-description`). 1064e24f5f31STony 1065e24f5f31STony*An initial stack* 1066e24f5f31STony 1067e24f5f31STony This is a list of values or location descriptions that will be pushed on the 1068e24f5f31STony operation expression evaluation stack in the order provided before evaluation 1069e24f5f31STony of an operation expression starts. 1070e24f5f31STony 1071e24f5f31STony Some debugger information entries have attributes that evaluate their DWARF 1072e24f5f31STony expression value with initial stack entries. In all other cases the initial 1073e24f5f31STony stack is empty. 1074e24f5f31STony 1075817f64e7STony Tye The result is undefined if any location descriptions are invalid (see 1076e24f5f31STony :ref:`amdgpu-dwarf-location-description`). 1077e24f5f31STony 1078e24f5f31STonyIf the evaluation requires a context element that is not specified, then the 1079e24f5f31STonyresult of the evaluation is an error. 1080e24f5f31STony 10810ac939f3STony Tye*A DWARF expression for a location description may be able to be evaluated 1082e24f5f31STonywithout a thread, lane, call frame, program location, or architecture context. 1083e24f5f31STonyFor example, the location of a global variable may be able to be evaluated 1084e24f5f31STonywithout such context. If the expression evaluates with an error then it may 1085e24f5f31STonyindicate the variable has been optimized and so requires more context.* 1086e24f5f31STony 10873138fda3STony Tye*The DWARF expression for call frame information (see* 10883138fda3STony Tye:ref:`amdgpu-dwarf-call-frame-information`\ *) operations are restricted to 10893138fda3STony Tyethose that do not require the compilation unit context to be specified.* 1090e24f5f31STony 1091e24f5f31STonyThe DWARF is ill-formed if all the ``address_size`` fields in the headers of all 1092e24f5f31STonythe entries in the ``.debug_info``, ``.debug_addr``, ``.debug_line``, 1093e24f5f31STony``.debug_rnglists``, ``.debug_rnglists.dwo``, ``.debug_loclists``, and 1094e24f5f31STony``.debug_loclists.dwo`` sections corresponding to any given program location do 1095e24f5f31STonynot match. 1096e24f5f31STony 1097e24f5f31STony.. _amdgpu-dwarf-expression-value: 1098e24f5f31STony 10990ac939f3STony TyeA.2.5.2 DWARF Expression Value 11000ac939f3STony Tye++++++++++++++++++++++++++++++ 1101e24f5f31STony 1102e24f5f31STonyA value has a type and a literal value. It can represent a literal value of any 1103f79bab3fSTonysupported base type of the target architecture. The base type specifies the 1104f79bab3fSTonysize, encoding, and endianity of the literal value. 1105e24f5f31STony 1106e24f5f31STony.. note:: 1107e24f5f31STony 1108e24f5f31STony It may be desirable to add an implicit pointer base type encoding. It would be 1109e24f5f31STony used for the type of the value that is produced when the ``DW_OP_deref*`` 1110e24f5f31STony operation retrieves the full contents of an implicit pointer location storage 1111e24f5f31STony created by the ``DW_OP_implicit_pointer`` or 1112e24f5f31STony ``DW_OP_LLVM_aspace_implicit_pointer`` operations. The literal value would 1113e24f5f31STony record the debugging information entry and byte displacement specified by the 1114e24f5f31STony associated ``DW_OP_implicit_pointer`` or 1115e24f5f31STony ``DW_OP_LLVM_aspace_implicit_pointer`` operations. 1116e24f5f31STony 1117e24f5f31STonyThere is a distinguished base type termed the generic type, which is an integral 1118e24f5f31STonytype that has the size of an address in the target architecture default address 1119ca602a72STonyspace, a target architecture defined endianity, and unspecified signedness. 1120e24f5f31STony 1121e24f5f31STony*The generic type is the same as the unspecified type used for stack operations 1122e24f5f31STonydefined in DWARF Version 4 and before.* 1123e24f5f31STony 1124e24f5f31STonyAn integral type is a base type that has an encoding of ``DW_ATE_signed``, 1125e24f5f31STony``DW_ATE_signed_char``, ``DW_ATE_unsigned``, ``DW_ATE_unsigned_char``, 1126e24f5f31STony``DW_ATE_boolean``, or any target architecture defined integral encoding in the 1127e24f5f31STonyinclusive range ``DW_ATE_lo_user`` to ``DW_ATE_hi_user``. 1128e24f5f31STony 1129e24f5f31STony.. note:: 1130e24f5f31STony 1131e24f5f31STony It is unclear if ``DW_ATE_address`` is an integral type. GDB does not seem to 1132e24f5f31STony consider it as integral. 1133e24f5f31STony 1134e24f5f31STony.. _amdgpu-dwarf-location-description: 1135e24f5f31STony 11360ac939f3STony TyeA.2.5.3 DWARF Location Description 11370ac939f3STony Tye++++++++++++++++++++++++++++++++++ 1138e24f5f31STony 1139e24f5f31STony*Debugging information must provide consumers a way to find the location of 1140e24f5f31STonyprogram variables, determine the bounds of dynamic arrays and strings, and 1141e24f5f31STonypossibly to find the base address of a subprogram’s call frame or the return 1142e24f5f31STonyaddress of a subprogram. Furthermore, to meet the needs of recent computer 1143e24f5f31STonyarchitectures and optimization techniques, debugging information must be able to 1144e24f5f31STonydescribe the location of an object whose location changes over the object’s 1145e24f5f31STonylifetime, and may reside at multiple locations simultaneously during parts of an 1146e24f5f31STonyobject's lifetime.* 1147e24f5f31STony 1148e24f5f31STonyInformation about the location of program objects is provided by location 1149e24f5f31STonydescriptions. 1150e24f5f31STony 1151e24f5f31STonyLocation descriptions can consist of one or more single location descriptions. 1152e24f5f31STony 1153e24f5f31STonyA single location description specifies the location storage that holds a 1154e24f5f31STonyprogram object and a position within the location storage where the program 1155e24f5f31STonyobject starts. The position within the location storage is expressed as a bit 1156e24f5f31STonyoffset relative to the start of the location storage. 1157e24f5f31STony 1158e24f5f31STonyA location storage is a linear stream of bits that can hold values. Each 1159e24f5f31STonylocation storage has a size in bits and can be accessed using a zero-based bit 1160e24f5f31STonyoffset. The ordering of bits within a location storage uses the bit numbering 1161e24f5f31STonyand direction conventions that are appropriate to the current language on the 1162e24f5f31STonytarget architecture. 1163e24f5f31STony 1164e24f5f31STonyThere are five kinds of location storage: 1165e24f5f31STony 1166e24f5f31STony*memory location storage* 1167e24f5f31STony Corresponds to the target architecture memory address spaces. 1168e24f5f31STony 1169e24f5f31STony*register location storage* 1170e24f5f31STony Corresponds to the target architecture registers. 1171e24f5f31STony 1172e24f5f31STony*implicit location storage* 1173e24f5f31STony Corresponds to fixed values that can only be read. 1174e24f5f31STony 1175e24f5f31STony*undefined location storage* 1176e24f5f31STony Indicates no value is available and therefore cannot be read or written. 1177e24f5f31STony 1178e24f5f31STony*composite location storage* 1179e24f5f31STony Allows a mixture of these where some bits come from one location storage and 1180e24f5f31STony some from another location storage, or from disjoint parts of the same 1181e24f5f31STony location storage. 1182e24f5f31STony 1183e24f5f31STony.. note:: 1184e24f5f31STony 1185e24f5f31STony It may be better to add an implicit pointer location storage kind used by the 1186e24f5f31STony ``DW_OP_implicit_pointer`` and ``DW_OP_LLVM_aspace_implicit_pointer`` 1187e24f5f31STony operations. It would specify the debugger information entry and byte offset 1188e24f5f31STony provided by the operations. 1189e24f5f31STony 1190e24f5f31STony*Location descriptions are a language independent representation of addressing 11910ac939f3STony Tyerules.* 11920ac939f3STony Tye 11930ac939f3STony Tye* *They can be the result of evaluating a debugger information entry attribute 11940ac939f3STony Tye that specifies an operation expression of arbitrary complexity. In this usage 11950ac939f3STony Tye they can describe the location of an object as long as its lifetime is either 11960ac939f3STony Tye static or the same as the lexical block (see 11970ac939f3STony Tye :ref:`amdgpu-dwarf-lexical-block-entries`) that owns it, and it does not move 11980ac939f3STony Tye during its lifetime.* 11990ac939f3STony Tye 12000ac939f3STony Tye* *They can be the result of evaluating a debugger information entry attribute 12010ac939f3STony Tye that specifies a location list expression. In this usage they can describe the 12020ac939f3STony Tye location of an object that has a limited lifetime, changes its location during 12030ac939f3STony Tye its lifetime, or has multiple locations over part or all of its lifetime.* 1204e24f5f31STony 1205e24f5f31STonyIf a location description has more than one single location description, the 1206e24f5f31STonyDWARF expression is ill-formed if the object value held in each single location 1207e24f5f31STonydescription's position within the associated location storage is not the same 1208e24f5f31STonyvalue, except for the parts of the value that are uninitialized. 1209e24f5f31STony 1210e24f5f31STony*A location description that has more than one single location description can 1211e24f5f31STonyonly be created by a location list expression that has overlapping program 1212e24f5f31STonylocation ranges, or certain expression operations that act on a location 1213e24f5f31STonydescription that has more than one single location description. There are no 1214e24f5f31STonyoperation expression operations that can directly create a location description 1215e24f5f31STonywith more than one single location description.* 1216e24f5f31STony 1217e24f5f31STony*A location description with more than one single location description can be 1218e24f5f31STonyused to describe objects that reside in more than one piece of storage at the 1219e24f5f31STonysame time. An object may have more than one location as a result of 1220e24f5f31STonyoptimization. For example, a value that is only read may be promoted from memory 1221e24f5f31STonyto a register for some region of code, but later code may revert to reading the 1222e24f5f31STonyvalue from memory as the register may be used for other purposes. For the code 1223e24f5f31STonyregion where the value is in a register, any change to the object value must be 1224e24f5f31STonymade in both the register and the memory so both regions of code will read the 1225e24f5f31STonyupdated value.* 1226e24f5f31STony 1227e24f5f31STony*A consumer of a location description with more than one single location 1228e24f5f31STonydescription can read the object's value from any of the single location 1229e24f5f31STonydescriptions (since they all refer to location storage that has the same value), 1230e24f5f31STonybut must write any changed value to all the single location descriptions.* 1231e24f5f31STony 1232e24f5f31STonyThe evaluation of an expression may require context elements to create a 1233e24f5f31STonylocation description. If such a location description is accessed, the storage it 1234e24f5f31STonydenotes is that associated with the context element values specified when the 1235e24f5f31STonylocation description was created, which may differ from the context at the time 1236e24f5f31STonyit is accessed. 1237e24f5f31STony 1238e24f5f31STony*For example, creating a register location description requires the thread 1239e24f5f31STonycontext: the location storage is for the specified register of that thread. 1240e24f5f31STonyCreating a memory location description for an address space may required a 1241e24f5f31STonythread and a lane context: the location storage is the memory associated with 1242e24f5f31STonythat thread and lane.* 1243e24f5f31STony 1244e24f5f31STonyIf any of the context elements required to create a location description change, 1245e24f5f31STonythe location description becomes invalid and accessing it is undefined. 1246e24f5f31STony 1247e24f5f31STony*Examples of context that can invalidate a location description are:* 1248e24f5f31STony 1249e24f5f31STony* *The thread context is required and execution causes the thread to terminate.* 1250e24f5f31STony* *The call frame context is required and further execution causes the call 1251e24f5f31STony frame to return to the calling frame.* 1252e24f5f31STony* *The program location is required and further execution of the thread occurs. 1253e24f5f31STony That could change the location list entry or call frame information entry that 1254e24f5f31STony applies.* 1255e24f5f31STony* *An operation uses call frame information:* 1256e24f5f31STony 1257e24f5f31STony * *Any of the frames used in the virtual call frame unwinding return.* 1258e24f5f31STony * *The top call frame is used, the program location is used to select the call 1259e24f5f31STony frame information entry, and further execution of the thread occurs.* 1260e24f5f31STony 1261e24f5f31STony*A DWARF expression can be used to compute a location description for an object. 1262e24f5f31STonyA subsequent DWARF expression evaluation can be given the object location 1263e24f5f31STonydescription as the object context or initial stack context to compute a 1264e24f5f31STonycomponent of the object. The final result is undefined if the object location 1265e24f5f31STonydescription becomes invalid between the two expression evaluations.* 1266e24f5f31STony 1267e24f5f31STonyA change of a thread's program location may not make a location description 1268e24f5f31STonyinvalid, yet may still render it as no longer meaningful. Accessing such a 1269e24f5f31STonylocation description, or using it as the object context or initial stack context 1270e24f5f31STonyof an expression evaluation, may produce an undefined result. 1271e24f5f31STony 1272e24f5f31STony*For example, a location description may specify a register that no longer holds 1273e24f5f31STonythe intended program object after a program location change. One way to avoid 1274e24f5f31STonysuch problems is to recompute location descriptions associated with threads when 1275e24f5f31STonytheir program locations change.* 1276e24f5f31STony 1277e24f5f31STony.. _amdgpu-dwarf-operation-expressions: 1278e24f5f31STony 12790ac939f3STony TyeA.2.5.4 DWARF Operation Expressions 12800ac939f3STony Tye+++++++++++++++++++++++++++++++++++ 1281e24f5f31STony 1282e24f5f31STonyAn operation expression is comprised of a stream of operations, each consisting 1283e24f5f31STonyof an opcode followed by zero or more operands. The number of operands is 1284e24f5f31STonyimplied by the opcode. 1285e24f5f31STony 1286e24f5f31STonyOperations represent a postfix operation on a simple stack machine. Each stack 1287e24f5f31STonyentry can hold either a value or a location description. Operations can act on 1288e24f5f31STonyentries on the stack, including adding entries and removing entries. If the kind 1289e24f5f31STonyof a stack entry does not match the kind required by the operation and is not 1290e24f5f31STonyimplicitly convertible to the required kind (see 1291e24f5f31STony:ref:`amdgpu-dwarf-memory-location-description-operations`), then the DWARF 1292e24f5f31STonyoperation expression is ill-formed. 1293e24f5f31STony 1294e24f5f31STonyEvaluation of an operation expression starts with an empty stack on which the 1295e24f5f31STonyentries from the initial stack provided by the context are pushed in the order 1296e24f5f31STonyprovided. Then the operations are evaluated, starting with the first operation 1297e24f5f31STonyof the stream. Evaluation continues until either an operation has an evaluation 1298e24f5f31STonyerror, or until one past the last operation of the stream is reached. 1299e24f5f31STony 1300e24f5f31STonyThe result of the evaluation is: 1301e24f5f31STony 1302e24f5f31STony* If an operation has an evaluation error, or an operation evaluates an 1303e24f5f31STony expression that has an evaluation error, then the result is an evaluation 1304e24f5f31STony error. 1305e24f5f31STony 1306e24f5f31STony* If the current result kind specifies a location description, then: 1307e24f5f31STony 1308e24f5f31STony * If the stack is empty, the result is a location description with one 1309e24f5f31STony undefined location description. 1310e24f5f31STony 1311e24f5f31STony *This rule is for backwards compatibility with DWARF Version 5 which has no 1312e24f5f31STony explicit operation to create an undefined location description, and uses an 1313e24f5f31STony empty operation expression for this purpose.* 1314e24f5f31STony 1315e24f5f31STony * If the top stack entry is a location description, or can be converted 1316e24f5f31STony to one (see :ref:`amdgpu-dwarf-memory-location-description-operations`), 1317e24f5f31STony then the result is that, possibly converted, location description. Any other 1318e24f5f31STony entries on the stack are discarded. 1319e24f5f31STony 1320e24f5f31STony * Otherwise the DWARF expression is ill-formed. 1321e24f5f31STony 1322e24f5f31STony .. note:: 1323e24f5f31STony 1324e24f5f31STony Could define this case as returning an implicit location description as 1325e24f5f31STony if the ``DW_OP_implicit`` operation is performed. 1326e24f5f31STony 1327e24f5f31STony* If the current result kind specifies a value, then: 1328e24f5f31STony 1329e24f5f31STony * If the top stack entry is a value, or can be converted to one (see 1330e24f5f31STony :ref:`amdgpu-dwarf-memory-location-description-operations`), then the result 1331e24f5f31STony is that, possibly converted, value. Any other entries on the stack are 1332e24f5f31STony discarded. 1333e24f5f31STony 1334e24f5f31STony * Otherwise the DWARF expression is ill-formed. 1335e24f5f31STony 1336e24f5f31STony* If the current result kind is not specified, then: 1337e24f5f31STony 1338e24f5f31STony * If the stack is empty, the result is a location description with one 1339e24f5f31STony undefined location description. 1340e24f5f31STony 1341e24f5f31STony *This rule is for backwards compatibility with DWARF Version 5 which has no 1342e24f5f31STony explicit operation to create an undefined location description, and uses an 1343e24f5f31STony empty operation expression for this purpose.* 1344e24f5f31STony 1345e24f5f31STony .. note:: 1346e24f5f31STony 1347e24f5f31STony This rule is consistent with the rule above for when a location 1348e24f5f31STony description is requested. However, GDB appears to report this as an error 1349e24f5f31STony and no GDB tests appear to cause an empty stack for this case. 1350e24f5f31STony 1351e24f5f31STony * Otherwise, the top stack entry is returned. Any other entries on the stack 1352e24f5f31STony are discarded. 1353e24f5f31STony 1354e24f5f31STonyAn operation expression is encoded as a byte block with some form of prefix that 1355e24f5f31STonyspecifies the byte count. It can be used: 1356e24f5f31STony 1357e24f5f31STony* as the value of a debugging information entry attribute that is encoded using 13580ac939f3STony Tye class ``exprloc`` (see :ref:`amdgpu-dwarf-classes-and-forms`), 1359e24f5f31STony 1360e24f5f31STony* as the operand to certain operation expression operations, 1361e24f5f31STony 1362e24f5f31STony* as the operand to certain call frame information operations (see 1363e24f5f31STony :ref:`amdgpu-dwarf-call-frame-information`), 1364e24f5f31STony 1365e24f5f31STony* and in location list entries (see 1366e24f5f31STony :ref:`amdgpu-dwarf-location-list-expressions`). 1367e24f5f31STony 1368a4fb7f60SScott Linder.. _amdgpu-dwarf-vendor-extensions-operations: 1369a4fb7f60SScott Linder 1370a4fb7f60SScott LinderA.2.5.4.0 Vendor Extension Operations 1371a4fb7f60SScott Linder##################################### 1372a4fb7f60SScott Linder 1373a4fb7f60SScott Linder1. ``DW_OP_LLVM_user`` 1374a4fb7f60SScott Linder 1375a4fb7f60SScott Linder ``DW_OP_LLVM_user`` encodes a vendor extension operation. It has at least one 1376a4fb7f60SScott Linder operand: a ULEB128 constant identifying a vendor extension operation. The 1377a4fb7f60SScott Linder remaining operands are defined by the vendor extension. The vendor extension 1378a4fb7f60SScott Linder opcode 0 is reserved and cannot be used by any vendor extension. 1379a4fb7f60SScott Linder 1380a4fb7f60SScott Linder *The DW_OP_user encoding space can be understood to supplement the space 1381a4fb7f60SScott Linder defined by DW_OP_lo_user and DW_OP_hi_user that is allocated by the standard 1382a4fb7f60SScott Linder for the same purpose.* 1383a4fb7f60SScott Linder 1384e24f5f31STony.. _amdgpu-dwarf-stack-operations: 1385e24f5f31STony 13860ac939f3STony TyeA.2.5.4.1 Stack Operations 13870ac939f3STony Tye########################## 13880ac939f3STony Tye 13890ac939f3STony Tye.. note:: 13900ac939f3STony Tye 13910ac939f3STony Tye This section replaces DWARF Version 5 section 2.5.1.3. 1392e24f5f31STony 1393e24f5f31STonyThe following operations manipulate the DWARF stack. Operations that index the 1394e24f5f31STonystack assume that the top of the stack (most recently added entry) has index 0. 1395e24f5f31STonyThey allow the stack entries to be either a value or location description. 1396e24f5f31STony 1397e24f5f31STonyIf any stack entry accessed by a stack operation is an incomplete composite 1398e24f5f31STonylocation description (see 1399e24f5f31STony:ref:`amdgpu-dwarf-composite-location-description-operations`), then the DWARF 1400e24f5f31STonyexpression is ill-formed. 1401e24f5f31STony 1402e24f5f31STony.. note:: 1403e24f5f31STony 1404e24f5f31STony These operations now support stack entries that are values and location 1405e24f5f31STony descriptions. 1406e24f5f31STony 1407e24f5f31STony.. note:: 1408e24f5f31STony 1409e24f5f31STony If it is desired to also make them work with incomplete composite location 1410e24f5f31STony descriptions, then would need to define that the composite location storage 1411e24f5f31STony specified by the incomplete composite location description is also replicated 1412e24f5f31STony when a copy is pushed. This ensures that each copy of the incomplete composite 1413e24f5f31STony location description can update the composite location storage they specify 1414e24f5f31STony independently. 1415e24f5f31STony 1416e24f5f31STony1. ``DW_OP_dup`` 1417e24f5f31STony 1418e24f5f31STony ``DW_OP_dup`` duplicates the stack entry at the top of the stack. 1419e24f5f31STony 1420e24f5f31STony2. ``DW_OP_drop`` 1421e24f5f31STony 1422e24f5f31STony ``DW_OP_drop`` pops the stack entry at the top of the stack and discards it. 1423e24f5f31STony 1424e24f5f31STony3. ``DW_OP_pick`` 1425e24f5f31STony 1426e24f5f31STony ``DW_OP_pick`` has a single unsigned 1-byte operand that represents an index 1427e24f5f31STony I. A copy of the stack entry with index I is pushed onto the stack. 1428e24f5f31STony 1429e24f5f31STony4. ``DW_OP_over`` 1430e24f5f31STony 1431e24f5f31STony ``DW_OP_over`` pushes a copy of the entry with index 1. 1432e24f5f31STony 14330ac939f3STony Tye *This is equivalent to a* ``DW_OP_pick 1`` *operation.* 1434e24f5f31STony 1435e24f5f31STony5. ``DW_OP_swap`` 1436e24f5f31STony 1437e24f5f31STony ``DW_OP_swap`` swaps the top two stack entries. The entry at the top of the 1438e24f5f31STony stack becomes the second stack entry, and the second stack entry becomes the 1439e24f5f31STony top of the stack. 1440e24f5f31STony 1441e24f5f31STony6. ``DW_OP_rot`` 1442e24f5f31STony 1443e24f5f31STony ``DW_OP_rot`` rotates the first three stack entries. The entry at the top of 1444e24f5f31STony the stack becomes the third stack entry, the second entry becomes the top of 1445e24f5f31STony the stack, and the third entry becomes the second entry. 1446e24f5f31STony 14473138fda3STony Tye*Examples illustrating many of these stack operations are found in Appendix 14483138fda3STony TyeD.1.2 on page 289.* 14493138fda3STony Tye 1450e24f5f31STony.. _amdgpu-dwarf-control-flow-operations: 1451e24f5f31STony 14520ac939f3STony TyeA.2.5.4.2 Control Flow Operations 14530ac939f3STony Tye################################# 14540ac939f3STony Tye 14550ac939f3STony Tye.. note:: 14560ac939f3STony Tye 14570ac939f3STony Tye This section replaces DWARF Version 5 section 2.5.1.5. 1458e24f5f31STony 1459e24f5f31STonyThe following operations provide simple control of the flow of a DWARF operation 1460e24f5f31STonyexpression. 1461e24f5f31STony 1462e24f5f31STony1. ``DW_OP_nop`` 1463e24f5f31STony 1464e24f5f31STony ``DW_OP_nop`` is a place holder. It has no effect on the DWARF stack 1465e24f5f31STony entries. 1466e24f5f31STony 1467e24f5f31STony2. ``DW_OP_le``, ``DW_OP_ge``, ``DW_OP_eq``, ``DW_OP_lt``, ``DW_OP_gt``, 1468e24f5f31STony ``DW_OP_ne`` 1469e24f5f31STony 1470e24f5f31STony .. note:: 1471e24f5f31STony 1472e24f5f31STony The same as in DWARF Version 5 section 2.5.1.5. 1473e24f5f31STony 1474e24f5f31STony3. ``DW_OP_skip`` 1475e24f5f31STony 1476e24f5f31STony ``DW_OP_skip`` is an unconditional branch. Its single operand is a 2-byte 1477e24f5f31STony signed integer constant. The 2-byte constant is the number of bytes of the 1478e24f5f31STony DWARF expression to skip forward or backward from the current operation, 1479e24f5f31STony beginning after the 2-byte constant. 1480e24f5f31STony 1481e24f5f31STony If the updated position is at one past the end of the last operation, then 1482e24f5f31STony the operation expression evaluation is complete. 1483e24f5f31STony 1484e24f5f31STony Otherwise, the DWARF expression is ill-formed if the updated operation 1485e24f5f31STony position is not in the range of the first to last operation inclusive, or 1486e24f5f31STony not at the start of an operation. 1487e24f5f31STony 1488e24f5f31STony4. ``DW_OP_bra`` 1489e24f5f31STony 1490e24f5f31STony ``DW_OP_bra`` is a conditional branch. Its single operand is a 2-byte signed 1491e24f5f31STony integer constant. This operation pops the top of stack. If the value popped 1492e24f5f31STony is not the constant 0, the 2-byte constant operand is the number of bytes of 1493e24f5f31STony the DWARF operation expression to skip forward or backward from the current 1494e24f5f31STony operation, beginning after the 2-byte constant. 1495e24f5f31STony 1496e24f5f31STony If the updated position is at one past the end of the last operation, then 1497e24f5f31STony the operation expression evaluation is complete. 1498e24f5f31STony 1499e24f5f31STony Otherwise, the DWARF expression is ill-formed if the updated operation 1500e24f5f31STony position is not in the range of the first to last operation inclusive, or 1501e24f5f31STony not at the start of an operation. 1502e24f5f31STony 1503e24f5f31STony5. ``DW_OP_call2, DW_OP_call4, DW_OP_call_ref`` 1504e24f5f31STony 1505e24f5f31STony ``DW_OP_call2``, ``DW_OP_call4``, and ``DW_OP_call_ref`` perform DWARF 1506817f64e7STony Tye procedure calls during evaluation of a DWARF operation expression. 1507e24f5f31STony 1508e24f5f31STony ``DW_OP_call2`` and ``DW_OP_call4``, have one operand that is, respectively, 1509e24f5f31STony a 2-byte or 4-byte unsigned offset DR that represents the byte offset of a 1510e24f5f31STony debugging information entry D relative to the beginning of the current 1511e24f5f31STony compilation unit. 1512e24f5f31STony 1513e24f5f31STony ``DW_OP_call_ref`` has one operand that is a 4-byte unsigned value in the 1514e24f5f31STony 32-bit DWARF format, or an 8-byte unsigned value in the 64-bit DWARF format, 1515e24f5f31STony that represents the byte offset DR of a debugging information entry D 1516e24f5f31STony relative to the beginning of the ``.debug_info`` section that contains the 1517e24f5f31STony current compilation unit. D may not be in the current compilation unit. 1518e24f5f31STony 15190ac939f3STony Tye .. note:: 1520e24f5f31STony 1521e24f5f31STony DWARF Version 5 states that DR can be an offset in a ``.debug_info`` 1522e24f5f31STony section other than the one that contains the current compilation unit. It 1523e24f5f31STony states that relocation of references from one executable or shared object 1524e24f5f31STony file to another must be performed by the consumer. But given that DR is 1525e24f5f31STony defined as an offset in a ``.debug_info`` section this seems impossible. 1526e24f5f31STony If DR was defined as an implementation defined value, then the consumer 1527e24f5f31STony could choose to interpret the value in an implementation defined manner to 1528e24f5f31STony reference a debug information in another executable or shared object. 1529e24f5f31STony 1530e24f5f31STony In ELF the ``.debug_info`` section is in a non-\ ``PT_LOAD`` segment so 1531e24f5f31STony standard dynamic relocations cannot be used. But even if they were loaded 1532e24f5f31STony segments and dynamic relocations were used, DR would need to be the 1533e24f5f31STony address of D, not an offset in a ``.debug_info`` section. That would also 1534e24f5f31STony need DR to be the size of a global address. So it would not be possible to 1535e24f5f31STony use the 32-bit DWARF format in a 64-bit global address space. In addition, 1536e24f5f31STony the consumer would need to determine what executable or shared object the 1537e24f5f31STony relocated address was in so it could determine the containing compilation 1538e24f5f31STony unit. 1539e24f5f31STony 1540e24f5f31STony GDB only interprets DR as an offset in the ``.debug_info`` section that 1541e24f5f31STony contains the current compilation unit. 1542e24f5f31STony 1543e24f5f31STony This comment also applies to ``DW_OP_implicit_pointer`` and 1544e24f5f31STony ``DW_OP_LLVM_aspace_implicit_pointer``. 1545e24f5f31STony 1546e24f5f31STony *Operand interpretation of* ``DW_OP_call2``\ *,* ``DW_OP_call4``\ *, and* 1547e24f5f31STony ``DW_OP_call_ref`` *is exactly like that for* ``DW_FORM_ref2``\ *, 1548e24f5f31STony ``DW_FORM_ref4``\ *, and* ``DW_FORM_ref_addr``\ *, respectively.* 1549e24f5f31STony 1550e24f5f31STony The call operation is evaluated by: 1551e24f5f31STony 1552e24f5f31STony * If D has a ``DW_AT_location`` attribute that is encoded as a ``exprloc`` 1553e24f5f31STony that specifies an operation expression E, then execution of the current 1554e24f5f31STony operation expression continues from the first operation of E. Execution 1555e24f5f31STony continues until one past the last operation of E is reached, at which 1556e24f5f31STony point execution continues with the operation following the call operation. 1557e24f5f31STony The operations of E are evaluated with the same current context, except 1558e24f5f31STony current compilation unit is the one that contains D and the stack is the 1559e24f5f31STony same as that being used by the call operation. After the call operation 1560e24f5f31STony has been evaluated, the stack is therefore as it is left by the evaluation 1561e24f5f31STony of the operations of E. Since E is evaluated on the same stack as the call 1562e24f5f31STony operation, E can use, and/or remove entries already on the stack, and can 1563e24f5f31STony add new entries to the stack. 1564e24f5f31STony 1565e24f5f31STony *Values on the stack at the time of the call may be used as parameters by 1566e24f5f31STony the called expression and values left on the stack by the called expression 1567e24f5f31STony may be used as return values by prior agreement between the calling and 1568e24f5f31STony called expressions.* 1569e24f5f31STony 1570e24f5f31STony * If D has a ``DW_AT_location`` attribute that is encoded as a ``loclist`` or 1571e24f5f31STony ``loclistsptr``, then the specified location list expression E is 1572e24f5f31STony evaluated. The evaluation of E uses the current context, except the result 1573e24f5f31STony kind is a location description, the compilation unit is the one that 1574e24f5f31STony contains D, and the initial stack is empty. The location description 1575e24f5f31STony result is pushed on the stack. 1576e24f5f31STony 1577e24f5f31STony .. note:: 1578e24f5f31STony 1579e24f5f31STony This rule avoids having to define how to execute a matched location list 1580e24f5f31STony entry operation expression on the same stack as the call when there are 1581e24f5f31STony multiple matches. But it allows the call to obtain the location 1582e24f5f31STony description for a variable or formal parameter which may use a location 1583e24f5f31STony list expression. 1584e24f5f31STony 1585e24f5f31STony An alternative is to treat the case when D has a ``DW_AT_location`` 1586e24f5f31STony attribute that is encoded as a ``loclist`` or ``loclistsptr``, and the 1587e24f5f31STony specified location list expression E' matches a single location list 1588e24f5f31STony entry with operation expression E, the same as the ``exprloc`` case and 1589e24f5f31STony evaluate on the same stack. 1590e24f5f31STony 1591e24f5f31STony But this is not attractive as if the attribute is for a variable that 1592e24f5f31STony happens to end with a non-singleton stack, it will not simply put a 1593e24f5f31STony location description on the stack. Presumably the intent of using 1594e24f5f31STony ``DW_OP_call*`` on a variable or formal parameter debugger information 1595e24f5f31STony entry is to push just one location description on the stack. That 1596e24f5f31STony location description may have more than one single location description. 1597e24f5f31STony 15980ac939f3STony Tye The previous rule for ``exprloc`` also has the same problem, as normally 1599e24f5f31STony a variable or formal parameter location expression may leave multiple 1600e24f5f31STony entries on the stack and only return the top entry. 1601e24f5f31STony 1602e24f5f31STony GDB implements ``DW_OP_call*`` by always executing E on the same stack. 1603e24f5f31STony If the location list has multiple matching entries, it simply picks the 1604e24f5f31STony first one and ignores the rest. This seems fundamentally at odds with 16050ac939f3STony Tye the desire to support multiple places for variables. 1606e24f5f31STony 1607e24f5f31STony So, it feels like ``DW_OP_call*`` should both support pushing a location 1608e24f5f31STony description on the stack for a variable or formal parameter, and also 1609e24f5f31STony support being able to execute an operation expression on the same stack. 1610e24f5f31STony Being able to specify a different operation expression for different 1611e24f5f31STony program locations seems a desirable feature to retain. 1612e24f5f31STony 1613e24f5f31STony A solution to that is to have a distinct ``DW_AT_LLVM_proc`` attribute 1614e24f5f31STony for the ``DW_TAG_dwarf_procedure`` debugging information entry. Then the 1615e24f5f31STony ``DW_AT_location`` attribute expression is always executed separately 1616e24f5f31STony and pushes a location description (that may have multiple single 1617e24f5f31STony location descriptions), and the ``DW_AT_LLVM_proc`` attribute expression 1618e24f5f31STony is always executed on the same stack and can leave anything on the 1619e24f5f31STony stack. 1620e24f5f31STony 1621e24f5f31STony The ``DW_AT_LLVM_proc`` attribute could have the new classes 1622e24f5f31STony ``exprproc``, ``loclistproc``, and ``loclistsptrproc`` to indicate that 1623e24f5f31STony the expression is executed on the same stack. ``exprproc`` is the same 1624e24f5f31STony encoding as ``exprloc``. ``loclistproc`` and ``loclistsptrproc`` are the 1625e24f5f31STony same encoding as their non-\ ``proc`` counterparts, except the DWARF is 1626e24f5f31STony ill-formed if the location list does not match exactly one location list 1627e24f5f31STony entry and a default entry is required. These forms indicate explicitly 1628e24f5f31STony that the matched single operation expression must be executed on the 1629e24f5f31STony same stack. This is better than ad hoc special rules for ``loclistproc`` 1630e24f5f31STony and ``loclistsptrproc`` which are currently clearly defined to always 1631e24f5f31STony return a location description. The producer then explicitly indicates 1632e24f5f31STony the intent through the attribute classes. 1633e24f5f31STony 1634e24f5f31STony Such a change would be a breaking change for how GDB implements 1635e24f5f31STony ``DW_OP_call*``. However, are the breaking cases actually occurring in 1636e24f5f31STony practice? GDB could implement the current approach for DWARF Version 5, 1637e24f5f31STony and the new semantics for DWARF Version 6 which has been done for some 1638e24f5f31STony other features. 1639e24f5f31STony 1640e24f5f31STony Another option is to limit the execution to be on the same stack only to 1641e24f5f31STony the evaluation of an expression E that is the value of a 1642e24f5f31STony ``DW_AT_location`` attribute of a ``DW_TAG_dwarf_procedure`` debugging 1643e24f5f31STony information entry. The DWARF would be ill-formed if E is a location list 1644e24f5f31STony expression that does not match exactly one location list entry. In all 1645e24f5f31STony other cases the evaluation of an expression E that is the value of a 1646e24f5f31STony ``DW_AT_location`` attribute would evaluate E with the current context, 1647e24f5f31STony except the result kind is a location description, the compilation unit 1648e24f5f31STony is the one that contains D, and the initial stack is empty. The location 1649e24f5f31STony description result is pushed on the stack. 1650e24f5f31STony 1651e24f5f31STony * If D has a ``DW_AT_const_value`` attribute with a value V, then it is as 1652e24f5f31STony if a ``DW_OP_implicit_value V`` operation was executed. 1653e24f5f31STony 1654e24f5f31STony *This allows a call operation to be used to compute the location 1655e24f5f31STony description for any variable or formal parameter regardless of whether the 16560ac939f3STony Tye producer has optimized it to a constant. This is consistent with the* 16570ac939f3STony Tye ``DW_OP_implicit_pointer`` *operation.* 1658e24f5f31STony 1659e24f5f31STony .. note:: 1660e24f5f31STony 1661e24f5f31STony Alternatively, could deprecate using ``DW_AT_const_value`` for 1662e24f5f31STony ``DW_TAG_variable`` and ``DW_TAG_formal_parameter`` debugger information 1663e24f5f31STony entries that are constants and instead use ``DW_AT_location`` with an 1664e24f5f31STony operation expression that results in a location description with one 1665e24f5f31STony implicit location description. Then this rule would not be required. 1666e24f5f31STony 1667e24f5f31STony * Otherwise, there is no effect and no changes are made to the stack. 1668e24f5f31STony 1669e24f5f31STony .. note:: 1670e24f5f31STony 1671e24f5f31STony In DWARF Version 5, if D does not have a ``DW_AT_location`` then 1672e24f5f31STony ``DW_OP_call*`` is defined to have no effect. It is unclear that this is 1673e24f5f31STony the right definition as a producer should be able to rely on using 1674e24f5f31STony ``DW_OP_call*`` to get a location description for any non-\ 1675e24f5f31STony ``DW_TAG_dwarf_procedure`` debugging information entries. Also, the 1676e24f5f31STony producer should not be creating DWARF with ``DW_OP_call*`` to a 1677e24f5f31STony ``DW_TAG_dwarf_procedure`` that does not have a ``DW_AT_location`` 1678e24f5f31STony attribute. So, should this case be defined as an ill-formed DWARF 1679e24f5f31STony expression? 1680e24f5f31STony 1681e24f5f31STony *The* ``DW_TAG_dwarf_procedure`` *debugging information entry can be used to 1682e24f5f31STony define DWARF procedures that can be called.* 1683e24f5f31STony 1684e24f5f31STony.. _amdgpu-dwarf-value-operations: 1685e24f5f31STony 16860ac939f3STony TyeA.2.5.4.3 Value Operations 16870ac939f3STony Tye########################## 1688e24f5f31STony 1689e24f5f31STonyThis section describes the operations that push values on the stack. 1690e24f5f31STony 16910ac939f3STony TyeEach value stack entry has a type and a literal value. It can represent a 1692e24f5f31STonyliteral value of any supported base type of the target architecture. The base 1693f79bab3fSTonytype specifies the size, encoding, and endianity of the literal value. 1694e24f5f31STony 1695f79bab3fSTonyThe base type of value stack entries can be the distinguished generic type. 1696e24f5f31STony 1697e24f5f31STony.. _amdgpu-dwarf-literal-operations: 1698e24f5f31STony 16990ac939f3STony TyeA.2.5.4.3.1 Literal Operations 17000ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17010ac939f3STony Tye 17020ac939f3STony Tye.. note:: 17030ac939f3STony Tye 17040ac939f3STony Tye This section replaces DWARF Version 5 section 2.5.1.1. 1705e24f5f31STony 1706e24f5f31STonyThe following operations all push a literal value onto the DWARF stack. 1707e24f5f31STony 1708e24f5f31STonyOperations other than ``DW_OP_const_type`` push a value V with the generic type. 1709e24f5f31STonyIf V is larger than the generic type, then V is truncated to the generic type 1710e24f5f31STonysize and the low-order bits used. 1711e24f5f31STony 1712e24f5f31STony1. ``DW_OP_lit0``, ``DW_OP_lit1``, ..., ``DW_OP_lit31`` 1713e24f5f31STony 1714e24f5f31STony ``DW_OP_lit<N>`` operations encode an unsigned literal value N from 0 1715e24f5f31STony through 31, inclusive. They push the value N with the generic type. 1716e24f5f31STony 1717e24f5f31STony2. ``DW_OP_const1u``, ``DW_OP_const2u``, ``DW_OP_const4u``, ``DW_OP_const8u`` 1718e24f5f31STony 1719e24f5f31STony ``DW_OP_const<N>u`` operations have a single operand that is a 1, 2, 4, or 1720e24f5f31STony 8-byte unsigned integer constant U, respectively. They push the value U with 1721e24f5f31STony the generic type. 1722e24f5f31STony 1723e24f5f31STony3. ``DW_OP_const1s``, ``DW_OP_const2s``, ``DW_OP_const4s``, ``DW_OP_const8s`` 1724e24f5f31STony 1725e24f5f31STony ``DW_OP_const<N>s`` operations have a single operand that is a 1, 2, 4, or 1726e24f5f31STony 8-byte signed integer constant S, respectively. They push the value S with 1727e24f5f31STony the generic type. 1728e24f5f31STony 1729e24f5f31STony4. ``DW_OP_constu`` 1730e24f5f31STony 1731e24f5f31STony ``DW_OP_constu`` has a single unsigned LEB128 integer operand N. It pushes 1732e24f5f31STony the value N with the generic type. 1733e24f5f31STony 1734e24f5f31STony5. ``DW_OP_consts`` 1735e24f5f31STony 1736e24f5f31STony ``DW_OP_consts`` has a single signed LEB128 integer operand N. It pushes the 1737e24f5f31STony value N with the generic type. 1738e24f5f31STony 1739e24f5f31STony6. ``DW_OP_constx`` 1740e24f5f31STony 1741e24f5f31STony ``DW_OP_constx`` has a single unsigned LEB128 integer operand that 1742e24f5f31STony represents a zero-based index into the ``.debug_addr`` section relative to 1743e24f5f31STony the value of the ``DW_AT_addr_base`` attribute of the associated compilation 1744e24f5f31STony unit. The value N in the ``.debug_addr`` section has the size of the generic 1745e24f5f31STony type. It pushes the value N with the generic type. 1746e24f5f31STony 1747e24f5f31STony *The* ``DW_OP_constx`` *operation is provided for constants that require 1748e24f5f31STony link-time relocation but should not be interpreted by the consumer as a 1749e24f5f31STony relocatable address (for example, offsets to thread-local storage).* 1750e24f5f31STony 17510ac939f3STony Tye7. ``DW_OP_const_type`` 1752e24f5f31STony 1753e24f5f31STony ``DW_OP_const_type`` has three operands. The first is an unsigned LEB128 1754e24f5f31STony integer DR that represents the byte offset of a debugging information entry 1755e24f5f31STony D relative to the beginning of the current compilation unit, that provides 1756e24f5f31STony the type T of the constant value. The second is a 1-byte unsigned integral 1757e24f5f31STony constant S. The third is a block of bytes B, with a length equal to S. 1758e24f5f31STony 1759e24f5f31STony TS is the bit size of the type T. The least significant TS bits of B are 1760e24f5f31STony interpreted as a value V of the type D. It pushes the value V with the type 1761e24f5f31STony D. 1762e24f5f31STony 1763e24f5f31STony The DWARF is ill-formed if D is not a ``DW_TAG_base_type`` debugging 1764e24f5f31STony information entry in the current compilation unit, or if TS divided by 8 1765e24f5f31STony (the byte size) and rounded up to a whole number is not equal to S. 1766e24f5f31STony 1767e24f5f31STony *While the size of the byte block B can be inferred from the type D 1768e24f5f31STony definition, it is encoded explicitly into the operation so that the 1769e24f5f31STony operation can be parsed easily without reference to the* ``.debug_info`` 1770e24f5f31STony *section.* 1771e24f5f31STony 17720ac939f3STony Tye8. ``DW_OP_LLVM_push_lane`` *New* 1773e24f5f31STony 17748ba5043dSTony Tye ``DW_OP_LLVM_push_lane`` pushes the current lane as a value with the generic 17758ba5043dSTony Tye type. 1776e24f5f31STony 17778ba5043dSTony Tye *For source languages that are implemented using a SIMT execution model, 17788ba5043dSTony Tye this is the zero-based lane number that corresponds to the source language 17798ba5043dSTony Tye thread of execution upon which the user is focused.* 17808ba5043dSTony Tye 17818ba5043dSTony Tye The value must be greater than or equal to 0 and less than the value of the 17828ba5043dSTony Tye ``DW_AT_LLVM_lanes`` attribute, otherwise the DWARF expression is 17838ba5043dSTony Tye ill-formed. See :ref:`amdgpu-dwarf-low-level-information`. 17848ba5043dSTony Tye 17858ba5043dSTony Tye9. ``DW_OP_LLVM_push_iteration`` *New* 17868ba5043dSTony Tye 17878ba5043dSTony Tye ``DW_OP_LLVM_push_iteration`` pushes the current iteration as a value with 17888ba5043dSTony Tye the generic type. 17898ba5043dSTony Tye 17908ba5043dSTony Tye *For source language implementations with optimizations that cause multiple 17918ba5043dSTony Tye loop iterations to execute concurrently, this is the zero-based iteration 17928ba5043dSTony Tye number that corresponds to the source language concurrent loop iteration 17938ba5043dSTony Tye upon which the user is focused.* 17948ba5043dSTony Tye 17958ba5043dSTony Tye The value must be greater than or equal to 0 and less than the value of the 17968ba5043dSTony Tye ``DW_AT_LLVM_iterations`` attribute, otherwise the DWARF expression is 17978ba5043dSTony Tye ill-formed. See :ref:`amdgpu-dwarf-low-level-information`. 1798e24f5f31STony 1799e24f5f31STony.. _amdgpu-dwarf-arithmetic-logical-operations: 1800e24f5f31STony 18010ac939f3STony TyeA.2.5.4.3.2 Arithmetic and Logical Operations 18020ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1803e24f5f31STony 1804e24f5f31STony.. note:: 1805e24f5f31STony 1806e24f5f31STony This section is the same as DWARF Version 5 section 2.5.1.4. 1807e24f5f31STony 1808e24f5f31STony.. _amdgpu-dwarf-type-conversions-operations: 1809e24f5f31STony 18100ac939f3STony TyeA.2.5.4.3.3 Type Conversion Operations 18110ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1812e24f5f31STony 1813e24f5f31STony.. note:: 1814e24f5f31STony 1815e24f5f31STony This section is the same as DWARF Version 5 section 2.5.1.6. 1816e24f5f31STony 1817e24f5f31STony.. _amdgpu-dwarf-general-operations: 1818e24f5f31STony 18190ac939f3STony TyeA.2.5.4.3.4 Special Value Operations 18200ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18210ac939f3STony Tye 18220ac939f3STony Tye.. note:: 18230ac939f3STony Tye 18240ac939f3STony Tye This section replaces parts of DWARF Version 5 sections 2.5.1.2, 2.5.1.3, and 18250ac939f3STony Tye 2.5.1.7. 1826e24f5f31STony 1827e24f5f31STonyThere are these special value operations currently defined: 1828e24f5f31STony 1829e24f5f31STony1. ``DW_OP_regval_type`` 1830e24f5f31STony 1831e24f5f31STony ``DW_OP_regval_type`` has two operands. The first is an unsigned LEB128 1832e24f5f31STony integer that represents a register number R. The second is an unsigned 1833e24f5f31STony LEB128 integer DR that represents the byte offset of a debugging information 1834e24f5f31STony entry D relative to the beginning of the current compilation unit, that 1835e24f5f31STony provides the type T of the register value. 1836e24f5f31STony 1837e24f5f31STony The operation is equivalent to performing ``DW_OP_regx R; DW_OP_deref_type 1838e24f5f31STony DR``. 1839e24f5f31STony 1840e24f5f31STony .. note:: 1841e24f5f31STony 1842e24f5f31STony Should DWARF allow the type T to be a larger size than the size of the 1843e24f5f31STony register R? Restricting a larger bit size avoids any issue of conversion 1844e24f5f31STony as the, possibly truncated, bit contents of the register is simply 1845e24f5f31STony interpreted as a value of T. If a conversion is wanted it can be done 1846e24f5f31STony explicitly using a ``DW_OP_convert`` operation. 1847e24f5f31STony 1848e24f5f31STony GDB has a per register hook that allows a target specific conversion on a 1849e24f5f31STony register by register basis. It defaults to truncation of bigger registers. 1850e24f5f31STony Removing use of the target hook does not cause any test failures in common 1851e24f5f31STony architectures. If the compiler for a target architecture did want some 1852e24f5f31STony form of conversion, including a larger result type, it could always 1853817f64e7STony Tye explicitly use the ``DW_OP_convert`` operation. 1854e24f5f31STony 1855e24f5f31STony If T is a larger type than the register size, then the default GDB 1856e24f5f31STony register hook reads bytes from the next register (or reads out of bounds 1857e24f5f31STony for the last register!). Removing use of the target hook does not cause 1858e24f5f31STony any test failures in common architectures (except an illegal hand written 1859e24f5f31STony assembly test). If a target architecture requires this behavior, these 1860e24f5f31STony extensions allow a composite location description to be used to combine 1861e24f5f31STony multiple registers. 1862e24f5f31STony 1863e24f5f31STony2. ``DW_OP_deref`` 1864e24f5f31STony 1865e24f5f31STony S is the bit size of the generic type divided by 8 (the byte size) and 1866e24f5f31STony rounded up to a whole number. DR is the offset of a hypothetical debug 1867e24f5f31STony information entry D in the current compilation unit for a base type of the 1868e24f5f31STony generic type. 1869e24f5f31STony 1870e24f5f31STony The operation is equivalent to performing ``DW_OP_deref_type S, DR``. 1871e24f5f31STony 1872e24f5f31STony3. ``DW_OP_deref_size`` 1873e24f5f31STony 1874e24f5f31STony ``DW_OP_deref_size`` has a single 1-byte unsigned integral constant that 1875e24f5f31STony represents a byte result size S. 1876e24f5f31STony 1877e24f5f31STony TS is the smaller of the generic type bit size and S scaled by 8 (the byte 1878e24f5f31STony size). If TS is smaller than the generic type bit size then T is an unsigned 1879e24f5f31STony integral type of bit size TS, otherwise T is the generic type. DR is the 1880e24f5f31STony offset of a hypothetical debug information entry D in the current 1881e24f5f31STony compilation unit for a base type T. 1882e24f5f31STony 1883e24f5f31STony .. note:: 1884e24f5f31STony 1885e24f5f31STony Truncating the value when S is larger than the generic type matches what 1886e24f5f31STony GDB does. This allows the generic type size to not be an integral byte 1887e24f5f31STony size. It does allow S to be arbitrarily large. Should S be restricted to 1888e24f5f31STony the size of the generic type rounded up to a multiple of 8? 1889e24f5f31STony 1890e24f5f31STony The operation is equivalent to performing ``DW_OP_deref_type S, DR``, except 1891e24f5f31STony if T is not the generic type, the value V pushed is zero-extended to the 1892e24f5f31STony generic type bit size and its type changed to the generic type. 1893e24f5f31STony 1894e24f5f31STony4. ``DW_OP_deref_type`` 1895e24f5f31STony 1896e24f5f31STony ``DW_OP_deref_type`` has two operands. The first is a 1-byte unsigned 1897e24f5f31STony integral constant S. The second is an unsigned LEB128 integer DR that 1898e24f5f31STony represents the byte offset of a debugging information entry D relative to 1899e24f5f31STony the beginning of the current compilation unit, that provides the type T of 1900e24f5f31STony the result value. 1901e24f5f31STony 1902e24f5f31STony TS is the bit size of the type T. 1903e24f5f31STony 1904e24f5f31STony *While the size of the pushed value V can be inferred from the type T, it is 1905e24f5f31STony encoded explicitly as the operand S so that the operation can be parsed 1906e24f5f31STony easily without reference to the* ``.debug_info`` *section.* 1907e24f5f31STony 1908e24f5f31STony .. note:: 1909e24f5f31STony 1910e24f5f31STony It is unclear why the operand S is needed. Unlike ``DW_OP_const_type``, 1911e24f5f31STony the size is not needed for parsing. Any evaluation needs to get the base 1912e24f5f31STony type T to push with the value to know its encoding and bit size. 1913e24f5f31STony 1914e24f5f31STony It pops one stack entry that must be a location description L. 1915e24f5f31STony 1916e24f5f31STony A value V of TS bits is retrieved from the location storage LS specified by 1917e24f5f31STony one of the single location descriptions SL of L. 1918e24f5f31STony 1919e24f5f31STony *If L, or the location description of any composite location description 1920e24f5f31STony part that is a subcomponent of L, has more than one single location 1921e24f5f31STony description, then any one of them can be selected as they are required to 1922e24f5f31STony all have the same value. For any single location description SL, bits are 1923e24f5f31STony retrieved from the associated storage location starting at the bit offset 1924e24f5f31STony specified by SL. For a composite location description, the retrieved bits 1925e24f5f31STony are the concatenation of the N bits from each composite location part PL, 1926e24f5f31STony where N is limited to the size of PL.* 1927e24f5f31STony 1928e24f5f31STony V is pushed on the stack with the type T. 1929e24f5f31STony 1930e24f5f31STony .. note:: 1931e24f5f31STony 1932e24f5f31STony This definition makes it an evaluation error if L is a register location 1933e24f5f31STony description that has less than TS bits remaining in the register storage. 1934e24f5f31STony Particularly since these extensions extend location descriptions to have 1935e24f5f31STony a bit offset, it would be odd to define this as performing sign extension 1936e24f5f31STony based on the type, or be target architecture dependent, as the number of 1937e24f5f31STony remaining bits could be any number. This matches the GDB implementation 1938e24f5f31STony for ``DW_OP_deref_type``. 1939e24f5f31STony 1940e24f5f31STony These extensions define ``DW_OP_*breg*`` in terms of 1941e24f5f31STony ``DW_OP_regval_type``. ``DW_OP_regval_type`` is defined in terms of 1942e24f5f31STony ``DW_OP_regx``, which uses a 0 bit offset, and ``DW_OP_deref_type``. 1943e24f5f31STony Therefore, it requires the register size to be greater or equal to the 1944e24f5f31STony address size of the address space. This matches the GDB implementation for 1945e24f5f31STony ``DW_OP_*breg*``. 1946e24f5f31STony 1947e24f5f31STony The DWARF is ill-formed if D is not in the current compilation unit, D is 1948e24f5f31STony not a ``DW_TAG_base_type`` debugging information entry, or if TS divided by 1949e24f5f31STony 8 (the byte size) and rounded up to a whole number is not equal to S. 1950e24f5f31STony 1951e24f5f31STony .. note:: 1952e24f5f31STony 1953e24f5f31STony This definition allows the base type to be a bit size since there seems no 1954e24f5f31STony reason to restrict it. 1955e24f5f31STony 1956e24f5f31STony It is an evaluation error if any bit of the value is retrieved from the 1957e24f5f31STony undefined location storage or the offset of any bit exceeds the size of the 1958e24f5f31STony location storage LS specified by any single location description SL of L. 1959e24f5f31STony 19600ac939f3STony Tye See :ref:`amdgpu-dwarf-implicit-location-description-operations` for special 19610ac939f3STony Tye rules concerning implicit location descriptions created by the 1962817f64e7STony Tye ``DW_OP_implicit_pointer`` and ``DW_OP_LLVM_aspace_implicit_pointer`` 1963e24f5f31STony operations. 1964e24f5f31STony 1965e24f5f31STony5. ``DW_OP_xderef`` *Deprecated* 1966e24f5f31STony 1967e24f5f31STony ``DW_OP_xderef`` pops two stack entries. The first must be an integral type 1968e24f5f31STony value that represents an address A. The second must be an integral type 1969e24f5f31STony value that represents a target architecture specific address space 1970e24f5f31STony identifier AS. 1971e24f5f31STony 1972e24f5f31STony The operation is equivalent to performing ``DW_OP_swap; 1973e24f5f31STony DW_OP_LLVM_form_aspace_address; DW_OP_deref``. The value V retrieved is left 1974e24f5f31STony on the stack with the generic type. 1975e24f5f31STony 1976e24f5f31STony *This operation is deprecated as the* ``DW_OP_LLVM_form_aspace_address`` 1977e24f5f31STony *operation can be used and provides greater expressiveness.* 1978e24f5f31STony 1979e24f5f31STony6. ``DW_OP_xderef_size`` *Deprecated* 1980e24f5f31STony 1981e24f5f31STony ``DW_OP_xderef_size`` has a single 1-byte unsigned integral constant that 1982e24f5f31STony represents a byte result size S. 1983e24f5f31STony 1984e24f5f31STony It pops two stack entries. The first must be an integral type value that 1985e24f5f31STony represents an address A. The second must be an integral type value that 1986e24f5f31STony represents a target architecture specific address space identifier AS. 1987e24f5f31STony 1988e24f5f31STony The operation is equivalent to performing ``DW_OP_swap; 1989e24f5f31STony DW_OP_LLVM_form_aspace_address; DW_OP_deref_size S``. The zero-extended 1990e24f5f31STony value V retrieved is left on the stack with the generic type. 1991e24f5f31STony 1992e24f5f31STony *This operation is deprecated as the* ``DW_OP_LLVM_form_aspace_address`` 1993e24f5f31STony *operation can be used and provides greater expressiveness.* 1994e24f5f31STony 1995e24f5f31STony7. ``DW_OP_xderef_type`` *Deprecated* 1996e24f5f31STony 1997e24f5f31STony ``DW_OP_xderef_type`` has two operands. The first is a 1-byte unsigned 1998e24f5f31STony integral constant S. The second operand is an unsigned LEB128 integer DR 1999e24f5f31STony that represents the byte offset of a debugging information entry D relative 2000e24f5f31STony to the beginning of the current compilation unit, that provides the type T 2001e24f5f31STony of the result value. 2002e24f5f31STony 2003e24f5f31STony It pops two stack entries. The first must be an integral type value that 2004e24f5f31STony represents an address A. The second must be an integral type value that 2005e24f5f31STony represents a target architecture specific address space identifier AS. 2006e24f5f31STony 2007e24f5f31STony The operation is equivalent to performing ``DW_OP_swap; 20080ac939f3STony Tye DW_OP_LLVM_form_aspace_address; DW_OP_deref_type S DR``. The value V 20090ac939f3STony Tye retrieved is left on the stack with the type T. 2010e24f5f31STony 2011e24f5f31STony *This operation is deprecated as the* ``DW_OP_LLVM_form_aspace_address`` 2012e24f5f31STony *operation can be used and provides greater expressiveness.* 2013e24f5f31STony 2014e24f5f31STony8. ``DW_OP_entry_value`` *Deprecated* 2015e24f5f31STony 2016e24f5f31STony ``DW_OP_entry_value`` pushes the value of an expression that is evaluated in 2017e24f5f31STony the context of the calling frame. 2018e24f5f31STony 2019e24f5f31STony *It may be used to determine the value of arguments on entry to the current 2020e24f5f31STony call frame provided they are not clobbered.* 2021e24f5f31STony 2022e24f5f31STony It has two operands. The first is an unsigned LEB128 integer S. The second 2023e24f5f31STony is a block of bytes, with a length equal S, interpreted as a DWARF 2024e24f5f31STony operation expression E. 2025e24f5f31STony 2026e24f5f31STony E is evaluated with the current context, except the result kind is 2027e24f5f31STony unspecified, the call frame is the one that called the current frame, the 2028e24f5f31STony program location is the call site in the calling frame, the object is 2029e24f5f31STony unspecified, and the initial stack is empty. The calling frame information 2030e24f5f31STony is obtained by virtually unwinding the current call frame using the call 2031e24f5f31STony frame information (see :ref:`amdgpu-dwarf-call-frame-information`). 2032e24f5f31STony 2033e24f5f31STony If the result of E is a location description L (see 20340ac939f3STony Tye :ref:`amdgpu-dwarf-register-location-description-operations`), and the last 20350ac939f3STony Tye operation executed by E is a ``DW_OP_reg*`` for register R with a target 20360ac939f3STony Tye architecture specific base type of T, then the contents of the register are 20370ac939f3STony Tye retrieved as if a ``DW_OP_deref_type DR`` operation was performed where DR 20380ac939f3STony Tye is the offset of a hypothetical debug information entry in the current 20390ac939f3STony Tye compilation unit for T. The resulting value V s pushed on the stack. 2040e24f5f31STony 2041e24f5f31STony *Using* ``DW_OP_reg*`` *provides a more compact form for the case where the 2042e24f5f31STony value was in a register on entry to the subprogram.* 2043e24f5f31STony 20440ac939f3STony Tye .. note:: 2045e24f5f31STony 2046e24f5f31STony It is unclear how this provides a more compact expression, as 2047e24f5f31STony ``DW_OP_regval_type`` could be used which is marginally larger. 2048e24f5f31STony 2049e24f5f31STony If the result of E is a value V, then V is pushed on the stack. 2050e24f5f31STony 2051e24f5f31STony Otherwise, the DWARF expression is ill-formed. 2052e24f5f31STony 2053e24f5f31STony *The* ``DW_OP_entry_value`` *operation is deprecated as its main usage is 2054e24f5f31STony provided by other means. DWARF Version 5 added the* 2055e24f5f31STony ``DW_TAG_call_site_parameter`` *debugger information entry for call sites 2056e24f5f31STony that has* ``DW_AT_call_value``\ *,* ``DW_AT_call_data_location``\ *, and* 2057e24f5f31STony ``DW_AT_call_data_value`` *attributes that provide DWARF expressions to 2058e24f5f31STony compute actual parameter values at the time of the call, and requires the 2059e24f5f31STony producer to ensure the expressions are valid to evaluate even when virtually 2060e24f5f31STony unwound. The* ``DW_OP_LLVM_call_frame_entry_reg`` *operation provides access 2061e24f5f31STony to registers in the virtually unwound calling frame.* 2062e24f5f31STony 2063e24f5f31STony .. note:: 2064e24f5f31STony 2065e24f5f31STony GDB only implements ``DW_OP_entry_value`` when E is exactly 2066e24f5f31STony ``DW_OP_reg*`` or ``DW_OP_breg*; DW_OP_deref*``. 2067e24f5f31STony 2068e24f5f31STony.. _amdgpu-dwarf-location-description-operations: 2069e24f5f31STony 20700ac939f3STony TyeA.2.5.4.4 Location Description Operations 20710ac939f3STony Tye######################################### 2072e24f5f31STony 2073e24f5f31STonyThis section describes the operations that push location descriptions on the 2074e24f5f31STonystack. 2075e24f5f31STony 20760ac939f3STony Tye.. _amdgpu-dwarf-general-location-description-operations: 20770ac939f3STony Tye 20780ac939f3STony TyeA.2.5.4.4.1 General Location Description Operations 20790ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20800ac939f3STony Tye 20810ac939f3STony Tye.. note:: 20820ac939f3STony Tye 20830ac939f3STony Tye This section replaces part of DWARF Version 5 section 2.5.1.3. 2084e24f5f31STony 2085e24f5f31STony1. ``DW_OP_LLVM_offset`` *New* 2086e24f5f31STony 2087e24f5f31STony ``DW_OP_LLVM_offset`` pops two stack entries. The first must be an integral 2088e24f5f31STony type value that represents a byte displacement B. The second must be a 2089e24f5f31STony location description L. 2090e24f5f31STony 2091e24f5f31STony It adds the value of B scaled by 8 (the byte size) to the bit offset of each 2092e24f5f31STony single location description SL of L, and pushes the updated L. 2093e24f5f31STony 2094e24f5f31STony It is an evaluation error if the updated bit offset of any SL is less than 0 2095e24f5f31STony or greater than or equal to the size of the location storage specified by 2096e24f5f31STony SL. 2097e24f5f31STony 2098e24f5f31STony2. ``DW_OP_LLVM_offset_uconst`` *New* 2099e24f5f31STony 2100e24f5f31STony ``DW_OP_LLVM_offset_uconst`` has a single unsigned LEB128 integer operand 2101e24f5f31STony that represents a byte displacement B. 2102e24f5f31STony 2103e24f5f31STony The operation is equivalent to performing ``DW_OP_constu B; 2104e24f5f31STony DW_OP_LLVM_offset``. 2105e24f5f31STony 2106e24f5f31STony *This operation is supplied specifically to be able to encode more field 2107e24f5f31STony displacements in two bytes than can be done with* ``DW_OP_lit*; 2108e24f5f31STony DW_OP_LLVM_offset``\ *.* 2109e24f5f31STony 2110e24f5f31STony .. note:: 2111e24f5f31STony 2112e24f5f31STony Should this be named ``DW_OP_LLVM_offset_uconst`` to match 2113e24f5f31STony ``DW_OP_plus_uconst``, or ``DW_OP_LLVM_offset_constu`` to match 2114e24f5f31STony ``DW_OP_constu``? 2115e24f5f31STony 2116e24f5f31STony3. ``DW_OP_LLVM_bit_offset`` *New* 2117e24f5f31STony 2118e24f5f31STony ``DW_OP_LLVM_bit_offset`` pops two stack entries. The first must be an 2119e24f5f31STony integral type value that represents a bit displacement B. The second must be 2120e24f5f31STony a location description L. 2121e24f5f31STony 2122e24f5f31STony It adds the value of B to the bit offset of each single location description 2123e24f5f31STony SL of L, and pushes the updated L. 2124e24f5f31STony 2125e24f5f31STony It is an evaluation error if the updated bit offset of any SL is less than 0 2126e24f5f31STony or greater than or equal to the size of the location storage specified by 2127e24f5f31STony SL. 2128e24f5f31STony 2129e24f5f31STony4. ``DW_OP_push_object_address`` 2130e24f5f31STony 2131e24f5f31STony ``DW_OP_push_object_address`` pushes the location description L of the 2132e24f5f31STony current object. 2133e24f5f31STony 2134e24f5f31STony *This object may correspond to an independent variable that is part of a 2135e24f5f31STony user presented expression that is being evaluated. The object location 2136e24f5f31STony description may be determined from the variable's own debugging information 2137e24f5f31STony entry or it may be a component of an array, structure, or class whose 2138e24f5f31STony address has been dynamically determined by an earlier step during user 2139e24f5f31STony expression evaluation.* 2140e24f5f31STony 2141e24f5f31STony *This operation provides explicit functionality (especially for arrays 21420ac939f3STony Tye involving descriptors) that is analogous to the implicit push of the base 21430ac939f3STony Tye location description of a structure prior to evaluation of a* 21440ac939f3STony Tye ``DW_AT_data_member_location`` *to access a data member of a structure.* 2145e24f5f31STony 2146e24f5f31STony .. note:: 2147e24f5f31STony 2148e24f5f31STony This operation could be removed and the object location description 2149e24f5f31STony specified as the initial stack as for ``DW_AT_data_member_location``. 2150e24f5f31STony 21510ac939f3STony Tye Or this operation could be used instead of needing to specify an initial 21520ac939f3STony Tye stack. The latter approach is more composable as access to the object may 21530ac939f3STony Tye be needed at any point of the expression, and passing it as the initial 21540ac939f3STony Tye stack requires the entire expression to be aware where on the stack it is. 21550ac939f3STony Tye If this were done, ``DW_AT_use_location`` would require a 21560ac939f3STony Tye ``DW_OP_push_object2_address`` operation for the second object. 21570ac939f3STony Tye 21580ac939f3STony Tye Or a more general way to pass an arbitrary number of arguments in and an 21590ac939f3STony Tye operation to get the Nth one such as ``DW_OP_arg N``. A vector of 21600ac939f3STony Tye arguments would then be passed in the expression context rather than an 21610ac939f3STony Tye initial stack. This could also resolve the issues with ``DW_OP_call*`` by 21620ac939f3STony Tye allowing a specific number of arguments passed in and returned to be 21630ac939f3STony Tye specified. The ``DW_OP_call*`` operation could then always execute on a 21640ac939f3STony Tye separate stack: the number of arguments would be specified in a new call 21650ac939f3STony Tye operation and taken from the callers stack, and similarly the number of 21660ac939f3STony Tye return results specified and copied from the called stack back to the 21670ac939f3STony Tye callee stack when the called expression was complete. 21680ac939f3STony Tye 2169e24f5f31STony The only attribute that specifies a current object is 2170e24f5f31STony ``DW_AT_data_location`` so the non-normative text seems to overstate how 2171e24f5f31STony this is being used. Or are there other attributes that need to state they 2172e24f5f31STony pass an object? 2173e24f5f31STony 2174e24f5f31STony5. ``DW_OP_LLVM_call_frame_entry_reg`` *New* 2175e24f5f31STony 2176e24f5f31STony ``DW_OP_LLVM_call_frame_entry_reg`` has a single unsigned LEB128 integer 2177e24f5f31STony operand that represents a target architecture register number R. 2178e24f5f31STony 2179e24f5f31STony It pushes a location description L that holds the value of register R on 2180e24f5f31STony entry to the current subprogram as defined by the call frame information 2181e24f5f31STony (see :ref:`amdgpu-dwarf-call-frame-information`). 2182e24f5f31STony 2183e24f5f31STony *If there is no call frame information defined, then the default rules for 2184e24f5f31STony the target architecture are used. If the register rule is* undefined\ *, then 2185e24f5f31STony the undefined location description is pushed. If the register rule is* same 2186e24f5f31STony value\ *, then a register location description for R is pushed.* 2187e24f5f31STony 2188e24f5f31STony.. _amdgpu-dwarf-undefined-location-description-operations: 2189e24f5f31STony 21900ac939f3STony TyeA.2.5.4.4.2 Undefined Location Description Operations 21910ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21920ac939f3STony Tye 21930ac939f3STony Tye.. note:: 21940ac939f3STony Tye 21950ac939f3STony Tye This section replaces DWARF Version 5 section 2.6.1.1.1. 2196e24f5f31STony 2197e24f5f31STony*The undefined location storage represents a piece or all of an object that is 2198e24f5f31STonypresent in the source but not in the object code (perhaps due to optimization). 2199e24f5f31STonyNeither reading nor writing to the undefined location storage is meaningful.* 2200e24f5f31STony 2201e24f5f31STonyAn undefined location description specifies the undefined location storage. 2202e24f5f31STonyThere is no concept of the size of the undefined location storage, nor of a bit 2203e24f5f31STonyoffset for an undefined location description. The ``DW_OP_LLVM_*offset`` 2204e24f5f31STonyoperations leave an undefined location description unchanged. The 2205e24f5f31STony``DW_OP_*piece`` operations can explicitly or implicitly specify an undefined 2206e24f5f31STonylocation description, allowing any size and offset to be specified, and results 2207e24f5f31STonyin a part with all undefined bits. 2208e24f5f31STony 2209e24f5f31STony1. ``DW_OP_LLVM_undefined`` *New* 2210e24f5f31STony 2211e24f5f31STony ``DW_OP_LLVM_undefined`` pushes a location description L that comprises one 2212e24f5f31STony undefined location description SL. 2213e24f5f31STony 2214e24f5f31STony.. _amdgpu-dwarf-memory-location-description-operations: 2215e24f5f31STony 22160ac939f3STony TyeA.2.5.4.4.3 Memory Location Description Operations 22170ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22180ac939f3STony Tye 22190ac939f3STony Tye.. note:: 22200ac939f3STony Tye 22210ac939f3STony Tye This section replaces parts of DWARF Version 5 section 2.5.1.1, 2.5.1.2, 22220ac939f3STony Tye 2.5.1.3, and 2.6.1.1.2. 2223e24f5f31STony 2224e24f5f31STonyEach of the target architecture specific address spaces has a corresponding 2225e24f5f31STonymemory location storage that denotes the linear addressable memory of that 2226e24f5f31STonyaddress space. The size of each memory location storage corresponds to the range 2227e24f5f31STonyof the addresses in the corresponding address space. 2228e24f5f31STony 2229e24f5f31STony*It is target architecture defined how address space location storage maps to 2230e24f5f31STonytarget architecture physical memory. For example, they may be independent 2231e24f5f31STonymemory, or more than one location storage may alias the same physical memory 2232e24f5f31STonypossibly at different offsets and with different interleaving. The mapping may 2233e24f5f31STonyalso be dictated by the source language address classes.* 2234e24f5f31STony 2235e24f5f31STonyA memory location description specifies a memory location storage. The bit 2236e24f5f31STonyoffset corresponds to a bit position within a byte of the memory. Bits accessed 2237e24f5f31STonyusing a memory location description, access the corresponding target 2238e24f5f31STonyarchitecture memory starting at the bit position within the byte specified by 2239e24f5f31STonythe bit offset. 2240e24f5f31STony 2241e24f5f31STonyA memory location description that has a bit offset that is a multiple of 8 (the 2242e24f5f31STonybyte size) is defined to be a byte address memory location description. It has a 2243e24f5f31STonymemory byte address A that is equal to the bit offset divided by 8. 2244e24f5f31STony 2245e24f5f31STonyA memory location description that does not have a bit offset that is a multiple 2246e24f5f31STonyof 8 (the byte size) is defined to be a bit field memory location description. 2247e24f5f31STonyIt has a bit position B equal to the bit offset modulo 8, and a memory byte 2248e24f5f31STonyaddress A equal to the bit offset minus B that is then divided by 8. 2249e24f5f31STony 2250e24f5f31STonyThe address space AS of a memory location description is defined to be the 2251e24f5f31STonyaddress space that corresponds to the memory location storage associated with 2252e24f5f31STonythe memory location description. 2253e24f5f31STony 2254e24f5f31STonyA location description that is comprised of one byte address memory location 2255e24f5f31STonydescription SL is defined to be a memory byte address location description. It 2256e24f5f31STonyhas a byte address equal to A and an address space equal to AS of the 2257e24f5f31STonycorresponding SL. 2258e24f5f31STony 22593138fda3STony Tye``DW_ASPACE_LLVM_none`` is defined as the target architecture default address 22603138fda3STony Tyespace. See :ref:`amdgpu-dwarf-address-spaces`. 2261e24f5f31STony 2262e24f5f31STonyIf a stack entry is required to be a location description, but it is a value V 2263e24f5f31STonywith the generic type, then it is implicitly converted to a location description 2264e24f5f31STonyL with one memory location description SL. SL specifies the memory location 2265e24f5f31STonystorage that corresponds to the target architecture default address space with a 2266e24f5f31STonybit offset equal to V scaled by 8 (the byte size). 2267e24f5f31STony 2268e24f5f31STony.. note:: 2269e24f5f31STony 2270e24f5f31STony If it is wanted to allow any integral type value to be implicitly converted to 2271e24f5f31STony a memory location description in the target architecture default address 2272e24f5f31STony space: 2273e24f5f31STony 2274e24f5f31STony If a stack entry is required to be a location description, but is a value V 2275e24f5f31STony with an integral type, then it is implicitly converted to a location 2276e24f5f31STony description L with a one memory location description SL. If the type size of 2277e24f5f31STony V is less than the generic type size, then the value V is zero extended to 2278e24f5f31STony the size of the generic type. The least significant generic type size bits 22790ac939f3STony Tye are treated as an unsigned value to be used as an address A. SL specifies 22800ac939f3STony Tye memory location storage corresponding to the target architecture default 22810ac939f3STony Tye address space with a bit offset equal to A scaled by 8 (the byte size). 2282e24f5f31STony 2283e24f5f31STony The implicit conversion could also be defined as target architecture specific. 2284e24f5f31STony For example, GDB checks if V is an integral type. If it is not it gives an 2285e24f5f31STony error. Otherwise, GDB zero-extends V to 64 bits. If the GDB target defines a 2286e24f5f31STony hook function, then it is called. The target specific hook function can modify 2287e24f5f31STony the 64-bit value, possibly sign extending based on the original value type. 2288e24f5f31STony Finally, GDB treats the 64-bit value V as a memory location address. 2289e24f5f31STony 2290e24f5f31STonyIf a stack entry is required to be a location description, but it is an implicit 2291e24f5f31STonypointer value IPV with the target architecture default address space, then it is 2292e24f5f31STonyimplicitly converted to a location description with one single location 2293e24f5f31STonydescription specified by IPV. See 22940ac939f3STony Tye:ref:`amdgpu-dwarf-implicit-location-description-operations`. 2295e24f5f31STony 2296e24f5f31STony.. note:: 2297e24f5f31STony 2298e24f5f31STony Is this rule required for DWARF Version 5 backwards compatibility? If not, it 2299e24f5f31STony can be eliminated, and the producer can use 2300e24f5f31STony ``DW_OP_LLVM_form_aspace_address``. 2301e24f5f31STony 2302e24f5f31STonyIf a stack entry is required to be a value, but it is a location description L 2303e24f5f31STonywith one memory location description SL in the target architecture default 2304e24f5f31STonyaddress space with a bit offset B that is a multiple of 8, then it is implicitly 2305e24f5f31STonyconverted to a value equal to B divided by 8 (the byte size) with the generic 2306e24f5f31STonytype. 2307e24f5f31STony 2308e24f5f31STony1. ``DW_OP_addr`` 2309e24f5f31STony 2310e24f5f31STony ``DW_OP_addr`` has a single byte constant value operand, which has the size 2311e24f5f31STony of the generic type, that represents an address A. 2312e24f5f31STony 2313e24f5f31STony It pushes a location description L with one memory location description SL 2314e24f5f31STony on the stack. SL specifies the memory location storage corresponding to the 2315e24f5f31STony target architecture default address space with a bit offset equal to A 2316e24f5f31STony scaled by 8 (the byte size). 2317e24f5f31STony 2318e24f5f31STony *If the DWARF is part of a code object, then A may need to be relocated. For 2319e24f5f31STony example, in the ELF code object format, A must be adjusted by the difference 2320e24f5f31STony between the ELF segment virtual address and the virtual address at which the 2321e24f5f31STony segment is loaded.* 2322e24f5f31STony 2323e24f5f31STony2. ``DW_OP_addrx`` 2324e24f5f31STony 2325e24f5f31STony ``DW_OP_addrx`` has a single unsigned LEB128 integer operand that represents 2326e24f5f31STony a zero-based index into the ``.debug_addr`` section relative to the value of 2327e24f5f31STony the ``DW_AT_addr_base`` attribute of the associated compilation unit. The 2328e24f5f31STony address value A in the ``.debug_addr`` section has the size of the generic 2329e24f5f31STony type. 2330e24f5f31STony 2331e24f5f31STony It pushes a location description L with one memory location description SL 2332e24f5f31STony on the stack. SL specifies the memory location storage corresponding to the 2333e24f5f31STony target architecture default address space with a bit offset equal to A 2334e24f5f31STony scaled by 8 (the byte size). 2335e24f5f31STony 2336e24f5f31STony *If the DWARF is part of a code object, then A may need to be relocated. For 2337e24f5f31STony example, in the ELF code object format, A must be adjusted by the difference 2338e24f5f31STony between the ELF segment virtual address and the virtual address at which the 2339e24f5f31STony segment is loaded.* 2340e24f5f31STony 2341e24f5f31STony3. ``DW_OP_LLVM_form_aspace_address`` *New* 2342e24f5f31STony 2343e24f5f31STony ``DW_OP_LLVM_form_aspace_address`` pops top two stack entries. The first 2344e24f5f31STony must be an integral type value that represents a target architecture 2345e24f5f31STony specific address space identifier AS. The second must be an integral type 2346e24f5f31STony value that represents an address A. 2347e24f5f31STony 2348e24f5f31STony The address size S is defined as the address bit size of the target 2349e24f5f31STony architecture specific address space that corresponds to AS. 2350e24f5f31STony 23510ac939f3STony Tye A is adjusted to S bits by zero extending if necessary, and then treating 23520ac939f3STony Tye the least significant S bits as an unsigned value A'. 2353e24f5f31STony 2354e24f5f31STony It pushes a location description L with one memory location description SL 2355e24f5f31STony on the stack. SL specifies the memory location storage LS that corresponds 2356e24f5f31STony to AS with a bit offset equal to A' scaled by 8 (the byte size). 2357e24f5f31STony 2358e24f5f31STony If AS is an address space that is specific to context elements, then LS 2359e24f5f31STony corresponds to the location storage associated with the current context. 2360e24f5f31STony 2361e24f5f31STony *For example, if AS is for per thread storage then LS is the location 2362e24f5f31STony storage for the current thread. For languages that are implemented using a 23638ba5043dSTony Tye SIMT execution model, then if AS is for per lane storage then LS is the 23648ba5043dSTony Tye location storage for the current lane of the current thread. Therefore, if L 23658ba5043dSTony Tye is accessed by an operation, the location storage selected when the location 23668ba5043dSTony Tye description was created is accessed, and not the location storage associated 23678ba5043dSTony Tye with the current context of the access operation.* 2368e24f5f31STony 2369e24f5f31STony The DWARF expression is ill-formed if AS is not one of the values defined by 23703138fda3STony Tye the target architecture specific ``DW_ASPACE_LLVM_*`` values. 2371e24f5f31STony 23720ac939f3STony Tye See :ref:`amdgpu-dwarf-implicit-location-description-operations` for special 23730ac939f3STony Tye rules concerning implicit pointer values produced by dereferencing implicit 2374e24f5f31STony location descriptions created by the ``DW_OP_implicit_pointer`` and 2375817f64e7STony Tye ``DW_OP_LLVM_aspace_implicit_pointer`` operations. 2376e24f5f31STony 2377e24f5f31STony4. ``DW_OP_form_tls_address`` 2378e24f5f31STony 2379e24f5f31STony ``DW_OP_form_tls_address`` pops one stack entry that must be an integral 2380e24f5f31STony type value and treats it as a thread-local storage address TA. 2381e24f5f31STony 2382e24f5f31STony It pushes a location description L with one memory location description SL 2383e24f5f31STony on the stack. SL is the target architecture specific memory location 2384e24f5f31STony description that corresponds to the thread-local storage address TA. 2385e24f5f31STony 2386e24f5f31STony The meaning of the thread-local storage address TA is defined by the 2387e24f5f31STony run-time environment. If the run-time environment supports multiple 2388e24f5f31STony thread-local storage blocks for a single thread, then the block 2389e24f5f31STony corresponding to the executable or shared library containing this DWARF 2390e24f5f31STony expression is used. 2391e24f5f31STony 2392817f64e7STony Tye *Some implementations of C, C++, Fortran, and other languages, support a 2393e24f5f31STony thread-local storage class. Variables with this storage class have distinct 2394e24f5f31STony values and addresses in distinct threads, much as automatic variables have 2395e24f5f31STony distinct values and addresses in each subprogram invocation. Typically, 2396e24f5f31STony there is a single block of storage containing all thread-local variables 2397e24f5f31STony declared in the main executable, and a separate block for the variables 2398e24f5f31STony declared in each shared library. Each thread-local variable can then be 2399e24f5f31STony accessed in its block using an identifier. This identifier is typically a 2400e24f5f31STony byte offset into the block and pushed onto the DWARF stack by one of the* 2401e24f5f31STony ``DW_OP_const*`` *operations prior to the* ``DW_OP_form_tls_address`` 2402e24f5f31STony *operation. Computing the address of the appropriate block can be complex 2403e24f5f31STony (in some cases, the compiler emits a function call to do it), and difficult 2404e24f5f31STony to describe using ordinary DWARF location descriptions. Instead of forcing 2405e24f5f31STony complex thread-local storage calculations into the DWARF expressions, the* 2406e24f5f31STony ``DW_OP_form_tls_address`` *allows the consumer to perform the computation 2407e24f5f31STony based on the target architecture specific run-time environment.* 2408e24f5f31STony 2409e24f5f31STony5. ``DW_OP_call_frame_cfa`` 2410e24f5f31STony 2411e24f5f31STony ``DW_OP_call_frame_cfa`` pushes the location description L of the Canonical 2412e24f5f31STony Frame Address (CFA) of the current subprogram, obtained from the call frame 2413e24f5f31STony information on the stack. See :ref:`amdgpu-dwarf-call-frame-information`. 2414e24f5f31STony 2415e24f5f31STony *Although the value of the* ``DW_AT_frame_base`` *attribute of the debugger 2416e24f5f31STony information entry corresponding to the current subprogram can be computed 2417e24f5f31STony using a location list expression, in some cases this would require an 2418e24f5f31STony extensive location list because the values of the registers used in 2419e24f5f31STony computing the CFA change during a subprogram execution. If the call frame 2420e24f5f31STony information is present, then it already encodes such changes, and it is 2421e24f5f31STony space efficient to reference that using the* ``DW_OP_call_frame_cfa`` 2422e24f5f31STony *operation.* 2423e24f5f31STony 2424e24f5f31STony6. ``DW_OP_fbreg`` 2425e24f5f31STony 2426e24f5f31STony ``DW_OP_fbreg`` has a single signed LEB128 integer operand that represents a 2427e24f5f31STony byte displacement B. 2428e24f5f31STony 2429e24f5f31STony The location description L for the *frame base* of the current subprogram is 2430e24f5f31STony obtained from the ``DW_AT_frame_base`` attribute of the debugger information 2431e24f5f31STony entry corresponding to the current subprogram as described in 24320ac939f3STony Tye :ref:`amdgpu-dwarf-low-level-information`. 2433e24f5f31STony 2434e24f5f31STony The location description L is updated as if the ``DW_OP_LLVM_offset_uconst 2435e24f5f31STony B`` operation was applied. The updated L is pushed on the stack. 2436e24f5f31STony 2437e24f5f31STony7. ``DW_OP_breg0``, ``DW_OP_breg1``, ..., ``DW_OP_breg31`` 2438e24f5f31STony 2439e24f5f31STony The ``DW_OP_breg<N>`` operations encode the numbers of up to 32 registers, 2440e24f5f31STony numbered from 0 through 31, inclusive. The register number R corresponds to 2441e24f5f31STony the N in the operation name. 2442e24f5f31STony 2443e24f5f31STony They have a single signed LEB128 integer operand that represents a byte 2444e24f5f31STony displacement B. 2445e24f5f31STony 2446e24f5f31STony The address space identifier AS is defined as the one corresponding to the 2447e24f5f31STony target architecture specific default address space. 2448e24f5f31STony 2449e24f5f31STony The address size S is defined as the address bit size of the target 2450e24f5f31STony architecture specific address space corresponding to AS. 2451e24f5f31STony 2452e24f5f31STony The contents of the register specified by R are retrieved as if a 2453e24f5f31STony ``DW_OP_regval_type R, DR`` operation was performed where DR is the offset 2454e24f5f31STony of a hypothetical debug information entry in the current compilation unit 2455e24f5f31STony for an unsigned integral base type of size S bits. B is added and the least 2456e24f5f31STony significant S bits are treated as an unsigned value to be used as an address 2457e24f5f31STony A. 2458e24f5f31STony 2459e24f5f31STony They push a location description L comprising one memory location 2460e24f5f31STony description LS on the stack. LS specifies the memory location storage that 2461e24f5f31STony corresponds to AS with a bit offset equal to A scaled by 8 (the byte size). 2462e24f5f31STony 2463e24f5f31STony8. ``DW_OP_bregx`` 2464e24f5f31STony 2465e24f5f31STony ``DW_OP_bregx`` has two operands. The first is an unsigned LEB128 integer 2466e24f5f31STony that represents a register number R. The second is a signed LEB128 2467e24f5f31STony integer that represents a byte displacement B. 2468e24f5f31STony 2469e24f5f31STony The action is the same as for ``DW_OP_breg<N>``, except that R is used as 2470e24f5f31STony the register number and B is used as the byte displacement. 2471e24f5f31STony 2472e24f5f31STony9. ``DW_OP_LLVM_aspace_bregx`` *New* 2473e24f5f31STony 2474e24f5f31STony ``DW_OP_LLVM_aspace_bregx`` has two operands. The first is an unsigned 2475e24f5f31STony LEB128 integer that represents a register number R. The second is a signed 2476e24f5f31STony LEB128 integer that represents a byte displacement B. It pops one stack 2477e24f5f31STony entry that is required to be an integral type value that represents a target 2478e24f5f31STony architecture specific address space identifier AS. 2479e24f5f31STony 2480e24f5f31STony The action is the same as for ``DW_OP_breg<N>``, except that R is used as 2481e24f5f31STony the register number, B is used as the byte displacement, and AS is used as 2482e24f5f31STony the address space identifier. 2483e24f5f31STony 2484e24f5f31STony The DWARF expression is ill-formed if AS is not one of the values defined by 24853138fda3STony Tye the target architecture specific ``DW_ASPACE_LLVM_*`` values. 2486e24f5f31STony 2487e24f5f31STony .. note:: 2488e24f5f31STony 248958661406STony Tye Could also consider adding ``DW_OP_LLVM_aspace_breg0, 249069a3976eSScott Linder DW_OP_LLVM_aspace_breg1, ..., DW_OP_LLVM_aspace_breg31`` which would save 249158661406STony Tye encoding size. 2492e24f5f31STony 24930ac939f3STony Tye.. _amdgpu-dwarf-register-location-description-operations: 2494e24f5f31STony 24950ac939f3STony TyeA.2.5.4.4.4 Register Location Description Operations 24960ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24970ac939f3STony Tye 24980ac939f3STony Tye.. note:: 24990ac939f3STony Tye 25000ac939f3STony Tye This section replaces DWARF Version 5 section 2.6.1.1.3. 2501e24f5f31STony 2502e24f5f31STonyThere is a register location storage that corresponds to each of the target 2503e24f5f31STonyarchitecture registers. The size of each register location storage corresponds 2504e24f5f31STonyto the size of the corresponding target architecture register. 2505e24f5f31STony 2506e24f5f31STonyA register location description specifies a register location storage. The bit 2507e24f5f31STonyoffset corresponds to a bit position within the register. Bits accessed using a 2508e24f5f31STonyregister location description access the corresponding target architecture 2509e24f5f31STonyregister starting at the specified bit offset. 2510e24f5f31STony 2511e24f5f31STony1. ``DW_OP_reg0``, ``DW_OP_reg1``, ..., ``DW_OP_reg31`` 2512e24f5f31STony 2513e24f5f31STony ``DW_OP_reg<N>`` operations encode the numbers of up to 32 registers, 2514e24f5f31STony numbered from 0 through 31, inclusive. The target architecture register 2515e24f5f31STony number R corresponds to the N in the operation name. 2516e24f5f31STony 2517e24f5f31STony The operation is equivalent to performing ``DW_OP_regx R``. 2518e24f5f31STony 2519e24f5f31STony2. ``DW_OP_regx`` 2520e24f5f31STony 2521e24f5f31STony ``DW_OP_regx`` has a single unsigned LEB128 integer operand that represents 2522e24f5f31STony a target architecture register number R. 2523e24f5f31STony 2524e24f5f31STony If the current call frame is the top call frame, it pushes a location 2525e24f5f31STony description L that specifies one register location description SL on the 2526e24f5f31STony stack. SL specifies the register location storage that corresponds to R with 2527e24f5f31STony a bit offset of 0 for the current thread. 2528e24f5f31STony 2529e24f5f31STony If the current call frame is not the top call frame, call frame information 2530e24f5f31STony (see :ref:`amdgpu-dwarf-call-frame-information`) is used to determine the 2531e24f5f31STony location description that holds the register for the current call frame and 2532e24f5f31STony current program location of the current thread. The resulting location 2533e24f5f31STony description L is pushed. 2534e24f5f31STony 2535e24f5f31STony *Note that if call frame information is used, the resulting location 2536e24f5f31STony description may be register, memory, or undefined.* 2537e24f5f31STony 2538e24f5f31STony *An implementation may evaluate the call frame information immediately, or 2539e24f5f31STony may defer evaluation until L is accessed by an operation. If evaluation is 2540a31b3893SKazu Hirata deferred, R and the current context can be recorded in L. When accessed, the 2541e24f5f31STony recorded context is used to evaluate the call frame information, not the 2542e24f5f31STony current context of the access operation.* 2543e24f5f31STony 2544e24f5f31STony*These operations obtain a register location. To fetch the contents of a 2545e24f5f31STonyregister, it is necessary to use* ``DW_OP_regval_type``\ *, use one of the* 2546e24f5f31STony``DW_OP_breg*`` *register-based addressing operations, or use* ``DW_OP_deref*`` 2547e24f5f31STony*on a register location description.* 2548e24f5f31STony 25490ac939f3STony Tye.. _amdgpu-dwarf-implicit-location-description-operations: 2550e24f5f31STony 25510ac939f3STony TyeA.2.5.4.4.5 Implicit Location Description Operations 25520ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25530ac939f3STony Tye 25540ac939f3STony Tye.. note:: 25550ac939f3STony Tye 25560ac939f3STony Tye This section replaces DWARF Version 5 section 2.6.1.1.4. 2557e24f5f31STony 2558e24f5f31STonyImplicit location storage represents a piece or all of an object which has no 2559e24f5f31STonyactual location in the program but whose contents are nonetheless known, either 2560e24f5f31STonyas a constant or can be computed from other locations and values in the program. 2561e24f5f31STony 2562e24f5f31STonyAn implicit location description specifies an implicit location storage. The bit 2563e24f5f31STonyoffset corresponds to a bit position within the implicit location storage. Bits 2564e24f5f31STonyaccessed using an implicit location description, access the corresponding 2565e24f5f31STonyimplicit storage value starting at the bit offset. 2566e24f5f31STony 2567e24f5f31STony1. ``DW_OP_implicit_value`` 2568e24f5f31STony 2569e24f5f31STony ``DW_OP_implicit_value`` has two operands. The first is an unsigned LEB128 2570e24f5f31STony integer that represents a byte size S. The second is a block of bytes with a 2571e24f5f31STony length equal to S treated as a literal value V. 2572e24f5f31STony 2573e24f5f31STony An implicit location storage LS is created with the literal value V and a 2574e24f5f31STony size of S. 2575e24f5f31STony 2576e24f5f31STony It pushes location description L with one implicit location description SL 2577e24f5f31STony on the stack. SL specifies LS with a bit offset of 0. 2578e24f5f31STony 2579e24f5f31STony2. ``DW_OP_stack_value`` 2580e24f5f31STony 2581e24f5f31STony ``DW_OP_stack_value`` pops one stack entry that must be a value V. 2582e24f5f31STony 2583f79bab3fSTony An implicit location storage LS is created with the literal value V using 25843138fda3STony Tye the size, encoding, and endianity specified by V's base type. 2585e24f5f31STony 2586e24f5f31STony It pushes a location description L with one implicit location description SL 2587e24f5f31STony on the stack. SL specifies LS with a bit offset of 0. 2588e24f5f31STony 2589e24f5f31STony *The* ``DW_OP_stack_value`` *operation specifies that the object does not 2590e24f5f31STony exist in memory, but its value is nonetheless known. In this form, the 2591e24f5f31STony location description specifies the actual value of the object, rather than 2592e24f5f31STony specifying the memory or register storage that holds the value.* 2593e24f5f31STony 2594817f64e7STony Tye See ``DW_OP_implicit_pointer`` (following) for special rules concerning 2595817f64e7STony Tye implicit pointer values produced by dereferencing implicit location 2596817f64e7STony Tye descriptions created by the ``DW_OP_implicit_pointer`` and 2597817f64e7STony Tye ``DW_OP_LLVM_aspace_implicit_pointer`` operations. 2598e24f5f31STony 25993138fda3STony Tye Note: Since location descriptions are allowed on the stack, the 2600e24f5f31STony ``DW_OP_stack_value`` operation no longer terminates the DWARF operation 2601e24f5f31STony expression execution as in DWARF Version 5. 2602e24f5f31STony 2603e24f5f31STony3. ``DW_OP_implicit_pointer`` 2604e24f5f31STony 2605e24f5f31STony *An optimizing compiler may eliminate a pointer, while still retaining the 2606e24f5f31STony value that the pointer addressed.* ``DW_OP_implicit_pointer`` *allows a 2607e24f5f31STony producer to describe this value.* 2608e24f5f31STony 2609e24f5f31STony ``DW_OP_implicit_pointer`` *specifies an object is a pointer to the target 2610e24f5f31STony architecture default address space that cannot be represented as a real 2611e24f5f31STony pointer, even though the value it would point to can be described. In this 2612e24f5f31STony form, the location description specifies a debugging information entry that 2613e24f5f31STony represents the actual location description of the object to which the 2614e24f5f31STony pointer would point. Thus, a consumer of the debug information would be able 2615e24f5f31STony to access the dereferenced pointer, even when it cannot access the pointer 2616e24f5f31STony itself.* 2617e24f5f31STony 2618e24f5f31STony ``DW_OP_implicit_pointer`` has two operands. The first operand is a 4-byte 2619e24f5f31STony unsigned value in the 32-bit DWARF format, or an 8-byte unsigned value in 2620e24f5f31STony the 64-bit DWARF format, that represents the byte offset DR of a debugging 2621e24f5f31STony information entry D relative to the beginning of the ``.debug_info`` section 2622e24f5f31STony that contains the current compilation unit. The second operand is a signed 2623e24f5f31STony LEB128 integer that represents a byte displacement B. 2624e24f5f31STony 2625817f64e7STony Tye *Note that D might not be in the current compilation unit.* 2626e24f5f31STony 2627e24f5f31STony *The first operand interpretation is exactly like that for* 2628e24f5f31STony ``DW_FORM_ref_addr``\ *.* 2629e24f5f31STony 2630e24f5f31STony The address space identifier AS is defined as the one corresponding to the 2631e24f5f31STony target architecture specific default address space. 2632e24f5f31STony 2633e24f5f31STony The address size S is defined as the address bit size of the target 2634e24f5f31STony architecture specific address space corresponding to AS. 2635e24f5f31STony 2636e24f5f31STony An implicit location storage LS is created with the debugging information 2637e24f5f31STony entry D, address space AS, and size of S. 2638e24f5f31STony 2639e24f5f31STony It pushes a location description L that comprises one implicit location 2640e24f5f31STony description SL on the stack. SL specifies LS with a bit offset of 0. 2641e24f5f31STony 2642e24f5f31STony It is an evaluation error if a ``DW_OP_deref*`` operation pops a location 2643e24f5f31STony description L', and retrieves S bits, such that any retrieved bits come from 2644e24f5f31STony an implicit location storage that is the same as LS, unless both the 2645e24f5f31STony following conditions are met: 2646e24f5f31STony 2647e24f5f31STony 1. All retrieved bits come from an implicit location description that 2648e24f5f31STony refers to an implicit location storage that is the same as LS. 2649e24f5f31STony 2650e24f5f31STony *Note that all bits do not have to come from the same implicit location 2651817f64e7STony Tye description, as L' may involve composite location descriptions.* 2652e24f5f31STony 2653e24f5f31STony 2. The bits come from consecutive ascending offsets within their respective 2654e24f5f31STony implicit location storage. 2655e24f5f31STony 2656e24f5f31STony *These rules are equivalent to retrieving the complete contents of LS.* 2657e24f5f31STony 2658e24f5f31STony If both the above conditions are met, then the value V pushed by the 2659e24f5f31STony ``DW_OP_deref*`` operation is an implicit pointer value IPV with a target 2660e24f5f31STony architecture specific address space of AS, a debugging information entry of 2661e24f5f31STony D, and a base type of T. If AS is the target architecture default address 2662e24f5f31STony space, then T is the generic type. Otherwise, T is a target architecture 2663e24f5f31STony specific integral type with a bit size equal to S. 2664e24f5f31STony 2665e24f5f31STony If IPV is either implicitly converted to a location description (only done 2666e24f5f31STony if AS is the target architecture default address space) or used by 2667e24f5f31STony ``DW_OP_LLVM_form_aspace_address`` (only done if the address space popped by 2668e24f5f31STony ``DW_OP_LLVM_form_aspace_address`` is AS), then the resulting location 2669e24f5f31STony description RL is: 2670e24f5f31STony 2671e24f5f31STony * If D has a ``DW_AT_location`` attribute, the DWARF expression E from the 2672e24f5f31STony ``DW_AT_location`` attribute is evaluated with the current context, except 2673e24f5f31STony that the result kind is a location description, the compilation unit is 2674e24f5f31STony the one that contains D, the object is unspecified, and the initial stack 2675e24f5f31STony is empty. RL is the expression result. 2676e24f5f31STony 2677e24f5f31STony *Note that E is evaluated with the context of the expression accessing 2678e24f5f31STony IPV, and not the context of the expression that contained the* 2679e24f5f31STony ``DW_OP_implicit_pointer`` *or* ``DW_OP_LLVM_aspace_implicit_pointer`` 2680e24f5f31STony *operation that created L.* 2681e24f5f31STony 2682e24f5f31STony * If D has a ``DW_AT_const_value`` attribute, then an implicit location 2683e24f5f31STony storage RLS is created from the ``DW_AT_const_value`` attribute's value 2684e24f5f31STony with a size matching the size of the ``DW_AT_const_value`` attribute's 2685e24f5f31STony value. RL comprises one implicit location description SRL. SRL specifies 2686e24f5f31STony RLS with a bit offset of 0. 2687e24f5f31STony 2688e24f5f31STony .. note:: 2689e24f5f31STony 2690e24f5f31STony If using ``DW_AT_const_value`` for variables and formal parameters is 2691e24f5f31STony deprecated and instead ``DW_AT_location`` is used with an implicit 2692e24f5f31STony location description, then this rule would not be required. 2693e24f5f31STony 2694e24f5f31STony * Otherwise, it is an evaluation error. 2695e24f5f31STony 2696e24f5f31STony The bit offset of RL is updated as if the ``DW_OP_LLVM_offset_uconst B`` 2697e24f5f31STony operation was applied. 2698e24f5f31STony 2699e24f5f31STony If a ``DW_OP_stack_value`` operation pops a value that is the same as IPV, 2700e24f5f31STony then it pushes a location description that is the same as L. 2701e24f5f31STony 2702e24f5f31STony It is an evaluation error if LS or IPV is accessed in any other manner. 2703e24f5f31STony 2704e24f5f31STony *The restrictions on how an implicit pointer location description created 2705e24f5f31STony by* ``DW_OP_implicit_pointer`` *and* ``DW_OP_LLVM_aspace_implicit_pointer`` 2706e24f5f31STony *can be used are to simplify the DWARF consumer. Similarly, for an implicit 27070ac939f3STony Tye pointer value created by* ``DW_OP_deref*`` *and* ``DW_OP_stack_value``\ *.* 2708e24f5f31STony 2709e24f5f31STony4. ``DW_OP_LLVM_aspace_implicit_pointer`` *New* 2710e24f5f31STony 2711e24f5f31STony ``DW_OP_LLVM_aspace_implicit_pointer`` has two operands that are the same as 2712e24f5f31STony for ``DW_OP_implicit_pointer``. 2713e24f5f31STony 2714e24f5f31STony It pops one stack entry that must be an integral type value that represents 2715e24f5f31STony a target architecture specific address space identifier AS. 2716e24f5f31STony 2717e24f5f31STony The location description L that is pushed on the stack is the same as for 2718e24f5f31STony ``DW_OP_implicit_pointer``, except that the address space identifier used is 2719e24f5f31STony AS. 2720e24f5f31STony 2721e24f5f31STony The DWARF expression is ill-formed if AS is not one of the values defined by 27223138fda3STony Tye the target architecture specific ``DW_ASPACE_LLVM_*`` values. 2723e24f5f31STony 2724e24f5f31STony .. note:: 2725e24f5f31STony 2726e24f5f31STony This definition of ``DW_OP_LLVM_aspace_implicit_pointer`` may change when 2727e24f5f31STony full support for address classes is added as required for languages such 2728e24f5f31STony as OpenCL/SyCL. 2729e24f5f31STony 2730e24f5f31STony*Typically a* ``DW_OP_implicit_pointer`` *or* 2731e24f5f31STony``DW_OP_LLVM_aspace_implicit_pointer`` *operation is used in a DWARF expression 2732e24f5f31STonyE*\ :sub:`1` *of a* ``DW_TAG_variable`` *or* ``DW_TAG_formal_parameter`` 2733e24f5f31STony*debugging information entry D*\ :sub:`1`\ *'s* ``DW_AT_location`` *attribute. 2734e24f5f31STonyThe debugging information entry referenced by the* ``DW_OP_implicit_pointer`` 2735e24f5f31STony*or* ``DW_OP_LLVM_aspace_implicit_pointer`` *operations is typically itself a* 2736e24f5f31STony``DW_TAG_variable`` *or* ``DW_TAG_formal_parameter`` *debugging information 2737e24f5f31STonyentry D*\ :sub:`2` *whose* ``DW_AT_location`` *attribute gives a second DWARF 2738e24f5f31STonyexpression E*\ :sub:`2`\ *.* 2739e24f5f31STony 2740e24f5f31STony*D*\ :sub:`1` *and E*\ :sub:`1` *are describing the location of a pointer type 2741e24f5f31STonyobject. D*\ :sub:`2` *and E*\ :sub:`2` *are describing the location of the 2742e24f5f31STonyobject pointed to by that pointer object.* 2743e24f5f31STony 2744e24f5f31STony*However, D*\ :sub:`2` *may be any debugging information entry that contains a* 2745e24f5f31STony``DW_AT_location`` *or* ``DW_AT_const_value`` *attribute (for example,* 2746e24f5f31STony``DW_TAG_dwarf_procedure``\ *). By using E*\ :sub:`2`\ *, a consumer can 2747e24f5f31STonyreconstruct the value of the object when asked to dereference the pointer 27480ac939f3STony Tyedescribed by E*\ :sub:`1` *which contains the* ``DW_OP_implicit_pointer`` *or* 2749e24f5f31STony``DW_OP_LLVM_aspace_implicit_pointer`` *operation.* 2750e24f5f31STony 2751e24f5f31STony.. _amdgpu-dwarf-composite-location-description-operations: 2752e24f5f31STony 27530ac939f3STony TyeA.2.5.4.4.6 Composite Location Description Operations 27540ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27550ac939f3STony Tye 27560ac939f3STony Tye.. note:: 27570ac939f3STony Tye 27580ac939f3STony Tye This section replaces DWARF Version 5 section 2.6.1.2. 2759e24f5f31STony 2760e24f5f31STonyA composite location storage represents an object or value which may be 2761e24f5f31STonycontained in part of another location storage or contained in parts of more 2762e24f5f31STonythan one location storage. 2763e24f5f31STony 2764e24f5f31STonyEach part has a part location description L and a part bit size S. L can have 2765e24f5f31STonyone or more single location descriptions SL. If there are more than one SL then 2766e24f5f31STonythat indicates that part is located in more than one place. The bits of each 2767e24f5f31STonyplace of the part comprise S contiguous bits from the location storage LS 2768e24f5f31STonyspecified by SL starting at the bit offset specified by SL. All the bits must 2769e24f5f31STonybe within the size of LS or the DWARF expression is ill-formed. 2770e24f5f31STony 2771e24f5f31STonyA composite location storage can have zero or more parts. The parts are 2772e24f5f31STonycontiguous such that the zero-based location storage bit index will range over 2773e24f5f31STonyeach part with no gaps between them. Therefore, the size of a composite location 2774e24f5f31STonystorage is the sum of the size of its parts. The DWARF expression is ill-formed 2775e24f5f31STonyif the size of the contiguous location storage is larger than the size of the 2776e24f5f31STonymemory location storage corresponding to the largest target architecture 2777e24f5f31STonyspecific address space. 2778e24f5f31STony 2779e24f5f31STonyA composite location description specifies a composite location storage. The bit 2780e24f5f31STonyoffset corresponds to a bit position within the composite location storage. 2781e24f5f31STony 2782e24f5f31STonyThere are operations that create a composite location storage. 2783e24f5f31STony 2784e24f5f31STonyThere are other operations that allow a composite location storage to be 2785e24f5f31STonyincrementally created. Each part is created by a separate operation. There may 2786e24f5f31STonybe one or more operations to create the final composite location storage. A 2787e24f5f31STonyseries of such operations describes the parts of the composite location storage 2788e24f5f31STonythat are in the order that the associated part operations are executed. 2789e24f5f31STony 2790e24f5f31STonyTo support incremental creation, a composite location storage can be in an 2791e24f5f31STonyincomplete state. When an incremental operation operates on an incomplete 2792e24f5f31STonycomposite location storage, it adds a new part, otherwise it creates a new 2793e24f5f31STonycomposite location storage. The ``DW_OP_LLVM_piece_end`` operation explicitly 2794e24f5f31STonymakes an incomplete composite location storage complete. 2795e24f5f31STony 2796e24f5f31STonyA composite location description that specifies a composite location storage 2797e24f5f31STonythat is incomplete is termed an incomplete composite location description. A 2798e24f5f31STonycomposite location description that specifies a composite location storage that 2799e24f5f31STonyis complete is termed a complete composite location description. 2800e24f5f31STony 2801e24f5f31STonyIf the top stack entry is a location description that has one incomplete 2802e24f5f31STonycomposite location description SL after the execution of an operation expression 2803e24f5f31STonyhas completed, SL is converted to a complete composite location description. 2804e24f5f31STony 2805e24f5f31STony*Note that this conversion does not happen after the completion of an operation 2806e24f5f31STonyexpression that is evaluated on the same stack by the* ``DW_OP_call*`` 2807e24f5f31STony*operations. Such executions are not a separate evaluation of an operation 2808e24f5f31STonyexpression, but rather the continued evaluation of the same operation expression 2809e24f5f31STonythat contains the* ``DW_OP_call*`` *operation.* 2810e24f5f31STony 2811e24f5f31STonyIf a stack entry is required to be a location description L, but L has an 2812e24f5f31STonyincomplete composite location description, then the DWARF expression is 2813e24f5f31STonyill-formed. The exception is for the operations involved in incrementally 2814e24f5f31STonycreating a composite location description as described below. 2815e24f5f31STony 2816e24f5f31STony*Note that a DWARF operation expression may arbitrarily compose composite 2817e24f5f31STonylocation descriptions from any other location description, including those that 2818e24f5f31STonyhave multiple single location descriptions, and those that have composite 2819e24f5f31STonylocation descriptions.* 2820e24f5f31STony 2821e24f5f31STony*The incremental composite location description operations are defined to be 2822e24f5f31STonycompatible with the definitions in DWARF Version 5.* 2823e24f5f31STony 2824e24f5f31STony1. ``DW_OP_piece`` 2825e24f5f31STony 2826e24f5f31STony ``DW_OP_piece`` has a single unsigned LEB128 integer that represents a byte 2827e24f5f31STony size S. 2828e24f5f31STony 2829e24f5f31STony The action is based on the context: 2830e24f5f31STony 2831e24f5f31STony * If the stack is empty, then a location description L comprised of one 2832e24f5f31STony incomplete composite location description SL is pushed on the stack. 2833e24f5f31STony 2834e24f5f31STony An incomplete composite location storage LS is created with a single part 2835e24f5f31STony P. P specifies a location description PL and has a bit size of S scaled by 2836e24f5f31STony 8 (the byte size). PL is comprised of one undefined location description 2837e24f5f31STony PSL. 2838e24f5f31STony 2839e24f5f31STony SL specifies LS with a bit offset of 0. 2840e24f5f31STony 2841e24f5f31STony * Otherwise, if the top stack entry is a location description L comprised of 2842e24f5f31STony one incomplete composite location description SL, then the incomplete 2843e24f5f31STony composite location storage LS that SL specifies is updated to append a new 2844e24f5f31STony part P. P specifies a location description PL and has a bit size of S 2845e24f5f31STony scaled by 8 (the byte size). PL is comprised of one undefined location 2846e24f5f31STony description PSL. L is left on the stack. 2847e24f5f31STony 2848e24f5f31STony * Otherwise, if the top stack entry is a location description or can be 2849e24f5f31STony converted to one, then it is popped and treated as a part location 2850e24f5f31STony description PL. Then: 2851e24f5f31STony 2852e24f5f31STony * If the top stack entry (after popping PL) is a location description L 2853e24f5f31STony comprised of one incomplete composite location description SL, then the 2854e24f5f31STony incomplete composite location storage LS that SL specifies is updated to 2855e24f5f31STony append a new part P. P specifies the location description PL and has a 2856e24f5f31STony bit size of S scaled by 8 (the byte size). L is left on the stack. 2857e24f5f31STony 2858e24f5f31STony * Otherwise, a location description L comprised of one incomplete 2859e24f5f31STony composite location description SL is pushed on the stack. 2860e24f5f31STony 2861e24f5f31STony An incomplete composite location storage LS is created with a single 2862e24f5f31STony part P. P specifies the location description PL and has a bit size of S 2863e24f5f31STony scaled by 8 (the byte size). 2864e24f5f31STony 2865e24f5f31STony SL specifies LS with a bit offset of 0. 2866e24f5f31STony 2867e24f5f31STony * Otherwise, the DWARF expression is ill-formed 2868e24f5f31STony 2869e24f5f31STony *Many compilers store a single variable in sets of registers or store a 2870e24f5f31STony variable partially in memory and partially in registers.* ``DW_OP_piece`` 2871e24f5f31STony *provides a way of describing where a part of a variable is located.* 2872e24f5f31STony 2873e24f5f31STony *If a non-0 byte displacement is required, the* ``DW_OP_LLVM_offset`` 2874e24f5f31STony *operation can be used to update the location description before using it as 2875e24f5f31STony the part location description of a* ``DW_OP_piece`` *operation.* 2876e24f5f31STony 2877e24f5f31STony *The evaluation rules for the* ``DW_OP_piece`` *operation allow it to be 2878e24f5f31STony compatible with the DWARF Version 5 definition.* 2879e24f5f31STony 2880e24f5f31STony .. note:: 2881e24f5f31STony 2882e24f5f31STony Since these extensions allow location descriptions to be entries on the 28832817e21cSTony stack, a simpler operation to create composite location descriptions could 28842817e21cSTony be defined. For example, just one operation that specifies how many parts, 28852817e21cSTony and pops pairs of stack entries for the part size and location 28862817e21cSTony description. Not only would this be a simpler operation and avoid the 28872817e21cSTony complexities of incomplete composite location descriptions, but it may 28882817e21cSTony also have a smaller encoding in practice. However, the desire for 28892817e21cSTony compatibility with DWARF Version 5 is likely a stronger consideration. 2890e24f5f31STony 2891e24f5f31STony2. ``DW_OP_bit_piece`` 2892e24f5f31STony 2893e24f5f31STony ``DW_OP_bit_piece`` has two operands. The first is an unsigned LEB128 2894e24f5f31STony integer that represents the part bit size S. The second is an unsigned 2895e24f5f31STony LEB128 integer that represents a bit displacement B. 2896e24f5f31STony 2897e24f5f31STony The action is the same as for ``DW_OP_piece``, except that any part created 2898e24f5f31STony has the bit size S, and the location description PL of any created part is 2899e24f5f31STony updated as if the ``DW_OP_constu B; DW_OP_LLVM_bit_offset`` operations were 2900e24f5f31STony applied. 2901e24f5f31STony 2902e24f5f31STony ``DW_OP_bit_piece`` *is used instead of* ``DW_OP_piece`` *when the piece to 2903e24f5f31STony be assembled is not byte-sized or is not at the start of the part location 2904e24f5f31STony description.* 2905e24f5f31STony 2906e24f5f31STony *If a computed bit displacement is required, the* ``DW_OP_LLVM_bit_offset`` 2907e24f5f31STony *operation can be used to update the location description before using it as 2908e24f5f31STony the part location description of a* ``DW_OP_bit_piece`` *operation.* 2909e24f5f31STony 2910e24f5f31STony .. note:: 2911e24f5f31STony 2912e24f5f31STony The bit offset operand is not needed as ``DW_OP_LLVM_bit_offset`` can be 2913e24f5f31STony used on the part's location description. 2914e24f5f31STony 2915e24f5f31STony3. ``DW_OP_LLVM_piece_end`` *New* 2916e24f5f31STony 2917e24f5f31STony If the top stack entry is not a location description L comprised of one 2918e24f5f31STony incomplete composite location description SL, then the DWARF expression is 2919e24f5f31STony ill-formed. 2920e24f5f31STony 2921e24f5f31STony Otherwise, the incomplete composite location storage LS specified by SL is 2922e24f5f31STony updated to be a complete composite location description with the same parts. 2923e24f5f31STony 2924e24f5f31STony4. ``DW_OP_LLVM_extend`` *New* 2925e24f5f31STony 2926e24f5f31STony ``DW_OP_LLVM_extend`` has two operands. The first is an unsigned LEB128 2927e24f5f31STony integer that represents the element bit size S. The second is an unsigned 2928e24f5f31STony LEB128 integer that represents a count C. 2929e24f5f31STony 2930e24f5f31STony It pops one stack entry that must be a location description and is treated 2931e24f5f31STony as the part location description PL. 2932e24f5f31STony 2933e24f5f31STony A location description L comprised of one complete composite location 2934e24f5f31STony description SL is pushed on the stack. 2935e24f5f31STony 2936e24f5f31STony A complete composite location storage LS is created with C identical parts 2937e24f5f31STony P. Each P specifies PL and has a bit size of S. 2938e24f5f31STony 2939e24f5f31STony SL specifies LS with a bit offset of 0. 2940e24f5f31STony 2941e24f5f31STony The DWARF expression is ill-formed if the element bit size or count are 0. 2942e24f5f31STony 2943e24f5f31STony5. ``DW_OP_LLVM_select_bit_piece`` *New* 2944e24f5f31STony 2945e24f5f31STony ``DW_OP_LLVM_select_bit_piece`` has two operands. The first is an unsigned 2946e24f5f31STony LEB128 integer that represents the element bit size S. The second is an 2947e24f5f31STony unsigned LEB128 integer that represents a count C. 2948e24f5f31STony 2949e24f5f31STony It pops three stack entries. The first must be an integral type value that 2950e24f5f31STony represents a bit mask value M. The second must be a location description 2951e24f5f31STony that represents the one-location description L1. The third must be a 2952e24f5f31STony location description that represents the zero-location description L0. 2953e24f5f31STony 2954e24f5f31STony A complete composite location storage LS is created with C parts P\ :sub:`N` 2955e24f5f31STony ordered in ascending N from 0 to C-1 inclusive. Each P\ :sub:`N` specifies 2956e24f5f31STony location description PL\ :sub:`N` and has a bit size of S. 2957e24f5f31STony 2958e24f5f31STony PL\ :sub:`N` is as if the ``DW_OP_LLVM_bit_offset N*S`` operation was 2959e24f5f31STony applied to PLX\ :sub:`N`\ . 2960e24f5f31STony 2961e24f5f31STony PLX\ :sub:`N` is the same as L0 if the N\ :sup:`th` least significant bit of 2962e24f5f31STony M is a zero, otherwise it is the same as L1. 2963e24f5f31STony 2964e24f5f31STony A location description L comprised of one complete composite location 2965e24f5f31STony description SL is pushed on the stack. SL specifies LS with a bit offset of 2966e24f5f31STony 0. 2967e24f5f31STony 2968e24f5f31STony The DWARF expression is ill-formed if S or C are 0, or if the bit size of M 2969e24f5f31STony is less than C. 2970e24f5f31STony 29713138fda3STony Tye .. note:: 29723138fda3STony Tye 29733138fda3STony Tye Should the count operand for DW_OP_extend and DW_OP_select_bit_piece be 29743138fda3STony Tye changed to get the count value off the stack? This would allow support for 29753138fda3STony Tye architectures that have variable length vector instructions such as ARM 29763138fda3STony Tye and RISC-V. 29773138fda3STony Tye 29788ba5043dSTony Tye6. ``DW_OP_LLVM_overlay`` *New* 29798ba5043dSTony Tye 29808ba5043dSTony Tye ``DW_OP_LLVM_overlay`` pops four stack entries. The first must be an 29818ba5043dSTony Tye integral type value that represents the overlay byte size value S. The 29828ba5043dSTony Tye second must be an integral type value that represents the overlay byte 29838ba5043dSTony Tye offset value O. The third must be a location description that represents the 29848ba5043dSTony Tye overlay location description OL. The fourth must be a location description 29858ba5043dSTony Tye that represents the base location description BL. 29868ba5043dSTony Tye 29878ba5043dSTony Tye The action is the same as for ``DW_OP_LLVM_bit_overlay``, except that the 29888ba5043dSTony Tye overlay bit size BS and overlay bit offset BO used are S and O respectively 29898ba5043dSTony Tye scaled by 8 (the byte size). 29908ba5043dSTony Tye 29918ba5043dSTony Tye7. ``DW_OP_LLVM_bit_overlay`` *New* 29928ba5043dSTony Tye 29938ba5043dSTony Tye ``DW_OP_LLVM_bit_overlay`` pops four stack entries. The first must be an 29948ba5043dSTony Tye integral type value that represents the overlay bit size value BS. The 29958ba5043dSTony Tye second must be an integral type value that represents the overlay bit offset 29968ba5043dSTony Tye value BO. The third must be a location description that represents the 29978ba5043dSTony Tye overlay location description OL. The fourth must be a location description 29988ba5043dSTony Tye that represents the base location description BL. 29998ba5043dSTony Tye 30008ba5043dSTony Tye The DWARF expression is ill-formed if BS or BO are negative values. 30018ba5043dSTony Tye 30028ba5043dSTony Tye *rbss(L)* is the minimum remaining bit storage size of L which is defined as 30038ba5043dSTony Tye follows. LS is the location storage and LO is the location bit offset 30040fde0f41STony Tye specified by a single location description SL of L. The remaining bit 30058ba5043dSTony Tye storage size RBSS of SL is the bit size of LS minus LO. *rbss(L)* is the 30068ba5043dSTony Tye minimum RBSS of each single location description SL of L. 30078ba5043dSTony Tye 30088ba5043dSTony Tye The DWARF expression is ill-formed if *rbss(BL)* is less than BO plus BS. 30098ba5043dSTony Tye 30108ba5043dSTony Tye If BS is 0, then the operation pushes BL. 30118ba5043dSTony Tye 30128ba5043dSTony Tye If BO is 0 and BS equals *rbss(BL)*, then the operation pushes OL. 30138ba5043dSTony Tye 30148ba5043dSTony Tye Otherwise, the operation is equivalent to performing the following steps to 30158ba5043dSTony Tye push a composite location description. 30168ba5043dSTony Tye 30178ba5043dSTony Tye *The composite location description is conceptually the base location 30188ba5043dSTony Tye description BL with the overlay location description OL positioned as an 30198ba5043dSTony Tye overlay starting at the overlay offset BO and covering overlay bit size BS.* 30208ba5043dSTony Tye 30218ba5043dSTony Tye 1. If BO is not 0 then push BL followed by performing the ``DW_OP_bit_piece 30220fde0f41STony Tye BO, 0`` operation. 30230fde0f41STony Tye 2. Push OL followed by performing the ``DW_OP_bit_piece BS, 0`` operation. 30248ba5043dSTony Tye 3. If *rbss(BL)* is greater than BO plus BS, push BL followed by performing 30250fde0f41STony Tye the ``DW_OP_bit_piece (rbss(BL) - BO - BS), (BO + BS)`` operation. 30268ba5043dSTony Tye 4. Perform the ``DW_OP_LLVM_piece_end`` operation. 30278ba5043dSTony Tye 3028e24f5f31STony.. _amdgpu-dwarf-location-list-expressions: 3029e24f5f31STony 30300ac939f3STony TyeA.2.5.5 DWARF Location List Expressions 30310ac939f3STony Tye+++++++++++++++++++++++++++++++++++++++ 30320ac939f3STony Tye 30330ac939f3STony Tye.. note:: 30340ac939f3STony Tye 30350ac939f3STony Tye This section replaces DWARF Version 5 section 2.6.2. 3036e24f5f31STony 3037e24f5f31STony*To meet the needs of recent computer architectures and optimization techniques, 3038e24f5f31STonydebugging information must be able to describe the location of an object whose 3039e24f5f31STonylocation changes over the object’s lifetime, and may reside at multiple 3040e24f5f31STonylocations during parts of an object's lifetime. Location list expressions are 3041e24f5f31STonyused in place of operation expressions whenever the object whose location is 3042e24f5f31STonybeing described has these requirements.* 3043e24f5f31STony 3044e24f5f31STonyA location list expression consists of a series of location list entries. Each 3045e24f5f31STonylocation list entry is one of the following kinds: 3046e24f5f31STony 3047e24f5f31STony*Bounded location description* 3048e24f5f31STony 3049e24f5f31STony This kind of location list entry provides an operation expression that 3050e24f5f31STony evaluates to the location description of an object that is valid over a 3051e24f5f31STony lifetime bounded by a starting and ending address. The starting address is the 3052e24f5f31STony lowest address of the address range over which the location is valid. The 3053e24f5f31STony ending address is the address of the first location past the highest address 3054e24f5f31STony of the address range. 3055e24f5f31STony 3056e24f5f31STony The location list entry matches when the current program location is within 3057e24f5f31STony the given range. 3058e24f5f31STony 3059e24f5f31STony There are several kinds of bounded location description entries which differ 3060e24f5f31STony in the way that they specify the starting and ending addresses. 3061e24f5f31STony 3062e24f5f31STony*Default location description* 3063e24f5f31STony 3064e24f5f31STony This kind of location list entry provides an operation expression that 3065e24f5f31STony evaluates to the location description of an object that is valid when no 3066e24f5f31STony bounded location description entry applies. 3067e24f5f31STony 3068e24f5f31STony The location list entry matches when the current program location is not 3069e24f5f31STony within the range of any bounded location description entry. 3070e24f5f31STony 3071e24f5f31STony*Base address* 3072e24f5f31STony 3073e24f5f31STony This kind of location list entry provides an address to be used as the base 3074e24f5f31STony address for beginning and ending address offsets given in certain kinds of 3075e24f5f31STony bounded location description entries. The applicable base address of a bounded 3076e24f5f31STony location description entry is the address specified by the closest preceding 3077e24f5f31STony base address entry in the same location list. If there is no preceding base 3078e24f5f31STony address entry, then the applicable base address defaults to the base address 3079e24f5f31STony of the compilation unit (see DWARF Version 5 section 3.1.1). 3080e24f5f31STony 3081e24f5f31STony In the case of a compilation unit where all of the machine code is contained 3082e24f5f31STony in a single contiguous section, no base address entry is needed. 3083e24f5f31STony 3084e24f5f31STony*End-of-list* 3085e24f5f31STony 3086e24f5f31STony This kind of location list entry marks the end of the location list 3087e24f5f31STony expression. 3088e24f5f31STony 3089e24f5f31STonyThe address ranges defined by the bounded location description entries of a 3090e24f5f31STonylocation list expression may overlap. When they do, they describe a situation in 3091e24f5f31STonywhich an object exists simultaneously in more than one place. 3092e24f5f31STony 3093e24f5f31STonyIf all of the address ranges in a given location list expression do not 3094e24f5f31STonycollectively cover the entire range over which the object in question is 3095e24f5f31STonydefined, and there is no following default location description entry, it is 3096e24f5f31STonyassumed that the object is not available for the portion of the range that is 3097e24f5f31STonynot covered. 3098e24f5f31STony 3099e24f5f31STonyThe result of the evaluation of a DWARF location list expression is: 3100e24f5f31STony 3101e24f5f31STony* If the current program location is not specified, then it is an evaluation 3102e24f5f31STony error. 3103e24f5f31STony 3104e24f5f31STony .. note:: 3105e24f5f31STony 3106e24f5f31STony If the location list only has a single default entry, should that be 3107e24f5f31STony considered a match if there is no program location? If there are non-default 3108e24f5f31STony entries then it seems it has to be an evaluation error when there is no 3109e24f5f31STony program location as that indicates the location depends on the program 3110e24f5f31STony location which is not known. 3111e24f5f31STony 3112e24f5f31STony* If there are no matching location list entries, then the result is a location 3113e24f5f31STony description that comprises one undefined location description. 3114e24f5f31STony 3115e24f5f31STony* Otherwise, the operation expression E of each matching location list entry is 3116e24f5f31STony evaluated with the current context, except that the result kind is a location 3117e24f5f31STony description, the object is unspecified, and the initial stack is empty. The 3118e24f5f31STony location list entry result is the location description returned by the 3119e24f5f31STony evaluation of E. 3120e24f5f31STony 3121e24f5f31STony The result is a location description that is comprised of the union of the 3122e24f5f31STony single location descriptions of the location description result of each 3123e24f5f31STony matching location list entry. 3124e24f5f31STony 3125e24f5f31STonyA location list expression can only be used as the value of a debugger 3126e24f5f31STonyinformation entry attribute that is encoded using class ``loclist`` or 31270ac939f3STony Tye``loclistsptr`` (see :ref:`amdgpu-dwarf-classes-and-forms`). The value of the 31280ac939f3STony Tyeattribute provides an index into a separate object file section called 31290ac939f3STony Tye``.debug_loclists`` or ``.debug_loclists.dwo`` (for split DWARF object files) 31300ac939f3STony Tyethat contains the location list entries. 3131e24f5f31STony 3132e24f5f31STonyA ``DW_OP_call*`` and ``DW_OP_implicit_pointer`` operation can be used to 3133e24f5f31STonyspecify a debugger information entry attribute that has a location list 3134e24f5f31STonyexpression. Several debugger information entry attributes allow DWARF 3135e24f5f31STonyexpressions that are evaluated with an initial stack that includes a location 3136e24f5f31STonydescription that may originate from the evaluation of a location list 3137e24f5f31STonyexpression. 3138e24f5f31STony 3139e24f5f31STony*This location list representation, the* ``loclist`` *and* ``loclistsptr`` 3140e24f5f31STony*class, and the related* ``DW_AT_loclists_base`` *attribute are new in DWARF 3141e24f5f31STonyVersion 5. Together they eliminate most, or all of the code object relocations 3142e24f5f31STonypreviously needed for location list expressions.* 3143e24f5f31STony 3144e24f5f31STony.. note:: 3145e24f5f31STony 3146e24f5f31STony The rest of this section is the same as DWARF Version 5 section 2.6.2. 3147e24f5f31STony 31483138fda3STony Tye.. _amdgpu-dwarf-address-spaces: 3149e24f5f31STony 31503138fda3STony TyeA.2.13 Address Spaces 31513138fda3STony Tye~~~~~~~~~~~~~~~~~~~~~ 3152e24f5f31STony 3153e24f5f31STony.. note:: 3154e24f5f31STony 31553138fda3STony Tye This is a new section after DWARF Version 5 section 2.12 Segmented Addresses. 3156e24f5f31STony 3157e24f5f31STonyDWARF address spaces correspond to target architecture specific linear 3158e24f5f31STonyaddressable memory areas. They are used in DWARF expression location 3159e24f5f31STonydescriptions to describe in which target architecture specific memory area data 3160e24f5f31STonyresides. 3161e24f5f31STony 3162e24f5f31STony*Target architecture specific DWARF address spaces may correspond to hardware 3163e24f5f31STonysupported facilities such as memory utilizing base address registers, scratchpad 3164e24f5f31STonymemory, and memory with special interleaving. The size of addresses in these 3165e24f5f31STonyaddress spaces may vary. Their access and allocation may be hardware managed 3166e24f5f31STonywith each thread or group of threads having access to independent storage. For 3167e24f5f31STonythese reasons they may have properties that do not allow them to be viewed as 3168e24f5f31STonypart of the unified global virtual address space accessible by all threads.* 3169e24f5f31STony 3170e24f5f31STony*It is target architecture specific whether multiple DWARF address spaces are 31713138fda3STony Tyesupported and how source language memory spaces map to target architecture 31723138fda3STony Tyespecific DWARF address spaces. A target architecture may map multiple source 31733138fda3STony Tyelanguage memory spaces to the same target architecture specific DWARF address 31743138fda3STony Tyeclass. Optimization may determine that variable lifetime and access pattern 31753138fda3STony Tyeallows them to be allocated in faster scratchpad memory represented by a 31763138fda3STony Tyedifferent DWARF address space than the default for the source language memory 31773138fda3STony Tyespace.* 3178e24f5f31STony 3179e24f5f31STonyAlthough DWARF address space identifiers are target architecture specific, 31803138fda3STony Tye``DW_ASPACE_LLVM_none`` is a common address space supported by all target 31813138fda3STony Tyearchitectures, and defined as the target architecture default address space. 3182e24f5f31STony 3183e24f5f31STonyDWARF address space identifiers are used by: 3184e24f5f31STony 31853138fda3STony Tye* The ``DW_AT_LLVM_address_space`` attribute. 3186e24f5f31STony 31873138fda3STony Tye* The DWARF expression operations: ``DW_OP_aspace_bregx``, 31883138fda3STony Tye ``DW_OP_form_aspace_address``, ``DW_OP_aspace_implicit_pointer``, and 31893138fda3STony Tye ``DW_OP_xderef*``. 3190e24f5f31STony 31913138fda3STony Tye* The CFI instructions: ``DW_CFA_def_aspace_cfa`` and 31923138fda3STony Tye ``DW_CFA_def_aspace_cfa_sf``. 3193e24f5f31STony 3194e24f5f31STony.. note:: 3195e24f5f31STony 3196e24f5f31STony Currently, DWARF defines address class values as being target architecture 31973138fda3STony Tye specific, and defines a DW_AT_address_class attribute. With the removal of 31983138fda3STony Tye DW_AT_segment in DWARF 6, it is unclear how the address class is intended to 31993138fda3STony Tye be used as the term is not used elsewhere. Should these be replaced by this 32003138fda3STony Tye proposal's more complete address space? Or are they intended to represent 32013138fda3STony Tye source language memory spaces such as in OpenCL? 3202e24f5f31STony 32033138fda3STony Tye.. _amdgpu-dwarf-memory-spaces: 3204e24f5f31STony 32053138fda3STony TyeA.2.14 Memory Spaces 32063138fda3STony Tye~~~~~~~~~~~~~~~~~~~~ 3207e24f5f31STony 32083138fda3STony Tye.. note:: 3209e24f5f31STony 32103138fda3STony Tye This is a new section after DWARF Version 5 section 2.12 Segmented Addresses. 3211e24f5f31STony 32123138fda3STony TyeDWARF memory spaces are used for source languages that have the concept of 32133138fda3STony Tyememory spaces. They are used in the ``DW_AT_LLVM_memory_space`` attribute for 32143138fda3STony Tyepointer type, reference type, variable, formal parameter, and constant debugger 32153138fda3STony Tyeinformation entries. 3216e24f5f31STony 32173138fda3STony TyeEach DWARF memory space is conceptually a separate source language memory space 32183138fda3STony Tyewith its own lifetime and aliasing rules. DWARF memory spaces are used to 32193138fda3STony Tyespecify the source language memory spaces that pointer type and reference type 32203138fda3STony Tyevalues refer, and to specify the source language memory space in which variables 32213138fda3STony Tyeare allocated. 3222e24f5f31STony 32233138fda3STony TyeAlthough DWARF memory space identifiers are source language specific, 32243138fda3STony Tye``DW_MSPACE_LLVM_none`` is a common memory space supported by all source 32253138fda3STony Tyelanguages, and defined as the source language default memory space. 3226e24f5f31STony 32273138fda3STony TyeThe set of currently defined DWARF memory spaces, together with source language 32283138fda3STony Tyemappings, is given in :ref:`amdgpu-dwarf-source-language-memory-spaces-table`. 32293138fda3STony Tye 32303138fda3STony TyeVendor defined source language memory spaces may be defined using codes in the 32313138fda3STony Tyerange ``DW_MSPACE_LLVM_lo_user`` to ``DW_MSPACE_LLVM_hi_user``. 32323138fda3STony Tye 32333138fda3STony Tye.. table:: Source language memory spaces 32343138fda3STony Tye :name: amdgpu-dwarf-source-language-memory-spaces-table 32353138fda3STony Tye 32363138fda3STony Tye =========================== ============ ============== ============== ============== 32373138fda3STony Tye Memory Space Name Meaning C/C++ OpenCL CUDA/HIP 32383138fda3STony Tye =========================== ============ ============== ============== ============== 32393138fda3STony Tye ``DW_MSPACE_LLVM_none`` generic *default* generic *default* 32403138fda3STony Tye ``DW_MSPACE_LLVM_global`` global global 32413138fda3STony Tye ``DW_MSPACE_LLVM_constant`` constant constant constant 32423138fda3STony Tye ``DW_MSPACE_LLVM_group`` thread-group local shared 32433138fda3STony Tye ``DW_MSPACE_LLVM_private`` thread private 32443138fda3STony Tye ``DW_MSPACE_LLVM_lo_user`` 32453138fda3STony Tye ``DW_MSPACE_LLVM_hi_user`` 32463138fda3STony Tye =========================== ============ ============== ============== ============== 32473138fda3STony Tye 32483138fda3STony Tye.. note:: 32493138fda3STony Tye 32503138fda3STony Tye The approach presented in 32513138fda3STony Tye :ref:`amdgpu-dwarf-source-language-memory-spaces-table` is to define the 32523138fda3STony Tye default ``DW_MSPACE_LLVM_none`` to be the generic address class and not the 3253e24f5f31STony global address class. This matches how CLANG and LLVM have added support for 3254e24f5f31STony CUDA-like languages on top of existing C++ language support. This allows all 3255e24f5f31STony addresses to be generic by default which matches CUDA-like languages. 3256e24f5f31STony 32573138fda3STony Tye An alternative approach is to define ``DW_MSPACE_LLVM_none`` as being the 32583138fda3STony Tye global memory space and then change ``DW_MSPACE_LLVM_global`` to 32593138fda3STony Tye ``DW_MSPACE_LLVM_generic``. This would match the reality that languages that 32603138fda3STony Tye do not support multiple memory spaces only have one default global memory 32613138fda3STony Tye space. Generally, in these languages if they expose that the target 32623138fda3STony Tye architecture supports multiple memory spaces, the default one is still the 32633138fda3STony Tye global memory space. Then a language that does support multiple memory spaces 32643138fda3STony Tye has to explicitly indicate which pointers have the added ability to reference 32653138fda3STony Tye more than the global memory space. However, compilers generating DWARF for 3266e24f5f31STony CUDA-like languages would then have to define every CUDA-like language pointer 32673138fda3STony Tye type or reference type with a ``DW_AT_LLVM_memory_space`` attribute of 32683138fda3STony Tye ``DW_MSPACE_LLVM_generic`` to match the language semantics. 3269e24f5f31STony 32700ac939f3STony TyeA.3 Program Scope Entries 32710ac939f3STony Tye------------------------- 3272e24f5f31STony 3273e24f5f31STony.. note:: 3274e24f5f31STony 3275e24f5f31STony This section provides changes to existing debugger information entry 32760ac939f3STony Tye attributes. These would be incorporated into the corresponding DWARF Version 5 32770ac939f3STony Tye chapter 3 sections. 3278e24f5f31STony 32790ac939f3STony TyeA.3.1 Unit Entries 32800ac939f3STony Tye~~~~~~~~~~~~~~~~~~ 3281e24f5f31STony 32820ac939f3STony Tye.. _amdgpu-dwarf-full-and-partial-compilation-unit-entries: 32830ac939f3STony Tye 32840ac939f3STony TyeA.3.1.1 Full and Partial Compilation Unit Entries 32850ac939f3STony Tye+++++++++++++++++++++++++++++++++++++++++++++++++ 32860ac939f3STony Tye 32870ac939f3STony Tye.. note:: 32880ac939f3STony Tye 32890ac939f3STony Tye This augments DWARF Version 5 section 3.1.1 and Table 3.1. 32900ac939f3STony Tye 32910ac939f3STony TyeAdditional language codes defined for use with the ``DW_AT_language`` attribute 32920ac939f3STony Tyeare defined in :ref:`amdgpu-dwarf-language-names-table`. 32930ac939f3STony Tye 32940ac939f3STony Tye.. table:: Language Names 32950ac939f3STony Tye :name: amdgpu-dwarf-language-names-table 32960ac939f3STony Tye 32970ac939f3STony Tye ==================== ============================= 32980ac939f3STony Tye Language Name Meaning 32990ac939f3STony Tye ==================== ============================= 33000ac939f3STony Tye ``DW_LANG_LLVM_HIP`` HIP Language. 33010ac939f3STony Tye ==================== ============================= 33020ac939f3STony Tye 33030ac939f3STony TyeThe HIP language [:ref:`HIP <amdgpu-dwarf-HIP>`] can be supported by extending 33040ac939f3STony Tyethe C++ language. 33050ac939f3STony Tye 33060ac939f3STony Tye.. note:: 33070ac939f3STony Tye 33080ac939f3STony Tye The following new attribute is added. 33090ac939f3STony Tye 33100ac939f3STony Tye1. A ``DW_TAG_compile_unit`` debugger information entry for a compilation unit 33110ac939f3STony Tye may have a ``DW_AT_LLVM_augmentation`` attribute, whose value is an 33120ac939f3STony Tye augmentation string. 33130ac939f3STony Tye 33140ac939f3STony Tye *The augmentation string allows producers to indicate that there is 33150ac939f3STony Tye additional vendor or target specific information in the debugging 33160ac939f3STony Tye information entries. For example, this might be information about the 33170ac939f3STony Tye version of vendor specific extensions that are being used.* 33180ac939f3STony Tye 33190ac939f3STony Tye If not present, or if the string is empty, then the compilation unit has no 33200ac939f3STony Tye augmentation string. 33210ac939f3STony Tye 33220ac939f3STony Tye The format for the augmentation string is: 33230ac939f3STony Tye 33240ac939f3STony Tye | ``[``\ *vendor*\ ``:v``\ *X*\ ``.``\ *Y*\ [\ ``:``\ *options*\ ]\ ``]``\ * 33250ac939f3STony Tye 33260ac939f3STony Tye Where *vendor* is the producer, ``vX.Y`` specifies the major X and minor Y 33270ac939f3STony Tye version number of the extensions used, and *options* is an optional string 33280ac939f3STony Tye providing additional information about the extensions. The version number 33290ac939f3STony Tye must conform to semantic versioning [:ref:`SEMVER <amdgpu-dwarf-SEMVER>`]. 33300ac939f3STony Tye The *options* string must not contain the "\ ``]``\ " character. 33310ac939f3STony Tye 33320ac939f3STony Tye For example: 33330ac939f3STony Tye 33340ac939f3STony Tye :: 33350ac939f3STony Tye 33360ac939f3STony Tye [abc:v0.0][def:v1.2:feature-a=on,feature-b=3] 33370ac939f3STony Tye 33380ac939f3STony TyeA.3.3 Subroutine and Entry Point Entries 33390ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 33400ac939f3STony Tye 33410ac939f3STony Tye.. _amdgpu-dwarf-low-level-information: 33420ac939f3STony Tye 33430ac939f3STony TyeA.3.3.5 Low-Level Information 33440ac939f3STony Tye+++++++++++++++++++++++++++++ 33450ac939f3STony Tye 33460ac939f3STony Tye1. A ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or 33470ac939f3STony Tye ``DW_TAG_entry_point`` debugger information entry may have a 33480ac939f3STony Tye ``DW_AT_return_addr`` attribute, whose value is a DWARF expression E. 33490ac939f3STony Tye 33500ac939f3STony Tye The result of the attribute is obtained by evaluating E with a context that 33510ac939f3STony Tye has a result kind of a location description, an unspecified object, the 33520ac939f3STony Tye compilation unit that contains E, an empty initial stack, and other context 33530ac939f3STony Tye elements corresponding to the source language thread of execution upon which 33540ac939f3STony Tye the user is focused, if any. The result of the evaluation is the location 33550ac939f3STony Tye description L of the place where the return address for the current call 33560ac939f3STony Tye frame's subprogram or entry point is stored. 33570ac939f3STony Tye 33580ac939f3STony Tye The DWARF is ill-formed if L is not comprised of one memory location 33590ac939f3STony Tye description for one of the target architecture specific address spaces. 33600ac939f3STony Tye 33610ac939f3STony Tye .. note:: 33620ac939f3STony Tye 33630ac939f3STony Tye It is unclear why ``DW_TAG_inlined_subroutine`` has a 33640ac939f3STony Tye ``DW_AT_return_addr`` attribute but not a ``DW_AT_frame_base`` or 33650ac939f3STony Tye ``DW_AT_static_link`` attribute. Seems it would either have all of them or 33660ac939f3STony Tye none. Since inlined subprograms do not have a call frame it seems they 33670ac939f3STony Tye would have none of these attributes. 33680ac939f3STony Tye 33690ac939f3STony Tye2. A ``DW_TAG_subprogram`` or ``DW_TAG_entry_point`` debugger information entry 33700ac939f3STony Tye may have a ``DW_AT_frame_base`` attribute, whose value is a DWARF expression 33710ac939f3STony Tye E. 33720ac939f3STony Tye 33730ac939f3STony Tye The result of the attribute is obtained by evaluating E with a context that 33740ac939f3STony Tye has a result kind of a location description, an unspecified object, the 33750ac939f3STony Tye compilation unit that contains E, an empty initial stack, and other context 33760ac939f3STony Tye elements corresponding to the source language thread of execution upon which 33770ac939f3STony Tye the user is focused, if any. 33780ac939f3STony Tye 3379817f64e7STony Tye The DWARF is ill-formed if E contains a ``DW_OP_fbreg`` operation, or the 33800ac939f3STony Tye resulting location description L is not comprised of one single location 33810ac939f3STony Tye description SL. 33820ac939f3STony Tye 33830ac939f3STony Tye If SL is a register location description for register R, then L is replaced 33840ac939f3STony Tye with the result of evaluating a ``DW_OP_bregx R, 0`` operation. This 33850ac939f3STony Tye computes the frame base memory location description in the target 33860ac939f3STony Tye architecture default address space. 33870ac939f3STony Tye 33880ac939f3STony Tye *This allows the more compact* ``DW_OP_reg*`` *to be used instead of* 33890ac939f3STony Tye ``DW_OP_breg* 0``\ *.* 33900ac939f3STony Tye 33910ac939f3STony Tye .. note:: 33920ac939f3STony Tye 33930ac939f3STony Tye This rule could be removed and require the producer to create the required 33940ac939f3STony Tye location description directly using ``DW_OP_call_frame_cfa``, 33950ac939f3STony Tye ``DW_OP_breg*``, or ``DW_OP_LLVM_aspace_bregx``. This would also then 33960ac939f3STony Tye allow a target to implement the call frames within a large register. 33970ac939f3STony Tye 33980ac939f3STony Tye Otherwise, the DWARF is ill-formed if SL is not a memory location 33990ac939f3STony Tye description in any of the target architecture specific address spaces. 34000ac939f3STony Tye 34010ac939f3STony Tye The resulting L is the *frame base* for the subprogram or entry point. 34020ac939f3STony Tye 34030ac939f3STony Tye *Typically, E will use the* ``DW_OP_call_frame_cfa`` *operation or be a 34040ac939f3STony Tye stack pointer register plus or minus some offset.* 34050ac939f3STony Tye 34063138fda3STony Tye *The frame base for a subprogram is typically an address relative to the 34073138fda3STony Tye first unit of storage allocated for the subprogram's stack frame. The* 34083138fda3STony Tye ``DW_AT_frame_base`` *attribute can be used in several ways:* 34093138fda3STony Tye 34103138fda3STony Tye 1. *In subprograms that need location lists to locate local variables, the* 34113138fda3STony Tye ``DW_AT_frame_base`` *can hold the needed location list, while all 34123138fda3STony Tye variables' location descriptions can be simpler ones involving the frame 34133138fda3STony Tye base.* 34143138fda3STony Tye 34153138fda3STony Tye 2. *It can be used in resolving "up-level" addressing within 34163138fda3STony Tye nested routines. (See also* ``DW_AT_static_link``\ *, below)* 34173138fda3STony Tye 34183138fda3STony Tye *Some languages support nested subroutines. In such languages, it is 34193138fda3STony Tye possible to reference the local variables of an outer subroutine from within 34203138fda3STony Tye an inner subroutine. The* ``DW_AT_static_link`` *and* ``DW_AT_frame_base`` 34213138fda3STony Tye *attributes allow debuggers to support this same kind of referencing.* 34223138fda3STony Tye 34230ac939f3STony Tye3. If a ``DW_TAG_subprogram`` or ``DW_TAG_entry_point`` debugger information 34240ac939f3STony Tye entry is lexically nested, it may have a ``DW_AT_static_link`` attribute, 34250ac939f3STony Tye whose value is a DWARF expression E. 34260ac939f3STony Tye 34270ac939f3STony Tye The result of the attribute is obtained by evaluating E with a context that 34280ac939f3STony Tye has a result kind of a location description, an unspecified object, the 34290ac939f3STony Tye compilation unit that contains E, an empty initial stack, and other context 34300ac939f3STony Tye elements corresponding to the source language thread of execution upon which 34310ac939f3STony Tye the user is focused, if any. The result of the evaluation is the location 34320ac939f3STony Tye description L of the *canonical frame address* (see 34330ac939f3STony Tye :ref:`amdgpu-dwarf-call-frame-information`) of the relevant call frame of 34340ac939f3STony Tye the subprogram instance that immediately lexically encloses the current call 34350ac939f3STony Tye frame's subprogram or entry point. 34360ac939f3STony Tye 3437817f64e7STony Tye The DWARF is ill-formed if L is not comprised of one memory location 34380ac939f3STony Tye description for one of the target architecture specific address spaces. 34390ac939f3STony Tye 34403138fda3STony Tye In the context of supporting nested subroutines, the DW_AT_frame_base 34413138fda3STony Tye attribute value obeys the following constraints: 34423138fda3STony Tye 34433138fda3STony Tye 1. It computes a value that does not change during the life of the 34443138fda3STony Tye subprogram, and 34453138fda3STony Tye 34463138fda3STony Tye 2. The computed value is unique among instances of the same subroutine. 34473138fda3STony Tye 34483138fda3STony Tye *For typical DW_AT_frame_base use, this means that a recursive subroutine's 34493138fda3STony Tye stack frame must have non-zero size.* 34503138fda3STony Tye 34513138fda3STony Tye *If a debugger is attempting to resolve an up-level reference to a variable, 34523138fda3STony Tye it uses the nesting structure of DWARF to determine which subroutine is the 34533138fda3STony Tye lexical parent and the* ``DW_AT_static_link`` *value to identify the 34543138fda3STony Tye appropriate active frame of the parent. It can then attempt to find the 34553138fda3STony Tye reference within the context of the parent.* 34563138fda3STony Tye 34570ac939f3STony Tye .. note:: 34580ac939f3STony Tye 34590ac939f3STony Tye The following new attributes are added. 34600ac939f3STony Tye 34618ba5043dSTony Tye4. For languages that are implemented using a SIMT execution model, a 34620ac939f3STony Tye ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or 34630ac939f3STony Tye ``DW_TAG_entry_point`` debugger information entry may have a 34640ac939f3STony Tye ``DW_AT_LLVM_lanes`` attribute whose value is an integer constant that is 34658ba5043dSTony Tye the number of source language threads of execution per target architecture 34668ba5043dSTony Tye thread. 34678ba5043dSTony Tye 34688ba5043dSTony Tye *For example, a compiler may map source language threads of execution onto 34698ba5043dSTony Tye lanes of a target architecture thread using a SIMT execution model.* 34708ba5043dSTony Tye 34718ba5043dSTony Tye It is the static number of source language threads of execution per target 34728ba5043dSTony Tye architecture thread. It is not the dynamic number of source language threads 34738ba5043dSTony Tye of execution with which the target architecture thread was initiated, for 34748ba5043dSTony Tye example, due to smaller or partial work-groups. 34750ac939f3STony Tye 34760ac939f3STony Tye If not present, the default value of 1 is used. 34770ac939f3STony Tye 34788ba5043dSTony Tye The DWARF is ill-formed if the value is less than or equal to 0. 34790ac939f3STony Tye 34808ba5043dSTony Tye5. For source languages that are implemented using a SIMT execution model, a 34810ac939f3STony Tye ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or 34820ac939f3STony Tye ``DW_TAG_entry_point`` debugging information entry may have a 34830ac939f3STony Tye ``DW_AT_LLVM_lane_pc`` attribute whose value is a DWARF expression E. 34840ac939f3STony Tye 34850ac939f3STony Tye The result of the attribute is obtained by evaluating E with a context that 34860ac939f3STony Tye has a result kind of a location description, an unspecified object, the 34870ac939f3STony Tye compilation unit that contains E, an empty initial stack, and other context 34880ac939f3STony Tye elements corresponding to the source language thread of execution upon which 34890ac939f3STony Tye the user is focused, if any. 34900ac939f3STony Tye 34918ba5043dSTony Tye The resulting location description L is for a lane count sized vector of 34928ba5043dSTony Tye generic type elements. The lane count is the value of the 34930ac939f3STony Tye ``DW_AT_LLVM_lanes`` attribute. Each element holds the conceptual program 34948ba5043dSTony Tye location of the corresponding lane. If the lane was not active when the 34958ba5043dSTony Tye current subprogram was called, its element is an undefined location 34968ba5043dSTony Tye description. 34978ba5043dSTony Tye 34988ba5043dSTony Tye The DWARF is ill-formed if L does not have exactly one single location 34998ba5043dSTony Tye description. 35000ac939f3STony Tye 35010ac939f3STony Tye ``DW_AT_LLVM_lane_pc`` *allows the compiler to indicate conceptually where 35028ba5043dSTony Tye each SIMT lane of a target architecture thread is positioned even when it is 35038ba5043dSTony Tye in divergent control flow that is not active.* 35040ac939f3STony Tye 35050ac939f3STony Tye *Typically, the result is a location description with one composite location 35060ac939f3STony Tye description with each part being a location description with either one 35070ac939f3STony Tye undefined location description or one memory location description.* 35080ac939f3STony Tye 35098ba5043dSTony Tye If not present, the target architecture thread is not being used in a SIMT 35108ba5043dSTony Tye manner, and the thread's current program location is used. 35110ac939f3STony Tye 35128ba5043dSTony Tye6. For languages that are implemented using a SIMT execution model, a 35130ac939f3STony Tye ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or 35140ac939f3STony Tye ``DW_TAG_entry_point`` debugger information entry may have a 35150ac939f3STony Tye ``DW_AT_LLVM_active_lane`` attribute whose value is a DWARF expression E. 35160ac939f3STony Tye 35178ba5043dSTony Tye E is evaluated with a context that has a result kind of a location 35188ba5043dSTony Tye description, an unspecified object, the compilation unit that contains E, an 35198ba5043dSTony Tye empty initial stack, and other context elements corresponding to the source 35208ba5043dSTony Tye language thread of execution upon which the user is focused, if any. 35210ac939f3STony Tye 35228ba5043dSTony Tye The DWARF is ill-formed if L does not have exactly one single location 35238ba5043dSTony Tye description SL. 35240ac939f3STony Tye 35258ba5043dSTony Tye The active lane bit mask V for the current program location is obtained by 35268ba5043dSTony Tye reading from SL using a target architecture specific integral base type T 35278ba5043dSTony Tye that has a bit size equal to the value of the ``DW_AT_LLVM_lanes`` attribute 35288ba5043dSTony Tye of the subprogram corresponding to context's frame and program location. The 35298ba5043dSTony Tye N\ :sup:`th` least significant bit of the mask corresponds to the N\ 35308ba5043dSTony Tye :sup:`th` lane. If the bit is 1 the lane is active, otherwise it is 35318ba5043dSTony Tye inactive. The result of the attribute is the value V. 35320ac939f3STony Tye 35330ac939f3STony Tye *Some targets may update the target architecture execution mask for regions 35340ac939f3STony Tye of code that must execute with different sets of lanes than the current 35350ac939f3STony Tye active lanes. For example, some code must execute with all lanes made 35360ac939f3STony Tye temporarily active.* ``DW_AT_LLVM_active_lane`` *allows the compiler to 35378ba5043dSTony Tye provide the means to determine the source language active lanes at any 35388ba5043dSTony Tye program location. Typically, this attribute will use a loclist to express 35398ba5043dSTony Tye different locations of the active lane mask at different program locations.* 35400ac939f3STony Tye 35410ac939f3STony Tye If not present and ``DW_AT_LLVM_lanes`` is greater than 1, then the target 35420ac939f3STony Tye architecture execution mask is used. 35430ac939f3STony Tye 35448ba5043dSTony Tye7. A ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or 35458ba5043dSTony Tye ``DW_TAG_entry_point`` debugger information entry may have a 35468ba5043dSTony Tye ``DW_AT_LLVM_iterations`` attribute whose value is an integer constant or a 35478ba5043dSTony Tye DWARF expression E. Its value is the number of source language loop 35488ba5043dSTony Tye iterations executing concurrently by the target architecture for a single 35498ba5043dSTony Tye source language thread of execution. 35508ba5043dSTony Tye 35518ba5043dSTony Tye *A compiler may generate code that executes more than one iteration of a 35528ba5043dSTony Tye source language loop concurrently using optimization techniques such as 35538ba5043dSTony Tye software pipelining or SIMD vectorization. The number of concurrent 35548ba5043dSTony Tye iterations may vary for different loop nests in the same subprogram. 35558ba5043dSTony Tye Typically, this attribute will use a loclist to express different values at 35568ba5043dSTony Tye different program locations.* 35578ba5043dSTony Tye 35588ba5043dSTony Tye If the attribute is an integer constant, then the value is the constant. The 35598ba5043dSTony Tye DWARF is ill-formed if the constant is less than or equal to 0. 35608ba5043dSTony Tye 35618ba5043dSTony Tye Otherwise, E is evaluated with a context that has a result kind of a 35628ba5043dSTony Tye location description, an unspecified object, the compilation unit that 35638ba5043dSTony Tye contains E, an empty initial stack, and other context elements corresponding 35648ba5043dSTony Tye to the source language thread of execution upon which the user is focused, 35658ba5043dSTony Tye if any. The DWARF is ill-formed if the result is not a location description 35668ba5043dSTony Tye comprised of one implicit location description, that when read as the 35678ba5043dSTony Tye generic type, results in a value V that is less than or equal to 0. The 35688ba5043dSTony Tye result of the attribute is the value V. 35698ba5043dSTony Tye 35708ba5043dSTony Tye If not present, the default value of 1 is used. 35718ba5043dSTony Tye 35720ac939f3STony TyeA.3.4 Call Site Entries and Parameters 35730ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 35740ac939f3STony Tye 35750ac939f3STony TyeA.3.4.2 Call Site Parameters 35760ac939f3STony Tye++++++++++++++++++++++++++++ 35770ac939f3STony Tye 35783138fda3STony Tye1. The call site entry may own ``DW_TAG_call_site_parameter`` debugging 35793138fda3STony Tye information entries representing the parameters passed to the call. Call 35803138fda3STony Tye site parameter entries occur in the same order as the corresponding 35813138fda3STony Tye parameters in the source. Each such entry has a ``DW_AT_location`` attribute 35823138fda3STony Tye which is a location description. This location description describes where 35833138fda3STony Tye the parameter is passed (usually either some register, or a memory location 35843138fda3STony Tye expressible as the contents of the stack register plus some offset). 35853138fda3STony Tye 35863138fda3STony Tye2. A ``DW_TAG_call_site_parameter`` debugger information entry may have a 35870ac939f3STony Tye ``DW_AT_call_value`` attribute, whose value is a DWARF operation expression 35880ac939f3STony Tye E\ :sub:`1`\ . 35890ac939f3STony Tye 35900ac939f3STony Tye The result of the ``DW_AT_call_value`` attribute is obtained by evaluating 35910ac939f3STony Tye E\ :sub:`1` with a context that has a result kind of a value, an unspecified 35920ac939f3STony Tye object, the compilation unit that contains E, an empty initial stack, and 35930ac939f3STony Tye other context elements corresponding to the source language thread of 35940ac939f3STony Tye execution upon which the user is focused, if any. The resulting value V\ 35950ac939f3STony Tye :sub:`1` is the value of the parameter at the time of the call made by the 35960ac939f3STony Tye call site. 35970ac939f3STony Tye 35980ac939f3STony Tye For parameters passed by reference, where the code passes a pointer to a 35990ac939f3STony Tye location which contains the parameter, or for reference type parameters, the 36000ac939f3STony Tye ``DW_TAG_call_site_parameter`` debugger information entry may also have a 36010ac939f3STony Tye ``DW_AT_call_data_location`` attribute whose value is a DWARF operation 36020ac939f3STony Tye expression E\ :sub:`2`\ , and a ``DW_AT_call_data_value`` attribute whose 36030ac939f3STony Tye value is a DWARF operation expression E\ :sub:`3`\ . 36040ac939f3STony Tye 36050ac939f3STony Tye The value of the ``DW_AT_call_data_location`` attribute is obtained by 36060ac939f3STony Tye evaluating E\ :sub:`2` with a context that has a result kind of a location 36070ac939f3STony Tye description, an unspecified object, the compilation unit that contains E, an 36080ac939f3STony Tye empty initial stack, and other context elements corresponding to the source 36090ac939f3STony Tye language thread of execution upon which the user is focused, if any. The 36100ac939f3STony Tye resulting location description L\ :sub:`2` is the location where the 36110ac939f3STony Tye referenced parameter lives during the call made by the call site. If E\ 36120ac939f3STony Tye :sub:`2` would just be a ``DW_OP_push_object_address``, then the 36130ac939f3STony Tye ``DW_AT_call_data_location`` attribute may be omitted. 36140ac939f3STony Tye 36150ac939f3STony Tye .. note:: 36160ac939f3STony Tye 36173138fda3STony Tye The DWARF Version 5 implies that ``DW_OP_push_object_address`` may be used 36180ac939f3STony Tye but does not state what object must be specified in the context. Either 36193138fda3STony Tye ``DW_OP_push_object_address`` cannot be used, or the object to be passed 36203138fda3STony Tye in the context must be defined. 36210ac939f3STony Tye 36220ac939f3STony Tye The value of the ``DW_AT_call_data_value`` attribute is obtained by 36230ac939f3STony Tye evaluating E\ :sub:`3` with a context that has a result kind of a value, an 36240ac939f3STony Tye unspecified object, the compilation unit that contains E, an empty initial 36250ac939f3STony Tye stack, and other context elements corresponding to the source language 36260ac939f3STony Tye thread of execution upon which the user is focused, if any. The resulting 36270ac939f3STony Tye value V\ :sub:`3` is the value in L\ :sub:`2` at the time of the call made 36280ac939f3STony Tye by the call site. 36290ac939f3STony Tye 36300ac939f3STony Tye The result of these attributes is undefined if the current call frame is not 36310ac939f3STony Tye for the subprogram containing the ``DW_TAG_call_site_parameter`` debugger 36320ac939f3STony Tye information entry or the current program location is not for the call site 36330ac939f3STony Tye containing the ``DW_TAG_call_site_parameter`` debugger information entry in 36340ac939f3STony Tye the current call frame. 36350ac939f3STony Tye 36360ac939f3STony Tye *The consumer may have to virtually unwind to the call site (see* 36370ac939f3STony Tye :ref:`amdgpu-dwarf-call-frame-information`\ *) in order to evaluate these 36380ac939f3STony Tye attributes. This will ensure the source language thread of execution upon 36390ac939f3STony Tye which the user is focused corresponds to the call site needed to evaluate 36400ac939f3STony Tye the expression.* 36410ac939f3STony Tye 36420ac939f3STony Tye If it is not possible to avoid the expressions of these attributes from 36430ac939f3STony Tye accessing registers or memory locations that might be clobbered by the 36440ac939f3STony Tye subprogram being called by the call site, then the associated attribute 36450ac939f3STony Tye should not be provided. 36460ac939f3STony Tye 36470ac939f3STony Tye *The reason for the restriction is that the parameter may need to be 36480ac939f3STony Tye accessed during the execution of the callee. The consumer may virtually 36490ac939f3STony Tye unwind from the called subprogram back to the caller and then evaluate the 36500ac939f3STony Tye attribute expressions. The call frame information (see* 36510ac939f3STony Tye :ref:`amdgpu-dwarf-call-frame-information`\ *) will not be able to restore 36520ac939f3STony Tye registers that have been clobbered, and clobbered memory will no longer have 36530ac939f3STony Tye the value at the time of the call.* 36540ac939f3STony Tye 36553138fda3STony Tye3. Each call site parameter entry may also have a ``DW_AT_call_parameter`` 36563138fda3STony Tye attribute which contains a reference to a ``DW_TAG_formal_parameter`` entry, 36573138fda3STony Tye ``DW_AT_type attribute`` referencing the type of the parameter or 36583138fda3STony Tye ``DW_AT_name`` attribute describing the parameter's name. 36593138fda3STony Tye 36603138fda3STony Tye*Examples using call site entries and related attributes are found in Appendix 36613138fda3STony TyeD.15.* 36623138fda3STony Tye 36630ac939f3STony Tye.. _amdgpu-dwarf-lexical-block-entries: 36640ac939f3STony Tye 36650ac939f3STony TyeA.3.5 Lexical Block Entries 36660ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~ 36670ac939f3STony Tye 36680ac939f3STony Tye.. note:: 36690ac939f3STony Tye 36700ac939f3STony Tye This section is the same as DWARF Version 5 section 3.5. 36710ac939f3STony Tye 36720ac939f3STony TyeA.4 Data Object and Object List Entries 36730ac939f3STony Tye--------------------------------------- 36740ac939f3STony Tye 36750ac939f3STony Tye.. note:: 36760ac939f3STony Tye 36770ac939f3STony Tye This section provides changes to existing debugger information entry 36780ac939f3STony Tye attributes. These would be incorporated into the corresponding DWARF Version 5 36790ac939f3STony Tye chapter 4 sections. 36800ac939f3STony Tye 3681e60d1239STony Tye.. _amdgpu-dwarf-data-object-entries: 3682e60d1239STony Tye 36830ac939f3STony TyeA.4.1 Data Object Entries 36840ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~ 36850ac939f3STony Tye 36863138fda3STony TyeProgram variables, formal parameters and constants are represented by debugging 36873138fda3STony Tyeinformation entries with the tags ``DW_TAG_variable``, 36883138fda3STony Tye``DW_TAG_formal_parameter`` and ``DW_TAG_constant``, respectively. 36893138fda3STony Tye 36903138fda3STony Tye*The tag DW_TAG_constant is used for languages that have true named constants.* 36913138fda3STony Tye 36923138fda3STony TyeThe debugging information entry for a program variable, formal parameter or 36933138fda3STony Tyeconstant may have the following attributes: 36943138fda3STony Tye 36953138fda3STony Tye1. A ``DW_AT_location`` attribute, whose value is a DWARF expression E that 36963138fda3STony Tye describes the location of a variable or parameter at run-time. 3697e24f5f31STony 3698e24f5f31STony The result of the attribute is obtained by evaluating E with a context that 3699e24f5f31STony has a result kind of a location description, an unspecified object, the 3700e24f5f31STony compilation unit that contains E, an empty initial stack, and other context 3701e24f5f31STony elements corresponding to the source language thread of execution upon which 3702e24f5f31STony the user is focused, if any. The result of the evaluation is the location 3703e24f5f31STony description of the base of the data object. 3704e24f5f31STony 3705e24f5f31STony See :ref:`amdgpu-dwarf-control-flow-operations` for special evaluation rules 3706e24f5f31STony used by the ``DW_OP_call*`` operations. 3707e24f5f31STony 3708e24f5f31STony .. note:: 3709e24f5f31STony 3710e24f5f31STony Delete the description of how the ``DW_OP_call*`` operations evaluate a 3711e24f5f31STony ``DW_AT_location`` attribute as that is now described in the operations. 3712e24f5f31STony 3713e24f5f31STony .. note:: 3714e24f5f31STony 3715e24f5f31STony See the discussion about the ``DW_AT_location`` attribute in the 3716e24f5f31STony ``DW_OP_call*`` operation. Having each attribute only have a single 3717e24f5f31STony purpose and single execution semantics seems desirable. It makes it easier 3718e24f5f31STony for the consumer that no longer have to track the context. It makes it 3719e24f5f31STony easier for the producer as it can rely on a single semantics for each 3720e24f5f31STony attribute. 3721e24f5f31STony 3722e24f5f31STony For that reason, limiting the ``DW_AT_location`` attribute to only 3723e24f5f31STony supporting evaluating the location description of an object, and using a 3724e24f5f31STony different attribute and encoding class for the evaluation of DWARF 3725e24f5f31STony expression *procedures* on the same operation expression stack seems 3726e24f5f31STony desirable. 3727e24f5f31STony 3728e24f5f31STony2. ``DW_AT_const_value`` 3729e24f5f31STony 3730e24f5f31STony .. note:: 3731e24f5f31STony 3732e24f5f31STony Could deprecate using the ``DW_AT_const_value`` attribute for 3733e24f5f31STony ``DW_TAG_variable`` or ``DW_TAG_formal_parameter`` debugger information 3734e24f5f31STony entries that have been optimized to a constant. Instead, 3735e24f5f31STony ``DW_AT_location`` could be used with a DWARF expression that produces an 3736e24f5f31STony implicit location description now that any location description can be 3737e24f5f31STony used within a DWARF expression. This allows the ``DW_OP_call*`` operations 3738e24f5f31STony to be used to push the location description of any variable regardless of 3739e24f5f31STony how it is optimized. 3740e24f5f31STony 3741e60d1239STony Tye3. ``DW_AT_LLVM_memory_space`` 3742e60d1239STony Tye 3743e60d1239STony Tye A ``DW_AT_memory_space`` attribute with a constant value representing a source 3744e60d1239STony Tye language specific DWARF memory space (see 2.14 "Memory Spaces"). If omitted, 3745e60d1239STony Tye defaults to ``DW_MSPACE_none``. 3746e60d1239STony Tye 3747e60d1239STony Tye 37483138fda3STony TyeA.4.2 Common Block Entries 37493138fda3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~ 37503138fda3STony Tye 37513138fda3STony TyeA common block entry also has a ``DW_AT_location`` attribute whose value is a 37523138fda3STony TyeDWARF expression E that describes the location of the common block at run-time. 37533138fda3STony TyeThe result of the attribute is obtained by evaluating E with a context that has 37543138fda3STony Tyea result kind of a location description, an unspecified object, the compilation 37553138fda3STony Tyeunit that contains E, an empty initial stack, and other context elements 37563138fda3STony Tyecorresponding to the source language thread of execution upon which the user is 37573138fda3STony Tyefocused, if any. The result of the evaluation is the location description of the 37583138fda3STony Tyebase of the common block. See :ref:`amdgpu-dwarf-control-flow-operations` for 37593138fda3STony Tyespecial evaluation rules used by the ``DW_OP_call*`` operations. 37603138fda3STony Tye 37610ac939f3STony TyeA.5 Type Entries 37620ac939f3STony Tye---------------- 3763e24f5f31STony 3764e24f5f31STony.. note:: 3765e24f5f31STony 37660ac939f3STony Tye This section provides changes to existing debugger information entry 37670ac939f3STony Tye attributes. These would be incorporated into the corresponding DWARF Version 5 37680ac939f3STony Tye chapter 5 sections. 3769e24f5f31STony 37700ac939f3STony Tye.. _amdgpu-dwarf-base-type-entries: 3771e24f5f31STony 37720ac939f3STony TyeA.5.1 Base Type Entries 37730ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~ 3774e24f5f31STony 37750ac939f3STony Tye.. note:: 3776e24f5f31STony 37770ac939f3STony Tye The following new attribute is added. 3778e24f5f31STony 37790ac939f3STony Tye1. A ``DW_TAG_base_type`` debugger information entry for a base type T may have 37800ac939f3STony Tye a ``DW_AT_LLVM_vector_size`` attribute whose value is an integer constant 37810ac939f3STony Tye that is the vector type size N. 37820ac939f3STony Tye 37830ac939f3STony Tye The representation of a vector base type is as N contiguous elements, each 37840ac939f3STony Tye one having the representation of a base type T' that is the same as T 37850ac939f3STony Tye without the ``DW_AT_LLVM_vector_size`` attribute. 37860ac939f3STony Tye 37870ac939f3STony Tye If a ``DW_TAG_base_type`` debugger information entry does not have a 37880ac939f3STony Tye ``DW_AT_LLVM_vector_size`` attribute, then the base type is not a vector 37890ac939f3STony Tye type. 37900ac939f3STony Tye 37910ac939f3STony Tye The DWARF is ill-formed if N is not greater than 0. 37920ac939f3STony Tye 37930ac939f3STony Tye .. note:: 37940ac939f3STony Tye 37950ac939f3STony Tye LLVM has mention of a non-upstreamed debugger information entry that is 37960ac939f3STony Tye intended to support vector types. However, that was not for a base type so 37970ac939f3STony Tye would not be suitable as the type of a stack value entry. But perhaps that 37980ac939f3STony Tye could be replaced by using this attribute. 37990ac939f3STony Tye 38003138fda3STony Tye .. note:: 38013138fda3STony Tye 38023138fda3STony Tye Compare this with the ``DW_AT_GNU_vector`` extension supported by GNU. Is 38033138fda3STony Tye it better to add an attribute to the existing ``DW_TAG_base_type`` debug 38043138fda3STony Tye entry, or allow some forms of ``DW_TAG_array_type`` (those that have the 38053138fda3STony Tye ``DW_AT_GNU_vector`` attribute) to be used as stack entry value types? 38063138fda3STony Tye 380722825dddSScott Linder2. A ``DW_TAG_base_type`` debugger information entry with the encoding 380822825dddSScott Linder ``DW_ATE_address`` may have a ``DW_AT_LLVM_address_space`` attribute whose 380922825dddSScott Linder value is an architecture specific address space (see 3810*9171881dSScott Linder :ref:`amdgpu-dwarf-address-spaces`). If omitted it defaults to 381122825dddSScott Linder ``DW_ASPACE_LLVM_none``. 381222825dddSScott Linder 3813e60d1239STony Tye.. _amdgpu-dwarf-type-modifier-entries: 3814e60d1239STony Tye 38153138fda3STony TyeA.5.3 Type Modifier Entries 38163138fda3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~ 38173138fda3STony Tye 38183138fda3STony Tye.. note:: 38193138fda3STony Tye 38203138fda3STony Tye This section augments DWARF Version 5 section 5.3. 38213138fda3STony Tye 38223138fda3STony TyeA modified type entry describing a pointer or reference type (using 38233138fda3STony Tye``DW_TAG_pointer_type``, ``DW_TAG_reference_type`` or 38243138fda3STony Tye``DW_TAG_rvalue_reference_type``\ ) may have a ``DW_AT_LLVM_memory_space`` 38253138fda3STony Tyeattribute with a constant value representing a source language specific DWARF 38263138fda3STony Tyememory space (see :ref:`amdgpu-dwarf-memory-spaces`). If omitted, defaults to 38273138fda3STony TyeDW_MSPACE_LLVM_none. 38283138fda3STony Tye 38293138fda3STony TyeA modified type entry describing a pointer or reference type (using 38303138fda3STony Tye``DW_TAG_pointer_type``, ``DW_TAG_reference_type`` or 38313138fda3STony Tye``DW_TAG_rvalue_reference_type``\ ) may have a ``DW_AT_LLVM_address_space`` 38323138fda3STony Tyeattribute with a constant value AS representing an architecture specific DWARF 38333138fda3STony Tyeaddress space (see :ref:`amdgpu-dwarf-address-spaces`). If omitted, defaults to 38343138fda3STony Tye``DW_ASPACE_LLVM_none``. DR is the offset of a hypothetical debug information 38353138fda3STony Tyeentry D in the current compilation unit for an integral base type matching the 38363138fda3STony Tyeaddress size of AS. An object P having the given pointer or reference type are 38373138fda3STony Tyedereferenced as if the ``DW_OP_push_object_address; DW_OP_deref_type DR; 38383138fda3STony TyeDW_OP_constu AS; DW_OP_form_aspace_address`` operation expression was evaluated 38393138fda3STony Tyewith the current context except: the result kind is location description; the 38403138fda3STony Tyeinitial stack is empty; and the object is the location description of P. 38413138fda3STony Tye 38423138fda3STony Tye.. note:: 38433138fda3STony Tye 38443138fda3STony Tye What if the current context does not have a current target architecture 38453138fda3STony Tye defined? 38463138fda3STony Tye 38473138fda3STony Tye.. note:: 38483138fda3STony Tye 38493138fda3STony Tye With the expanded support for DWARF address spaces, it may be worth examining 38503138fda3STony Tye if they can be used for what was formerly supported by DWARF 5 segments. That 38513138fda3STony Tye would include specifying the address space of all code addresses (compilation 38523138fda3STony Tye units, subprograms, subprogram entries, labels, subprogram types, etc.). 38533138fda3STony Tye Either the code address attributes could be extended to allow a exprloc form 38543138fda3STony Tye (so that ``DW_OP_form_aspace_address`` can be used) or the 38553138fda3STony Tye ``DW_AT_LLVM_address_space`` attribute be allowed on all DIEs that allow 38563138fda3STony Tye ``DW_AT_segment``. 38573138fda3STony Tye 38580ac939f3STony TyeA.5.7 Structure, Union, Class and Interface Type Entries 38590ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 38600ac939f3STony Tye 38610ac939f3STony TyeA.5.7.3 Derived or Extended Structures, Classes and Interfaces 38620ac939f3STony Tye++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 38630ac939f3STony Tye 38640ac939f3STony Tye1. For a ``DW_AT_data_member_location`` attribute there are two cases: 3865e24f5f31STony 3866e24f5f31STony 1. If the attribute is an integer constant B, it provides the offset in 3867e24f5f31STony bytes from the beginning of the containing entity. 3868e24f5f31STony 3869e24f5f31STony The result of the attribute is obtained by evaluating a 3870e24f5f31STony ``DW_OP_LLVM_offset B`` operation with an initial stack comprising the 3871e24f5f31STony location description of the beginning of the containing entity. The 3872e24f5f31STony result of the evaluation is the location description of the base of the 3873e24f5f31STony member entry. 3874e24f5f31STony 3875e24f5f31STony *If the beginning of the containing entity is not byte aligned, then the 3876e24f5f31STony beginning of the member entry has the same bit displacement within a 3877e24f5f31STony byte.* 3878e24f5f31STony 3879e24f5f31STony 2. Otherwise, the attribute must be a DWARF expression E which is evaluated 3880e24f5f31STony with a context that has a result kind of a location description, an 3881e24f5f31STony unspecified object, the compilation unit that contains E, an initial 3882e24f5f31STony stack comprising the location description of the beginning of the 3883e24f5f31STony containing entity, and other context elements corresponding to the 3884e24f5f31STony source language thread of execution upon which the user is focused, if 3885e24f5f31STony any. The result of the evaluation is the location description of the 3886e24f5f31STony base of the member entry. 3887e24f5f31STony 3888e24f5f31STony .. note:: 3889e24f5f31STony 3890e24f5f31STony The beginning of the containing entity can now be any location 3891e24f5f31STony description, including those with more than one single location 3892e24f5f31STony description, and those with single location descriptions that are of any 3893e24f5f31STony kind and have any bit offset. 3894e24f5f31STony 38950ac939f3STony TyeA.5.7.8 Member Function Entries 38960ac939f3STony Tye+++++++++++++++++++++++++++++++ 3897e24f5f31STony 38980ac939f3STony Tye1. An entry for a virtual function also has a ``DW_AT_vtable_elem_location`` 38990ac939f3STony Tye attribute whose value is a DWARF expression E. 39000ac939f3STony Tye 39010ac939f3STony Tye The result of the attribute is obtained by evaluating E with a context that 39020ac939f3STony Tye has a result kind of a location description, an unspecified object, the 39030ac939f3STony Tye compilation unit that contains E, an initial stack comprising the location 39040ac939f3STony Tye description of the object of the enclosing type, and other context elements 39050ac939f3STony Tye corresponding to the source language thread of execution upon which the user 39060ac939f3STony Tye is focused, if any. The result of the evaluation is the location description 39070ac939f3STony Tye of the slot for the function within the virtual function table for the 39080ac939f3STony Tye enclosing class. 39090ac939f3STony Tye 39100ac939f3STony TyeA.5.14 Pointer to Member Type Entries 39110ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 39120ac939f3STony Tye 39130ac939f3STony Tye1. The ``DW_TAG_ptr_to_member_type`` debugging information entry has a 3914e24f5f31STony ``DW_AT_use_location`` attribute whose value is a DWARF expression E. It is 3915e24f5f31STony used to compute the location description of the member of the class to which 3916e24f5f31STony the pointer to member entry points. 3917e24f5f31STony 3918e24f5f31STony *The method used to find the location description of a given member of a 3919e24f5f31STony class, structure, or union is common to any instance of that class, 3920e24f5f31STony structure, or union and to any instance of the pointer to member type. The 3921e24f5f31STony method is thus associated with the pointer to member type, rather than with 3922e24f5f31STony each object that has a pointer to member type.* 3923e24f5f31STony 3924e24f5f31STony The ``DW_AT_use_location`` DWARF expression is used in conjunction with the 3925e24f5f31STony location description for a particular object of the given pointer to member 3926e24f5f31STony type and for a particular structure or class instance. 3927e24f5f31STony 3928e24f5f31STony The result of the attribute is obtained by evaluating E with a context that 3929e24f5f31STony has a result kind of a location description, an unspecified object, the 3930e24f5f31STony compilation unit that contains E, an initial stack comprising two entries, 3931e24f5f31STony and other context elements corresponding to the source language thread of 3932e24f5f31STony execution upon which the user is focused, if any. The first stack entry is 3933e24f5f31STony the value of the pointer to member object itself. The second stack entry is 3934e24f5f31STony the location description of the base of the entire class, structure, or 3935e24f5f31STony union instance containing the member whose location is being calculated. The 3936e24f5f31STony result of the evaluation is the location description of the member of the 3937e24f5f31STony class to which the pointer to member entry points. 3938e24f5f31STony 3939817f64e7STony TyeA.5.18 Dynamic Properties of Types 3940817f64e7STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941817f64e7STony Tye 3942817f64e7STony TyeA.5.18.1 Data Location 3943817f64e7STony Tye++++++++++++++++++++++ 3944e24f5f31STony 39453138fda3STony Tye*Some languages may represent objects using descriptors to hold information, 39463138fda3STony Tyeincluding a location and/or run-time parameters, about the data that represents 39473138fda3STony Tyethe value for that object.* 39483138fda3STony Tye 39490ac939f3STony Tye1. The ``DW_AT_data_location`` attribute may be used with any type that 3950e24f5f31STony provides one or more levels of hidden indirection and/or run-time parameters 3951e24f5f31STony in its representation. Its value is a DWARF operation expression E which 3952e24f5f31STony computes the location description of the data for an object. When this 3953e24f5f31STony attribute is omitted, the location description of the data is the same as 3954e24f5f31STony the location description of the object. 3955e24f5f31STony 3956e24f5f31STony The result of the attribute is obtained by evaluating E with a context that 3957e24f5f31STony has a result kind of a location description, an object that is the location 3958e24f5f31STony description of the data descriptor, the compilation unit that contains E, an 3959e24f5f31STony empty initial stack, and other context elements corresponding to the source 3960e24f5f31STony language thread of execution upon which the user is focused, if any. The 3961e24f5f31STony result of the evaluation is the location description of the base of the 3962e24f5f31STony member entry. 3963e24f5f31STony 3964e24f5f31STony *E will typically involve an operation expression that begins with a* 3965e24f5f31STony ``DW_OP_push_object_address`` *operation which loads the location 39660ac939f3STony Tye description of the object which can then serve as a descriptor in subsequent 39670ac939f3STony Tye calculation.* 3968e24f5f31STony 3969e24f5f31STony .. note:: 3970e24f5f31STony 3971e24f5f31STony Since ``DW_AT_data_member_location``, ``DW_AT_use_location``, and 3972e24f5f31STony ``DW_AT_vtable_elem_location`` allow both operation expressions and 3973e24f5f31STony location list expressions, why does ``DW_AT_data_location`` not allow 3974e24f5f31STony both? In all cases they apply to data objects so less likely that 3975e24f5f31STony optimization would cause different operation expressions for different 3976e24f5f31STony program location ranges. But if supporting for some then should be for 3977e24f5f31STony all. 3978e24f5f31STony 3979e24f5f31STony It seems odd this attribute is not the same as 3980e24f5f31STony ``DW_AT_data_member_location`` in having an initial stack with the 3981e24f5f31STony location description of the object since the expression has to need it. 3982e24f5f31STony 39830ac939f3STony TyeA.6 Other Debugging Information 39840ac939f3STony Tye------------------------------- 3985e24f5f31STony 3986e24f5f31STony.. note:: 3987e24f5f31STony 39880ac939f3STony Tye This section provides changes to existing debugger information entry 39890ac939f3STony Tye attributes. These would be incorporated into the corresponding DWARF Version 5 39900ac939f3STony Tye chapter 6 sections. 3991e24f5f31STony 39920ac939f3STony TyeA.6.1 Accelerated Access 39930ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~ 3994e24f5f31STony 3995e24f5f31STony.. _amdgpu-dwarf-lookup-by-name: 3996e24f5f31STony 39970ac939f3STony TyeA.6.1.1 Lookup By Name 39980ac939f3STony Tye++++++++++++++++++++++ 3999e24f5f31STony 40000ac939f3STony TyeA.6.1.1.1 Contents of the Name Index 40010ac939f3STony Tye#################################### 4002e24f5f31STony 4003e24f5f31STony.. note:: 4004e24f5f31STony 4005e24f5f31STony The following provides changes to DWARF Version 5 section 6.1.1.1. 4006e24f5f31STony 4007e24f5f31STony The rule for debugger information entries included in the name index in the 4008e24f5f31STony optional ``.debug_names`` section is extended to also include named 4009e24f5f31STony ``DW_TAG_variable`` debugging information entries with a ``DW_AT_location`` 4010e24f5f31STony attribute that includes a ``DW_OP_LLVM_form_aspace_address`` operation. 4011e24f5f31STony 4012e24f5f31STonyThe name index must contain an entry for each debugging information entry that 4013e24f5f31STonydefines a named subprogram, label, variable, type, or namespace, subject to the 4014e24f5f31STonyfollowing rules: 4015e24f5f31STony 4016e24f5f31STony* ``DW_TAG_variable`` debugging information entries with a ``DW_AT_location`` 4017e24f5f31STony attribute that includes a ``DW_OP_addr``, ``DW_OP_LLVM_form_aspace_address``, 4018e24f5f31STony or ``DW_OP_form_tls_address`` operation are included; otherwise, they are 4019e24f5f31STony excluded. 4020e24f5f31STony 40210ac939f3STony TyeA.6.1.1.4 Data Representation of the Name Index 40220ac939f3STony Tye############################################### 4023e24f5f31STony 40240ac939f3STony Tye.. _amdgpu-dwarf-name-index-section-header: 40250ac939f3STony Tye 40260ac939f3STony Tye 40270ac939f3STony TyeA.6.1.1.4.1 Section Header 40280ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^ 4029e24f5f31STony 4030e24f5f31STony.. note:: 4031e24f5f31STony 4032e24f5f31STony The following provides an addition to DWARF Version 5 section 6.1.1.4.1 item 4033e24f5f31STony 14 ``augmentation_string``. 4034e24f5f31STony 4035e24f5f31STonyA null-terminated UTF-8 vendor specific augmentation string, which provides 4036e24f5f31STonyadditional information about the contents of this index. If provided, the 4037e24f5f31STonyrecommended format for augmentation string is: 4038e24f5f31STony 4039e24f5f31STony | ``[``\ *vendor*\ ``:v``\ *X*\ ``.``\ *Y*\ [\ ``:``\ *options*\ ]\ ``]``\ * 4040e24f5f31STony 4041e24f5f31STonyWhere *vendor* is the producer, ``vX.Y`` specifies the major X and minor Y 4042e24f5f31STonyversion number of the extensions used in the DWARF of the compilation unit, and 4043e24f5f31STony*options* is an optional string providing additional information about the 4044e24f5f31STonyextensions. The version number must conform to semantic versioning [:ref:`SEMVER 4045e24f5f31STony<amdgpu-dwarf-SEMVER>`]. The *options* string must not contain the "\ ``]``\ " 4046e24f5f31STonycharacter. 4047e24f5f31STony 4048e24f5f31STonyFor example: 4049e24f5f31STony 4050e24f5f31STony :: 4051e24f5f31STony 4052e24f5f31STony [abc:v0.0][def:v1.2:feature-a=on,feature-b=3] 4053e24f5f31STony 4054e24f5f31STony.. note:: 4055e24f5f31STony 4056e24f5f31STony This is different to the definition in DWARF Version 5 but is consistent with 4057e24f5f31STony the other augmentation strings and allows multiple vendor extensions to be 4058e24f5f31STony supported. 4059e24f5f31STony 4060e24f5f31STony.. _amdgpu-dwarf-line-number-information: 4061e24f5f31STony 40620ac939f3STony TyeA.6.2 Line Number Information 40630ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4064e24f5f31STony 40650ac939f3STony TyeA.6.2.4 The Line Number Program Header 40660ac939f3STony Tye++++++++++++++++++++++++++++++++++++++ 4067e24f5f31STony 40680ac939f3STony TyeA.6.2.4.1 Standard Content Descriptions 40690ac939f3STony Tye####################################### 4070e24f5f31STony 4071e24f5f31STony.. note:: 4072e24f5f31STony 4073e24f5f31STony This augments DWARF Version 5 section 6.2.4.1. 4074e24f5f31STony 4075e24f5f31STony.. _amdgpu-dwarf-line-number-information-dw-lnct-llvm-source: 4076e24f5f31STony 4077e24f5f31STony1. ``DW_LNCT_LLVM_source`` 4078e24f5f31STony 4079e24f5f31STony The component is a null-terminated UTF-8 source text string with "\ ``\n``\ 4080e24f5f31STony " line endings. This content code is paired with the same forms as 4081e24f5f31STony ``DW_LNCT_path``. It can be used for file name entries. 4082e24f5f31STony 4083e24f5f31STony The value is an empty null-terminated string if no source is available. If 4084e24f5f31STony the source is available but is an empty file then the value is a 4085e24f5f31STony null-terminated single "\ ``\n``\ ". 4086e24f5f31STony 4087e24f5f31STony *When the source field is present, consumers can use the embedded source 4088e24f5f31STony instead of attempting to discover the source on disk using the file path 4089e24f5f31STony provided by the* ``DW_LNCT_path`` *field. When the source field is absent, 4090e24f5f31STony consumers can access the file to get the source text.* 4091e24f5f31STony 4092f2bb4b88SYangZhihui *This is particularly useful for programming languages that support runtime 4093e24f5f31STony compilation and runtime generation of source text. In these cases, the 4094e24f5f31STony source text does not reside in any permanent file. For example, the OpenCL 4095e24f5f31STony language [:ref:`OpenCL <amdgpu-dwarf-OpenCL>`] supports online compilation.* 4096e24f5f31STony 4097e24f5f31STony2. ``DW_LNCT_LLVM_is_MD5`` 4098e24f5f31STony 4099e24f5f31STony ``DW_LNCT_LLVM_is_MD5`` indicates if the ``DW_LNCT_MD5`` content kind, if 4100e24f5f31STony present, is valid: when 0 it is not valid and when 1 it is valid. If 4101e24f5f31STony ``DW_LNCT_LLVM_is_MD5`` content kind is not present, and ``DW_LNCT_MD5`` 4102e24f5f31STony content kind is present, then the MD5 checksum is valid. 4103e24f5f31STony 4104e24f5f31STony ``DW_LNCT_LLVM_is_MD5`` is always paired with the ``DW_FORM_udata`` form. 4105e24f5f31STony 4106e24f5f31STony *This allows a compilation unit to have a mixture of files with and without 4107e24f5f31STony MD5 checksums. This can happen when multiple relocatable files are linked 4108e24f5f31STony together.* 4109e24f5f31STony 4110e24f5f31STony.. _amdgpu-dwarf-call-frame-information: 4111e24f5f31STony 41120ac939f3STony TyeA.6.4 Call Frame Information 41130ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4114e24f5f31STony 4115e24f5f31STony.. note:: 4116e24f5f31STony 4117e24f5f31STony This section provides changes to existing call frame information and defines 4118e24f5f31STony instructions added by these extensions. Additional support is added for 4119e24f5f31STony address spaces. Register unwind DWARF expressions are generalized to allow any 4120e24f5f31STony location description, including those with composite and implicit location 4121e24f5f31STony descriptions. 4122e24f5f31STony 41230ac939f3STony Tye These changes would be incorporated into the DWARF Version 5 section 6.4. 4124e24f5f31STony 4125e24f5f31STony.. _amdgpu-dwarf-structure_of-call-frame-information: 4126e24f5f31STony 41270ac939f3STony TyeA.6.4.1 Structure of Call Frame Information 41280ac939f3STony Tye+++++++++++++++++++++++++++++++++++++++++++ 4129e24f5f31STony 4130e24f5f31STonyThe register rules are: 4131e24f5f31STony 4132e24f5f31STony*undefined* 4133e24f5f31STony A register that has this rule has no recoverable value in the previous frame. 4134e24f5f31STony The previous value of this register is the undefined location description (see 4135e24f5f31STony :ref:`amdgpu-dwarf-undefined-location-description-operations`). 4136e24f5f31STony 4137e24f5f31STony *By convention, the register is not preserved by a callee.* 4138e24f5f31STony 4139e24f5f31STony*same value* 4140e24f5f31STony This register has not been modified from the previous caller frame. 4141e24f5f31STony 4142e24f5f31STony If the current frame is the top frame, then the previous value of this 4143e24f5f31STony register is the location description L that specifies one register location 4144e24f5f31STony description SL. SL specifies the register location storage that corresponds to 4145e24f5f31STony the register with a bit offset of 0 for the current thread. 4146e24f5f31STony 4147e24f5f31STony If the current frame is not the top frame, then the previous value of this 4148e24f5f31STony register is the location description obtained using the call frame information 4149e24f5f31STony for the callee frame and callee program location invoked by the current caller 4150e24f5f31STony frame for the same register. 4151e24f5f31STony 4152e24f5f31STony *By convention, the register is preserved by the callee, but the callee has 4153e24f5f31STony not modified it.* 4154e24f5f31STony 4155e24f5f31STony*offset(N)* 4156e24f5f31STony N is a signed byte offset. The previous value of this register is saved at the 4157e24f5f31STony location description computed as if the DWARF operation expression 4158e24f5f31STony ``DW_OP_LLVM_offset N`` is evaluated with the current context, except the 4159e24f5f31STony result kind is a location description, the compilation unit is unspecified, 4160e24f5f31STony the object is unspecified, and an initial stack comprising the location 4161e24f5f31STony description of the current CFA (see 4162e24f5f31STony :ref:`amdgpu-dwarf-operation-expressions`). 4163e24f5f31STony 4164e24f5f31STony*val_offset(N)* 4165e24f5f31STony N is a signed byte offset. The previous value of this register is the memory 4166e24f5f31STony byte address of the location description computed as if the DWARF operation 4167e24f5f31STony expression ``DW_OP_LLVM_offset N`` is evaluated with the current context, 4168e24f5f31STony except the result kind is a location description, the compilation unit is 4169e24f5f31STony unspecified, the object is unspecified, and an initial stack comprising the 4170e24f5f31STony location description of the current CFA (see 4171e24f5f31STony :ref:`amdgpu-dwarf-operation-expressions`). 4172e24f5f31STony 4173e24f5f31STony The DWARF is ill-formed if the CFA location description is not a memory byte 4174e24f5f31STony address location description, or if the register size does not match the size 4175e24f5f31STony of an address in the address space of the current CFA location description. 4176e24f5f31STony 4177e24f5f31STony *Since the CFA location description is required to be a memory byte address 4178e24f5f31STony location description, the value of val_offset(N) will also be a memory byte 4179e24f5f31STony address location description since it is offsetting the CFA location 4180e24f5f31STony description by N bytes. Furthermore, the value of val_offset(N) will be a 4181e24f5f31STony memory byte address in the same address space as the CFA location 4182e24f5f31STony description.* 4183e24f5f31STony 4184e24f5f31STony .. note:: 4185e24f5f31STony 4186e24f5f31STony Should DWARF allow the address size to be a different size to the size of 4187e24f5f31STony the register? Requiring them to be the same bit size avoids any issue of 4188e24f5f31STony conversion as the bit contents of the register is simply interpreted as a 4189e24f5f31STony value of the address. 4190e24f5f31STony 4191e24f5f31STony GDB has a per register hook that allows a target specific conversion on a 4192e24f5f31STony register by register basis. It defaults to truncation of bigger registers, 4193e24f5f31STony and to actually reading bytes from the next register (or reads out of bounds 4194e24f5f31STony for the last register) for smaller registers. There are no GDB tests that 4195e24f5f31STony read a register out of bounds (except an illegal hand written assembly 4196e24f5f31STony test). 4197e24f5f31STony 4198e24f5f31STony*register(R)* 4199e24f5f31STony This register has been stored in another register numbered R. 4200e24f5f31STony 4201e24f5f31STony The previous value of this register is the location description obtained using 4202e24f5f31STony the call frame information for the current frame and current program location 4203e24f5f31STony for register R. 4204e24f5f31STony 4205e24f5f31STony The DWARF is ill-formed if the size of this register does not match the size 4206e24f5f31STony of register R or if there is a cyclic dependency in the call frame 4207e24f5f31STony information. 4208e24f5f31STony 4209e24f5f31STony .. note:: 4210e24f5f31STony 4211e24f5f31STony Should this also allow R to be larger than this register? If so is the value 4212e24f5f31STony stored in the low order bits and it is undefined what is stored in the 4213e24f5f31STony extra upper bits? 4214e24f5f31STony 4215e24f5f31STony*expression(E)* 4216e24f5f31STony The previous value of this register is located at the location description 4217e24f5f31STony produced by evaluating the DWARF operation expression E (see 4218e24f5f31STony :ref:`amdgpu-dwarf-operation-expressions`). 4219e24f5f31STony 4220e24f5f31STony E is evaluated with the current context, except the result kind is a location 4221e24f5f31STony description, the compilation unit is unspecified, the object is unspecified, 4222e24f5f31STony and an initial stack comprising the location description of the current CFA 4223e24f5f31STony (see :ref:`amdgpu-dwarf-operation-expressions`). 4224e24f5f31STony 4225e24f5f31STony*val_expression(E)* 42263138fda3STony Tye The previous value of this register is located at the implicit location 42273138fda3STony Tye description created from the value produced by evaluating the DWARF operation 42283138fda3STony Tye expression E (see :ref:`amdgpu-dwarf-operation-expressions`). 4229e24f5f31STony 4230e24f5f31STony E is evaluated with the current context, except the result kind is a value, 4231e24f5f31STony the compilation unit is unspecified, the object is unspecified, and an initial 4232e24f5f31STony stack comprising the location description of the current CFA (see 4233e24f5f31STony :ref:`amdgpu-dwarf-operation-expressions`). 4234e24f5f31STony 4235e24f5f31STony The DWARF is ill-formed if the resulting value type size does not match the 4236e24f5f31STony register size. 4237e24f5f31STony 4238e24f5f31STony .. note:: 4239e24f5f31STony 4240e24f5f31STony This has limited usefulness as the DWARF expression E can only produce 4241e24f5f31STony values up to the size of the generic type. This is due to not allowing any 4242e24f5f31STony operations that specify a type in a CFI operation expression. This makes it 4243e24f5f31STony unusable for registers that are larger than the generic type. However, 4244e24f5f31STony *expression(E)* can be used to create an implicit location description of 4245e24f5f31STony any size. 4246e24f5f31STony 4247e24f5f31STony*architectural* 4248e24f5f31STony The rule is defined externally to this specification by the augmenter. 4249e24f5f31STony 42503138fda3STony Tye*This table would be extremely large if actually constructed as described. Most 42513138fda3STony Tyeof the entries at any point in the table are identical to the ones above them. 42523138fda3STony TyeThe whole table can be represented quite compactly by recording just the 42533138fda3STony Tyedifferences starting at the beginning address of each subroutine in the 42543138fda3STony Tyeprogram.* 42553138fda3STony Tye 42563138fda3STony TyeThe virtual unwind information is encoded in a self-contained section called 42573138fda3STony Tye``.debug_frame``. Entries in a ``.debug_frame`` section are aligned on a 42583138fda3STony Tyemultiple of the address size relative to the start of the section and come in 42593138fda3STony Tyetwo forms: a Common Information Entry (CIE) and a Frame Description Entry (FDE). 42603138fda3STony Tye 42613138fda3STony Tye*If the range of code addresses for a function is not contiguous, there may be 42623138fda3STony Tyemultiple CIEs and FDEs corresponding to the parts of that function.* 42633138fda3STony Tye 4264e24f5f31STonyA Common Information Entry (CIE) holds information that is shared among many 4265e24f5f31STonyFrame Description Entries (FDE). There is at least one CIE in every non-empty 4266e24f5f31STony``.debug_frame`` section. A CIE contains the following fields, in order: 4267e24f5f31STony 4268e24f5f31STony1. ``length`` (initial length) 4269e24f5f31STony 4270e24f5f31STony A constant that gives the number of bytes of the CIE structure, not 42713138fda3STony Tye including the length field itself (see Section 7.2.2 Initial Length Values). 42723138fda3STony Tye The size of the length field plus the value of length must be an integral 42733138fda3STony Tye multiple of the address size specified in the ``address_size`` field. 4274e24f5f31STony 4275e24f5f31STony2. ``CIE_id`` (4 or 8 bytes, see 4276e24f5f31STony :ref:`amdgpu-dwarf-32-bit-and-64-bit-dwarf-formats`) 4277e24f5f31STony 4278e24f5f31STony A constant that is used to distinguish CIEs from FDEs. 4279e24f5f31STony 4280e24f5f31STony In the 32-bit DWARF format, the value of the CIE id in the CIE header is 4281e24f5f31STony 0xffffffff; in the 64-bit DWARF format, the value is 0xffffffffffffffff. 4282e24f5f31STony 4283e24f5f31STony3. ``version`` (ubyte) 4284e24f5f31STony 42853138fda3STony Tye A version number (see Section 7.24 Call Frame Information). This number is 42863138fda3STony Tye specific to the call frame information and is independent of the DWARF 42873138fda3STony Tye version number. 4288e24f5f31STony 4289e24f5f31STony The value of the CIE version number is 4. 4290e24f5f31STony 4291e24f5f31STony .. note:: 4292e24f5f31STony 4293e24f5f31STony Would this be increased to 5 to reflect the changes in these extensions? 4294e24f5f31STony 4295e24f5f31STony4. ``augmentation`` (sequence of UTF-8 characters) 4296e24f5f31STony 4297e24f5f31STony A null-terminated UTF-8 string that identifies the augmentation to this CIE 4298e24f5f31STony or to the FDEs that use it. If a reader encounters an augmentation string 4299e24f5f31STony that is unexpected, then only the following fields can be read: 4300e24f5f31STony 4301e24f5f31STony * CIE: length, CIE_id, version, augmentation 4302e24f5f31STony * FDE: length, CIE_pointer, initial_location, address_range 4303e24f5f31STony 4304e24f5f31STony If there is no augmentation, this value is a zero byte. 4305e24f5f31STony 4306e24f5f31STony *The augmentation string allows users to indicate that there is additional 4307e24f5f31STony vendor and target architecture specific information in the CIE or FDE which 4308e24f5f31STony is needed to virtually unwind a stack frame. For example, this might be 4309e24f5f31STony information about dynamically allocated data which needs to be freed on exit 4310e24f5f31STony from the routine.* 4311e24f5f31STony 4312e24f5f31STony *Because the* ``.debug_frame`` *section is useful independently of any* 4313e24f5f31STony ``.debug_info`` *section, the augmentation string always uses UTF-8 4314e24f5f31STony encoding.* 4315e24f5f31STony 4316e24f5f31STony The recommended format for the augmentation string is: 4317e24f5f31STony 4318e24f5f31STony | ``[``\ *vendor*\ ``:v``\ *X*\ ``.``\ *Y*\ [\ ``:``\ *options*\ ]\ ``]``\ * 4319e24f5f31STony 4320e24f5f31STony Where *vendor* is the producer, ``vX.Y`` specifies the major X and minor Y 4321e24f5f31STony version number of the extensions used, and *options* is an optional string 4322e24f5f31STony providing additional information about the extensions. The version number 4323e24f5f31STony must conform to semantic versioning [:ref:`SEMVER <amdgpu-dwarf-SEMVER>`]. 4324e24f5f31STony The *options* string must not contain the "\ ``]``\ " character. 4325e24f5f31STony 4326e24f5f31STony For example: 4327e24f5f31STony 4328e24f5f31STony :: 4329e24f5f31STony 4330e24f5f31STony [abc:v0.0][def:v1.2:feature-a=on,feature-b=3] 4331e24f5f31STony 4332e24f5f31STony5. ``address_size`` (ubyte) 4333e24f5f31STony 4334e24f5f31STony The size of a target address in this CIE and any FDEs that use it, in bytes. 4335e24f5f31STony If a compilation unit exists for this frame, its address size must match the 4336e24f5f31STony address size here. 4337e24f5f31STony 4338e24f5f31STony6. ``segment_selector_size`` (ubyte) 4339e24f5f31STony 4340e24f5f31STony The size of a segment selector in this CIE and any FDEs that use it, in 4341e24f5f31STony bytes. 4342e24f5f31STony 4343e24f5f31STony7. ``code_alignment_factor`` (unsigned LEB128) 4344e24f5f31STony 4345e24f5f31STony A constant that is factored out of all advance location instructions (see 4346e24f5f31STony :ref:`amdgpu-dwarf-row-creation-instructions`). The resulting value is 4347e24f5f31STony ``(operand * code_alignment_factor)``. 4348e24f5f31STony 4349e24f5f31STony8. ``data_alignment_factor`` (signed LEB128) 4350e24f5f31STony 4351e24f5f31STony A constant that is factored out of certain offset instructions (see 4352e24f5f31STony :ref:`amdgpu-dwarf-cfa-definition-instructions` and 4353e24f5f31STony :ref:`amdgpu-dwarf-register-rule-instructions`). The resulting value is 4354e24f5f31STony ``(operand * data_alignment_factor)``. 4355e24f5f31STony 4356e24f5f31STony9. ``return_address_register`` (unsigned LEB128) 4357e24f5f31STony 4358e24f5f31STony An unsigned LEB128 constant that indicates which column in the rule table 4359e24f5f31STony represents the return address of the subprogram. Note that this column might 4360e24f5f31STony not correspond to an actual machine register. 4361e24f5f31STony 4362e24f5f31STony The value of the return address register is used to determine the program 4363e24f5f31STony location of the caller frame. The program location of the top frame is the 4364e24f5f31STony target architecture program counter value of the current thread. 4365e24f5f31STony 4366e24f5f31STony10. ``initial_instructions`` (array of ubyte) 4367e24f5f31STony 4368e24f5f31STony A sequence of rules that are interpreted to create the initial setting of 4369e24f5f31STony each column in the table. 4370e24f5f31STony 4371e24f5f31STony The default rule for all columns before interpretation of the initial 4372e24f5f31STony instructions is the undefined rule. However, an ABI authoring body or a 4373e24f5f31STony compilation system authoring body may specify an alternate default value for 4374e24f5f31STony any or all columns. 4375e24f5f31STony 4376e24f5f31STony11. ``padding`` (array of ubyte) 4377e24f5f31STony 4378e24f5f31STony Enough ``DW_CFA_nop`` instructions to make the size of this entry match the 4379e24f5f31STony length value above. 4380e24f5f31STony 4381e24f5f31STonyAn FDE contains the following fields, in order: 4382e24f5f31STony 4383e24f5f31STony1. ``length`` (initial length) 4384e24f5f31STony 4385e24f5f31STony A constant that gives the number of bytes of the header and instruction 43863138fda3STony Tye stream for this subprogram, not including the length field itself (see 43873138fda3STony Tye Section 7.2.2 Initial Length Values). The size of the length field plus the 43883138fda3STony Tye value of length must be an integral multiple of the address size. 4389e24f5f31STony 4390e24f5f31STony2. ``CIE_pointer`` (4 or 8 bytes, see 4391e24f5f31STony :ref:`amdgpu-dwarf-32-bit-and-64-bit-dwarf-formats`) 4392e24f5f31STony 4393e24f5f31STony A constant offset into the ``.debug_frame`` section that denotes the CIE 4394e24f5f31STony that is associated with this FDE. 4395e24f5f31STony 4396e24f5f31STony3. ``initial_location`` (segment selector and target address) 4397e24f5f31STony 4398e24f5f31STony The address of the first location associated with this table entry. If the 4399e24f5f31STony segment_selector_size field of this FDE’s CIE is non-zero, the initial 4400e24f5f31STony location is preceded by a segment selector of the given length. 4401e24f5f31STony 4402e24f5f31STony4. ``address_range`` (target address) 4403e24f5f31STony 4404e24f5f31STony The number of bytes of program instructions described by this entry. 4405e24f5f31STony 4406e24f5f31STony5. ``instructions`` (array of ubyte) 4407e24f5f31STony 4408e24f5f31STony A sequence of table defining instructions that are described in 4409e24f5f31STony :ref:`amdgpu-dwarf-call-frame-instructions`. 4410e24f5f31STony 4411e24f5f31STony6. ``padding`` (array of ubyte) 4412e24f5f31STony 4413e24f5f31STony Enough ``DW_CFA_nop`` instructions to make the size of this entry match the 4414e24f5f31STony length value above. 4415e24f5f31STony 4416e24f5f31STony.. _amdgpu-dwarf-call-frame-instructions: 4417e24f5f31STony 44180ac939f3STony TyeA.6.4.2 Call Frame Instructions 44190ac939f3STony Tye+++++++++++++++++++++++++++++++ 4420e24f5f31STony 44213138fda3STony TyeEach call frame instruction is defined to take 0 or more operands. Some of the 44223138fda3STony Tyeoperands may be encoded as part of the opcode (see 44233138fda3STony Tye:ref:`amdgpu-dwarf-call-frame-information-encoding`). The instructions are 44243138fda3STony Tyedefined in the following sections. 44253138fda3STony Tye 4426e24f5f31STonySome call frame instructions have operands that are encoded as DWARF operation 4427e24f5f31STonyexpressions E (see :ref:`amdgpu-dwarf-operation-expressions`). The DWARF 4428e24f5f31STonyoperations that can be used in E have the following restrictions: 4429e24f5f31STony 4430e24f5f31STony* ``DW_OP_addrx``, ``DW_OP_call2``, ``DW_OP_call4``, ``DW_OP_call_ref``, 4431e24f5f31STony ``DW_OP_const_type``, ``DW_OP_constx``, ``DW_OP_convert``, 4432e24f5f31STony ``DW_OP_deref_type``, ``DW_OP_fbreg``, ``DW_OP_implicit_pointer``, 4433e24f5f31STony ``DW_OP_regval_type``, ``DW_OP_reinterpret``, and ``DW_OP_xderef_type`` 4434e24f5f31STony operations are not allowed because the call frame information must not depend 4435e24f5f31STony on other debug sections. 4436e24f5f31STony 4437e24f5f31STony* ``DW_OP_push_object_address`` is not allowed because there is no object 4438e24f5f31STony context to provide a value to push. 4439e24f5f31STony 44408ba5043dSTony Tye* ``DW_OP_LLVM_push_lane`` and ``DW_OP_LLVM_push_iteration`` are not allowed 44418ba5043dSTony Tye because the call frame instructions describe the actions for the whole target 44428ba5043dSTony Tye architecture thread, not the lanes or iterations independently. 4443e24f5f31STony 4444e24f5f31STony* ``DW_OP_call_frame_cfa`` and ``DW_OP_entry_value`` are not allowed because 4445e24f5f31STony their use would be circular. 4446e24f5f31STony 4447e24f5f31STony* ``DW_OP_LLVM_call_frame_entry_reg`` is not allowed if evaluating E causes a 4448e24f5f31STony circular dependency between ``DW_OP_LLVM_call_frame_entry_reg`` operations. 4449e24f5f31STony 4450e24f5f31STony *For example, if a register R1 has a* ``DW_CFA_def_cfa_expression`` 4451e24f5f31STony *instruction that evaluates a* ``DW_OP_LLVM_call_frame_entry_reg`` *operation 4452e24f5f31STony that specifies register R2, and register R2 has a* 4453e24f5f31STony ``DW_CFA_def_cfa_expression`` *instruction that that evaluates a* 4454e24f5f31STony ``DW_OP_LLVM_call_frame_entry_reg`` *operation that specifies register R1.* 4455e24f5f31STony 4456e24f5f31STony*Call frame instructions to which these restrictions apply include* 4457e24f5f31STony``DW_CFA_def_cfa_expression``\ *,* ``DW_CFA_expression``\ *, and* 4458e24f5f31STony``DW_CFA_val_expression``\ *.* 4459e24f5f31STony 4460e24f5f31STony.. _amdgpu-dwarf-row-creation-instructions: 4461e24f5f31STony 44620ac939f3STony TyeA.6.4.2.1 Row Creation Instructions 44630ac939f3STony Tye################################### 4464e24f5f31STony 4465e24f5f31STony.. note:: 4466e24f5f31STony 4467e24f5f31STony These instructions are the same as in DWARF Version 5 section 6.4.2.1. 4468e24f5f31STony 4469e24f5f31STony.. _amdgpu-dwarf-cfa-definition-instructions: 4470e24f5f31STony 44710ac939f3STony TyeA.6.4.2.2 CFA Definition Instructions 44720ac939f3STony Tye##################################### 4473e24f5f31STony 4474e24f5f31STony1. ``DW_CFA_def_cfa`` 4475e24f5f31STony 4476e24f5f31STony The ``DW_CFA_def_cfa`` instruction takes two unsigned LEB128 operands 4477e24f5f31STony representing a register number R and a (non-factored) byte displacement B. 4478e24f5f31STony AS is set to the target architecture default address space identifier. The 44793138fda3STony Tye required action is to define the current CFA rule to be equivalent to the 44803138fda3STony Tye result of evaluating the DWARF operation expression ``DW_OP_constu AS; 448158661406STony Tye DW_OP_LLVM_aspace_bregx R, B`` as a location description. 4482e24f5f31STony 4483e24f5f31STony2. ``DW_CFA_def_cfa_sf`` 4484e24f5f31STony 4485e24f5f31STony The ``DW_CFA_def_cfa_sf`` instruction takes two operands: an unsigned LEB128 4486e24f5f31STony value representing a register number R and a signed LEB128 factored byte 4487e24f5f31STony displacement B. AS is set to the target architecture default address space 44883138fda3STony Tye identifier. The required action is to define the current CFA rule to be 44893138fda3STony Tye equivalent to the result of evaluating the DWARF operation expression 44903138fda3STony Tye ``DW_OP_constu AS; DW_OP_LLVM_aspace_bregx R, B * data_alignment_factor`` as 44913138fda3STony Tye a location description. 4492e24f5f31STony 4493e24f5f31STony *The action is the same as* ``DW_CFA_def_cfa``\ *, except that the second 4494e24f5f31STony operand is signed and factored.* 4495e24f5f31STony 4496231f4182STony Tye3. ``DW_CFA_LLVM_def_aspace_cfa`` *New* 4497e24f5f31STony 4498231f4182STony Tye The ``DW_CFA_LLVM_def_aspace_cfa`` instruction takes three unsigned LEB128 4499e24f5f31STony operands representing a register number R, a (non-factored) byte 4500e24f5f31STony displacement B, and a target architecture specific address space identifier 45013138fda3STony Tye AS. The required action is to define the current CFA rule to be equivalent 45023138fda3STony Tye to the result of evaluating the DWARF operation expression ``DW_OP_constu 45033138fda3STony Tye AS; DW_OP_LLVM_aspace_bregx R, B`` as a location description. 4504e24f5f31STony 4505e24f5f31STony If AS is not one of the values defined by the target architecture specific 45063138fda3STony Tye ``DW_ASPACE_LLVM_*`` values then the DWARF expression is ill-formed. 4507e24f5f31STony 4508231f4182STony Tye4. ``DW_CFA_LLVM_def_aspace_cfa_sf`` *New* 4509e24f5f31STony 4510817f64e7STony Tye The ``DW_CFA_LLVM_def_aspace_cfa_sf`` instruction takes three operands: an 4511817f64e7STony Tye unsigned LEB128 value representing a register number R, a signed LEB128 4512817f64e7STony Tye factored byte displacement B, and an unsigned LEB128 value representing a 4513817f64e7STony Tye target architecture specific address space identifier AS. The required 45143138fda3STony Tye action is to define the current CFA rule to be equivalent to the result of 45153138fda3STony Tye evaluating the DWARF operation expression ``DW_OP_constu AS; 45163138fda3STony Tye DW_OP_LLVM_aspace_bregx R, B * data_alignment_factor`` as a location 45173138fda3STony Tye description. 4518e24f5f31STony 4519e24f5f31STony If AS is not one of the values defined by the target architecture specific 45203138fda3STony Tye ``DW_ASPACE_LLVM_*`` values, then the DWARF expression is ill-formed. 4521e24f5f31STony 4522e24f5f31STony *The action is the same as* ``DW_CFA_aspace_def_cfa``\ *, except that the 4523e24f5f31STony second operand is signed and factored.* 4524e24f5f31STony 4525e24f5f31STony5. ``DW_CFA_def_cfa_register`` 4526e24f5f31STony 4527e24f5f31STony The ``DW_CFA_def_cfa_register`` instruction takes a single unsigned LEB128 4528e24f5f31STony operand representing a register number R. The required action is to define 45293138fda3STony Tye the current CFA rule to be equivalent to the result of evaluating the DWARF 45303138fda3STony Tye operation expression ``DW_OP_constu AS; DW_OP_LLVM_aspace_bregx R, B`` as a 45313138fda3STony Tye location description. B and AS are the old CFA byte displacement and address 45323138fda3STony Tye space respectively. 4533e24f5f31STony 4534e24f5f31STony If the subprogram has no current CFA rule, or the rule was defined by a 4535e24f5f31STony ``DW_CFA_def_cfa_expression`` instruction, then the DWARF is ill-formed. 4536e24f5f31STony 4537e24f5f31STony6. ``DW_CFA_def_cfa_offset`` 4538e24f5f31STony 4539e24f5f31STony The ``DW_CFA_def_cfa_offset`` instruction takes a single unsigned LEB128 4540e24f5f31STony operand representing a (non-factored) byte displacement B. The required 45413138fda3STony Tye action is to define the current CFA rule to be equivalent to the result of 45423138fda3STony Tye evaluating the DWARF operation expression ``DW_OP_constu AS; 45433138fda3STony Tye DW_OP_LLVM_aspace_bregx R, B`` as a location description. R and AS are the 45443138fda3STony Tye old CFA register number and address space respectively. 4545e24f5f31STony 4546e24f5f31STony If the subprogram has no current CFA rule, or the rule was defined by a 4547e24f5f31STony ``DW_CFA_def_cfa_expression`` instruction, then the DWARF is ill-formed. 4548e24f5f31STony 4549e24f5f31STony7. ``DW_CFA_def_cfa_offset_sf`` 4550e24f5f31STony 4551e24f5f31STony The ``DW_CFA_def_cfa_offset_sf`` instruction takes a signed LEB128 operand 4552e24f5f31STony representing a factored byte displacement B. The required action is to 45533138fda3STony Tye define the current CFA rule to be equivalent to the result of evaluating the 45543138fda3STony Tye DWARF operation expression ``DW_OP_constu AS; DW_OP_LLVM_aspace_bregx R, B * 45550ac939f3STony Tye data_alignment_factor`` as a location description. R and AS are the old CFA 45560ac939f3STony Tye register number and address space respectively. 4557e24f5f31STony 4558e24f5f31STony If the subprogram has no current CFA rule, or the rule was defined by a 4559e24f5f31STony ``DW_CFA_def_cfa_expression`` instruction, then the DWARF is ill-formed. 4560e24f5f31STony 4561e24f5f31STony *The action is the same as* ``DW_CFA_def_cfa_offset``\ *, except that the 4562e24f5f31STony operand is signed and factored.* 4563e24f5f31STony 4564e24f5f31STony8. ``DW_CFA_def_cfa_expression`` 4565e24f5f31STony 4566e24f5f31STony The ``DW_CFA_def_cfa_expression`` instruction takes a single operand encoded 4567e24f5f31STony as a ``DW_FORM_exprloc`` value representing a DWARF operation expression E. 45683138fda3STony Tye The required action is to define the current CFA rule to be equivalent to 45693138fda3STony Tye the result of evaluating E with the current context, except the result kind 45703138fda3STony Tye is a location description, the compilation unit is unspecified, the object 45713138fda3STony Tye is unspecified, and an empty initial stack. 4572e24f5f31STony 4573e24f5f31STony *See* :ref:`amdgpu-dwarf-call-frame-instructions` *regarding restrictions on 4574e24f5f31STony the DWARF expression operations that can be used in E.* 4575e24f5f31STony 4576e24f5f31STony The DWARF is ill-formed if the result of evaluating E is not a memory byte 4577e24f5f31STony address location description. 4578e24f5f31STony 4579e24f5f31STony.. _amdgpu-dwarf-register-rule-instructions: 4580e24f5f31STony 45810ac939f3STony TyeA.6.4.2.3 Register Rule Instructions 45820ac939f3STony Tye#################################### 4583e24f5f31STony 4584e24f5f31STony1. ``DW_CFA_undefined`` 4585e24f5f31STony 4586e24f5f31STony The ``DW_CFA_undefined`` instruction takes a single unsigned LEB128 operand 4587e24f5f31STony that represents a register number R. The required action is to set the rule 4588e24f5f31STony for the register specified by R to ``undefined``. 4589e24f5f31STony 4590e24f5f31STony2. ``DW_CFA_same_value`` 4591e24f5f31STony 4592e24f5f31STony The ``DW_CFA_same_value`` instruction takes a single unsigned LEB128 operand 4593e24f5f31STony that represents a register number R. The required action is to set the rule 4594e24f5f31STony for the register specified by R to ``same value``. 4595e24f5f31STony 4596e24f5f31STony3. ``DW_CFA_offset`` 4597e24f5f31STony 4598e24f5f31STony The ``DW_CFA_offset`` instruction takes two operands: a register number R 4599e24f5f31STony (encoded with the opcode) and an unsigned LEB128 constant representing a 4600e24f5f31STony factored displacement B. The required action is to change the rule for the 4601e24f5f31STony register specified by R to be an *offset(B \* data_alignment_factor)* rule. 4602e24f5f31STony 4603e24f5f31STony .. note:: 4604e24f5f31STony 4605e24f5f31STony Seems this should be named ``DW_CFA_offset_uf`` since the offset is 4606e24f5f31STony unsigned factored. 4607e24f5f31STony 4608e24f5f31STony4. ``DW_CFA_offset_extended`` 4609e24f5f31STony 4610e24f5f31STony The ``DW_CFA_offset_extended`` instruction takes two unsigned LEB128 4611e24f5f31STony operands representing a register number R and a factored displacement B. 4612e24f5f31STony This instruction is identical to ``DW_CFA_offset``, except for the encoding 4613e24f5f31STony and size of the register operand. 4614e24f5f31STony 4615e24f5f31STony .. note:: 4616e24f5f31STony 4617e24f5f31STony Seems this should be named ``DW_CFA_offset_extended_uf`` since the 4618e24f5f31STony displacement is unsigned factored. 4619e24f5f31STony 4620e24f5f31STony5. ``DW_CFA_offset_extended_sf`` 4621e24f5f31STony 4622e24f5f31STony The ``DW_CFA_offset_extended_sf`` instruction takes two operands: an 4623e24f5f31STony unsigned LEB128 value representing a register number R and a signed LEB128 4624e24f5f31STony factored displacement B. This instruction is identical to 4625e24f5f31STony ``DW_CFA_offset_extended``, except that B is signed. 4626e24f5f31STony 4627e24f5f31STony6. ``DW_CFA_val_offset`` 4628e24f5f31STony 4629e24f5f31STony The ``DW_CFA_val_offset`` instruction takes two unsigned LEB128 operands 4630e24f5f31STony representing a register number R and a factored displacement B. The required 4631e24f5f31STony action is to change the rule for the register indicated by R to be a 4632e24f5f31STony *val_offset(B \* data_alignment_factor)* rule. 4633e24f5f31STony 4634e24f5f31STony .. note:: 4635e24f5f31STony 4636e24f5f31STony Seems this should be named ``DW_CFA_val_offset_uf`` since the displacement 4637e24f5f31STony is unsigned factored. 4638e24f5f31STony 4639e24f5f31STony .. note:: 4640e24f5f31STony 4641e24f5f31STony An alternative is to define ``DW_CFA_val_offset`` to implicitly use the 4642e24f5f31STony target architecture default address space, and add another operation that 4643e24f5f31STony specifies the address space. 4644e24f5f31STony 4645e24f5f31STony7. ``DW_CFA_val_offset_sf`` 4646e24f5f31STony 4647e24f5f31STony The ``DW_CFA_val_offset_sf`` instruction takes two operands: an unsigned 4648e24f5f31STony LEB128 value representing a register number R and a signed LEB128 factored 4649e24f5f31STony displacement B. This instruction is identical to ``DW_CFA_val_offset``, 4650e24f5f31STony except that B is signed. 4651e24f5f31STony 4652e24f5f31STony8. ``DW_CFA_register`` 4653e24f5f31STony 4654e24f5f31STony The ``DW_CFA_register`` instruction takes two unsigned LEB128 operands 4655e24f5f31STony representing register numbers R1 and R2 respectively. The required action is 4656e24f5f31STony to set the rule for the register specified by R1 to be a *register(R2)* rule. 4657e24f5f31STony 4658e24f5f31STony9. ``DW_CFA_expression`` 4659e24f5f31STony 4660e24f5f31STony The ``DW_CFA_expression`` instruction takes two operands: an unsigned LEB128 4661e24f5f31STony value representing a register number R, and a ``DW_FORM_block`` value 4662e24f5f31STony representing a DWARF operation expression E. The required action is to 4663e24f5f31STony change the rule for the register specified by R to be an *expression(E)* 4664e24f5f31STony rule. 4665e24f5f31STony 4666e24f5f31STony *That is, E computes the location description where the register value can 4667e24f5f31STony be retrieved.* 4668e24f5f31STony 4669e24f5f31STony *See* :ref:`amdgpu-dwarf-call-frame-instructions` *regarding restrictions on 4670e24f5f31STony the DWARF expression operations that can be used in E.* 4671e24f5f31STony 4672e24f5f31STony10. ``DW_CFA_val_expression`` 4673e24f5f31STony 4674e24f5f31STony The ``DW_CFA_val_expression`` instruction takes two operands: an unsigned 4675e24f5f31STony LEB128 value representing a register number R, and a ``DW_FORM_block`` value 4676e24f5f31STony representing a DWARF operation expression E. The required action is to 4677e24f5f31STony change the rule for the register specified by R to be a *val_expression(E)* 4678e24f5f31STony rule. 4679e24f5f31STony 4680e24f5f31STony *That is, E computes the value of register R.* 4681e24f5f31STony 4682e24f5f31STony *See* :ref:`amdgpu-dwarf-call-frame-instructions` *regarding restrictions on 4683e24f5f31STony the DWARF expression operations that can be used in E.* 4684e24f5f31STony 4685e24f5f31STony If the result of evaluating E is not a value with a base type size that 4686e24f5f31STony matches the register size, then the DWARF is ill-formed. 4687e24f5f31STony 4688e24f5f31STony11. ``DW_CFA_restore`` 4689e24f5f31STony 4690e24f5f31STony The ``DW_CFA_restore`` instruction takes a single operand (encoded with the 4691e24f5f31STony opcode) that represents a register number R. The required action is to 4692e24f5f31STony change the rule for the register specified by R to the rule assigned it by 4693e24f5f31STony the ``initial_instructions`` in the CIE. 4694e24f5f31STony 4695e24f5f31STony12. ``DW_CFA_restore_extended`` 4696e24f5f31STony 4697e24f5f31STony The ``DW_CFA_restore_extended`` instruction takes a single unsigned LEB128 4698e24f5f31STony operand that represents a register number R. This instruction is identical 4699e24f5f31STony to ``DW_CFA_restore``, except for the encoding and size of the register 4700e24f5f31STony operand. 4701e24f5f31STony 47020ac939f3STony TyeA.6.4.2.4 Row State Instructions 47030ac939f3STony Tye################################ 4704e24f5f31STony 4705e24f5f31STony.. note:: 4706e24f5f31STony 4707e24f5f31STony These instructions are the same as in DWARF Version 5 section 6.4.2.4. 4708e24f5f31STony 47090ac939f3STony TyeA.6.4.2.5 Padding Instruction 47100ac939f3STony Tye############################# 4711e24f5f31STony 4712e24f5f31STony.. note:: 4713e24f5f31STony 4714e24f5f31STony These instructions are the same as in DWARF Version 5 section 6.4.2.5. 4715e24f5f31STony 47160ac939f3STony TyeA.6.4.3 Call Frame Instruction Usage 47170ac939f3STony Tye++++++++++++++++++++++++++++++++++++ 4718e24f5f31STony 4719e24f5f31STony.. note:: 4720e24f5f31STony 4721e24f5f31STony The same as in DWARF Version 5 section 6.4.3. 4722e24f5f31STony 4723e24f5f31STony.. _amdgpu-dwarf-call-frame-calling-address: 4724e24f5f31STony 47250ac939f3STony TyeA.6.4.4 Call Frame Calling Address 47260ac939f3STony Tye++++++++++++++++++++++++++++++++++ 4727e24f5f31STony 4728e24f5f31STony.. note:: 4729e24f5f31STony 4730e24f5f31STony The same as in DWARF Version 5 section 6.4.4. 4731e24f5f31STony 47320ac939f3STony TyeA.7 Data Representation 47330ac939f3STony Tye----------------------- 4734e24f5f31STony 4735e24f5f31STony.. note:: 4736e24f5f31STony 47370ac939f3STony Tye This section provides changes to existing debugger information entry 47380ac939f3STony Tye attributes. These would be incorporated into the corresponding DWARF Version 5 47390ac939f3STony Tye chapter 7 sections. 4740e24f5f31STony 47410ac939f3STony Tye.. _amdgpu-dwarf-32-bit-and-64-bit-dwarf-formats: 47420ac939f3STony Tye 47430ac939f3STony TyeA.7.4 32-Bit and 64-Bit DWARF Formats 47440ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 47450ac939f3STony Tye 47460ac939f3STony Tye.. note:: 47470ac939f3STony Tye 47480ac939f3STony Tye This augments DWARF Version 5 section 7.4 list item 3's table. 4749e24f5f31STony 4750e24f5f31STony.. table:: ``.debug_info`` section attribute form roles 4751e24f5f31STony :name: amdgpu-dwarf-debug-info-section-attribute-form-roles-table 4752e24f5f31STony 4753e24f5f31STony ================================== =================================== 4754e24f5f31STony Form Role 4755e24f5f31STony ================================== =================================== 4756e24f5f31STony DW_OP_LLVM_aspace_implicit_pointer offset in ``.debug_info`` 4757e24f5f31STony ================================== =================================== 4758e24f5f31STony 47590ac939f3STony TyeA.7.5 Format of Debugging Information 47600ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761e24f5f31STony 47620ac939f3STony TyeA.7.5.4 Attribute Encodings 47630ac939f3STony Tye+++++++++++++++++++++++++++ 4764e24f5f31STony 4765e24f5f31STony.. note:: 4766e24f5f31STony 4767e24f5f31STony This augments DWARF Version 5 section 7.5.4 and Table 7.5. 4768e24f5f31STony 4769e24f5f31STonyThe following table gives the encoding of the additional debugging information 4770e24f5f31STonyentry attributes. 4771e24f5f31STony 4772e24f5f31STony.. table:: Attribute encodings 4773e24f5f31STony :name: amdgpu-dwarf-attribute-encodings-table 4774e24f5f31STony 4775e24f5f31STony ================================== ====== =================================== 4776e24f5f31STony Attribute Name Value Classes 4777e24f5f31STony ================================== ====== =================================== 47783138fda3STony Tye ``DW_AT_LLVM_active_lane`` 0x3e08 exprloc, loclist 47793138fda3STony Tye ``DW_AT_LLVM_augmentation`` 0x3e09 string 47803138fda3STony Tye ``DW_AT_LLVM_lanes`` 0x3e0a constant 47813138fda3STony Tye ``DW_AT_LLVM_lane_pc`` 0x3e0b exprloc, loclist 47823138fda3STony Tye ``DW_AT_LLVM_vector_size`` 0x3e0c constant 47833138fda3STony Tye ``DW_AT_LLVM_iterations`` 0x3e0a constant, exprloc, loclist 47843138fda3STony Tye ``DW_AT_LLVM_address_space`` TBA constant 47853138fda3STony Tye ``DW_AT_LLVM_memory_space`` TBA constant 4786e24f5f31STony ================================== ====== =================================== 4787e24f5f31STony 47880ac939f3STony Tye.. _amdgpu-dwarf-classes-and-forms: 47890ac939f3STony Tye 47900ac939f3STony TyeA.7.5.5 Classes and Forms 47910ac939f3STony Tye+++++++++++++++++++++++++ 47920ac939f3STony Tye 47930ac939f3STony Tye.. note:: 47940ac939f3STony Tye 47953138fda3STony Tye The following modifies the matching text in DWARF Version 5 section 7.5.5. 47963138fda3STony Tye 47973138fda3STony Tye* reference 47983138fda3STony Tye There are four types of reference. 47993138fda3STony Tye 48003138fda3STony Tye - The first type of reference... 48013138fda3STony Tye 48023138fda3STony Tye - The second type of reference can identify any debugging information 48033138fda3STony Tye entry within a .debug_info section; in particular, it may refer to an 48043138fda3STony Tye entry in a different compilation unit from the unit containing the 48053138fda3STony Tye reference, and may refer to an entry in a different shared object file. 48063138fda3STony Tye This type of reference (DW_FORM_ref_addr) is an offset from the 48073138fda3STony Tye beginning of the .debug_info section of the target executable or shared 48083138fda3STony Tye object file, or, for references within a supplementary object file, an 48093138fda3STony Tye offset from the beginning of the local .debug_info section; it is 48103138fda3STony Tye relocatable in a relocatable object file and frequently relocated in an 48113138fda3STony Tye executable or shared object file. In the 32-bit DWARF format, this 48123138fda3STony Tye offset is a 4-byte unsigned value; in the 64-bit DWARF format, it is an 48133138fda3STony Tye 8-byte unsigned value (see 48143138fda3STony Tye :ref:`amdgpu-dwarf-32-bit-and-64-bit-dwarf-formats`). 48153138fda3STony Tye 48163138fda3STony Tye *A debugging information entry that may be referenced by another 48173138fda3STony Tye compilation unit using DW_FORM_ref_addr must have a global symbolic 48183138fda3STony Tye name.* 48193138fda3STony Tye 48203138fda3STony Tye *For a reference from one executable or shared object file to another, 48213138fda3STony Tye the reference is resolved by the debugger to identify the executable or 48223138fda3STony Tye shared object file and the offset into that file's* ``.debug_info`` 48233138fda3STony Tye *section in the same fashion as the run time loader, either when the 48243138fda3STony Tye debug information is first read, or when the reference is used.* 48250ac939f3STony Tye 48260ac939f3STony TyeA.7.7 DWARF Expressions 48270ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~ 4828e24f5f31STony 4829e24f5f31STony.. note:: 4830e24f5f31STony 4831e24f5f31STony Rename DWARF Version 5 section 7.7 to reflect the unification of location 4832e24f5f31STony descriptions into DWARF expressions. 4833e24f5f31STony 48340ac939f3STony TyeA.7.7.1 Operation Expressions 48350ac939f3STony Tye+++++++++++++++++++++++++++++ 4836e24f5f31STony 4837e24f5f31STony.. note:: 4838e24f5f31STony 4839e24f5f31STony Rename DWARF Version 5 section 7.7.1 and delete section 7.7.2 to reflect the 4840e24f5f31STony unification of location descriptions into DWARF expressions. 4841e24f5f31STony 4842a4fb7f60SScott Linder This augments DWARF Version 5 section 7.7.1 and Table 7.9, and adds a new 4843a4fb7f60SScott Linder table describing vendor extension operations for ``DW_OP_LLVM_user``. 4844e24f5f31STony 48453138fda3STony TyeA DWARF operation expression is stored in a block of contiguous bytes. The bytes 48463138fda3STony Tyeform a sequence of operations. Each operation is a 1-byte code that identifies 4847a4fb7f60SScott Linderthat operation, followed by zero or more bytes of additional data. The encoding 4848a4fb7f60SScott Linderfor the operation ``DW_OP_LLVM_user`` is described in 4849a4fb7f60SScott Linder:ref:`amdgpu-dwarf-operation-encodings-table`, and the encoding of all 4850a4fb7f60SScott Linder``DW_OP_LLVM_user`` vendor extensions operations are described in 4851a4fb7f60SScott Linder:ref:`amdgpu-dwarf-dw-op-llvm-user-vendor-extension-operation-encodings-table`. 4852e24f5f31STony 4853e24f5f31STony.. table:: DWARF Operation Encodings 4854e24f5f31STony :name: amdgpu-dwarf-operation-encodings-table 4855e24f5f31STony 4856a4fb7f60SScott Linder ====================================== ===== ======== ========================================================================================= 4857e24f5f31STony Operation Code Number Notes 4858e24f5f31STony of 4859e24f5f31STony Operands 4860a4fb7f60SScott Linder ====================================== ===== ======== ========================================================================================= 4861a4fb7f60SScott Linder ``DW_OP_LLVM_user`` 0xe9 1+ ULEB128 vendor extension opcode, followed by vendor extension operands 4862a4fb7f60SScott Linder defined in :ref:`amdgpu-dwarf-dw-op-llvm-user-vendor-extension-operation-encodings-table` 4863a4fb7f60SScott Linder ====================================== ===== ======== ========================================================================================= 4864a4fb7f60SScott Linder 4865a4fb7f60SScott Linder.. table:: DWARF DW_OP_LLVM_user Vendor Extension Operation Encodings 4866a4fb7f60SScott Linder :name: amdgpu-dwarf-dw-op-llvm-user-vendor-extension-operation-encodings-table 4867a4fb7f60SScott Linder 4868a4fb7f60SScott Linder ====================================== ========= ========== =============================== 4869a4fb7f60SScott Linder Operation Vendor Number Notes 4870a4fb7f60SScott Linder Extension of 4871a4fb7f60SScott Linder Opcode Additional 4872a4fb7f60SScott Linder Operands 4873a4fb7f60SScott Linder ====================================== ========= ========== =============================== 4874a4fb7f60SScott Linder ``DW_OP_LLVM_form_aspace_address`` 0x02 0 4875a4fb7f60SScott Linder ``DW_OP_LLVM_push_lane`` 0x03 0 4876a4fb7f60SScott Linder ``DW_OP_LLVM_offset`` 0x04 0 4877a4fb7f60SScott Linder ``DW_OP_LLVM_offset_uconst`` 0x05 1 ULEB128 byte displacement 4878a4fb7f60SScott Linder ``DW_OP_LLVM_bit_offset`` 0x06 0 4879a4fb7f60SScott Linder ``DW_OP_LLVM_call_frame_entry_reg`` 0x07 1 ULEB128 register number 4880a4fb7f60SScott Linder ``DW_OP_LLVM_undefined`` 0x08 0 4881a4fb7f60SScott Linder ``DW_OP_LLVM_aspace_bregx`` 0x09 2 ULEB128 register number, 4882e24f5f31STony SLEB128 byte displacement 4883a4fb7f60SScott Linder ``DW_OP_LLVM_piece_end`` 0x0a 0 4884a4fb7f60SScott Linder ``DW_OP_LLVM_extend`` 0x0b 2 ULEB128 bit size, 4885e24f5f31STony ULEB128 count 4886a4fb7f60SScott Linder ``DW_OP_LLVM_select_bit_piece`` 0x0c 2 ULEB128 bit size, 4887e24f5f31STony ULEB128 count 4888a4fb7f60SScott Linder ``DW_OP_LLVM_aspace_implicit_pointer`` TBA 2 4-byte or 8-byte offset of DIE, 4889a4fb7f60SScott Linder SLEB128 byte displacement 48903138fda3STony Tye ``DW_OP_LLVM_push_iteration`` TBA 0 48913138fda3STony Tye ``DW_OP_LLVM_overlay`` TBA 0 48923138fda3STony Tye ``DW_OP_LLVM_bit_overlay`` TBA 0 4893a4fb7f60SScott Linder ====================================== ========= ========== =============================== 4894e24f5f31STony 48950ac939f3STony TyeA.7.7.3 Location List Expressions 48960ac939f3STony Tye+++++++++++++++++++++++++++++++++ 4897e24f5f31STony 4898e24f5f31STony.. note:: 4899e24f5f31STony 4900e24f5f31STony Rename DWARF Version 5 section 7.7.3 to reflect that location lists are a kind 4901e24f5f31STony of DWARF expression. 4902e24f5f31STony 49030ac939f3STony TyeA.7.12 Source Languages 49040ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~ 4905e24f5f31STony 4906e24f5f31STony.. note:: 4907e24f5f31STony 4908e24f5f31STony This augments DWARF Version 5 section 7.12 and Table 7.17. 4909e24f5f31STony 4910e24f5f31STonyThe following table gives the encoding of the additional DWARF languages. 4911e24f5f31STony 4912e24f5f31STony.. table:: Language encodings 4913e24f5f31STony :name: amdgpu-dwarf-language-encodings-table 4914e24f5f31STony 4915e24f5f31STony ==================== ====== =================== 4916e24f5f31STony Language Name Value Default Lower Bound 4917e24f5f31STony ==================== ====== =================== 4918e24f5f31STony ``DW_LANG_LLVM_HIP`` 0x8100 0 4919e24f5f31STony ==================== ====== =================== 4920e24f5f31STony 49213138fda3STony TyeA.7.14 Address Space Encodings 49223138fda3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923e24f5f31STony 4924e24f5f31STony.. note:: 4925e24f5f31STony 49263138fda3STony Tye This is a new section after DWARF Version 5 section 7.13 "Address Class and 49273138fda3STony Tye Address Space Encodings". 4928e24f5f31STony 49293138fda3STony TyeThe value of the common address space encoding ``DW_ASPACE_LLVM_none`` is 0. 4930e24f5f31STony 49313138fda3STony TyeA.7.15 Memory Space Encodings 49323138fda3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933e24f5f31STony 49343138fda3STony Tye.. note:: 49353138fda3STony Tye 49363138fda3STony Tye This is a new section after DWARF Version 5 section 7.13 "Address Class and 49373138fda3STony Tye Address Space Encodings". 49383138fda3STony Tye 49393138fda3STony TyeThe encodings of the constants used for the currently defined memory spaces 49403138fda3STony Tyeare given in :ref:`amdgpu-dwarf-memory-space-encodings-table`. 49413138fda3STony Tye 49423138fda3STony Tye.. table:: Memory space encodings 49433138fda3STony Tye :name: amdgpu-dwarf-memory-space-encodings-table 49443138fda3STony Tye 49453138fda3STony Tye =========================== ====== 49463138fda3STony Tye Memory Space Name Value 49473138fda3STony Tye =========================== ====== 49483138fda3STony Tye ``DW_MSPACE_LLVM_none`` 0x0000 49493138fda3STony Tye ``DW_MSPACE_LLVM_global`` 0x0001 49503138fda3STony Tye ``DW_MSPACE_LLVM_constant`` 0x0002 49513138fda3STony Tye ``DW_MSPACE_LLVM_group`` 0x0003 49523138fda3STony Tye ``DW_MSPACE_LLVM_private`` 0x0004 49533138fda3STony Tye ``DW_MSPACE_LLVM_lo_user`` 0x8000 49543138fda3STony Tye ``DW_MSPACE_LLVM_hi_user`` 0xffff 49553138fda3STony Tye =========================== ====== 4956e24f5f31STony 49570ac939f3STony TyeA.7.22 Line Number Information 49580ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959e24f5f31STony 4960e24f5f31STony.. note:: 4961e24f5f31STony 4962e24f5f31STony This augments DWARF Version 5 section 7.22 and Table 7.27. 4963e24f5f31STony 4964e24f5f31STonyThe following table gives the encoding of the additional line number header 4965e24f5f31STonyentry formats. 4966e24f5f31STony 4967e24f5f31STony.. table:: Line number header entry format encodings 4968e24f5f31STony :name: amdgpu-dwarf-line-number-header-entry-format-encodings-table 4969e24f5f31STony 4970e24f5f31STony ==================================== ==================== 4971e24f5f31STony Line number header entry format name Value 4972e24f5f31STony ==================================== ==================== 4973e24f5f31STony ``DW_LNCT_LLVM_source`` 0x2001 4974e24f5f31STony ``DW_LNCT_LLVM_is_MD5`` 0x2002 4975e24f5f31STony ==================================== ==================== 4976e24f5f31STony 49773138fda3STony Tye.. _amdgpu-dwarf-call-frame-information-encoding: 49783138fda3STony Tye 49790ac939f3STony TyeA.7.24 Call Frame Information 49800ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4981e24f5f31STony 4982e24f5f31STony.. note:: 4983e24f5f31STony 4984e24f5f31STony This augments DWARF Version 5 section 7.24 and Table 7.29. 4985e24f5f31STony 4986e24f5f31STonyThe following table gives the encoding of the additional call frame information 4987e24f5f31STonyinstructions. 4988e24f5f31STony 4989e24f5f31STony.. table:: Call frame instruction encodings 4990e24f5f31STony :name: amdgpu-dwarf-call-frame-instruction-encodings-table 4991e24f5f31STony 49923138fda3STony Tye ================================= ====== ====== ================ ================ ===================== 4993e24f5f31STony Instruction High 2 Low 6 Operand 1 Operand 2 Operand 3 4994e24f5f31STony Bits Bits 49953138fda3STony Tye ================================= ====== ====== ================ ================ ===================== 49963138fda3STony Tye ``DW_CFA_LLVM_def_aspace_cfa`` 0 0x30 ULEB128 register ULEB128 offset ULEB128 address space 49973138fda3STony Tye ``DW_CFA_LLVM_def_aspace_cfa_sf`` 0 0x31 ULEB128 register SLEB128 offset ULEB128 address space 49983138fda3STony Tye ================================= ====== ====== ================ ================ ===================== 49993138fda3STony Tye 50003138fda3STony TyeA.7.32 Type Signature Computation 50013138fda3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 50023138fda3STony Tye 50033138fda3STony Tye.. note:: 50043138fda3STony Tye 500596ddbd6dSKazu Hirata This augments (in alphabetical order) DWARF Version 5 section 7.32, Table 50063138fda3STony Tye 7.32. 50073138fda3STony Tye 50083138fda3STony Tye.. table:: Attributes used in type signature computation 50093138fda3STony Tye :name: amdgpu-dwarf-attributes-used-in-type-signature-computation-table 50103138fda3STony Tye 50113138fda3STony Tye ================================== ======= 50123138fda3STony Tye ``DW_AT_LLVM_address_space`` 50133138fda3STony Tye ``DW_AT_LLVM_memory_space`` 50143138fda3STony Tye ``DW_AT_LLVM_vector_size`` 50153138fda3STony Tye ================================== ======= 5016e24f5f31STony 50170ac939f3STony TyeA. Attributes by Tag Value (Informative) 50180ac939f3STony Tye---------------------------------------- 5019e24f5f31STony 5020e24f5f31STony.. note:: 5021e24f5f31STony 5022e24f5f31STony This augments DWARF Version 5 Appendix A and Table A.1. 5023e24f5f31STony 5024e24f5f31STonyThe following table provides the additional attributes that are applicable to 5025e24f5f31STonydebugger information entries. 5026e24f5f31STony 5027e24f5f31STony.. table:: Attributes by tag value 5028e24f5f31STony :name: amdgpu-dwarf-attributes-by-tag-value-table 5029e24f5f31STony 50303138fda3STony Tye ================================== ============================= 5031e24f5f31STony Tag Name Applicable Attributes 50323138fda3STony Tye ================================== ============================= 5033e24f5f31STony ``DW_TAG_base_type`` * ``DW_AT_LLVM_vector_size`` 50343138fda3STony Tye ``DW_TAG_pointer_type`` * ``DW_AT_LLVM_address_space`` 50353138fda3STony Tye * ``DW_AT_LLVM_memory_space`` 50363138fda3STony Tye ``DW_TAG_reference_type`` * ``DW_AT_LLVM_address_space`` 50373138fda3STony Tye * ``DW_AT_LLVM_memory_space`` 50383138fda3STony Tye ``DW_TAG_rvalue_reference_type`` * ``DW_AT_LLVM_address_space`` 50393138fda3STony Tye * ``DW_AT_LLVM_memory_space`` 50403138fda3STony Tye ``DW_TAG_variable`` * ``DW_AT_LLVM_memory_space`` 50413138fda3STony Tye ``DW_TAG_formal_parameter`` * ``DW_AT_LLVM_memory_space`` 50423138fda3STony Tye ``DW_TAG_constant`` * ``DW_AT_LLVM_memory_space`` 5043e24f5f31STony ``DW_TAG_compile_unit`` * ``DW_AT_LLVM_augmentation`` 5044e24f5f31STony ``DW_TAG_entry_point`` * ``DW_AT_LLVM_active_lane`` 5045e24f5f31STony * ``DW_AT_LLVM_lane_pc`` 5046e24f5f31STony * ``DW_AT_LLVM_lanes`` 50478ba5043dSTony Tye * ``DW_AT_LLVM_iterations`` 5048e24f5f31STony ``DW_TAG_inlined_subroutine`` * ``DW_AT_LLVM_active_lane`` 5049e24f5f31STony * ``DW_AT_LLVM_lane_pc`` 5050e24f5f31STony * ``DW_AT_LLVM_lanes`` 50518ba5043dSTony Tye * ``DW_AT_LLVM_iterations`` 5052e24f5f31STony ``DW_TAG_subprogram`` * ``DW_AT_LLVM_active_lane`` 5053e24f5f31STony * ``DW_AT_LLVM_lane_pc`` 5054e24f5f31STony * ``DW_AT_LLVM_lanes`` 50558ba5043dSTony Tye * ``DW_AT_LLVM_iterations`` 50563138fda3STony Tye ================================== ============================= 5057e24f5f31STony 50583138fda3STony TyeD. Examples (Informative) 50593138fda3STony Tye------------------------- 5060e24f5f31STony 50613138fda3STony Tye.. note:: 50623138fda3STony Tye 50633138fda3STony Tye This modifies the corresponding DWARF Version 5 Appendix D examples. 50643138fda3STony Tye 50653138fda3STony TyeD.1 General Description Examples 50663138fda3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 50673138fda3STony Tye 50683138fda3STony TyeD.1.3 DWARF Location Description Examples 50693138fda3STony Tye+++++++++++++++++++++++++++++++++++++++++ 50703138fda3STony Tye 50713138fda3STony Tye``DW_OP_offset_uconst 4`` 50723138fda3STony Tye A structure member is four bytes from the start of the structure instance. The 50733138fda3STony Tye location description of the base of the structure instance is assumed to be 50743138fda3STony Tye already on the stack. 50753138fda3STony Tye 50763138fda3STony Tye``DW_OP_entry_value 1 DW_OP_reg5 DW_OP_offset_uconst 16`` 50773138fda3STony Tye The address of the memory location is calculated by adding 16 to the value 50783138fda3STony Tye contained in register 5 upon entering the current subprogram. 50793138fda3STony Tye 50803138fda3STony TyeD.2 Aggregate Examples 50813138fda3STony Tye~~~~~~~~~~~~~~~~~~~~~~ 50823138fda3STony Tye 50833138fda3STony TyeD.2.1 Fortran Simple Array Example 50843138fda3STony Tye++++++++++++++++++++++++++++++++++ 50853138fda3STony Tye 50863138fda3STony TyeFigure D.4: Fortran array example: DWARF description 50873138fda3STony Tye 50883138fda3STony Tye.. code:: 50893138fda3STony Tye :number-lines: 50903138fda3STony Tye 50913138fda3STony Tye ------------------------------------------------------------------------------- 50923138fda3STony Tye ! Description for type of 'ap' 50933138fda3STony Tye ! 50943138fda3STony Tye 1$: DW_TAG_array_type 50953138fda3STony Tye ! No name, default (Fortran) ordering, default stride 50963138fda3STony Tye DW_AT_type(reference to REAL) 50973138fda3STony Tye DW_AT_associated(expression= ! Test 'ptr_assoc' flag 50983138fda3STony Tye DW_OP_push_object_address 50993138fda3STony Tye DW_OP_lit<n> ! where n == offset(ptr_assoc) 51003138fda3STony Tye DW_OP_offset 51013138fda3STony Tye DW_OP_deref 51023138fda3STony Tye DW_OP_lit1 ! mask for 'ptr_assoc' flag 51033138fda3STony Tye DW_OP_and) 51043138fda3STony Tye DW_AT_data_location(expression= ! Get raw data address 51053138fda3STony Tye DW_OP_push_object_address 51063138fda3STony Tye DW_OP_lit<n> ! where n == offset(base) 51073138fda3STony Tye DW_OP_offset 51083138fda3STony Tye DW_OP_deref) ! Type of index of array 'ap' 51093138fda3STony Tye 2$: DW_TAG_subrange_type 51103138fda3STony Tye ! No name, default stride 51113138fda3STony Tye DW_AT_type(reference to INTEGER) 51123138fda3STony Tye DW_AT_lower_bound(expression= 51133138fda3STony Tye DW_OP_push_object_address 51143138fda3STony Tye DW_OP_lit<n> ! where n == 51153138fda3STony Tye ! offset(desc, dims) + 51163138fda3STony Tye ! offset(dims_str, lower_bound) 51173138fda3STony Tye DW_OP_offset 51183138fda3STony Tye DW_OP_deref) 51193138fda3STony Tye DW_AT_upper_bound(expression= 51203138fda3STony Tye DW_OP_push_object_address 51213138fda3STony Tye DW_OP_lit<n> ! where n == 51223138fda3STony Tye ! offset(desc, dims) + 51233138fda3STony Tye ! offset(dims_str, upper_bound) 51243138fda3STony Tye DW_OP_offset 51253138fda3STony Tye DW_OP_deref) 51263138fda3STony Tye ! Note: for the m'th dimension, the second operator becomes 51273138fda3STony Tye ! DW_OP_lit<n> where 51283138fda3STony Tye ! n == offset(desc, dims) + 51293138fda3STony Tye ! (m-1)*sizeof(dims_str) + 51303138fda3STony Tye ! offset(dims_str, [lower|upper]_bound) 51313138fda3STony Tye ! That is, the expression does not get longer for each successive 51323138fda3STony Tye ! dimension (other than to express the larger offsets involved). 51333138fda3STony Tye 3$: DW_TAG_structure_type 51343138fda3STony Tye DW_AT_name("array_ptr") 51353138fda3STony Tye DW_AT_byte_size(constant sizeof(REAL) + sizeof(desc<1>)) 51363138fda3STony Tye 4$: DW_TAG_member 51373138fda3STony Tye DW_AT_name("myvar") 51383138fda3STony Tye DW_AT_type(reference to REAL) 51393138fda3STony Tye DW_AT_data_member_location(constant 0) 51403138fda3STony Tye 5$: DW_TAG_member 51413138fda3STony Tye DW_AT_name("ap"); 51423138fda3STony Tye DW_AT_type(reference to 1$) 51433138fda3STony Tye DW_AT_data_member_location(constant sizeof(REAL)) 51443138fda3STony Tye 6$: DW_TAG_array_type 51453138fda3STony Tye ! No name, default (Fortran) ordering, default stride 51463138fda3STony Tye DW_AT_type(reference to 3$) 51473138fda3STony Tye DW_AT_allocated(expression= ! Test 'ptr_alloc' flag 51483138fda3STony Tye DW_OP_push_object_address 51493138fda3STony Tye DW_OP_lit<n> ! where n == offset(ptr_alloc) 51503138fda3STony Tye DW_OP_offset 51513138fda3STony Tye DW_OP_deref 51523138fda3STony Tye DW_OP_lit2 ! Mask for 'ptr_alloc' flag 51533138fda3STony Tye DW_OP_and) 51543138fda3STony Tye DW_AT_data_location(expression= ! Get raw data address 51553138fda3STony Tye DW_OP_push_object_address 51563138fda3STony Tye DW_OP_lit<n> ! where n == offset(base) 51573138fda3STony Tye DW_OP_offset 51583138fda3STony Tye DW_OP_deref) 51593138fda3STony Tye 7$: DW_TAG_subrange_type 51603138fda3STony Tye ! No name, default stride 51613138fda3STony Tye DW_AT_type(reference to INTEGER) 51623138fda3STony Tye DW_AT_lower_bound(expression= 51633138fda3STony Tye DW_OP_push_object_address 51643138fda3STony Tye DW_OP_lit<n> ! where n == ... 51653138fda3STony Tye DW_OP_offset 51663138fda3STony Tye DW_OP_deref) 51673138fda3STony Tye DW_AT_upper_bound(expression= 51683138fda3STony Tye DW_OP_push_object_address 51693138fda3STony Tye DW_OP_lit<n> ! where n == ... 51703138fda3STony Tye DW_OP_offset 51713138fda3STony Tye DW_OP_deref) 51723138fda3STony Tye 8$: DW_TAG_variable 51733138fda3STony Tye DW_AT_name("arrayvar") 51743138fda3STony Tye DW_AT_type(reference to 6$) 51753138fda3STony Tye DW_AT_location(expression= 51763138fda3STony Tye ...as appropriate...) ! Assume static allocation 51773138fda3STony Tye ------------------------------------------------------------------------------- 51783138fda3STony Tye 51793138fda3STony TyeD.2.3 Fortran 2008 Assumed-rank Array Example 51803138fda3STony Tye+++++++++++++++++++++++++++++++++++++++++++++ 51813138fda3STony Tye 51823138fda3STony TyeFigure D.13: Sample DWARF for the array descriptor in Figure D.12 51833138fda3STony Tye 51843138fda3STony Tye.. code:: 51853138fda3STony Tye :number-lines: 51863138fda3STony Tye 51873138fda3STony Tye ---------------------------------------------------------------------------- 51883138fda3STony Tye 10$: DW_TAG_array_type 51893138fda3STony Tye DW_AT_type(reference to real) 51903138fda3STony Tye DW_AT_rank(expression= 51913138fda3STony Tye DW_OP_push_object_address 51923138fda3STony Tye DW_OP_lit<n> 51933138fda3STony Tye DW_OP_offset 51943138fda3STony Tye DW_OP_deref) 51953138fda3STony Tye DW_AT_data_location(expression= 51963138fda3STony Tye DW_OP_push_object_address 51973138fda3STony Tye DW_OP_lit<n> 51983138fda3STony Tye DW_OP_offset 51993138fda3STony Tye DW_OP_deref) 52003138fda3STony Tye 11$: DW_TAG_generic_subrange 52013138fda3STony Tye DW_AT_type(reference to integer) 52023138fda3STony Tye ! offset of rank in descriptor 52033138fda3STony Tye ! offset of data in descriptor 52043138fda3STony Tye DW_AT_lower_bound(expression= 52053138fda3STony Tye ! Looks up the lower bound of dimension i. 52063138fda3STony Tye ! Operation ! Stack effect 52073138fda3STony Tye ! (implicit) ! i 52083138fda3STony Tye DW_OP_lit<n> ! i sizeof(dim) 52093138fda3STony Tye DW_OP_mul ! dim[i] 52103138fda3STony Tye DW_OP_lit<n> ! dim[i] offsetof(dim) 52113138fda3STony Tye DW_OP_plus ! dim[i]+offset 52123138fda3STony Tye DW_OP_push_object_address ! dim[i]+offsetof(dim) objptr 52133138fda3STony Tye DW_OP_swap ! objptr dim[i]+offsetof(dim) 52143138fda3STony Tye DW_OP_offset ! objptr.dim[i] 52153138fda3STony Tye DW_OP_lit<n> ! objptr.dim[i] offsetof(lb) 52163138fda3STony Tye DW_OP_offset ! objptr.dim[i].lowerbound 52173138fda3STony Tye DW_OP_deref) ! *objptr.dim[i].lowerbound 52183138fda3STony Tye DW_AT_upper_bound(expression= 52193138fda3STony Tye ! Looks up the upper bound of dimension i. 52203138fda3STony Tye DW_OP_lit<n> ! sizeof(dim) 52213138fda3STony Tye DW_OP_mul 52223138fda3STony Tye DW_OP_lit<n> ! offsetof(dim) 52233138fda3STony Tye DW_OP_plus 52243138fda3STony Tye DW_OP_push_object_address 52253138fda3STony Tye DW_OP_swap 52263138fda3STony Tye DW_OP_offset 52273138fda3STony Tye DW_OP_lit<n> ! offset of upperbound in dim 52283138fda3STony Tye DW_OP_offset 52293138fda3STony Tye DW_OP_deref) 52303138fda3STony Tye DW_AT_byte_stride(expression= 52313138fda3STony Tye ! Looks up the byte stride of dimension i. 52323138fda3STony Tye ... 52333138fda3STony Tye ! (analogous to DW_AT_upper_bound) 52343138fda3STony Tye ) 52353138fda3STony Tye ---------------------------------------------------------------------------- 52363138fda3STony Tye 52373138fda3STony Tye.. note:: 52383138fda3STony Tye 52393138fda3STony Tye This example suggests that ``DW_AT_lower_bound`` and ``DW_AT_upper_bound`` 52403138fda3STony Tye evaluate an exprloc with an initial stack containing the rank value. The 52413138fda3STony Tye attribute definition should be updated to state this. 52423138fda3STony Tye 52433138fda3STony TyeD.2.6 Ada Example 52443138fda3STony Tye+++++++++++++++++ 52453138fda3STony Tye 52463138fda3STony TyeFigure D.20: Ada example: DWARF description 52473138fda3STony Tye 52483138fda3STony Tye.. code:: 52493138fda3STony Tye :number-lines: 52503138fda3STony Tye 52513138fda3STony Tye ---------------------------------------------------------------------------- 52523138fda3STony Tye 11$: DW_TAG_variable 52533138fda3STony Tye DW_AT_name("M") 52543138fda3STony Tye DW_AT_type(reference to INTEGER) 52553138fda3STony Tye 12$: DW_TAG_array_type 52563138fda3STony Tye ! No name, default (Ada) order, default stride 52573138fda3STony Tye DW_AT_type(reference to INTEGER) 52583138fda3STony Tye 13$: DW_TAG_subrange_type 52593138fda3STony Tye DW_AT_type(reference to INTEGER) 52603138fda3STony Tye DW_AT_lower_bound(constant 1) 52613138fda3STony Tye DW_AT_upper_bound(reference to variable M at 11$) 52623138fda3STony Tye 14$: DW_TAG_variable 52633138fda3STony Tye DW_AT_name("VEC1") 52643138fda3STony Tye DW_AT_type(reference to array type at 12$) 52653138fda3STony Tye ... 52663138fda3STony Tye 21$: DW_TAG_subrange_type 52673138fda3STony Tye DW_AT_name("TEENY") 52683138fda3STony Tye DW_AT_type(reference to INTEGER) 52693138fda3STony Tye DW_AT_lower_bound(constant 1) 52703138fda3STony Tye DW_AT_upper_bound(constant 100) 52713138fda3STony Tye ... 52723138fda3STony Tye 26$: DW_TAG_structure_type 52733138fda3STony Tye DW_AT_name("REC2") 52743138fda3STony Tye 27$: DW_TAG_member 52753138fda3STony Tye DW_AT_name("N") 52763138fda3STony Tye DW_AT_type(reference to subtype TEENY at 21$) 52773138fda3STony Tye DW_AT_data_member_location(constant 0) 52783138fda3STony Tye 28$: DW_TAG_array_type 52793138fda3STony Tye ! No name, default (Ada) order, default stride 52803138fda3STony Tye ! Default data location 52813138fda3STony Tye DW_AT_type(reference to INTEGER) 52823138fda3STony Tye 29$: DW_TAG_subrange_type 52833138fda3STony Tye DW_AT_type(reference to subrange TEENY at 21$) 52843138fda3STony Tye DW_AT_lower_bound(constant 1) 52853138fda3STony Tye DW_AT_upper_bound(reference to member N at 27$) 52863138fda3STony Tye 30$: DW_TAG_member 52873138fda3STony Tye DW_AT_name("VEC2") 52883138fda3STony Tye DW_AT_type(reference to array "subtype" at 28$) 52893138fda3STony Tye DW_AT_data_member_location(machine= 52903138fda3STony Tye DW_OP_lit<n> ! where n == offset(REC2, VEC2) 52913138fda3STony Tye DW_OP_offset) 52923138fda3STony Tye ... 52933138fda3STony Tye 41$: DW_TAG_variable 52943138fda3STony Tye DW_AT_name("OBJ2B") 52953138fda3STony Tye DW_AT_type(reference to REC2 at 26$) 52963138fda3STony Tye DW_AT_location(...as appropriate...) 52973138fda3STony Tye ---------------------------------------------------------------------------- 52983138fda3STony Tye 52993138fda3STony Tye.. _amdgpu-dwarf-further-examples: 53003138fda3STony Tye 53013138fda3STony TyeC. Further Examples 53023138fda3STony Tye=================== 5303e24f5f31STony 5304e24f5f31STonyThe AMD GPU specific usage of the features in these extensions, including 5305e24f5f31STonyexamples, is available at *User Guide for AMDGPU Backend* section 5306e24f5f31STony:ref:`amdgpu-dwarf-debug-information`. 5307e24f5f31STony 5308e24f5f31STony.. note:: 5309e24f5f31STony 5310e24f5f31STony Change examples to use ``DW_OP_LLVM_offset`` instead of ``DW_OP_add`` when 5311e24f5f31STony acting on a location description. 5312e24f5f31STony 5313e24f5f31STony Need to provide examples of new features. 5314e24f5f31STony 5315e24f5f31STony.. _amdgpu-dwarf-references: 5316e24f5f31STony 53173138fda3STony TyeD. References 53180ac939f3STony Tye============= 5319e24f5f31STony 5320e24f5f31STony .. _amdgpu-dwarf-AMD: 5321e24f5f31STony 5322e24f5f31STony1. [AMD] `Advanced Micro Devices <https://www.amd.com/>`__ 5323e24f5f31STony 5324e24f5f31STony .. _amdgpu-dwarf-AMD-ROCgdb: 5325e24f5f31STony 53260ac939f3STony Tye2. [AMD-ROCgdb] `AMD ROCm Debugger (ROCgdb) <https://github.com/ROCm-Developer-Tools/ROCgdb>`__ 53270ac939f3STony Tye 53280ac939f3STony Tye .. _amdgpu-dwarf-AMD-ROCm: 53290ac939f3STony Tye 53300ac939f3STony Tye3. [AMD-ROCm] `AMD ROCm Platform <https://rocm-documentation.readthedocs.io>`__ 53310ac939f3STony Tye 53320ac939f3STony Tye .. _amdgpu-dwarf-AMDGPU-DWARF-LOC: 53330ac939f3STony Tye 53340ac939f3STony Tye4. [AMDGPU-DWARF-LOC] `Allow Location Descriptions on the DWARF Expression Stack <https://llvm.org/docs/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack.html>`__ 5335e24f5f31STony 5336e24f5f31STony .. _amdgpu-dwarf-AMDGPU-LLVM: 5337e24f5f31STony 53380ac939f3STony Tye5. [AMDGPU-LLVM] `User Guide for AMDGPU LLVM Backend <https://llvm.org/docs/AMDGPUUsage.html>`__ 5339e24f5f31STony 5340e24f5f31STony .. _amdgpu-dwarf-CUDA: 5341e24f5f31STony 53420ac939f3STony Tye6. [CUDA] `Nvidia CUDA Language <https://docs.nvidia.com/cuda/cuda-c-programming-guide/>`__ 5343e24f5f31STony 5344e24f5f31STony .. _amdgpu-dwarf-DWARF: 5345e24f5f31STony 53460ac939f3STony Tye7. [DWARF] `DWARF Debugging Information Format <http://dwarfstd.org/>`__ 5347e24f5f31STony 5348e24f5f31STony .. _amdgpu-dwarf-ELF: 5349e24f5f31STony 53500ac939f3STony Tye8. [ELF] `Executable and Linkable Format (ELF) <http://www.sco.com/developers/gabi/>`__ 5351e24f5f31STony 5352e24f5f31STony .. _amdgpu-dwarf-GCC: 5353e24f5f31STony 53540ac939f3STony Tye9. [GCC] `GCC: The GNU Compiler Collection <https://www.gnu.org/software/gcc/>`__ 5355e24f5f31STony 5356e24f5f31STony .. _amdgpu-dwarf-GDB: 5357e24f5f31STony 53580ac939f3STony Tye10. [GDB] `GDB: The GNU Project Debugger <https://www.gnu.org/software/gdb/>`__ 5359e24f5f31STony 5360e24f5f31STony .. _amdgpu-dwarf-HIP: 5361e24f5f31STony 53620ac939f3STony Tye11. [HIP] `HIP Programming Guide <https://rocm-documentation.readthedocs.io/en/latest/Programming_Guides/Programming-Guides.html#hip-programing-guide>`__ 5363e24f5f31STony 5364e24f5f31STony .. _amdgpu-dwarf-HSA: 5365e24f5f31STony 53660ac939f3STony Tye12. [HSA] `Heterogeneous System Architecture (HSA) Foundation <http://www.hsafoundation.com/>`__ 5367e24f5f31STony 5368e24f5f31STony .. _amdgpu-dwarf-LLVM: 5369e24f5f31STony 53700ac939f3STony Tye13. [LLVM] `The LLVM Compiler Infrastructure <https://llvm.org/>`__ 5371e24f5f31STony 5372e24f5f31STony .. _amdgpu-dwarf-OpenCL: 5373e24f5f31STony 53740ac939f3STony Tye14. [OpenCL] `The OpenCL Specification Version 2.0 <http://www.khronos.org/registry/cl/specs/opencl-2.0.pdf>`__ 5375e24f5f31STony 5376e24f5f31STony .. _amdgpu-dwarf-Perforce-TotalView: 5377e24f5f31STony 53780ac939f3STony Tye15. [Perforce-TotalView] `Perforce TotalView HPC Debugging Software <https://totalview.io/products/totalview>`__ 5379e24f5f31STony 5380e24f5f31STony .. _amdgpu-dwarf-SEMVER: 5381e24f5f31STony 53820ac939f3STony Tye16. [SEMVER] `Semantic Versioning <https://semver.org/>`__ 5383