1 /* dwarf.h - DWARF support header file 2 Copyright 2005, 2007, 2008, 2009, 2010, 2011 3 Free Software Foundation, Inc. 4 5 This file is part of GNU Binutils. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 3 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 20 MA 02110-1301, USA. */ 21 22 typedef unsigned HOST_WIDEST_INT dwarf_vma; 23 typedef HOST_WIDEST_INT dwarf_signed_vma; 24 typedef unsigned HOST_WIDEST_INT dwarf_size_type; 25 26 /* Structure found in the .debug_line section. */ 27 typedef struct 28 { 29 unsigned char li_length [4]; 30 unsigned char li_version [2]; 31 unsigned char li_prologue_length [4]; 32 unsigned char li_min_insn_length [1]; 33 unsigned char li_default_is_stmt [1]; 34 unsigned char li_line_base [1]; 35 unsigned char li_line_range [1]; 36 unsigned char li_opcode_base [1]; 37 } 38 DWARF2_External_LineInfo; 39 40 typedef struct 41 { 42 dwarf_vma li_length; 43 unsigned short li_version; 44 unsigned int li_prologue_length; 45 unsigned char li_min_insn_length; 46 unsigned char li_max_ops_per_insn; 47 unsigned char li_default_is_stmt; 48 int li_line_base; 49 unsigned char li_line_range; 50 unsigned char li_opcode_base; 51 } 52 DWARF2_Internal_LineInfo; 53 54 /* Structure found in .debug_pubnames section. */ 55 typedef struct 56 { 57 unsigned char pn_length [4]; 58 unsigned char pn_version [2]; 59 unsigned char pn_offset [4]; 60 unsigned char pn_size [4]; 61 } 62 DWARF2_External_PubNames; 63 64 typedef struct 65 { 66 dwarf_vma pn_length; 67 unsigned short pn_version; 68 dwarf_vma pn_offset; 69 dwarf_vma pn_size; 70 } 71 DWARF2_Internal_PubNames; 72 73 /* Structure found in .debug_info section. */ 74 typedef struct 75 { 76 unsigned char cu_length [4]; 77 unsigned char cu_version [2]; 78 unsigned char cu_abbrev_offset [4]; 79 unsigned char cu_pointer_size [1]; 80 } 81 DWARF2_External_CompUnit; 82 83 typedef struct 84 { 85 dwarf_vma cu_length; 86 unsigned short cu_version; 87 dwarf_vma cu_abbrev_offset; 88 unsigned char cu_pointer_size; 89 } 90 DWARF2_Internal_CompUnit; 91 92 typedef struct 93 { 94 unsigned char ar_length [4]; 95 unsigned char ar_version [2]; 96 unsigned char ar_info_offset [4]; 97 unsigned char ar_pointer_size [1]; 98 unsigned char ar_segment_size [1]; 99 } 100 DWARF2_External_ARange; 101 102 typedef struct 103 { 104 dwarf_vma ar_length; 105 unsigned short ar_version; 106 dwarf_vma ar_info_offset; 107 unsigned char ar_pointer_size; 108 unsigned char ar_segment_size; 109 } 110 DWARF2_Internal_ARange; 111 112 enum dwarf_section_display_enum 113 { 114 abbrev = 0, 115 aranges, 116 frame, 117 info, 118 line, 119 pubnames, 120 eh_frame, 121 macinfo, 122 macro, 123 str, 124 loc, 125 pubtypes, 126 ranges, 127 static_func, 128 static_vars, 129 types, 130 weaknames, 131 gdb_index, 132 trace_info, 133 trace_abbrev, 134 trace_aranges, 135 info_dwo, 136 abbrev_dwo, 137 types_dwo, 138 line_dwo, 139 loc_dwo, 140 macro_dwo, 141 macinfo_dwo, 142 str_dwo, 143 str_index, 144 str_index_dwo, 145 debug_addr, 146 max 147 }; 148 149 struct dwarf_section 150 { 151 /* A debug section has a different name when it's stored compressed 152 or not. COMPRESSED_NAME and UNCOMPRESSED_NAME are the two 153 possibilities. NAME is set to whichever one is used for this 154 input file, as determined by load_debug_section(). */ 155 const char *uncompressed_name; 156 const char *compressed_name; 157 const char *name; 158 unsigned char *start; 159 dwarf_vma address; 160 dwarf_size_type size; 161 enum dwarf_section_display_enum abbrev_sec; 162 }; 163 164 /* A structure containing the name of a debug section 165 and a pointer to a function that can decode it. */ 166 struct dwarf_section_display 167 { 168 struct dwarf_section section; 169 int (*display) (struct dwarf_section *, void *); 170 int *enabled; 171 unsigned int relocate : 1; 172 }; 173 174 extern struct dwarf_section_display debug_displays []; 175 176 /* This structure records the information that 177 we extract from the.debug_info section. */ 178 typedef struct 179 { 180 unsigned int pointer_size; 181 unsigned int offset_size; 182 int dwarf_version; 183 dwarf_vma cu_offset; 184 dwarf_vma base_address; 185 /* This field is filled in when reading the attribute DW_AT_GNU_addr_base and 186 is used with the form DW_AT_GNU_FORM_addr_index. */ 187 dwarf_vma addr_base; 188 /* This field is filled in when reading the attribute DW_AT_GNU_ranges_base and 189 is used when calculating ranges. */ 190 dwarf_vma ranges_base; 191 /* This is an array of offsets to the location list table. */ 192 dwarf_vma * loc_offsets; 193 int * have_frame_base; 194 unsigned int num_loc_offsets; 195 unsigned int max_loc_offsets; 196 /* List of .debug_ranges offsets seen in this .debug_info. */ 197 dwarf_vma * range_lists; 198 unsigned int num_range_lists; 199 unsigned int max_range_lists; 200 } 201 debug_info; 202 203 extern int eh_addr_size; 204 205 extern int do_debug_info; 206 extern int do_debug_abbrevs; 207 extern int do_debug_lines; 208 extern int do_debug_pubnames; 209 extern int do_debug_pubtypes; 210 extern int do_debug_aranges; 211 extern int do_debug_ranges; 212 extern int do_debug_frames; 213 extern int do_debug_frames_interp; 214 extern int do_debug_macinfo; 215 extern int do_debug_str; 216 extern int do_debug_loc; 217 extern int do_gdb_index; 218 extern int do_trace_info; 219 extern int do_trace_abbrevs; 220 extern int do_trace_aranges; 221 extern int do_wide; 222 223 extern int dwarf_cutoff_level; 224 extern unsigned long dwarf_start_die; 225 226 extern int dwarf_check; 227 228 extern void init_dwarf_regnames (unsigned int); 229 extern void init_dwarf_regnames_i386 (void); 230 extern void init_dwarf_regnames_x86_64 (void); 231 232 extern int load_debug_section (enum dwarf_section_display_enum, void *); 233 extern void free_debug_section (enum dwarf_section_display_enum); 234 235 extern void free_debug_memory (void); 236 237 extern void dwarf_select_sections_by_names (const char *); 238 extern void dwarf_select_sections_by_letters (const char *); 239 extern void dwarf_select_sections_all (void); 240 241 void * cmalloc (size_t, size_t); 242 void * xcmalloc (size_t, size_t); 243 void * xcrealloc (void *, size_t, size_t); 244 245 dwarf_vma read_leb128 (unsigned char *, unsigned int *, int); 246