xref: /llvm-project/llvm/test/tools/llvm-dwarfdump/dump_dwo.test (revision dc1e2790e476499f6007efcd73ab9d648bfc48bb)
1## Check that llvm-dwarfdump works when dumping .o files with .dwo files.
2
3# RUN: yaml2obj %p/Inputs/dump_dwo.o.yaml -o %T/dump_dwo.o
4# RUN: yaml2obj %p/Inputs/dump_dwo.dwo.yaml -o %T/dump_dwo.dwo
5## We need to be in the same directory so we can find .dwo file
6# RUN: cd %T
7# RUN: llvm-dwarfdump --dwo dump_dwo.o | FileCheck %s
8# RUN: llvm-dwarfdump --dwo --name int --name char dump_dwo.o | FileCheck %s --check-prefix=NAMES
9# RUN: llvm-dwarfdump --name int --name char dump_dwo.o | FileCheck %s --check-prefix=NAMES_NO_DWO
10# RUN: llvm-dwarfdump --dwo --lookup 0x10 dump_dwo.o | FileCheck %s --check-prefix=LOOKUP
11# RUN: llvm-dwarfdump --lookup 0x10 dump_dwo.o | FileCheck %s --check-prefix=LOOKUP_NO_DWO
12
13
14## Make sure if we dump dump_dwo.o with the --dwo option that we see the
15## contents of the dump_dwo.o _and_ the dump_dwo.dwo file.
16
17# CHECK: .debug_info contents:
18# CHECK: 0x00000000: Compile Unit: length = 0x00000024, format = DWARF32, version = 0x0005, unit_type = DW_UT_skeleton, abbr_offset = 0x0000, addr_size = 0x08, DWO_id = 0x376dd35da7c3c136 (next unit at 0x00000028)
19
20# CHECK: 0x00000014: DW_TAG_skeleton_unit
21# CHECK:               DW_AT_stmt_list	(0x00000000)
22# CHECK:               DW_AT_str_offsets_base	(0x00000008)
23# CHECK:               DW_AT_comp_dir	("./")
24# CHECK:               DW_AT_GNU_pubnames	(true)
25# CHECK:               DW_AT_dwo_name	("./dump_dwo.dwo")
26# CHECK:               DW_AT_low_pc	(0x0000000000000000)
27# CHECK:               DW_AT_high_pc	(0x0000000000000033)
28# CHECK:               DW_AT_addr_base	(0x00000008)
29
30# CHECK: 0x00000014: DW_TAG_compile_unit
31# CHECK:               DW_AT_producer	("Apple clang version 15.0.0 (clang-1500.1.0.2.5)")
32# CHECK:               DW_AT_language	(DW_LANG_C_plus_plus)
33# CHECK:               DW_AT_name	("dump_dwo.cpp")
34# CHECK:               DW_AT_dwo_name	("./dump_dwo.dwo")
35
36# CHECK: 0x0000001a:   DW_TAG_subprogram
37# CHECK:                 DW_AT_low_pc	(0x0000000000000000)
38# CHECK:                 DW_AT_high_pc	(0x0000000000000008)
39# CHECK:                 DW_AT_frame_base	(DW_OP_reg6
40# CHECK:                 DW_AT_linkage_name	("_Z3foov")
41# CHECK:                 DW_AT_name	("foo")
42# CHECK:                 DW_AT_decl_file	(0x00)
43# CHECK:                 DW_AT_decl_line	(2)
44# CHECK:                 DW_AT_type	(0x00000050 "int")
45# CHECK:                 DW_AT_external	(true)
46
47# CHECK: 0x0000002a:   DW_TAG_subprogram
48# CHECK:                 DW_AT_low_pc	(0x0000000000000010)
49# CHECK:                 DW_AT_high_pc	(0x0000000000000033)
50# CHECK:                 DW_AT_frame_base	(DW_OP_reg6
51# CHECK:                 DW_AT_name	("main")
52# CHECK:                 DW_AT_decl_file	(0x00)
53# CHECK:                 DW_AT_decl_line	(6)
54# CHECK:                 DW_AT_type	(0x00000050 "int")
55# CHECK:                 DW_AT_external	(true)
56
57# CHECK: 0x00000039:     DW_TAG_formal_parameter
58# CHECK:                   DW_AT_location	(DW_OP_fbreg -8)
59# CHECK:                   DW_AT_name	("argc")
60# CHECK:                   DW_AT_decl_file	(0x00)
61# CHECK:                   DW_AT_decl_line	(6)
62# CHECK:                   DW_AT_type	(0x00000050 "int")
63
64# CHECK: 0x00000044:     DW_TAG_formal_parameter
65# CHECK:                   DW_AT_location	(DW_OP_fbreg -16)
66# CHECK:                   DW_AT_name	("argv")
67# CHECK:                   DW_AT_decl_file	(0x00)
68# CHECK:                   DW_AT_decl_line	(6)
69# CHECK:                   DW_AT_type	(0x00000054 "const char **")
70
71# CHECK: 0x0000004f:     NULL
72
73# CHECK: 0x00000050:   DW_TAG_base_type
74# CHECK:                 DW_AT_name	("int")
75# CHECK:                 DW_AT_encoding	(DW_ATE_signed)
76# CHECK:                 DW_AT_byte_size	(0x04)
77
78# CHECK: 0x00000054:   DW_TAG_pointer_type
79# CHECK:                 DW_AT_type	(0x00000059 "const char *")
80
81# CHECK: 0x00000059:   DW_TAG_pointer_type
82# CHECK:                 DW_AT_type	(0x0000005e "const char")
83
84# CHECK: 0x0000005e:   DW_TAG_const_type
85# CHECK:                 DW_AT_type	(0x00000063 "char")
86
87# CHECK: 0x00000063:   DW_TAG_base_type
88# CHECK:                 DW_AT_name	("char")
89# CHECK:                 DW_AT_encoding	(DW_ATE_signed_char)
90# CHECK:                 DW_AT_byte_size	(0x01)
91
92# CHECK: 0x00000067:   NULL
93
94
95## Make sure that if we do specify the --dwo when using --name that we get
96## the expected results form the .dwo file
97
98# NAMES: 0x00000050: DW_TAG_base_type
99# NAMES:               DW_AT_name	("int")
100# NAMES:               DW_AT_encoding	(DW_ATE_signed)
101# NAMES:               DW_AT_byte_size	(0x04)
102
103# NAMES: 0x00000063: DW_TAG_base_type
104# NAMES:               DW_AT_name	("char")
105# NAMES:               DW_AT_encoding	(DW_ATE_signed_char)
106# NAMES:               DW_AT_byte_size	(0x01)
107
108## Make sure that if we don't specify the --dwo when using --name that we get
109## no results
110
111# NAMES_NO_DWO-NOT:  0x00000050: DW_TAG_base_type
112# NAMES_NO_DWO-NOT:  0x00000063: DW_TAG_base_type
113
114## Make sure address lookups succeed when using the --dwo option and the
115## --lookup option. Verify that we see the information from the .dwo file which
116## means "unit_type = DW_UT_split_compile" and that we see a DW_TAG_compile_unit
117# LOOKUP: 0x00000000: Compile Unit: length = 0x00000064, format = DWARF32, version = 0x0005, unit_type = DW_UT_split_compile, abbr_offset = 0x0000, addr_size = 0x08, DWO_id = 0x376dd35da7c3c136 (next unit at 0x00000068)
118
119# LOOKUP: 0x00000014: DW_TAG_compile_unit
120# LOOKUP:               DW_AT_producer	("Apple clang version 15.0.0 (clang-1500.1.0.2.5)")
121# LOOKUP:               DW_AT_language	(DW_LANG_C_plus_plus)
122# LOOKUP:               DW_AT_name	("dump_dwo.cpp")
123# LOOKUP:               DW_AT_dwo_name	("./dump_dwo.dwo")
124
125# LOOKUP: 0x0000002a:   DW_TAG_subprogram
126# LOOKUP:                 DW_AT_low_pc	(0x0000000000000010)
127# LOOKUP:                 DW_AT_high_pc	(0x0000000000000033)
128# LOOKUP:                 DW_AT_frame_base	(DW_OP_reg6
129# LOOKUP:                 DW_AT_name	("main")
130# LOOKUP:                 DW_AT_decl_file	(0x00)
131# LOOKUP:                 DW_AT_decl_line	(6)
132# LOOKUP:                 DW_AT_type	(0x00000050 "int")
133# LOOKUP:                 DW_AT_external	(true)
134
135## Make sure address lookups succeed when not using the --dwo option and the
136## --lookup option. Verify that we see the information from the .o file which
137## Means "unit_type = DW_UT_skeleton" and that we see a DW_TAG_skeleton_unit
138
139# LOOKUP_NO_DWO: 0x00000000: Compile Unit: length = 0x00000024, format = DWARF32, version = 0x0005, unit_type = DW_UT_skeleton, abbr_offset = 0x0000, addr_size = 0x08, DWO_id = 0x376dd35da7c3c136 (next unit at 0x00000028)
140
141# LOOKUP_NO_DWO: 0x00000014: DW_TAG_skeleton_unit
142# LOOKUP_NO_DWO:               DW_AT_stmt_list	(0x00000000)
143# LOOKUP_NO_DWO:               DW_AT_str_offsets_base	(0x00000008)
144# LOOKUP_NO_DWO:               DW_AT_comp_dir	("./")
145# LOOKUP_NO_DWO:               DW_AT_GNU_pubnames	(true)
146# LOOKUP_NO_DWO:               DW_AT_dwo_name	("./dump_dwo.dwo")
147# LOOKUP_NO_DWO:               DW_AT_low_pc	(0x0000000000000000)
148# LOOKUP_NO_DWO:               DW_AT_high_pc	(0x0000000000000033)
149# LOOKUP_NO_DWO:               DW_AT_addr_base	(0x00000008)
150