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 570ac939f3STony Tye:ref:`amdgpu-dwarf-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 630ac939f3STony Tye1. 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 2250ac939f3STony Tyeof two's compliment 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 2460ac939f3STony TyeSee ``DW_OP_LLVM_offset``, ``DW_OP_LLVM_offset_uconst``, and 2470ac939f3STony Tye``DW_OP_LLVM_bit_offset`` in 2480ac939f3STony Tye:ref:`amdgpu-dwarf-general-location-description-operations`. 2490ac939f3STony Tye 2500ac939f3STony Tye2.5 Generalize Creation of Undefined Location Descriptions 2510ac939f3STony Tye---------------------------------------------------------- 2520ac939f3STony Tye 2530ac939f3STony TyeCurrent DWARF uses an empty expression to indicate an undefined location 2540ac939f3STony Tyedescription. Since 2550ac939f3STony Tye:ref:`amdgpu-dwarf-allow-location-description-on-the-dwarf-evaluation-stack` 2560ac939f3STony Tyeallows location descriptions to be created on the stack, it is necessary to have 2570ac939f3STony Tyean explicit way to specify an undefined location description. 2580ac939f3STony Tye 2590ac939f3STony TyeFor example, the ``DW_OP_LLVM_select_bit_piece`` (see 2600ac939f3STony Tye:ref:`amdgpu-dwarf-support-for-divergent-control-flow-of-simt-hardware`) 2610ac939f3STony Tyeoperation takes more than one location description on the stack. Without this 2620ac939f3STony Tyeability, it is not possible to specify that a particular one of the input 2630ac939f3STony Tyelocation descriptions is undefined. 2640ac939f3STony Tye 2650ac939f3STony TyeSee the ``DW_OP_LLVM_undefined`` operation in 2660ac939f3STony Tye:ref:`amdgpu-dwarf-undefined-location-description-operations`. 2670ac939f3STony Tye 2680ac939f3STony Tye2.6 Generalize Creation of Composite Location Descriptions 2690ac939f3STony Tye---------------------------------------------------------- 2700ac939f3STony Tye 2710ac939f3STony TyeTo allow composition of composite location descriptions, an explicit operation 2720ac939f3STony Tyethat indicates the end of the definition of a composite location description is 2730ac939f3STony Tyerequired. This can be implied if the end of a DWARF expression is reached, 2740ac939f3STony Tyeallowing current DWARF expressions to remain legal. 2750ac939f3STony Tye 2760ac939f3STony TyeSee ``DW_OP_LLVM_piece_end`` in 2770ac939f3STony Tye:ref:`amdgpu-dwarf-composite-location-description-operations`. 2780ac939f3STony Tye 2790ac939f3STony Tye2.7 Generalize DWARF Base Objects to Allow Any Location Description Kind 2800ac939f3STony Tye------------------------------------------------------------------------ 2810ac939f3STony Tye 2820ac939f3STony TyeThe number of registers and the cost of memory operations is much higher for 2830ac939f3STony TyeAMDGPU than a typical CPU. The compiler attempts to optimize whole variables and 2840ac939f3STony Tyearrays into registers. 2850ac939f3STony Tye 2860ac939f3STony TyeCurrently DWARF only allows ``DW_OP_push_object_address`` and related operations 2870ac939f3STony Tyeto work with a global memory location. To support AMDGPU optimized code it is 2880ac939f3STony Tyerequired to generalize DWARF to allow any location description to be used. This 2890ac939f3STony Tyeallows registers, or composite location descriptions that may be a mixture of 2900ac939f3STony Tyememory, registers, or even implicit values. 2910ac939f3STony Tye 2920ac939f3STony TyeSee ``DW_OP_push_object_address`` in 2930ac939f3STony Tye:ref:`amdgpu-dwarf-general-location-description-operations`. 2940ac939f3STony Tye 2950ac939f3STony Tye2.8 General Support for Address Spaces 2960ac939f3STony Tye-------------------------------------- 2970ac939f3STony Tye 2980ac939f3STony TyeAMDGPU needs to be able to describe addresses that are in different kinds of 2990ac939f3STony Tyememory. Optimized code may need to describe a variable that resides in pieces 3000ac939f3STony Tyethat are in different kinds of storage which may include parts of registers, 3010ac939f3STony Tyememory that is in a mixture of memory kinds, implicit values, or be undefined. 3020ac939f3STony Tye 3030ac939f3STony TyeDWARF has the concept of segment addresses. However, the segment cannot be 3040ac939f3STony Tyespecified within a DWARF expression, which is only able to specify the offset 3050ac939f3STony Tyeportion of a segment address. The segment index is only provided by the entity 3060ac939f3STony Tyethat specifies the DWARF expression. Therefore, the segment index is a property 3070ac939f3STony Tyethat can only be put on complete objects, such as a variable. That makes it only 3080ac939f3STony Tyesuitable for describing an entity (such as variable or subprogram code) that is 3090ac939f3STony Tyein a single kind of memory. 3100ac939f3STony Tye 3110ac939f3STony TyeTherefore, AMDGPU uses the DWARF concept of address spaces. For example, a 3120ac939f3STony Tyevariable may be allocated in a register that is partially spilled to the call 3130ac939f3STony Tyestack which is in the private address space, and partially spilled to the local 3140ac939f3STony Tyeaddress space. 3150ac939f3STony Tye 3160ac939f3STony TyeDWARF uses the concept of an address in many expression operations but does not 3170ac939f3STony Tyedefine how it relates to address spaces. For example, 3180ac939f3STony Tye``DW_OP_push_object_address`` pushes the address of an object. Other contexts 3190ac939f3STony Tyeimplicitly push an address on the stack before evaluating an expression. For 3200ac939f3STony Tyeexample, the ``DW_AT_use_location`` attribute of the 3210ac939f3STony Tye``DW_TAG_ptr_to_member_type``. The expression belongs to a source language type 3220ac939f3STony Tyewhich may apply to objects allocated in different kinds of storage. Therefore, 3230ac939f3STony Tyeit is desirable that the expression that uses the address can do so without 3240ac939f3STony Tyeregard to what kind of storage it specifies, including the address space of a 3250ac939f3STony Tyememory location description. For example, a pointer to member value may want to 3260ac939f3STony Tyebe applied to an object that may reside in any address space. 3270ac939f3STony Tye 3280ac939f3STony TyeThe DWARF ``DW_OP_xderef*`` operations allow a value to be converted into an 3290ac939f3STony Tyeaddress of a specified address space which is then read. But it provides no 3300ac939f3STony Tyeway to create a memory location description for an address in the non-default 3310ac939f3STony Tyeaddress space. For example, AMDGPU variables can be allocated in the local 3320ac939f3STony Tyeaddress space at a fixed address. 3330ac939f3STony Tye 3340ac939f3STony TyeThe ``DW_OP_LLVM_form_aspace_address`` (see 3350ac939f3STony Tye:ref:`amdgpu-dwarf-memory-location-description-operations`) operation is defined 3360ac939f3STony Tyeto create a memory location description from an address and address space. If 3370ac939f3STony Tyecan be used to specify the location of a variable that is allocated in a 3380ac939f3STony Tyespecific address space. This allows the size of addresses in an address space to 3390ac939f3STony Tyebe larger than the generic type. It also allows a consumer great implementation 3400ac939f3STony Tyefreedom. It allows the implicit conversion back to a value to be limited only to 3410ac939f3STony Tyethe default address space to maintain compatibility with DWARF Version 5. For 3420ac939f3STony Tyeother address spaces the producer can use the new operations that explicitly 3430ac939f3STony Tyespecify the address space. 3440ac939f3STony Tye 3450ac939f3STony TyeIn contrast, if the ``DW_OP_LLVM_form_aspace_address`` operation had been 3460ac939f3STony Tyedefined to produce a value, and an implicit conversion to a memory location 3470ac939f3STony Tyedescription was defined, then it would be limited to the size of the generic 3480ac939f3STony Tyetype (which matches the size of the default address space). An implementation 3490ac939f3STony Tyewould likely have to use *reserved ranges* of value to represent different 3500ac939f3STony Tyeaddress spaces. Such a value would likely not match any address value in the 3510ac939f3STony Tyeactual hardware. That would require the consumer to have special treatment for 3520ac939f3STony Tyesuch values. 3530ac939f3STony Tye 3540ac939f3STony Tye``DW_OP_breg*`` treats the register as containing an address in the default 3550ac939f3STony Tyeaddress space. A ``DW_OP_LLVM_aspace_bregx`` (see 3560ac939f3STony Tye:ref:`amdgpu-dwarf-memory-location-description-operations`) operation is added 3570ac939f3STony Tyeto allow the address space of the address held in a register to be specified. 3580ac939f3STony Tye 3590ac939f3STony TyeSimilarly, ``DW_OP_implicit_pointer`` treats its implicit pointer value as being 3600ac939f3STony Tyein the default address space. A ``DW_OP_LLVM_aspace_implicit_pointer`` 3610ac939f3STony Tye(:ref:`amdgpu-dwarf-implicit-location-description-operations`) operation is 3620ac939f3STony Tyeadded to allow the address space to be specified. 3630ac939f3STony Tye 3640ac939f3STony TyeAlmost all uses of addresses in DWARF are limited to defining location 3650ac939f3STony Tyedescriptions, or to be dereferenced to read memory. The exception is 3660ac939f3STony Tye``DW_CFA_val_offset`` which uses the address to set the value of a register. In 3670ac939f3STony Tyeorder to support address spaces, the CFA DWARF expression is defined to be a 3680ac939f3STony Tyememory location description. This allows it to specify an address space which is 3690ac939f3STony Tyeused to convert the offset address back to an address in that address space. See 370e24f5f31STony:ref:`amdgpu-dwarf-call-frame-information`. 371e24f5f31STony 3720ac939f3STony TyeThis approach of extending memory location descriptions to support address 3730ac939f3STony Tyespaces, allows all existing DWARF Version 5 expressions to have the identical 3740ac939f3STony Tyesemantics. It allows the compiler to explicitly specify the address space it is 3750ac939f3STony Tyeusing. For example, a compiler could choose to access private memory in a 3760ac939f3STony Tyeswizzled manner when mapping a source language thread to the lane of a wavefront 3770ac939f3STony Tyein a SIMT manner. Or a compiler could choose to access it in an unswizzled 3780ac939f3STony Tyemanner if mapping the same language with the wavefront being the thread. 3790ac939f3STony Tye 3800ac939f3STony TyeIt also allows the compiler to mix the address space it uses to access private 3810ac939f3STony Tyememory. For example, for SIMT it can still spill entire vector registers in an 3820ac939f3STony Tyeunswizzled manner, while using a swizzled private memory for SIMT variable 3830ac939f3STony Tyeaccess. 3840ac939f3STony Tye 3850ac939f3STony TyeThis approach also allows memory location descriptions for different address 3860ac939f3STony Tyespaces to be combined using the regular ``DW_OP_*piece`` operations. 3870ac939f3STony Tye 3880ac939f3STony TyeLocation descriptions are an abstraction of storage. They give freedom to the 3890ac939f3STony Tyeconsumer on how to implement them. They allow the address space to encode lane 3900ac939f3STony Tyeinformation so they can be used to read memory with only the memory location 3910ac939f3STony Tyedescription and no extra information. The same set of operations can operate on 3920ac939f3STony Tyelocations independent of their kind of storage. The ``DW_OP_deref*`` therefore 3930ac939f3STony Tyecan be used on any storage kind, including memory location descriptions of 3940ac939f3STony Tyedifferent address spaces. Therefore, the ``DW_OP_xderef*`` operations are 3950ac939f3STony Tyeunnecessary, except to become a more compact way to encode a non-default address 3960ac939f3STony Tyespace address followed by dereferencing it. See 3970ac939f3STony Tye:ref:`amdgpu-dwarf-general-operations`. 3980ac939f3STony Tye 3990ac939f3STony Tye2.9 Support for Vector Base Types 4000ac939f3STony Tye--------------------------------- 4010ac939f3STony Tye 402e24f5f31STonyThe vector registers of the AMDGPU are represented as their full wavefront 403e24f5f31STonysize, meaning the wavefront size times the dword size. This reflects the 404e24f5f31STonyactual hardware and allows the compiler to generate DWARF for languages that 405e24f5f31STonymap a thread to the complete wavefront. It also allows more efficient DWARF to 406e24f5f31STonybe generated to describe the CFI as only a single expression is required for 407e24f5f31STonythe whole vector register, rather than a separate expression for each lane's 408e24f5f31STonydword of the vector register. It also allows the compiler to produce DWARF 409e24f5f31STonythat indexes the vector register if it spills scalar registers into portions 410b9496efbSvnalamotof a vector register. 411e24f5f31STony 412e24f5f31STonySince DWARF stack value entries have a base type and AMDGPU registers are a 413e24f5f31STonyvector of dwords, the ability to specify that a base type is a vector is 4140ac939f3STony Tyerequired. 4150ac939f3STony Tye 4160ac939f3STony TyeSee ``DW_AT_LLVM_vector_size`` in :ref:`amdgpu-dwarf-literal-operations`. 4170ac939f3STony Tye 4180ac939f3STony Tye.. _amdgpu-dwarf-operation-to-create-vector-composite-location-descriptions: 4190ac939f3STony Tye 4200ac939f3STony Tye2.10 DWARF Operations to Create Vector Composite Location Descriptions 4210ac939f3STony Tye---------------------------------------------------------------------- 4220ac939f3STony Tye 4230ac939f3STony TyeAMDGPU optimized code may spill vector registers to non-global address space 4240ac939f3STony Tyememory, and this spilling may be done only for SIMT lanes that are active on 4250ac939f3STony Tyeentry to the subprogram. 4260ac939f3STony Tye 4270ac939f3STony TyeTo support this, a composite location description that can be created as a 4280ac939f3STony Tyemasked select is required. In addition, an operation that creates a composite 4290ac939f3STony Tyelocation description that is a vector on another location description is needed. 4300ac939f3STony Tye 4310ac939f3STony TyeAn example that uses these operations is referenced in the 4320ac939f3STony Tye:ref:`amdgpu-dwarf-examples` appendix. 4330ac939f3STony Tye 4340ac939f3STony TyeSee ``DW_OP_LLVM_select_bit_piece`` and ``DW_OP_LLVM_extend`` in 4350ac939f3STony Tye:ref:`amdgpu-dwarf-composite-location-description-operations`. 4360ac939f3STony Tye 4370ac939f3STony Tye2.11 DWARF Operation to Access Call Frame Entry Registers 4380ac939f3STony Tye--------------------------------------------------------- 4390ac939f3STony Tye 4400ac939f3STony TyeAs described in 4410ac939f3STony Tye:ref:`amdgpu-dwarf-operation-to-create-vector-composite-location-descriptions`, 4420ac939f3STony Tyea DWARF expression involving the set of SIMT lanes active on entry to a 4430ac939f3STony Tyesubprogram is required. The SIMT active lane mask may be held in a register that 4440ac939f3STony Tyeis modified as the subprogram executes. However, its value may be saved on entry 4450ac939f3STony Tyeto the subprogram. 4460ac939f3STony Tye 4470ac939f3STony TyeThe Call Frame Information (CFI) already encodes such register saving, so it is 4480ac939f3STony Tyemore efficient to provide an operation to return the location of a saved 4490ac939f3STony Tyeregister than have to generate a loclist to describe the same information. This 4500ac939f3STony Tyeis now possible since 4510ac939f3STony Tye:ref:`amdgpu-dwarf-allow-location-description-on-the-dwarf-evaluation-stack` 4520ac939f3STony Tyeallows location descriptions on the stack. 4530ac939f3STony Tye 4540ac939f3STony TyeSee ``DW_OP_LLVM_call_frame_entry_reg`` in 4550ac939f3STony Tye:ref:`amdgpu-dwarf-general-location-description-operations` and 4560ac939f3STony Tye:ref:`amdgpu-dwarf-call-frame-information`. 4570ac939f3STony Tye 4580ac939f3STony Tye2.12 Support for Source Languages Mapped to SIMT Hardware 4590ac939f3STony Tye--------------------------------------------------------- 460e24f5f31STony 461e24f5f31STonyIf the source language is mapped onto the AMDGPU wavefronts in a SIMT manner, 462e24f5f31STonythen the variable DWARF location expressions must compute the location for a 463e24f5f31STonysingle lane of the wavefront. Therefore, a DWARF operation is required to denote 464e24f5f31STonythe current lane, much like ``DW_OP_push_object_address`` denotes the current 4658ba5043dSTony Tyeobject. See ``DW_OP_LLVM_push_lane`` in :ref:`amdgpu-dwarf-literal-operations`. 466e24f5f31STony 4678ba5043dSTony TyeIn addition, a way is needed for the compiler to communicate how many source 4688ba5043dSTony Tyelanguage threads of execution are mapped to a target architecture thread's SIMT 4698ba5043dSTony Tyelanes. See ``DW_AT_LLVM_lanes`` in :ref:`amdgpu-dwarf-low-level-information`. 470e24f5f31STony 4710ac939f3STony Tye.. _amdgpu-dwarf-support-for-divergent-control-flow-of-simt-hardware: 472e24f5f31STony 4730ac939f3STony Tye2.13 Support for Divergent Control Flow of SIMT Hardware 4740ac939f3STony Tye-------------------------------------------------------- 475e24f5f31STony 4760ac939f3STony TyeIf the source language is mapped onto the AMDGPU wavefronts in a SIMT manner the 4770ac939f3STony Tyecompiler can use the AMDGPU execution mask register to control which lanes are 4780ac939f3STony Tyeactive. To describe the conceptual location of non-active lanes requires an 4790ac939f3STony Tyeattribute that has an expression that computes the source location PC for each 4800ac939f3STony Tyelane. 481e24f5f31STony 4820ac939f3STony TyeFor efficiency, the expression calculates the source location the wavefront as a 4830ac939f3STony Tyewhole. This can be done using the ``DW_OP_LLVM_select_bit_piece`` (see 4840ac939f3STony Tye:ref:`amdgpu-dwarf-operation-to-create-vector-composite-location-descriptions`) 4850ac939f3STony Tyeoperation. 486e24f5f31STony 4870ac939f3STony TyeThe AMDGPU may update the execution mask to perform whole wavefront operations. 4880ac939f3STony TyeTherefore, there is a need for an attribute that computes the current active 4890ac939f3STony Tyelane mask. This can have an expression that may evaluate to the SIMT active lane 4900ac939f3STony Tyemask register or to a saved mask when in whole wavefront execution mode. 491e24f5f31STony 4920ac939f3STony TyeAn example that uses these attributes is referenced in the 4930ac939f3STony Tye:ref:`amdgpu-dwarf-examples` appendix. 494e24f5f31STony 4950ac939f3STony TyeSee ``DW_AT_LLVM_lane_pc`` and ``DW_AT_LLVM_active_lane`` in 4960ac939f3STony Tye:ref:`amdgpu-dwarf-composite-location-description-operations`. 497e24f5f31STony 4980ac939f3STony Tye2.14 Define Source Language Address Classes 4990ac939f3STony Tye------------------------------------------- 500e24f5f31STony 5010ac939f3STony TyeAMDGPU supports languages, such as OpenCL [:ref:`OpenCL <amdgpu-dwarf-OpenCL>`], 5020ac939f3STony Tyethat define source language address classes. Support is added to define language 5030ac939f3STony Tyespecific address classes so they can be used in a consistent way by consumers. 504e24f5f31STony 5050ac939f3STony TyeIt would also be desirable to add support for using address classes in defining 5060ac939f3STony Tyesource language types. DWARF Version 5 only supports using target architecture 5070ac939f3STony Tyespecific address spaces. 508e24f5f31STony 5090ac939f3STony TyeSee :ref:`amdgpu-dwarf-segment_addresses`. 510e24f5f31STony 5110ac939f3STony Tye2.15 Define Augmentation Strings to Support Multiple Extensions 5120ac939f3STony Tye--------------------------------------------------------------- 513e24f5f31STony 5140ac939f3STony TyeA ``DW_AT_LLVM_augmentation`` attribute is added to a compilation unit debugger 5150ac939f3STony Tyeinformation entry to indicate that there is additional target architecture 5160ac939f3STony Tyespecific information in the debugging information entries of that compilation 5170ac939f3STony Tyeunit. This allows a consumer to know what extensions are present in the debugger 5180ac939f3STony Tyeinformation entries as is possible with the augmentation string of other 5190ac939f3STony Tyesections. See . 520e24f5f31STony 5210ac939f3STony TyeThe format that should be used for an augmentation string is also recommended. 5220ac939f3STony TyeThis allows a consumer to parse the string when it contains information from 5230ac939f3STony Tyemultiple vendors. Augmentation strings occur in the ``DW_AT_LLVM_augmentation`` 5240ac939f3STony Tyeattribute, in the lookup by name table, and in the CFI Common Information Entry 5250ac939f3STony Tye(CIE). 526e24f5f31STony 5270ac939f3STony TyeSee :ref:`amdgpu-dwarf-full-and-partial-compilation-unit-entries`, 5280ac939f3STony Tye:ref:`amdgpu-dwarf-name-index-section-header`, and 5290ac939f3STony Tye:ref:`amdgpu-dwarf-structure_of-call-frame-information`. 530e24f5f31STony 5310ac939f3STony Tye2.16 Support Embedding Source Text for Online Compilation 5320ac939f3STony Tye--------------------------------------------------------- 533e24f5f31STony 5340ac939f3STony TyeAMDGPU supports programming languages that include online compilation where the 5350ac939f3STony Tyesource text may be created at runtime. For example, the OpenCL and HIP language 5360ac939f3STony Tyeruntimes support online compilation. To support is, a way to embed the source 5370ac939f3STony Tyetext in the debug information is provided. 538e24f5f31STony 5390ac939f3STony TyeSee :ref:`amdgpu-dwarf-line-number-information`. 540e24f5f31STony 5410ac939f3STony Tye2.17 Allow MD5 Checksums to be Optionally Present 5420ac939f3STony Tye------------------------------------------------- 543e24f5f31STony 5440ac939f3STony TyeIn DWARF Version 5 the file timestamp and file size can be optional, but if the 5450ac939f3STony TyeMD5 checksum is present it must be valid for all files. This is a problem if 5460ac939f3STony Tyeusing link time optimization to combine compilation units where some have MD5 5470ac939f3STony Tyechecksums and some do not. Therefore, sSupport to allow MD5 checksums to be 5480ac939f3STony Tyeoptionally present in the line table is added. 549e24f5f31STony 5500ac939f3STony TyeSee :ref:`amdgpu-dwarf-line-number-information`. 551e24f5f31STony 5520ac939f3STony Tye2.18 Add the HIP Programing Language 5530ac939f3STony Tye------------------------------------ 554e24f5f31STony 5550ac939f3STony TyeThe HIP programming language [:ref:`HIP <amdgpu-dwarf-HIP>`], which is supported 5560ac939f3STony Tyeby the AMDGPU, is added. 557e24f5f31STony 5580ac939f3STony TyeSee :ref:`amdgpu-dwarf-language-names-table`. 559e24f5f31STony 5608ba5043dSTony Tye2.19 Support for Source Language Optimizations that Result in Concurrent Iteration Execution 5618ba5043dSTony Tye-------------------------------------------------------------------------------------------- 5628ba5043dSTony Tye 5638ba5043dSTony TyeA compiler can perform loop optimizations that result in the generated code 5648ba5043dSTony Tyeexecuting multiple iterations concurrently. For example, software pipelining 5658ba5043dSTony Tyeschedules multiple iterations in an interleaved fashion to allow the 5668ba5043dSTony Tyeinstructions of one iteration to hide the latencies of the instructions of 5678ba5043dSTony Tyeanother iteration. Another example is vectorization that can exploit SIMD 5688ba5043dSTony Tyehardware to allow a single instruction to execute multiple iterations using 5698ba5043dSTony Tyevector registers. 5708ba5043dSTony Tye 5718ba5043dSTony TyeNote that although this is similar to SIMT execution, the way a client debugger 5728ba5043dSTony Tyeuses the information is fundamentally different. In SIMT execution the debugger 5738ba5043dSTony Tyeneeds to present the concurrent execution as distinct source language threads 5748ba5043dSTony Tyethat the user can list and switch focus between. With iteration concurrency 5758ba5043dSTony Tyeoptimizations, such as software pipelining and vectorized SIMD, the debugger 5768ba5043dSTony Tyemust not present the concurrency as distinct source language threads. Instead, 5778ba5043dSTony Tyeit must inform the user that multiple loop iterations are executing in parallel 5788ba5043dSTony Tyeand allow the user to select between them. 5798ba5043dSTony Tye 5808ba5043dSTony TyeIn general, SIMT execution fixes the number of concurrent executions per target 5818ba5043dSTony Tyearchitecture thread. However, both software pipelining and SIMD vectorization 5828ba5043dSTony Tyemay vary the number of concurrent iterations for different loops executed by a 5838ba5043dSTony Tyesingle source language thread. 5848ba5043dSTony Tye 5858ba5043dSTony TyeIt is possible for the compiler to use both SIMT concurrency and iteration 5868ba5043dSTony Tyeconcurrency techniques in the code of a single source language thread. 5878ba5043dSTony Tye 5888ba5043dSTony TyeTherefore, a DWARF operation is required to denote the current concurrent 5898ba5043dSTony Tyeiteration instance, much like ``DW_OP_push_object_address`` denotes the current 5908ba5043dSTony Tyeobject. See ``DW_OP_LLVM_push_iteration`` in 5918ba5043dSTony Tye:ref:`amdgpu-dwarf-literal-operations`. 5928ba5043dSTony Tye 5938ba5043dSTony TyeIn addition, a way is needed for the compiler to communicate how many source 5948ba5043dSTony Tyelanguage loop iterations are executing concurrently. See 5958ba5043dSTony Tye``DW_AT_LLVM_iterations`` in :ref:`amdgpu-dwarf-low-level-information`. 5968ba5043dSTony Tye 5978ba5043dSTony Tye2.20 DWARF Operation to Create Runtime Overlay Composite Location Description 5988ba5043dSTony Tye----------------------------------------------------------------------------- 5998ba5043dSTony Tye 6008ba5043dSTony TyeIt is common in SIMD vectorization for the compiler to generate code that 6018ba5043dSTony Tyepromotes portions of an array into vector registers. For example, if the 6028ba5043dSTony Tyehardware has vector registers with 8 elements, and 8 wide SIMD instructions, the 6038ba5043dSTony Tyecompiler may vectorize a loop so that is executes 8 iterations concurrently for 6048ba5043dSTony Tyeeach vectorized loop iteration. 6058ba5043dSTony Tye 6068ba5043dSTony TyeOn the first iteration of the generated vectorized loop, iterations 0 to 7 of 6078ba5043dSTony Tyethe source language loop will be executed using SIMD instructions. Then on the 6088ba5043dSTony Tyenext iteration of the generated vectorized loop, iteration 8 to 15 will be 6098ba5043dSTony Tyeexecuted, and so on. 6108ba5043dSTony Tye 6118ba5043dSTony TyeIf the source language loop accesses an array element based on the loop 6128ba5043dSTony Tyeiteration index, the compiler may read the element into a register for the 6138ba5043dSTony Tyeduration of that iteration. Next iteration it will read the next element into 6148ba5043dSTony Tyethe register, and so on. With SIMD, this generalizes to the compiler reading 6158ba5043dSTony Tyearray elements 0 to 7 into a vector register on the first vectorized loop 6168ba5043dSTony Tyeiteration, then array elements 8 to 15 on the next iteration, and so on. 6178ba5043dSTony Tye 6188ba5043dSTony TyeThe DWARF location description for the array needs to express that all elements 6198ba5043dSTony Tyeare in memory, except the slice that has been promoted to the vector register. 6208ba5043dSTony TyeThe starting position of the slice is a runtime value based on the iteration 6218ba5043dSTony Tyeindex modulo the vectorization size. This cannot be expressed by ``DW_OP_piece`` 6228ba5043dSTony Tyeand ``DW_OP_bit_piece`` which only allow constant offsets to be expressed. 6238ba5043dSTony Tye 6248ba5043dSTony TyeTherefore, a new operator is defined that takes two location descriptions, an 6258ba5043dSTony Tyeoffset and a size, and creates a composite that effectively uses the second 6268ba5043dSTony Tyelocation description as an overlay of the first, positioned according to the 6278ba5043dSTony Tyeoffset and size. See ``DW_OP_LLVM_overlay`` and ``DW_OP_LLVM_bit_overlay`` in 6288ba5043dSTony Tye:ref:`amdgpu-dwarf-composite-location-description-operations`. 6298ba5043dSTony Tye 630e24f5f31STony.. _amdgpu-dwarf-changes-relative-to-dwarf-version-5: 631e24f5f31STony 6320ac939f3STony TyeA. Changes Relative to DWARF Version 5 6330ac939f3STony Tye====================================== 634e24f5f31STony 6350ac939f3STony Tye.. note:: 636e24f5f31STony 6370ac939f3STony Tye This appendix provides changes relative to DWARF Version 5. It has been 6380ac939f3STony Tye defined such that it is backwards compatible with DWARF Version 5. 6390ac939f3STony Tye Non-normative text is shown in *italics*. The section numbers generally 6400ac939f3STony Tye correspond to those in the DWARF Version 5 standard unless specified 6410ac939f3STony Tye otherwise. Definitions are given for the additional operations, as well as 6420ac939f3STony Tye clarifying how existing expression operations, CFI operations, and attributes 6430ac939f3STony Tye behave with respect to generalized location descriptions that support address 6440ac939f3STony Tye spaces and multiple places. 6450ac939f3STony Tye 6460ac939f3STony Tye The names for the new operations, attributes, and constants include "\ 6470ac939f3STony Tye ``LLVM``\ " and are encoded with vendor specific codes so these extensions can 6480ac939f3STony Tye be implemented as an LLVM vendor extension to DWARF Version 5. 6490ac939f3STony Tye 6500ac939f3STony Tye .. note:: 6510ac939f3STony Tye 6520ac939f3STony Tye Notes are included to describe how the changes are to be applied to the 6530ac939f3STony Tye DWARF Version 5 standard. They also describe rational and issues that may 6540ac939f3STony Tye need further consideration. 6550ac939f3STony Tye 6560ac939f3STony TyeA.2 General Description 6570ac939f3STony Tye----------------------- 6580ac939f3STony Tye 6590ac939f3STony TyeA.2.2 Attribute Types 6600ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~ 661e24f5f31STony 662e24f5f31STony.. note:: 663e24f5f31STony 664e24f5f31STony This augments DWARF Version 5 section 2.2 and Table 2.2. 665e24f5f31STony 6660ac939f3STony TyeThe following table provides the additional attributes. 667e24f5f31STony 668e24f5f31STony.. table:: Attribute names 669e24f5f31STony :name: amdgpu-dwarf-attribute-names-table 670e24f5f31STony 671e24f5f31STony =========================== ==================================== 672e24f5f31STony Attribute Usage 673e24f5f31STony =========================== ==================================== 6748ba5043dSTony Tye ``DW_AT_LLVM_active_lane`` SIMT active lanes (see :ref:`amdgpu-dwarf-low-level-information`) 6750ac939f3STony Tye ``DW_AT_LLVM_augmentation`` Compilation unit augmentation string (see :ref:`amdgpu-dwarf-full-and-partial-compilation-unit-entries`) 6768ba5043dSTony Tye ``DW_AT_LLVM_lane_pc`` SIMT lane program location (see :ref:`amdgpu-dwarf-low-level-information`) 6778ba5043dSTony Tye ``DW_AT_LLVM_lanes`` SIMT lane count (see :ref:`amdgpu-dwarf-low-level-information`) 6788ba5043dSTony Tye ``DW_AT_LLVM_iterations`` Concurrent iteration count (see :ref:`amdgpu-dwarf-low-level-information`) 6790ac939f3STony Tye ``DW_AT_LLVM_vector_size`` Base type vector size (see :ref:`amdgpu-dwarf-base-type-entries`) 680e24f5f31STony =========================== ==================================== 681e24f5f31STony 682e24f5f31STony.. _amdgpu-dwarf-expressions: 683e24f5f31STony 6840ac939f3STony TyeA.2.5 DWARF Expressions 6850ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~ 686e24f5f31STony 687e24f5f31STony.. note:: 688e24f5f31STony 689e24f5f31STony This section, and its nested sections, replaces DWARF Version 5 section 2.5 690e24f5f31STony and section 2.6. The new DWARF expression operation extensions are defined as 691e24f5f31STony well as clarifying the extensions to already existing DWARF Version 5 692e24f5f31STony operations. It is based on the text of the existing DWARF Version 5 standard. 693e24f5f31STony 694e24f5f31STonyDWARF expressions describe how to compute a value or specify a location. 695e24f5f31STony 696e24f5f31STony*The evaluation of a DWARF expression can provide the location of an object, the 697e24f5f31STonyvalue of an array bound, the length of a dynamic string, the desired value 698e24f5f31STonyitself, and so on.* 699e24f5f31STony 700e24f5f31STonyIf the evaluation of a DWARF expression does not encounter an error, then it can 701e24f5f31STonyeither result in a value (see :ref:`amdgpu-dwarf-expression-value`) or a 702e24f5f31STonylocation description (see :ref:`amdgpu-dwarf-location-description`). When a 703e24f5f31STonyDWARF expression is evaluated, it may be specified whether a value or location 704e24f5f31STonydescription is required as the result kind. 705e24f5f31STony 706e24f5f31STonyIf a result kind is specified, and the result of the evaluation does not match 707e24f5f31STonythe specified result kind, then the implicit conversions described in 708e24f5f31STony:ref:`amdgpu-dwarf-memory-location-description-operations` are performed if 709e24f5f31STonyvalid. Otherwise, the DWARF expression is ill-formed. 710e24f5f31STony 711e24f5f31STonyIf the evaluation of a DWARF expression encounters an evaluation error, then the 712e24f5f31STonyresult is an evaluation error. 713e24f5f31STony 714e24f5f31STony.. note:: 715e24f5f31STony 716e24f5f31STony Decided to define the concept of an evaluation error. An alternative is to 717e24f5f31STony introduce an undefined value base type in a similar way to location 718e24f5f31STony descriptions having an undefined location description. Then operations that 719e24f5f31STony encounter an evaluation error can return the undefined location description or 720e24f5f31STony value with an undefined base type. 721e24f5f31STony 722e24f5f31STony All operations that act on values would return an undefined entity if given an 723e24f5f31STony undefined value. The expression would then always evaluate to completion, and 724e24f5f31STony can be tested to determine if it is an undefined entity. 725e24f5f31STony 726e24f5f31STony However, this would add considerable additional complexity and does not match 727e24f5f31STony that GDB throws an exception when these evaluation errors occur. 728e24f5f31STony 729e24f5f31STonyIf a DWARF expression is ill-formed, then the result is undefined. 730e24f5f31STony 731e24f5f31STonyThe following sections detail the rules for when a DWARF expression is 732e24f5f31STonyill-formed or results in an evaluation error. 733e24f5f31STony 734e8fa9014SKazu HirataA DWARF expression can either be encoded as an operation expression (see 735e24f5f31STony:ref:`amdgpu-dwarf-operation-expressions`), or as a location list expression 736e24f5f31STony(see :ref:`amdgpu-dwarf-location-list-expressions`). 737e24f5f31STony 738e24f5f31STony.. _amdgpu-dwarf-expression-evaluation-context: 739e24f5f31STony 7400ac939f3STony TyeA.2.5.1 DWARF Expression Evaluation Context 7410ac939f3STony Tye+++++++++++++++++++++++++++++++++++++++++++ 742e24f5f31STony 743e24f5f31STonyA DWARF expression is evaluated in a context that can include a number of 744e24f5f31STonycontext elements. If multiple context elements are specified then they must be 745e24f5f31STonyself consistent or the result of the evaluation is undefined. The context 746e24f5f31STonyelements that can be specified are: 747e24f5f31STony 748e24f5f31STony*A current result kind* 749e24f5f31STony 750e24f5f31STony The kind of result required by the DWARF expression evaluation. If specified 751e24f5f31STony it can be a location description or a value. 752e24f5f31STony 753e24f5f31STony*A current thread* 754e24f5f31STony 7558ba5043dSTony Tye The target architecture thread identifier. For source languages that are not 7568ba5043dSTony Tye implemented using a SIMT execution model, this corresponds to the source 7578ba5043dSTony Tye program thread of execution for which a user presented expression is currently 7588ba5043dSTony Tye being evaluated. For source languages that are implemented using a SIMT 7598ba5043dSTony Tye execution model, this together with the current lane corresponds to the source 7608ba5043dSTony Tye program thread of execution for which a user presented expression is currently 7618ba5043dSTony Tye being evaluated. 762e24f5f31STony 763e24f5f31STony It is required for operations that are related to target architecture threads. 764e24f5f31STony 7650ac939f3STony Tye *For example, the* ``DW_OP_regval_type`` *operation, or the* 7660ac939f3STony Tye ``DW_OP_form_tls_address`` *and* ``DW_OP_LLVM_form_aspace_address`` 7678ba5043dSTony Tye *operations when given an address space that is target architecture thread 7688ba5043dSTony Tye specific.* 769e24f5f31STony 770e24f5f31STony*A current lane* 771e24f5f31STony 7728ba5043dSTony Tye The 0 based SIMT lane identifier to be used in evaluating a user presented 7738ba5043dSTony Tye expression. This applies to source languages that are implemented for a target 7748ba5043dSTony Tye architecture using a SIMT execution model. These implementations map source 7758ba5043dSTony Tye language threads of execution to lanes of the target architecture threads. 776e24f5f31STony 7778ba5043dSTony Tye It is required for operations that are related to SIMT lanes. 778e24f5f31STony 779e24f5f31STony *For example, the* ``DW_OP_LLVM_push_lane`` *operation and* 780e24f5f31STony ``DW_OP_LLVM_form_aspace_address`` *operation when given an address space that 7818ba5043dSTony Tye is SIMT lane specific.* 782e24f5f31STony 7838ba5043dSTony Tye If specified, it must be consistent with the value of the ``DW_AT_LLVM_lanes`` 7848ba5043dSTony Tye attribute of the subprogram corresponding to context's frame and program 7858ba5043dSTony Tye location. It is consistent if the value is greater than or equal to 0 and less 7868ba5043dSTony Tye than the, possibly default, value of the ``DW_AT_LLVM_lanes`` attribute. 7878ba5043dSTony Tye Otherwise the result is undefined. 7888ba5043dSTony Tye 7898ba5043dSTony Tye*A current iteration* 7908ba5043dSTony Tye 7918ba5043dSTony Tye The 0 based source language iteration instance to be used in evaluating a user 7928ba5043dSTony Tye presented expression. This applies to target architectures that support 7938ba5043dSTony Tye optimizations that result in executing multiple source language loop iterations 7948ba5043dSTony Tye concurrently. 7958ba5043dSTony Tye 7968ba5043dSTony Tye *For example, software pipelining and SIMD vectorization.* 7978ba5043dSTony Tye 7988ba5043dSTony Tye It is required for operations that are related to source language loop 7998ba5043dSTony Tye iterations. 8008ba5043dSTony Tye 8018ba5043dSTony Tye *For example, the* ``DW_OP_LLVM_push_iteration`` *operation.* 8028ba5043dSTony Tye 8038ba5043dSTony Tye If specified, it must be consistent with the value of the 8048ba5043dSTony Tye ``DW_AT_LLVM_iterations`` attribute of the subprogram corresponding to 8058ba5043dSTony Tye context's frame and program location. It is consistent if the value is greater 8068ba5043dSTony Tye than or equal to 0 and less than the, possibly default, value of the 8078ba5043dSTony Tye ``DW_AT_LLVM_iterations`` attribute. Otherwise the result is undefined. 808e24f5f31STony 809e24f5f31STony*A current call frame* 810e24f5f31STony 811e24f5f31STony The target architecture call frame identifier. It identifies a call frame that 812e24f5f31STony corresponds to an active invocation of a subprogram in the current thread. It 813e24f5f31STony is identified by its address on the call stack. The address is referred to as 814e24f5f31STony the Canonical Frame Address (CFA). The call frame information is used to 815e24f5f31STony determine the CFA for the call frames of the current thread's call stack (see 816e24f5f31STony :ref:`amdgpu-dwarf-call-frame-information`). 817e24f5f31STony 818e24f5f31STony It is required for operations that specify target architecture registers to 819e24f5f31STony support virtual unwinding of the call stack. 820e24f5f31STony 821e24f5f31STony *For example, the* ``DW_OP_*reg*`` *operations.* 822e24f5f31STony 823e24f5f31STony If specified, it must be an active call frame in the current thread. If the 824e24f5f31STony current lane is specified, then that lane must have been active on entry to 825e24f5f31STony the call frame (see the ``DW_AT_LLVM_lane_pc`` attribute). Otherwise the 826e24f5f31STony result is undefined. 827e24f5f31STony 828e24f5f31STony If it is the currently executing call frame, then it is termed the top call 829e24f5f31STony frame. 830e24f5f31STony 831e24f5f31STony*A current program location* 832e24f5f31STony 833e24f5f31STony The target architecture program location corresponding to the current call 834e24f5f31STony frame of the current thread. 835e24f5f31STony 836e24f5f31STony The program location of the top call frame is the target architecture program 837e24f5f31STony counter for the current thread. The call frame information is used to obtain 838e24f5f31STony the value of the return address register to determine the program location of 839e24f5f31STony the other call frames (see :ref:`amdgpu-dwarf-call-frame-information`). 840e24f5f31STony 841e24f5f31STony It is required for the evaluation of location list expressions to select 842e24f5f31STony amongst multiple program location ranges. It is required for operations that 843e24f5f31STony specify target architecture registers to support virtual unwinding of the call 844e24f5f31STony stack (see :ref:`amdgpu-dwarf-call-frame-information`). 845e24f5f31STony 846e24f5f31STony If specified: 847e24f5f31STony 848e24f5f31STony * If the current lane is not specified: 849e24f5f31STony 850e24f5f31STony * If the current call frame is the top call frame, it must be the current 851e24f5f31STony target architecture program location. 852e24f5f31STony 853e24f5f31STony * If the current call frame F is not the top call frame, it must be the 854e24f5f31STony program location associated with the call site in the current caller frame 855e24f5f31STony F that invoked the callee frame. 856e24f5f31STony 857e24f5f31STony * If the current lane is specified and the architecture program location LPC 858e24f5f31STony computed by the ``DW_AT_LLVM_lane_pc`` attribute for the current lane is not 859e24f5f31STony the undefined location description (indicating the lane was not active on 860e24f5f31STony entry to the call frame), it must be LPC. 861e24f5f31STony 862e24f5f31STony * Otherwise the result is undefined. 863e24f5f31STony 864e24f5f31STony*A current compilation unit* 865e24f5f31STony 866e24f5f31STony The compilation unit debug information entry that contains the DWARF expression 867e24f5f31STony being evaluated. 868e24f5f31STony 869e24f5f31STony It is required for operations that reference debug information associated with 870e24f5f31STony the same compilation unit, including indicating if such references use the 871e24f5f31STony 32-bit or 64-bit DWARF format. It can also provide the default address space 872e24f5f31STony address size if no current target architecture is specified. 873e24f5f31STony 874e24f5f31STony *For example, the* ``DW_OP_constx`` *and* ``DW_OP_addrx`` *operations.* 875e24f5f31STony 876e24f5f31STony *Note that this compilation unit may not be the same as the compilation unit 877e24f5f31STony determined from the loaded code object corresponding to the current program 8780ac939f3STony Tye location. For example, the evaluation of the expression E associated with a* 8790ac939f3STony Tye ``DW_AT_location`` *attribute of the debug information entry operand of the* 8800ac939f3STony Tye ``DW_OP_call*`` *operations is evaluated with the compilation unit that 8810ac939f3STony Tye contains E and not the one that contains the* ``DW_OP_call*`` *operation 882e24f5f31STony expression.* 883e24f5f31STony 884e24f5f31STony*A current target architecture* 885e24f5f31STony 886e24f5f31STony The target architecture. 887e24f5f31STony 888e24f5f31STony It is required for operations that specify target architecture specific 889e24f5f31STony entities. 890e24f5f31STony 891e24f5f31STony *For example, target architecture specific entities include DWARF register 892e24f5f31STony identifiers, DWARF lane identifiers, DWARF address space identifiers, the 893e24f5f31STony default address space, and the address space address sizes.* 894e24f5f31STony 895e24f5f31STony If specified: 896e24f5f31STony 897e24f5f31STony * If the current thread is specified, then the current target architecture 898e24f5f31STony must be the same as the target architecture of the current thread. 899e24f5f31STony 900e24f5f31STony * If the current compilation unit is specified, then the current target 9010ac939f3STony Tye architecture default address space address size must be the same as the 902e24f5f31STony ``address_size`` field in the header of the current compilation unit and any 903e24f5f31STony associated entry in the ``.debug_aranges`` section. 904e24f5f31STony 905e24f5f31STony * If the current program location is specified, then the current target 906e24f5f31STony architecture must be the same as the target architecture of any line number 907e24f5f31STony information entry (see :ref:`amdgpu-dwarf-line-number-information`) 908e24f5f31STony corresponding to the current program location. 909e24f5f31STony 910e24f5f31STony * If the current program location is specified, then the current target 9110ac939f3STony Tye architecture default address space address size must be the same as the 912e24f5f31STony ``address_size`` field in the header of any entry corresponding to the 913e24f5f31STony current program location in the ``.debug_addr``, ``.debug_line``, 914e24f5f31STony ``.debug_rnglists``, ``.debug_rnglists.dwo``, ``.debug_loclists``, and 915e24f5f31STony ``.debug_loclists.dwo`` sections. 916e24f5f31STony 917e24f5f31STony * Otherwise the result is undefined. 918e24f5f31STony 919e24f5f31STony*A current object* 920e24f5f31STony 921e24f5f31STony The location description of a program object. 922e24f5f31STony 923e24f5f31STony It is required for the ``DW_OP_push_object_address`` operation. 924e24f5f31STony 925e24f5f31STony *For example, the* ``DW_AT_data_location`` *attribute on type debug 9260ac939f3STony Tye information entries specifies the program object corresponding to a runtime 9270ac939f3STony Tye descriptor as the current object when it evaluates its associated expression.* 928e24f5f31STony 929e24f5f31STony The result is undefined if the location descriptor is invalid (see 930e24f5f31STony :ref:`amdgpu-dwarf-location-description`). 931e24f5f31STony 932e24f5f31STony*An initial stack* 933e24f5f31STony 934e24f5f31STony This is a list of values or location descriptions that will be pushed on the 935e24f5f31STony operation expression evaluation stack in the order provided before evaluation 936e24f5f31STony of an operation expression starts. 937e24f5f31STony 938e24f5f31STony Some debugger information entries have attributes that evaluate their DWARF 939e24f5f31STony expression value with initial stack entries. In all other cases the initial 940e24f5f31STony stack is empty. 941e24f5f31STony 942e24f5f31STony The result is undefined if any location descriptors are invalid (see 943e24f5f31STony :ref:`amdgpu-dwarf-location-description`). 944e24f5f31STony 945e24f5f31STonyIf the evaluation requires a context element that is not specified, then the 946e24f5f31STonyresult of the evaluation is an error. 947e24f5f31STony 9480ac939f3STony Tye*A DWARF expression for a location description may be able to be evaluated 949e24f5f31STonywithout a thread, lane, call frame, program location, or architecture context. 950e24f5f31STonyFor example, the location of a global variable may be able to be evaluated 951e24f5f31STonywithout such context. If the expression evaluates with an error then it may 952e24f5f31STonyindicate the variable has been optimized and so requires more context.* 953e24f5f31STony 954e24f5f31STony*The DWARF expression for call frame information (see 955e24f5f31STony:ref:`amdgpu-dwarf-call-frame-information`) operations are restricted to those 956e24f5f31STonythat do not require the compilation unit context to be specified.* 957e24f5f31STony 958e24f5f31STonyThe DWARF is ill-formed if all the ``address_size`` fields in the headers of all 959e24f5f31STonythe entries in the ``.debug_info``, ``.debug_addr``, ``.debug_line``, 960e24f5f31STony``.debug_rnglists``, ``.debug_rnglists.dwo``, ``.debug_loclists``, and 961e24f5f31STony``.debug_loclists.dwo`` sections corresponding to any given program location do 962e24f5f31STonynot match. 963e24f5f31STony 964e24f5f31STony.. _amdgpu-dwarf-expression-value: 965e24f5f31STony 9660ac939f3STony TyeA.2.5.2 DWARF Expression Value 9670ac939f3STony Tye++++++++++++++++++++++++++++++ 968e24f5f31STony 969e24f5f31STonyA value has a type and a literal value. It can represent a literal value of any 970f79bab3fSTonysupported base type of the target architecture. The base type specifies the 971f79bab3fSTonysize, encoding, and endianity of the literal value. 972e24f5f31STony 973e24f5f31STony.. note:: 974e24f5f31STony 975e24f5f31STony It may be desirable to add an implicit pointer base type encoding. It would be 976e24f5f31STony used for the type of the value that is produced when the ``DW_OP_deref*`` 977e24f5f31STony operation retrieves the full contents of an implicit pointer location storage 978e24f5f31STony created by the ``DW_OP_implicit_pointer`` or 979e24f5f31STony ``DW_OP_LLVM_aspace_implicit_pointer`` operations. The literal value would 980e24f5f31STony record the debugging information entry and byte displacement specified by the 981e24f5f31STony associated ``DW_OP_implicit_pointer`` or 982e24f5f31STony ``DW_OP_LLVM_aspace_implicit_pointer`` operations. 983e24f5f31STony 984e24f5f31STonyThere is a distinguished base type termed the generic type, which is an integral 985e24f5f31STonytype that has the size of an address in the target architecture default address 986ca602a72STonyspace, a target architecture defined endianity, and unspecified signedness. 987e24f5f31STony 988e24f5f31STony*The generic type is the same as the unspecified type used for stack operations 989e24f5f31STonydefined in DWARF Version 4 and before.* 990e24f5f31STony 991e24f5f31STonyAn integral type is a base type that has an encoding of ``DW_ATE_signed``, 992e24f5f31STony``DW_ATE_signed_char``, ``DW_ATE_unsigned``, ``DW_ATE_unsigned_char``, 993e24f5f31STony``DW_ATE_boolean``, or any target architecture defined integral encoding in the 994e24f5f31STonyinclusive range ``DW_ATE_lo_user`` to ``DW_ATE_hi_user``. 995e24f5f31STony 996e24f5f31STony.. note:: 997e24f5f31STony 998e24f5f31STony It is unclear if ``DW_ATE_address`` is an integral type. GDB does not seem to 999e24f5f31STony consider it as integral. 1000e24f5f31STony 1001e24f5f31STony.. _amdgpu-dwarf-location-description: 1002e24f5f31STony 10030ac939f3STony TyeA.2.5.3 DWARF Location Description 10040ac939f3STony Tye++++++++++++++++++++++++++++++++++ 1005e24f5f31STony 1006e24f5f31STony*Debugging information must provide consumers a way to find the location of 1007e24f5f31STonyprogram variables, determine the bounds of dynamic arrays and strings, and 1008e24f5f31STonypossibly to find the base address of a subprogram’s call frame or the return 1009e24f5f31STonyaddress of a subprogram. Furthermore, to meet the needs of recent computer 1010e24f5f31STonyarchitectures and optimization techniques, debugging information must be able to 1011e24f5f31STonydescribe the location of an object whose location changes over the object’s 1012e24f5f31STonylifetime, and may reside at multiple locations simultaneously during parts of an 1013e24f5f31STonyobject's lifetime.* 1014e24f5f31STony 1015e24f5f31STonyInformation about the location of program objects is provided by location 1016e24f5f31STonydescriptions. 1017e24f5f31STony 1018e24f5f31STonyLocation descriptions can consist of one or more single location descriptions. 1019e24f5f31STony 1020e24f5f31STonyA single location description specifies the location storage that holds a 1021e24f5f31STonyprogram object and a position within the location storage where the program 1022e24f5f31STonyobject starts. The position within the location storage is expressed as a bit 1023e24f5f31STonyoffset relative to the start of the location storage. 1024e24f5f31STony 1025e24f5f31STonyA location storage is a linear stream of bits that can hold values. Each 1026e24f5f31STonylocation storage has a size in bits and can be accessed using a zero-based bit 1027e24f5f31STonyoffset. The ordering of bits within a location storage uses the bit numbering 1028e24f5f31STonyand direction conventions that are appropriate to the current language on the 1029e24f5f31STonytarget architecture. 1030e24f5f31STony 1031e24f5f31STonyThere are five kinds of location storage: 1032e24f5f31STony 1033e24f5f31STony*memory location storage* 1034e24f5f31STony Corresponds to the target architecture memory address spaces. 1035e24f5f31STony 1036e24f5f31STony*register location storage* 1037e24f5f31STony Corresponds to the target architecture registers. 1038e24f5f31STony 1039e24f5f31STony*implicit location storage* 1040e24f5f31STony Corresponds to fixed values that can only be read. 1041e24f5f31STony 1042e24f5f31STony*undefined location storage* 1043e24f5f31STony Indicates no value is available and therefore cannot be read or written. 1044e24f5f31STony 1045e24f5f31STony*composite location storage* 1046e24f5f31STony Allows a mixture of these where some bits come from one location storage and 1047e24f5f31STony some from another location storage, or from disjoint parts of the same 1048e24f5f31STony location storage. 1049e24f5f31STony 1050e24f5f31STony.. note:: 1051e24f5f31STony 1052e24f5f31STony It may be better to add an implicit pointer location storage kind used by the 1053e24f5f31STony ``DW_OP_implicit_pointer`` and ``DW_OP_LLVM_aspace_implicit_pointer`` 1054e24f5f31STony operations. It would specify the debugger information entry and byte offset 1055e24f5f31STony provided by the operations. 1056e24f5f31STony 1057e24f5f31STony*Location descriptions are a language independent representation of addressing 10580ac939f3STony Tyerules.* 10590ac939f3STony Tye 10600ac939f3STony Tye* *They can be the result of evaluating a debugger information entry attribute 10610ac939f3STony Tye that specifies an operation expression of arbitrary complexity. In this usage 10620ac939f3STony Tye they can describe the location of an object as long as its lifetime is either 10630ac939f3STony Tye static or the same as the lexical block (see 10640ac939f3STony Tye :ref:`amdgpu-dwarf-lexical-block-entries`) that owns it, and it does not move 10650ac939f3STony Tye during its lifetime.* 10660ac939f3STony Tye 10670ac939f3STony Tye* *They can be the result of evaluating a debugger information entry attribute 10680ac939f3STony Tye that specifies a location list expression. In this usage they can describe the 10690ac939f3STony Tye location of an object that has a limited lifetime, changes its location during 10700ac939f3STony Tye its lifetime, or has multiple locations over part or all of its lifetime.* 1071e24f5f31STony 1072e24f5f31STonyIf a location description has more than one single location description, the 1073e24f5f31STonyDWARF expression is ill-formed if the object value held in each single location 1074e24f5f31STonydescription's position within the associated location storage is not the same 1075e24f5f31STonyvalue, except for the parts of the value that are uninitialized. 1076e24f5f31STony 1077e24f5f31STony*A location description that has more than one single location description can 1078e24f5f31STonyonly be created by a location list expression that has overlapping program 1079e24f5f31STonylocation ranges, or certain expression operations that act on a location 1080e24f5f31STonydescription that has more than one single location description. There are no 1081e24f5f31STonyoperation expression operations that can directly create a location description 1082e24f5f31STonywith more than one single location description.* 1083e24f5f31STony 1084e24f5f31STony*A location description with more than one single location description can be 1085e24f5f31STonyused to describe objects that reside in more than one piece of storage at the 1086e24f5f31STonysame time. An object may have more than one location as a result of 1087e24f5f31STonyoptimization. For example, a value that is only read may be promoted from memory 1088e24f5f31STonyto a register for some region of code, but later code may revert to reading the 1089e24f5f31STonyvalue from memory as the register may be used for other purposes. For the code 1090e24f5f31STonyregion where the value is in a register, any change to the object value must be 1091e24f5f31STonymade in both the register and the memory so both regions of code will read the 1092e24f5f31STonyupdated value.* 1093e24f5f31STony 1094e24f5f31STony*A consumer of a location description with more than one single location 1095e24f5f31STonydescription can read the object's value from any of the single location 1096e24f5f31STonydescriptions (since they all refer to location storage that has the same value), 1097e24f5f31STonybut must write any changed value to all the single location descriptions.* 1098e24f5f31STony 1099e24f5f31STonyThe evaluation of an expression may require context elements to create a 1100e24f5f31STonylocation description. If such a location description is accessed, the storage it 1101e24f5f31STonydenotes is that associated with the context element values specified when the 1102e24f5f31STonylocation description was created, which may differ from the context at the time 1103e24f5f31STonyit is accessed. 1104e24f5f31STony 1105e24f5f31STony*For example, creating a register location description requires the thread 1106e24f5f31STonycontext: the location storage is for the specified register of that thread. 1107e24f5f31STonyCreating a memory location description for an address space may required a 1108e24f5f31STonythread and a lane context: the location storage is the memory associated with 1109e24f5f31STonythat thread and lane.* 1110e24f5f31STony 1111e24f5f31STonyIf any of the context elements required to create a location description change, 1112e24f5f31STonythe location description becomes invalid and accessing it is undefined. 1113e24f5f31STony 1114e24f5f31STony*Examples of context that can invalidate a location description are:* 1115e24f5f31STony 1116e24f5f31STony* *The thread context is required and execution causes the thread to terminate.* 1117e24f5f31STony* *The call frame context is required and further execution causes the call 1118e24f5f31STony frame to return to the calling frame.* 1119e24f5f31STony* *The program location is required and further execution of the thread occurs. 1120e24f5f31STony That could change the location list entry or call frame information entry that 1121e24f5f31STony applies.* 1122e24f5f31STony* *An operation uses call frame information:* 1123e24f5f31STony 1124e24f5f31STony * *Any of the frames used in the virtual call frame unwinding return.* 1125e24f5f31STony * *The top call frame is used, the program location is used to select the call 1126e24f5f31STony frame information entry, and further execution of the thread occurs.* 1127e24f5f31STony 1128e24f5f31STony*A DWARF expression can be used to compute a location description for an object. 1129e24f5f31STonyA subsequent DWARF expression evaluation can be given the object location 1130e24f5f31STonydescription as the object context or initial stack context to compute a 1131e24f5f31STonycomponent of the object. The final result is undefined if the object location 1132e24f5f31STonydescription becomes invalid between the two expression evaluations.* 1133e24f5f31STony 1134e24f5f31STonyA change of a thread's program location may not make a location description 1135e24f5f31STonyinvalid, yet may still render it as no longer meaningful. Accessing such a 1136e24f5f31STonylocation description, or using it as the object context or initial stack context 1137e24f5f31STonyof an expression evaluation, may produce an undefined result. 1138e24f5f31STony 1139e24f5f31STony*For example, a location description may specify a register that no longer holds 1140e24f5f31STonythe intended program object after a program location change. One way to avoid 1141e24f5f31STonysuch problems is to recompute location descriptions associated with threads when 1142e24f5f31STonytheir program locations change.* 1143e24f5f31STony 1144e24f5f31STony.. _amdgpu-dwarf-operation-expressions: 1145e24f5f31STony 11460ac939f3STony TyeA.2.5.4 DWARF Operation Expressions 11470ac939f3STony Tye+++++++++++++++++++++++++++++++++++ 1148e24f5f31STony 1149e24f5f31STonyAn operation expression is comprised of a stream of operations, each consisting 1150e24f5f31STonyof an opcode followed by zero or more operands. The number of operands is 1151e24f5f31STonyimplied by the opcode. 1152e24f5f31STony 1153e24f5f31STonyOperations represent a postfix operation on a simple stack machine. Each stack 1154e24f5f31STonyentry can hold either a value or a location description. Operations can act on 1155e24f5f31STonyentries on the stack, including adding entries and removing entries. If the kind 1156e24f5f31STonyof a stack entry does not match the kind required by the operation and is not 1157e24f5f31STonyimplicitly convertible to the required kind (see 1158e24f5f31STony:ref:`amdgpu-dwarf-memory-location-description-operations`), then the DWARF 1159e24f5f31STonyoperation expression is ill-formed. 1160e24f5f31STony 1161e24f5f31STonyEvaluation of an operation expression starts with an empty stack on which the 1162e24f5f31STonyentries from the initial stack provided by the context are pushed in the order 1163e24f5f31STonyprovided. Then the operations are evaluated, starting with the first operation 1164e24f5f31STonyof the stream. Evaluation continues until either an operation has an evaluation 1165e24f5f31STonyerror, or until one past the last operation of the stream is reached. 1166e24f5f31STony 1167e24f5f31STonyThe result of the evaluation is: 1168e24f5f31STony 1169e24f5f31STony* If an operation has an evaluation error, or an operation evaluates an 1170e24f5f31STony expression that has an evaluation error, then the result is an evaluation 1171e24f5f31STony error. 1172e24f5f31STony 1173e24f5f31STony* If the current result kind specifies a location description, then: 1174e24f5f31STony 1175e24f5f31STony * If the stack is empty, the result is a location description with one 1176e24f5f31STony undefined location description. 1177e24f5f31STony 1178e24f5f31STony *This rule is for backwards compatibility with DWARF Version 5 which has no 1179e24f5f31STony explicit operation to create an undefined location description, and uses an 1180e24f5f31STony empty operation expression for this purpose.* 1181e24f5f31STony 1182e24f5f31STony * If the top stack entry is a location description, or can be converted 1183e24f5f31STony to one (see :ref:`amdgpu-dwarf-memory-location-description-operations`), 1184e24f5f31STony then the result is that, possibly converted, location description. Any other 1185e24f5f31STony entries on the stack are discarded. 1186e24f5f31STony 1187e24f5f31STony * Otherwise the DWARF expression is ill-formed. 1188e24f5f31STony 1189e24f5f31STony .. note:: 1190e24f5f31STony 1191e24f5f31STony Could define this case as returning an implicit location description as 1192e24f5f31STony if the ``DW_OP_implicit`` operation is performed. 1193e24f5f31STony 1194e24f5f31STony* If the current result kind specifies a value, then: 1195e24f5f31STony 1196e24f5f31STony * If the top stack entry is a value, or can be converted to one (see 1197e24f5f31STony :ref:`amdgpu-dwarf-memory-location-description-operations`), then the result 1198e24f5f31STony is that, possibly converted, value. Any other entries on the stack are 1199e24f5f31STony discarded. 1200e24f5f31STony 1201e24f5f31STony * Otherwise the DWARF expression is ill-formed. 1202e24f5f31STony 1203e24f5f31STony* If the current result kind is not specified, then: 1204e24f5f31STony 1205e24f5f31STony * If the stack is empty, the result is a location description with one 1206e24f5f31STony undefined location description. 1207e24f5f31STony 1208e24f5f31STony *This rule is for backwards compatibility with DWARF Version 5 which has no 1209e24f5f31STony explicit operation to create an undefined location description, and uses an 1210e24f5f31STony empty operation expression for this purpose.* 1211e24f5f31STony 1212e24f5f31STony .. note:: 1213e24f5f31STony 1214e24f5f31STony This rule is consistent with the rule above for when a location 1215e24f5f31STony description is requested. However, GDB appears to report this as an error 1216e24f5f31STony and no GDB tests appear to cause an empty stack for this case. 1217e24f5f31STony 1218e24f5f31STony * Otherwise, the top stack entry is returned. Any other entries on the stack 1219e24f5f31STony are discarded. 1220e24f5f31STony 1221e24f5f31STonyAn operation expression is encoded as a byte block with some form of prefix that 1222e24f5f31STonyspecifies the byte count. It can be used: 1223e24f5f31STony 1224e24f5f31STony* as the value of a debugging information entry attribute that is encoded using 12250ac939f3STony Tye class ``exprloc`` (see :ref:`amdgpu-dwarf-classes-and-forms`), 1226e24f5f31STony 1227e24f5f31STony* as the operand to certain operation expression operations, 1228e24f5f31STony 1229e24f5f31STony* as the operand to certain call frame information operations (see 1230e24f5f31STony :ref:`amdgpu-dwarf-call-frame-information`), 1231e24f5f31STony 1232e24f5f31STony* and in location list entries (see 1233e24f5f31STony :ref:`amdgpu-dwarf-location-list-expressions`). 1234e24f5f31STony 1235e24f5f31STony.. _amdgpu-dwarf-stack-operations: 1236e24f5f31STony 12370ac939f3STony TyeA.2.5.4.1 Stack Operations 12380ac939f3STony Tye########################## 12390ac939f3STony Tye 12400ac939f3STony Tye.. note:: 12410ac939f3STony Tye 12420ac939f3STony Tye This section replaces DWARF Version 5 section 2.5.1.3. 1243e24f5f31STony 1244e24f5f31STonyThe following operations manipulate the DWARF stack. Operations that index the 1245e24f5f31STonystack assume that the top of the stack (most recently added entry) has index 0. 1246e24f5f31STonyThey allow the stack entries to be either a value or location description. 1247e24f5f31STony 1248e24f5f31STonyIf any stack entry accessed by a stack operation is an incomplete composite 1249e24f5f31STonylocation description (see 1250e24f5f31STony:ref:`amdgpu-dwarf-composite-location-description-operations`), then the DWARF 1251e24f5f31STonyexpression is ill-formed. 1252e24f5f31STony 1253e24f5f31STony.. note:: 1254e24f5f31STony 1255e24f5f31STony These operations now support stack entries that are values and location 1256e24f5f31STony descriptions. 1257e24f5f31STony 1258e24f5f31STony.. note:: 1259e24f5f31STony 1260e24f5f31STony If it is desired to also make them work with incomplete composite location 1261e24f5f31STony descriptions, then would need to define that the composite location storage 1262e24f5f31STony specified by the incomplete composite location description is also replicated 1263e24f5f31STony when a copy is pushed. This ensures that each copy of the incomplete composite 1264e24f5f31STony location description can update the composite location storage they specify 1265e24f5f31STony independently. 1266e24f5f31STony 1267e24f5f31STony1. ``DW_OP_dup`` 1268e24f5f31STony 1269e24f5f31STony ``DW_OP_dup`` duplicates the stack entry at the top of the stack. 1270e24f5f31STony 1271e24f5f31STony2. ``DW_OP_drop`` 1272e24f5f31STony 1273e24f5f31STony ``DW_OP_drop`` pops the stack entry at the top of the stack and discards it. 1274e24f5f31STony 1275e24f5f31STony3. ``DW_OP_pick`` 1276e24f5f31STony 1277e24f5f31STony ``DW_OP_pick`` has a single unsigned 1-byte operand that represents an index 1278e24f5f31STony I. A copy of the stack entry with index I is pushed onto the stack. 1279e24f5f31STony 1280e24f5f31STony4. ``DW_OP_over`` 1281e24f5f31STony 1282e24f5f31STony ``DW_OP_over`` pushes a copy of the entry with index 1. 1283e24f5f31STony 12840ac939f3STony Tye *This is equivalent to a* ``DW_OP_pick 1`` *operation.* 1285e24f5f31STony 1286e24f5f31STony5. ``DW_OP_swap`` 1287e24f5f31STony 1288e24f5f31STony ``DW_OP_swap`` swaps the top two stack entries. The entry at the top of the 1289e24f5f31STony stack becomes the second stack entry, and the second stack entry becomes the 1290e24f5f31STony top of the stack. 1291e24f5f31STony 1292e24f5f31STony6. ``DW_OP_rot`` 1293e24f5f31STony 1294e24f5f31STony ``DW_OP_rot`` rotates the first three stack entries. The entry at the top of 1295e24f5f31STony the stack becomes the third stack entry, the second entry becomes the top of 1296e24f5f31STony the stack, and the third entry becomes the second entry. 1297e24f5f31STony 1298e24f5f31STony.. _amdgpu-dwarf-control-flow-operations: 1299e24f5f31STony 13000ac939f3STony TyeA.2.5.4.2 Control Flow Operations 13010ac939f3STony Tye################################# 13020ac939f3STony Tye 13030ac939f3STony Tye.. note:: 13040ac939f3STony Tye 13050ac939f3STony Tye This section replaces DWARF Version 5 section 2.5.1.5. 1306e24f5f31STony 1307e24f5f31STonyThe following operations provide simple control of the flow of a DWARF operation 1308e24f5f31STonyexpression. 1309e24f5f31STony 1310e24f5f31STony1. ``DW_OP_nop`` 1311e24f5f31STony 1312e24f5f31STony ``DW_OP_nop`` is a place holder. It has no effect on the DWARF stack 1313e24f5f31STony entries. 1314e24f5f31STony 1315e24f5f31STony2. ``DW_OP_le``, ``DW_OP_ge``, ``DW_OP_eq``, ``DW_OP_lt``, ``DW_OP_gt``, 1316e24f5f31STony ``DW_OP_ne`` 1317e24f5f31STony 1318e24f5f31STony .. note:: 1319e24f5f31STony 1320e24f5f31STony The same as in DWARF Version 5 section 2.5.1.5. 1321e24f5f31STony 1322e24f5f31STony3. ``DW_OP_skip`` 1323e24f5f31STony 1324e24f5f31STony ``DW_OP_skip`` is an unconditional branch. Its single operand is a 2-byte 1325e24f5f31STony signed integer constant. The 2-byte constant is the number of bytes of the 1326e24f5f31STony DWARF expression to skip forward or backward from the current operation, 1327e24f5f31STony beginning after the 2-byte constant. 1328e24f5f31STony 1329e24f5f31STony If the updated position is at one past the end of the last operation, then 1330e24f5f31STony the operation expression evaluation is complete. 1331e24f5f31STony 1332e24f5f31STony Otherwise, the DWARF expression is ill-formed if the updated operation 1333e24f5f31STony position is not in the range of the first to last operation inclusive, or 1334e24f5f31STony not at the start of an operation. 1335e24f5f31STony 1336e24f5f31STony4. ``DW_OP_bra`` 1337e24f5f31STony 1338e24f5f31STony ``DW_OP_bra`` is a conditional branch. Its single operand is a 2-byte signed 1339e24f5f31STony integer constant. This operation pops the top of stack. If the value popped 1340e24f5f31STony is not the constant 0, the 2-byte constant operand is the number of bytes of 1341e24f5f31STony the DWARF operation expression to skip forward or backward from the current 1342e24f5f31STony operation, beginning after the 2-byte constant. 1343e24f5f31STony 1344e24f5f31STony If the updated position is at one past the end of the last operation, then 1345e24f5f31STony the operation expression evaluation is complete. 1346e24f5f31STony 1347e24f5f31STony Otherwise, the DWARF expression is ill-formed if the updated operation 1348e24f5f31STony position is not in the range of the first to last operation inclusive, or 1349e24f5f31STony not at the start of an operation. 1350e24f5f31STony 1351e24f5f31STony5. ``DW_OP_call2, DW_OP_call4, DW_OP_call_ref`` 1352e24f5f31STony 1353e24f5f31STony ``DW_OP_call2``, ``DW_OP_call4``, and ``DW_OP_call_ref`` perform DWARF 1354e24f5f31STony procedure calls during evaluation of a DWARF expression. 1355e24f5f31STony 1356e24f5f31STony ``DW_OP_call2`` and ``DW_OP_call4``, have one operand that is, respectively, 1357e24f5f31STony a 2-byte or 4-byte unsigned offset DR that represents the byte offset of a 1358e24f5f31STony debugging information entry D relative to the beginning of the current 1359e24f5f31STony compilation unit. 1360e24f5f31STony 1361e24f5f31STony ``DW_OP_call_ref`` has one operand that is a 4-byte unsigned value in the 1362e24f5f31STony 32-bit DWARF format, or an 8-byte unsigned value in the 64-bit DWARF format, 1363e24f5f31STony that represents the byte offset DR of a debugging information entry D 1364e24f5f31STony relative to the beginning of the ``.debug_info`` section that contains the 1365e24f5f31STony current compilation unit. D may not be in the current compilation unit. 1366e24f5f31STony 13670ac939f3STony Tye .. note:: 1368e24f5f31STony 1369e24f5f31STony DWARF Version 5 states that DR can be an offset in a ``.debug_info`` 1370e24f5f31STony section other than the one that contains the current compilation unit. It 1371e24f5f31STony states that relocation of references from one executable or shared object 1372e24f5f31STony file to another must be performed by the consumer. But given that DR is 1373e24f5f31STony defined as an offset in a ``.debug_info`` section this seems impossible. 1374e24f5f31STony If DR was defined as an implementation defined value, then the consumer 1375e24f5f31STony could choose to interpret the value in an implementation defined manner to 1376e24f5f31STony reference a debug information in another executable or shared object. 1377e24f5f31STony 1378e24f5f31STony In ELF the ``.debug_info`` section is in a non-\ ``PT_LOAD`` segment so 1379e24f5f31STony standard dynamic relocations cannot be used. But even if they were loaded 1380e24f5f31STony segments and dynamic relocations were used, DR would need to be the 1381e24f5f31STony address of D, not an offset in a ``.debug_info`` section. That would also 1382e24f5f31STony need DR to be the size of a global address. So it would not be possible to 1383e24f5f31STony use the 32-bit DWARF format in a 64-bit global address space. In addition, 1384e24f5f31STony the consumer would need to determine what executable or shared object the 1385e24f5f31STony relocated address was in so it could determine the containing compilation 1386e24f5f31STony unit. 1387e24f5f31STony 1388e24f5f31STony GDB only interprets DR as an offset in the ``.debug_info`` section that 1389e24f5f31STony contains the current compilation unit. 1390e24f5f31STony 1391e24f5f31STony This comment also applies to ``DW_OP_implicit_pointer`` and 1392e24f5f31STony ``DW_OP_LLVM_aspace_implicit_pointer``. 1393e24f5f31STony 1394e24f5f31STony *Operand interpretation of* ``DW_OP_call2``\ *,* ``DW_OP_call4``\ *, and* 1395e24f5f31STony ``DW_OP_call_ref`` *is exactly like that for* ``DW_FORM_ref2``\ *, 1396e24f5f31STony ``DW_FORM_ref4``\ *, and* ``DW_FORM_ref_addr``\ *, respectively.* 1397e24f5f31STony 1398e24f5f31STony The call operation is evaluated by: 1399e24f5f31STony 1400e24f5f31STony * If D has a ``DW_AT_location`` attribute that is encoded as a ``exprloc`` 1401e24f5f31STony that specifies an operation expression E, then execution of the current 1402e24f5f31STony operation expression continues from the first operation of E. Execution 1403e24f5f31STony continues until one past the last operation of E is reached, at which 1404e24f5f31STony point execution continues with the operation following the call operation. 1405e24f5f31STony The operations of E are evaluated with the same current context, except 1406e24f5f31STony current compilation unit is the one that contains D and the stack is the 1407e24f5f31STony same as that being used by the call operation. After the call operation 1408e24f5f31STony has been evaluated, the stack is therefore as it is left by the evaluation 1409e24f5f31STony of the operations of E. Since E is evaluated on the same stack as the call 1410e24f5f31STony operation, E can use, and/or remove entries already on the stack, and can 1411e24f5f31STony add new entries to the stack. 1412e24f5f31STony 1413e24f5f31STony *Values on the stack at the time of the call may be used as parameters by 1414e24f5f31STony the called expression and values left on the stack by the called expression 1415e24f5f31STony may be used as return values by prior agreement between the calling and 1416e24f5f31STony called expressions.* 1417e24f5f31STony 1418e24f5f31STony * If D has a ``DW_AT_location`` attribute that is encoded as a ``loclist`` or 1419e24f5f31STony ``loclistsptr``, then the specified location list expression E is 1420e24f5f31STony evaluated. The evaluation of E uses the current context, except the result 1421e24f5f31STony kind is a location description, the compilation unit is the one that 1422e24f5f31STony contains D, and the initial stack is empty. The location description 1423e24f5f31STony result is pushed on the stack. 1424e24f5f31STony 1425e24f5f31STony .. note:: 1426e24f5f31STony 1427e24f5f31STony This rule avoids having to define how to execute a matched location list 1428e24f5f31STony entry operation expression on the same stack as the call when there are 1429e24f5f31STony multiple matches. But it allows the call to obtain the location 1430e24f5f31STony description for a variable or formal parameter which may use a location 1431e24f5f31STony list expression. 1432e24f5f31STony 1433e24f5f31STony An alternative is to treat the case when D has a ``DW_AT_location`` 1434e24f5f31STony attribute that is encoded as a ``loclist`` or ``loclistsptr``, and the 1435e24f5f31STony specified location list expression E' matches a single location list 1436e24f5f31STony entry with operation expression E, the same as the ``exprloc`` case and 1437e24f5f31STony evaluate on the same stack. 1438e24f5f31STony 1439e24f5f31STony But this is not attractive as if the attribute is for a variable that 1440e24f5f31STony happens to end with a non-singleton stack, it will not simply put a 1441e24f5f31STony location description on the stack. Presumably the intent of using 1442e24f5f31STony ``DW_OP_call*`` on a variable or formal parameter debugger information 1443e24f5f31STony entry is to push just one location description on the stack. That 1444e24f5f31STony location description may have more than one single location description. 1445e24f5f31STony 14460ac939f3STony Tye The previous rule for ``exprloc`` also has the same problem, as normally 1447e24f5f31STony a variable or formal parameter location expression may leave multiple 1448e24f5f31STony entries on the stack and only return the top entry. 1449e24f5f31STony 1450e24f5f31STony GDB implements ``DW_OP_call*`` by always executing E on the same stack. 1451e24f5f31STony If the location list has multiple matching entries, it simply picks the 1452e24f5f31STony first one and ignores the rest. This seems fundamentally at odds with 14530ac939f3STony Tye the desire to support multiple places for variables. 1454e24f5f31STony 1455e24f5f31STony So, it feels like ``DW_OP_call*`` should both support pushing a location 1456e24f5f31STony description on the stack for a variable or formal parameter, and also 1457e24f5f31STony support being able to execute an operation expression on the same stack. 1458e24f5f31STony Being able to specify a different operation expression for different 1459e24f5f31STony program locations seems a desirable feature to retain. 1460e24f5f31STony 1461e24f5f31STony A solution to that is to have a distinct ``DW_AT_LLVM_proc`` attribute 1462e24f5f31STony for the ``DW_TAG_dwarf_procedure`` debugging information entry. Then the 1463e24f5f31STony ``DW_AT_location`` attribute expression is always executed separately 1464e24f5f31STony and pushes a location description (that may have multiple single 1465e24f5f31STony location descriptions), and the ``DW_AT_LLVM_proc`` attribute expression 1466e24f5f31STony is always executed on the same stack and can leave anything on the 1467e24f5f31STony stack. 1468e24f5f31STony 1469e24f5f31STony The ``DW_AT_LLVM_proc`` attribute could have the new classes 1470e24f5f31STony ``exprproc``, ``loclistproc``, and ``loclistsptrproc`` to indicate that 1471e24f5f31STony the expression is executed on the same stack. ``exprproc`` is the same 1472e24f5f31STony encoding as ``exprloc``. ``loclistproc`` and ``loclistsptrproc`` are the 1473e24f5f31STony same encoding as their non-\ ``proc`` counterparts, except the DWARF is 1474e24f5f31STony ill-formed if the location list does not match exactly one location list 1475e24f5f31STony entry and a default entry is required. These forms indicate explicitly 1476e24f5f31STony that the matched single operation expression must be executed on the 1477e24f5f31STony same stack. This is better than ad hoc special rules for ``loclistproc`` 1478e24f5f31STony and ``loclistsptrproc`` which are currently clearly defined to always 1479e24f5f31STony return a location description. The producer then explicitly indicates 1480e24f5f31STony the intent through the attribute classes. 1481e24f5f31STony 1482e24f5f31STony Such a change would be a breaking change for how GDB implements 1483e24f5f31STony ``DW_OP_call*``. However, are the breaking cases actually occurring in 1484e24f5f31STony practice? GDB could implement the current approach for DWARF Version 5, 1485e24f5f31STony and the new semantics for DWARF Version 6 which has been done for some 1486e24f5f31STony other features. 1487e24f5f31STony 1488e24f5f31STony Another option is to limit the execution to be on the same stack only to 1489e24f5f31STony the evaluation of an expression E that is the value of a 1490e24f5f31STony ``DW_AT_location`` attribute of a ``DW_TAG_dwarf_procedure`` debugging 1491e24f5f31STony information entry. The DWARF would be ill-formed if E is a location list 1492e24f5f31STony expression that does not match exactly one location list entry. In all 1493e24f5f31STony other cases the evaluation of an expression E that is the value of a 1494e24f5f31STony ``DW_AT_location`` attribute would evaluate E with the current context, 1495e24f5f31STony except the result kind is a location description, the compilation unit 1496e24f5f31STony is the one that contains D, and the initial stack is empty. The location 1497e24f5f31STony description result is pushed on the stack. 1498e24f5f31STony 1499e24f5f31STony * If D has a ``DW_AT_const_value`` attribute with a value V, then it is as 1500e24f5f31STony if a ``DW_OP_implicit_value V`` operation was executed. 1501e24f5f31STony 1502e24f5f31STony *This allows a call operation to be used to compute the location 1503e24f5f31STony description for any variable or formal parameter regardless of whether the 15040ac939f3STony Tye producer has optimized it to a constant. This is consistent with the* 15050ac939f3STony Tye ``DW_OP_implicit_pointer`` *operation.* 1506e24f5f31STony 1507e24f5f31STony .. note:: 1508e24f5f31STony 1509e24f5f31STony Alternatively, could deprecate using ``DW_AT_const_value`` for 1510e24f5f31STony ``DW_TAG_variable`` and ``DW_TAG_formal_parameter`` debugger information 1511e24f5f31STony entries that are constants and instead use ``DW_AT_location`` with an 1512e24f5f31STony operation expression that results in a location description with one 1513e24f5f31STony implicit location description. Then this rule would not be required. 1514e24f5f31STony 1515e24f5f31STony * Otherwise, there is no effect and no changes are made to the stack. 1516e24f5f31STony 1517e24f5f31STony .. note:: 1518e24f5f31STony 1519e24f5f31STony In DWARF Version 5, if D does not have a ``DW_AT_location`` then 1520e24f5f31STony ``DW_OP_call*`` is defined to have no effect. It is unclear that this is 1521e24f5f31STony the right definition as a producer should be able to rely on using 1522e24f5f31STony ``DW_OP_call*`` to get a location description for any non-\ 1523e24f5f31STony ``DW_TAG_dwarf_procedure`` debugging information entries. Also, the 1524e24f5f31STony producer should not be creating DWARF with ``DW_OP_call*`` to a 1525e24f5f31STony ``DW_TAG_dwarf_procedure`` that does not have a ``DW_AT_location`` 1526e24f5f31STony attribute. So, should this case be defined as an ill-formed DWARF 1527e24f5f31STony expression? 1528e24f5f31STony 1529e24f5f31STony *The* ``DW_TAG_dwarf_procedure`` *debugging information entry can be used to 1530e24f5f31STony define DWARF procedures that can be called.* 1531e24f5f31STony 1532e24f5f31STony.. _amdgpu-dwarf-value-operations: 1533e24f5f31STony 15340ac939f3STony TyeA.2.5.4.3 Value Operations 15350ac939f3STony Tye########################## 1536e24f5f31STony 1537e24f5f31STonyThis section describes the operations that push values on the stack. 1538e24f5f31STony 15390ac939f3STony TyeEach value stack entry has a type and a literal value. It can represent a 1540e24f5f31STonyliteral value of any supported base type of the target architecture. The base 1541f79bab3fSTonytype specifies the size, encoding, and endianity of the literal value. 1542e24f5f31STony 1543f79bab3fSTonyThe base type of value stack entries can be the distinguished generic type. 1544e24f5f31STony 1545e24f5f31STony.. _amdgpu-dwarf-literal-operations: 1546e24f5f31STony 15470ac939f3STony TyeA.2.5.4.3.1 Literal Operations 15480ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15490ac939f3STony Tye 15500ac939f3STony Tye.. note:: 15510ac939f3STony Tye 15520ac939f3STony Tye This section replaces DWARF Version 5 section 2.5.1.1. 1553e24f5f31STony 1554e24f5f31STonyThe following operations all push a literal value onto the DWARF stack. 1555e24f5f31STony 1556e24f5f31STonyOperations other than ``DW_OP_const_type`` push a value V with the generic type. 1557e24f5f31STonyIf V is larger than the generic type, then V is truncated to the generic type 1558e24f5f31STonysize and the low-order bits used. 1559e24f5f31STony 1560e24f5f31STony1. ``DW_OP_lit0``, ``DW_OP_lit1``, ..., ``DW_OP_lit31`` 1561e24f5f31STony 1562e24f5f31STony ``DW_OP_lit<N>`` operations encode an unsigned literal value N from 0 1563e24f5f31STony through 31, inclusive. They push the value N with the generic type. 1564e24f5f31STony 1565e24f5f31STony2. ``DW_OP_const1u``, ``DW_OP_const2u``, ``DW_OP_const4u``, ``DW_OP_const8u`` 1566e24f5f31STony 1567e24f5f31STony ``DW_OP_const<N>u`` operations have a single operand that is a 1, 2, 4, or 1568e24f5f31STony 8-byte unsigned integer constant U, respectively. They push the value U with 1569e24f5f31STony the generic type. 1570e24f5f31STony 1571e24f5f31STony3. ``DW_OP_const1s``, ``DW_OP_const2s``, ``DW_OP_const4s``, ``DW_OP_const8s`` 1572e24f5f31STony 1573e24f5f31STony ``DW_OP_const<N>s`` operations have a single operand that is a 1, 2, 4, or 1574e24f5f31STony 8-byte signed integer constant S, respectively. They push the value S with 1575e24f5f31STony the generic type. 1576e24f5f31STony 1577e24f5f31STony4. ``DW_OP_constu`` 1578e24f5f31STony 1579e24f5f31STony ``DW_OP_constu`` has a single unsigned LEB128 integer operand N. It pushes 1580e24f5f31STony the value N with the generic type. 1581e24f5f31STony 1582e24f5f31STony5. ``DW_OP_consts`` 1583e24f5f31STony 1584e24f5f31STony ``DW_OP_consts`` has a single signed LEB128 integer operand N. It pushes the 1585e24f5f31STony value N with the generic type. 1586e24f5f31STony 1587e24f5f31STony6. ``DW_OP_constx`` 1588e24f5f31STony 1589e24f5f31STony ``DW_OP_constx`` has a single unsigned LEB128 integer operand that 1590e24f5f31STony represents a zero-based index into the ``.debug_addr`` section relative to 1591e24f5f31STony the value of the ``DW_AT_addr_base`` attribute of the associated compilation 1592e24f5f31STony unit. The value N in the ``.debug_addr`` section has the size of the generic 1593e24f5f31STony type. It pushes the value N with the generic type. 1594e24f5f31STony 1595e24f5f31STony *The* ``DW_OP_constx`` *operation is provided for constants that require 1596e24f5f31STony link-time relocation but should not be interpreted by the consumer as a 1597e24f5f31STony relocatable address (for example, offsets to thread-local storage).* 1598e24f5f31STony 15990ac939f3STony Tye7. ``DW_OP_const_type`` 1600e24f5f31STony 1601e24f5f31STony ``DW_OP_const_type`` has three operands. The first is an unsigned LEB128 1602e24f5f31STony integer DR that represents the byte offset of a debugging information entry 1603e24f5f31STony D relative to the beginning of the current compilation unit, that provides 1604e24f5f31STony the type T of the constant value. The second is a 1-byte unsigned integral 1605e24f5f31STony constant S. The third is a block of bytes B, with a length equal to S. 1606e24f5f31STony 1607e24f5f31STony TS is the bit size of the type T. The least significant TS bits of B are 1608e24f5f31STony interpreted as a value V of the type D. It pushes the value V with the type 1609e24f5f31STony D. 1610e24f5f31STony 1611e24f5f31STony The DWARF is ill-formed if D is not a ``DW_TAG_base_type`` debugging 1612e24f5f31STony information entry in the current compilation unit, or if TS divided by 8 1613e24f5f31STony (the byte size) and rounded up to a whole number is not equal to S. 1614e24f5f31STony 1615e24f5f31STony *While the size of the byte block B can be inferred from the type D 1616e24f5f31STony definition, it is encoded explicitly into the operation so that the 1617e24f5f31STony operation can be parsed easily without reference to the* ``.debug_info`` 1618e24f5f31STony *section.* 1619e24f5f31STony 16200ac939f3STony Tye8. ``DW_OP_LLVM_push_lane`` *New* 1621e24f5f31STony 16228ba5043dSTony Tye ``DW_OP_LLVM_push_lane`` pushes the current lane as a value with the generic 16238ba5043dSTony Tye type. 1624e24f5f31STony 16258ba5043dSTony Tye *For source languages that are implemented using a SIMT execution model, 16268ba5043dSTony Tye this is the zero-based lane number that corresponds to the source language 16278ba5043dSTony Tye thread of execution upon which the user is focused.* 16288ba5043dSTony Tye 16298ba5043dSTony Tye The value must be greater than or equal to 0 and less than the value of the 16308ba5043dSTony Tye ``DW_AT_LLVM_lanes`` attribute, otherwise the DWARF expression is 16318ba5043dSTony Tye ill-formed. See :ref:`amdgpu-dwarf-low-level-information`. 16328ba5043dSTony Tye 16338ba5043dSTony Tye9. ``DW_OP_LLVM_push_iteration`` *New* 16348ba5043dSTony Tye 16358ba5043dSTony Tye ``DW_OP_LLVM_push_iteration`` pushes the current iteration as a value with 16368ba5043dSTony Tye the generic type. 16378ba5043dSTony Tye 16388ba5043dSTony Tye *For source language implementations with optimizations that cause multiple 16398ba5043dSTony Tye loop iterations to execute concurrently, this is the zero-based iteration 16408ba5043dSTony Tye number that corresponds to the source language concurrent loop iteration 16418ba5043dSTony Tye upon which the user is focused.* 16428ba5043dSTony Tye 16438ba5043dSTony Tye The value must be greater than or equal to 0 and less than the value of the 16448ba5043dSTony Tye ``DW_AT_LLVM_iterations`` attribute, otherwise the DWARF expression is 16458ba5043dSTony Tye ill-formed. See :ref:`amdgpu-dwarf-low-level-information`. 1646e24f5f31STony 1647e24f5f31STony.. _amdgpu-dwarf-arithmetic-logical-operations: 1648e24f5f31STony 16490ac939f3STony TyeA.2.5.4.3.2 Arithmetic and Logical Operations 16500ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1651e24f5f31STony 1652e24f5f31STony.. note:: 1653e24f5f31STony 1654e24f5f31STony This section is the same as DWARF Version 5 section 2.5.1.4. 1655e24f5f31STony 1656e24f5f31STony.. _amdgpu-dwarf-type-conversions-operations: 1657e24f5f31STony 16580ac939f3STony TyeA.2.5.4.3.3 Type Conversion Operations 16590ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1660e24f5f31STony 1661e24f5f31STony.. note:: 1662e24f5f31STony 1663e24f5f31STony This section is the same as DWARF Version 5 section 2.5.1.6. 1664e24f5f31STony 1665e24f5f31STony.. _amdgpu-dwarf-general-operations: 1666e24f5f31STony 16670ac939f3STony TyeA.2.5.4.3.4 Special Value Operations 16680ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16690ac939f3STony Tye 16700ac939f3STony Tye.. note:: 16710ac939f3STony Tye 16720ac939f3STony Tye This section replaces parts of DWARF Version 5 sections 2.5.1.2, 2.5.1.3, and 16730ac939f3STony Tye 2.5.1.7. 1674e24f5f31STony 1675e24f5f31STonyThere are these special value operations currently defined: 1676e24f5f31STony 1677e24f5f31STony1. ``DW_OP_regval_type`` 1678e24f5f31STony 1679e24f5f31STony ``DW_OP_regval_type`` has two operands. The first is an unsigned LEB128 1680e24f5f31STony integer that represents a register number R. The second is an unsigned 1681e24f5f31STony LEB128 integer DR that represents the byte offset of a debugging information 1682e24f5f31STony entry D relative to the beginning of the current compilation unit, that 1683e24f5f31STony provides the type T of the register value. 1684e24f5f31STony 1685e24f5f31STony The operation is equivalent to performing ``DW_OP_regx R; DW_OP_deref_type 1686e24f5f31STony DR``. 1687e24f5f31STony 1688e24f5f31STony .. note:: 1689e24f5f31STony 1690e24f5f31STony Should DWARF allow the type T to be a larger size than the size of the 1691e24f5f31STony register R? Restricting a larger bit size avoids any issue of conversion 1692e24f5f31STony as the, possibly truncated, bit contents of the register is simply 1693e24f5f31STony interpreted as a value of T. If a conversion is wanted it can be done 1694e24f5f31STony explicitly using a ``DW_OP_convert`` operation. 1695e24f5f31STony 1696e24f5f31STony GDB has a per register hook that allows a target specific conversion on a 1697e24f5f31STony register by register basis. It defaults to truncation of bigger registers. 1698e24f5f31STony Removing use of the target hook does not cause any test failures in common 1699e24f5f31STony architectures. If the compiler for a target architecture did want some 1700e24f5f31STony form of conversion, including a larger result type, it could always 1701e24f5f31STony explicitly used the ``DW_OP_convert`` operation. 1702e24f5f31STony 1703e24f5f31STony If T is a larger type than the register size, then the default GDB 1704e24f5f31STony register hook reads bytes from the next register (or reads out of bounds 1705e24f5f31STony for the last register!). Removing use of the target hook does not cause 1706e24f5f31STony any test failures in common architectures (except an illegal hand written 1707e24f5f31STony assembly test). If a target architecture requires this behavior, these 1708e24f5f31STony extensions allow a composite location description to be used to combine 1709e24f5f31STony multiple registers. 1710e24f5f31STony 1711e24f5f31STony2. ``DW_OP_deref`` 1712e24f5f31STony 1713e24f5f31STony S is the bit size of the generic type divided by 8 (the byte size) and 1714e24f5f31STony rounded up to a whole number. DR is the offset of a hypothetical debug 1715e24f5f31STony information entry D in the current compilation unit for a base type of the 1716e24f5f31STony generic type. 1717e24f5f31STony 1718e24f5f31STony The operation is equivalent to performing ``DW_OP_deref_type S, DR``. 1719e24f5f31STony 1720e24f5f31STony3. ``DW_OP_deref_size`` 1721e24f5f31STony 1722e24f5f31STony ``DW_OP_deref_size`` has a single 1-byte unsigned integral constant that 1723e24f5f31STony represents a byte result size S. 1724e24f5f31STony 1725e24f5f31STony TS is the smaller of the generic type bit size and S scaled by 8 (the byte 1726e24f5f31STony size). If TS is smaller than the generic type bit size then T is an unsigned 1727e24f5f31STony integral type of bit size TS, otherwise T is the generic type. DR is the 1728e24f5f31STony offset of a hypothetical debug information entry D in the current 1729e24f5f31STony compilation unit for a base type T. 1730e24f5f31STony 1731e24f5f31STony .. note:: 1732e24f5f31STony 1733e24f5f31STony Truncating the value when S is larger than the generic type matches what 1734e24f5f31STony GDB does. This allows the generic type size to not be an integral byte 1735e24f5f31STony size. It does allow S to be arbitrarily large. Should S be restricted to 1736e24f5f31STony the size of the generic type rounded up to a multiple of 8? 1737e24f5f31STony 1738e24f5f31STony The operation is equivalent to performing ``DW_OP_deref_type S, DR``, except 1739e24f5f31STony if T is not the generic type, the value V pushed is zero-extended to the 1740e24f5f31STony generic type bit size and its type changed to the generic type. 1741e24f5f31STony 1742e24f5f31STony4. ``DW_OP_deref_type`` 1743e24f5f31STony 1744e24f5f31STony ``DW_OP_deref_type`` has two operands. The first is a 1-byte unsigned 1745e24f5f31STony integral constant S. The second is an unsigned LEB128 integer DR that 1746e24f5f31STony represents the byte offset of a debugging information entry D relative to 1747e24f5f31STony the beginning of the current compilation unit, that provides the type T of 1748e24f5f31STony the result value. 1749e24f5f31STony 1750e24f5f31STony TS is the bit size of the type T. 1751e24f5f31STony 1752e24f5f31STony *While the size of the pushed value V can be inferred from the type T, it is 1753e24f5f31STony encoded explicitly as the operand S so that the operation can be parsed 1754e24f5f31STony easily without reference to the* ``.debug_info`` *section.* 1755e24f5f31STony 1756e24f5f31STony .. note:: 1757e24f5f31STony 1758e24f5f31STony It is unclear why the operand S is needed. Unlike ``DW_OP_const_type``, 1759e24f5f31STony the size is not needed for parsing. Any evaluation needs to get the base 1760e24f5f31STony type T to push with the value to know its encoding and bit size. 1761e24f5f31STony 1762e24f5f31STony It pops one stack entry that must be a location description L. 1763e24f5f31STony 1764e24f5f31STony A value V of TS bits is retrieved from the location storage LS specified by 1765e24f5f31STony one of the single location descriptions SL of L. 1766e24f5f31STony 1767e24f5f31STony *If L, or the location description of any composite location description 1768e24f5f31STony part that is a subcomponent of L, has more than one single location 1769e24f5f31STony description, then any one of them can be selected as they are required to 1770e24f5f31STony all have the same value. For any single location description SL, bits are 1771e24f5f31STony retrieved from the associated storage location starting at the bit offset 1772e24f5f31STony specified by SL. For a composite location description, the retrieved bits 1773e24f5f31STony are the concatenation of the N bits from each composite location part PL, 1774e24f5f31STony where N is limited to the size of PL.* 1775e24f5f31STony 1776e24f5f31STony V is pushed on the stack with the type T. 1777e24f5f31STony 1778e24f5f31STony .. note:: 1779e24f5f31STony 1780e24f5f31STony This definition makes it an evaluation error if L is a register location 1781e24f5f31STony description that has less than TS bits remaining in the register storage. 1782e24f5f31STony Particularly since these extensions extend location descriptions to have 1783e24f5f31STony a bit offset, it would be odd to define this as performing sign extension 1784e24f5f31STony based on the type, or be target architecture dependent, as the number of 1785e24f5f31STony remaining bits could be any number. This matches the GDB implementation 1786e24f5f31STony for ``DW_OP_deref_type``. 1787e24f5f31STony 1788e24f5f31STony These extensions define ``DW_OP_*breg*`` in terms of 1789e24f5f31STony ``DW_OP_regval_type``. ``DW_OP_regval_type`` is defined in terms of 1790e24f5f31STony ``DW_OP_regx``, which uses a 0 bit offset, and ``DW_OP_deref_type``. 1791e24f5f31STony Therefore, it requires the register size to be greater or equal to the 1792e24f5f31STony address size of the address space. This matches the GDB implementation for 1793e24f5f31STony ``DW_OP_*breg*``. 1794e24f5f31STony 1795e24f5f31STony The DWARF is ill-formed if D is not in the current compilation unit, D is 1796e24f5f31STony not a ``DW_TAG_base_type`` debugging information entry, or if TS divided by 1797e24f5f31STony 8 (the byte size) and rounded up to a whole number is not equal to S. 1798e24f5f31STony 1799e24f5f31STony .. note:: 1800e24f5f31STony 1801e24f5f31STony This definition allows the base type to be a bit size since there seems no 1802e24f5f31STony reason to restrict it. 1803e24f5f31STony 1804e24f5f31STony It is an evaluation error if any bit of the value is retrieved from the 1805e24f5f31STony undefined location storage or the offset of any bit exceeds the size of the 1806e24f5f31STony location storage LS specified by any single location description SL of L. 1807e24f5f31STony 18080ac939f3STony Tye See :ref:`amdgpu-dwarf-implicit-location-description-operations` for special 18090ac939f3STony Tye rules concerning implicit location descriptions created by the 1810e24f5f31STony ``DW_OP_implicit_pointer`` and ``DW_OP_LLVM_implicit_aspace_pointer`` 1811e24f5f31STony operations. 1812e24f5f31STony 1813e24f5f31STony5. ``DW_OP_xderef`` *Deprecated* 1814e24f5f31STony 1815e24f5f31STony ``DW_OP_xderef`` pops two stack entries. The first must be an integral type 1816e24f5f31STony value that represents an address A. The second must be an integral type 1817e24f5f31STony value that represents a target architecture specific address space 1818e24f5f31STony identifier AS. 1819e24f5f31STony 1820e24f5f31STony The operation is equivalent to performing ``DW_OP_swap; 1821e24f5f31STony DW_OP_LLVM_form_aspace_address; DW_OP_deref``. The value V retrieved is left 1822e24f5f31STony on the stack with the generic type. 1823e24f5f31STony 1824e24f5f31STony *This operation is deprecated as the* ``DW_OP_LLVM_form_aspace_address`` 1825e24f5f31STony *operation can be used and provides greater expressiveness.* 1826e24f5f31STony 1827e24f5f31STony6. ``DW_OP_xderef_size`` *Deprecated* 1828e24f5f31STony 1829e24f5f31STony ``DW_OP_xderef_size`` has a single 1-byte unsigned integral constant that 1830e24f5f31STony represents a byte result size S. 1831e24f5f31STony 1832e24f5f31STony It pops two stack entries. The first must be an integral type value that 1833e24f5f31STony represents an address A. The second must be an integral type value that 1834e24f5f31STony represents a target architecture specific address space identifier AS. 1835e24f5f31STony 1836e24f5f31STony The operation is equivalent to performing ``DW_OP_swap; 1837e24f5f31STony DW_OP_LLVM_form_aspace_address; DW_OP_deref_size S``. The zero-extended 1838e24f5f31STony value V retrieved is left on the stack with the generic type. 1839e24f5f31STony 1840e24f5f31STony *This operation is deprecated as the* ``DW_OP_LLVM_form_aspace_address`` 1841e24f5f31STony *operation can be used and provides greater expressiveness.* 1842e24f5f31STony 1843e24f5f31STony7. ``DW_OP_xderef_type`` *Deprecated* 1844e24f5f31STony 1845e24f5f31STony ``DW_OP_xderef_type`` has two operands. The first is a 1-byte unsigned 1846e24f5f31STony integral constant S. The second operand is an unsigned LEB128 integer DR 1847e24f5f31STony that represents the byte offset of a debugging information entry D relative 1848e24f5f31STony to the beginning of the current compilation unit, that provides the type T 1849e24f5f31STony of the result value. 1850e24f5f31STony 1851e24f5f31STony It pops two stack entries. The first must be an integral type value that 1852e24f5f31STony represents an address A. The second must be an integral type value that 1853e24f5f31STony represents a target architecture specific address space identifier AS. 1854e24f5f31STony 1855e24f5f31STony The operation is equivalent to performing ``DW_OP_swap; 18560ac939f3STony Tye DW_OP_LLVM_form_aspace_address; DW_OP_deref_type S DR``. The value V 18570ac939f3STony Tye retrieved is left on the stack with the type T. 1858e24f5f31STony 1859e24f5f31STony *This operation is deprecated as the* ``DW_OP_LLVM_form_aspace_address`` 1860e24f5f31STony *operation can be used and provides greater expressiveness.* 1861e24f5f31STony 1862e24f5f31STony8. ``DW_OP_entry_value`` *Deprecated* 1863e24f5f31STony 1864e24f5f31STony ``DW_OP_entry_value`` pushes the value of an expression that is evaluated in 1865e24f5f31STony the context of the calling frame. 1866e24f5f31STony 1867e24f5f31STony *It may be used to determine the value of arguments on entry to the current 1868e24f5f31STony call frame provided they are not clobbered.* 1869e24f5f31STony 1870e24f5f31STony It has two operands. The first is an unsigned LEB128 integer S. The second 1871e24f5f31STony is a block of bytes, with a length equal S, interpreted as a DWARF 1872e24f5f31STony operation expression E. 1873e24f5f31STony 1874e24f5f31STony E is evaluated with the current context, except the result kind is 1875e24f5f31STony unspecified, the call frame is the one that called the current frame, the 1876e24f5f31STony program location is the call site in the calling frame, the object is 1877e24f5f31STony unspecified, and the initial stack is empty. The calling frame information 1878e24f5f31STony is obtained by virtually unwinding the current call frame using the call 1879e24f5f31STony frame information (see :ref:`amdgpu-dwarf-call-frame-information`). 1880e24f5f31STony 1881e24f5f31STony If the result of E is a location description L (see 18820ac939f3STony Tye :ref:`amdgpu-dwarf-register-location-description-operations`), and the last 18830ac939f3STony Tye operation executed by E is a ``DW_OP_reg*`` for register R with a target 18840ac939f3STony Tye architecture specific base type of T, then the contents of the register are 18850ac939f3STony Tye retrieved as if a ``DW_OP_deref_type DR`` operation was performed where DR 18860ac939f3STony Tye is the offset of a hypothetical debug information entry in the current 18870ac939f3STony Tye compilation unit for T. The resulting value V s pushed on the stack. 1888e24f5f31STony 1889e24f5f31STony *Using* ``DW_OP_reg*`` *provides a more compact form for the case where the 1890e24f5f31STony value was in a register on entry to the subprogram.* 1891e24f5f31STony 18920ac939f3STony Tye .. note:: 1893e24f5f31STony 1894e24f5f31STony It is unclear how this provides a more compact expression, as 1895e24f5f31STony ``DW_OP_regval_type`` could be used which is marginally larger. 1896e24f5f31STony 1897e24f5f31STony If the result of E is a value V, then V is pushed on the stack. 1898e24f5f31STony 1899e24f5f31STony Otherwise, the DWARF expression is ill-formed. 1900e24f5f31STony 1901e24f5f31STony *The* ``DW_OP_entry_value`` *operation is deprecated as its main usage is 1902e24f5f31STony provided by other means. DWARF Version 5 added the* 1903e24f5f31STony ``DW_TAG_call_site_parameter`` *debugger information entry for call sites 1904e24f5f31STony that has* ``DW_AT_call_value``\ *,* ``DW_AT_call_data_location``\ *, and* 1905e24f5f31STony ``DW_AT_call_data_value`` *attributes that provide DWARF expressions to 1906e24f5f31STony compute actual parameter values at the time of the call, and requires the 1907e24f5f31STony producer to ensure the expressions are valid to evaluate even when virtually 1908e24f5f31STony unwound. The* ``DW_OP_LLVM_call_frame_entry_reg`` *operation provides access 1909e24f5f31STony to registers in the virtually unwound calling frame.* 1910e24f5f31STony 1911e24f5f31STony .. note:: 1912e24f5f31STony 1913e24f5f31STony GDB only implements ``DW_OP_entry_value`` when E is exactly 1914e24f5f31STony ``DW_OP_reg*`` or ``DW_OP_breg*; DW_OP_deref*``. 1915e24f5f31STony 1916e24f5f31STony.. _amdgpu-dwarf-location-description-operations: 1917e24f5f31STony 19180ac939f3STony TyeA.2.5.4.4 Location Description Operations 19190ac939f3STony Tye######################################### 1920e24f5f31STony 1921e24f5f31STonyThis section describes the operations that push location descriptions on the 1922e24f5f31STonystack. 1923e24f5f31STony 19240ac939f3STony Tye.. _amdgpu-dwarf-general-location-description-operations: 19250ac939f3STony Tye 19260ac939f3STony TyeA.2.5.4.4.1 General Location Description Operations 19270ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19280ac939f3STony Tye 19290ac939f3STony Tye.. note:: 19300ac939f3STony Tye 19310ac939f3STony Tye This section replaces part of DWARF Version 5 section 2.5.1.3. 1932e24f5f31STony 1933e24f5f31STony1. ``DW_OP_LLVM_offset`` *New* 1934e24f5f31STony 1935e24f5f31STony ``DW_OP_LLVM_offset`` pops two stack entries. The first must be an integral 1936e24f5f31STony type value that represents a byte displacement B. The second must be a 1937e24f5f31STony location description L. 1938e24f5f31STony 1939e24f5f31STony It adds the value of B scaled by 8 (the byte size) to the bit offset of each 1940e24f5f31STony single location description SL of L, and pushes the updated L. 1941e24f5f31STony 1942e24f5f31STony It is an evaluation error if the updated bit offset of any SL is less than 0 1943e24f5f31STony or greater than or equal to the size of the location storage specified by 1944e24f5f31STony SL. 1945e24f5f31STony 1946e24f5f31STony2. ``DW_OP_LLVM_offset_uconst`` *New* 1947e24f5f31STony 1948e24f5f31STony ``DW_OP_LLVM_offset_uconst`` has a single unsigned LEB128 integer operand 1949e24f5f31STony that represents a byte displacement B. 1950e24f5f31STony 1951e24f5f31STony The operation is equivalent to performing ``DW_OP_constu B; 1952e24f5f31STony DW_OP_LLVM_offset``. 1953e24f5f31STony 1954e24f5f31STony *This operation is supplied specifically to be able to encode more field 1955e24f5f31STony displacements in two bytes than can be done with* ``DW_OP_lit*; 1956e24f5f31STony DW_OP_LLVM_offset``\ *.* 1957e24f5f31STony 1958e24f5f31STony .. note:: 1959e24f5f31STony 1960e24f5f31STony Should this be named ``DW_OP_LLVM_offset_uconst`` to match 1961e24f5f31STony ``DW_OP_plus_uconst``, or ``DW_OP_LLVM_offset_constu`` to match 1962e24f5f31STony ``DW_OP_constu``? 1963e24f5f31STony 1964e24f5f31STony3. ``DW_OP_LLVM_bit_offset`` *New* 1965e24f5f31STony 1966e24f5f31STony ``DW_OP_LLVM_bit_offset`` pops two stack entries. The first must be an 1967e24f5f31STony integral type value that represents a bit displacement B. The second must be 1968e24f5f31STony a location description L. 1969e24f5f31STony 1970e24f5f31STony It adds the value of B to the bit offset of each single location description 1971e24f5f31STony SL of L, and pushes the updated L. 1972e24f5f31STony 1973e24f5f31STony It is an evaluation error if the updated bit offset of any SL is less than 0 1974e24f5f31STony or greater than or equal to the size of the location storage specified by 1975e24f5f31STony SL. 1976e24f5f31STony 1977e24f5f31STony4. ``DW_OP_push_object_address`` 1978e24f5f31STony 1979e24f5f31STony ``DW_OP_push_object_address`` pushes the location description L of the 1980e24f5f31STony current object. 1981e24f5f31STony 1982e24f5f31STony *This object may correspond to an independent variable that is part of a 1983e24f5f31STony user presented expression that is being evaluated. The object location 1984e24f5f31STony description may be determined from the variable's own debugging information 1985e24f5f31STony entry or it may be a component of an array, structure, or class whose 1986e24f5f31STony address has been dynamically determined by an earlier step during user 1987e24f5f31STony expression evaluation.* 1988e24f5f31STony 1989e24f5f31STony *This operation provides explicit functionality (especially for arrays 19900ac939f3STony Tye involving descriptors) that is analogous to the implicit push of the base 19910ac939f3STony Tye location description of a structure prior to evaluation of a* 19920ac939f3STony Tye ``DW_AT_data_member_location`` *to access a data member of a structure.* 1993e24f5f31STony 1994e24f5f31STony .. note:: 1995e24f5f31STony 1996e24f5f31STony This operation could be removed and the object location description 1997e24f5f31STony specified as the initial stack as for ``DW_AT_data_member_location``. 1998e24f5f31STony 19990ac939f3STony Tye Or this operation could be used instead of needing to specify an initial 20000ac939f3STony Tye stack. The latter approach is more composable as access to the object may 20010ac939f3STony Tye be needed at any point of the expression, and passing it as the initial 20020ac939f3STony Tye stack requires the entire expression to be aware where on the stack it is. 20030ac939f3STony Tye If this were done, ``DW_AT_use_location`` would require a 20040ac939f3STony Tye ``DW_OP_push_object2_address`` operation for the second object. 20050ac939f3STony Tye 20060ac939f3STony Tye Or a more general way to pass an arbitrary number of arguments in and an 20070ac939f3STony Tye operation to get the Nth one such as ``DW_OP_arg N``. A vector of 20080ac939f3STony Tye arguments would then be passed in the expression context rather than an 20090ac939f3STony Tye initial stack. This could also resolve the issues with ``DW_OP_call*`` by 20100ac939f3STony Tye allowing a specific number of arguments passed in and returned to be 20110ac939f3STony Tye specified. The ``DW_OP_call*`` operation could then always execute on a 20120ac939f3STony Tye separate stack: the number of arguments would be specified in a new call 20130ac939f3STony Tye operation and taken from the callers stack, and similarly the number of 20140ac939f3STony Tye return results specified and copied from the called stack back to the 20150ac939f3STony Tye callee stack when the called expression was complete. 20160ac939f3STony Tye 2017e24f5f31STony The only attribute that specifies a current object is 2018e24f5f31STony ``DW_AT_data_location`` so the non-normative text seems to overstate how 2019e24f5f31STony this is being used. Or are there other attributes that need to state they 2020e24f5f31STony pass an object? 2021e24f5f31STony 2022e24f5f31STony5. ``DW_OP_LLVM_call_frame_entry_reg`` *New* 2023e24f5f31STony 2024e24f5f31STony ``DW_OP_LLVM_call_frame_entry_reg`` has a single unsigned LEB128 integer 2025e24f5f31STony operand that represents a target architecture register number R. 2026e24f5f31STony 2027e24f5f31STony It pushes a location description L that holds the value of register R on 2028e24f5f31STony entry to the current subprogram as defined by the call frame information 2029e24f5f31STony (see :ref:`amdgpu-dwarf-call-frame-information`). 2030e24f5f31STony 2031e24f5f31STony *If there is no call frame information defined, then the default rules for 2032e24f5f31STony the target architecture are used. If the register rule is* undefined\ *, then 2033e24f5f31STony the undefined location description is pushed. If the register rule is* same 2034e24f5f31STony value\ *, then a register location description for R is pushed.* 2035e24f5f31STony 2036e24f5f31STony.. _amdgpu-dwarf-undefined-location-description-operations: 2037e24f5f31STony 20380ac939f3STony TyeA.2.5.4.4.2 Undefined Location Description Operations 20390ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20400ac939f3STony Tye 20410ac939f3STony Tye.. note:: 20420ac939f3STony Tye 20430ac939f3STony Tye This section replaces DWARF Version 5 section 2.6.1.1.1. 2044e24f5f31STony 2045e24f5f31STony*The undefined location storage represents a piece or all of an object that is 2046e24f5f31STonypresent in the source but not in the object code (perhaps due to optimization). 2047e24f5f31STonyNeither reading nor writing to the undefined location storage is meaningful.* 2048e24f5f31STony 2049e24f5f31STonyAn undefined location description specifies the undefined location storage. 2050e24f5f31STonyThere is no concept of the size of the undefined location storage, nor of a bit 2051e24f5f31STonyoffset for an undefined location description. The ``DW_OP_LLVM_*offset`` 2052e24f5f31STonyoperations leave an undefined location description unchanged. The 2053e24f5f31STony``DW_OP_*piece`` operations can explicitly or implicitly specify an undefined 2054e24f5f31STonylocation description, allowing any size and offset to be specified, and results 2055e24f5f31STonyin a part with all undefined bits. 2056e24f5f31STony 2057e24f5f31STony1. ``DW_OP_LLVM_undefined`` *New* 2058e24f5f31STony 2059e24f5f31STony ``DW_OP_LLVM_undefined`` pushes a location description L that comprises one 2060e24f5f31STony undefined location description SL. 2061e24f5f31STony 2062e24f5f31STony.. _amdgpu-dwarf-memory-location-description-operations: 2063e24f5f31STony 20640ac939f3STony TyeA.2.5.4.4.3 Memory Location Description Operations 20650ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20660ac939f3STony Tye 20670ac939f3STony Tye.. note:: 20680ac939f3STony Tye 20690ac939f3STony Tye This section replaces parts of DWARF Version 5 section 2.5.1.1, 2.5.1.2, 20700ac939f3STony Tye 2.5.1.3, and 2.6.1.1.2. 2071e24f5f31STony 2072e24f5f31STonyEach of the target architecture specific address spaces has a corresponding 2073e24f5f31STonymemory location storage that denotes the linear addressable memory of that 2074e24f5f31STonyaddress space. The size of each memory location storage corresponds to the range 2075e24f5f31STonyof the addresses in the corresponding address space. 2076e24f5f31STony 2077e24f5f31STony*It is target architecture defined how address space location storage maps to 2078e24f5f31STonytarget architecture physical memory. For example, they may be independent 2079e24f5f31STonymemory, or more than one location storage may alias the same physical memory 2080e24f5f31STonypossibly at different offsets and with different interleaving. The mapping may 2081e24f5f31STonyalso be dictated by the source language address classes.* 2082e24f5f31STony 2083e24f5f31STonyA memory location description specifies a memory location storage. The bit 2084e24f5f31STonyoffset corresponds to a bit position within a byte of the memory. Bits accessed 2085e24f5f31STonyusing a memory location description, access the corresponding target 2086e24f5f31STonyarchitecture memory starting at the bit position within the byte specified by 2087e24f5f31STonythe bit offset. 2088e24f5f31STony 2089e24f5f31STonyA memory location description that has a bit offset that is a multiple of 8 (the 2090e24f5f31STonybyte size) is defined to be a byte address memory location description. It has a 2091e24f5f31STonymemory byte address A that is equal to the bit offset divided by 8. 2092e24f5f31STony 2093e24f5f31STonyA memory location description that does not have a bit offset that is a multiple 2094e24f5f31STonyof 8 (the byte size) is defined to be a bit field memory location description. 2095e24f5f31STonyIt has a bit position B equal to the bit offset modulo 8, and a memory byte 2096e24f5f31STonyaddress A equal to the bit offset minus B that is then divided by 8. 2097e24f5f31STony 2098e24f5f31STonyThe address space AS of a memory location description is defined to be the 2099e24f5f31STonyaddress space that corresponds to the memory location storage associated with 2100e24f5f31STonythe memory location description. 2101e24f5f31STony 2102e24f5f31STonyA location description that is comprised of one byte address memory location 2103e24f5f31STonydescription SL is defined to be a memory byte address location description. It 2104e24f5f31STonyhas a byte address equal to A and an address space equal to AS of the 2105e24f5f31STonycorresponding SL. 2106e24f5f31STony 2107e24f5f31STony``DW_ASPACE_none`` is defined as the target architecture default address space. 2108e24f5f31STony 2109e24f5f31STonyIf a stack entry is required to be a location description, but it is a value V 2110e24f5f31STonywith the generic type, then it is implicitly converted to a location description 2111e24f5f31STonyL with one memory location description SL. SL specifies the memory location 2112e24f5f31STonystorage that corresponds to the target architecture default address space with a 2113e24f5f31STonybit offset equal to V scaled by 8 (the byte size). 2114e24f5f31STony 2115e24f5f31STony.. note:: 2116e24f5f31STony 2117e24f5f31STony If it is wanted to allow any integral type value to be implicitly converted to 2118e24f5f31STony a memory location description in the target architecture default address 2119e24f5f31STony space: 2120e24f5f31STony 2121e24f5f31STony If a stack entry is required to be a location description, but is a value V 2122e24f5f31STony with an integral type, then it is implicitly converted to a location 2123e24f5f31STony description L with a one memory location description SL. If the type size of 2124e24f5f31STony V is less than the generic type size, then the value V is zero extended to 2125e24f5f31STony the size of the generic type. The least significant generic type size bits 21260ac939f3STony Tye are treated as an unsigned value to be used as an address A. SL specifies 21270ac939f3STony Tye memory location storage corresponding to the target architecture default 21280ac939f3STony Tye address space with a bit offset equal to A scaled by 8 (the byte size). 2129e24f5f31STony 2130e24f5f31STony The implicit conversion could also be defined as target architecture specific. 2131e24f5f31STony For example, GDB checks if V is an integral type. If it is not it gives an 2132e24f5f31STony error. Otherwise, GDB zero-extends V to 64 bits. If the GDB target defines a 2133e24f5f31STony hook function, then it is called. The target specific hook function can modify 2134e24f5f31STony the 64-bit value, possibly sign extending based on the original value type. 2135e24f5f31STony Finally, GDB treats the 64-bit value V as a memory location address. 2136e24f5f31STony 2137e24f5f31STonyIf a stack entry is required to be a location description, but it is an implicit 2138e24f5f31STonypointer value IPV with the target architecture default address space, then it is 2139e24f5f31STonyimplicitly converted to a location description with one single location 2140e24f5f31STonydescription specified by IPV. See 21410ac939f3STony Tye:ref:`amdgpu-dwarf-implicit-location-description-operations`. 2142e24f5f31STony 2143e24f5f31STony.. note:: 2144e24f5f31STony 2145e24f5f31STony Is this rule required for DWARF Version 5 backwards compatibility? If not, it 2146e24f5f31STony can be eliminated, and the producer can use 2147e24f5f31STony ``DW_OP_LLVM_form_aspace_address``. 2148e24f5f31STony 2149e24f5f31STonyIf a stack entry is required to be a value, but it is a location description L 2150e24f5f31STonywith one memory location description SL in the target architecture default 2151e24f5f31STonyaddress space with a bit offset B that is a multiple of 8, then it is implicitly 2152e24f5f31STonyconverted to a value equal to B divided by 8 (the byte size) with the generic 2153e24f5f31STonytype. 2154e24f5f31STony 2155e24f5f31STony1. ``DW_OP_addr`` 2156e24f5f31STony 2157e24f5f31STony ``DW_OP_addr`` has a single byte constant value operand, which has the size 2158e24f5f31STony of the generic type, that represents an address A. 2159e24f5f31STony 2160e24f5f31STony It pushes a location description L with one memory location description SL 2161e24f5f31STony on the stack. SL specifies the memory location storage corresponding to the 2162e24f5f31STony target architecture default address space with a bit offset equal to A 2163e24f5f31STony scaled by 8 (the byte size). 2164e24f5f31STony 2165e24f5f31STony *If the DWARF is part of a code object, then A may need to be relocated. For 2166e24f5f31STony example, in the ELF code object format, A must be adjusted by the difference 2167e24f5f31STony between the ELF segment virtual address and the virtual address at which the 2168e24f5f31STony segment is loaded.* 2169e24f5f31STony 2170e24f5f31STony2. ``DW_OP_addrx`` 2171e24f5f31STony 2172e24f5f31STony ``DW_OP_addrx`` has a single unsigned LEB128 integer operand that represents 2173e24f5f31STony a zero-based index into the ``.debug_addr`` section relative to the value of 2174e24f5f31STony the ``DW_AT_addr_base`` attribute of the associated compilation unit. The 2175e24f5f31STony address value A in the ``.debug_addr`` section has the size of the generic 2176e24f5f31STony type. 2177e24f5f31STony 2178e24f5f31STony It pushes a location description L with one memory location description SL 2179e24f5f31STony on the stack. SL specifies the memory location storage corresponding to the 2180e24f5f31STony target architecture default address space with a bit offset equal to A 2181e24f5f31STony scaled by 8 (the byte size). 2182e24f5f31STony 2183e24f5f31STony *If the DWARF is part of a code object, then A may need to be relocated. For 2184e24f5f31STony example, in the ELF code object format, A must be adjusted by the difference 2185e24f5f31STony between the ELF segment virtual address and the virtual address at which the 2186e24f5f31STony segment is loaded.* 2187e24f5f31STony 2188e24f5f31STony3. ``DW_OP_LLVM_form_aspace_address`` *New* 2189e24f5f31STony 2190e24f5f31STony ``DW_OP_LLVM_form_aspace_address`` pops top two stack entries. The first 2191e24f5f31STony must be an integral type value that represents a target architecture 2192e24f5f31STony specific address space identifier AS. The second must be an integral type 2193e24f5f31STony value that represents an address A. 2194e24f5f31STony 2195e24f5f31STony The address size S is defined as the address bit size of the target 2196e24f5f31STony architecture specific address space that corresponds to AS. 2197e24f5f31STony 21980ac939f3STony Tye A is adjusted to S bits by zero extending if necessary, and then treating 21990ac939f3STony Tye the least significant S bits as an unsigned value A'. 2200e24f5f31STony 2201e24f5f31STony It pushes a location description L with one memory location description SL 2202e24f5f31STony on the stack. SL specifies the memory location storage LS that corresponds 2203e24f5f31STony to AS with a bit offset equal to A' scaled by 8 (the byte size). 2204e24f5f31STony 2205e24f5f31STony If AS is an address space that is specific to context elements, then LS 2206e24f5f31STony corresponds to the location storage associated with the current context. 2207e24f5f31STony 2208e24f5f31STony *For example, if AS is for per thread storage then LS is the location 2209e24f5f31STony storage for the current thread. For languages that are implemented using a 22108ba5043dSTony Tye SIMT execution model, then if AS is for per lane storage then LS is the 22118ba5043dSTony Tye location storage for the current lane of the current thread. Therefore, if L 22128ba5043dSTony Tye is accessed by an operation, the location storage selected when the location 22138ba5043dSTony Tye description was created is accessed, and not the location storage associated 22148ba5043dSTony Tye with the current context of the access operation.* 2215e24f5f31STony 2216e24f5f31STony The DWARF expression is ill-formed if AS is not one of the values defined by 2217e24f5f31STony the target architecture specific ``DW_ASPACE_*`` values. 2218e24f5f31STony 22190ac939f3STony Tye See :ref:`amdgpu-dwarf-implicit-location-description-operations` for special 22200ac939f3STony Tye rules concerning implicit pointer values produced by dereferencing implicit 2221e24f5f31STony location descriptions created by the ``DW_OP_implicit_pointer`` and 2222e24f5f31STony ``DW_OP_LLVM_implicit_aspace_pointer`` operations. 2223e24f5f31STony 2224e24f5f31STony4. ``DW_OP_form_tls_address`` 2225e24f5f31STony 2226e24f5f31STony ``DW_OP_form_tls_address`` pops one stack entry that must be an integral 2227e24f5f31STony type value and treats it as a thread-local storage address TA. 2228e24f5f31STony 2229e24f5f31STony It pushes a location description L with one memory location description SL 2230e24f5f31STony on the stack. SL is the target architecture specific memory location 2231e24f5f31STony description that corresponds to the thread-local storage address TA. 2232e24f5f31STony 2233e24f5f31STony The meaning of the thread-local storage address TA is defined by the 2234e24f5f31STony run-time environment. If the run-time environment supports multiple 2235e24f5f31STony thread-local storage blocks for a single thread, then the block 2236e24f5f31STony corresponding to the executable or shared library containing this DWARF 2237e24f5f31STony expression is used. 2238e24f5f31STony 2239e24f5f31STony *Some implementations of C, C++, Fortran, and other languages support a 2240e24f5f31STony thread-local storage class. Variables with this storage class have distinct 2241e24f5f31STony values and addresses in distinct threads, much as automatic variables have 2242e24f5f31STony distinct values and addresses in each subprogram invocation. Typically, 2243e24f5f31STony there is a single block of storage containing all thread-local variables 2244e24f5f31STony declared in the main executable, and a separate block for the variables 2245e24f5f31STony declared in each shared library. Each thread-local variable can then be 2246e24f5f31STony accessed in its block using an identifier. This identifier is typically a 2247e24f5f31STony byte offset into the block and pushed onto the DWARF stack by one of the* 2248e24f5f31STony ``DW_OP_const*`` *operations prior to the* ``DW_OP_form_tls_address`` 2249e24f5f31STony *operation. Computing the address of the appropriate block can be complex 2250e24f5f31STony (in some cases, the compiler emits a function call to do it), and difficult 2251e24f5f31STony to describe using ordinary DWARF location descriptions. Instead of forcing 2252e24f5f31STony complex thread-local storage calculations into the DWARF expressions, the* 2253e24f5f31STony ``DW_OP_form_tls_address`` *allows the consumer to perform the computation 2254e24f5f31STony based on the target architecture specific run-time environment.* 2255e24f5f31STony 2256e24f5f31STony5. ``DW_OP_call_frame_cfa`` 2257e24f5f31STony 2258e24f5f31STony ``DW_OP_call_frame_cfa`` pushes the location description L of the Canonical 2259e24f5f31STony Frame Address (CFA) of the current subprogram, obtained from the call frame 2260e24f5f31STony information on the stack. See :ref:`amdgpu-dwarf-call-frame-information`. 2261e24f5f31STony 2262e24f5f31STony *Although the value of the* ``DW_AT_frame_base`` *attribute of the debugger 2263e24f5f31STony information entry corresponding to the current subprogram can be computed 2264e24f5f31STony using a location list expression, in some cases this would require an 2265e24f5f31STony extensive location list because the values of the registers used in 2266e24f5f31STony computing the CFA change during a subprogram execution. If the call frame 2267e24f5f31STony information is present, then it already encodes such changes, and it is 2268e24f5f31STony space efficient to reference that using the* ``DW_OP_call_frame_cfa`` 2269e24f5f31STony *operation.* 2270e24f5f31STony 2271e24f5f31STony6. ``DW_OP_fbreg`` 2272e24f5f31STony 2273e24f5f31STony ``DW_OP_fbreg`` has a single signed LEB128 integer operand that represents a 2274e24f5f31STony byte displacement B. 2275e24f5f31STony 2276e24f5f31STony The location description L for the *frame base* of the current subprogram is 2277e24f5f31STony obtained from the ``DW_AT_frame_base`` attribute of the debugger information 2278e24f5f31STony entry corresponding to the current subprogram as described in 22790ac939f3STony Tye :ref:`amdgpu-dwarf-low-level-information`. 2280e24f5f31STony 2281e24f5f31STony The location description L is updated as if the ``DW_OP_LLVM_offset_uconst 2282e24f5f31STony B`` operation was applied. The updated L is pushed on the stack. 2283e24f5f31STony 2284e24f5f31STony7. ``DW_OP_breg0``, ``DW_OP_breg1``, ..., ``DW_OP_breg31`` 2285e24f5f31STony 2286e24f5f31STony The ``DW_OP_breg<N>`` operations encode the numbers of up to 32 registers, 2287e24f5f31STony numbered from 0 through 31, inclusive. The register number R corresponds to 2288e24f5f31STony the N in the operation name. 2289e24f5f31STony 2290e24f5f31STony They have a single signed LEB128 integer operand that represents a byte 2291e24f5f31STony displacement B. 2292e24f5f31STony 2293e24f5f31STony The address space identifier AS is defined as the one corresponding to the 2294e24f5f31STony target architecture specific default address space. 2295e24f5f31STony 2296e24f5f31STony The address size S is defined as the address bit size of the target 2297e24f5f31STony architecture specific address space corresponding to AS. 2298e24f5f31STony 2299e24f5f31STony The contents of the register specified by R are retrieved as if a 2300e24f5f31STony ``DW_OP_regval_type R, DR`` operation was performed where DR is the offset 2301e24f5f31STony of a hypothetical debug information entry in the current compilation unit 2302e24f5f31STony for an unsigned integral base type of size S bits. B is added and the least 2303e24f5f31STony significant S bits are treated as an unsigned value to be used as an address 2304e24f5f31STony A. 2305e24f5f31STony 2306e24f5f31STony They push a location description L comprising one memory location 2307e24f5f31STony description LS on the stack. LS specifies the memory location storage that 2308e24f5f31STony corresponds to AS with a bit offset equal to A scaled by 8 (the byte size). 2309e24f5f31STony 2310e24f5f31STony8. ``DW_OP_bregx`` 2311e24f5f31STony 2312e24f5f31STony ``DW_OP_bregx`` has two operands. The first is an unsigned LEB128 integer 2313e24f5f31STony that represents a register number R. The second is a signed LEB128 2314e24f5f31STony integer that represents a byte displacement B. 2315e24f5f31STony 2316e24f5f31STony The action is the same as for ``DW_OP_breg<N>``, except that R is used as 2317e24f5f31STony the register number and B is used as the byte displacement. 2318e24f5f31STony 2319e24f5f31STony9. ``DW_OP_LLVM_aspace_bregx`` *New* 2320e24f5f31STony 2321e24f5f31STony ``DW_OP_LLVM_aspace_bregx`` has two operands. The first is an unsigned 2322e24f5f31STony LEB128 integer that represents a register number R. The second is a signed 2323e24f5f31STony LEB128 integer that represents a byte displacement B. It pops one stack 2324e24f5f31STony entry that is required to be an integral type value that represents a target 2325e24f5f31STony architecture specific address space identifier AS. 2326e24f5f31STony 2327e24f5f31STony The action is the same as for ``DW_OP_breg<N>``, except that R is used as 2328e24f5f31STony the register number, B is used as the byte displacement, and AS is used as 2329e24f5f31STony the address space identifier. 2330e24f5f31STony 2331e24f5f31STony The DWARF expression is ill-formed if AS is not one of the values defined by 2332e24f5f31STony the target architecture specific ``DW_ASPACE_*`` values. 2333e24f5f31STony 2334e24f5f31STony .. note:: 2335e24f5f31STony 2336e24f5f31STony Could also consider adding ``DW_OP_aspace_breg0, DW_OP_aspace_breg1, ..., 2337e24f5f31STony DW_OP_aspace_bref31`` which would save encoding size. 2338e24f5f31STony 23390ac939f3STony Tye.. _amdgpu-dwarf-register-location-description-operations: 2340e24f5f31STony 23410ac939f3STony TyeA.2.5.4.4.4 Register Location Description Operations 23420ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23430ac939f3STony Tye 23440ac939f3STony Tye.. note:: 23450ac939f3STony Tye 23460ac939f3STony Tye This section replaces DWARF Version 5 section 2.6.1.1.3. 2347e24f5f31STony 2348e24f5f31STonyThere is a register location storage that corresponds to each of the target 2349e24f5f31STonyarchitecture registers. The size of each register location storage corresponds 2350e24f5f31STonyto the size of the corresponding target architecture register. 2351e24f5f31STony 2352e24f5f31STonyA register location description specifies a register location storage. The bit 2353e24f5f31STonyoffset corresponds to a bit position within the register. Bits accessed using a 2354e24f5f31STonyregister location description access the corresponding target architecture 2355e24f5f31STonyregister starting at the specified bit offset. 2356e24f5f31STony 2357e24f5f31STony1. ``DW_OP_reg0``, ``DW_OP_reg1``, ..., ``DW_OP_reg31`` 2358e24f5f31STony 2359e24f5f31STony ``DW_OP_reg<N>`` operations encode the numbers of up to 32 registers, 2360e24f5f31STony numbered from 0 through 31, inclusive. The target architecture register 2361e24f5f31STony number R corresponds to the N in the operation name. 2362e24f5f31STony 2363e24f5f31STony The operation is equivalent to performing ``DW_OP_regx R``. 2364e24f5f31STony 2365e24f5f31STony2. ``DW_OP_regx`` 2366e24f5f31STony 2367e24f5f31STony ``DW_OP_regx`` has a single unsigned LEB128 integer operand that represents 2368e24f5f31STony a target architecture register number R. 2369e24f5f31STony 2370e24f5f31STony If the current call frame is the top call frame, it pushes a location 2371e24f5f31STony description L that specifies one register location description SL on the 2372e24f5f31STony stack. SL specifies the register location storage that corresponds to R with 2373e24f5f31STony a bit offset of 0 for the current thread. 2374e24f5f31STony 2375e24f5f31STony If the current call frame is not the top call frame, call frame information 2376e24f5f31STony (see :ref:`amdgpu-dwarf-call-frame-information`) is used to determine the 2377e24f5f31STony location description that holds the register for the current call frame and 2378e24f5f31STony current program location of the current thread. The resulting location 2379e24f5f31STony description L is pushed. 2380e24f5f31STony 2381e24f5f31STony *Note that if call frame information is used, the resulting location 2382e24f5f31STony description may be register, memory, or undefined.* 2383e24f5f31STony 2384e24f5f31STony *An implementation may evaluate the call frame information immediately, or 2385e24f5f31STony may defer evaluation until L is accessed by an operation. If evaluation is 2386a31b3893SKazu Hirata deferred, R and the current context can be recorded in L. When accessed, the 2387e24f5f31STony recorded context is used to evaluate the call frame information, not the 2388e24f5f31STony current context of the access operation.* 2389e24f5f31STony 2390e24f5f31STony*These operations obtain a register location. To fetch the contents of a 2391e24f5f31STonyregister, it is necessary to use* ``DW_OP_regval_type``\ *, use one of the* 2392e24f5f31STony``DW_OP_breg*`` *register-based addressing operations, or use* ``DW_OP_deref*`` 2393e24f5f31STony*on a register location description.* 2394e24f5f31STony 23950ac939f3STony Tye.. _amdgpu-dwarf-implicit-location-description-operations: 2396e24f5f31STony 23970ac939f3STony TyeA.2.5.4.4.5 Implicit Location Description Operations 23980ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23990ac939f3STony Tye 24000ac939f3STony Tye.. note:: 24010ac939f3STony Tye 24020ac939f3STony Tye This section replaces DWARF Version 5 section 2.6.1.1.4. 2403e24f5f31STony 2404e24f5f31STonyImplicit location storage represents a piece or all of an object which has no 2405e24f5f31STonyactual location in the program but whose contents are nonetheless known, either 2406e24f5f31STonyas a constant or can be computed from other locations and values in the program. 2407e24f5f31STony 2408e24f5f31STonyAn implicit location description specifies an implicit location storage. The bit 2409e24f5f31STonyoffset corresponds to a bit position within the implicit location storage. Bits 2410e24f5f31STonyaccessed using an implicit location description, access the corresponding 2411e24f5f31STonyimplicit storage value starting at the bit offset. 2412e24f5f31STony 2413e24f5f31STony1. ``DW_OP_implicit_value`` 2414e24f5f31STony 2415e24f5f31STony ``DW_OP_implicit_value`` has two operands. The first is an unsigned LEB128 2416e24f5f31STony integer that represents a byte size S. The second is a block of bytes with a 2417e24f5f31STony length equal to S treated as a literal value V. 2418e24f5f31STony 2419e24f5f31STony An implicit location storage LS is created with the literal value V and a 2420e24f5f31STony size of S. 2421e24f5f31STony 2422e24f5f31STony It pushes location description L with one implicit location description SL 2423e24f5f31STony on the stack. SL specifies LS with a bit offset of 0. 2424e24f5f31STony 2425e24f5f31STony2. ``DW_OP_stack_value`` 2426e24f5f31STony 2427e24f5f31STony ``DW_OP_stack_value`` pops one stack entry that must be a value V. 2428e24f5f31STony 2429f79bab3fSTony An implicit location storage LS is created with the literal value V using 2430f79bab3fSTony the size, encoding, and enianity specified by V's base type. 2431e24f5f31STony 2432e24f5f31STony It pushes a location description L with one implicit location description SL 2433e24f5f31STony on the stack. SL specifies LS with a bit offset of 0. 2434e24f5f31STony 2435e24f5f31STony *The* ``DW_OP_stack_value`` *operation specifies that the object does not 2436e24f5f31STony exist in memory, but its value is nonetheless known. In this form, the 2437e24f5f31STony location description specifies the actual value of the object, rather than 2438e24f5f31STony specifying the memory or register storage that holds the value.* 2439e24f5f31STony 24400ac939f3STony Tye See :ref:`amdgpu-dwarf-implicit-location-description-operations` for special 24410ac939f3STony Tye rules concerning implicit pointer values produced by dereferencing implicit 2442e24f5f31STony location descriptions created by the ``DW_OP_implicit_pointer`` and 2443e24f5f31STony ``DW_OP_LLVM_implicit_aspace_pointer`` operations. 2444e24f5f31STony 2445e24f5f31STony .. note:: 2446e24f5f31STony 2447e24f5f31STony Since location descriptions are allowed on the stack, the 2448e24f5f31STony ``DW_OP_stack_value`` operation no longer terminates the DWARF operation 2449e24f5f31STony expression execution as in DWARF Version 5. 2450e24f5f31STony 2451e24f5f31STony3. ``DW_OP_implicit_pointer`` 2452e24f5f31STony 2453e24f5f31STony *An optimizing compiler may eliminate a pointer, while still retaining the 2454e24f5f31STony value that the pointer addressed.* ``DW_OP_implicit_pointer`` *allows a 2455e24f5f31STony producer to describe this value.* 2456e24f5f31STony 2457e24f5f31STony ``DW_OP_implicit_pointer`` *specifies an object is a pointer to the target 2458e24f5f31STony architecture default address space that cannot be represented as a real 2459e24f5f31STony pointer, even though the value it would point to can be described. In this 2460e24f5f31STony form, the location description specifies a debugging information entry that 2461e24f5f31STony represents the actual location description of the object to which the 2462e24f5f31STony pointer would point. Thus, a consumer of the debug information would be able 2463e24f5f31STony to access the dereferenced pointer, even when it cannot access the pointer 2464e24f5f31STony itself.* 2465e24f5f31STony 2466e24f5f31STony ``DW_OP_implicit_pointer`` has two operands. The first operand is a 4-byte 2467e24f5f31STony unsigned value in the 32-bit DWARF format, or an 8-byte unsigned value in 2468e24f5f31STony the 64-bit DWARF format, that represents the byte offset DR of a debugging 2469e24f5f31STony information entry D relative to the beginning of the ``.debug_info`` section 2470e24f5f31STony that contains the current compilation unit. The second operand is a signed 2471e24f5f31STony LEB128 integer that represents a byte displacement B. 2472e24f5f31STony 2473e24f5f31STony *Note that D may not be in the current compilation unit.* 2474e24f5f31STony 2475e24f5f31STony *The first operand interpretation is exactly like that for* 2476e24f5f31STony ``DW_FORM_ref_addr``\ *.* 2477e24f5f31STony 2478e24f5f31STony The address space identifier AS is defined as the one corresponding to the 2479e24f5f31STony target architecture specific default address space. 2480e24f5f31STony 2481e24f5f31STony The address size S is defined as the address bit size of the target 2482e24f5f31STony architecture specific address space corresponding to AS. 2483e24f5f31STony 2484e24f5f31STony An implicit location storage LS is created with the debugging information 2485e24f5f31STony entry D, address space AS, and size of S. 2486e24f5f31STony 2487e24f5f31STony It pushes a location description L that comprises one implicit location 2488e24f5f31STony description SL on the stack. SL specifies LS with a bit offset of 0. 2489e24f5f31STony 2490e24f5f31STony It is an evaluation error if a ``DW_OP_deref*`` operation pops a location 2491e24f5f31STony description L', and retrieves S bits, such that any retrieved bits come from 2492e24f5f31STony an implicit location storage that is the same as LS, unless both the 2493e24f5f31STony following conditions are met: 2494e24f5f31STony 2495e24f5f31STony 1. All retrieved bits come from an implicit location description that 2496e24f5f31STony refers to an implicit location storage that is the same as LS. 2497e24f5f31STony 2498e24f5f31STony *Note that all bits do not have to come from the same implicit location 2499e24f5f31STony description, as L' may involve composite location descriptors.* 2500e24f5f31STony 2501e24f5f31STony 2. The bits come from consecutive ascending offsets within their respective 2502e24f5f31STony implicit location storage. 2503e24f5f31STony 2504e24f5f31STony *These rules are equivalent to retrieving the complete contents of LS.* 2505e24f5f31STony 2506e24f5f31STony If both the above conditions are met, then the value V pushed by the 2507e24f5f31STony ``DW_OP_deref*`` operation is an implicit pointer value IPV with a target 2508e24f5f31STony architecture specific address space of AS, a debugging information entry of 2509e24f5f31STony D, and a base type of T. If AS is the target architecture default address 2510e24f5f31STony space, then T is the generic type. Otherwise, T is a target architecture 2511e24f5f31STony specific integral type with a bit size equal to S. 2512e24f5f31STony 2513e24f5f31STony If IPV is either implicitly converted to a location description (only done 2514e24f5f31STony if AS is the target architecture default address space) or used by 2515e24f5f31STony ``DW_OP_LLVM_form_aspace_address`` (only done if the address space popped by 2516e24f5f31STony ``DW_OP_LLVM_form_aspace_address`` is AS), then the resulting location 2517e24f5f31STony description RL is: 2518e24f5f31STony 2519e24f5f31STony * If D has a ``DW_AT_location`` attribute, the DWARF expression E from the 2520e24f5f31STony ``DW_AT_location`` attribute is evaluated with the current context, except 2521e24f5f31STony that the result kind is a location description, the compilation unit is 2522e24f5f31STony the one that contains D, the object is unspecified, and the initial stack 2523e24f5f31STony is empty. RL is the expression result. 2524e24f5f31STony 2525e24f5f31STony *Note that E is evaluated with the context of the expression accessing 2526e24f5f31STony IPV, and not the context of the expression that contained the* 2527e24f5f31STony ``DW_OP_implicit_pointer`` *or* ``DW_OP_LLVM_aspace_implicit_pointer`` 2528e24f5f31STony *operation that created L.* 2529e24f5f31STony 2530e24f5f31STony * If D has a ``DW_AT_const_value`` attribute, then an implicit location 2531e24f5f31STony storage RLS is created from the ``DW_AT_const_value`` attribute's value 2532e24f5f31STony with a size matching the size of the ``DW_AT_const_value`` attribute's 2533e24f5f31STony value. RL comprises one implicit location description SRL. SRL specifies 2534e24f5f31STony RLS with a bit offset of 0. 2535e24f5f31STony 2536e24f5f31STony .. note:: 2537e24f5f31STony 2538e24f5f31STony If using ``DW_AT_const_value`` for variables and formal parameters is 2539e24f5f31STony deprecated and instead ``DW_AT_location`` is used with an implicit 2540e24f5f31STony location description, then this rule would not be required. 2541e24f5f31STony 2542e24f5f31STony * Otherwise, it is an evaluation error. 2543e24f5f31STony 2544e24f5f31STony The bit offset of RL is updated as if the ``DW_OP_LLVM_offset_uconst B`` 2545e24f5f31STony operation was applied. 2546e24f5f31STony 2547e24f5f31STony If a ``DW_OP_stack_value`` operation pops a value that is the same as IPV, 2548e24f5f31STony then it pushes a location description that is the same as L. 2549e24f5f31STony 2550e24f5f31STony It is an evaluation error if LS or IPV is accessed in any other manner. 2551e24f5f31STony 2552e24f5f31STony *The restrictions on how an implicit pointer location description created 2553e24f5f31STony by* ``DW_OP_implicit_pointer`` *and* ``DW_OP_LLVM_aspace_implicit_pointer`` 2554e24f5f31STony *can be used are to simplify the DWARF consumer. Similarly, for an implicit 25550ac939f3STony Tye pointer value created by* ``DW_OP_deref*`` *and* ``DW_OP_stack_value``\ *.* 2556e24f5f31STony 2557e24f5f31STony4. ``DW_OP_LLVM_aspace_implicit_pointer`` *New* 2558e24f5f31STony 2559e24f5f31STony ``DW_OP_LLVM_aspace_implicit_pointer`` has two operands that are the same as 2560e24f5f31STony for ``DW_OP_implicit_pointer``. 2561e24f5f31STony 2562e24f5f31STony It pops one stack entry that must be an integral type value that represents 2563e24f5f31STony a target architecture specific address space identifier AS. 2564e24f5f31STony 2565e24f5f31STony The location description L that is pushed on the stack is the same as for 2566e24f5f31STony ``DW_OP_implicit_pointer``, except that the address space identifier used is 2567e24f5f31STony AS. 2568e24f5f31STony 2569e24f5f31STony The DWARF expression is ill-formed if AS is not one of the values defined by 2570e24f5f31STony the target architecture specific ``DW_ASPACE_*`` values. 2571e24f5f31STony 2572e24f5f31STony .. note:: 2573e24f5f31STony 2574e24f5f31STony This definition of ``DW_OP_LLVM_aspace_implicit_pointer`` may change when 2575e24f5f31STony full support for address classes is added as required for languages such 2576e24f5f31STony as OpenCL/SyCL. 2577e24f5f31STony 2578e24f5f31STony*Typically a* ``DW_OP_implicit_pointer`` *or* 2579e24f5f31STony``DW_OP_LLVM_aspace_implicit_pointer`` *operation is used in a DWARF expression 2580e24f5f31STonyE*\ :sub:`1` *of a* ``DW_TAG_variable`` *or* ``DW_TAG_formal_parameter`` 2581e24f5f31STony*debugging information entry D*\ :sub:`1`\ *'s* ``DW_AT_location`` *attribute. 2582e24f5f31STonyThe debugging information entry referenced by the* ``DW_OP_implicit_pointer`` 2583e24f5f31STony*or* ``DW_OP_LLVM_aspace_implicit_pointer`` *operations is typically itself a* 2584e24f5f31STony``DW_TAG_variable`` *or* ``DW_TAG_formal_parameter`` *debugging information 2585e24f5f31STonyentry D*\ :sub:`2` *whose* ``DW_AT_location`` *attribute gives a second DWARF 2586e24f5f31STonyexpression E*\ :sub:`2`\ *.* 2587e24f5f31STony 2588e24f5f31STony*D*\ :sub:`1` *and E*\ :sub:`1` *are describing the location of a pointer type 2589e24f5f31STonyobject. D*\ :sub:`2` *and E*\ :sub:`2` *are describing the location of the 2590e24f5f31STonyobject pointed to by that pointer object.* 2591e24f5f31STony 2592e24f5f31STony*However, D*\ :sub:`2` *may be any debugging information entry that contains a* 2593e24f5f31STony``DW_AT_location`` *or* ``DW_AT_const_value`` *attribute (for example,* 2594e24f5f31STony``DW_TAG_dwarf_procedure``\ *). By using E*\ :sub:`2`\ *, a consumer can 2595e24f5f31STonyreconstruct the value of the object when asked to dereference the pointer 25960ac939f3STony Tyedescribed by E*\ :sub:`1` *which contains the* ``DW_OP_implicit_pointer`` *or* 2597e24f5f31STony``DW_OP_LLVM_aspace_implicit_pointer`` *operation.* 2598e24f5f31STony 2599e24f5f31STony.. _amdgpu-dwarf-composite-location-description-operations: 2600e24f5f31STony 26010ac939f3STony TyeA.2.5.4.4.6 Composite Location Description Operations 26020ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26030ac939f3STony Tye 26040ac939f3STony Tye.. note:: 26050ac939f3STony Tye 26060ac939f3STony Tye This section replaces DWARF Version 5 section 2.6.1.2. 2607e24f5f31STony 2608e24f5f31STonyA composite location storage represents an object or value which may be 2609e24f5f31STonycontained in part of another location storage or contained in parts of more 2610e24f5f31STonythan one location storage. 2611e24f5f31STony 2612e24f5f31STonyEach part has a part location description L and a part bit size S. L can have 2613e24f5f31STonyone or more single location descriptions SL. If there are more than one SL then 2614e24f5f31STonythat indicates that part is located in more than one place. The bits of each 2615e24f5f31STonyplace of the part comprise S contiguous bits from the location storage LS 2616e24f5f31STonyspecified by SL starting at the bit offset specified by SL. All the bits must 2617e24f5f31STonybe within the size of LS or the DWARF expression is ill-formed. 2618e24f5f31STony 2619e24f5f31STonyA composite location storage can have zero or more parts. The parts are 2620e24f5f31STonycontiguous such that the zero-based location storage bit index will range over 2621e24f5f31STonyeach part with no gaps between them. Therefore, the size of a composite location 2622e24f5f31STonystorage is the sum of the size of its parts. The DWARF expression is ill-formed 2623e24f5f31STonyif the size of the contiguous location storage is larger than the size of the 2624e24f5f31STonymemory location storage corresponding to the largest target architecture 2625e24f5f31STonyspecific address space. 2626e24f5f31STony 2627e24f5f31STonyA composite location description specifies a composite location storage. The bit 2628e24f5f31STonyoffset corresponds to a bit position within the composite location storage. 2629e24f5f31STony 2630e24f5f31STonyThere are operations that create a composite location storage. 2631e24f5f31STony 2632e24f5f31STonyThere are other operations that allow a composite location storage to be 2633e24f5f31STonyincrementally created. Each part is created by a separate operation. There may 2634e24f5f31STonybe one or more operations to create the final composite location storage. A 2635e24f5f31STonyseries of such operations describes the parts of the composite location storage 2636e24f5f31STonythat are in the order that the associated part operations are executed. 2637e24f5f31STony 2638e24f5f31STonyTo support incremental creation, a composite location storage can be in an 2639e24f5f31STonyincomplete state. When an incremental operation operates on an incomplete 2640e24f5f31STonycomposite location storage, it adds a new part, otherwise it creates a new 2641e24f5f31STonycomposite location storage. The ``DW_OP_LLVM_piece_end`` operation explicitly 2642e24f5f31STonymakes an incomplete composite location storage complete. 2643e24f5f31STony 2644e24f5f31STonyA composite location description that specifies a composite location storage 2645e24f5f31STonythat is incomplete is termed an incomplete composite location description. A 2646e24f5f31STonycomposite location description that specifies a composite location storage that 2647e24f5f31STonyis complete is termed a complete composite location description. 2648e24f5f31STony 2649e24f5f31STonyIf the top stack entry is a location description that has one incomplete 2650e24f5f31STonycomposite location description SL after the execution of an operation expression 2651e24f5f31STonyhas completed, SL is converted to a complete composite location description. 2652e24f5f31STony 2653e24f5f31STony*Note that this conversion does not happen after the completion of an operation 2654e24f5f31STonyexpression that is evaluated on the same stack by the* ``DW_OP_call*`` 2655e24f5f31STony*operations. Such executions are not a separate evaluation of an operation 2656e24f5f31STonyexpression, but rather the continued evaluation of the same operation expression 2657e24f5f31STonythat contains the* ``DW_OP_call*`` *operation.* 2658e24f5f31STony 2659e24f5f31STonyIf a stack entry is required to be a location description L, but L has an 2660e24f5f31STonyincomplete composite location description, then the DWARF expression is 2661e24f5f31STonyill-formed. The exception is for the operations involved in incrementally 2662e24f5f31STonycreating a composite location description as described below. 2663e24f5f31STony 2664e24f5f31STony*Note that a DWARF operation expression may arbitrarily compose composite 2665e24f5f31STonylocation descriptions from any other location description, including those that 2666e24f5f31STonyhave multiple single location descriptions, and those that have composite 2667e24f5f31STonylocation descriptions.* 2668e24f5f31STony 2669e24f5f31STony*The incremental composite location description operations are defined to be 2670e24f5f31STonycompatible with the definitions in DWARF Version 5.* 2671e24f5f31STony 2672e24f5f31STony1. ``DW_OP_piece`` 2673e24f5f31STony 2674e24f5f31STony ``DW_OP_piece`` has a single unsigned LEB128 integer that represents a byte 2675e24f5f31STony size S. 2676e24f5f31STony 2677e24f5f31STony The action is based on the context: 2678e24f5f31STony 2679e24f5f31STony * If the stack is empty, then a location description L comprised of one 2680e24f5f31STony incomplete composite location description SL is pushed on the stack. 2681e24f5f31STony 2682e24f5f31STony An incomplete composite location storage LS is created with a single part 2683e24f5f31STony P. P specifies a location description PL and has a bit size of S scaled by 2684e24f5f31STony 8 (the byte size). PL is comprised of one undefined location description 2685e24f5f31STony PSL. 2686e24f5f31STony 2687e24f5f31STony SL specifies LS with a bit offset of 0. 2688e24f5f31STony 2689e24f5f31STony * Otherwise, if the top stack entry is a location description L comprised of 2690e24f5f31STony one incomplete composite location description SL, then the incomplete 2691e24f5f31STony composite location storage LS that SL specifies is updated to append a new 2692e24f5f31STony part P. P specifies a location description PL and has a bit size of S 2693e24f5f31STony scaled by 8 (the byte size). PL is comprised of one undefined location 2694e24f5f31STony description PSL. L is left on the stack. 2695e24f5f31STony 2696e24f5f31STony * Otherwise, if the top stack entry is a location description or can be 2697e24f5f31STony converted to one, then it is popped and treated as a part location 2698e24f5f31STony description PL. Then: 2699e24f5f31STony 2700e24f5f31STony * If the top stack entry (after popping PL) is a location description L 2701e24f5f31STony comprised of one incomplete composite location description SL, then the 2702e24f5f31STony incomplete composite location storage LS that SL specifies is updated to 2703e24f5f31STony append a new part P. P specifies the location description PL and has a 2704e24f5f31STony bit size of S scaled by 8 (the byte size). L is left on the stack. 2705e24f5f31STony 2706e24f5f31STony * Otherwise, a location description L comprised of one incomplete 2707e24f5f31STony composite location description SL is pushed on the stack. 2708e24f5f31STony 2709e24f5f31STony An incomplete composite location storage LS is created with a single 2710e24f5f31STony part P. P specifies the location description PL and has a bit size of S 2711e24f5f31STony scaled by 8 (the byte size). 2712e24f5f31STony 2713e24f5f31STony SL specifies LS with a bit offset of 0. 2714e24f5f31STony 2715e24f5f31STony * Otherwise, the DWARF expression is ill-formed 2716e24f5f31STony 2717e24f5f31STony *Many compilers store a single variable in sets of registers or store a 2718e24f5f31STony variable partially in memory and partially in registers.* ``DW_OP_piece`` 2719e24f5f31STony *provides a way of describing where a part of a variable is located.* 2720e24f5f31STony 2721e24f5f31STony *If a non-0 byte displacement is required, the* ``DW_OP_LLVM_offset`` 2722e24f5f31STony *operation can be used to update the location description before using it as 2723e24f5f31STony the part location description of a* ``DW_OP_piece`` *operation.* 2724e24f5f31STony 2725e24f5f31STony *The evaluation rules for the* ``DW_OP_piece`` *operation allow it to be 2726e24f5f31STony compatible with the DWARF Version 5 definition.* 2727e24f5f31STony 2728e24f5f31STony .. note:: 2729e24f5f31STony 2730e24f5f31STony Since these extensions allow location descriptions to be entries on the 27312817e21cSTony stack, a simpler operation to create composite location descriptions could 27322817e21cSTony be defined. For example, just one operation that specifies how many parts, 27332817e21cSTony and pops pairs of stack entries for the part size and location 27342817e21cSTony description. Not only would this be a simpler operation and avoid the 27352817e21cSTony complexities of incomplete composite location descriptions, but it may 27362817e21cSTony also have a smaller encoding in practice. However, the desire for 27372817e21cSTony compatibility with DWARF Version 5 is likely a stronger consideration. 2738e24f5f31STony 2739e24f5f31STony2. ``DW_OP_bit_piece`` 2740e24f5f31STony 2741e24f5f31STony ``DW_OP_bit_piece`` has two operands. The first is an unsigned LEB128 2742e24f5f31STony integer that represents the part bit size S. The second is an unsigned 2743e24f5f31STony LEB128 integer that represents a bit displacement B. 2744e24f5f31STony 2745e24f5f31STony The action is the same as for ``DW_OP_piece``, except that any part created 2746e24f5f31STony has the bit size S, and the location description PL of any created part is 2747e24f5f31STony updated as if the ``DW_OP_constu B; DW_OP_LLVM_bit_offset`` operations were 2748e24f5f31STony applied. 2749e24f5f31STony 2750e24f5f31STony ``DW_OP_bit_piece`` *is used instead of* ``DW_OP_piece`` *when the piece to 2751e24f5f31STony be assembled is not byte-sized or is not at the start of the part location 2752e24f5f31STony description.* 2753e24f5f31STony 2754e24f5f31STony *If a computed bit displacement is required, the* ``DW_OP_LLVM_bit_offset`` 2755e24f5f31STony *operation can be used to update the location description before using it as 2756e24f5f31STony the part location description of a* ``DW_OP_bit_piece`` *operation.* 2757e24f5f31STony 2758e24f5f31STony .. note:: 2759e24f5f31STony 2760e24f5f31STony The bit offset operand is not needed as ``DW_OP_LLVM_bit_offset`` can be 2761e24f5f31STony used on the part's location description. 2762e24f5f31STony 2763e24f5f31STony3. ``DW_OP_LLVM_piece_end`` *New* 2764e24f5f31STony 2765e24f5f31STony If the top stack entry is not a location description L comprised of one 2766e24f5f31STony incomplete composite location description SL, then the DWARF expression is 2767e24f5f31STony ill-formed. 2768e24f5f31STony 2769e24f5f31STony Otherwise, the incomplete composite location storage LS specified by SL is 2770e24f5f31STony updated to be a complete composite location description with the same parts. 2771e24f5f31STony 2772e24f5f31STony4. ``DW_OP_LLVM_extend`` *New* 2773e24f5f31STony 2774e24f5f31STony ``DW_OP_LLVM_extend`` has two operands. The first is an unsigned LEB128 2775e24f5f31STony integer that represents the element bit size S. The second is an unsigned 2776e24f5f31STony LEB128 integer that represents a count C. 2777e24f5f31STony 2778e24f5f31STony It pops one stack entry that must be a location description and is treated 2779e24f5f31STony as the part location description PL. 2780e24f5f31STony 2781e24f5f31STony A location description L comprised of one complete composite location 2782e24f5f31STony description SL is pushed on the stack. 2783e24f5f31STony 2784e24f5f31STony A complete composite location storage LS is created with C identical parts 2785e24f5f31STony P. Each P specifies PL and has a bit size of S. 2786e24f5f31STony 2787e24f5f31STony SL specifies LS with a bit offset of 0. 2788e24f5f31STony 2789e24f5f31STony The DWARF expression is ill-formed if the element bit size or count are 0. 2790e24f5f31STony 2791e24f5f31STony5. ``DW_OP_LLVM_select_bit_piece`` *New* 2792e24f5f31STony 2793e24f5f31STony ``DW_OP_LLVM_select_bit_piece`` has two operands. The first is an unsigned 2794e24f5f31STony LEB128 integer that represents the element bit size S. The second is an 2795e24f5f31STony unsigned LEB128 integer that represents a count C. 2796e24f5f31STony 2797e24f5f31STony It pops three stack entries. The first must be an integral type value that 2798e24f5f31STony represents a bit mask value M. The second must be a location description 2799e24f5f31STony that represents the one-location description L1. The third must be a 2800e24f5f31STony location description that represents the zero-location description L0. 2801e24f5f31STony 2802e24f5f31STony A complete composite location storage LS is created with C parts P\ :sub:`N` 2803e24f5f31STony ordered in ascending N from 0 to C-1 inclusive. Each P\ :sub:`N` specifies 2804e24f5f31STony location description PL\ :sub:`N` and has a bit size of S. 2805e24f5f31STony 2806e24f5f31STony PL\ :sub:`N` is as if the ``DW_OP_LLVM_bit_offset N*S`` operation was 2807e24f5f31STony applied to PLX\ :sub:`N`\ . 2808e24f5f31STony 2809e24f5f31STony PLX\ :sub:`N` is the same as L0 if the N\ :sup:`th` least significant bit of 2810e24f5f31STony M is a zero, otherwise it is the same as L1. 2811e24f5f31STony 2812e24f5f31STony A location description L comprised of one complete composite location 2813e24f5f31STony description SL is pushed on the stack. SL specifies LS with a bit offset of 2814e24f5f31STony 0. 2815e24f5f31STony 2816e24f5f31STony The DWARF expression is ill-formed if S or C are 0, or if the bit size of M 2817e24f5f31STony is less than C. 2818e24f5f31STony 28198ba5043dSTony Tye6. ``DW_OP_LLVM_overlay`` *New* 28208ba5043dSTony Tye 28218ba5043dSTony Tye ``DW_OP_LLVM_overlay`` pops four stack entries. The first must be an 28228ba5043dSTony Tye integral type value that represents the overlay byte size value S. The 28238ba5043dSTony Tye second must be an integral type value that represents the overlay byte 28248ba5043dSTony Tye offset value O. The third must be a location description that represents the 28258ba5043dSTony Tye overlay location description OL. The fourth must be a location description 28268ba5043dSTony Tye that represents the base location description BL. 28278ba5043dSTony Tye 28288ba5043dSTony Tye The action is the same as for ``DW_OP_LLVM_bit_overlay``, except that the 28298ba5043dSTony Tye overlay bit size BS and overlay bit offset BO used are S and O respectively 28308ba5043dSTony Tye scaled by 8 (the byte size). 28318ba5043dSTony Tye 28328ba5043dSTony Tye7. ``DW_OP_LLVM_bit_overlay`` *New* 28338ba5043dSTony Tye 28348ba5043dSTony Tye ``DW_OP_LLVM_bit_overlay`` pops four stack entries. The first must be an 28358ba5043dSTony Tye integral type value that represents the overlay bit size value BS. The 28368ba5043dSTony Tye second must be an integral type value that represents the overlay bit offset 28378ba5043dSTony Tye value BO. The third must be a location description that represents the 28388ba5043dSTony Tye overlay location description OL. The fourth must be a location description 28398ba5043dSTony Tye that represents the base location description BL. 28408ba5043dSTony Tye 28418ba5043dSTony Tye The DWARF expression is ill-formed if BS or BO are negative values. 28428ba5043dSTony Tye 28438ba5043dSTony Tye *rbss(L)* is the minimum remaining bit storage size of L which is defined as 28448ba5043dSTony Tye follows. LS is the location storage and LO is the location bit offset 28458ba5043dSTony Tye specified by a single location descriptions SL of L. The remaining bit 28468ba5043dSTony Tye storage size RBSS of SL is the bit size of LS minus LO. *rbss(L)* is the 28478ba5043dSTony Tye minimum RBSS of each single location description SL of L. 28488ba5043dSTony Tye 28498ba5043dSTony Tye The DWARF expression is ill-formed if *rbss(BL)* is less than BO plus BS. 28508ba5043dSTony Tye 28518ba5043dSTony Tye If BS is 0, then the operation pushes BL. 28528ba5043dSTony Tye 28538ba5043dSTony Tye If BO is 0 and BS equals *rbss(BL)*, then the operation pushes OL. 28548ba5043dSTony Tye 28558ba5043dSTony Tye Otherwise, the operation is equivalent to performing the following steps to 28568ba5043dSTony Tye push a composite location description. 28578ba5043dSTony Tye 28588ba5043dSTony Tye *The composite location description is conceptually the base location 28598ba5043dSTony Tye description BL with the overlay location description OL positioned as an 28608ba5043dSTony Tye overlay starting at the overlay offset BO and covering overlay bit size BS.* 28618ba5043dSTony Tye 28628ba5043dSTony Tye 1. If BO is not 0 then push BL followed by performing the ``DW_OP_bit_piece 28638ba5043dSTony Tye BO`` operation. 28648ba5043dSTony Tye 2. Push OL followed by performing the ``DW_OP_bit_piece BS`` operation. 28658ba5043dSTony Tye 3. If *rbss(BL)* is greater than BO plus BS, push BL followed by performing 28668ba5043dSTony Tye the ``DW_OP_LLVM_bit_offset (BO + BS); DW_OP_bit_piece (rbss(BL) - BO - 28678ba5043dSTony Tye BS)`` operations. 28688ba5043dSTony Tye 4. Perform the ``DW_OP_LLVM_piece_end`` operation. 28698ba5043dSTony Tye 2870e24f5f31STony.. _amdgpu-dwarf-location-list-expressions: 2871e24f5f31STony 28720ac939f3STony TyeA.2.5.5 DWARF Location List Expressions 28730ac939f3STony Tye+++++++++++++++++++++++++++++++++++++++ 28740ac939f3STony Tye 28750ac939f3STony Tye.. note:: 28760ac939f3STony Tye 28770ac939f3STony Tye This section replaces DWARF Version 5 section 2.6.2. 2878e24f5f31STony 2879e24f5f31STony*To meet the needs of recent computer architectures and optimization techniques, 2880e24f5f31STonydebugging information must be able to describe the location of an object whose 2881e24f5f31STonylocation changes over the object’s lifetime, and may reside at multiple 2882e24f5f31STonylocations during parts of an object's lifetime. Location list expressions are 2883e24f5f31STonyused in place of operation expressions whenever the object whose location is 2884e24f5f31STonybeing described has these requirements.* 2885e24f5f31STony 2886e24f5f31STonyA location list expression consists of a series of location list entries. Each 2887e24f5f31STonylocation list entry is one of the following kinds: 2888e24f5f31STony 2889e24f5f31STony*Bounded location description* 2890e24f5f31STony 2891e24f5f31STony This kind of location list entry provides an operation expression that 2892e24f5f31STony evaluates to the location description of an object that is valid over a 2893e24f5f31STony lifetime bounded by a starting and ending address. The starting address is the 2894e24f5f31STony lowest address of the address range over which the location is valid. The 2895e24f5f31STony ending address is the address of the first location past the highest address 2896e24f5f31STony of the address range. 2897e24f5f31STony 2898e24f5f31STony The location list entry matches when the current program location is within 2899e24f5f31STony the given range. 2900e24f5f31STony 2901e24f5f31STony There are several kinds of bounded location description entries which differ 2902e24f5f31STony in the way that they specify the starting and ending addresses. 2903e24f5f31STony 2904e24f5f31STony*Default location description* 2905e24f5f31STony 2906e24f5f31STony This kind of location list entry provides an operation expression that 2907e24f5f31STony evaluates to the location description of an object that is valid when no 2908e24f5f31STony bounded location description entry applies. 2909e24f5f31STony 2910e24f5f31STony The location list entry matches when the current program location is not 2911e24f5f31STony within the range of any bounded location description entry. 2912e24f5f31STony 2913e24f5f31STony*Base address* 2914e24f5f31STony 2915e24f5f31STony This kind of location list entry provides an address to be used as the base 2916e24f5f31STony address for beginning and ending address offsets given in certain kinds of 2917e24f5f31STony bounded location description entries. The applicable base address of a bounded 2918e24f5f31STony location description entry is the address specified by the closest preceding 2919e24f5f31STony base address entry in the same location list. If there is no preceding base 2920e24f5f31STony address entry, then the applicable base address defaults to the base address 2921e24f5f31STony of the compilation unit (see DWARF Version 5 section 3.1.1). 2922e24f5f31STony 2923e24f5f31STony In the case of a compilation unit where all of the machine code is contained 2924e24f5f31STony in a single contiguous section, no base address entry is needed. 2925e24f5f31STony 2926e24f5f31STony*End-of-list* 2927e24f5f31STony 2928e24f5f31STony This kind of location list entry marks the end of the location list 2929e24f5f31STony expression. 2930e24f5f31STony 2931e24f5f31STonyThe address ranges defined by the bounded location description entries of a 2932e24f5f31STonylocation list expression may overlap. When they do, they describe a situation in 2933e24f5f31STonywhich an object exists simultaneously in more than one place. 2934e24f5f31STony 2935e24f5f31STonyIf all of the address ranges in a given location list expression do not 2936e24f5f31STonycollectively cover the entire range over which the object in question is 2937e24f5f31STonydefined, and there is no following default location description entry, it is 2938e24f5f31STonyassumed that the object is not available for the portion of the range that is 2939e24f5f31STonynot covered. 2940e24f5f31STony 2941e24f5f31STonyThe result of the evaluation of a DWARF location list expression is: 2942e24f5f31STony 2943e24f5f31STony* If the current program location is not specified, then it is an evaluation 2944e24f5f31STony error. 2945e24f5f31STony 2946e24f5f31STony .. note:: 2947e24f5f31STony 2948e24f5f31STony If the location list only has a single default entry, should that be 2949e24f5f31STony considered a match if there is no program location? If there are non-default 2950e24f5f31STony entries then it seems it has to be an evaluation error when there is no 2951e24f5f31STony program location as that indicates the location depends on the program 2952e24f5f31STony location which is not known. 2953e24f5f31STony 2954e24f5f31STony* If there are no matching location list entries, then the result is a location 2955e24f5f31STony description that comprises one undefined location description. 2956e24f5f31STony 2957e24f5f31STony* Otherwise, the operation expression E of each matching location list entry is 2958e24f5f31STony evaluated with the current context, except that the result kind is a location 2959e24f5f31STony description, the object is unspecified, and the initial stack is empty. The 2960e24f5f31STony location list entry result is the location description returned by the 2961e24f5f31STony evaluation of E. 2962e24f5f31STony 2963e24f5f31STony The result is a location description that is comprised of the union of the 2964e24f5f31STony single location descriptions of the location description result of each 2965e24f5f31STony matching location list entry. 2966e24f5f31STony 2967e24f5f31STonyA location list expression can only be used as the value of a debugger 2968e24f5f31STonyinformation entry attribute that is encoded using class ``loclist`` or 29690ac939f3STony Tye``loclistsptr`` (see :ref:`amdgpu-dwarf-classes-and-forms`). The value of the 29700ac939f3STony Tyeattribute provides an index into a separate object file section called 29710ac939f3STony Tye``.debug_loclists`` or ``.debug_loclists.dwo`` (for split DWARF object files) 29720ac939f3STony Tyethat contains the location list entries. 2973e24f5f31STony 2974e24f5f31STonyA ``DW_OP_call*`` and ``DW_OP_implicit_pointer`` operation can be used to 2975e24f5f31STonyspecify a debugger information entry attribute that has a location list 2976e24f5f31STonyexpression. Several debugger information entry attributes allow DWARF 2977e24f5f31STonyexpressions that are evaluated with an initial stack that includes a location 2978e24f5f31STonydescription that may originate from the evaluation of a location list 2979e24f5f31STonyexpression. 2980e24f5f31STony 2981e24f5f31STony*This location list representation, the* ``loclist`` *and* ``loclistsptr`` 2982e24f5f31STony*class, and the related* ``DW_AT_loclists_base`` *attribute are new in DWARF 2983e24f5f31STonyVersion 5. Together they eliminate most, or all of the code object relocations 2984e24f5f31STonypreviously needed for location list expressions.* 2985e24f5f31STony 2986e24f5f31STony.. note:: 2987e24f5f31STony 2988e24f5f31STony The rest of this section is the same as DWARF Version 5 section 2.6.2. 2989e24f5f31STony 2990e24f5f31STony.. _amdgpu-dwarf-segment_addresses: 2991e24f5f31STony 29920ac939f3STony TyeA.2.12 Segmented Addresses 29930ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994e24f5f31STony 2995e24f5f31STony.. note:: 2996e24f5f31STony 2997e24f5f31STony This augments DWARF Version 5 section 2.12. 2998e24f5f31STony 2999e24f5f31STonyDWARF address classes are used for source languages that have the concept of 3000e24f5f31STonymemory spaces. They are used in the ``DW_AT_address_class`` attribute for 3001e24f5f31STonypointer type, reference type, subprogram, and subprogram type debugger 3002e24f5f31STonyinformation entries. 3003e24f5f31STony 3004e24f5f31STonyEach DWARF address class is conceptually a separate source language memory space 3005e24f5f31STonywith its own lifetime and aliasing rules. DWARF address classes are used to 3006e24f5f31STonyspecify the source language memory spaces that pointer type and reference type 3007e24f5f31STonyvalues refer, and to specify the source language memory space in which variables 3008e24f5f31STonyare allocated. 3009e24f5f31STony 3010e24f5f31STonyThe set of currently defined source language DWARF address classes, together 3011e24f5f31STonywith source language mappings, is given in 3012e24f5f31STony:ref:`amdgpu-dwarf-address-class-table`. 3013e24f5f31STony 3014e24f5f31STonyVendor defined source language address classes may be defined using codes in the 3015e24f5f31STonyrange ``DW_ADDR_LLVM_lo_user`` to ``DW_ADDR_LLVM_hi_user``. 3016e24f5f31STony 3017e24f5f31STony.. table:: Address class 3018e24f5f31STony :name: amdgpu-dwarf-address-class-table 3019e24f5f31STony 3020e24f5f31STony ========================= ============ ========= ========= ========= 3021e24f5f31STony Address Class Name Meaning C/C++ OpenCL CUDA/HIP 3022e24f5f31STony ========================= ============ ========= ========= ========= 3023e24f5f31STony ``DW_ADDR_none`` generic *default* generic *default* 3024e24f5f31STony ``DW_ADDR_LLVM_global`` global global 3025e24f5f31STony ``DW_ADDR_LLVM_constant`` constant constant constant 3026e24f5f31STony ``DW_ADDR_LLVM_group`` thread-group local shared 3027e24f5f31STony ``DW_ADDR_LLVM_private`` thread private 3028e24f5f31STony ``DW_ADDR_LLVM_lo_user`` 3029e24f5f31STony ``DW_ADDR_LLVM_hi_user`` 3030e24f5f31STony ========================= ============ ========= ========= ========= 3031e24f5f31STony 3032e24f5f31STonyDWARF address spaces correspond to target architecture specific linear 3033e24f5f31STonyaddressable memory areas. They are used in DWARF expression location 3034e24f5f31STonydescriptions to describe in which target architecture specific memory area data 3035e24f5f31STonyresides. 3036e24f5f31STony 3037e24f5f31STony*Target architecture specific DWARF address spaces may correspond to hardware 3038e24f5f31STonysupported facilities such as memory utilizing base address registers, scratchpad 3039e24f5f31STonymemory, and memory with special interleaving. The size of addresses in these 3040e24f5f31STonyaddress spaces may vary. Their access and allocation may be hardware managed 3041e24f5f31STonywith each thread or group of threads having access to independent storage. For 3042e24f5f31STonythese reasons they may have properties that do not allow them to be viewed as 3043e24f5f31STonypart of the unified global virtual address space accessible by all threads.* 3044e24f5f31STony 3045e24f5f31STony*It is target architecture specific whether multiple DWARF address spaces are 3046e24f5f31STonysupported and how source language DWARF address classes map to target 3047e24f5f31STonyarchitecture specific DWARF address spaces. A target architecture may map 3048e24f5f31STonymultiple source language DWARF address classes to the same target architecture 3049e24f5f31STonyspecific DWARF address class. Optimization may determine that variable lifetime 3050e24f5f31STonyand access pattern allows them to be allocated in faster scratchpad memory 3051e24f5f31STonyrepresented by a different DWARF address space.* 3052e24f5f31STony 3053e24f5f31STonyAlthough DWARF address space identifiers are target architecture specific, 3054e24f5f31STony``DW_ASPACE_none`` is a common address space supported by all target 3055e24f5f31STonyarchitectures. 3056e24f5f31STony 3057e24f5f31STonyDWARF address space identifiers are used by: 3058e24f5f31STony 3059f2bb4b88SYangZhihui* The DWARF expression operations: ``DW_OP_LLVM_aspace_bregx``, 3060e24f5f31STony ``DW_OP_LLVM_form_aspace_address``, ``DW_OP_LLVM_implicit_aspace_pointer``, 3061e24f5f31STony and ``DW_OP_xderef*``. 3062e24f5f31STony 3063231f4182STony Tye* The CFI instructions: ``DW_CFA_LLVM_def_aspace_cfa`` and 3064231f4182STony Tye ``DW_CFA_LLVM_def_aspace_cfa_sf``. 3065e24f5f31STony 3066e24f5f31STony.. note:: 3067e24f5f31STony 3068e24f5f31STony With the definition of DWARF address classes and DWARF address spaces in these 3069e24f5f31STony extensions, DWARF Version 5 table 2.7 needs to be updated. It seems it is an 3070e24f5f31STony example of DWARF address spaces and not DWARF address classes. 3071e24f5f31STony 3072e24f5f31STony.. note:: 3073e24f5f31STony 3074e24f5f31STony With the expanded support for DWARF address spaces in these extensions, it may 3075e24f5f31STony be worth examining if DWARF segments can be eliminated and DWARF address 3076e24f5f31STony spaces used instead. 3077e24f5f31STony 3078e24f5f31STony That may involve extending DWARF address spaces to also be used to specify 3079e24f5f31STony code locations. In target architectures that use different memory areas for 3080e24f5f31STony code and data this would seem a natural use for DWARF address spaces. This 3081e24f5f31STony would allow DWARF expression location descriptions to be used to describe the 3082e24f5f31STony location of subprograms and entry points that are used in expressions 3083e24f5f31STony involving subprogram pointer type values. 3084e24f5f31STony 3085e24f5f31STony Currently, DWARF expressions assume data and code resides in the same default 3086e24f5f31STony DWARF address space, and only the address ranges in DWARF location list 3087e24f5f31STony entries and in the ``.debug_aranges`` section for accelerated access for 3088e24f5f31STony addresses allow DWARF segments to be used to distinguish. 3089e24f5f31STony 3090e24f5f31STony.. note:: 3091e24f5f31STony 3092e24f5f31STony Currently, DWARF defines address class values as being target architecture 3093e24f5f31STony specific. It is unclear how language specific memory spaces are intended to be 3094e24f5f31STony represented in DWARF using these. 3095e24f5f31STony 3096e24f5f31STony For example, OpenCL defines memory spaces (called address spaces in OpenCL) 3097e24f5f31STony for ``global``, ``local``, ``constant``, and ``private``. These are part of 3098e24f5f31STony the type system and are modifiers to pointer types. In addition, OpenCL 3099e24f5f31STony defines ``generic`` pointers that can reference either the ``global``, 3100e24f5f31STony ``local``, or ``private`` memory spaces. To support the OpenCL language the 3101e24f5f31STony debugger would want to support casting pointers between the ``generic`` and 3102e24f5f31STony other memory spaces, querying what memory space a ``generic`` pointer value is 3103e24f5f31STony currently referencing, and possibly using pointer casting to form an address 3104e24f5f31STony for a specific memory space out of an integral value. 3105e24f5f31STony 3106e24f5f31STony The method to use to dereference a pointer type or reference type value is 3107e24f5f31STony defined in DWARF expressions using ``DW_OP_xderef*`` which uses a target 3108e24f5f31STony architecture specific address space. 3109e24f5f31STony 3110e24f5f31STony DWARF defines the ``DW_AT_address_class`` attribute on pointer type and 3111e24f5f31STony reference type debugger information entries. It specifies the method to use to 3112e24f5f31STony dereference them. Why is the value of this not the same as the address space 3113e24f5f31STony value used in ``DW_OP_xderef*``? In both cases it is target architecture 3114e24f5f31STony specific and the architecture presumably will use the same set of methods to 3115e24f5f31STony dereference pointers in both cases. 3116e24f5f31STony 3117e24f5f31STony Since ``DW_AT_address_class`` uses a target architecture specific value, it 3118e24f5f31STony cannot in general capture the source language memory space type modifier 3119e24f5f31STony concept. On some architectures all source language memory space modifiers may 3120e24f5f31STony actually use the same method for dereferencing pointers. 3121e24f5f31STony 3122e24f5f31STony One possibility is for DWARF to add an ``DW_TAG_LLVM_address_class_type`` 3123e24f5f31STony debugger information entry type modifier that can be applied to a pointer type 3124e24f5f31STony and reference type. The ``DW_AT_address_class`` attribute could be re-defined 3125e24f5f31STony to not be target architecture specific and instead define generalized language 3126e24f5f31STony values (as presented above for DWARF address classes in the table 3127e24f5f31STony :ref:`amdgpu-dwarf-address-class-table`) that will support OpenCL and other 3128e24f5f31STony languages using memory spaces. The ``DW_AT_address_class`` attribute could be 3129e24f5f31STony defined to not be applied to pointer types or reference types, but instead 3130e24f5f31STony only to the new ``DW_TAG_LLVM_address_class_type`` type modifier debugger 3131e24f5f31STony information entry. 3132e24f5f31STony 3133e24f5f31STony If a pointer type or reference type is not modified by 3134e24f5f31STony ``DW_TAG_LLVM_address_class_type`` or if ``DW_TAG_LLVM_address_class_type`` 3135e24f5f31STony has no ``DW_AT_address_class`` attribute, then the pointer type or reference 3136e24f5f31STony type would be defined to use the ``DW_ADDR_none`` address class as currently. 3137e24f5f31STony Since modifiers can be chained, it would need to be defined if multiple 3138e24f5f31STony ``DW_TAG_LLVM_address_class_type`` modifiers were legal, and if so if the 3139e24f5f31STony outermost one is the one that takes precedence. 3140e24f5f31STony 3141e24f5f31STony A target architecture implementation that supports multiple address spaces 3142e24f5f31STony would need to map ``DW_ADDR_none`` appropriately to support CUDA-like 3143e24f5f31STony languages that have no address classes in the type system but do support 3144e24f5f31STony variable allocation in address classes. Such variable allocation would result 3145e24f5f31STony in the variable's location description needing an address space. 3146e24f5f31STony 3147e24f5f31STony The approach presented in :ref:`amdgpu-dwarf-address-class-table` is to define 3148e24f5f31STony the default ``DW_ADDR_none`` to be the generic address class and not the 3149e24f5f31STony global address class. This matches how CLANG and LLVM have added support for 3150e24f5f31STony CUDA-like languages on top of existing C++ language support. This allows all 3151e24f5f31STony addresses to be generic by default which matches CUDA-like languages. 3152e24f5f31STony 3153e24f5f31STony An alternative approach is to define ``DW_ADDR_none`` as being the global 3154e24f5f31STony address class and then change ``DW_ADDR_LLVM_global`` to 3155e24f5f31STony ``DW_ADDR_LLVM_generic``. This would match the reality that languages that do 3156e24f5f31STony not support multiple memory spaces only have one default global memory space. 3157e24f5f31STony Generally, in these languages if they expose that the target architecture 3158e24f5f31STony supports multiple address spaces, the default one is still the global memory 3159e24f5f31STony space. Then a language that does support multiple memory spaces has to 3160e24f5f31STony explicitly indicate which pointers have the added ability to reference more 3161e24f5f31STony than the global memory space. However, compilers generating DWARF for 3162e24f5f31STony CUDA-like languages would then have to define every CUDA-like language pointer 3163e24f5f31STony type or reference type using ``DW_TAG_LLVM_address_class_type`` with a 3164e24f5f31STony ``DW_AT_address_class`` attribute of ``DW_ADDR_LLVM_generic`` to match the 3165e24f5f31STony language semantics. 3166e24f5f31STony 3167e24f5f31STony A new ``DW_AT_LLVM_address_space`` attribute could be defined that can be 3168e24f5f31STony applied to pointer type, reference type, subprogram, and subprogram type to 3169e24f5f31STony describe how objects having the given type are dereferenced or called (the 3170e24f5f31STony role that ``DW_AT_address_class`` currently provides). The values of 3171*5d2cc4d8SVenkata Ramanaiah Nalamothu ``DW_AT_LLVM_address_space`` would be target architecture specific and the 3172*5d2cc4d8SVenkata Ramanaiah Nalamothu same as used in ``DW_OP_xderef*``. 3173e24f5f31STony 3174e24f5f31STony.. note:: 3175e24f5f31STony 3176e24f5f31STony Some additional changes will be made to support languages such as OpenCL/SyCL 3177e24f5f31STony that allow address class pointer casting and queries. 3178e24f5f31STony 3179e24f5f31STony This requires the compiler to provide the mapping from address space to 3180e24f5f31STony address class which may be runtime and not target architecture dependent. Some 3181e24f5f31STony implementations may have a one-to-one mapping from source language address 3182e24f5f31STony class to target architecture address space, and some may have a many-to-one 3183e24f5f31STony mapping which requires knowledge of the address class when determining if 3184e24f5f31STony pointer address class casts are allowed. 3185e24f5f31STony 3186e24f5f31STony The changes will likely add an attribute that has an expression provided by 3187e24f5f31STony the compiler to map from address class to address space. The 3188e24f5f31STony ``DW_OP_implicit_pointer`` and ``DW_OP_LLVM_aspace_implicit_pointer`` 3189e24f5f31STony operations may be changed as the current IPV definition may not provide enough 3190e24f5f31STony information when used to cast between address classes. Other attributes and 3191e24f5f31STony operations may be needed. The legal casts between address classes may need to 3192e24f5f31STony be defined on a per language address class basis. 3193e24f5f31STony 31940ac939f3STony TyeA.3 Program Scope Entries 31950ac939f3STony Tye------------------------- 3196e24f5f31STony 3197e24f5f31STony.. note:: 3198e24f5f31STony 3199e24f5f31STony This section provides changes to existing debugger information entry 32000ac939f3STony Tye attributes. These would be incorporated into the corresponding DWARF Version 5 32010ac939f3STony Tye chapter 3 sections. 3202e24f5f31STony 32030ac939f3STony TyeA.3.1 Unit Entries 32040ac939f3STony Tye~~~~~~~~~~~~~~~~~~ 3205e24f5f31STony 32060ac939f3STony Tye.. _amdgpu-dwarf-full-and-partial-compilation-unit-entries: 32070ac939f3STony Tye 32080ac939f3STony TyeA.3.1.1 Full and Partial Compilation Unit Entries 32090ac939f3STony Tye+++++++++++++++++++++++++++++++++++++++++++++++++ 32100ac939f3STony Tye 32110ac939f3STony Tye.. note:: 32120ac939f3STony Tye 32130ac939f3STony Tye This augments DWARF Version 5 section 3.1.1 and Table 3.1. 32140ac939f3STony Tye 32150ac939f3STony TyeAdditional language codes defined for use with the ``DW_AT_language`` attribute 32160ac939f3STony Tyeare defined in :ref:`amdgpu-dwarf-language-names-table`. 32170ac939f3STony Tye 32180ac939f3STony Tye.. table:: Language Names 32190ac939f3STony Tye :name: amdgpu-dwarf-language-names-table 32200ac939f3STony Tye 32210ac939f3STony Tye ==================== ============================= 32220ac939f3STony Tye Language Name Meaning 32230ac939f3STony Tye ==================== ============================= 32240ac939f3STony Tye ``DW_LANG_LLVM_HIP`` HIP Language. 32250ac939f3STony Tye ==================== ============================= 32260ac939f3STony Tye 32270ac939f3STony TyeThe HIP language [:ref:`HIP <amdgpu-dwarf-HIP>`] can be supported by extending 32280ac939f3STony Tyethe C++ language. 32290ac939f3STony Tye 32300ac939f3STony Tye.. note:: 32310ac939f3STony Tye 32320ac939f3STony Tye The following new attribute is added. 32330ac939f3STony Tye 32340ac939f3STony Tye1. A ``DW_TAG_compile_unit`` debugger information entry for a compilation unit 32350ac939f3STony Tye may have a ``DW_AT_LLVM_augmentation`` attribute, whose value is an 32360ac939f3STony Tye augmentation string. 32370ac939f3STony Tye 32380ac939f3STony Tye *The augmentation string allows producers to indicate that there is 32390ac939f3STony Tye additional vendor or target specific information in the debugging 32400ac939f3STony Tye information entries. For example, this might be information about the 32410ac939f3STony Tye version of vendor specific extensions that are being used.* 32420ac939f3STony Tye 32430ac939f3STony Tye If not present, or if the string is empty, then the compilation unit has no 32440ac939f3STony Tye augmentation string. 32450ac939f3STony Tye 32460ac939f3STony Tye The format for the augmentation string is: 32470ac939f3STony Tye 32480ac939f3STony Tye | ``[``\ *vendor*\ ``:v``\ *X*\ ``.``\ *Y*\ [\ ``:``\ *options*\ ]\ ``]``\ * 32490ac939f3STony Tye 32500ac939f3STony Tye Where *vendor* is the producer, ``vX.Y`` specifies the major X and minor Y 32510ac939f3STony Tye version number of the extensions used, and *options* is an optional string 32520ac939f3STony Tye providing additional information about the extensions. The version number 32530ac939f3STony Tye must conform to semantic versioning [:ref:`SEMVER <amdgpu-dwarf-SEMVER>`]. 32540ac939f3STony Tye The *options* string must not contain the "\ ``]``\ " character. 32550ac939f3STony Tye 32560ac939f3STony Tye For example: 32570ac939f3STony Tye 32580ac939f3STony Tye :: 32590ac939f3STony Tye 32600ac939f3STony Tye [abc:v0.0][def:v1.2:feature-a=on,feature-b=3] 32610ac939f3STony Tye 32620ac939f3STony TyeA.3.3 Subroutine and Entry Point Entries 32630ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 32640ac939f3STony Tye 32650ac939f3STony Tye.. _amdgpu-dwarf-low-level-information: 32660ac939f3STony Tye 32670ac939f3STony TyeA.3.3.5 Low-Level Information 32680ac939f3STony Tye+++++++++++++++++++++++++++++ 32690ac939f3STony Tye 32700ac939f3STony Tye1. A ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or 32710ac939f3STony Tye ``DW_TAG_entry_point`` debugger information entry may have a 32720ac939f3STony Tye ``DW_AT_return_addr`` attribute, whose value is a DWARF expression E. 32730ac939f3STony Tye 32740ac939f3STony Tye The result of the attribute is obtained by evaluating E with a context that 32750ac939f3STony Tye has a result kind of a location description, an unspecified object, the 32760ac939f3STony Tye compilation unit that contains E, an empty initial stack, and other context 32770ac939f3STony Tye elements corresponding to the source language thread of execution upon which 32780ac939f3STony Tye the user is focused, if any. The result of the evaluation is the location 32790ac939f3STony Tye description L of the place where the return address for the current call 32800ac939f3STony Tye frame's subprogram or entry point is stored. 32810ac939f3STony Tye 32820ac939f3STony Tye The DWARF is ill-formed if L is not comprised of one memory location 32830ac939f3STony Tye description for one of the target architecture specific address spaces. 32840ac939f3STony Tye 32850ac939f3STony Tye .. note:: 32860ac939f3STony Tye 32870ac939f3STony Tye It is unclear why ``DW_TAG_inlined_subroutine`` has a 32880ac939f3STony Tye ``DW_AT_return_addr`` attribute but not a ``DW_AT_frame_base`` or 32890ac939f3STony Tye ``DW_AT_static_link`` attribute. Seems it would either have all of them or 32900ac939f3STony Tye none. Since inlined subprograms do not have a call frame it seems they 32910ac939f3STony Tye would have none of these attributes. 32920ac939f3STony Tye 32930ac939f3STony Tye2. A ``DW_TAG_subprogram`` or ``DW_TAG_entry_point`` debugger information entry 32940ac939f3STony Tye may have a ``DW_AT_frame_base`` attribute, whose value is a DWARF expression 32950ac939f3STony Tye E. 32960ac939f3STony Tye 32970ac939f3STony Tye The result of the attribute is obtained by evaluating E with a context that 32980ac939f3STony Tye has a result kind of a location description, an unspecified object, the 32990ac939f3STony Tye compilation unit that contains E, an empty initial stack, and other context 33000ac939f3STony Tye elements corresponding to the source language thread of execution upon which 33010ac939f3STony Tye the user is focused, if any. 33020ac939f3STony Tye 33030ac939f3STony Tye The DWARF is ill-formed if E contains an ``DW_OP_fbreg`` operation, or the 33040ac939f3STony Tye resulting location description L is not comprised of one single location 33050ac939f3STony Tye description SL. 33060ac939f3STony Tye 33070ac939f3STony Tye If SL is a register location description for register R, then L is replaced 33080ac939f3STony Tye with the result of evaluating a ``DW_OP_bregx R, 0`` operation. This 33090ac939f3STony Tye computes the frame base memory location description in the target 33100ac939f3STony Tye architecture default address space. 33110ac939f3STony Tye 33120ac939f3STony Tye *This allows the more compact* ``DW_OP_reg*`` *to be used instead of* 33130ac939f3STony Tye ``DW_OP_breg* 0``\ *.* 33140ac939f3STony Tye 33150ac939f3STony Tye .. note:: 33160ac939f3STony Tye 33170ac939f3STony Tye This rule could be removed and require the producer to create the required 33180ac939f3STony Tye location description directly using ``DW_OP_call_frame_cfa``, 33190ac939f3STony Tye ``DW_OP_breg*``, or ``DW_OP_LLVM_aspace_bregx``. This would also then 33200ac939f3STony Tye allow a target to implement the call frames within a large register. 33210ac939f3STony Tye 33220ac939f3STony Tye Otherwise, the DWARF is ill-formed if SL is not a memory location 33230ac939f3STony Tye description in any of the target architecture specific address spaces. 33240ac939f3STony Tye 33250ac939f3STony Tye The resulting L is the *frame base* for the subprogram or entry point. 33260ac939f3STony Tye 33270ac939f3STony Tye *Typically, E will use the* ``DW_OP_call_frame_cfa`` *operation or be a 33280ac939f3STony Tye stack pointer register plus or minus some offset.* 33290ac939f3STony Tye 33300ac939f3STony Tye3. If a ``DW_TAG_subprogram`` or ``DW_TAG_entry_point`` debugger information 33310ac939f3STony Tye entry is lexically nested, it may have a ``DW_AT_static_link`` attribute, 33320ac939f3STony Tye whose value is a DWARF expression E. 33330ac939f3STony Tye 33340ac939f3STony Tye The result of the attribute is obtained by evaluating E with a context that 33350ac939f3STony Tye has a result kind of a location description, an unspecified object, the 33360ac939f3STony Tye compilation unit that contains E, an empty initial stack, and other context 33370ac939f3STony Tye elements corresponding to the source language thread of execution upon which 33380ac939f3STony Tye the user is focused, if any. The result of the evaluation is the location 33390ac939f3STony Tye description L of the *canonical frame address* (see 33400ac939f3STony Tye :ref:`amdgpu-dwarf-call-frame-information`) of the relevant call frame of 33410ac939f3STony Tye the subprogram instance that immediately lexically encloses the current call 33420ac939f3STony Tye frame's subprogram or entry point. 33430ac939f3STony Tye 33440ac939f3STony Tye The DWARF is ill-formed if L is is not comprised of one memory location 33450ac939f3STony Tye description for one of the target architecture specific address spaces. 33460ac939f3STony Tye 33470ac939f3STony Tye .. note:: 33480ac939f3STony Tye 33490ac939f3STony Tye The following new attributes are added. 33500ac939f3STony Tye 33518ba5043dSTony Tye4. For languages that are implemented using a SIMT execution model, a 33520ac939f3STony Tye ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or 33530ac939f3STony Tye ``DW_TAG_entry_point`` debugger information entry may have a 33540ac939f3STony Tye ``DW_AT_LLVM_lanes`` attribute whose value is an integer constant that is 33558ba5043dSTony Tye the number of source language threads of execution per target architecture 33568ba5043dSTony Tye thread. 33578ba5043dSTony Tye 33588ba5043dSTony Tye *For example, a compiler may map source language threads of execution onto 33598ba5043dSTony Tye lanes of a target architecture thread using a SIMT execution model.* 33608ba5043dSTony Tye 33618ba5043dSTony Tye It is the static number of source language threads of execution per target 33628ba5043dSTony Tye architecture thread. It is not the dynamic number of source language threads 33638ba5043dSTony Tye of execution with which the target architecture thread was initiated, for 33648ba5043dSTony Tye example, due to smaller or partial work-groups. 33650ac939f3STony Tye 33660ac939f3STony Tye If not present, the default value of 1 is used. 33670ac939f3STony Tye 33688ba5043dSTony Tye The DWARF is ill-formed if the value is less than or equal to 0. 33690ac939f3STony Tye 33708ba5043dSTony Tye5. For source languages that are implemented using a SIMT execution model, a 33710ac939f3STony Tye ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or 33720ac939f3STony Tye ``DW_TAG_entry_point`` debugging information entry may have a 33730ac939f3STony Tye ``DW_AT_LLVM_lane_pc`` attribute whose value is a DWARF expression E. 33740ac939f3STony Tye 33750ac939f3STony Tye The result of the attribute is obtained by evaluating E with a context that 33760ac939f3STony Tye has a result kind of a location description, an unspecified object, the 33770ac939f3STony Tye compilation unit that contains E, an empty initial stack, and other context 33780ac939f3STony Tye elements corresponding to the source language thread of execution upon which 33790ac939f3STony Tye the user is focused, if any. 33800ac939f3STony Tye 33818ba5043dSTony Tye The resulting location description L is for a lane count sized vector of 33828ba5043dSTony Tye generic type elements. The lane count is the value of the 33830ac939f3STony Tye ``DW_AT_LLVM_lanes`` attribute. Each element holds the conceptual program 33848ba5043dSTony Tye location of the corresponding lane. If the lane was not active when the 33858ba5043dSTony Tye current subprogram was called, its element is an undefined location 33868ba5043dSTony Tye description. 33878ba5043dSTony Tye 33888ba5043dSTony Tye The DWARF is ill-formed if L does not have exactly one single location 33898ba5043dSTony Tye description. 33900ac939f3STony Tye 33910ac939f3STony Tye ``DW_AT_LLVM_lane_pc`` *allows the compiler to indicate conceptually where 33928ba5043dSTony Tye each SIMT lane of a target architecture thread is positioned even when it is 33938ba5043dSTony Tye in divergent control flow that is not active.* 33940ac939f3STony Tye 33950ac939f3STony Tye *Typically, the result is a location description with one composite location 33960ac939f3STony Tye description with each part being a location description with either one 33970ac939f3STony Tye undefined location description or one memory location description.* 33980ac939f3STony Tye 33998ba5043dSTony Tye If not present, the target architecture thread is not being used in a SIMT 34008ba5043dSTony Tye manner, and the thread's current program location is used. 34010ac939f3STony Tye 34028ba5043dSTony Tye6. For languages that are implemented using a SIMT execution model, a 34030ac939f3STony Tye ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or 34040ac939f3STony Tye ``DW_TAG_entry_point`` debugger information entry may have a 34050ac939f3STony Tye ``DW_AT_LLVM_active_lane`` attribute whose value is a DWARF expression E. 34060ac939f3STony Tye 34078ba5043dSTony Tye E is evaluated with a context that has a result kind of a location 34088ba5043dSTony Tye description, an unspecified object, the compilation unit that contains E, an 34098ba5043dSTony Tye empty initial stack, and other context elements corresponding to the source 34108ba5043dSTony Tye language thread of execution upon which the user is focused, if any. 34110ac939f3STony Tye 34128ba5043dSTony Tye The DWARF is ill-formed if L does not have exactly one single location 34138ba5043dSTony Tye description SL. 34140ac939f3STony Tye 34158ba5043dSTony Tye The active lane bit mask V for the current program location is obtained by 34168ba5043dSTony Tye reading from SL using a target architecture specific integral base type T 34178ba5043dSTony Tye that has a bit size equal to the value of the ``DW_AT_LLVM_lanes`` attribute 34188ba5043dSTony Tye of the subprogram corresponding to context's frame and program location. The 34198ba5043dSTony Tye N\ :sup:`th` least significant bit of the mask corresponds to the N\ 34208ba5043dSTony Tye :sup:`th` lane. If the bit is 1 the lane is active, otherwise it is 34218ba5043dSTony Tye inactive. The result of the attribute is the value V. 34220ac939f3STony Tye 34230ac939f3STony Tye *Some targets may update the target architecture execution mask for regions 34240ac939f3STony Tye of code that must execute with different sets of lanes than the current 34250ac939f3STony Tye active lanes. For example, some code must execute with all lanes made 34260ac939f3STony Tye temporarily active.* ``DW_AT_LLVM_active_lane`` *allows the compiler to 34278ba5043dSTony Tye provide the means to determine the source language active lanes at any 34288ba5043dSTony Tye program location. Typically, this attribute will use a loclist to express 34298ba5043dSTony Tye different locations of the active lane mask at different program locations.* 34300ac939f3STony Tye 34310ac939f3STony Tye If not present and ``DW_AT_LLVM_lanes`` is greater than 1, then the target 34320ac939f3STony Tye architecture execution mask is used. 34330ac939f3STony Tye 34348ba5043dSTony Tye7. A ``DW_TAG_subprogram``, ``DW_TAG_inlined_subroutine``, or 34358ba5043dSTony Tye ``DW_TAG_entry_point`` debugger information entry may have a 34368ba5043dSTony Tye ``DW_AT_LLVM_iterations`` attribute whose value is an integer constant or a 34378ba5043dSTony Tye DWARF expression E. Its value is the number of source language loop 34388ba5043dSTony Tye iterations executing concurrently by the target architecture for a single 34398ba5043dSTony Tye source language thread of execution. 34408ba5043dSTony Tye 34418ba5043dSTony Tye *A compiler may generate code that executes more than one iteration of a 34428ba5043dSTony Tye source language loop concurrently using optimization techniques such as 34438ba5043dSTony Tye software pipelining or SIMD vectorization. The number of concurrent 34448ba5043dSTony Tye iterations may vary for different loop nests in the same subprogram. 34458ba5043dSTony Tye Typically, this attribute will use a loclist to express different values at 34468ba5043dSTony Tye different program locations.* 34478ba5043dSTony Tye 34488ba5043dSTony Tye If the attribute is an integer constant, then the value is the constant. The 34498ba5043dSTony Tye DWARF is ill-formed if the constant is less than or equal to 0. 34508ba5043dSTony Tye 34518ba5043dSTony Tye Otherwise, E is evaluated with a context that has a result kind of a 34528ba5043dSTony Tye location description, an unspecified object, the compilation unit that 34538ba5043dSTony Tye contains E, an empty initial stack, and other context elements corresponding 34548ba5043dSTony Tye to the source language thread of execution upon which the user is focused, 34558ba5043dSTony Tye if any. The DWARF is ill-formed if the result is not a location description 34568ba5043dSTony Tye comprised of one implicit location description, that when read as the 34578ba5043dSTony Tye generic type, results in a value V that is less than or equal to 0. The 34588ba5043dSTony Tye result of the attribute is the value V. 34598ba5043dSTony Tye 34608ba5043dSTony Tye If not present, the default value of 1 is used. 34618ba5043dSTony Tye 34620ac939f3STony TyeA.3.4 Call Site Entries and Parameters 34630ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 34640ac939f3STony Tye 34650ac939f3STony TyeA.3.4.2 Call Site Parameters 34660ac939f3STony Tye++++++++++++++++++++++++++++ 34670ac939f3STony Tye 34680ac939f3STony Tye1. A ``DW_TAG_call_site_parameter`` debugger information entry may have a 34690ac939f3STony Tye ``DW_AT_call_value`` attribute, whose value is a DWARF operation expression 34700ac939f3STony Tye E\ :sub:`1`\ . 34710ac939f3STony Tye 34720ac939f3STony Tye The result of the ``DW_AT_call_value`` attribute is obtained by evaluating 34730ac939f3STony Tye E\ :sub:`1` with a context that has a result kind of a value, an unspecified 34740ac939f3STony Tye object, the compilation unit that contains E, an empty initial stack, and 34750ac939f3STony Tye other context elements corresponding to the source language thread of 34760ac939f3STony Tye execution upon which the user is focused, if any. The resulting value V\ 34770ac939f3STony Tye :sub:`1` is the value of the parameter at the time of the call made by the 34780ac939f3STony Tye call site. 34790ac939f3STony Tye 34800ac939f3STony Tye For parameters passed by reference, where the code passes a pointer to a 34810ac939f3STony Tye location which contains the parameter, or for reference type parameters, the 34820ac939f3STony Tye ``DW_TAG_call_site_parameter`` debugger information entry may also have a 34830ac939f3STony Tye ``DW_AT_call_data_location`` attribute whose value is a DWARF operation 34840ac939f3STony Tye expression E\ :sub:`2`\ , and a ``DW_AT_call_data_value`` attribute whose 34850ac939f3STony Tye value is a DWARF operation expression E\ :sub:`3`\ . 34860ac939f3STony Tye 34870ac939f3STony Tye The value of the ``DW_AT_call_data_location`` attribute is obtained by 34880ac939f3STony Tye evaluating E\ :sub:`2` with a context that has a result kind of a location 34890ac939f3STony Tye description, an unspecified object, the compilation unit that contains E, an 34900ac939f3STony Tye empty initial stack, and other context elements corresponding to the source 34910ac939f3STony Tye language thread of execution upon which the user is focused, if any. The 34920ac939f3STony Tye resulting location description L\ :sub:`2` is the location where the 34930ac939f3STony Tye referenced parameter lives during the call made by the call site. If E\ 34940ac939f3STony Tye :sub:`2` would just be a ``DW_OP_push_object_address``, then the 34950ac939f3STony Tye ``DW_AT_call_data_location`` attribute may be omitted. 34960ac939f3STony Tye 34970ac939f3STony Tye .. note:: 34980ac939f3STony Tye 34990ac939f3STony Tye The DWARF Version 5 implies that `DW_OP_push_object_address` may be used 35000ac939f3STony Tye but does not state what object must be specified in the context. Either 35010ac939f3STony Tye `DW_OP_push_object_address` cannot be used, or the object to be passed in 35020ac939f3STony Tye the context must be defined. 35030ac939f3STony Tye 35040ac939f3STony Tye The value of the ``DW_AT_call_data_value`` attribute is obtained by 35050ac939f3STony Tye evaluating E\ :sub:`3` with a context that has a result kind of a value, an 35060ac939f3STony Tye unspecified object, the compilation unit that contains E, an empty initial 35070ac939f3STony Tye stack, and other context elements corresponding to the source language 35080ac939f3STony Tye thread of execution upon which the user is focused, if any. The resulting 35090ac939f3STony Tye value V\ :sub:`3` is the value in L\ :sub:`2` at the time of the call made 35100ac939f3STony Tye by the call site. 35110ac939f3STony Tye 35120ac939f3STony Tye The result of these attributes is undefined if the current call frame is not 35130ac939f3STony Tye for the subprogram containing the ``DW_TAG_call_site_parameter`` debugger 35140ac939f3STony Tye information entry or the current program location is not for the call site 35150ac939f3STony Tye containing the ``DW_TAG_call_site_parameter`` debugger information entry in 35160ac939f3STony Tye the current call frame. 35170ac939f3STony Tye 35180ac939f3STony Tye *The consumer may have to virtually unwind to the call site (see* 35190ac939f3STony Tye :ref:`amdgpu-dwarf-call-frame-information`\ *) in order to evaluate these 35200ac939f3STony Tye attributes. This will ensure the source language thread of execution upon 35210ac939f3STony Tye which the user is focused corresponds to the call site needed to evaluate 35220ac939f3STony Tye the expression.* 35230ac939f3STony Tye 35240ac939f3STony Tye If it is not possible to avoid the expressions of these attributes from 35250ac939f3STony Tye accessing registers or memory locations that might be clobbered by the 35260ac939f3STony Tye subprogram being called by the call site, then the associated attribute 35270ac939f3STony Tye should not be provided. 35280ac939f3STony Tye 35290ac939f3STony Tye *The reason for the restriction is that the parameter may need to be 35300ac939f3STony Tye accessed during the execution of the callee. The consumer may virtually 35310ac939f3STony Tye unwind from the called subprogram back to the caller and then evaluate the 35320ac939f3STony Tye attribute expressions. The call frame information (see* 35330ac939f3STony Tye :ref:`amdgpu-dwarf-call-frame-information`\ *) will not be able to restore 35340ac939f3STony Tye registers that have been clobbered, and clobbered memory will no longer have 35350ac939f3STony Tye the value at the time of the call.* 35360ac939f3STony Tye 35370ac939f3STony Tye.. _amdgpu-dwarf-lexical-block-entries: 35380ac939f3STony Tye 35390ac939f3STony TyeA.3.5 Lexical Block Entries 35400ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~ 35410ac939f3STony Tye 35420ac939f3STony Tye.. note:: 35430ac939f3STony Tye 35440ac939f3STony Tye This section is the same as DWARF Version 5 section 3.5. 35450ac939f3STony Tye 35460ac939f3STony TyeA.4 Data Object and Object List Entries 35470ac939f3STony Tye--------------------------------------- 35480ac939f3STony Tye 35490ac939f3STony Tye.. note:: 35500ac939f3STony Tye 35510ac939f3STony Tye This section provides changes to existing debugger information entry 35520ac939f3STony Tye attributes. These would be incorporated into the corresponding DWARF Version 5 35530ac939f3STony Tye chapter 4 sections. 35540ac939f3STony Tye 35550ac939f3STony TyeA.4.1 Data Object Entries 35560ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~ 35570ac939f3STony Tye 35580ac939f3STony Tye1. Any debugging information entry describing a data object (which includes 3559e24f5f31STony variables and parameters) or common blocks may have a ``DW_AT_location`` 3560e24f5f31STony attribute, whose value is a DWARF expression E. 3561e24f5f31STony 3562e24f5f31STony The result of the attribute is obtained by evaluating E with a context that 3563e24f5f31STony has a result kind of a location description, an unspecified object, the 3564e24f5f31STony compilation unit that contains E, an empty initial stack, and other context 3565e24f5f31STony elements corresponding to the source language thread of execution upon which 3566e24f5f31STony the user is focused, if any. The result of the evaluation is the location 3567e24f5f31STony description of the base of the data object. 3568e24f5f31STony 3569e24f5f31STony See :ref:`amdgpu-dwarf-control-flow-operations` for special evaluation rules 3570e24f5f31STony used by the ``DW_OP_call*`` operations. 3571e24f5f31STony 3572e24f5f31STony .. note:: 3573e24f5f31STony 3574e24f5f31STony Delete the description of how the ``DW_OP_call*`` operations evaluate a 3575e24f5f31STony ``DW_AT_location`` attribute as that is now described in the operations. 3576e24f5f31STony 3577e24f5f31STony .. note:: 3578e24f5f31STony 3579e24f5f31STony See the discussion about the ``DW_AT_location`` attribute in the 3580e24f5f31STony ``DW_OP_call*`` operation. Having each attribute only have a single 3581e24f5f31STony purpose and single execution semantics seems desirable. It makes it easier 3582e24f5f31STony for the consumer that no longer have to track the context. It makes it 3583e24f5f31STony easier for the producer as it can rely on a single semantics for each 3584e24f5f31STony attribute. 3585e24f5f31STony 3586e24f5f31STony For that reason, limiting the ``DW_AT_location`` attribute to only 3587e24f5f31STony supporting evaluating the location description of an object, and using a 3588e24f5f31STony different attribute and encoding class for the evaluation of DWARF 3589e24f5f31STony expression *procedures* on the same operation expression stack seems 3590e24f5f31STony desirable. 3591e24f5f31STony 3592e24f5f31STony2. ``DW_AT_const_value`` 3593e24f5f31STony 3594e24f5f31STony .. note:: 3595e24f5f31STony 3596e24f5f31STony Could deprecate using the ``DW_AT_const_value`` attribute for 3597e24f5f31STony ``DW_TAG_variable`` or ``DW_TAG_formal_parameter`` debugger information 3598e24f5f31STony entries that have been optimized to a constant. Instead, 3599e24f5f31STony ``DW_AT_location`` could be used with a DWARF expression that produces an 3600e24f5f31STony implicit location description now that any location description can be 3601e24f5f31STony used within a DWARF expression. This allows the ``DW_OP_call*`` operations 3602e24f5f31STony to be used to push the location description of any variable regardless of 3603e24f5f31STony how it is optimized. 3604e24f5f31STony 36050ac939f3STony TyeA.5 Type Entries 36060ac939f3STony Tye---------------- 3607e24f5f31STony 3608e24f5f31STony.. note:: 3609e24f5f31STony 36100ac939f3STony Tye This section provides changes to existing debugger information entry 36110ac939f3STony Tye attributes. These would be incorporated into the corresponding DWARF Version 5 36120ac939f3STony Tye chapter 5 sections. 3613e24f5f31STony 36140ac939f3STony Tye.. _amdgpu-dwarf-base-type-entries: 3615e24f5f31STony 36160ac939f3STony TyeA.5.1 Base Type Entries 36170ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~ 3618e24f5f31STony 36190ac939f3STony Tye.. note:: 3620e24f5f31STony 36210ac939f3STony Tye The following new attribute is added. 3622e24f5f31STony 36230ac939f3STony Tye1. A ``DW_TAG_base_type`` debugger information entry for a base type T may have 36240ac939f3STony Tye a ``DW_AT_LLVM_vector_size`` attribute whose value is an integer constant 36250ac939f3STony Tye that is the vector type size N. 36260ac939f3STony Tye 36270ac939f3STony Tye The representation of a vector base type is as N contiguous elements, each 36280ac939f3STony Tye one having the representation of a base type T' that is the same as T 36290ac939f3STony Tye without the ``DW_AT_LLVM_vector_size`` attribute. 36300ac939f3STony Tye 36310ac939f3STony Tye If a ``DW_TAG_base_type`` debugger information entry does not have a 36320ac939f3STony Tye ``DW_AT_LLVM_vector_size`` attribute, then the base type is not a vector 36330ac939f3STony Tye type. 36340ac939f3STony Tye 36350ac939f3STony Tye The DWARF is ill-formed if N is not greater than 0. 36360ac939f3STony Tye 36370ac939f3STony Tye .. note:: 36380ac939f3STony Tye 36390ac939f3STony Tye LLVM has mention of a non-upstreamed debugger information entry that is 36400ac939f3STony Tye intended to support vector types. However, that was not for a base type so 36410ac939f3STony Tye would not be suitable as the type of a stack value entry. But perhaps that 36420ac939f3STony Tye could be replaced by using this attribute. 36430ac939f3STony Tye 36440ac939f3STony TyeA.5.7 Structure, Union, Class and Interface Type Entries 36450ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 36460ac939f3STony Tye 36470ac939f3STony TyeA.5.7.3 Derived or Extended Structures, Classes and Interfaces 36480ac939f3STony Tye++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 36490ac939f3STony Tye 36500ac939f3STony Tye1. For a ``DW_AT_data_member_location`` attribute there are two cases: 3651e24f5f31STony 3652e24f5f31STony 1. If the attribute is an integer constant B, it provides the offset in 3653e24f5f31STony bytes from the beginning of the containing entity. 3654e24f5f31STony 3655e24f5f31STony The result of the attribute is obtained by evaluating a 3656e24f5f31STony ``DW_OP_LLVM_offset B`` operation with an initial stack comprising the 3657e24f5f31STony location description of the beginning of the containing entity. The 3658e24f5f31STony result of the evaluation is the location description of the base of the 3659e24f5f31STony member entry. 3660e24f5f31STony 3661e24f5f31STony *If the beginning of the containing entity is not byte aligned, then the 3662e24f5f31STony beginning of the member entry has the same bit displacement within a 3663e24f5f31STony byte.* 3664e24f5f31STony 3665e24f5f31STony 2. Otherwise, the attribute must be a DWARF expression E which is evaluated 3666e24f5f31STony with a context that has a result kind of a location description, an 3667e24f5f31STony unspecified object, the compilation unit that contains E, an initial 3668e24f5f31STony stack comprising the location description of the beginning of the 3669e24f5f31STony containing entity, and other context elements corresponding to the 3670e24f5f31STony source language thread of execution upon which the user is focused, if 3671e24f5f31STony any. The result of the evaluation is the location description of the 3672e24f5f31STony base of the member entry. 3673e24f5f31STony 3674e24f5f31STony .. note:: 3675e24f5f31STony 3676e24f5f31STony The beginning of the containing entity can now be any location 3677e24f5f31STony description, including those with more than one single location 3678e24f5f31STony description, and those with single location descriptions that are of any 3679e24f5f31STony kind and have any bit offset. 3680e24f5f31STony 36810ac939f3STony TyeA.5.7.8 Member Function Entries 36820ac939f3STony Tye+++++++++++++++++++++++++++++++ 3683e24f5f31STony 36840ac939f3STony Tye1. An entry for a virtual function also has a ``DW_AT_vtable_elem_location`` 36850ac939f3STony Tye attribute whose value is a DWARF expression E. 36860ac939f3STony Tye 36870ac939f3STony Tye The result of the attribute is obtained by evaluating E with a context that 36880ac939f3STony Tye has a result kind of a location description, an unspecified object, the 36890ac939f3STony Tye compilation unit that contains E, an initial stack comprising the location 36900ac939f3STony Tye description of the object of the enclosing type, and other context elements 36910ac939f3STony Tye corresponding to the source language thread of execution upon which the user 36920ac939f3STony Tye is focused, if any. The result of the evaluation is the location description 36930ac939f3STony Tye of the slot for the function within the virtual function table for the 36940ac939f3STony Tye enclosing class. 36950ac939f3STony Tye 36960ac939f3STony TyeA.5.14 Pointer to Member Type Entries 36970ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 36980ac939f3STony Tye 36990ac939f3STony Tye1. The ``DW_TAG_ptr_to_member_type`` debugging information entry has a 3700e24f5f31STony ``DW_AT_use_location`` attribute whose value is a DWARF expression E. It is 3701e24f5f31STony used to compute the location description of the member of the class to which 3702e24f5f31STony the pointer to member entry points. 3703e24f5f31STony 3704e24f5f31STony *The method used to find the location description of a given member of a 3705e24f5f31STony class, structure, or union is common to any instance of that class, 3706e24f5f31STony structure, or union and to any instance of the pointer to member type. The 3707e24f5f31STony method is thus associated with the pointer to member type, rather than with 3708e24f5f31STony each object that has a pointer to member type.* 3709e24f5f31STony 3710e24f5f31STony The ``DW_AT_use_location`` DWARF expression is used in conjunction with the 3711e24f5f31STony location description for a particular object of the given pointer to member 3712e24f5f31STony type and for a particular structure or class instance. 3713e24f5f31STony 3714e24f5f31STony The result of the attribute is obtained by evaluating E with a context that 3715e24f5f31STony has a result kind of a location description, an unspecified object, the 3716e24f5f31STony compilation unit that contains E, an initial stack comprising two entries, 3717e24f5f31STony and other context elements corresponding to the source language thread of 3718e24f5f31STony execution upon which the user is focused, if any. The first stack entry is 3719e24f5f31STony the value of the pointer to member object itself. The second stack entry is 3720e24f5f31STony the location description of the base of the entire class, structure, or 3721e24f5f31STony union instance containing the member whose location is being calculated. The 3722e24f5f31STony result of the evaluation is the location description of the member of the 3723e24f5f31STony class to which the pointer to member entry points. 3724e24f5f31STony 37250ac939f3STony TyeA.5.16 Dynamic Type Entries 37260ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3727e24f5f31STony 37280ac939f3STony Tye1. The ``DW_AT_data_location`` attribute may be used with any type that 3729e24f5f31STony provides one or more levels of hidden indirection and/or run-time parameters 3730e24f5f31STony in its representation. Its value is a DWARF operation expression E which 3731e24f5f31STony computes the location description of the data for an object. When this 3732e24f5f31STony attribute is omitted, the location description of the data is the same as 3733e24f5f31STony the location description of the object. 3734e24f5f31STony 3735e24f5f31STony The result of the attribute is obtained by evaluating E with a context that 3736e24f5f31STony has a result kind of a location description, an object that is the location 3737e24f5f31STony description of the data descriptor, the compilation unit that contains E, an 3738e24f5f31STony empty initial stack, and other context elements corresponding to the source 3739e24f5f31STony language thread of execution upon which the user is focused, if any. The 3740e24f5f31STony result of the evaluation is the location description of the base of the 3741e24f5f31STony member entry. 3742e24f5f31STony 3743e24f5f31STony *E will typically involve an operation expression that begins with a* 3744e24f5f31STony ``DW_OP_push_object_address`` *operation which loads the location 37450ac939f3STony Tye description of the object which can then serve as a descriptor in subsequent 37460ac939f3STony Tye calculation.* 3747e24f5f31STony 3748e24f5f31STony .. note:: 3749e24f5f31STony 3750e24f5f31STony Since ``DW_AT_data_member_location``, ``DW_AT_use_location``, and 3751e24f5f31STony ``DW_AT_vtable_elem_location`` allow both operation expressions and 3752e24f5f31STony location list expressions, why does ``DW_AT_data_location`` not allow 3753e24f5f31STony both? In all cases they apply to data objects so less likely that 3754e24f5f31STony optimization would cause different operation expressions for different 3755e24f5f31STony program location ranges. But if supporting for some then should be for 3756e24f5f31STony all. 3757e24f5f31STony 3758e24f5f31STony It seems odd this attribute is not the same as 3759e24f5f31STony ``DW_AT_data_member_location`` in having an initial stack with the 3760e24f5f31STony location description of the object since the expression has to need it. 3761e24f5f31STony 37620ac939f3STony TyeA.6 Other Debugging Information 37630ac939f3STony Tye------------------------------- 3764e24f5f31STony 3765e24f5f31STony.. note:: 3766e24f5f31STony 37670ac939f3STony Tye This section provides changes to existing debugger information entry 37680ac939f3STony Tye attributes. These would be incorporated into the corresponding DWARF Version 5 37690ac939f3STony Tye chapter 6 sections. 3770e24f5f31STony 37710ac939f3STony TyeA.6.1 Accelerated Access 37720ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~ 3773e24f5f31STony 3774e24f5f31STony.. _amdgpu-dwarf-lookup-by-name: 3775e24f5f31STony 37760ac939f3STony TyeA.6.1.1 Lookup By Name 37770ac939f3STony Tye++++++++++++++++++++++ 3778e24f5f31STony 37790ac939f3STony TyeA.6.1.1.1 Contents of the Name Index 37800ac939f3STony Tye#################################### 3781e24f5f31STony 3782e24f5f31STony.. note:: 3783e24f5f31STony 3784e24f5f31STony The following provides changes to DWARF Version 5 section 6.1.1.1. 3785e24f5f31STony 3786e24f5f31STony The rule for debugger information entries included in the name index in the 3787e24f5f31STony optional ``.debug_names`` section is extended to also include named 3788e24f5f31STony ``DW_TAG_variable`` debugging information entries with a ``DW_AT_location`` 3789e24f5f31STony attribute that includes a ``DW_OP_LLVM_form_aspace_address`` operation. 3790e24f5f31STony 3791e24f5f31STonyThe name index must contain an entry for each debugging information entry that 3792e24f5f31STonydefines a named subprogram, label, variable, type, or namespace, subject to the 3793e24f5f31STonyfollowing rules: 3794e24f5f31STony 3795e24f5f31STony* ``DW_TAG_variable`` debugging information entries with a ``DW_AT_location`` 3796e24f5f31STony attribute that includes a ``DW_OP_addr``, ``DW_OP_LLVM_form_aspace_address``, 3797e24f5f31STony or ``DW_OP_form_tls_address`` operation are included; otherwise, they are 3798e24f5f31STony excluded. 3799e24f5f31STony 38000ac939f3STony TyeA.6.1.1.4 Data Representation of the Name Index 38010ac939f3STony Tye############################################### 3802e24f5f31STony 38030ac939f3STony Tye.. _amdgpu-dwarf-name-index-section-header: 38040ac939f3STony Tye 38050ac939f3STony Tye 38060ac939f3STony TyeA.6.1.1.4.1 Section Header 38070ac939f3STony Tye^^^^^^^^^^^^^^^^^^^^^^^^^^ 3808e24f5f31STony 3809e24f5f31STony.. note:: 3810e24f5f31STony 3811e24f5f31STony The following provides an addition to DWARF Version 5 section 6.1.1.4.1 item 3812e24f5f31STony 14 ``augmentation_string``. 3813e24f5f31STony 3814e24f5f31STonyA null-terminated UTF-8 vendor specific augmentation string, which provides 3815e24f5f31STonyadditional information about the contents of this index. If provided, the 3816e24f5f31STonyrecommended format for augmentation string is: 3817e24f5f31STony 3818e24f5f31STony | ``[``\ *vendor*\ ``:v``\ *X*\ ``.``\ *Y*\ [\ ``:``\ *options*\ ]\ ``]``\ * 3819e24f5f31STony 3820e24f5f31STonyWhere *vendor* is the producer, ``vX.Y`` specifies the major X and minor Y 3821e24f5f31STonyversion number of the extensions used in the DWARF of the compilation unit, and 3822e24f5f31STony*options* is an optional string providing additional information about the 3823e24f5f31STonyextensions. The version number must conform to semantic versioning [:ref:`SEMVER 3824e24f5f31STony<amdgpu-dwarf-SEMVER>`]. The *options* string must not contain the "\ ``]``\ " 3825e24f5f31STonycharacter. 3826e24f5f31STony 3827e24f5f31STonyFor example: 3828e24f5f31STony 3829e24f5f31STony :: 3830e24f5f31STony 3831e24f5f31STony [abc:v0.0][def:v1.2:feature-a=on,feature-b=3] 3832e24f5f31STony 3833e24f5f31STony.. note:: 3834e24f5f31STony 3835e24f5f31STony This is different to the definition in DWARF Version 5 but is consistent with 3836e24f5f31STony the other augmentation strings and allows multiple vendor extensions to be 3837e24f5f31STony supported. 3838e24f5f31STony 3839e24f5f31STony.. _amdgpu-dwarf-line-number-information: 3840e24f5f31STony 38410ac939f3STony TyeA.6.2 Line Number Information 38420ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843e24f5f31STony 38440ac939f3STony TyeA.6.2.4 The Line Number Program Header 38450ac939f3STony Tye++++++++++++++++++++++++++++++++++++++ 3846e24f5f31STony 38470ac939f3STony TyeA.6.2.4.1 Standard Content Descriptions 38480ac939f3STony Tye####################################### 3849e24f5f31STony 3850e24f5f31STony.. note:: 3851e24f5f31STony 3852e24f5f31STony This augments DWARF Version 5 section 6.2.4.1. 3853e24f5f31STony 3854e24f5f31STony.. _amdgpu-dwarf-line-number-information-dw-lnct-llvm-source: 3855e24f5f31STony 3856e24f5f31STony1. ``DW_LNCT_LLVM_source`` 3857e24f5f31STony 3858e24f5f31STony The component is a null-terminated UTF-8 source text string with "\ ``\n``\ 3859e24f5f31STony " line endings. This content code is paired with the same forms as 3860e24f5f31STony ``DW_LNCT_path``. It can be used for file name entries. 3861e24f5f31STony 3862e24f5f31STony The value is an empty null-terminated string if no source is available. If 3863e24f5f31STony the source is available but is an empty file then the value is a 3864e24f5f31STony null-terminated single "\ ``\n``\ ". 3865e24f5f31STony 3866e24f5f31STony *When the source field is present, consumers can use the embedded source 3867e24f5f31STony instead of attempting to discover the source on disk using the file path 3868e24f5f31STony provided by the* ``DW_LNCT_path`` *field. When the source field is absent, 3869e24f5f31STony consumers can access the file to get the source text.* 3870e24f5f31STony 3871f2bb4b88SYangZhihui *This is particularly useful for programming languages that support runtime 3872e24f5f31STony compilation and runtime generation of source text. In these cases, the 3873e24f5f31STony source text does not reside in any permanent file. For example, the OpenCL 3874e24f5f31STony language [:ref:`OpenCL <amdgpu-dwarf-OpenCL>`] supports online compilation.* 3875e24f5f31STony 3876e24f5f31STony2. ``DW_LNCT_LLVM_is_MD5`` 3877e24f5f31STony 3878e24f5f31STony ``DW_LNCT_LLVM_is_MD5`` indicates if the ``DW_LNCT_MD5`` content kind, if 3879e24f5f31STony present, is valid: when 0 it is not valid and when 1 it is valid. If 3880e24f5f31STony ``DW_LNCT_LLVM_is_MD5`` content kind is not present, and ``DW_LNCT_MD5`` 3881e24f5f31STony content kind is present, then the MD5 checksum is valid. 3882e24f5f31STony 3883e24f5f31STony ``DW_LNCT_LLVM_is_MD5`` is always paired with the ``DW_FORM_udata`` form. 3884e24f5f31STony 3885e24f5f31STony *This allows a compilation unit to have a mixture of files with and without 3886e24f5f31STony MD5 checksums. This can happen when multiple relocatable files are linked 3887e24f5f31STony together.* 3888e24f5f31STony 3889e24f5f31STony.. _amdgpu-dwarf-call-frame-information: 3890e24f5f31STony 38910ac939f3STony TyeA.6.4 Call Frame Information 38920ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893e24f5f31STony 3894e24f5f31STony.. note:: 3895e24f5f31STony 3896e24f5f31STony This section provides changes to existing call frame information and defines 3897e24f5f31STony instructions added by these extensions. Additional support is added for 3898e24f5f31STony address spaces. Register unwind DWARF expressions are generalized to allow any 3899e24f5f31STony location description, including those with composite and implicit location 3900e24f5f31STony descriptions. 3901e24f5f31STony 39020ac939f3STony Tye These changes would be incorporated into the DWARF Version 5 section 6.4. 3903e24f5f31STony 3904e24f5f31STony.. _amdgpu-dwarf-structure_of-call-frame-information: 3905e24f5f31STony 39060ac939f3STony TyeA.6.4.1 Structure of Call Frame Information 39070ac939f3STony Tye+++++++++++++++++++++++++++++++++++++++++++ 3908e24f5f31STony 3909e24f5f31STonyThe register rules are: 3910e24f5f31STony 3911e24f5f31STony*undefined* 3912e24f5f31STony A register that has this rule has no recoverable value in the previous frame. 3913e24f5f31STony The previous value of this register is the undefined location description (see 3914e24f5f31STony :ref:`amdgpu-dwarf-undefined-location-description-operations`). 3915e24f5f31STony 3916e24f5f31STony *By convention, the register is not preserved by a callee.* 3917e24f5f31STony 3918e24f5f31STony*same value* 3919e24f5f31STony This register has not been modified from the previous caller frame. 3920e24f5f31STony 3921e24f5f31STony If the current frame is the top frame, then the previous value of this 3922e24f5f31STony register is the location description L that specifies one register location 3923e24f5f31STony description SL. SL specifies the register location storage that corresponds to 3924e24f5f31STony the register with a bit offset of 0 for the current thread. 3925e24f5f31STony 3926e24f5f31STony If the current frame is not the top frame, then the previous value of this 3927e24f5f31STony register is the location description obtained using the call frame information 3928e24f5f31STony for the callee frame and callee program location invoked by the current caller 3929e24f5f31STony frame for the same register. 3930e24f5f31STony 3931e24f5f31STony *By convention, the register is preserved by the callee, but the callee has 3932e24f5f31STony not modified it.* 3933e24f5f31STony 3934e24f5f31STony*offset(N)* 3935e24f5f31STony N is a signed byte offset. The previous value of this register is saved at the 3936e24f5f31STony location description computed as if the DWARF operation expression 3937e24f5f31STony ``DW_OP_LLVM_offset N`` is evaluated with the current context, except the 3938e24f5f31STony result kind is a location description, the compilation unit is unspecified, 3939e24f5f31STony the object is unspecified, and an initial stack comprising the location 3940e24f5f31STony description of the current CFA (see 3941e24f5f31STony :ref:`amdgpu-dwarf-operation-expressions`). 3942e24f5f31STony 3943e24f5f31STony*val_offset(N)* 3944e24f5f31STony N is a signed byte offset. The previous value of this register is the memory 3945e24f5f31STony byte address of the location description computed as if the DWARF operation 3946e24f5f31STony expression ``DW_OP_LLVM_offset N`` is evaluated with the current context, 3947e24f5f31STony except the result kind is a location description, the compilation unit is 3948e24f5f31STony unspecified, the object is unspecified, and an initial stack comprising the 3949e24f5f31STony location description of the current CFA (see 3950e24f5f31STony :ref:`amdgpu-dwarf-operation-expressions`). 3951e24f5f31STony 3952e24f5f31STony The DWARF is ill-formed if the CFA location description is not a memory byte 3953e24f5f31STony address location description, or if the register size does not match the size 3954e24f5f31STony of an address in the address space of the current CFA location description. 3955e24f5f31STony 3956e24f5f31STony *Since the CFA location description is required to be a memory byte address 3957e24f5f31STony location description, the value of val_offset(N) will also be a memory byte 3958e24f5f31STony address location description since it is offsetting the CFA location 3959e24f5f31STony description by N bytes. Furthermore, the value of val_offset(N) will be a 3960e24f5f31STony memory byte address in the same address space as the CFA location 3961e24f5f31STony description.* 3962e24f5f31STony 3963e24f5f31STony .. note:: 3964e24f5f31STony 3965e24f5f31STony Should DWARF allow the address size to be a different size to the size of 3966e24f5f31STony the register? Requiring them to be the same bit size avoids any issue of 3967e24f5f31STony conversion as the bit contents of the register is simply interpreted as a 3968e24f5f31STony value of the address. 3969e24f5f31STony 3970e24f5f31STony GDB has a per register hook that allows a target specific conversion on a 3971e24f5f31STony register by register basis. It defaults to truncation of bigger registers, 3972e24f5f31STony and to actually reading bytes from the next register (or reads out of bounds 3973e24f5f31STony for the last register) for smaller registers. There are no GDB tests that 3974e24f5f31STony read a register out of bounds (except an illegal hand written assembly 3975e24f5f31STony test). 3976e24f5f31STony 3977e24f5f31STony*register(R)* 3978e24f5f31STony This register has been stored in another register numbered R. 3979e24f5f31STony 3980e24f5f31STony The previous value of this register is the location description obtained using 3981e24f5f31STony the call frame information for the current frame and current program location 3982e24f5f31STony for register R. 3983e24f5f31STony 3984e24f5f31STony The DWARF is ill-formed if the size of this register does not match the size 3985e24f5f31STony of register R or if there is a cyclic dependency in the call frame 3986e24f5f31STony information. 3987e24f5f31STony 3988e24f5f31STony .. note:: 3989e24f5f31STony 3990e24f5f31STony Should this also allow R to be larger than this register? If so is the value 3991e24f5f31STony stored in the low order bits and it is undefined what is stored in the 3992e24f5f31STony extra upper bits? 3993e24f5f31STony 3994e24f5f31STony*expression(E)* 3995e24f5f31STony The previous value of this register is located at the location description 3996e24f5f31STony produced by evaluating the DWARF operation expression E (see 3997e24f5f31STony :ref:`amdgpu-dwarf-operation-expressions`). 3998e24f5f31STony 3999e24f5f31STony E is evaluated with the current context, except the result kind is a location 4000e24f5f31STony description, the compilation unit is unspecified, the object is unspecified, 4001e24f5f31STony and an initial stack comprising the location description of the current CFA 4002e24f5f31STony (see :ref:`amdgpu-dwarf-operation-expressions`). 4003e24f5f31STony 4004e24f5f31STony*val_expression(E)* 4005e24f5f31STony The previous value of this register is the value produced by evaluating the 4006e24f5f31STony DWARF operation expression E (see :ref:`amdgpu-dwarf-operation-expressions`). 4007e24f5f31STony 4008e24f5f31STony E is evaluated with the current context, except the result kind is a value, 4009e24f5f31STony the compilation unit is unspecified, the object is unspecified, and an initial 4010e24f5f31STony stack comprising the location description of the current CFA (see 4011e24f5f31STony :ref:`amdgpu-dwarf-operation-expressions`). 4012e24f5f31STony 4013e24f5f31STony The DWARF is ill-formed if the resulting value type size does not match the 4014e24f5f31STony register size. 4015e24f5f31STony 4016e24f5f31STony .. note:: 4017e24f5f31STony 4018e24f5f31STony This has limited usefulness as the DWARF expression E can only produce 4019e24f5f31STony values up to the size of the generic type. This is due to not allowing any 4020e24f5f31STony operations that specify a type in a CFI operation expression. This makes it 4021e24f5f31STony unusable for registers that are larger than the generic type. However, 4022e24f5f31STony *expression(E)* can be used to create an implicit location description of 4023e24f5f31STony any size. 4024e24f5f31STony 4025e24f5f31STony*architectural* 4026e24f5f31STony The rule is defined externally to this specification by the augmenter. 4027e24f5f31STony 4028e24f5f31STonyA Common Information Entry (CIE) holds information that is shared among many 4029e24f5f31STonyFrame Description Entries (FDE). There is at least one CIE in every non-empty 4030e24f5f31STony``.debug_frame`` section. A CIE contains the following fields, in order: 4031e24f5f31STony 4032e24f5f31STony1. ``length`` (initial length) 4033e24f5f31STony 4034e24f5f31STony A constant that gives the number of bytes of the CIE structure, not 4035e24f5f31STony including the length field itself. The size of the length field plus the 4036e24f5f31STony value of length must be an integral multiple of the address size specified 4037e24f5f31STony in the ``address_size`` field. 4038e24f5f31STony 4039e24f5f31STony2. ``CIE_id`` (4 or 8 bytes, see 4040e24f5f31STony :ref:`amdgpu-dwarf-32-bit-and-64-bit-dwarf-formats`) 4041e24f5f31STony 4042e24f5f31STony A constant that is used to distinguish CIEs from FDEs. 4043e24f5f31STony 4044e24f5f31STony In the 32-bit DWARF format, the value of the CIE id in the CIE header is 4045e24f5f31STony 0xffffffff; in the 64-bit DWARF format, the value is 0xffffffffffffffff. 4046e24f5f31STony 4047e24f5f31STony3. ``version`` (ubyte) 4048e24f5f31STony 4049e24f5f31STony A version number. This number is specific to the call frame information and 4050e24f5f31STony is independent of the DWARF version number. 4051e24f5f31STony 4052e24f5f31STony The value of the CIE version number is 4. 4053e24f5f31STony 4054e24f5f31STony .. note:: 4055e24f5f31STony 4056e24f5f31STony Would this be increased to 5 to reflect the changes in these extensions? 4057e24f5f31STony 4058e24f5f31STony4. ``augmentation`` (sequence of UTF-8 characters) 4059e24f5f31STony 4060e24f5f31STony A null-terminated UTF-8 string that identifies the augmentation to this CIE 4061e24f5f31STony or to the FDEs that use it. If a reader encounters an augmentation string 4062e24f5f31STony that is unexpected, then only the following fields can be read: 4063e24f5f31STony 4064e24f5f31STony * CIE: length, CIE_id, version, augmentation 4065e24f5f31STony * FDE: length, CIE_pointer, initial_location, address_range 4066e24f5f31STony 4067e24f5f31STony If there is no augmentation, this value is a zero byte. 4068e24f5f31STony 4069e24f5f31STony *The augmentation string allows users to indicate that there is additional 4070e24f5f31STony vendor and target architecture specific information in the CIE or FDE which 4071e24f5f31STony is needed to virtually unwind a stack frame. For example, this might be 4072e24f5f31STony information about dynamically allocated data which needs to be freed on exit 4073e24f5f31STony from the routine.* 4074e24f5f31STony 4075e24f5f31STony *Because the* ``.debug_frame`` *section is useful independently of any* 4076e24f5f31STony ``.debug_info`` *section, the augmentation string always uses UTF-8 4077e24f5f31STony encoding.* 4078e24f5f31STony 4079e24f5f31STony The recommended format for the augmentation string is: 4080e24f5f31STony 4081e24f5f31STony | ``[``\ *vendor*\ ``:v``\ *X*\ ``.``\ *Y*\ [\ ``:``\ *options*\ ]\ ``]``\ * 4082e24f5f31STony 4083e24f5f31STony Where *vendor* is the producer, ``vX.Y`` specifies the major X and minor Y 4084e24f5f31STony version number of the extensions used, and *options* is an optional string 4085e24f5f31STony providing additional information about the extensions. The version number 4086e24f5f31STony must conform to semantic versioning [:ref:`SEMVER <amdgpu-dwarf-SEMVER>`]. 4087e24f5f31STony The *options* string must not contain the "\ ``]``\ " character. 4088e24f5f31STony 4089e24f5f31STony For example: 4090e24f5f31STony 4091e24f5f31STony :: 4092e24f5f31STony 4093e24f5f31STony [abc:v0.0][def:v1.2:feature-a=on,feature-b=3] 4094e24f5f31STony 4095e24f5f31STony5. ``address_size`` (ubyte) 4096e24f5f31STony 4097e24f5f31STony The size of a target address in this CIE and any FDEs that use it, in bytes. 4098e24f5f31STony If a compilation unit exists for this frame, its address size must match the 4099e24f5f31STony address size here. 4100e24f5f31STony 4101e24f5f31STony6. ``segment_selector_size`` (ubyte) 4102e24f5f31STony 4103e24f5f31STony The size of a segment selector in this CIE and any FDEs that use it, in 4104e24f5f31STony bytes. 4105e24f5f31STony 4106e24f5f31STony7. ``code_alignment_factor`` (unsigned LEB128) 4107e24f5f31STony 4108e24f5f31STony A constant that is factored out of all advance location instructions (see 4109e24f5f31STony :ref:`amdgpu-dwarf-row-creation-instructions`). The resulting value is 4110e24f5f31STony ``(operand * code_alignment_factor)``. 4111e24f5f31STony 4112e24f5f31STony8. ``data_alignment_factor`` (signed LEB128) 4113e24f5f31STony 4114e24f5f31STony A constant that is factored out of certain offset instructions (see 4115e24f5f31STony :ref:`amdgpu-dwarf-cfa-definition-instructions` and 4116e24f5f31STony :ref:`amdgpu-dwarf-register-rule-instructions`). The resulting value is 4117e24f5f31STony ``(operand * data_alignment_factor)``. 4118e24f5f31STony 4119e24f5f31STony9. ``return_address_register`` (unsigned LEB128) 4120e24f5f31STony 4121e24f5f31STony An unsigned LEB128 constant that indicates which column in the rule table 4122e24f5f31STony represents the return address of the subprogram. Note that this column might 4123e24f5f31STony not correspond to an actual machine register. 4124e24f5f31STony 4125e24f5f31STony The value of the return address register is used to determine the program 4126e24f5f31STony location of the caller frame. The program location of the top frame is the 4127e24f5f31STony target architecture program counter value of the current thread. 4128e24f5f31STony 4129e24f5f31STony10. ``initial_instructions`` (array of ubyte) 4130e24f5f31STony 4131e24f5f31STony A sequence of rules that are interpreted to create the initial setting of 4132e24f5f31STony each column in the table. 4133e24f5f31STony 4134e24f5f31STony The default rule for all columns before interpretation of the initial 4135e24f5f31STony instructions is the undefined rule. However, an ABI authoring body or a 4136e24f5f31STony compilation system authoring body may specify an alternate default value for 4137e24f5f31STony any or all columns. 4138e24f5f31STony 4139e24f5f31STony11. ``padding`` (array of ubyte) 4140e24f5f31STony 4141e24f5f31STony Enough ``DW_CFA_nop`` instructions to make the size of this entry match the 4142e24f5f31STony length value above. 4143e24f5f31STony 4144e24f5f31STonyAn FDE contains the following fields, in order: 4145e24f5f31STony 4146e24f5f31STony1. ``length`` (initial length) 4147e24f5f31STony 4148e24f5f31STony A constant that gives the number of bytes of the header and instruction 4149e24f5f31STony stream for this subprogram, not including the length field itself. The size 4150e24f5f31STony of the length field plus the value of length must be an integral multiple of 4151e24f5f31STony the address size. 4152e24f5f31STony 4153e24f5f31STony2. ``CIE_pointer`` (4 or 8 bytes, see 4154e24f5f31STony :ref:`amdgpu-dwarf-32-bit-and-64-bit-dwarf-formats`) 4155e24f5f31STony 4156e24f5f31STony A constant offset into the ``.debug_frame`` section that denotes the CIE 4157e24f5f31STony that is associated with this FDE. 4158e24f5f31STony 4159e24f5f31STony3. ``initial_location`` (segment selector and target address) 4160e24f5f31STony 4161e24f5f31STony The address of the first location associated with this table entry. If the 4162e24f5f31STony segment_selector_size field of this FDE’s CIE is non-zero, the initial 4163e24f5f31STony location is preceded by a segment selector of the given length. 4164e24f5f31STony 4165e24f5f31STony4. ``address_range`` (target address) 4166e24f5f31STony 4167e24f5f31STony The number of bytes of program instructions described by this entry. 4168e24f5f31STony 4169e24f5f31STony5. ``instructions`` (array of ubyte) 4170e24f5f31STony 4171e24f5f31STony A sequence of table defining instructions that are described in 4172e24f5f31STony :ref:`amdgpu-dwarf-call-frame-instructions`. 4173e24f5f31STony 4174e24f5f31STony6. ``padding`` (array of ubyte) 4175e24f5f31STony 4176e24f5f31STony Enough ``DW_CFA_nop`` instructions to make the size of this entry match the 4177e24f5f31STony length value above. 4178e24f5f31STony 4179e24f5f31STony.. _amdgpu-dwarf-call-frame-instructions: 4180e24f5f31STony 41810ac939f3STony TyeA.6.4.2 Call Frame Instructions 41820ac939f3STony Tye+++++++++++++++++++++++++++++++ 4183e24f5f31STony 4184e24f5f31STonySome call frame instructions have operands that are encoded as DWARF operation 4185e24f5f31STonyexpressions E (see :ref:`amdgpu-dwarf-operation-expressions`). The DWARF 4186e24f5f31STonyoperations that can be used in E have the following restrictions: 4187e24f5f31STony 4188e24f5f31STony* ``DW_OP_addrx``, ``DW_OP_call2``, ``DW_OP_call4``, ``DW_OP_call_ref``, 4189e24f5f31STony ``DW_OP_const_type``, ``DW_OP_constx``, ``DW_OP_convert``, 4190e24f5f31STony ``DW_OP_deref_type``, ``DW_OP_fbreg``, ``DW_OP_implicit_pointer``, 4191e24f5f31STony ``DW_OP_regval_type``, ``DW_OP_reinterpret``, and ``DW_OP_xderef_type`` 4192e24f5f31STony operations are not allowed because the call frame information must not depend 4193e24f5f31STony on other debug sections. 4194e24f5f31STony 4195e24f5f31STony* ``DW_OP_push_object_address`` is not allowed because there is no object 4196e24f5f31STony context to provide a value to push. 4197e24f5f31STony 41988ba5043dSTony Tye* ``DW_OP_LLVM_push_lane`` and ``DW_OP_LLVM_push_iteration`` are not allowed 41998ba5043dSTony Tye because the call frame instructions describe the actions for the whole target 42008ba5043dSTony Tye architecture thread, not the lanes or iterations independently. 4201e24f5f31STony 4202e24f5f31STony* ``DW_OP_call_frame_cfa`` and ``DW_OP_entry_value`` are not allowed because 4203e24f5f31STony their use would be circular. 4204e24f5f31STony 4205e24f5f31STony* ``DW_OP_LLVM_call_frame_entry_reg`` is not allowed if evaluating E causes a 4206e24f5f31STony circular dependency between ``DW_OP_LLVM_call_frame_entry_reg`` operations. 4207e24f5f31STony 4208e24f5f31STony *For example, if a register R1 has a* ``DW_CFA_def_cfa_expression`` 4209e24f5f31STony *instruction that evaluates a* ``DW_OP_LLVM_call_frame_entry_reg`` *operation 4210e24f5f31STony that specifies register R2, and register R2 has a* 4211e24f5f31STony ``DW_CFA_def_cfa_expression`` *instruction that that evaluates a* 4212e24f5f31STony ``DW_OP_LLVM_call_frame_entry_reg`` *operation that specifies register R1.* 4213e24f5f31STony 4214e24f5f31STony*Call frame instructions to which these restrictions apply include* 4215e24f5f31STony``DW_CFA_def_cfa_expression``\ *,* ``DW_CFA_expression``\ *, and* 4216e24f5f31STony``DW_CFA_val_expression``\ *.* 4217e24f5f31STony 4218e24f5f31STony.. _amdgpu-dwarf-row-creation-instructions: 4219e24f5f31STony 42200ac939f3STony TyeA.6.4.2.1 Row Creation Instructions 42210ac939f3STony Tye################################### 4222e24f5f31STony 4223e24f5f31STony.. note:: 4224e24f5f31STony 4225e24f5f31STony These instructions are the same as in DWARF Version 5 section 6.4.2.1. 4226e24f5f31STony 4227e24f5f31STony.. _amdgpu-dwarf-cfa-definition-instructions: 4228e24f5f31STony 42290ac939f3STony TyeA.6.4.2.2 CFA Definition Instructions 42300ac939f3STony Tye##################################### 4231e24f5f31STony 4232e24f5f31STony1. ``DW_CFA_def_cfa`` 4233e24f5f31STony 4234e24f5f31STony The ``DW_CFA_def_cfa`` instruction takes two unsigned LEB128 operands 4235e24f5f31STony representing a register number R and a (non-factored) byte displacement B. 4236e24f5f31STony AS is set to the target architecture default address space identifier. The 4237e24f5f31STony required action is to define the current CFA rule to be the result of 4238e24f5f31STony evaluating the DWARF operation expression ``DW_OP_constu AS; 4239e24f5f31STony DW_OP_aspace_bregx R, B`` as a location description. 4240e24f5f31STony 4241e24f5f31STony2. ``DW_CFA_def_cfa_sf`` 4242e24f5f31STony 4243e24f5f31STony The ``DW_CFA_def_cfa_sf`` instruction takes two operands: an unsigned LEB128 4244e24f5f31STony value representing a register number R and a signed LEB128 factored byte 4245e24f5f31STony displacement B. AS is set to the target architecture default address space 4246e24f5f31STony identifier. The required action is to define the current CFA rule to be the 4247e24f5f31STony result of evaluating the DWARF operation expression ``DW_OP_constu AS; 4248e24f5f31STony DW_OP_aspace_bregx R, B * data_alignment_factor`` as a location description. 4249e24f5f31STony 4250e24f5f31STony *The action is the same as* ``DW_CFA_def_cfa``\ *, except that the second 4251e24f5f31STony operand is signed and factored.* 4252e24f5f31STony 4253231f4182STony Tye3. ``DW_CFA_LLVM_def_aspace_cfa`` *New* 4254e24f5f31STony 4255231f4182STony Tye The ``DW_CFA_LLVM_def_aspace_cfa`` instruction takes three unsigned LEB128 4256e24f5f31STony operands representing a register number R, a (non-factored) byte 4257e24f5f31STony displacement B, and a target architecture specific address space identifier 4258e24f5f31STony AS. The required action is to define the current CFA rule to be the result 4259e24f5f31STony of evaluating the DWARF operation expression ``DW_OP_constu AS; 4260e24f5f31STony DW_OP_aspace_bregx R, B`` as a location description. 4261e24f5f31STony 4262e24f5f31STony If AS is not one of the values defined by the target architecture specific 4263e24f5f31STony ``DW_ASPACE_*`` values then the DWARF expression is ill-formed. 4264e24f5f31STony 4265231f4182STony Tye4. ``DW_CFA_LLVM_def_aspace_cfa_sf`` *New* 4266e24f5f31STony 4267e24f5f31STony The ``DW_CFA_def_cfa_sf`` instruction takes three operands: an unsigned 4268e24f5f31STony LEB128 value representing a register number R, a signed LEB128 factored byte 4269e24f5f31STony displacement B, and an unsigned LEB128 value representing a target 4270e24f5f31STony architecture specific address space identifier AS. The required action is to 4271e24f5f31STony define the current CFA rule to be the result of evaluating the DWARF 4272e24f5f31STony operation expression ``DW_OP_constu AS; DW_OP_aspace_bregx R, 4273e24f5f31STony B * data_alignment_factor`` as a location description. 4274e24f5f31STony 4275e24f5f31STony If AS is not one of the values defined by the target architecture specific 4276e24f5f31STony ``DW_ASPACE_*`` values, then the DWARF expression is ill-formed. 4277e24f5f31STony 4278e24f5f31STony *The action is the same as* ``DW_CFA_aspace_def_cfa``\ *, except that the 4279e24f5f31STony second operand is signed and factored.* 4280e24f5f31STony 4281e24f5f31STony5. ``DW_CFA_def_cfa_register`` 4282e24f5f31STony 4283e24f5f31STony The ``DW_CFA_def_cfa_register`` instruction takes a single unsigned LEB128 4284e24f5f31STony operand representing a register number R. The required action is to define 4285e24f5f31STony the current CFA rule to be the result of evaluating the DWARF operation 4286e24f5f31STony expression ``DW_OP_constu AS; DW_OP_aspace_bregx R, B`` as a location 4287e24f5f31STony description. B and AS are the old CFA byte displacement and address space 4288e24f5f31STony respectively. 4289e24f5f31STony 4290e24f5f31STony If the subprogram has no current CFA rule, or the rule was defined by a 4291e24f5f31STony ``DW_CFA_def_cfa_expression`` instruction, then the DWARF is ill-formed. 4292e24f5f31STony 4293e24f5f31STony6. ``DW_CFA_def_cfa_offset`` 4294e24f5f31STony 4295e24f5f31STony The ``DW_CFA_def_cfa_offset`` instruction takes a single unsigned LEB128 4296e24f5f31STony operand representing a (non-factored) byte displacement B. The required 4297e24f5f31STony action is to define the current CFA rule to be the result of evaluating the 4298e24f5f31STony DWARF operation expression ``DW_OP_constu AS; DW_OP_aspace_bregx R, B`` as a 4299e24f5f31STony location description. R and AS are the old CFA register number and address 4300e24f5f31STony space respectively. 4301e24f5f31STony 4302e24f5f31STony If the subprogram has no current CFA rule, or the rule was defined by a 4303e24f5f31STony ``DW_CFA_def_cfa_expression`` instruction, then the DWARF is ill-formed. 4304e24f5f31STony 4305e24f5f31STony7. ``DW_CFA_def_cfa_offset_sf`` 4306e24f5f31STony 4307e24f5f31STony The ``DW_CFA_def_cfa_offset_sf`` instruction takes a signed LEB128 operand 4308e24f5f31STony representing a factored byte displacement B. The required action is to 4309e24f5f31STony define the current CFA rule to be the result of evaluating the DWARF 43100ac939f3STony Tye operation expression ``DW_OP_constu AS; DW_OP_aspace_bregx R, B * 43110ac939f3STony Tye data_alignment_factor`` as a location description. R and AS are the old CFA 43120ac939f3STony Tye register number and address space respectively. 4313e24f5f31STony 4314e24f5f31STony If the subprogram has no current CFA rule, or the rule was defined by a 4315e24f5f31STony ``DW_CFA_def_cfa_expression`` instruction, then the DWARF is ill-formed. 4316e24f5f31STony 4317e24f5f31STony *The action is the same as* ``DW_CFA_def_cfa_offset``\ *, except that the 4318e24f5f31STony operand is signed and factored.* 4319e24f5f31STony 4320e24f5f31STony8. ``DW_CFA_def_cfa_expression`` 4321e24f5f31STony 4322e24f5f31STony The ``DW_CFA_def_cfa_expression`` instruction takes a single operand encoded 4323e24f5f31STony as a ``DW_FORM_exprloc`` value representing a DWARF operation expression E. 4324e24f5f31STony The required action is to define the current CFA rule to be the result of 4325e24f5f31STony evaluating E with the current context, except the result kind is a location 4326e24f5f31STony description, the compilation unit is unspecified, the object is unspecified, 4327e24f5f31STony and an empty initial stack. 4328e24f5f31STony 4329e24f5f31STony *See* :ref:`amdgpu-dwarf-call-frame-instructions` *regarding restrictions on 4330e24f5f31STony the DWARF expression operations that can be used in E.* 4331e24f5f31STony 4332e24f5f31STony The DWARF is ill-formed if the result of evaluating E is not a memory byte 4333e24f5f31STony address location description. 4334e24f5f31STony 4335e24f5f31STony.. _amdgpu-dwarf-register-rule-instructions: 4336e24f5f31STony 43370ac939f3STony TyeA.6.4.2.3 Register Rule Instructions 43380ac939f3STony Tye#################################### 4339e24f5f31STony 4340e24f5f31STony1. ``DW_CFA_undefined`` 4341e24f5f31STony 4342e24f5f31STony The ``DW_CFA_undefined`` instruction takes a single unsigned LEB128 operand 4343e24f5f31STony that represents a register number R. The required action is to set the rule 4344e24f5f31STony for the register specified by R to ``undefined``. 4345e24f5f31STony 4346e24f5f31STony2. ``DW_CFA_same_value`` 4347e24f5f31STony 4348e24f5f31STony The ``DW_CFA_same_value`` instruction takes a single unsigned LEB128 operand 4349e24f5f31STony that represents a register number R. The required action is to set the rule 4350e24f5f31STony for the register specified by R to ``same value``. 4351e24f5f31STony 4352e24f5f31STony3. ``DW_CFA_offset`` 4353e24f5f31STony 4354e24f5f31STony The ``DW_CFA_offset`` instruction takes two operands: a register number R 4355e24f5f31STony (encoded with the opcode) and an unsigned LEB128 constant representing a 4356e24f5f31STony factored displacement B. The required action is to change the rule for the 4357e24f5f31STony register specified by R to be an *offset(B \* data_alignment_factor)* rule. 4358e24f5f31STony 4359e24f5f31STony .. note:: 4360e24f5f31STony 4361e24f5f31STony Seems this should be named ``DW_CFA_offset_uf`` since the offset is 4362e24f5f31STony unsigned factored. 4363e24f5f31STony 4364e24f5f31STony4. ``DW_CFA_offset_extended`` 4365e24f5f31STony 4366e24f5f31STony The ``DW_CFA_offset_extended`` instruction takes two unsigned LEB128 4367e24f5f31STony operands representing a register number R and a factored displacement B. 4368e24f5f31STony This instruction is identical to ``DW_CFA_offset``, except for the encoding 4369e24f5f31STony and size of the register operand. 4370e24f5f31STony 4371e24f5f31STony .. note:: 4372e24f5f31STony 4373e24f5f31STony Seems this should be named ``DW_CFA_offset_extended_uf`` since the 4374e24f5f31STony displacement is unsigned factored. 4375e24f5f31STony 4376e24f5f31STony5. ``DW_CFA_offset_extended_sf`` 4377e24f5f31STony 4378e24f5f31STony The ``DW_CFA_offset_extended_sf`` instruction takes two operands: an 4379e24f5f31STony unsigned LEB128 value representing a register number R and a signed LEB128 4380e24f5f31STony factored displacement B. This instruction is identical to 4381e24f5f31STony ``DW_CFA_offset_extended``, except that B is signed. 4382e24f5f31STony 4383e24f5f31STony6. ``DW_CFA_val_offset`` 4384e24f5f31STony 4385e24f5f31STony The ``DW_CFA_val_offset`` instruction takes two unsigned LEB128 operands 4386e24f5f31STony representing a register number R and a factored displacement B. The required 4387e24f5f31STony action is to change the rule for the register indicated by R to be a 4388e24f5f31STony *val_offset(B \* data_alignment_factor)* rule. 4389e24f5f31STony 4390e24f5f31STony .. note:: 4391e24f5f31STony 4392e24f5f31STony Seems this should be named ``DW_CFA_val_offset_uf`` since the displacement 4393e24f5f31STony is unsigned factored. 4394e24f5f31STony 4395e24f5f31STony .. note:: 4396e24f5f31STony 4397e24f5f31STony An alternative is to define ``DW_CFA_val_offset`` to implicitly use the 4398e24f5f31STony target architecture default address space, and add another operation that 4399e24f5f31STony specifies the address space. 4400e24f5f31STony 4401e24f5f31STony7. ``DW_CFA_val_offset_sf`` 4402e24f5f31STony 4403e24f5f31STony The ``DW_CFA_val_offset_sf`` instruction takes two operands: an unsigned 4404e24f5f31STony LEB128 value representing a register number R and a signed LEB128 factored 4405e24f5f31STony displacement B. This instruction is identical to ``DW_CFA_val_offset``, 4406e24f5f31STony except that B is signed. 4407e24f5f31STony 4408e24f5f31STony8. ``DW_CFA_register`` 4409e24f5f31STony 4410e24f5f31STony The ``DW_CFA_register`` instruction takes two unsigned LEB128 operands 4411e24f5f31STony representing register numbers R1 and R2 respectively. The required action is 4412e24f5f31STony to set the rule for the register specified by R1 to be a *register(R2)* rule. 4413e24f5f31STony 4414e24f5f31STony9. ``DW_CFA_expression`` 4415e24f5f31STony 4416e24f5f31STony The ``DW_CFA_expression`` instruction takes two operands: an unsigned LEB128 4417e24f5f31STony value representing a register number R, and a ``DW_FORM_block`` value 4418e24f5f31STony representing a DWARF operation expression E. The required action is to 4419e24f5f31STony change the rule for the register specified by R to be an *expression(E)* 4420e24f5f31STony rule. 4421e24f5f31STony 4422e24f5f31STony *That is, E computes the location description where the register value can 4423e24f5f31STony be retrieved.* 4424e24f5f31STony 4425e24f5f31STony *See* :ref:`amdgpu-dwarf-call-frame-instructions` *regarding restrictions on 4426e24f5f31STony the DWARF expression operations that can be used in E.* 4427e24f5f31STony 4428e24f5f31STony10. ``DW_CFA_val_expression`` 4429e24f5f31STony 4430e24f5f31STony The ``DW_CFA_val_expression`` instruction takes two operands: an unsigned 4431e24f5f31STony LEB128 value representing a register number R, and a ``DW_FORM_block`` value 4432e24f5f31STony representing a DWARF operation expression E. The required action is to 4433e24f5f31STony change the rule for the register specified by R to be a *val_expression(E)* 4434e24f5f31STony rule. 4435e24f5f31STony 4436e24f5f31STony *That is, E computes the value of register R.* 4437e24f5f31STony 4438e24f5f31STony *See* :ref:`amdgpu-dwarf-call-frame-instructions` *regarding restrictions on 4439e24f5f31STony the DWARF expression operations that can be used in E.* 4440e24f5f31STony 4441e24f5f31STony If the result of evaluating E is not a value with a base type size that 4442e24f5f31STony matches the register size, then the DWARF is ill-formed. 4443e24f5f31STony 4444e24f5f31STony11. ``DW_CFA_restore`` 4445e24f5f31STony 4446e24f5f31STony The ``DW_CFA_restore`` instruction takes a single operand (encoded with the 4447e24f5f31STony opcode) that represents a register number R. The required action is to 4448e24f5f31STony change the rule for the register specified by R to the rule assigned it by 4449e24f5f31STony the ``initial_instructions`` in the CIE. 4450e24f5f31STony 4451e24f5f31STony12. ``DW_CFA_restore_extended`` 4452e24f5f31STony 4453e24f5f31STony The ``DW_CFA_restore_extended`` instruction takes a single unsigned LEB128 4454e24f5f31STony operand that represents a register number R. This instruction is identical 4455e24f5f31STony to ``DW_CFA_restore``, except for the encoding and size of the register 4456e24f5f31STony operand. 4457e24f5f31STony 44580ac939f3STony TyeA.6.4.2.4 Row State Instructions 44590ac939f3STony Tye################################ 4460e24f5f31STony 4461e24f5f31STony.. note:: 4462e24f5f31STony 4463e24f5f31STony These instructions are the same as in DWARF Version 5 section 6.4.2.4. 4464e24f5f31STony 44650ac939f3STony TyeA.6.4.2.5 Padding Instruction 44660ac939f3STony Tye############################# 4467e24f5f31STony 4468e24f5f31STony.. note:: 4469e24f5f31STony 4470e24f5f31STony These instructions are the same as in DWARF Version 5 section 6.4.2.5. 4471e24f5f31STony 44720ac939f3STony TyeA.6.4.3 Call Frame Instruction Usage 44730ac939f3STony Tye++++++++++++++++++++++++++++++++++++ 4474e24f5f31STony 4475e24f5f31STony.. note:: 4476e24f5f31STony 4477e24f5f31STony The same as in DWARF Version 5 section 6.4.3. 4478e24f5f31STony 4479e24f5f31STony.. _amdgpu-dwarf-call-frame-calling-address: 4480e24f5f31STony 44810ac939f3STony TyeA.6.4.4 Call Frame Calling Address 44820ac939f3STony Tye++++++++++++++++++++++++++++++++++ 4483e24f5f31STony 4484e24f5f31STony.. note:: 4485e24f5f31STony 4486e24f5f31STony The same as in DWARF Version 5 section 6.4.4. 4487e24f5f31STony 44880ac939f3STony TyeA.7 Data Representation 44890ac939f3STony Tye----------------------- 4490e24f5f31STony 4491e24f5f31STony.. note:: 4492e24f5f31STony 44930ac939f3STony Tye This section provides changes to existing debugger information entry 44940ac939f3STony Tye attributes. These would be incorporated into the corresponding DWARF Version 5 44950ac939f3STony Tye chapter 7 sections. 4496e24f5f31STony 44970ac939f3STony Tye.. _amdgpu-dwarf-32-bit-and-64-bit-dwarf-formats: 44980ac939f3STony Tye 44990ac939f3STony TyeA.7.4 32-Bit and 64-Bit DWARF Formats 45000ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 45010ac939f3STony Tye 45020ac939f3STony Tye.. note:: 45030ac939f3STony Tye 45040ac939f3STony Tye This augments DWARF Version 5 section 7.4 list item 3's table. 4505e24f5f31STony 4506e24f5f31STony.. table:: ``.debug_info`` section attribute form roles 4507e24f5f31STony :name: amdgpu-dwarf-debug-info-section-attribute-form-roles-table 4508e24f5f31STony 4509e24f5f31STony ================================== =================================== 4510e24f5f31STony Form Role 4511e24f5f31STony ================================== =================================== 4512e24f5f31STony DW_OP_LLVM_aspace_implicit_pointer offset in ``.debug_info`` 4513e24f5f31STony ================================== =================================== 4514e24f5f31STony 45150ac939f3STony TyeA.7.5 Format of Debugging Information 45160ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4517e24f5f31STony 45180ac939f3STony TyeA.7.5.4 Attribute Encodings 45190ac939f3STony Tye+++++++++++++++++++++++++++ 4520e24f5f31STony 4521e24f5f31STony.. note:: 4522e24f5f31STony 4523e24f5f31STony This augments DWARF Version 5 section 7.5.4 and Table 7.5. 4524e24f5f31STony 4525e24f5f31STonyThe following table gives the encoding of the additional debugging information 4526e24f5f31STonyentry attributes. 4527e24f5f31STony 4528e24f5f31STony.. table:: Attribute encodings 4529e24f5f31STony :name: amdgpu-dwarf-attribute-encodings-table 4530e24f5f31STony 4531e24f5f31STony ================================== ====== =================================== 4532e24f5f31STony Attribute Name Value Classes 4533e24f5f31STony ================================== ====== =================================== 4534e24f5f31STony DW_AT_LLVM_active_lane 0x3e08 exprloc, loclist 4535e24f5f31STony DW_AT_LLVM_augmentation 0x3e09 string 4536e24f5f31STony DW_AT_LLVM_lanes 0x3e0a constant 4537e24f5f31STony DW_AT_LLVM_lane_pc 0x3e0b exprloc, loclist 4538e24f5f31STony DW_AT_LLVM_vector_size 0x3e0c constant 45398ba5043dSTony Tye DW_AT_LLVM_iterations 0x3e0a constant, exprloc, loclist 4540e24f5f31STony ================================== ====== =================================== 4541e24f5f31STony 45420ac939f3STony Tye.. _amdgpu-dwarf-classes-and-forms: 45430ac939f3STony Tye 45440ac939f3STony TyeA.7.5.5 Classes and Forms 45450ac939f3STony Tye+++++++++++++++++++++++++ 45460ac939f3STony Tye 45470ac939f3STony Tye.. note:: 45480ac939f3STony Tye 45490ac939f3STony Tye The same as in DWARF Version 5 section 7.5.5. 45500ac939f3STony Tye 45510ac939f3STony TyeA.7.7 DWARF Expressions 45520ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~ 4553e24f5f31STony 4554e24f5f31STony.. note:: 4555e24f5f31STony 4556e24f5f31STony Rename DWARF Version 5 section 7.7 to reflect the unification of location 4557e24f5f31STony descriptions into DWARF expressions. 4558e24f5f31STony 45590ac939f3STony TyeA.7.7.1 Operation Expressions 45600ac939f3STony Tye+++++++++++++++++++++++++++++ 4561e24f5f31STony 4562e24f5f31STony.. note:: 4563e24f5f31STony 4564e24f5f31STony Rename DWARF Version 5 section 7.7.1 and delete section 7.7.2 to reflect the 4565e24f5f31STony unification of location descriptions into DWARF expressions. 4566e24f5f31STony 4567e24f5f31STony This augments DWARF Version 5 section 7.7.1 and Table 7.9. 4568e24f5f31STony 4569e24f5f31STonyThe following table gives the encoding of the additional DWARF expression 4570e24f5f31STonyoperations. 4571e24f5f31STony 4572e24f5f31STony.. table:: DWARF Operation Encodings 4573e24f5f31STony :name: amdgpu-dwarf-operation-encodings-table 4574e24f5f31STony 4575e24f5f31STony ================================== ===== ======== =============================== 4576e24f5f31STony Operation Code Number Notes 4577e24f5f31STony of 4578e24f5f31STony Operands 4579e24f5f31STony ================================== ===== ======== =============================== 4580e24f5f31STony DW_OP_LLVM_form_aspace_address 0xe1 0 4581e24f5f31STony DW_OP_LLVM_push_lane 0xe2 0 4582e24f5f31STony DW_OP_LLVM_offset 0xe3 0 4583e24f5f31STony DW_OP_LLVM_offset_uconst 0xe4 1 ULEB128 byte displacement 4584e24f5f31STony DW_OP_LLVM_bit_offset 0xe5 0 4585e24f5f31STony DW_OP_LLVM_call_frame_entry_reg 0xe6 1 ULEB128 register number 4586e24f5f31STony DW_OP_LLVM_undefined 0xe7 0 4587e24f5f31STony DW_OP_LLVM_aspace_bregx 0xe8 2 ULEB128 register number, 4588e24f5f31STony ULEB128 byte displacement 4589e24f5f31STony DW_OP_LLVM_aspace_implicit_pointer 0xe9 2 4-byte or 8-byte offset of DIE, 4590e24f5f31STony SLEB128 byte displacement 4591e24f5f31STony DW_OP_LLVM_piece_end 0xea 0 4592e24f5f31STony DW_OP_LLVM_extend 0xeb 2 ULEB128 bit size, 4593e24f5f31STony ULEB128 count 4594e24f5f31STony DW_OP_LLVM_select_bit_piece 0xec 2 ULEB128 bit size, 4595e24f5f31STony ULEB128 count 45968ba5043dSTony Tye DW_OP_LLVM_push_iteration TBA 0 45978ba5043dSTony Tye DW_OP_LLVM_overlay TBA 0 45988ba5043dSTony Tye DW_OP_LLVM_bit_overlay TBA 0 4599e24f5f31STony ================================== ===== ======== =============================== 4600e24f5f31STony 46010ac939f3STony TyeA.7.7.3 Location List Expressions 46020ac939f3STony Tye+++++++++++++++++++++++++++++++++ 4603e24f5f31STony 4604e24f5f31STony.. note:: 4605e24f5f31STony 4606e24f5f31STony Rename DWARF Version 5 section 7.7.3 to reflect that location lists are a kind 4607e24f5f31STony of DWARF expression. 4608e24f5f31STony 46090ac939f3STony TyeA.7.12 Source Languages 46100ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~ 4611e24f5f31STony 4612e24f5f31STony.. note:: 4613e24f5f31STony 4614e24f5f31STony This augments DWARF Version 5 section 7.12 and Table 7.17. 4615e24f5f31STony 4616e24f5f31STonyThe following table gives the encoding of the additional DWARF languages. 4617e24f5f31STony 4618e24f5f31STony.. table:: Language encodings 4619e24f5f31STony :name: amdgpu-dwarf-language-encodings-table 4620e24f5f31STony 4621e24f5f31STony ==================== ====== =================== 4622e24f5f31STony Language Name Value Default Lower Bound 4623e24f5f31STony ==================== ====== =================== 4624e24f5f31STony ``DW_LANG_LLVM_HIP`` 0x8100 0 4625e24f5f31STony ==================== ====== =================== 4626e24f5f31STony 46270ac939f3STony TyeA.7.13 Address Class and Address Space Encodings 46280ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4629e24f5f31STony 4630e24f5f31STony.. note:: 4631e24f5f31STony 4632e24f5f31STony This replaces DWARF Version 5 section 7.13. 4633e24f5f31STony 4634e24f5f31STonyThe encodings of the constants used for the currently defined address classes 4635e24f5f31STonyare given in :ref:`amdgpu-dwarf-address-class-encodings-table`. 4636e24f5f31STony 4637e24f5f31STony.. table:: Address class encodings 4638e24f5f31STony :name: amdgpu-dwarf-address-class-encodings-table 4639e24f5f31STony 4640e24f5f31STony ========================== ====== 4641e24f5f31STony Address Class Name Value 4642e24f5f31STony ========================== ====== 4643e24f5f31STony ``DW_ADDR_none`` 0x0000 4644e24f5f31STony ``DW_ADDR_LLVM_global`` 0x0001 4645e24f5f31STony ``DW_ADDR_LLVM_constant`` 0x0002 4646e24f5f31STony ``DW_ADDR_LLVM_group`` 0x0003 4647e24f5f31STony ``DW_ADDR_LLVM_private`` 0x0004 4648e24f5f31STony ``DW_ADDR_LLVM_lo_user`` 0x8000 4649e24f5f31STony ``DW_ADDR_LLVM_hi_user`` 0xffff 4650e24f5f31STony ========================== ====== 4651e24f5f31STony 46520ac939f3STony TyeA.7.22 Line Number Information 46530ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654e24f5f31STony 4655e24f5f31STony.. note:: 4656e24f5f31STony 4657e24f5f31STony This augments DWARF Version 5 section 7.22 and Table 7.27. 4658e24f5f31STony 4659e24f5f31STonyThe following table gives the encoding of the additional line number header 4660e24f5f31STonyentry formats. 4661e24f5f31STony 4662e24f5f31STony.. table:: Line number header entry format encodings 4663e24f5f31STony :name: amdgpu-dwarf-line-number-header-entry-format-encodings-table 4664e24f5f31STony 4665e24f5f31STony ==================================== ==================== 4666e24f5f31STony Line number header entry format name Value 4667e24f5f31STony ==================================== ==================== 4668e24f5f31STony ``DW_LNCT_LLVM_source`` 0x2001 4669e24f5f31STony ``DW_LNCT_LLVM_is_MD5`` 0x2002 4670e24f5f31STony ==================================== ==================== 4671e24f5f31STony 46720ac939f3STony TyeA.7.24 Call Frame Information 46730ac939f3STony Tye~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4674e24f5f31STony 4675e24f5f31STony.. note:: 4676e24f5f31STony 4677e24f5f31STony This augments DWARF Version 5 section 7.24 and Table 7.29. 4678e24f5f31STony 4679e24f5f31STonyThe following table gives the encoding of the additional call frame information 4680e24f5f31STonyinstructions. 4681e24f5f31STony 4682e24f5f31STony.. table:: Call frame instruction encodings 4683e24f5f31STony :name: amdgpu-dwarf-call-frame-instruction-encodings-table 4684e24f5f31STony 4685231f4182STony Tye ============================= ====== ====== ================ ================ ===================== 4686e24f5f31STony Instruction High 2 Low 6 Operand 1 Operand 2 Operand 3 4687e24f5f31STony Bits Bits 4688231f4182STony Tye ============================= ====== ====== ================ ================ ===================== 4689231f4182STony Tye DW_CFA_LLVM_def_aspace_cfa 0 0x30 ULEB128 register ULEB128 offset ULEB128 address space 4690231f4182STony Tye DW_CFA_LLVM_def_aspace_cfa_sf 0 0x31 ULEB128 register SLEB128 offset ULEB128 address space 4691231f4182STony Tye ============================= ====== ====== ================ ================ ===================== 4692e24f5f31STony 46930ac939f3STony TyeA. Attributes by Tag Value (Informative) 46940ac939f3STony Tye---------------------------------------- 4695e24f5f31STony 4696e24f5f31STony.. note:: 4697e24f5f31STony 4698e24f5f31STony This augments DWARF Version 5 Appendix A and Table A.1. 4699e24f5f31STony 4700e24f5f31STonyThe following table provides the additional attributes that are applicable to 4701e24f5f31STonydebugger information entries. 4702e24f5f31STony 4703e24f5f31STony.. table:: Attributes by tag value 4704e24f5f31STony :name: amdgpu-dwarf-attributes-by-tag-value-table 4705e24f5f31STony 4706e24f5f31STony ============================= ============================= 4707e24f5f31STony Tag Name Applicable Attributes 4708e24f5f31STony ============================= ============================= 4709e24f5f31STony ``DW_TAG_base_type`` * ``DW_AT_LLVM_vector_size`` 4710e24f5f31STony ``DW_TAG_compile_unit`` * ``DW_AT_LLVM_augmentation`` 4711e24f5f31STony ``DW_TAG_entry_point`` * ``DW_AT_LLVM_active_lane`` 4712e24f5f31STony * ``DW_AT_LLVM_lane_pc`` 4713e24f5f31STony * ``DW_AT_LLVM_lanes`` 47148ba5043dSTony Tye * ``DW_AT_LLVM_iterations`` 4715e24f5f31STony ``DW_TAG_inlined_subroutine`` * ``DW_AT_LLVM_active_lane`` 4716e24f5f31STony * ``DW_AT_LLVM_lane_pc`` 4717e24f5f31STony * ``DW_AT_LLVM_lanes`` 47188ba5043dSTony Tye * ``DW_AT_LLVM_iterations`` 4719e24f5f31STony ``DW_TAG_subprogram`` * ``DW_AT_LLVM_active_lane`` 4720e24f5f31STony * ``DW_AT_LLVM_lane_pc`` 4721e24f5f31STony * ``DW_AT_LLVM_lanes`` 47228ba5043dSTony Tye * ``DW_AT_LLVM_iterations`` 4723e24f5f31STony ============================= ============================= 4724e24f5f31STony 4725e24f5f31STony.. _amdgpu-dwarf-examples: 4726e24f5f31STony 47270ac939f3STony TyeB. Examples 47280ac939f3STony Tye=========== 4729e24f5f31STony 4730e24f5f31STonyThe AMD GPU specific usage of the features in these extensions, including 4731e24f5f31STonyexamples, is available at *User Guide for AMDGPU Backend* section 4732e24f5f31STony:ref:`amdgpu-dwarf-debug-information`. 4733e24f5f31STony 4734e24f5f31STony.. note:: 4735e24f5f31STony 4736e24f5f31STony Change examples to use ``DW_OP_LLVM_offset`` instead of ``DW_OP_add`` when 4737e24f5f31STony acting on a location description. 4738e24f5f31STony 4739e24f5f31STony Need to provide examples of new features. 4740e24f5f31STony 4741e24f5f31STony.. _amdgpu-dwarf-references: 4742e24f5f31STony 47430ac939f3STony TyeC. References 47440ac939f3STony Tye============= 4745e24f5f31STony 4746e24f5f31STony .. _amdgpu-dwarf-AMD: 4747e24f5f31STony 4748e24f5f31STony1. [AMD] `Advanced Micro Devices <https://www.amd.com/>`__ 4749e24f5f31STony 4750e24f5f31STony .. _amdgpu-dwarf-AMD-ROCgdb: 4751e24f5f31STony 47520ac939f3STony Tye2. [AMD-ROCgdb] `AMD ROCm Debugger (ROCgdb) <https://github.com/ROCm-Developer-Tools/ROCgdb>`__ 47530ac939f3STony Tye 47540ac939f3STony Tye .. _amdgpu-dwarf-AMD-ROCm: 47550ac939f3STony Tye 47560ac939f3STony Tye3. [AMD-ROCm] `AMD ROCm Platform <https://rocm-documentation.readthedocs.io>`__ 47570ac939f3STony Tye 47580ac939f3STony Tye .. _amdgpu-dwarf-AMDGPU-DWARF-LOC: 47590ac939f3STony Tye 47600ac939f3STony Tye4. [AMDGPU-DWARF-LOC] `Allow Location Descriptions on the DWARF Expression Stack <https://llvm.org/docs/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack.html>`__ 4761e24f5f31STony 4762e24f5f31STony .. _amdgpu-dwarf-AMDGPU-LLVM: 4763e24f5f31STony 47640ac939f3STony Tye5. [AMDGPU-LLVM] `User Guide for AMDGPU LLVM Backend <https://llvm.org/docs/AMDGPUUsage.html>`__ 4765e24f5f31STony 4766e24f5f31STony .. _amdgpu-dwarf-CUDA: 4767e24f5f31STony 47680ac939f3STony Tye6. [CUDA] `Nvidia CUDA Language <https://docs.nvidia.com/cuda/cuda-c-programming-guide/>`__ 4769e24f5f31STony 4770e24f5f31STony .. _amdgpu-dwarf-DWARF: 4771e24f5f31STony 47720ac939f3STony Tye7. [DWARF] `DWARF Debugging Information Format <http://dwarfstd.org/>`__ 4773e24f5f31STony 4774e24f5f31STony .. _amdgpu-dwarf-ELF: 4775e24f5f31STony 47760ac939f3STony Tye8. [ELF] `Executable and Linkable Format (ELF) <http://www.sco.com/developers/gabi/>`__ 4777e24f5f31STony 4778e24f5f31STony .. _amdgpu-dwarf-GCC: 4779e24f5f31STony 47800ac939f3STony Tye9. [GCC] `GCC: The GNU Compiler Collection <https://www.gnu.org/software/gcc/>`__ 4781e24f5f31STony 4782e24f5f31STony .. _amdgpu-dwarf-GDB: 4783e24f5f31STony 47840ac939f3STony Tye10. [GDB] `GDB: The GNU Project Debugger <https://www.gnu.org/software/gdb/>`__ 4785e24f5f31STony 4786e24f5f31STony .. _amdgpu-dwarf-HIP: 4787e24f5f31STony 47880ac939f3STony Tye11. [HIP] `HIP Programming Guide <https://rocm-documentation.readthedocs.io/en/latest/Programming_Guides/Programming-Guides.html#hip-programing-guide>`__ 4789e24f5f31STony 4790e24f5f31STony .. _amdgpu-dwarf-HSA: 4791e24f5f31STony 47920ac939f3STony Tye12. [HSA] `Heterogeneous System Architecture (HSA) Foundation <http://www.hsafoundation.com/>`__ 4793e24f5f31STony 4794e24f5f31STony .. _amdgpu-dwarf-LLVM: 4795e24f5f31STony 47960ac939f3STony Tye13. [LLVM] `The LLVM Compiler Infrastructure <https://llvm.org/>`__ 4797e24f5f31STony 4798e24f5f31STony .. _amdgpu-dwarf-OpenCL: 4799e24f5f31STony 48000ac939f3STony Tye14. [OpenCL] `The OpenCL Specification Version 2.0 <http://www.khronos.org/registry/cl/specs/opencl-2.0.pdf>`__ 4801e24f5f31STony 4802e24f5f31STony .. _amdgpu-dwarf-Perforce-TotalView: 4803e24f5f31STony 48040ac939f3STony Tye15. [Perforce-TotalView] `Perforce TotalView HPC Debugging Software <https://totalview.io/products/totalview>`__ 4805e24f5f31STony 4806e24f5f31STony .. _amdgpu-dwarf-SEMVER: 4807e24f5f31STony 48080ac939f3STony Tye16. [SEMVER] `Semantic Versioning <https://semver.org/>`__ 4809