blob: 13a41557a8d21ffe287d717a1796b44aca67446b [file] [log] [blame]
Jim Laskey22e47b92006-02-27 12:43:29 +00001//===-- llvm/Support/Dwarf.cpp - Dwarf Framework ----------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jim Laskey22e47b92006-02-27 12:43:29 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains support for generic dwarf information.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/Support/Dwarf.h"
Duncan P. N. Exon Smith6f5546c2015-02-03 21:16:49 +000015#include "llvm/ADT/StringSwitch.h"
David Blaikied0a869d2013-09-19 22:19:37 +000016#include "llvm/Support/ErrorHandling.h"
17
Chris Lattner3b326722009-12-29 07:28:33 +000018using namespace llvm;
19using namespace dwarf;
Jim Laskey22e47b92006-02-27 12:43:29 +000020
Chris Lattner3b326722009-12-29 07:28:33 +000021const char *llvm::dwarf::TagString(unsigned Tag) {
Mike Stump889285d2009-05-13 23:23:20 +000022 switch (Tag) {
Duncan P. N. Exon Smith981811e2015-02-03 21:13:16 +000023 default: return nullptr;
24#define HANDLE_DW_TAG(ID, NAME) \
25 case DW_TAG_##NAME: \
26 return "DW_TAG_" #NAME;
27#include "llvm/Support/Dwarf.def"
Jim Laskey22e47b92006-02-27 12:43:29 +000028 }
Jim Laskey22e47b92006-02-27 12:43:29 +000029}
30
Duncan P. N. Exon Smith6f5546c2015-02-03 21:16:49 +000031unsigned llvm::dwarf::getTag(StringRef TagString) {
32 return StringSwitch<unsigned>(TagString)
33#define HANDLE_DW_TAG(ID, NAME) .Case("DW_TAG_" #NAME, DW_TAG_##NAME)
34#include "llvm/Support/Dwarf.def"
35 .Default(DW_TAG_invalid);
36}
37
Chris Lattner3b326722009-12-29 07:28:33 +000038const char *llvm::dwarf::ChildrenString(unsigned Children) {
Mike Stump889285d2009-05-13 23:23:20 +000039 switch (Children) {
Jason Molendadd6a4ca2010-06-17 01:23:24 +000040 case DW_CHILDREN_no: return "DW_CHILDREN_no";
41 case DW_CHILDREN_yes: return "DW_CHILDREN_yes";
Jim Laskey22e47b92006-02-27 12:43:29 +000042 }
Craig Topperc10719f2014-04-07 04:17:22 +000043 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +000044}
45
Chris Lattner3b326722009-12-29 07:28:33 +000046const char *llvm::dwarf::AttributeString(unsigned Attribute) {
Mike Stump889285d2009-05-13 23:23:20 +000047 switch (Attribute) {
Chris Lattner0709a272009-12-29 21:09:57 +000048 case DW_AT_sibling: return "DW_AT_sibling";
49 case DW_AT_location: return "DW_AT_location";
50 case DW_AT_name: return "DW_AT_name";
51 case DW_AT_ordering: return "DW_AT_ordering";
52 case DW_AT_byte_size: return "DW_AT_byte_size";
53 case DW_AT_bit_offset: return "DW_AT_bit_offset";
54 case DW_AT_bit_size: return "DW_AT_bit_size";
55 case DW_AT_stmt_list: return "DW_AT_stmt_list";
56 case DW_AT_low_pc: return "DW_AT_low_pc";
57 case DW_AT_high_pc: return "DW_AT_high_pc";
58 case DW_AT_language: return "DW_AT_language";
59 case DW_AT_discr: return "DW_AT_discr";
60 case DW_AT_discr_value: return "DW_AT_discr_value";
61 case DW_AT_visibility: return "DW_AT_visibility";
62 case DW_AT_import: return "DW_AT_import";
63 case DW_AT_string_length: return "DW_AT_string_length";
64 case DW_AT_common_reference: return "DW_AT_common_reference";
65 case DW_AT_comp_dir: return "DW_AT_comp_dir";
66 case DW_AT_const_value: return "DW_AT_const_value";
67 case DW_AT_containing_type: return "DW_AT_containing_type";
68 case DW_AT_default_value: return "DW_AT_default_value";
69 case DW_AT_inline: return "DW_AT_inline";
70 case DW_AT_is_optional: return "DW_AT_is_optional";
71 case DW_AT_lower_bound: return "DW_AT_lower_bound";
72 case DW_AT_producer: return "DW_AT_producer";
73 case DW_AT_prototyped: return "DW_AT_prototyped";
74 case DW_AT_return_addr: return "DW_AT_return_addr";
75 case DW_AT_start_scope: return "DW_AT_start_scope";
76 case DW_AT_bit_stride: return "DW_AT_bit_stride";
77 case DW_AT_upper_bound: return "DW_AT_upper_bound";
78 case DW_AT_abstract_origin: return "DW_AT_abstract_origin";
79 case DW_AT_accessibility: return "DW_AT_accessibility";
80 case DW_AT_address_class: return "DW_AT_address_class";
81 case DW_AT_artificial: return "DW_AT_artificial";
82 case DW_AT_base_types: return "DW_AT_base_types";
83 case DW_AT_calling_convention: return "DW_AT_calling_convention";
84 case DW_AT_count: return "DW_AT_count";
85 case DW_AT_data_member_location: return "DW_AT_data_member_location";
86 case DW_AT_decl_column: return "DW_AT_decl_column";
87 case DW_AT_decl_file: return "DW_AT_decl_file";
88 case DW_AT_decl_line: return "DW_AT_decl_line";
89 case DW_AT_declaration: return "DW_AT_declaration";
90 case DW_AT_discr_list: return "DW_AT_discr_list";
91 case DW_AT_encoding: return "DW_AT_encoding";
92 case DW_AT_external: return "DW_AT_external";
93 case DW_AT_frame_base: return "DW_AT_frame_base";
94 case DW_AT_friend: return "DW_AT_friend";
95 case DW_AT_identifier_case: return "DW_AT_identifier_case";
96 case DW_AT_macro_info: return "DW_AT_macro_info";
97 case DW_AT_namelist_item: return "DW_AT_namelist_item";
98 case DW_AT_priority: return "DW_AT_priority";
99 case DW_AT_segment: return "DW_AT_segment";
100 case DW_AT_specification: return "DW_AT_specification";
101 case DW_AT_static_link: return "DW_AT_static_link";
102 case DW_AT_type: return "DW_AT_type";
103 case DW_AT_use_location: return "DW_AT_use_location";
104 case DW_AT_variable_parameter: return "DW_AT_variable_parameter";
105 case DW_AT_virtuality: return "DW_AT_virtuality";
106 case DW_AT_vtable_elem_location: return "DW_AT_vtable_elem_location";
107 case DW_AT_allocated: return "DW_AT_allocated";
108 case DW_AT_associated: return "DW_AT_associated";
109 case DW_AT_data_location: return "DW_AT_data_location";
110 case DW_AT_byte_stride: return "DW_AT_byte_stride";
111 case DW_AT_entry_pc: return "DW_AT_entry_pc";
112 case DW_AT_use_UTF8: return "DW_AT_use_UTF8";
113 case DW_AT_extension: return "DW_AT_extension";
114 case DW_AT_ranges: return "DW_AT_ranges";
115 case DW_AT_trampoline: return "DW_AT_trampoline";
116 case DW_AT_call_column: return "DW_AT_call_column";
117 case DW_AT_call_file: return "DW_AT_call_file";
118 case DW_AT_call_line: return "DW_AT_call_line";
119 case DW_AT_description: return "DW_AT_description";
120 case DW_AT_binary_scale: return "DW_AT_binary_scale";
121 case DW_AT_decimal_scale: return "DW_AT_decimal_scale";
122 case DW_AT_small: return "DW_AT_small";
123 case DW_AT_decimal_sign: return "DW_AT_decimal_sign";
124 case DW_AT_digit_count: return "DW_AT_digit_count";
125 case DW_AT_picture_string: return "DW_AT_picture_string";
126 case DW_AT_mutable: return "DW_AT_mutable";
127 case DW_AT_threads_scaled: return "DW_AT_threads_scaled";
128 case DW_AT_explicit: return "DW_AT_explicit";
129 case DW_AT_object_pointer: return "DW_AT_object_pointer";
130 case DW_AT_endianity: return "DW_AT_endianity";
131 case DW_AT_elemental: return "DW_AT_elemental";
132 case DW_AT_pure: return "DW_AT_pure";
133 case DW_AT_recursive: return "DW_AT_recursive";
Nick Lewycky34368122011-09-15 04:23:44 +0000134 case DW_AT_signature: return "DW_AT_signature";
135 case DW_AT_main_subprogram: return "DW_AT_main_subprogram";
136 case DW_AT_data_bit_offset: return "DW_AT_data_bit_offset";
137 case DW_AT_const_expr: return "DW_AT_const_expr";
138 case DW_AT_enum_class: return "DW_AT_enum_class";
139 case DW_AT_linkage_name: return "DW_AT_linkage_name";
Adrian Prantl31631e42013-12-18 21:48:14 +0000140 case DW_AT_string_length_bit_size: return "DW_AT_string_length_bit_size";
141 case DW_AT_string_length_byte_size: return "DW_AT_string_length_byte_size";
142 case DW_AT_rank: return "DW_AT_rank";
143 case DW_AT_str_offsets_base: return "DW_AT_str_offsets_base";
144 case DW_AT_addr_base: return "DW_AT_addr_base";
145 case DW_AT_ranges_base: return "DW_AT_ranges_base";
146 case DW_AT_dwo_id: return "DW_AT_dwo_id";
147 case DW_AT_dwo_name: return "DW_AT_dwo_name";
148 case DW_AT_reference: return "DW_AT_reference";
149 case DW_AT_rvalue_reference: return "DW_AT_rvalue_reference";
Nick Lewyckyee674b32011-09-15 05:21:03 +0000150 case DW_AT_MIPS_loop_begin: return "DW_AT_MIPS_loop_begin";
151 case DW_AT_MIPS_tail_loop_begin: return "DW_AT_MIPS_tail_loop_begin";
152 case DW_AT_MIPS_epilog_begin: return "DW_AT_MIPS_epilog_begin";
153 case DW_AT_MIPS_loop_unroll_factor: return "DW_AT_MIPS_loop_unroll_factor";
154 case DW_AT_MIPS_software_pipeline_depth:
155 return "DW_AT_MIPS_software_pipeline_depth";
Chris Lattner0709a272009-12-29 21:09:57 +0000156 case DW_AT_MIPS_linkage_name: return "DW_AT_MIPS_linkage_name";
Nick Lewyckyee674b32011-09-15 05:21:03 +0000157 case DW_AT_MIPS_stride: return "DW_AT_MIPS_stride";
158 case DW_AT_MIPS_abstract_name: return "DW_AT_MIPS_abstract_name";
159 case DW_AT_MIPS_clone_origin: return "DW_AT_MIPS_clone_origin";
160 case DW_AT_MIPS_has_inlines: return "DW_AT_MIPS_has_inlines";
161 case DW_AT_MIPS_stride_byte: return "DW_AT_MIPS_stride_byte";
162 case DW_AT_MIPS_stride_elem: return "DW_AT_MIPS_stride_elem";
163 case DW_AT_MIPS_ptr_dopetype: return "DW_AT_MIPS_ptr_dopetype";
164 case DW_AT_MIPS_allocatable_dopetype:
165 return "DW_AT_MIPS_allocatable_dopetype";
166 case DW_AT_MIPS_assumed_shape_dopetype:
167 return "DW_AT_MIPS_assumed_shape_dopetype";
Chris Lattner0709a272009-12-29 21:09:57 +0000168 case DW_AT_sf_names: return "DW_AT_sf_names";
169 case DW_AT_src_info: return "DW_AT_src_info";
170 case DW_AT_mac_info: return "DW_AT_mac_info";
171 case DW_AT_src_coords: return "DW_AT_src_coords";
172 case DW_AT_body_begin: return "DW_AT_body_begin";
173 case DW_AT_body_end: return "DW_AT_body_end";
174 case DW_AT_GNU_vector: return "DW_AT_GNU_vector";
Nick Lewyckyee674b32011-09-15 05:21:03 +0000175 case DW_AT_GNU_template_name: return "DW_AT_GNU_template_name";
Eric Christopher8e46e7f2013-07-14 22:02:31 +0000176 case DW_AT_GNU_odr_signature: return "DW_AT_GNU_odr_signature";
Nick Lewyckyee674b32011-09-15 05:21:03 +0000177 case DW_AT_MIPS_assumed_size: return "DW_AT_MIPS_assumed_size";
Chris Lattner0709a272009-12-29 21:09:57 +0000178 case DW_AT_lo_user: return "DW_AT_lo_user";
179 case DW_AT_hi_user: return "DW_AT_hi_user";
180 case DW_AT_APPLE_optimized: return "DW_AT_APPLE_optimized";
181 case DW_AT_APPLE_flags: return "DW_AT_APPLE_flags";
182 case DW_AT_APPLE_isa: return "DW_AT_APPLE_isa";
183 case DW_AT_APPLE_block: return "DW_AT_APPLE_block";
Devang Patel61880932010-04-19 19:14:02 +0000184 case DW_AT_APPLE_major_runtime_vers: return "DW_AT_APPLE_major_runtime_vers";
Chris Lattner0709a272009-12-29 21:09:57 +0000185 case DW_AT_APPLE_runtime_class: return "DW_AT_APPLE_runtime_class";
Devang Patel561fa8492010-04-19 20:31:39 +0000186 case DW_AT_APPLE_omit_frame_ptr: return "DW_AT_APPLE_omit_frame_ptr";
Devang Patel514b4002011-04-16 00:11:51 +0000187 case DW_AT_APPLE_property_name: return "DW_AT_APPLE_property_name";
188 case DW_AT_APPLE_property_getter: return "DW_AT_APPLE_property_getter";
189 case DW_AT_APPLE_property_setter: return "DW_AT_APPLE_property_setter";
190 case DW_AT_APPLE_property_attribute: return "DW_AT_APPLE_property_attribute";
Devang Patel839515b2012-02-03 23:57:08 +0000191 case DW_AT_APPLE_property: return "DW_AT_APPLE_property";
Devang Patel12419ae2011-05-12 21:29:42 +0000192 case DW_AT_APPLE_objc_complete_type: return "DW_AT_APPLE_objc_complete_type";
Adrian Prantl08a388b2015-06-30 02:13:04 +0000193 case DW_AT_LLVM_include_path: return "DW_AT_LLVM_include_path";
194 case DW_AT_LLVM_config_macros: return "DW_AT_LLVM_config_macros";
195 case DW_AT_LLVM_isysroot: return "DW_AT_LLVM_isysroot";
Eric Christopherc7e43ff2012-11-30 23:20:43 +0000196
Bill Wendling3d7b0b82012-12-19 07:18:57 +0000197 // DWARF5 Fission Extension Attribute
Eric Christopherc7e43ff2012-11-30 23:20:43 +0000198 case DW_AT_GNU_dwo_name: return "DW_AT_GNU_dwo_name";
199 case DW_AT_GNU_dwo_id: return "DW_AT_GNU_dwo_id";
200 case DW_AT_GNU_ranges_base: return "DW_AT_GNU_ranges_base";
201 case DW_AT_GNU_addr_base: return "DW_AT_GNU_addr_base";
202 case DW_AT_GNU_pubnames: return "DW_AT_GNU_pubnames";
203 case DW_AT_GNU_pubtypes: return "DW_AT_GNU_pubtypes";
Jim Laskey22e47b92006-02-27 12:43:29 +0000204 }
Craig Topperc10719f2014-04-07 04:17:22 +0000205 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000206}
207
Chris Lattner3b326722009-12-29 07:28:33 +0000208const char *llvm::dwarf::FormEncodingString(unsigned Encoding) {
Mike Stump889285d2009-05-13 23:23:20 +0000209 switch (Encoding) {
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000210 case DW_FORM_addr: return "DW_FORM_addr";
211 case DW_FORM_block2: return "DW_FORM_block2";
212 case DW_FORM_block4: return "DW_FORM_block4";
213 case DW_FORM_data2: return "DW_FORM_data2";
214 case DW_FORM_data4: return "DW_FORM_data4";
215 case DW_FORM_data8: return "DW_FORM_data8";
216 case DW_FORM_string: return "DW_FORM_string";
217 case DW_FORM_block: return "DW_FORM_block";
218 case DW_FORM_block1: return "DW_FORM_block1";
219 case DW_FORM_data1: return "DW_FORM_data1";
220 case DW_FORM_flag: return "DW_FORM_flag";
221 case DW_FORM_sdata: return "DW_FORM_sdata";
222 case DW_FORM_strp: return "DW_FORM_strp";
223 case DW_FORM_udata: return "DW_FORM_udata";
224 case DW_FORM_ref_addr: return "DW_FORM_ref_addr";
225 case DW_FORM_ref1: return "DW_FORM_ref1";
226 case DW_FORM_ref2: return "DW_FORM_ref2";
227 case DW_FORM_ref4: return "DW_FORM_ref4";
228 case DW_FORM_ref8: return "DW_FORM_ref8";
229 case DW_FORM_ref_udata: return "DW_FORM_ref_udata";
230 case DW_FORM_indirect: return "DW_FORM_indirect";
Nick Lewycky34368122011-09-15 04:23:44 +0000231 case DW_FORM_sec_offset: return "DW_FORM_sec_offset";
232 case DW_FORM_exprloc: return "DW_FORM_exprloc";
233 case DW_FORM_flag_present: return "DW_FORM_flag_present";
234 case DW_FORM_ref_sig8: return "DW_FORM_ref_sig8";
Eric Christopherc7e43ff2012-11-30 23:20:43 +0000235
236 // DWARF5 Fission Extension Forms
237 case DW_FORM_GNU_addr_index: return "DW_FORM_GNU_addr_index";
238 case DW_FORM_GNU_str_index: return "DW_FORM_GNU_str_index";
Alexey Samsonovbf19a572015-05-19 20:29:28 +0000239
240 // Alternate debug sections proposal (output of "dwz" tool).
241 case DW_FORM_GNU_ref_alt: return "DW_FORM_GNU_ref_alt";
242 case DW_FORM_GNU_strp_alt: return "DW_FORM_GNU_strp_alt";
Jim Laskey22e47b92006-02-27 12:43:29 +0000243 }
Craig Topperc10719f2014-04-07 04:17:22 +0000244 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000245}
246
Chris Lattner3b326722009-12-29 07:28:33 +0000247const char *llvm::dwarf::OperationEncodingString(unsigned Encoding) {
Mike Stump889285d2009-05-13 23:23:20 +0000248 switch (Encoding) {
Duncan P. N. Exon Smith8f46ee62015-02-13 01:04:08 +0000249 default: return nullptr;
250#define HANDLE_DW_OP(ID, NAME) \
251 case DW_OP_##NAME: \
252 return "DW_OP_" #NAME;
253#include "llvm/Support/Dwarf.def"
Jim Laskey22e47b92006-02-27 12:43:29 +0000254 }
Jim Laskey22e47b92006-02-27 12:43:29 +0000255}
256
Duncan P. N. Exon Smith3b631d22015-02-13 01:05:00 +0000257unsigned llvm::dwarf::getOperationEncoding(StringRef OperationEncodingString) {
258 return StringSwitch<unsigned>(OperationEncodingString)
259#define HANDLE_DW_OP(ID, NAME) .Case("DW_OP_" #NAME, DW_OP_##NAME)
260#include "llvm/Support/Dwarf.def"
261 .Default(0);
262}
263
Chris Lattner3b326722009-12-29 07:28:33 +0000264const char *llvm::dwarf::AttributeEncodingString(unsigned Encoding) {
Mike Stump889285d2009-05-13 23:23:20 +0000265 switch (Encoding) {
Duncan P. N. Exon Smithdd563dd2015-02-06 23:45:37 +0000266 default: return nullptr;
267#define HANDLE_DW_ATE(ID, NAME) \
268 case DW_ATE_##NAME: \
269 return "DW_ATE_" #NAME;
270#include "llvm/Support/Dwarf.def"
Jim Laskey22e47b92006-02-27 12:43:29 +0000271 }
Jim Laskey22e47b92006-02-27 12:43:29 +0000272}
273
Duncan P. N. Exon Smithe07f13a2015-02-06 23:46:49 +0000274unsigned llvm::dwarf::getAttributeEncoding(StringRef EncodingString) {
275 return StringSwitch<unsigned>(EncodingString)
276#define HANDLE_DW_ATE(ID, NAME) .Case("DW_ATE_" #NAME, DW_ATE_##NAME)
277#include "llvm/Support/Dwarf.def"
278 .Default(0);
279}
280
Chris Lattner3b326722009-12-29 07:28:33 +0000281const char *llvm::dwarf::DecimalSignString(unsigned Sign) {
Mike Stump889285d2009-05-13 23:23:20 +0000282 switch (Sign) {
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000283 case DW_DS_unsigned: return "DW_DS_unsigned";
284 case DW_DS_leading_overpunch: return "DW_DS_leading_overpunch";
285 case DW_DS_trailing_overpunch: return "DW_DS_trailing_overpunch";
286 case DW_DS_leading_separate: return "DW_DS_leading_separate";
287 case DW_DS_trailing_separate: return "DW_DS_trailing_separate";
Jim Laskey22e47b92006-02-27 12:43:29 +0000288 }
Craig Topperc10719f2014-04-07 04:17:22 +0000289 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000290}
291
Chris Lattner3b326722009-12-29 07:28:33 +0000292const char *llvm::dwarf::EndianityString(unsigned Endian) {
Mike Stump889285d2009-05-13 23:23:20 +0000293 switch (Endian) {
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000294 case DW_END_default: return "DW_END_default";
295 case DW_END_big: return "DW_END_big";
296 case DW_END_little: return "DW_END_little";
297 case DW_END_lo_user: return "DW_END_lo_user";
298 case DW_END_hi_user: return "DW_END_hi_user";
Jim Laskey22e47b92006-02-27 12:43:29 +0000299 }
Craig Topperc10719f2014-04-07 04:17:22 +0000300 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000301}
302
Chris Lattner3b326722009-12-29 07:28:33 +0000303const char *llvm::dwarf::AccessibilityString(unsigned Access) {
Mike Stump889285d2009-05-13 23:23:20 +0000304 switch (Access) {
Chris Lattner0709a272009-12-29 21:09:57 +0000305 // Accessibility codes
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000306 case DW_ACCESS_public: return "DW_ACCESS_public";
307 case DW_ACCESS_protected: return "DW_ACCESS_protected";
308 case DW_ACCESS_private: return "DW_ACCESS_private";
Jim Laskey22e47b92006-02-27 12:43:29 +0000309 }
Craig Topperc10719f2014-04-07 04:17:22 +0000310 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000311}
312
Chris Lattner3b326722009-12-29 07:28:33 +0000313const char *llvm::dwarf::VisibilityString(unsigned Visibility) {
Mike Stump889285d2009-05-13 23:23:20 +0000314 switch (Visibility) {
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000315 case DW_VIS_local: return "DW_VIS_local";
316 case DW_VIS_exported: return "DW_VIS_exported";
317 case DW_VIS_qualified: return "DW_VIS_qualified";
Jim Laskey22e47b92006-02-27 12:43:29 +0000318 }
Craig Topperc10719f2014-04-07 04:17:22 +0000319 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000320}
321
Chris Lattner3b326722009-12-29 07:28:33 +0000322const char *llvm::dwarf::VirtualityString(unsigned Virtuality) {
Mike Stump889285d2009-05-13 23:23:20 +0000323 switch (Virtuality) {
Duncan P. N. Exon Smithd6f35742015-02-07 00:36:23 +0000324 default:
325 return nullptr;
326#define HANDLE_DW_VIRTUALITY(ID, NAME) \
327 case DW_VIRTUALITY_##NAME: \
328 return "DW_VIRTUALITY_" #NAME;
329#include "llvm/Support/Dwarf.def"
Jim Laskey22e47b92006-02-27 12:43:29 +0000330 }
Jim Laskey22e47b92006-02-27 12:43:29 +0000331}
332
Duncan P. N. Exon Smithe7e2abe2015-02-07 00:37:15 +0000333unsigned llvm::dwarf::getVirtuality(StringRef VirtualityString) {
334 return StringSwitch<unsigned>(VirtualityString)
335#define HANDLE_DW_VIRTUALITY(ID, NAME) \
336 .Case("DW_VIRTUALITY_" #NAME, DW_VIRTUALITY_##NAME)
337#include "llvm/Support/Dwarf.def"
338 .Default(DW_VIRTUALITY_invalid);
339}
340
Chris Lattner3b326722009-12-29 07:28:33 +0000341const char *llvm::dwarf::LanguageString(unsigned Language) {
Mike Stump889285d2009-05-13 23:23:20 +0000342 switch (Language) {
Duncan P. N. Exon Smith03179442015-02-06 22:53:19 +0000343 default:
344 return nullptr;
345#define HANDLE_DW_LANG(ID, NAME) \
346 case DW_LANG_##NAME: \
347 return "DW_LANG_" #NAME;
348#include "llvm/Support/Dwarf.def"
Jim Laskey22e47b92006-02-27 12:43:29 +0000349 }
Jim Laskey22e47b92006-02-27 12:43:29 +0000350}
351
Duncan P. N. Exon Smithd40af002015-02-06 22:55:13 +0000352unsigned llvm::dwarf::getLanguage(StringRef LanguageString) {
353 return StringSwitch<unsigned>(LanguageString)
354#define HANDLE_DW_LANG(ID, NAME) .Case("DW_LANG_" #NAME, DW_LANG_##NAME)
355#include "llvm/Support/Dwarf.def"
356 .Default(0);
357}
358
Chris Lattner3b326722009-12-29 07:28:33 +0000359const char *llvm::dwarf::CaseString(unsigned Case) {
Chris Lattner0709a272009-12-29 21:09:57 +0000360 switch (Case) {
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000361 case DW_ID_case_sensitive: return "DW_ID_case_sensitive";
362 case DW_ID_up_case: return "DW_ID_up_case";
363 case DW_ID_down_case: return "DW_ID_down_case";
364 case DW_ID_case_insensitive: return "DW_ID_case_insensitive";
Jim Laskey22e47b92006-02-27 12:43:29 +0000365 }
Craig Topperc10719f2014-04-07 04:17:22 +0000366 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000367}
368
Chris Lattner3b326722009-12-29 07:28:33 +0000369const char *llvm::dwarf::ConventionString(unsigned Convention) {
Mike Stump889285d2009-05-13 23:23:20 +0000370 switch (Convention) {
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000371 case DW_CC_normal: return "DW_CC_normal";
372 case DW_CC_program: return "DW_CC_program";
373 case DW_CC_nocall: return "DW_CC_nocall";
374 case DW_CC_lo_user: return "DW_CC_lo_user";
375 case DW_CC_hi_user: return "DW_CC_hi_user";
Jim Laskey22e47b92006-02-27 12:43:29 +0000376 }
Craig Topperc10719f2014-04-07 04:17:22 +0000377 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000378}
379
Chris Lattner3b326722009-12-29 07:28:33 +0000380const char *llvm::dwarf::InlineCodeString(unsigned Code) {
Chris Lattner0709a272009-12-29 21:09:57 +0000381 switch (Code) {
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000382 case DW_INL_not_inlined: return "DW_INL_not_inlined";
383 case DW_INL_inlined: return "DW_INL_inlined";
384 case DW_INL_declared_not_inlined: return "DW_INL_declared_not_inlined";
385 case DW_INL_declared_inlined: return "DW_INL_declared_inlined";
Jim Laskey22e47b92006-02-27 12:43:29 +0000386 }
Craig Topperc10719f2014-04-07 04:17:22 +0000387 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000388}
389
Chris Lattner3b326722009-12-29 07:28:33 +0000390const char *llvm::dwarf::ArrayOrderString(unsigned Order) {
Chris Lattner0709a272009-12-29 21:09:57 +0000391 switch (Order) {
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000392 case DW_ORD_row_major: return "DW_ORD_row_major";
393 case DW_ORD_col_major: return "DW_ORD_col_major";
Jim Laskey22e47b92006-02-27 12:43:29 +0000394 }
Craig Topperc10719f2014-04-07 04:17:22 +0000395 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000396}
397
Chris Lattner3b326722009-12-29 07:28:33 +0000398const char *llvm::dwarf::DiscriminantString(unsigned Discriminant) {
Chris Lattner0709a272009-12-29 21:09:57 +0000399 switch (Discriminant) {
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000400 case DW_DSC_label: return "DW_DSC_label";
401 case DW_DSC_range: return "DW_DSC_range";
Jim Laskey22e47b92006-02-27 12:43:29 +0000402 }
Craig Topperc10719f2014-04-07 04:17:22 +0000403 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000404}
405
Chris Lattner3b326722009-12-29 07:28:33 +0000406const char *llvm::dwarf::LNStandardString(unsigned Standard) {
Chris Lattner0709a272009-12-29 21:09:57 +0000407 switch (Standard) {
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000408 case DW_LNS_copy: return "DW_LNS_copy";
409 case DW_LNS_advance_pc: return "DW_LNS_advance_pc";
410 case DW_LNS_advance_line: return "DW_LNS_advance_line";
411 case DW_LNS_set_file: return "DW_LNS_set_file";
412 case DW_LNS_set_column: return "DW_LNS_set_column";
413 case DW_LNS_negate_stmt: return "DW_LNS_negate_stmt";
414 case DW_LNS_set_basic_block: return "DW_LNS_set_basic_block";
415 case DW_LNS_const_add_pc: return "DW_LNS_const_add_pc";
416 case DW_LNS_fixed_advance_pc: return "DW_LNS_fixed_advance_pc";
417 case DW_LNS_set_prologue_end: return "DW_LNS_set_prologue_end";
418 case DW_LNS_set_epilogue_begin: return "DW_LNS_set_epilogue_begin";
419 case DW_LNS_set_isa: return "DW_LNS_set_isa";
Jim Laskey22e47b92006-02-27 12:43:29 +0000420 }
Craig Topperc10719f2014-04-07 04:17:22 +0000421 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000422}
423
Chris Lattner3b326722009-12-29 07:28:33 +0000424const char *llvm::dwarf::LNExtendedString(unsigned Encoding) {
Chris Lattner0709a272009-12-29 21:09:57 +0000425 switch (Encoding) {
426 // Line Number Extended Opcode Encodings
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000427 case DW_LNE_end_sequence: return "DW_LNE_end_sequence";
428 case DW_LNE_set_address: return "DW_LNE_set_address";
429 case DW_LNE_define_file: return "DW_LNE_define_file";
Nick Lewycky34368122011-09-15 04:23:44 +0000430 case DW_LNE_set_discriminator: return "DW_LNE_set_discriminator";
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000431 case DW_LNE_lo_user: return "DW_LNE_lo_user";
432 case DW_LNE_hi_user: return "DW_LNE_hi_user";
Jim Laskey22e47b92006-02-27 12:43:29 +0000433 }
Craig Topperc10719f2014-04-07 04:17:22 +0000434 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000435}
436
Chris Lattner3b326722009-12-29 07:28:33 +0000437const char *llvm::dwarf::MacinfoString(unsigned Encoding) {
Chris Lattner0709a272009-12-29 21:09:57 +0000438 switch (Encoding) {
439 // Macinfo Type Encodings
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000440 case DW_MACINFO_define: return "DW_MACINFO_define";
441 case DW_MACINFO_undef: return "DW_MACINFO_undef";
442 case DW_MACINFO_start_file: return "DW_MACINFO_start_file";
443 case DW_MACINFO_end_file: return "DW_MACINFO_end_file";
444 case DW_MACINFO_vendor_ext: return "DW_MACINFO_vendor_ext";
Jim Laskey22e47b92006-02-27 12:43:29 +0000445 }
Craig Topperc10719f2014-04-07 04:17:22 +0000446 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000447}
448
Chris Lattner3b326722009-12-29 07:28:33 +0000449const char *llvm::dwarf::CallFrameString(unsigned Encoding) {
Chris Lattner0709a272009-12-29 21:09:57 +0000450 switch (Encoding) {
Eli Bendersky705085d2013-02-21 22:53:19 +0000451 case DW_CFA_nop: return "DW_CFA_nop";
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000452 case DW_CFA_advance_loc: return "DW_CFA_advance_loc";
453 case DW_CFA_offset: return "DW_CFA_offset";
454 case DW_CFA_restore: return "DW_CFA_restore";
455 case DW_CFA_set_loc: return "DW_CFA_set_loc";
456 case DW_CFA_advance_loc1: return "DW_CFA_advance_loc1";
457 case DW_CFA_advance_loc2: return "DW_CFA_advance_loc2";
458 case DW_CFA_advance_loc4: return "DW_CFA_advance_loc4";
459 case DW_CFA_offset_extended: return "DW_CFA_offset_extended";
460 case DW_CFA_restore_extended: return "DW_CFA_restore_extended";
461 case DW_CFA_undefined: return "DW_CFA_undefined";
462 case DW_CFA_same_value: return "DW_CFA_same_value";
463 case DW_CFA_register: return "DW_CFA_register";
464 case DW_CFA_remember_state: return "DW_CFA_remember_state";
465 case DW_CFA_restore_state: return "DW_CFA_restore_state";
466 case DW_CFA_def_cfa: return "DW_CFA_def_cfa";
467 case DW_CFA_def_cfa_register: return "DW_CFA_def_cfa_register";
468 case DW_CFA_def_cfa_offset: return "DW_CFA_def_cfa_offset";
469 case DW_CFA_def_cfa_expression: return "DW_CFA_def_cfa_expression";
470 case DW_CFA_expression: return "DW_CFA_expression";
471 case DW_CFA_offset_extended_sf: return "DW_CFA_offset_extended_sf";
472 case DW_CFA_def_cfa_sf: return "DW_CFA_def_cfa_sf";
473 case DW_CFA_def_cfa_offset_sf: return "DW_CFA_def_cfa_offset_sf";
474 case DW_CFA_val_offset: return "DW_CFA_val_offset";
475 case DW_CFA_val_offset_sf: return "DW_CFA_val_offset_sf";
476 case DW_CFA_val_expression: return "DW_CFA_val_expression";
Nick Lewyckyee674b32011-09-15 05:21:03 +0000477 case DW_CFA_MIPS_advance_loc8: return "DW_CFA_MIPS_advance_loc8";
478 case DW_CFA_GNU_window_save: return "DW_CFA_GNU_window_save";
479 case DW_CFA_GNU_args_size: return "DW_CFA_GNU_args_size";
Jason Molendadd6a4ca2010-06-17 01:23:24 +0000480 case DW_CFA_lo_user: return "DW_CFA_lo_user";
481 case DW_CFA_hi_user: return "DW_CFA_hi_user";
Jim Laskey22e47b92006-02-27 12:43:29 +0000482 }
Craig Topperc10719f2014-04-07 04:17:22 +0000483 return nullptr;
Jim Laskey22e47b92006-02-27 12:43:29 +0000484}
Eric Christophercf7289f2013-09-05 18:20:16 +0000485
Frederic Rissb5e53ee2014-10-09 20:43:04 +0000486const char *llvm::dwarf::ApplePropertyString(unsigned Prop) {
487 switch (Prop) {
488 case DW_APPLE_PROPERTY_readonly:
489 return "DW_APPLE_PROPERTY_readonly";
490 case DW_APPLE_PROPERTY_getter:
491 return "DW_APPLE_PROPERTY_getter";
492 case DW_APPLE_PROPERTY_assign:
493 return "DW_APPLE_PROPERTY_assign";
494 case DW_APPLE_PROPERTY_readwrite:
495 return "DW_APPLE_PROPERTY_readwrite";
496 case DW_APPLE_PROPERTY_retain:
497 return "DW_APPLE_PROPERTY_retain";
498 case DW_APPLE_PROPERTY_copy:
499 return "DW_APPLE_PROPERTY_copy";
500 case DW_APPLE_PROPERTY_nonatomic:
501 return "DW_APPLE_PROPERTY_nonatomic";
502 case DW_APPLE_PROPERTY_setter:
503 return "DW_APPLE_PROPERTY_setter";
504 case DW_APPLE_PROPERTY_atomic:
505 return "DW_APPLE_PROPERTY_atomic";
506 case DW_APPLE_PROPERTY_weak:
507 return "DW_APPLE_PROPERTY_weak";
508 case DW_APPLE_PROPERTY_strong:
509 return "DW_APPLE_PROPERTY_strong";
510 case DW_APPLE_PROPERTY_unsafe_unretained:
511 return "DW_APPLE_PROPERTY_unsafe_unretained";
512 }
513 return nullptr;
514}
515
Eric Christophercf7289f2013-09-05 18:20:16 +0000516const char *llvm::dwarf::AtomTypeString(unsigned AT) {
517 switch (AT) {
518 case dwarf::DW_ATOM_null:
519 return "DW_ATOM_null";
520 case dwarf::DW_ATOM_die_offset:
521 return "DW_ATOM_die_offset";
522 case DW_ATOM_cu_offset:
523 return "DW_ATOM_cu_offset";
524 case DW_ATOM_die_tag:
525 return "DW_ATOM_die_tag";
526 case DW_ATOM_type_flags:
527 return "DW_ATOM_type_flags";
528 }
Craig Topperc10719f2014-04-07 04:17:22 +0000529 return nullptr;
Eric Christophercf7289f2013-09-05 18:20:16 +0000530}
David Blaikied0a869d2013-09-19 22:19:37 +0000531
David Blaikieefd0bcb2013-09-20 00:33:15 +0000532const char *llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
David Blaikied0a869d2013-09-19 22:19:37 +0000533 switch (Kind) {
534 case GIEK_NONE:
535 return "NONE";
536 case GIEK_TYPE:
537 return "TYPE";
538 case GIEK_VARIABLE:
539 return "VARIABLE";
540 case GIEK_FUNCTION:
541 return "FUNCTION";
542 case GIEK_OTHER:
543 return "OTHER";
544 case GIEK_UNUSED5:
545 return "UNUSED5";
546 case GIEK_UNUSED6:
547 return "UNUSED6";
548 case GIEK_UNUSED7:
549 return "UNUSED7";
550 }
551 llvm_unreachable("Unknown GDBIndexEntryKind value");
552}
553
David Blaikieefd0bcb2013-09-20 00:33:15 +0000554const char *llvm::dwarf::GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage) {
David Blaikied0a869d2013-09-19 22:19:37 +0000555 switch (Linkage) {
556 case GIEL_EXTERNAL:
557 return "EXTERNAL";
558 case GIEL_STATIC:
559 return "STATIC";
560 }
561 llvm_unreachable("Unknown GDBIndexEntryLinkage value");
562}
Frederic Riss878065b2014-09-04 19:39:20 +0000563
564const char *llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) {
565 switch (Attr) {
566 case DW_AT_accessibility:
567 return AccessibilityString(Val);
568 case DW_AT_virtuality:
569 return VirtualityString(Val);
570 case DW_AT_language:
571 return LanguageString(Val);
572 case DW_AT_encoding:
573 return AttributeEncodingString(Val);
574 case DW_AT_decimal_sign:
575 return DecimalSignString(Val);
576 case DW_AT_endianity:
577 return EndianityString(Val);
578 case DW_AT_visibility:
579 return VisibilityString(Val);
580 case DW_AT_identifier_case:
581 return CaseString(Val);
582 case DW_AT_calling_convention:
583 return ConventionString(Val);
584 case DW_AT_inline:
585 return InlineCodeString(Val);
586 case DW_AT_ordering:
587 return ArrayOrderString(Val);
588 case DW_AT_discr_value:
589 return DiscriminantString(Val);
590 }
591
592 return nullptr;
593}