dwarf2.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. /* Declarations and definitions of codes relating to the DWARF2 and
  2. DWARF3 symbolic debugging information formats.
  3. Copyright (C) 1992-2022 Free Software Foundation, Inc.
  4. Written by Gary Funck (gary@intrepid.com) The Ada Joint Program
  5. Office (AJPO), Florida State University and Silicon Graphics Inc.
  6. provided support for this effort -- June 21, 1995.
  7. Derived from the DWARF 1 implementation written by Ron Guilmette
  8. (rfg@netcom.com), November 1990.
  9. This file is part of GCC.
  10. GCC is free software; you can redistribute it and/or modify it under
  11. the terms of the GNU General Public License as published by the Free
  12. Software Foundation; either version 3, or (at your option) any later
  13. version.
  14. GCC is distributed in the hope that it will be useful, but WITHOUT
  15. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  16. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  17. License for more details.
  18. Under Section 7 of GPL version 3, you are granted additional
  19. permissions described in the GCC Runtime Library Exception, version
  20. 3.1, as published by the Free Software Foundation.
  21. You should have received a copy of the GNU General Public License and
  22. a copy of the GCC Runtime Library Exception along with this program;
  23. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  24. <http://www.gnu.org/licenses/>. */
  25. /* This file is derived from the DWARF specification (a public document)
  26. Revision 2.0.0 (July 27, 1993) developed by the UNIX International
  27. Programming Languages Special Interest Group (UI/PLSIG) and distributed
  28. by UNIX International. Copies of this specification are available from
  29. UNIX International, 20 Waterview Boulevard, Parsippany, NJ, 07054.
  30. This file also now contains definitions from the DWARF 3 specification
  31. published Dec 20, 2005, available from: http://dwarf.freestandards.org. */
  32. #ifndef _DWARF2_H
  33. #define _DWARF2_H
  34. #define DW_TAG(name, value) , name = value
  35. #define DW_TAG_DUP(name, value) , name = value
  36. #define DW_FORM(name, value) , name = value
  37. #define DW_AT(name, value) , name = value
  38. #define DW_AT_DUP(name, value) , name = value
  39. #define DW_OP(name, value) , name = value
  40. #define DW_OP_DUP(name, value) , name = value
  41. #define DW_ATE(name, value) , name = value
  42. #define DW_ATE_DUP(name, value) , name = value
  43. #define DW_CFA(name, value) , name = value
  44. #define DW_CFA_DUP(name, value) , name = value
  45. #define DW_IDX(name, value) , name = value
  46. #define DW_IDX_DUP(name, value) , name = value
  47. #define DW_UT(name, value) , name = value
  48. #define DW_FIRST_TAG(name, value) enum dwarf_tag { \
  49. name = value
  50. #define DW_END_TAG };
  51. #define DW_FIRST_FORM(name, value) enum dwarf_form { \
  52. name = value
  53. #define DW_END_FORM };
  54. #define DW_FIRST_AT(name, value) enum dwarf_attribute { \
  55. name = value
  56. #define DW_END_AT };
  57. #define DW_FIRST_OP(name, value) enum dwarf_location_atom { \
  58. name = value
  59. #define DW_END_OP };
  60. #define DW_FIRST_ATE(name, value) enum dwarf_type { \
  61. name = value
  62. #define DW_END_ATE };
  63. #define DW_FIRST_CFA(name, value) enum dwarf_call_frame_info { \
  64. name = value
  65. #define DW_END_CFA };
  66. #define DW_FIRST_IDX(name, value) enum dwarf_name_index_attribute { \
  67. name = value
  68. #define DW_END_IDX };
  69. #define DW_FIRST_UT(name, value) enum dwarf_unit_type { \
  70. name = value
  71. #define DW_END_UT };
  72. #include "dwarf2.def"
  73. #undef DW_FIRST_TAG
  74. #undef DW_END_TAG
  75. #undef DW_FIRST_FORM
  76. #undef DW_END_FORM
  77. #undef DW_FIRST_AT
  78. #undef DW_END_AT
  79. #undef DW_FIRST_OP
  80. #undef DW_END_OP
  81. #undef DW_FIRST_ATE
  82. #undef DW_END_ATE
  83. #undef DW_FIRST_CFA
  84. #undef DW_END_CFA
  85. #undef DW_FIRST_IDX
  86. #undef DW_END_IDX
  87. #undef DW_FIRST_UT
  88. #undef DW_END_UT
  89. #undef DW_TAG
  90. #undef DW_TAG_DUP
  91. #undef DW_FORM
  92. #undef DW_AT
  93. #undef DW_AT_DUP
  94. #undef DW_OP
  95. #undef DW_OP_DUP
  96. #undef DW_ATE
  97. #undef DW_ATE_DUP
  98. #undef DW_CFA
  99. #undef DW_CFA_DUP
  100. #undef DW_IDX
  101. #undef DW_IDX_DUP
  102. #undef DW_UT
  103. /* Flag that tells whether entry has a child or not. */
  104. #define DW_children_no 0
  105. #define DW_children_yes 1
  106. #define DW_AT_stride_size DW_AT_bit_stride /* Note: The use of DW_AT_stride_size is deprecated. */
  107. #define DW_AT_stride DW_AT_byte_stride /* Note: The use of DW_AT_stride is deprecated. */
  108. /* Decimal sign encodings. */
  109. enum dwarf_decimal_sign_encoding
  110. {
  111. /* DWARF 3. */
  112. DW_DS_unsigned = 0x01,
  113. DW_DS_leading_overpunch = 0x02,
  114. DW_DS_trailing_overpunch = 0x03,
  115. DW_DS_leading_separate = 0x04,
  116. DW_DS_trailing_separate = 0x05
  117. };
  118. /* Endianity encodings. */
  119. enum dwarf_endianity_encoding
  120. {
  121. /* DWARF 3. */
  122. DW_END_default = 0x00,
  123. DW_END_big = 0x01,
  124. DW_END_little = 0x02,
  125. DW_END_lo_user = 0x40,
  126. DW_END_hi_user = 0xff
  127. };
  128. /* Array ordering names and codes. */
  129. enum dwarf_array_dim_ordering
  130. {
  131. DW_ORD_row_major = 0,
  132. DW_ORD_col_major = 1
  133. };
  134. /* Access attribute. */
  135. enum dwarf_access_attribute
  136. {
  137. DW_ACCESS_public = 1,
  138. DW_ACCESS_protected = 2,
  139. DW_ACCESS_private = 3
  140. };
  141. /* Visibility. */
  142. enum dwarf_visibility_attribute
  143. {
  144. DW_VIS_local = 1,
  145. DW_VIS_exported = 2,
  146. DW_VIS_qualified = 3
  147. };
  148. /* Virtuality. */
  149. enum dwarf_virtuality_attribute
  150. {
  151. DW_VIRTUALITY_none = 0,
  152. DW_VIRTUALITY_virtual = 1,
  153. DW_VIRTUALITY_pure_virtual = 2
  154. };
  155. /* Case sensitivity. */
  156. enum dwarf_id_case
  157. {
  158. DW_ID_case_sensitive = 0,
  159. DW_ID_up_case = 1,
  160. DW_ID_down_case = 2,
  161. DW_ID_case_insensitive = 3
  162. };
  163. /* Calling convention. */
  164. enum dwarf_calling_convention
  165. {
  166. DW_CC_normal = 0x1,
  167. DW_CC_program = 0x2,
  168. DW_CC_nocall = 0x3,
  169. /* DWARF 5. */
  170. DW_CC_pass_by_reference = 0x4,
  171. DW_CC_pass_by_value = 0x5,
  172. DW_CC_lo_user = 0x40,
  173. DW_CC_hi_user = 0xff,
  174. DW_CC_GNU_renesas_sh = 0x40,
  175. DW_CC_GNU_borland_fastcall_i386 = 0x41,
  176. /* This DW_CC_ value is not currently generated by any toolchain. It is
  177. used internally to GDB to indicate OpenCL C functions that have been
  178. compiled with the IBM XL C for OpenCL compiler and use a non-platform
  179. calling convention for passing OpenCL C vector types. This value may
  180. be changed freely as long as it does not conflict with any other DW_CC_
  181. value defined here. */
  182. DW_CC_GDB_IBM_OpenCL = 0xff
  183. };
  184. /* Inline attribute. */
  185. enum dwarf_inline_attribute
  186. {
  187. DW_INL_not_inlined = 0,
  188. DW_INL_inlined = 1,
  189. DW_INL_declared_not_inlined = 2,
  190. DW_INL_declared_inlined = 3
  191. };
  192. /* Discriminant lists. */
  193. enum dwarf_discrim_list
  194. {
  195. DW_DSC_label = 0,
  196. DW_DSC_range = 1
  197. };
  198. /* Line number opcodes. */
  199. enum dwarf_line_number_ops
  200. {
  201. DW_LNS_extended_op = 0,
  202. DW_LNS_copy = 1,
  203. DW_LNS_advance_pc = 2,
  204. DW_LNS_advance_line = 3,
  205. DW_LNS_set_file = 4,
  206. DW_LNS_set_column = 5,
  207. DW_LNS_negate_stmt = 6,
  208. DW_LNS_set_basic_block = 7,
  209. DW_LNS_const_add_pc = 8,
  210. DW_LNS_fixed_advance_pc = 9,
  211. /* DWARF 3. */
  212. DW_LNS_set_prologue_end = 10,
  213. DW_LNS_set_epilogue_begin = 11,
  214. DW_LNS_set_isa = 12
  215. };
  216. /* Line number extended opcodes. */
  217. enum dwarf_line_number_x_ops
  218. {
  219. DW_LNE_end_sequence = 1,
  220. DW_LNE_set_address = 2,
  221. DW_LNE_define_file = 3,
  222. DW_LNE_set_discriminator = 4,
  223. /* HP extensions. */
  224. DW_LNE_HP_negate_is_UV_update = 0x11,
  225. DW_LNE_HP_push_context = 0x12,
  226. DW_LNE_HP_pop_context = 0x13,
  227. DW_LNE_HP_set_file_line_column = 0x14,
  228. DW_LNE_HP_set_routine_name = 0x15,
  229. DW_LNE_HP_set_sequence = 0x16,
  230. DW_LNE_HP_negate_post_semantics = 0x17,
  231. DW_LNE_HP_negate_function_exit = 0x18,
  232. DW_LNE_HP_negate_front_end_logical = 0x19,
  233. DW_LNE_HP_define_proc = 0x20,
  234. DW_LNE_HP_source_file_correlation = 0x80,
  235. DW_LNE_lo_user = 0x80,
  236. DW_LNE_hi_user = 0xff
  237. };
  238. /* Sub-opcodes for DW_LNE_HP_source_file_correlation. */
  239. enum dwarf_line_number_hp_sfc_ops
  240. {
  241. DW_LNE_HP_SFC_formfeed = 1,
  242. DW_LNE_HP_SFC_set_listing_line = 2,
  243. DW_LNE_HP_SFC_associate = 3
  244. };
  245. /* Content type codes in line table directory_entry_format
  246. and file_name_entry_format sequences. */
  247. enum dwarf_line_number_content_type
  248. {
  249. DW_LNCT_path = 0x1,
  250. DW_LNCT_directory_index = 0x2,
  251. DW_LNCT_timestamp = 0x3,
  252. DW_LNCT_size = 0x4,
  253. DW_LNCT_MD5 = 0x5,
  254. DW_LNCT_lo_user = 0x2000,
  255. DW_LNCT_hi_user = 0x3fff
  256. };
  257. /* Type codes for location list entries. */
  258. enum dwarf_location_list_entry_type
  259. {
  260. DW_LLE_end_of_list = 0x00,
  261. DW_LLE_base_addressx = 0x01,
  262. DW_LLE_startx_endx = 0x02,
  263. DW_LLE_startx_length = 0x03,
  264. DW_LLE_offset_pair = 0x04,
  265. DW_LLE_default_location = 0x05,
  266. DW_LLE_base_address = 0x06,
  267. DW_LLE_start_end = 0x07,
  268. DW_LLE_start_length = 0x08,
  269. /* <http://lists.dwarfstd.org/private.cgi/dwarf-discuss-dwarfstd.org/2017-April/004347.html>
  270. has the proposal for now; only available to list members.
  271. A (possibly updated) copy of the proposal is available at
  272. <http://people.redhat.com/aoliva/papers/sfn/dwarf6-sfn-lvu.txt>. */
  273. DW_LLE_GNU_view_pair = 0x09,
  274. #define DW_LLE_view_pair DW_LLE_GNU_view_pair
  275. /* Former extension for Fission.
  276. See http://gcc.gnu.org/wiki/DebugFission. */
  277. DW_LLE_GNU_end_of_list_entry = 0x00,
  278. DW_LLE_GNU_base_address_selection_entry = 0x01,
  279. DW_LLE_GNU_start_end_entry = 0x02,
  280. DW_LLE_GNU_start_length_entry = 0x03
  281. };
  282. #define DW_CIE_ID 0xffffffff
  283. #define DW64_CIE_ID 0xffffffffffffffffULL
  284. #define DW_CFA_extended 0
  285. #define DW_CHILDREN_no 0x00
  286. #define DW_CHILDREN_yes 0x01
  287. #define DW_ADDR_none 0
  288. /* Source language names and codes. */
  289. enum dwarf_source_language
  290. {
  291. DW_LANG_C89 = 0x0001,
  292. DW_LANG_C = 0x0002,
  293. DW_LANG_Ada83 = 0x0003,
  294. DW_LANG_C_plus_plus = 0x0004,
  295. DW_LANG_Cobol74 = 0x0005,
  296. DW_LANG_Cobol85 = 0x0006,
  297. DW_LANG_Fortran77 = 0x0007,
  298. DW_LANG_Fortran90 = 0x0008,
  299. DW_LANG_Pascal83 = 0x0009,
  300. DW_LANG_Modula2 = 0x000a,
  301. /* DWARF 3. */
  302. DW_LANG_Java = 0x000b,
  303. DW_LANG_C99 = 0x000c,
  304. DW_LANG_Ada95 = 0x000d,
  305. DW_LANG_Fortran95 = 0x000e,
  306. DW_LANG_PLI = 0x000f,
  307. DW_LANG_ObjC = 0x0010,
  308. DW_LANG_ObjC_plus_plus = 0x0011,
  309. DW_LANG_UPC = 0x0012,
  310. DW_LANG_D = 0x0013,
  311. /* DWARF 4. */
  312. DW_LANG_Python = 0x0014,
  313. /* DWARF 5. */
  314. DW_LANG_OpenCL = 0x0015,
  315. DW_LANG_Go = 0x0016,
  316. DW_LANG_Modula3 = 0x0017,
  317. DW_LANG_Haskell = 0x0018,
  318. DW_LANG_C_plus_plus_03 = 0x0019,
  319. DW_LANG_C_plus_plus_11 = 0x001a,
  320. DW_LANG_OCaml = 0x001b,
  321. DW_LANG_Rust = 0x001c,
  322. DW_LANG_C11 = 0x001d,
  323. DW_LANG_Swift = 0x001e,
  324. DW_LANG_Julia = 0x001f,
  325. DW_LANG_Dylan = 0x0020,
  326. DW_LANG_C_plus_plus_14 = 0x0021,
  327. DW_LANG_Fortran03 = 0x0022,
  328. DW_LANG_Fortran08 = 0x0023,
  329. DW_LANG_RenderScript = 0x0024,
  330. DW_LANG_lo_user = 0x8000, /* Implementation-defined range start. */
  331. DW_LANG_hi_user = 0xffff, /* Implementation-defined range start. */
  332. /* MIPS. */
  333. DW_LANG_Mips_Assembler = 0x8001,
  334. /* UPC. */
  335. DW_LANG_Upc = 0x8765,
  336. /* HP extensions. */
  337. DW_LANG_HP_Bliss = 0x8003,
  338. DW_LANG_HP_Basic91 = 0x8004,
  339. DW_LANG_HP_Pascal91 = 0x8005,
  340. DW_LANG_HP_IMacro = 0x8006,
  341. DW_LANG_HP_Assembler = 0x8007,
  342. /* Rust extension, but replaced in DWARF 5. */
  343. DW_LANG_Rust_old = 0x9000
  344. };
  345. /* Names and codes for macro information. */
  346. enum dwarf_macinfo_record_type
  347. {
  348. DW_MACINFO_define = 1,
  349. DW_MACINFO_undef = 2,
  350. DW_MACINFO_start_file = 3,
  351. DW_MACINFO_end_file = 4,
  352. DW_MACINFO_vendor_ext = 255
  353. };
  354. /* DW_TAG_defaulted/DW_TAG_GNU_defaulted attributes. */
  355. enum dwarf_defaulted_attribute
  356. {
  357. DW_DEFAULTED_no = 0x00,
  358. DW_DEFAULTED_in_class = 0x01,
  359. DW_DEFAULTED_out_of_class = 0x02
  360. };
  361. /* Names and codes for new style macro information. */
  362. enum dwarf_macro_record_type
  363. {
  364. DW_MACRO_define = 0x01,
  365. DW_MACRO_undef = 0x02,
  366. DW_MACRO_start_file = 0x03,
  367. DW_MACRO_end_file = 0x04,
  368. DW_MACRO_define_strp = 0x05,
  369. DW_MACRO_undef_strp = 0x06,
  370. DW_MACRO_import = 0x07,
  371. DW_MACRO_define_sup = 0x08,
  372. DW_MACRO_undef_sup = 0x09,
  373. DW_MACRO_import_sup = 0x0a,
  374. DW_MACRO_define_strx = 0x0b,
  375. DW_MACRO_undef_strx = 0x0c,
  376. DW_MACRO_lo_user = 0xe0,
  377. DW_MACRO_hi_user = 0xff,
  378. /* Compatibility macros for the GNU .debug_macro extension. */
  379. DW_MACRO_GNU_define = 0x01,
  380. DW_MACRO_GNU_undef = 0x02,
  381. DW_MACRO_GNU_start_file = 0x03,
  382. DW_MACRO_GNU_end_file = 0x04,
  383. DW_MACRO_GNU_define_indirect = 0x05,
  384. DW_MACRO_GNU_undef_indirect = 0x06,
  385. DW_MACRO_GNU_transparent_include = 0x07,
  386. /* Extensions for DWZ multifile.
  387. See http://www.dwarfstd.org/ShowIssue.php?issue=120604.1&type=open . */
  388. DW_MACRO_GNU_define_indirect_alt = 0x08,
  389. DW_MACRO_GNU_undef_indirect_alt = 0x09,
  390. DW_MACRO_GNU_transparent_include_alt = 0x0a,
  391. DW_MACRO_GNU_lo_user = 0xe0,
  392. DW_MACRO_GNU_hi_user = 0xff
  393. };
  394. /* Range list entry kinds in .debug_rnglists* section. */
  395. enum dwarf_range_list_entry
  396. {
  397. DW_RLE_end_of_list = 0x00,
  398. DW_RLE_base_addressx = 0x01,
  399. DW_RLE_startx_endx = 0x02,
  400. DW_RLE_startx_length = 0x03,
  401. DW_RLE_offset_pair = 0x04,
  402. DW_RLE_base_address = 0x05,
  403. DW_RLE_start_end = 0x06,
  404. DW_RLE_start_length = 0x07
  405. };
  406. /* @@@ For use with GNU frame unwind information. */
  407. #define DW_EH_PE_absptr 0x00
  408. #define DW_EH_PE_omit 0xff
  409. #define DW_EH_PE_uleb128 0x01
  410. #define DW_EH_PE_udata2 0x02
  411. #define DW_EH_PE_udata4 0x03
  412. #define DW_EH_PE_udata8 0x04
  413. #define DW_EH_PE_sleb128 0x09
  414. #define DW_EH_PE_sdata2 0x0A
  415. #define DW_EH_PE_sdata4 0x0B
  416. #define DW_EH_PE_sdata8 0x0C
  417. #define DW_EH_PE_signed 0x08
  418. #define DW_EH_PE_pcrel 0x10
  419. #define DW_EH_PE_textrel 0x20
  420. #define DW_EH_PE_datarel 0x30
  421. #define DW_EH_PE_funcrel 0x40
  422. #define DW_EH_PE_aligned 0x50
  423. #define DW_EH_PE_indirect 0x80
  424. /* Codes for the debug sections in a dwarf package (.dwp) file.
  425. (From the pre-standard formats Extensions for Fission.
  426. See http://gcc.gnu.org/wiki/DebugFissionDWP). */
  427. enum dwarf_sect
  428. {
  429. DW_SECT_INFO = 1,
  430. DW_SECT_TYPES = 2,
  431. DW_SECT_ABBREV = 3,
  432. DW_SECT_LINE = 4,
  433. DW_SECT_LOC = 5,
  434. DW_SECT_STR_OFFSETS = 6,
  435. DW_SECT_MACINFO = 7,
  436. DW_SECT_MACRO = 8,
  437. DW_SECT_MAX = 8
  438. };
  439. /* Codes for the debug sections in a dwarf package (.dwp) file.
  440. (From the official DWARF v5 spec.
  441. See http://dwarfstd.org/doc/DWARF5.pdf, section 7.3.5). */
  442. enum dwarf_sect_v5
  443. {
  444. DW_SECT_INFO_V5 = 1,
  445. DW_SECT_RESERVED_V5 = 2,
  446. DW_SECT_ABBREV_V5 = 3,
  447. DW_SECT_LINE_V5 = 4,
  448. DW_SECT_LOCLISTS_V5 = 5,
  449. DW_SECT_STR_OFFSETS_V5 = 6,
  450. DW_SECT_MACRO_V5 = 7,
  451. DW_SECT_RNGLISTS_V5 = 8,
  452. DW_SECT_MAX_V5 = 8
  453. };
  454. #ifdef __cplusplus
  455. extern "C" {
  456. #endif /* __cplusplus */
  457. /* Return the name of a DW_TAG_ constant, or NULL if the value is not
  458. recognized. */
  459. extern const char *get_DW_TAG_name (unsigned int tag);
  460. /* Return the name of a DW_AT_ constant, or NULL if the value is not
  461. recognized. */
  462. extern const char *get_DW_AT_name (unsigned int attr);
  463. /* Return the name of a DW_FORM_ constant, or NULL if the value is not
  464. recognized. */
  465. extern const char *get_DW_FORM_name (unsigned int form);
  466. /* Return the name of a DW_OP_ constant, or NULL if the value is not
  467. recognized. */
  468. extern const char *get_DW_OP_name (unsigned int op);
  469. /* Return the name of a DW_ATE_ constant, or NULL if the value is not
  470. recognized. */
  471. extern const char *get_DW_ATE_name (unsigned int enc);
  472. /* Return the name of a DW_CFA_ constant, or NULL if the value is not
  473. recognized. */
  474. extern const char *get_DW_CFA_name (unsigned int opc);
  475. /* Return the name of a DW_IDX_ constant, or NULL if the value is not
  476. recognized. */
  477. extern const char *get_DW_IDX_name (unsigned int idx);
  478. /* Return the name of a DW_UT_ constant, or NULL if the value is not
  479. recognized. */
  480. extern const char *get_DW_UT_name (unsigned int ut);
  481. #ifdef __cplusplus
  482. }
  483. #endif /* __cplusplus */
  484. #endif /* _DWARF2_H */