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