Skip to content

Commit 5bc7b9d

Browse files
authored
[llvm][dwarfdump] Print the name (if available) of entities referenced by DW_AT_import (#171859)
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")`
1 parent 64dfc26 commit 5bc7b9d

File tree

8 files changed

+144
-22
lines changed

8 files changed

+144
-22
lines changed

llvm/lib/DebugInfo/DWARF/DWARFDie.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
246246
// having both the raw value and the pretty-printed value is
247247
// interesting. These attributes are handled below.
248248
if (Attr == DW_AT_specification || Attr == DW_AT_abstract_origin ||
249-
Attr == DW_AT_call_origin) {
249+
Attr == DW_AT_call_origin || Attr == DW_AT_import) {
250250
if (const char *Name =
251251
Die.getAttributeValueAsReferencedDie(FormValue).getName(
252252
DINameKind::LinkageName))

llvm/test/DebugInfo/Generic/import-inlined-declaration.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
; CHECK: DW_TAG_variable
3131
; CHECK: NULL
3232
; CHECK: DW_TAG_imported_declaration
33-
; CHECK: DW_AT_import ([[FOO]])
33+
; CHECK: DW_AT_import ([[FOO]] "_ZN2ns3fooEv")
3434
; CHECK: NULL
3535
; CHECK: NULL
3636

llvm/test/DebugInfo/Generic/namespace.ll

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
; CHECK: DW_TAG_imported_module
5353
; CHECK: DW_AT_decl_file ([[F2:.*]])
5454
; CHECK: DW_AT_decl_line (15)
55-
; CHECK: DW_AT_import ([[NS2]])
55+
; CHECK: DW_AT_import ([[NS2]] "B")
5656
; CHECK: DW_TAG_imported_declaration
5757
; CHECK: NULL
5858

@@ -72,60 +72,60 @@
7272
; CHECK: DW_TAG_imported_module
7373
; CHECK: DW_AT_decl_file ([[F2:.*]])
7474
; CHECK: DW_AT_decl_line (26)
75-
; CHECK: DW_AT_import ([[NS1]])
75+
; CHECK: DW_AT_import ([[NS1]] "A")
7676
; CHECK: DW_TAG_imported_declaration
7777
; CHECK: DW_AT_decl_file ([[F2]])
7878
; CHECK: DW_AT_decl_line (27)
79-
; CHECK: DW_AT_import ([[FOO]])
79+
; CHECK: DW_AT_import ([[FOO]] "foo")
8080
; CHECK: DW_TAG_imported_declaration
8181
; CHECK: DW_AT_decl_file ([[F2]])
8282
; CHECK: DW_AT_decl_line (28)
83-
; CHECK: DW_AT_import ([[BAR]])
83+
; CHECK: DW_AT_import ([[BAR]] "bar")
8484
; CHECK: DW_TAG_imported_declaration
8585
; CHECK: DW_AT_decl_file ([[F2]])
8686
; CHECK: DW_AT_decl_line (29)
87-
; CHECK: DW_AT_import ([[FUNC1]])
87+
; CHECK: DW_AT_import ([[FUNC1]] {{.*}})
8888
; CHECK: DW_TAG_imported_declaration
8989
; CHECK: DW_AT_decl_file ([[F2]])
9090
; CHECK: DW_AT_decl_line (30)
91-
; CHECK: DW_AT_import ([[I]])
91+
; CHECK: DW_AT_import ([[I]] "_ZN1A1B1iE")
9292
; CHECK: DW_TAG_imported_declaration
9393
; CHECK: DW_AT_decl_file ([[F2]])
9494
; CHECK: DW_AT_decl_line (31)
95-
; CHECK: DW_AT_import ([[BAZ]])
95+
; CHECK: DW_AT_import ([[BAZ]] "baz")
9696
; CHECK: [[X:0x[0-9a-f]*]]:{{ *}}DW_TAG_imported_declaration
9797
; CHECK: DW_AT_decl_file ([[F2]])
9898
; CHECK: DW_AT_decl_line (32)
99-
; CHECK: DW_AT_import ([[NS1]])
99+
; CHECK: DW_AT_import ([[NS1]] "A")
100100
; CHECK: DW_AT_name ("X")
101101
; CHECK: DW_TAG_imported_declaration
102102
; CHECK: DW_AT_decl_file ([[F2]])
103103
; CHECK: DW_AT_decl_line (33)
104-
; CHECK: DW_AT_import ([[X]])
104+
; CHECK: DW_AT_import ([[X]] "X")
105105
; CHECK: DW_AT_name ("Y")
106106
; CHECK: DW_TAG_imported_declaration
107107
; CHECK: DW_AT_decl_file ([[F2]])
108108
; CHECK: DW_AT_decl_line (34)
109-
; CHECK: DW_AT_import ([[VAR_DECL]])
109+
; CHECK: DW_AT_import ([[VAR_DECL]] "_ZN1A1B8var_declE")
110110
; CHECK: DW_TAG_imported_declaration
111111
; CHECK: DW_AT_decl_file ([[F2]])
112112
; CHECK: DW_AT_decl_line (35)
113-
; CHECK: DW_AT_import ([[FUNC_DECL]])
113+
; CHECK: DW_AT_import ([[FUNC_DECL]] "_ZN1A1B9func_declEv")
114114
; CHECK: DW_TAG_imported_declaration
115115
; CHECK: DW_AT_decl_file ([[F2]])
116116
; CHECK: DW_AT_decl_line (36)
117-
; CHECK: DW_AT_import ([[VAR_FWD]])
117+
; CHECK: DW_AT_import ([[VAR_FWD]] "_ZN1A1B7var_fwdE")
118118
; CHECK: DW_TAG_imported_declaration
119119
; CHECK: DW_AT_decl_file ([[F2]])
120120
; CHECK: DW_AT_decl_line (37)
121-
; CHECK: DW_AT_import ([[FUNC_FWD]])
121+
; CHECK: DW_AT_import ([[FUNC_FWD]] "_ZN1A1B8func_fwdEv")
122122
; CHECK: NULL
123123

124124
; CHECK: DW_TAG_subprogram
125125
; CHECK: DW_TAG_imported_module
126126
; CHECK: DW_AT_decl_file ([[F2:.*]])
127127
; CHECK: DW_AT_decl_line (18)
128-
; CHECK: DW_AT_import ([[NS1]])
128+
; CHECK: DW_AT_import ([[NS1]] "A")
129129
; CHECK: DW_TAG_imported_declaration
130130
; CHECK: DW_TAG_base_type
131131
; CHECK: NULL

llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ target triple = "x86_64-unknown-linux-gnu"
2121
; CHECK: [[ABSTRACT_FOO:0x[0-9a-f]+]]: DW_TAG_subprogram
2222
; CHECK: DW_AT_name ("foo")
2323
; CHECK: DW_TAG_imported_declaration
24-
; CHECK: DW_AT_import ([[A:0x[0-9a-f]+]])
24+
; CHECK: DW_AT_import ([[A:0x[0-9a-f]+]]
2525
; CHECK: NULL
2626

2727
; CHECK: DW_TAG_base_type

llvm/test/DebugInfo/X86/dimodule-external-fortran.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
; CHECK: DW_TAG_imported_module
3030
; CHECK-NEXT: DW_AT_decl_file
3131
; CHECK-NEXT: DW_AT_decl_line
32-
; CHECK-NEXT: DW_AT_import ([[DIE_ID]])
32+
; CHECK-NEXT: DW_AT_import ([[DIE_ID]] "external_module")
3333

3434
; When the debugger sees the module being imported is a declaration,
3535
; it should go to the global scope to find the module's definition.

llvm/test/DebugInfo/X86/dwarfdump-DIImportedEntity_elements.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
; CHECK: DW_TAG_subprogram
1414
; CHECK: DW_AT_name ("use_renamed")
1515
; CHECK: DW_TAG_imported_module
16-
; CHECK: DW_AT_import ([[MYMOD]])
16+
; CHECK: DW_AT_import ([[MYMOD]] "mymod")
1717
; CHECK: DW_TAG_imported_declaration
18-
; CHECK: DW_AT_import ([[VAR1]])
18+
; CHECK: DW_AT_import ([[VAR1]] "var1")
1919
; CHECK: DW_AT_name ("var4")
2020

2121
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

llvm/test/tools/dsymutil/X86/modules-empty.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ int main() {
3030

3131
// The empty CU from the pcm should not get copied into the dSYM.
3232
// Check that module name occured only once.
33-
// CHECK: "Empty"
34-
// CHECK-NOT: "Empty"
33+
// CHECK: DW_AT_name ("Empty")
34+
// CHECK-NOT: DW_AT_name ("Empty")
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# RUN: yaml2obj %s | llvm-dwarfdump -verify - | FileCheck %s --check-prefix=VERIFY
2+
# VERIFY: No errors.
3+
#
4+
# RUN: yaml2obj %s | llvm-dwarfdump - | FileCheck %s
5+
# CHECK: DW_AT_import ({{.*}} "Foo")
6+
# CHECK: DW_AT_import ({{.*}} "")
7+
# CHECK: DW_AT_import ({{.*}})
8+
# CHECK: DW_AT_import ({{.*}} "FooLinkage")
9+
# CHECK: DW_AT_import ({{.*}} "JustLinkage")
10+
# CHECK: DW_AT_import ({{.*}} "NoLinkage")
11+
12+
--- !ELF
13+
FileHeader:
14+
Class: ELFCLASS64
15+
Data: ELFDATA2LSB
16+
Type: ET_EXEC
17+
Machine: EM_AARCH64
18+
DWARF:
19+
debug_abbrev:
20+
- ID: 0
21+
Table:
22+
- Code: 0x1
23+
Tag: DW_TAG_compile_unit
24+
Children: DW_CHILDREN_yes
25+
Attributes:
26+
- Attribute: DW_AT_language
27+
Form: DW_FORM_data2
28+
- Code: 0x2
29+
Tag: DW_TAG_imported_declaration
30+
Children: DW_CHILDREN_no
31+
Attributes:
32+
- Attribute: DW_AT_import
33+
Form: DW_FORM_ref4
34+
- Code: 0x3
35+
Tag: DW_TAG_module
36+
Children: DW_CHILDREN_no
37+
Attributes:
38+
- Attribute: DW_AT_name
39+
Form: DW_FORM_string
40+
- Code: 0x4
41+
Tag: DW_TAG_module
42+
Children: DW_CHILDREN_no
43+
- Code: 0x5
44+
Tag: DW_TAG_subprogram
45+
Children: DW_CHILDREN_no
46+
Attributes:
47+
- Attribute: DW_AT_name
48+
Form: DW_FORM_string
49+
- Attribute: DW_AT_linkage_name
50+
Form: DW_FORM_string
51+
- Code: 0x6
52+
Tag: DW_TAG_subprogram
53+
Children: DW_CHILDREN_no
54+
Attributes:
55+
- Attribute: DW_AT_linkage_name
56+
Form: DW_FORM_string
57+
- Code: 0x7
58+
Tag: DW_TAG_subprogram
59+
Children: DW_CHILDREN_no
60+
Attributes:
61+
- Attribute: DW_AT_name
62+
Form: DW_FORM_string
63+
64+
debug_info:
65+
- Version: 5
66+
UnitType: DW_UT_compile
67+
AddrSize: 8
68+
Entries:
69+
70+
- AbbrCode: 0x1
71+
Values:
72+
- Value: 0x04
73+
74+
- AbbrCode: 0x2
75+
Values:
76+
- Value: 0x2d
77+
78+
- AbbrCode: 0x2
79+
Values:
80+
- Value: 0x32
81+
82+
- AbbrCode: 0x2
83+
Values:
84+
- Value: 0x34
85+
86+
- AbbrCode: 0x2
87+
Values:
88+
- Value: 0x35
89+
90+
- AbbrCode: 0x2
91+
Values:
92+
- Value: 0x45
93+
94+
- AbbrCode: 0x2
95+
Values:
96+
- Value: 0x52
97+
98+
- AbbrCode: 0x3
99+
Values:
100+
- CStr: Foo
101+
102+
- AbbrCode: 0x3
103+
Values:
104+
- CStr: ''
105+
106+
- AbbrCode: 0x4
107+
108+
- AbbrCode: 0x5
109+
Values:
110+
- CStr: Foo
111+
- CStr: FooLinkage
112+
113+
- AbbrCode: 0x6
114+
Values:
115+
- CStr: JustLinkage
116+
117+
- AbbrCode: 0x7
118+
Values:
119+
- CStr: NoLinkage
120+
121+
- AbbrCode: 0x0
122+
...

0 commit comments

Comments
 (0)