2
0

Dwarf.cpp 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. //===-- llvm/Support/Dwarf.cpp - Dwarf Framework ----------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file contains support for generic dwarf information.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "llvm/Support/Dwarf.h"
  14. #include "llvm/ADT/StringSwitch.h"
  15. #include "llvm/Support/ErrorHandling.h"
  16. using namespace llvm;
  17. using namespace dwarf;
  18. const char *llvm::dwarf::TagString(unsigned Tag) {
  19. switch (Tag) {
  20. default: return nullptr;
  21. #define HANDLE_DW_TAG(ID, NAME) \
  22. case DW_TAG_##NAME: \
  23. return "DW_TAG_" #NAME;
  24. #include "llvm/Support/Dwarf.def"
  25. }
  26. }
  27. unsigned llvm::dwarf::getTag(StringRef TagString) {
  28. return StringSwitch<unsigned>(TagString)
  29. #define HANDLE_DW_TAG(ID, NAME) .Case("DW_TAG_" #NAME, DW_TAG_##NAME)
  30. #include "llvm/Support/Dwarf.def"
  31. .Default(DW_TAG_invalid);
  32. }
  33. const char *llvm::dwarf::ChildrenString(unsigned Children) {
  34. switch (Children) {
  35. case DW_CHILDREN_no: return "DW_CHILDREN_no";
  36. case DW_CHILDREN_yes: return "DW_CHILDREN_yes";
  37. }
  38. return nullptr;
  39. }
  40. const char *llvm::dwarf::AttributeString(unsigned Attribute) {
  41. switch (Attribute) {
  42. case DW_AT_sibling: return "DW_AT_sibling";
  43. case DW_AT_location: return "DW_AT_location";
  44. case DW_AT_name: return "DW_AT_name";
  45. case DW_AT_ordering: return "DW_AT_ordering";
  46. case DW_AT_byte_size: return "DW_AT_byte_size";
  47. case DW_AT_bit_offset: return "DW_AT_bit_offset";
  48. case DW_AT_bit_size: return "DW_AT_bit_size";
  49. case DW_AT_stmt_list: return "DW_AT_stmt_list";
  50. case DW_AT_low_pc: return "DW_AT_low_pc";
  51. case DW_AT_high_pc: return "DW_AT_high_pc";
  52. case DW_AT_language: return "DW_AT_language";
  53. case DW_AT_discr: return "DW_AT_discr";
  54. case DW_AT_discr_value: return "DW_AT_discr_value";
  55. case DW_AT_visibility: return "DW_AT_visibility";
  56. case DW_AT_import: return "DW_AT_import";
  57. case DW_AT_string_length: return "DW_AT_string_length";
  58. case DW_AT_common_reference: return "DW_AT_common_reference";
  59. case DW_AT_comp_dir: return "DW_AT_comp_dir";
  60. case DW_AT_const_value: return "DW_AT_const_value";
  61. case DW_AT_containing_type: return "DW_AT_containing_type";
  62. case DW_AT_default_value: return "DW_AT_default_value";
  63. case DW_AT_inline: return "DW_AT_inline";
  64. case DW_AT_is_optional: return "DW_AT_is_optional";
  65. case DW_AT_lower_bound: return "DW_AT_lower_bound";
  66. case DW_AT_producer: return "DW_AT_producer";
  67. case DW_AT_prototyped: return "DW_AT_prototyped";
  68. case DW_AT_return_addr: return "DW_AT_return_addr";
  69. case DW_AT_start_scope: return "DW_AT_start_scope";
  70. case DW_AT_bit_stride: return "DW_AT_bit_stride";
  71. case DW_AT_upper_bound: return "DW_AT_upper_bound";
  72. case DW_AT_abstract_origin: return "DW_AT_abstract_origin";
  73. case DW_AT_accessibility: return "DW_AT_accessibility";
  74. case DW_AT_address_class: return "DW_AT_address_class";
  75. case DW_AT_artificial: return "DW_AT_artificial";
  76. case DW_AT_base_types: return "DW_AT_base_types";
  77. case DW_AT_calling_convention: return "DW_AT_calling_convention";
  78. case DW_AT_count: return "DW_AT_count";
  79. case DW_AT_data_member_location: return "DW_AT_data_member_location";
  80. case DW_AT_decl_column: return "DW_AT_decl_column";
  81. case DW_AT_decl_file: return "DW_AT_decl_file";
  82. case DW_AT_decl_line: return "DW_AT_decl_line";
  83. case DW_AT_declaration: return "DW_AT_declaration";
  84. case DW_AT_discr_list: return "DW_AT_discr_list";
  85. case DW_AT_encoding: return "DW_AT_encoding";
  86. case DW_AT_external: return "DW_AT_external";
  87. case DW_AT_frame_base: return "DW_AT_frame_base";
  88. case DW_AT_friend: return "DW_AT_friend";
  89. case DW_AT_identifier_case: return "DW_AT_identifier_case";
  90. case DW_AT_macro_info: return "DW_AT_macro_info";
  91. case DW_AT_namelist_item: return "DW_AT_namelist_item";
  92. case DW_AT_priority: return "DW_AT_priority";
  93. case DW_AT_segment: return "DW_AT_segment";
  94. case DW_AT_specification: return "DW_AT_specification";
  95. case DW_AT_static_link: return "DW_AT_static_link";
  96. case DW_AT_type: return "DW_AT_type";
  97. case DW_AT_use_location: return "DW_AT_use_location";
  98. case DW_AT_variable_parameter: return "DW_AT_variable_parameter";
  99. case DW_AT_virtuality: return "DW_AT_virtuality";
  100. case DW_AT_vtable_elem_location: return "DW_AT_vtable_elem_location";
  101. case DW_AT_allocated: return "DW_AT_allocated";
  102. case DW_AT_associated: return "DW_AT_associated";
  103. case DW_AT_data_location: return "DW_AT_data_location";
  104. case DW_AT_byte_stride: return "DW_AT_byte_stride";
  105. case DW_AT_entry_pc: return "DW_AT_entry_pc";
  106. case DW_AT_use_UTF8: return "DW_AT_use_UTF8";
  107. case DW_AT_extension: return "DW_AT_extension";
  108. case DW_AT_ranges: return "DW_AT_ranges";
  109. case DW_AT_trampoline: return "DW_AT_trampoline";
  110. case DW_AT_call_column: return "DW_AT_call_column";
  111. case DW_AT_call_file: return "DW_AT_call_file";
  112. case DW_AT_call_line: return "DW_AT_call_line";
  113. case DW_AT_description: return "DW_AT_description";
  114. case DW_AT_binary_scale: return "DW_AT_binary_scale";
  115. case DW_AT_decimal_scale: return "DW_AT_decimal_scale";
  116. case DW_AT_small: return "DW_AT_small";
  117. case DW_AT_decimal_sign: return "DW_AT_decimal_sign";
  118. case DW_AT_digit_count: return "DW_AT_digit_count";
  119. case DW_AT_picture_string: return "DW_AT_picture_string";
  120. case DW_AT_mutable: return "DW_AT_mutable";
  121. case DW_AT_threads_scaled: return "DW_AT_threads_scaled";
  122. case DW_AT_explicit: return "DW_AT_explicit";
  123. case DW_AT_object_pointer: return "DW_AT_object_pointer";
  124. case DW_AT_endianity: return "DW_AT_endianity";
  125. case DW_AT_elemental: return "DW_AT_elemental";
  126. case DW_AT_pure: return "DW_AT_pure";
  127. case DW_AT_recursive: return "DW_AT_recursive";
  128. case DW_AT_signature: return "DW_AT_signature";
  129. case DW_AT_main_subprogram: return "DW_AT_main_subprogram";
  130. case DW_AT_data_bit_offset: return "DW_AT_data_bit_offset";
  131. case DW_AT_const_expr: return "DW_AT_const_expr";
  132. case DW_AT_enum_class: return "DW_AT_enum_class";
  133. case DW_AT_linkage_name: return "DW_AT_linkage_name";
  134. case DW_AT_string_length_bit_size: return "DW_AT_string_length_bit_size";
  135. case DW_AT_string_length_byte_size: return "DW_AT_string_length_byte_size";
  136. case DW_AT_rank: return "DW_AT_rank";
  137. case DW_AT_str_offsets_base: return "DW_AT_str_offsets_base";
  138. case DW_AT_addr_base: return "DW_AT_addr_base";
  139. case DW_AT_ranges_base: return "DW_AT_ranges_base";
  140. case DW_AT_dwo_id: return "DW_AT_dwo_id";
  141. case DW_AT_dwo_name: return "DW_AT_dwo_name";
  142. case DW_AT_reference: return "DW_AT_reference";
  143. case DW_AT_rvalue_reference: return "DW_AT_rvalue_reference";
  144. case DW_AT_MIPS_loop_begin: return "DW_AT_MIPS_loop_begin";
  145. case DW_AT_MIPS_tail_loop_begin: return "DW_AT_MIPS_tail_loop_begin";
  146. case DW_AT_MIPS_epilog_begin: return "DW_AT_MIPS_epilog_begin";
  147. case DW_AT_MIPS_loop_unroll_factor: return "DW_AT_MIPS_loop_unroll_factor";
  148. case DW_AT_MIPS_software_pipeline_depth:
  149. return "DW_AT_MIPS_software_pipeline_depth";
  150. case DW_AT_MIPS_linkage_name: return "DW_AT_MIPS_linkage_name";
  151. case DW_AT_MIPS_stride: return "DW_AT_MIPS_stride";
  152. case DW_AT_MIPS_abstract_name: return "DW_AT_MIPS_abstract_name";
  153. case DW_AT_MIPS_clone_origin: return "DW_AT_MIPS_clone_origin";
  154. case DW_AT_MIPS_has_inlines: return "DW_AT_MIPS_has_inlines";
  155. case DW_AT_MIPS_stride_byte: return "DW_AT_MIPS_stride_byte";
  156. case DW_AT_MIPS_stride_elem: return "DW_AT_MIPS_stride_elem";
  157. case DW_AT_MIPS_ptr_dopetype: return "DW_AT_MIPS_ptr_dopetype";
  158. case DW_AT_MIPS_allocatable_dopetype:
  159. return "DW_AT_MIPS_allocatable_dopetype";
  160. case DW_AT_MIPS_assumed_shape_dopetype:
  161. return "DW_AT_MIPS_assumed_shape_dopetype";
  162. case DW_AT_sf_names: return "DW_AT_sf_names";
  163. case DW_AT_src_info: return "DW_AT_src_info";
  164. case DW_AT_mac_info: return "DW_AT_mac_info";
  165. case DW_AT_src_coords: return "DW_AT_src_coords";
  166. case DW_AT_body_begin: return "DW_AT_body_begin";
  167. case DW_AT_body_end: return "DW_AT_body_end";
  168. case DW_AT_GNU_vector: return "DW_AT_GNU_vector";
  169. case DW_AT_GNU_template_name: return "DW_AT_GNU_template_name";
  170. case DW_AT_GNU_odr_signature: return "DW_AT_GNU_odr_signature";
  171. case DW_AT_MIPS_assumed_size: return "DW_AT_MIPS_assumed_size";
  172. case DW_AT_lo_user: return "DW_AT_lo_user";
  173. case DW_AT_hi_user: return "DW_AT_hi_user";
  174. case DW_AT_APPLE_optimized: return "DW_AT_APPLE_optimized";
  175. case DW_AT_APPLE_flags: return "DW_AT_APPLE_flags";
  176. case DW_AT_APPLE_isa: return "DW_AT_APPLE_isa";
  177. case DW_AT_APPLE_block: return "DW_AT_APPLE_block";
  178. case DW_AT_APPLE_major_runtime_vers: return "DW_AT_APPLE_major_runtime_vers";
  179. case DW_AT_APPLE_runtime_class: return "DW_AT_APPLE_runtime_class";
  180. case DW_AT_APPLE_omit_frame_ptr: return "DW_AT_APPLE_omit_frame_ptr";
  181. case DW_AT_APPLE_property_name: return "DW_AT_APPLE_property_name";
  182. case DW_AT_APPLE_property_getter: return "DW_AT_APPLE_property_getter";
  183. case DW_AT_APPLE_property_setter: return "DW_AT_APPLE_property_setter";
  184. case DW_AT_APPLE_property_attribute: return "DW_AT_APPLE_property_attribute";
  185. case DW_AT_APPLE_property: return "DW_AT_APPLE_property";
  186. case DW_AT_APPLE_objc_complete_type: return "DW_AT_APPLE_objc_complete_type";
  187. case DW_AT_LLVM_include_path: return "DW_AT_LLVM_include_path";
  188. case DW_AT_LLVM_config_macros: return "DW_AT_LLVM_config_macros";
  189. case DW_AT_LLVM_isysroot: return "DW_AT_LLVM_isysroot";
  190. // DWARF5 Fission Extension Attribute
  191. case DW_AT_GNU_dwo_name: return "DW_AT_GNU_dwo_name";
  192. case DW_AT_GNU_dwo_id: return "DW_AT_GNU_dwo_id";
  193. case DW_AT_GNU_ranges_base: return "DW_AT_GNU_ranges_base";
  194. case DW_AT_GNU_addr_base: return "DW_AT_GNU_addr_base";
  195. case DW_AT_GNU_pubnames: return "DW_AT_GNU_pubnames";
  196. case DW_AT_GNU_pubtypes: return "DW_AT_GNU_pubtypes";
  197. }
  198. return nullptr;
  199. }
  200. const char *llvm::dwarf::FormEncodingString(unsigned Encoding) {
  201. switch (Encoding) {
  202. case DW_FORM_addr: return "DW_FORM_addr";
  203. case DW_FORM_block2: return "DW_FORM_block2";
  204. case DW_FORM_block4: return "DW_FORM_block4";
  205. case DW_FORM_data2: return "DW_FORM_data2";
  206. case DW_FORM_data4: return "DW_FORM_data4";
  207. case DW_FORM_data8: return "DW_FORM_data8";
  208. case DW_FORM_string: return "DW_FORM_string";
  209. case DW_FORM_block: return "DW_FORM_block";
  210. case DW_FORM_block1: return "DW_FORM_block1";
  211. case DW_FORM_data1: return "DW_FORM_data1";
  212. case DW_FORM_flag: return "DW_FORM_flag";
  213. case DW_FORM_sdata: return "DW_FORM_sdata";
  214. case DW_FORM_strp: return "DW_FORM_strp";
  215. case DW_FORM_udata: return "DW_FORM_udata";
  216. case DW_FORM_ref_addr: return "DW_FORM_ref_addr";
  217. case DW_FORM_ref1: return "DW_FORM_ref1";
  218. case DW_FORM_ref2: return "DW_FORM_ref2";
  219. case DW_FORM_ref4: return "DW_FORM_ref4";
  220. case DW_FORM_ref8: return "DW_FORM_ref8";
  221. case DW_FORM_ref_udata: return "DW_FORM_ref_udata";
  222. case DW_FORM_indirect: return "DW_FORM_indirect";
  223. case DW_FORM_sec_offset: return "DW_FORM_sec_offset";
  224. case DW_FORM_exprloc: return "DW_FORM_exprloc";
  225. case DW_FORM_flag_present: return "DW_FORM_flag_present";
  226. case DW_FORM_ref_sig8: return "DW_FORM_ref_sig8";
  227. // DWARF5 Fission Extension Forms
  228. case DW_FORM_GNU_addr_index: return "DW_FORM_GNU_addr_index";
  229. case DW_FORM_GNU_str_index: return "DW_FORM_GNU_str_index";
  230. // Alternate debug sections proposal (output of "dwz" tool).
  231. case DW_FORM_GNU_ref_alt: return "DW_FORM_GNU_ref_alt";
  232. case DW_FORM_GNU_strp_alt: return "DW_FORM_GNU_strp_alt";
  233. }
  234. return nullptr;
  235. }
  236. const char *llvm::dwarf::OperationEncodingString(unsigned Encoding) {
  237. switch (Encoding) {
  238. default: return nullptr;
  239. #define HANDLE_DW_OP(ID, NAME) \
  240. case DW_OP_##NAME: \
  241. return "DW_OP_" #NAME;
  242. #include "llvm/Support/Dwarf.def"
  243. }
  244. }
  245. unsigned llvm::dwarf::getOperationEncoding(StringRef OperationEncodingString) {
  246. return StringSwitch<unsigned>(OperationEncodingString)
  247. #define HANDLE_DW_OP(ID, NAME) .Case("DW_OP_" #NAME, DW_OP_##NAME)
  248. #include "llvm/Support/Dwarf.def"
  249. .Default(0);
  250. }
  251. const char *llvm::dwarf::AttributeEncodingString(unsigned Encoding) {
  252. switch (Encoding) {
  253. default: return nullptr;
  254. #define HANDLE_DW_ATE(ID, NAME) \
  255. case DW_ATE_##NAME: \
  256. return "DW_ATE_" #NAME;
  257. #include "llvm/Support/Dwarf.def"
  258. }
  259. }
  260. unsigned llvm::dwarf::getAttributeEncoding(StringRef EncodingString) {
  261. return StringSwitch<unsigned>(EncodingString)
  262. #define HANDLE_DW_ATE(ID, NAME) .Case("DW_ATE_" #NAME, DW_ATE_##NAME)
  263. #include "llvm/Support/Dwarf.def"
  264. .Default(0);
  265. }
  266. const char *llvm::dwarf::DecimalSignString(unsigned Sign) {
  267. switch (Sign) {
  268. case DW_DS_unsigned: return "DW_DS_unsigned";
  269. case DW_DS_leading_overpunch: return "DW_DS_leading_overpunch";
  270. case DW_DS_trailing_overpunch: return "DW_DS_trailing_overpunch";
  271. case DW_DS_leading_separate: return "DW_DS_leading_separate";
  272. case DW_DS_trailing_separate: return "DW_DS_trailing_separate";
  273. }
  274. return nullptr;
  275. }
  276. const char *llvm::dwarf::EndianityString(unsigned Endian) {
  277. switch (Endian) {
  278. case DW_END_default: return "DW_END_default";
  279. case DW_END_big: return "DW_END_big";
  280. case DW_END_little: return "DW_END_little";
  281. case DW_END_lo_user: return "DW_END_lo_user";
  282. case DW_END_hi_user: return "DW_END_hi_user";
  283. }
  284. return nullptr;
  285. }
  286. const char *llvm::dwarf::AccessibilityString(unsigned Access) {
  287. switch (Access) {
  288. // Accessibility codes
  289. case DW_ACCESS_public: return "DW_ACCESS_public";
  290. case DW_ACCESS_protected: return "DW_ACCESS_protected";
  291. case DW_ACCESS_private: return "DW_ACCESS_private";
  292. }
  293. return nullptr;
  294. }
  295. const char *llvm::dwarf::VisibilityString(unsigned Visibility) {
  296. switch (Visibility) {
  297. case DW_VIS_local: return "DW_VIS_local";
  298. case DW_VIS_exported: return "DW_VIS_exported";
  299. case DW_VIS_qualified: return "DW_VIS_qualified";
  300. }
  301. return nullptr;
  302. }
  303. const char *llvm::dwarf::VirtualityString(unsigned Virtuality) {
  304. switch (Virtuality) {
  305. default:
  306. return nullptr;
  307. #define HANDLE_DW_VIRTUALITY(ID, NAME) \
  308. case DW_VIRTUALITY_##NAME: \
  309. return "DW_VIRTUALITY_" #NAME;
  310. #include "llvm/Support/Dwarf.def"
  311. }
  312. }
  313. unsigned llvm::dwarf::getVirtuality(StringRef VirtualityString) {
  314. return StringSwitch<unsigned>(VirtualityString)
  315. #define HANDLE_DW_VIRTUALITY(ID, NAME) \
  316. .Case("DW_VIRTUALITY_" #NAME, DW_VIRTUALITY_##NAME)
  317. #include "llvm/Support/Dwarf.def"
  318. .Default(DW_VIRTUALITY_invalid);
  319. }
  320. const char *llvm::dwarf::LanguageString(unsigned Language) {
  321. switch (Language) {
  322. default:
  323. return nullptr;
  324. #define HANDLE_DW_LANG(ID, NAME) \
  325. case DW_LANG_##NAME: \
  326. return "DW_LANG_" #NAME;
  327. #include "llvm/Support/Dwarf.def"
  328. }
  329. }
  330. unsigned llvm::dwarf::getLanguage(StringRef LanguageString) {
  331. return StringSwitch<unsigned>(LanguageString)
  332. #define HANDLE_DW_LANG(ID, NAME) .Case("DW_LANG_" #NAME, DW_LANG_##NAME)
  333. #include "llvm/Support/Dwarf.def"
  334. .Default(0);
  335. }
  336. const char *llvm::dwarf::CaseString(unsigned Case) {
  337. switch (Case) {
  338. case DW_ID_case_sensitive: return "DW_ID_case_sensitive";
  339. case DW_ID_up_case: return "DW_ID_up_case";
  340. case DW_ID_down_case: return "DW_ID_down_case";
  341. case DW_ID_case_insensitive: return "DW_ID_case_insensitive";
  342. }
  343. return nullptr;
  344. }
  345. const char *llvm::dwarf::ConventionString(unsigned Convention) {
  346. switch (Convention) {
  347. case DW_CC_normal: return "DW_CC_normal";
  348. case DW_CC_program: return "DW_CC_program";
  349. case DW_CC_nocall: return "DW_CC_nocall";
  350. case DW_CC_lo_user: return "DW_CC_lo_user";
  351. case DW_CC_hi_user: return "DW_CC_hi_user";
  352. }
  353. return nullptr;
  354. }
  355. const char *llvm::dwarf::InlineCodeString(unsigned Code) {
  356. switch (Code) {
  357. case DW_INL_not_inlined: return "DW_INL_not_inlined";
  358. case DW_INL_inlined: return "DW_INL_inlined";
  359. case DW_INL_declared_not_inlined: return "DW_INL_declared_not_inlined";
  360. case DW_INL_declared_inlined: return "DW_INL_declared_inlined";
  361. }
  362. return nullptr;
  363. }
  364. const char *llvm::dwarf::ArrayOrderString(unsigned Order) {
  365. switch (Order) {
  366. case DW_ORD_row_major: return "DW_ORD_row_major";
  367. case DW_ORD_col_major: return "DW_ORD_col_major";
  368. }
  369. return nullptr;
  370. }
  371. const char *llvm::dwarf::DiscriminantString(unsigned Discriminant) {
  372. switch (Discriminant) {
  373. case DW_DSC_label: return "DW_DSC_label";
  374. case DW_DSC_range: return "DW_DSC_range";
  375. }
  376. return nullptr;
  377. }
  378. const char *llvm::dwarf::LNStandardString(unsigned Standard) {
  379. switch (Standard) {
  380. case DW_LNS_copy: return "DW_LNS_copy";
  381. case DW_LNS_advance_pc: return "DW_LNS_advance_pc";
  382. case DW_LNS_advance_line: return "DW_LNS_advance_line";
  383. case DW_LNS_set_file: return "DW_LNS_set_file";
  384. case DW_LNS_set_column: return "DW_LNS_set_column";
  385. case DW_LNS_negate_stmt: return "DW_LNS_negate_stmt";
  386. case DW_LNS_set_basic_block: return "DW_LNS_set_basic_block";
  387. case DW_LNS_const_add_pc: return "DW_LNS_const_add_pc";
  388. case DW_LNS_fixed_advance_pc: return "DW_LNS_fixed_advance_pc";
  389. case DW_LNS_set_prologue_end: return "DW_LNS_set_prologue_end";
  390. case DW_LNS_set_epilogue_begin: return "DW_LNS_set_epilogue_begin";
  391. case DW_LNS_set_isa: return "DW_LNS_set_isa";
  392. }
  393. return nullptr;
  394. }
  395. const char *llvm::dwarf::LNExtendedString(unsigned Encoding) {
  396. switch (Encoding) {
  397. // Line Number Extended Opcode Encodings
  398. case DW_LNE_end_sequence: return "DW_LNE_end_sequence";
  399. case DW_LNE_set_address: return "DW_LNE_set_address";
  400. case DW_LNE_define_file: return "DW_LNE_define_file";
  401. case DW_LNE_set_discriminator: return "DW_LNE_set_discriminator";
  402. case DW_LNE_lo_user: return "DW_LNE_lo_user";
  403. case DW_LNE_hi_user: return "DW_LNE_hi_user";
  404. }
  405. return nullptr;
  406. }
  407. const char *llvm::dwarf::MacinfoString(unsigned Encoding) {
  408. switch (Encoding) {
  409. // Macinfo Type Encodings
  410. case DW_MACINFO_define: return "DW_MACINFO_define";
  411. case DW_MACINFO_undef: return "DW_MACINFO_undef";
  412. case DW_MACINFO_start_file: return "DW_MACINFO_start_file";
  413. case DW_MACINFO_end_file: return "DW_MACINFO_end_file";
  414. case DW_MACINFO_vendor_ext: return "DW_MACINFO_vendor_ext";
  415. }
  416. return nullptr;
  417. }
  418. const char *llvm::dwarf::CallFrameString(unsigned Encoding) {
  419. switch (Encoding) {
  420. case DW_CFA_nop: return "DW_CFA_nop";
  421. case DW_CFA_advance_loc: return "DW_CFA_advance_loc";
  422. case DW_CFA_offset: return "DW_CFA_offset";
  423. case DW_CFA_restore: return "DW_CFA_restore";
  424. case DW_CFA_set_loc: return "DW_CFA_set_loc";
  425. case DW_CFA_advance_loc1: return "DW_CFA_advance_loc1";
  426. case DW_CFA_advance_loc2: return "DW_CFA_advance_loc2";
  427. case DW_CFA_advance_loc4: return "DW_CFA_advance_loc4";
  428. case DW_CFA_offset_extended: return "DW_CFA_offset_extended";
  429. case DW_CFA_restore_extended: return "DW_CFA_restore_extended";
  430. case DW_CFA_undefined: return "DW_CFA_undefined";
  431. case DW_CFA_same_value: return "DW_CFA_same_value";
  432. case DW_CFA_register: return "DW_CFA_register";
  433. case DW_CFA_remember_state: return "DW_CFA_remember_state";
  434. case DW_CFA_restore_state: return "DW_CFA_restore_state";
  435. case DW_CFA_def_cfa: return "DW_CFA_def_cfa";
  436. case DW_CFA_def_cfa_register: return "DW_CFA_def_cfa_register";
  437. case DW_CFA_def_cfa_offset: return "DW_CFA_def_cfa_offset";
  438. case DW_CFA_def_cfa_expression: return "DW_CFA_def_cfa_expression";
  439. case DW_CFA_expression: return "DW_CFA_expression";
  440. case DW_CFA_offset_extended_sf: return "DW_CFA_offset_extended_sf";
  441. case DW_CFA_def_cfa_sf: return "DW_CFA_def_cfa_sf";
  442. case DW_CFA_def_cfa_offset_sf: return "DW_CFA_def_cfa_offset_sf";
  443. case DW_CFA_val_offset: return "DW_CFA_val_offset";
  444. case DW_CFA_val_offset_sf: return "DW_CFA_val_offset_sf";
  445. case DW_CFA_val_expression: return "DW_CFA_val_expression";
  446. case DW_CFA_MIPS_advance_loc8: return "DW_CFA_MIPS_advance_loc8";
  447. case DW_CFA_GNU_window_save: return "DW_CFA_GNU_window_save";
  448. case DW_CFA_GNU_args_size: return "DW_CFA_GNU_args_size";
  449. case DW_CFA_lo_user: return "DW_CFA_lo_user";
  450. case DW_CFA_hi_user: return "DW_CFA_hi_user";
  451. }
  452. return nullptr;
  453. }
  454. const char *llvm::dwarf::ApplePropertyString(unsigned Prop) {
  455. switch (Prop) {
  456. case DW_APPLE_PROPERTY_readonly:
  457. return "DW_APPLE_PROPERTY_readonly";
  458. case DW_APPLE_PROPERTY_getter:
  459. return "DW_APPLE_PROPERTY_getter";
  460. case DW_APPLE_PROPERTY_assign:
  461. return "DW_APPLE_PROPERTY_assign";
  462. case DW_APPLE_PROPERTY_readwrite:
  463. return "DW_APPLE_PROPERTY_readwrite";
  464. case DW_APPLE_PROPERTY_retain:
  465. return "DW_APPLE_PROPERTY_retain";
  466. case DW_APPLE_PROPERTY_copy:
  467. return "DW_APPLE_PROPERTY_copy";
  468. case DW_APPLE_PROPERTY_nonatomic:
  469. return "DW_APPLE_PROPERTY_nonatomic";
  470. case DW_APPLE_PROPERTY_setter:
  471. return "DW_APPLE_PROPERTY_setter";
  472. case DW_APPLE_PROPERTY_atomic:
  473. return "DW_APPLE_PROPERTY_atomic";
  474. case DW_APPLE_PROPERTY_weak:
  475. return "DW_APPLE_PROPERTY_weak";
  476. case DW_APPLE_PROPERTY_strong:
  477. return "DW_APPLE_PROPERTY_strong";
  478. case DW_APPLE_PROPERTY_unsafe_unretained:
  479. return "DW_APPLE_PROPERTY_unsafe_unretained";
  480. }
  481. return nullptr;
  482. }
  483. const char *llvm::dwarf::AtomTypeString(unsigned AT) {
  484. switch (AT) {
  485. case dwarf::DW_ATOM_null:
  486. return "DW_ATOM_null";
  487. case dwarf::DW_ATOM_die_offset:
  488. return "DW_ATOM_die_offset";
  489. case DW_ATOM_cu_offset:
  490. return "DW_ATOM_cu_offset";
  491. case DW_ATOM_die_tag:
  492. return "DW_ATOM_die_tag";
  493. case DW_ATOM_type_flags:
  494. return "DW_ATOM_type_flags";
  495. }
  496. return nullptr;
  497. }
  498. const char *llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
  499. switch (Kind) {
  500. case GIEK_NONE:
  501. return "NONE";
  502. case GIEK_TYPE:
  503. return "TYPE";
  504. case GIEK_VARIABLE:
  505. return "VARIABLE";
  506. case GIEK_FUNCTION:
  507. return "FUNCTION";
  508. case GIEK_OTHER:
  509. return "OTHER";
  510. case GIEK_UNUSED5:
  511. return "UNUSED5";
  512. case GIEK_UNUSED6:
  513. return "UNUSED6";
  514. case GIEK_UNUSED7:
  515. return "UNUSED7";
  516. }
  517. llvm_unreachable("Unknown GDBIndexEntryKind value");
  518. }
  519. const char *llvm::dwarf::GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage) {
  520. switch (Linkage) {
  521. case GIEL_EXTERNAL:
  522. return "EXTERNAL";
  523. case GIEL_STATIC:
  524. return "STATIC";
  525. }
  526. llvm_unreachable("Unknown GDBIndexEntryLinkage value");
  527. }
  528. const char *llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) {
  529. switch (Attr) {
  530. case DW_AT_accessibility:
  531. return AccessibilityString(Val);
  532. case DW_AT_virtuality:
  533. return VirtualityString(Val);
  534. case DW_AT_language:
  535. return LanguageString(Val);
  536. case DW_AT_encoding:
  537. return AttributeEncodingString(Val);
  538. case DW_AT_decimal_sign:
  539. return DecimalSignString(Val);
  540. case DW_AT_endianity:
  541. return EndianityString(Val);
  542. case DW_AT_visibility:
  543. return VisibilityString(Val);
  544. case DW_AT_identifier_case:
  545. return CaseString(Val);
  546. case DW_AT_calling_convention:
  547. return ConventionString(Val);
  548. case DW_AT_inline:
  549. return InlineCodeString(Val);
  550. case DW_AT_ordering:
  551. return ArrayOrderString(Val);
  552. case DW_AT_discr_value:
  553. return DiscriminantString(Val);
  554. }
  555. return nullptr;
  556. }