[llvm] [llvm][dwarfdump] Print the name (if available) of entities referenced by DW_AT_import (PR #171859)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 11 08:58:19 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: Michael Buch (Michael137)
<details>
<summary>Changes</summary>
Instead of this:
```
0x00018cff: DW_TAG_imported_declaration
DW_AT_decl_line (12)
DW_AT_import (0x0000000000018cfb)
```
print:
```
0x00018cff: DW_TAG_imported_declaration
DW_AT_decl_line (12)
DW_AT_import (0x0000000000018cfb "platform")
```
Where `0x0000000000018cfb` in this example could be a `DW_TAG_module` with `DW_AT_name ("platform")`
---
Full diff: https://github.com/llvm/llvm-project/pull/171859.diff
2 Files Affected:
- (modified) llvm/lib/DebugInfo/DWARF/DWARFDie.cpp (+1-1)
- (added) llvm/test/tools/llvm-dwarfdump/AArch64/DW_AT_import.yaml (+73)
``````````diff
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index deafee80f559f..a10becb252006 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -246,7 +246,7 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
// having both the raw value and the pretty-printed value is
// interesting. These attributes are handled below.
if (Attr == DW_AT_specification || Attr == DW_AT_abstract_origin ||
- Attr == DW_AT_call_origin) {
+ Attr == DW_AT_call_origin || Attr == DW_AT_import) {
if (const char *Name =
Die.getAttributeValueAsReferencedDie(FormValue).getName(
DINameKind::LinkageName))
diff --git a/llvm/test/tools/llvm-dwarfdump/AArch64/DW_AT_import.yaml b/llvm/test/tools/llvm-dwarfdump/AArch64/DW_AT_import.yaml
new file mode 100644
index 0000000000000..fec25bdd9ba30
--- /dev/null
+++ b/llvm/test/tools/llvm-dwarfdump/AArch64/DW_AT_import.yaml
@@ -0,0 +1,73 @@
+# RUN: yaml2obj %s | llvm-dwarfdump -verify - | FileCheck %s --check-prefix=VERIFY
+# VERIFY: No errors.
+#
+# RUN: yaml2obj %s | llvm-dwarfdump - | FileCheck %s
+# CHECK: DW_AT_import ({{.*}} "Foo")
+# CHECK: DW_AT_import ({{.*}} "")
+# CHECK: DW_AT_import ({{.*}})
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_AARCH64
+DWARF:
+ debug_abbrev:
+ - ID: 0
+ Table:
+ - Code: 0x1
+ Tag: DW_TAG_compile_unit
+ Children: DW_CHILDREN_yes
+ Attributes:
+ - Attribute: DW_AT_language
+ Form: DW_FORM_data2
+ - Code: 0x2
+ Tag: DW_TAG_imported_declaration
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_import
+ Form: DW_FORM_ref4
+ - Code: 0x3
+ Tag: DW_TAG_module
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_name
+ Form: DW_FORM_string
+ - Code: 0x4
+ Tag: DW_TAG_module
+ Children: DW_CHILDREN_no
+
+ debug_info:
+ - Version: 5
+ UnitType: DW_UT_compile
+ AddrSize: 8
+ Entries:
+
+ - AbbrCode: 0x1
+ Values:
+ - Value: 0x04
+
+ - AbbrCode: 0x2
+ Values:
+ - Value: 0x1e
+
+ - AbbrCode: 0x2
+ Values:
+ - Value: 0x23
+
+ - AbbrCode: 0x2
+ Values:
+ - Value: 0x19
+
+ - AbbrCode: 0x3
+ Values:
+ - CStr: Foo
+
+ - AbbrCode: 0x3
+ Values:
+ - CStr: ''
+
+ - AbbrCode: 0x4
+ - AbbrCode: 0x0
+...
``````````
</details>
https://github.com/llvm/llvm-project/pull/171859
More information about the llvm-commits
mailing list