PulkoMandy | 17fc759 | 2022-07-28 18:27:54 +0200 | [diff] [blame] | 1 | /* $VER: vbcc (dwarf2.c) $Revision: 1.5 $ */ |
| 2 | |
| 3 | enum dwarf_tag |
| 4 | { |
| 5 | DW_TAG_padding = 0x00, |
| 6 | DW_TAG_array_type = 0x01, |
| 7 | DW_TAG_class_type = 0x02, |
| 8 | DW_TAG_entry_point = 0x03, |
| 9 | DW_TAG_enumeration_type = 0x04, |
| 10 | DW_TAG_formal_parameter = 0x05, |
| 11 | DW_TAG_imported_declaration = 0x08, |
| 12 | DW_TAG_label = 0x0a, |
| 13 | DW_TAG_lexical_block = 0x0b, |
| 14 | DW_TAG_member = 0x0d, |
| 15 | DW_TAG_pointer_type = 0x0f, |
| 16 | DW_TAG_reference_type = 0x10, |
| 17 | DW_TAG_compile_unit = 0x11, |
| 18 | DW_TAG_string_type = 0x12, |
| 19 | DW_TAG_structure_type = 0x13, |
| 20 | DW_TAG_subroutine_type = 0x15, |
| 21 | DW_TAG_typedef = 0x16, |
| 22 | DW_TAG_union_type = 0x17, |
| 23 | DW_TAG_unspecified_parameters = 0x18, |
| 24 | DW_TAG_variant = 0x19, |
| 25 | DW_TAG_common_block = 0x1a, |
| 26 | DW_TAG_common_inclusion = 0x1b, |
| 27 | DW_TAG_inheritance = 0x1c, |
| 28 | DW_TAG_inlined_subroutine = 0x1d, |
| 29 | DW_TAG_module = 0x1e, |
| 30 | DW_TAG_ptr_to_member_type = 0x1f, |
| 31 | DW_TAG_set_type = 0x20, |
| 32 | DW_TAG_subrange_type = 0x21, |
| 33 | DW_TAG_with_stmt = 0x22, |
| 34 | DW_TAG_access_declaration = 0x23, |
| 35 | DW_TAG_base_type = 0x24, |
| 36 | DW_TAG_catch_block = 0x25, |
| 37 | DW_TAG_const_type = 0x26, |
| 38 | DW_TAG_constant = 0x27, |
| 39 | DW_TAG_enumerator = 0x28, |
| 40 | DW_TAG_file_type = 0x29, |
| 41 | DW_TAG_friend = 0x2a, |
| 42 | DW_TAG_namelist = 0x2b, |
| 43 | DW_TAG_namelist_item = 0x2c, |
| 44 | DW_TAG_packed_type = 0x2d, |
| 45 | DW_TAG_subprogram = 0x2e, |
| 46 | DW_TAG_template_type_param = 0x2f, |
| 47 | DW_TAG_template_value_param = 0x30, |
| 48 | DW_TAG_thrown_type = 0x31, |
| 49 | DW_TAG_try_block = 0x32, |
| 50 | DW_TAG_variant_part = 0x33, |
| 51 | DW_TAG_variable = 0x34, |
| 52 | DW_TAG_volatile_type = 0x35, |
| 53 | /* SGI/MIPS Extensions */ |
| 54 | DW_TAG_MIPS_loop = 0x4081, |
| 55 | /* GNU extensions */ |
| 56 | DW_TAG_format_label = 0x4101, |
| 57 | DW_TAG_function_template = 0x4102, |
| 58 | DW_TAG_class_template = 0x4103 |
| 59 | }; |
| 60 | |
| 61 | enum dwarf_children |
| 62 | { |
| 63 | DW_children_no = 0, |
| 64 | DW_children_yes = 1 |
| 65 | }; |
| 66 | |
| 67 | enum dwarf_form |
| 68 | { |
| 69 | DW_FORM_addr = 0x01, |
| 70 | DW_FORM_block2 = 0x03, |
| 71 | DW_FORM_block4 = 0x04, |
| 72 | DW_FORM_data2 = 0x05, |
| 73 | DW_FORM_data4 = 0x06, |
| 74 | DW_FORM_data8 = 0x07, |
| 75 | DW_FORM_string = 0x08, |
| 76 | DW_FORM_block = 0x09, |
| 77 | DW_FORM_block1 = 0x0a, |
| 78 | DW_FORM_data1 = 0x0b, |
| 79 | DW_FORM_flag = 0x0c, |
| 80 | DW_FORM_sdata = 0x0d, |
| 81 | DW_FORM_strp = 0x0e, |
| 82 | DW_FORM_udata = 0x0f, |
| 83 | DW_FORM_ref_addr = 0x10, |
| 84 | DW_FORM_ref1 = 0x11, |
| 85 | DW_FORM_ref2 = 0x12, |
| 86 | DW_FORM_ref4 = 0x13, |
| 87 | DW_FORM_ref8 = 0x14, |
| 88 | DW_FORM_ref_udata = 0x15, |
| 89 | DW_FORM_indirect = 0x16 |
| 90 | }; |
| 91 | |
| 92 | enum dwarf_attribute |
| 93 | { |
| 94 | DW_AT_sibling = 0x01, |
| 95 | DW_AT_location = 0x02, |
| 96 | DW_AT_name = 0x03, |
| 97 | DW_AT_ordering = 0x09, |
| 98 | DW_AT_subscr_data = 0x0a, |
| 99 | DW_AT_byte_size = 0x0b, |
| 100 | DW_AT_bit_offset = 0x0c, |
| 101 | DW_AT_bit_size = 0x0d, |
| 102 | DW_AT_element_list = 0x0f, |
| 103 | DW_AT_stmt_list = 0x10, |
| 104 | DW_AT_low_pc = 0x11, |
| 105 | DW_AT_high_pc = 0x12, |
| 106 | DW_AT_language = 0x13, |
| 107 | DW_AT_member = 0x14, |
| 108 | DW_AT_discr = 0x15, |
| 109 | DW_AT_discr_value = 0x16, |
| 110 | DW_AT_visibility = 0x17, |
| 111 | DW_AT_import = 0x18, |
| 112 | DW_AT_string_length = 0x19, |
| 113 | DW_AT_common_reference = 0x1a, |
| 114 | DW_AT_comp_dir = 0x1b, |
| 115 | DW_AT_const_value = 0x1c, |
| 116 | DW_AT_containing_type = 0x1d, |
| 117 | DW_AT_default_value = 0x1e, |
| 118 | DW_AT_inline = 0x20, |
| 119 | DW_AT_is_optional = 0x21, |
| 120 | DW_AT_lower_bound = 0x22, |
| 121 | DW_AT_producer = 0x25, |
| 122 | DW_AT_prototyped = 0x27, |
| 123 | DW_AT_return_addr = 0x2a, |
| 124 | DW_AT_start_scope = 0x2c, |
| 125 | DW_AT_stride_size = 0x2e, |
| 126 | DW_AT_upper_bound = 0x2f, |
| 127 | DW_AT_abstract_origin = 0x31, |
| 128 | DW_AT_accessibility = 0x32, |
| 129 | DW_AT_address_class = 0x33, |
| 130 | DW_AT_artificial = 0x34, |
| 131 | DW_AT_base_types = 0x35, |
| 132 | DW_AT_calling_convention = 0x36, |
| 133 | DW_AT_count = 0x37, |
| 134 | DW_AT_data_member_location = 0x38, |
| 135 | DW_AT_decl_column = 0x39, |
| 136 | DW_AT_decl_file = 0x3a, |
| 137 | DW_AT_decl_line = 0x3b, |
| 138 | DW_AT_declaration = 0x3c, |
| 139 | DW_AT_discr_list = 0x3d, |
| 140 | DW_AT_encoding = 0x3e, |
| 141 | DW_AT_external = 0x3f, |
| 142 | DW_AT_frame_base = 0x40, |
| 143 | DW_AT_friend = 0x41, |
| 144 | DW_AT_identifier_case = 0x42, |
| 145 | DW_AT_macro_info = 0x43, |
| 146 | DW_AT_namelist_items = 0x44, |
| 147 | DW_AT_priority = 0x45, |
| 148 | DW_AT_segment = 0x46, |
| 149 | DW_AT_specification = 0x47, |
| 150 | DW_AT_static_link = 0x48, |
| 151 | DW_AT_type = 0x49, |
| 152 | DW_AT_use_location = 0x4a, |
| 153 | DW_AT_variable_parameter = 0x4b, |
| 154 | DW_AT_virtuality = 0x4c, |
| 155 | DW_AT_vtable_elem_location = 0x4d, |
| 156 | DW_AT_MIPS_fde = 0x2001, |
| 157 | DW_AT_MIPS_loop_begin = 0x2002, |
| 158 | DW_AT_MIPS_tail_loop_begin = 0x2003, |
| 159 | DW_AT_MIPS_epilog_begin = 0x2004, |
| 160 | DW_AT_MIPS_loop_unroll_factor = 0x2005, |
| 161 | DW_AT_MIPS_software_pipeline_depth = 0x2006, |
| 162 | DW_AT_MIPS_linkage_name = 0x2007, |
| 163 | DW_AT_MIPS_stride = 0x2008, |
| 164 | DW_AT_MIPS_abstract_name = 0x2009, |
| 165 | DW_AT_MIPS_clone_origin = 0x200a, |
| 166 | DW_AT_MIPS_has_inlines = 0x200b, |
| 167 | /* GNU */ |
| 168 | DW_AT_sf_names = 0x2101, |
| 169 | DW_AT_src_info = 0x2102, |
| 170 | DW_AT_mac_info = 0x2103, |
| 171 | DW_AT_src_coords = 0x2104, |
| 172 | DW_AT_body_begin = 0x2105, |
| 173 | DW_AT_body_end = 0x2106 |
| 174 | }; |
| 175 | |
| 176 | enum dwarf_location_atom |
| 177 | { |
| 178 | DW_OP_addr = 0x03, |
| 179 | DW_OP_deref = 0x06, |
| 180 | DW_OP_const1u = 0x08, |
| 181 | DW_OP_const1s = 0x09, |
| 182 | DW_OP_const2u = 0x0a, |
| 183 | DW_OP_const2s = 0x0b, |
| 184 | DW_OP_const4u = 0x0c, |
| 185 | DW_OP_const4s = 0x0d, |
| 186 | DW_OP_const8u = 0x0e, |
| 187 | DW_OP_const8s = 0x0f, |
| 188 | DW_OP_constu = 0x10, |
| 189 | DW_OP_consts = 0x11, |
| 190 | DW_OP_dup = 0x12, |
| 191 | DW_OP_drop = 0x13, |
| 192 | DW_OP_over = 0x14, |
| 193 | DW_OP_pick = 0x15, |
| 194 | DW_OP_swap = 0x16, |
| 195 | DW_OP_rot = 0x17, |
| 196 | DW_OP_xderef = 0x18, |
| 197 | DW_OP_abs = 0x19, |
| 198 | DW_OP_and = 0x1a, |
| 199 | DW_OP_div = 0x1b, |
| 200 | DW_OP_minus = 0x1c, |
| 201 | DW_OP_mod = 0x1d, |
| 202 | DW_OP_mul = 0x1e, |
| 203 | DW_OP_neg = 0x1f, |
| 204 | DW_OP_not = 0x20, |
| 205 | DW_OP_or = 0x21, |
| 206 | DW_OP_plus = 0x22, |
| 207 | DW_OP_plus_uconst = 0x23, |
| 208 | DW_OP_shl = 0x24, |
| 209 | DW_OP_shr = 0x25, |
| 210 | DW_OP_shra = 0x26, |
| 211 | DW_OP_xor = 0x27, |
| 212 | DW_OP_bra = 0x28, |
| 213 | DW_OP_eq = 0x29, |
| 214 | DW_OP_ge = 0x2a, |
| 215 | DW_OP_gt = 0x2b, |
| 216 | DW_OP_le = 0x2c, |
| 217 | DW_OP_lt = 0x2d, |
| 218 | DW_OP_ne = 0x2e, |
| 219 | DW_OP_skip = 0x2f, |
| 220 | DW_OP_lit0 = 0x30, |
| 221 | DW_OP_lit1 = 0x31, |
| 222 | DW_OP_lit2 = 0x32, |
| 223 | DW_OP_lit3 = 0x33, |
| 224 | DW_OP_lit4 = 0x34, |
| 225 | DW_OP_lit5 = 0x35, |
| 226 | DW_OP_lit6 = 0x36, |
| 227 | DW_OP_lit7 = 0x37, |
| 228 | DW_OP_lit8 = 0x38, |
| 229 | DW_OP_lit9 = 0x39, |
| 230 | DW_OP_lit10 = 0x3a, |
| 231 | DW_OP_lit11 = 0x3b, |
| 232 | DW_OP_lit12 = 0x3c, |
| 233 | DW_OP_lit13 = 0x3d, |
| 234 | DW_OP_lit14 = 0x3e, |
| 235 | DW_OP_lit15 = 0x3f, |
| 236 | DW_OP_lit16 = 0x40, |
| 237 | DW_OP_lit17 = 0x41, |
| 238 | DW_OP_lit18 = 0x42, |
| 239 | DW_OP_lit19 = 0x43, |
| 240 | DW_OP_lit20 = 0x44, |
| 241 | DW_OP_lit21 = 0x45, |
| 242 | DW_OP_lit22 = 0x46, |
| 243 | DW_OP_lit23 = 0x47, |
| 244 | DW_OP_lit24 = 0x48, |
| 245 | DW_OP_lit25 = 0x49, |
| 246 | DW_OP_lit26 = 0x4a, |
| 247 | DW_OP_lit27 = 0x4b, |
| 248 | DW_OP_lit28 = 0x4c, |
| 249 | DW_OP_lit29 = 0x4d, |
| 250 | DW_OP_lit30 = 0x4e, |
| 251 | DW_OP_lit31 = 0x4f, |
| 252 | DW_OP_reg0 = 0x50, |
| 253 | DW_OP_reg1 = 0x51, |
| 254 | DW_OP_reg2 = 0x52, |
| 255 | DW_OP_reg3 = 0x53, |
| 256 | DW_OP_reg4 = 0x54, |
| 257 | DW_OP_reg5 = 0x55, |
| 258 | DW_OP_reg6 = 0x56, |
| 259 | DW_OP_reg7 = 0x57, |
| 260 | DW_OP_reg8 = 0x58, |
| 261 | DW_OP_reg9 = 0x59, |
| 262 | DW_OP_reg10 = 0x5a, |
| 263 | DW_OP_reg11 = 0x5b, |
| 264 | DW_OP_reg12 = 0x5c, |
| 265 | DW_OP_reg13 = 0x5d, |
| 266 | DW_OP_reg14 = 0x5e, |
| 267 | DW_OP_reg15 = 0x5f, |
| 268 | DW_OP_reg16 = 0x60, |
| 269 | DW_OP_reg17 = 0x61, |
| 270 | DW_OP_reg18 = 0x62, |
| 271 | DW_OP_reg19 = 0x63, |
| 272 | DW_OP_reg20 = 0x64, |
| 273 | DW_OP_reg21 = 0x65, |
| 274 | DW_OP_reg22 = 0x66, |
| 275 | DW_OP_reg23 = 0x67, |
| 276 | DW_OP_reg24 = 0x68, |
| 277 | DW_OP_reg25 = 0x69, |
| 278 | DW_OP_reg26 = 0x6a, |
| 279 | DW_OP_reg27 = 0x6b, |
| 280 | DW_OP_reg28 = 0x6c, |
| 281 | DW_OP_reg29 = 0x6d, |
| 282 | DW_OP_reg30 = 0x6e, |
| 283 | DW_OP_reg31 = 0x6f, |
| 284 | DW_OP_breg0 = 0x70, |
| 285 | DW_OP_breg1 = 0x71, |
| 286 | DW_OP_breg2 = 0x72, |
| 287 | DW_OP_breg3 = 0x73, |
| 288 | DW_OP_breg4 = 0x74, |
| 289 | DW_OP_breg5 = 0x75, |
| 290 | DW_OP_breg6 = 0x76, |
| 291 | DW_OP_breg7 = 0x77, |
| 292 | DW_OP_breg8 = 0x78, |
| 293 | DW_OP_breg9 = 0x79, |
| 294 | DW_OP_breg10 = 0x7a, |
| 295 | DW_OP_breg11 = 0x7b, |
| 296 | DW_OP_breg12 = 0x7c, |
| 297 | DW_OP_breg13 = 0x7d, |
| 298 | DW_OP_breg14 = 0x7e, |
| 299 | DW_OP_breg15 = 0x7f, |
| 300 | DW_OP_breg16 = 0x80, |
| 301 | DW_OP_breg17 = 0x81, |
| 302 | DW_OP_breg18 = 0x82, |
| 303 | DW_OP_breg19 = 0x83, |
| 304 | DW_OP_breg20 = 0x84, |
| 305 | DW_OP_breg21 = 0x85, |
| 306 | DW_OP_breg22 = 0x86, |
| 307 | DW_OP_breg23 = 0x87, |
| 308 | DW_OP_breg24 = 0x88, |
| 309 | DW_OP_breg25 = 0x89, |
| 310 | DW_OP_breg26 = 0x8a, |
| 311 | DW_OP_breg27 = 0x8b, |
| 312 | DW_OP_breg28 = 0x8c, |
| 313 | DW_OP_breg29 = 0x8d, |
| 314 | DW_OP_breg30 = 0x8e, |
| 315 | DW_OP_breg31 = 0x8f, |
| 316 | DW_OP_regx = 0x90, |
| 317 | DW_OP_fbreg = 0x91, |
| 318 | DW_OP_bregx = 0x92, |
| 319 | DW_OP_piece = 0x93, |
| 320 | DW_OP_deref_size = 0x94, |
| 321 | DW_OP_xderef_size = 0x95, |
| 322 | DW_OP_nop = 0x96 |
| 323 | }; |
| 324 | |
| 325 | enum dwarf_type |
| 326 | { |
| 327 | DW_ATE_void = 0x0, |
| 328 | DW_ATE_address = 0x1, |
| 329 | DW_ATE_boolean = 0x2, |
| 330 | DW_ATE_complex_float = 0x3, |
| 331 | DW_ATE_float = 0x4, |
| 332 | DW_ATE_signed = 0x5, |
| 333 | DW_ATE_signed_char = 0x6, |
| 334 | DW_ATE_unsigned = 0x7, |
| 335 | DW_ATE_unsigned_char = 0x8 |
| 336 | }; |
| 337 | |
| 338 | enum dwarf_array_dim_ordering |
| 339 | { |
| 340 | DW_ORD_row_major = 0, |
| 341 | DW_ORD_col_major = 1 |
| 342 | }; |
| 343 | |
| 344 | enum dwarf_access_attribute |
| 345 | { |
| 346 | DW_ACCESS_public = 1, |
| 347 | DW_ACCESS_protected = 2, |
| 348 | DW_ACCESS_private = 3 |
| 349 | }; |
| 350 | |
| 351 | enum dwarf_visibility_attribute |
| 352 | { |
| 353 | DW_VIS_local = 1, |
| 354 | DW_VIS_exported = 2, |
| 355 | DW_VIS_qualified = 3 |
| 356 | }; |
| 357 | |
| 358 | enum dwarf_virtuality_attribute |
| 359 | { |
| 360 | DW_VIRTUALITY_none = 0, |
| 361 | DW_VIRTUALITY_virtual = 1, |
| 362 | DW_VIRTUALITY_pure_virtual = 2 |
| 363 | }; |
| 364 | |
| 365 | enum dwarf_id_case |
| 366 | { |
| 367 | DW_ID_case_sensitive = 0, |
| 368 | DW_ID_up_case = 1, |
| 369 | DW_ID_down_case = 2, |
| 370 | DW_ID_case_insensitive = 3 |
| 371 | }; |
| 372 | |
| 373 | enum dwarf_calling_convention |
| 374 | { |
| 375 | DW_CC_normal = 0x1, |
| 376 | DW_CC_program = 0x2, |
| 377 | DW_CC_nocall = 0x3 |
| 378 | }; |
| 379 | |
| 380 | enum dwarf_inline_attribute |
| 381 | { |
| 382 | DW_INL_not_inlined = 0, |
| 383 | DW_INL_inlined = 1, |
| 384 | DW_INL_declared_not_inlined = 2, |
| 385 | DW_INL_declared_inlined = 3 |
| 386 | }; |
| 387 | |
| 388 | enum dwarf_descrim_list |
| 389 | { |
| 390 | DW_DSC_label = 0, |
| 391 | DW_DSC_range = 1 |
| 392 | }; |
| 393 | |
| 394 | enum dwarf_line_number_ops |
| 395 | { |
| 396 | DW_LNS_extended_op = 0, |
| 397 | DW_LNS_copy = 1, |
| 398 | DW_LNS_advance_pc = 2, |
| 399 | DW_LNS_advance_line = 3, |
| 400 | DW_LNS_set_file = 4, |
| 401 | DW_LNS_set_column = 5, |
| 402 | DW_LNS_negate_stmt = 6, |
| 403 | DW_LNS_set_basic_block = 7, |
| 404 | DW_LNS_const_add_pc = 8, |
| 405 | DW_LNS_fixed_advance_pc = 9 |
| 406 | }; |
| 407 | |
| 408 | enum dwarf_line_number_x_ops |
| 409 | { |
| 410 | DW_LNE_end_sequence = 1, |
| 411 | DW_LNE_set_address = 2, |
| 412 | DW_LNE_define_file = 3 |
| 413 | }; |
| 414 | |
| 415 | enum dwarf_call_frame_info |
| 416 | { |
| 417 | DW_CFA_advance_loc = 0x40, |
| 418 | DW_CFA_offset = 0x80, |
| 419 | DW_CFA_restore = 0xc0, |
| 420 | DW_CFA_nop = 0x00, |
| 421 | DW_CFA_set_loc = 0x01, |
| 422 | DW_CFA_advance_loc1 = 0x02, |
| 423 | DW_CFA_advance_loc2 = 0x03, |
| 424 | DW_CFA_advance_loc4 = 0x04, |
| 425 | DW_CFA_offset_extended = 0x05, |
| 426 | DW_CFA_restore_extended = 0x06, |
| 427 | DW_CFA_undefined = 0x07, |
| 428 | DW_CFA_same_value = 0x08, |
| 429 | DW_CFA_register = 0x09, |
| 430 | DW_CFA_remember_state = 0x0a, |
| 431 | DW_CFA_restore_state = 0x0b, |
| 432 | DW_CFA_def_cfa = 0x0c, |
| 433 | DW_CFA_def_cfa_register = 0x0d, |
| 434 | DW_CFA_def_cfa_offset = 0x0e, |
| 435 | DW_CFA_MIPS_advance_loc8 = 0x1d |
| 436 | }; |
| 437 | |
| 438 | #define DW_CIE_ID 0xffffffff |
| 439 | #define DW_CIE_VERSION 1 |
| 440 | |
| 441 | #define DW_CFA_extended 0 |
| 442 | #define DW_CFA_low_user 0x1c |
| 443 | #define DW_CFA_high_user 0x3f |
| 444 | |
| 445 | #define DW_CHILDREN_no 0x00 |
| 446 | #define DW_CHILDREN_yes 0x01 |
| 447 | |
| 448 | #define DW_ADDR_none 0 |
| 449 | |
| 450 | enum dwarf_source_language |
| 451 | { |
| 452 | DW_LANG_C89 = 0x0001, |
| 453 | DW_LANG_C = 0x0002, |
| 454 | DW_LANG_Ada83 = 0x0003, |
| 455 | DW_LANG_C_plus_plus = 0x0004, |
| 456 | DW_LANG_Cobol74 = 0x0005, |
| 457 | DW_LANG_Cobol85 = 0x0006, |
| 458 | DW_LANG_Fortran77 = 0x0007, |
| 459 | DW_LANG_Fortran90 = 0x0008, |
| 460 | DW_LANG_Pascal83 = 0x0009, |
| 461 | DW_LANG_Modula2 = 0x000a, |
| 462 | DW_LANG_Mips_Assembler = 0x8001 |
| 463 | }; |
| 464 | |
| 465 | |
| 466 | enum dwarf_macinfo_record_type |
| 467 | { |
| 468 | DW_MACINFO_define = 1, |
| 469 | DW_MACINFO_undef = 2, |
| 470 | DW_MACINFO_start_file = 3, |
| 471 | DW_MACINFO_end_file = 4, |
| 472 | DW_MACINFO_vendor_ext = 255 |
| 473 | }; |
| 474 | |
| 475 | |
| 476 | |
| 477 | #define HAVE_LOCATION_LISTS 0 |
| 478 | |
| 479 | /* provided by the code generator */ |
| 480 | static void dwarf2_print_frame_location(FILE *,Var *); |
| 481 | static zmax dwarf2_fboffset(Var *); |
| 482 | static int dwarf2_regnumber(int); |
| 483 | |
| 484 | static int abbrev_label,info_start,info_end,line_start,line_end; |
| 485 | |
| 486 | static int sizeof_addr; |
| 487 | static char *dwarfd1,*dwarfd2,*dwarfd4,*da,*lp,*ip,*dsec; |
| 488 | static int addr_form; |
| 489 | static char **names; |
| 490 | static int namecount; |
| 491 | |
| 492 | extern Var *merk_varf,*first_var[],*first_ext; /*FIXME: not nice */ |
| 493 | extern struct_declaration *first_sd[]; |
| 494 | |
| 495 | #define COMP_UNIT 1UL |
| 496 | #define SUBPROGRAM 2UL |
| 497 | #define SUBPROGRAMVOID 3UL |
| 498 | #define BASETYPE 4UL |
| 499 | #define POINTERTYPE 5UL |
| 500 | #define CONSTTYPE 6UL |
| 501 | #define VOLATILETYPE 7UL |
| 502 | #define FORMALPARAMETER 8UL |
| 503 | #define VARIABLE 9UL |
| 504 | #define ARRAYTYPE 10UL |
| 505 | #define ARRAYDIM 11UL |
| 506 | #define STRUCTTYPE 12UL |
| 507 | #define UNIONTYPE 13UL |
| 508 | #define STRUCTTAG 14UL |
| 509 | #define UNIONTAG 15UL |
| 510 | #define TYPEDEFTYPE 16UL |
| 511 | #define MEMBERTYPE 17UL |
| 512 | #define FUNCTYPE 18UL |
| 513 | #define VOIDFUNCTYPE 19UL |
| 514 | #define PARMTYPE 20UL |
| 515 | |
| 516 | typedef struct dwarf2_line_info { |
| 517 | struct dwarf2_line_info *next; |
| 518 | char *id; |
| 519 | int file,line,label; |
| 520 | } tdwarf2_line_info; |
| 521 | |
| 522 | static tdwarf2_line_info *dwarf2_first_li,*dwarf2_last_li; |
| 523 | |
| 524 | static void dwarf2_add_line(int file,int line,int label,char *id) |
| 525 | { |
| 526 | tdwarf2_line_info *new,*p,*lp; |
| 527 | new=mymalloc(sizeof(*new)); |
| 528 | new->file=file; |
| 529 | new->line=line; |
| 530 | new->label=label; |
| 531 | if(id){ |
| 532 | new->id=mymalloc(strlen(id)+1); |
| 533 | strcpy(new->id,id); |
| 534 | }else{ |
| 535 | new->id=0; |
| 536 | } |
| 537 | new->next=0; |
| 538 | #if 0 |
| 539 | for(lp=p=dwarf2_first_li;p;p=p->next){ |
| 540 | if(p!=lp&&p->file==file&&p->line>=line){ |
| 541 | new->next=lp->next; |
| 542 | lp->next=new; |
| 543 | return; |
| 544 | } |
| 545 | lp=p; |
| 546 | } |
| 547 | #endif |
| 548 | if(dwarf2_last_li){ |
| 549 | dwarf2_last_li->next=new; |
| 550 | dwarf2_last_li=new; |
| 551 | }else{ |
| 552 | dwarf2_first_li=dwarf2_last_li=new; |
| 553 | } |
| 554 | #if 0 |
| 555 | printf("linfo:\n"); |
| 556 | for(p=dwarf2_first_li;p;p=p->next) |
| 557 | printf("li: line=%d\n",p->line); |
| 558 | #endif |
| 559 | } |
| 560 | |
| 561 | static void dwarf2_setup(int sa,char *dwarfd1s,char *dwarfd2s,char *dwarfd4s,char *das,char *lps,char *ips,char *ds) |
| 562 | { |
| 563 | sizeof_addr=sa; |
| 564 | dwarfd1=dwarfd1s; |
| 565 | dwarfd2=dwarfd2s; |
| 566 | dwarfd4=dwarfd4s; |
| 567 | da=das; |
| 568 | lp=lps; |
| 569 | ip=ips; |
| 570 | dsec=ds; |
| 571 | if(sizeof_addr==2) |
| 572 | addr_form=DW_FORM_data2; |
| 573 | else if(sizeof_addr==4) |
| 574 | addr_form=DW_FORM_data4; |
| 575 | else if(sizeof_addr==8) |
| 576 | addr_form=DW_FORM_data8; |
| 577 | else |
| 578 | ierror(0); |
| 579 | } |
| 580 | static int dwarf2_uleb128_size(zumax value) |
| 581 | { |
| 582 | int size=0; |
| 583 | do{ |
| 584 | value=zumrshift(value,ul2zum(7UL)); |
| 585 | size++; |
| 586 | }while(!zmeqto(value,ul2zum(0UL))); |
| 587 | return size; |
| 588 | } |
| 589 | static void dwarf2_print_uleb128(FILE *f,zumax value) |
| 590 | { |
| 591 | unsigned long byte; |
| 592 | emit(f,"\t%s\t",dwarfd1); |
| 593 | do{ |
| 594 | byte=zum2ul(zumand(value,ul2zum(127UL))); |
| 595 | value=zumrshift(value,ul2zum(7UL)); |
| 596 | if(!zumeqto(value,ul2zum(0UL))) |
| 597 | emit(f,"%lu,",byte|0x80); |
| 598 | else |
| 599 | emit(f,"%lu\n",byte); |
| 600 | }while(!zumeqto(value,ul2zum(0UL))); |
| 601 | } |
| 602 | static int dwarf2_sleb128_size(zmax value) |
| 603 | { |
| 604 | int more=1,size=0; |
| 605 | long byte; |
| 606 | do{ |
| 607 | byte=zm2l(zmand(value,l2zm(127L))); |
| 608 | value=zmrshift(value,l2zm(7L)); /*FIXME*/ |
| 609 | if((zmeqto(value,l2zm(0L))&&!(byte&0x40))|| |
| 610 | (zmeqto(value,l2zm(-1L))&&(byte&0x40))) |
| 611 | more=0; |
| 612 | size++; |
| 613 | }while(more); |
| 614 | return size; |
| 615 | } |
| 616 | static void dwarf2_print_sleb128(FILE *f,zmax value) |
| 617 | { |
| 618 | int more=1; |
| 619 | long byte; |
| 620 | emit(f,"\t%s\t",dwarfd1); |
| 621 | do{ |
| 622 | byte=zm2l(zmand(value,l2zm(127L))); |
| 623 | value=zmrshift(value,l2zm(7L)); /*FIXME*/ |
| 624 | if((zmeqto(value,l2zm(0L))&&!(byte&0x40))|| |
| 625 | (zmeqto(value,l2zm(-1L))&&(byte&0x40))){ |
| 626 | more=0; |
| 627 | emit(f,"%ld\n",byte); |
| 628 | }else{ |
| 629 | emit(f,"%ld,",byte|0x80); |
| 630 | } |
| 631 | }while(more); |
| 632 | } |
| 633 | static void dwarf2_print_location(FILE *f,obj *o) |
| 634 | { |
| 635 | if(o->flags&(KONST|DREFOBJ)) ierror(0); |
| 636 | if(!(o->flags&(VAR|REG))) ierror(0); |
| 637 | if(o->flags®){ |
| 638 | int r=dwarf2_regnumber(o->reg); |
| 639 | if(r<=31){ |
| 640 | emit(f,"\t%s\t%d\n",dwarfd2,1); |
| 641 | emit(f,"\t%s\t%d\n",dwarfd1,DW_OP_reg0+r); |
| 642 | }else{ |
| 643 | emit(f,"\t%s\t%d\n",dwarfd2,1+dwarf2_uleb128_size(ul2zum((unsigned long)r))); |
| 644 | emit(f,"\t%s\t%d\n",dwarfd1,DW_OP_regx); |
| 645 | dwarf2_print_uleb128(f,ul2zum(r)); |
| 646 | } |
| 647 | }else{ |
| 648 | if(o->v->storage_class==STATIC||o->v->storage_class==EXTERN){ |
| 649 | if(cross_module&&!(o->v->flags&REFERENCED)){ |
| 650 | emit(f,"\t%s\t0\n",dwarfd1); |
| 651 | }else{ |
| 652 | emit(f,"\t%s\t%d\n",dwarfd2,(int)(1+sizeof_addr)); |
| 653 | emit(f,"\t%s\t%d\n",dwarfd1,DW_OP_addr); |
| 654 | if(o->v->storage_class==STATIC) |
| 655 | emit(f,"\t%s\t%s%ld\n",da,lp,zm2l(o->v->offset)); |
| 656 | else |
| 657 | emit(f,"\t%s\t%s%s\n",da,ip,o->v->identifier); |
| 658 | } |
| 659 | }else{ |
| 660 | zmax of=dwarf2_fboffset(o->v); |
| 661 | emit(f,"\t%s\t%d\n",dwarfd2,1+dwarf2_sleb128_size(of)); |
| 662 | emit(f,"\t%s\t%d\n",dwarfd1,DW_OP_fbreg); |
| 663 | dwarf2_print_sleb128(f,of); |
| 664 | } |
| 665 | } |
| 666 | } |
| 667 | static int dwarf2_file(const char *p) |
| 668 | { |
| 669 | int i; |
| 670 | if(!p) ierror(0); |
| 671 | for(i=0;i<namecount;i++) |
| 672 | if(!strcmp(p,names[i])) |
| 673 | return i+1; |
| 674 | namecount++; |
| 675 | names=myrealloc(names,namecount*sizeof(*names)); |
| 676 | names[namecount-1]=mymalloc(strlen(p)+1); |
| 677 | strcpy(names[namecount-1],p); |
| 678 | return namecount; |
| 679 | } |
| 680 | static int dwarf2_type(FILE *f,type *t) |
| 681 | { |
| 682 | int l,lo;char *p; |
| 683 | if(ISPOINTER(t->flags)){ |
| 684 | lo=dwarf2_type(f,t->next); |
| 685 | l=++label; |
| 686 | emit(f,"%s%d:\n",lp,l); |
| 687 | dwarf2_print_uleb128(f,ul2zum(POINTERTYPE)); |
| 688 | emit(f,"\t%s\t%s%d\n",da,lp,lo); |
| 689 | }else if(ISINT(t->flags)||ISFLOAT(t->flags)||(t->flags&NQ)==VOID){ |
| 690 | l=++label; |
| 691 | emit(f,"%s%d:\n",lp,l); |
| 692 | dwarf2_print_uleb128(f,ul2zum(BASETYPE)); |
| 693 | for(p=typname[t->flags&NQ];*p;p++) emit(f,"\t%s\t%d\n",dwarfd1,*p); |
| 694 | emit(f,"\t%s\t0\n",dwarfd1); |
| 695 | if(ISFLOAT(t->flags)){ |
| 696 | lo=DW_ATE_float; |
| 697 | }else if((t->flags&NQ)==CHAR){ |
| 698 | if(t->flags&UNSIGNED) |
| 699 | lo=DW_ATE_unsigned_char; |
| 700 | else |
| 701 | lo=DW_ATE_signed_char; |
| 702 | }else if((t->flags&NQ)==VOID){ |
| 703 | lo=DW_ATE_unsigned_char; |
| 704 | }else{ |
| 705 | if(!ISINT(t->flags)) ierror(0); |
| 706 | if(t->flags&UNSIGNED) |
| 707 | lo=DW_ATE_unsigned; |
| 708 | else |
| 709 | lo=DW_ATE_signed; |
| 710 | } |
| 711 | dwarf2_print_uleb128(f,ul2zum((unsigned long)lo)); |
| 712 | dwarf2_print_uleb128(f,sizetab[t->flags&NQ]); |
| 713 | }else if(ISARRAY(t->flags)){ |
| 714 | lo=dwarf2_type(f,t->next); |
| 715 | l=++label; |
| 716 | emit(f,"%s%d:\n",lp,l); |
| 717 | dwarf2_print_uleb128(f,ul2zum(ARRAYTYPE)); |
| 718 | emit(f,"\t%s\t%s%d\n",da,lp,lo); |
| 719 | dwarf2_print_uleb128(f,ul2zum(ARRAYDIM)); |
| 720 | dwarf2_print_uleb128(f,zumsub(t->size,ul2zum(1UL))); |
| 721 | emit(f,"\t%s\t0\n",dwarfd1); |
| 722 | }else if(ISSTRUCT(t->flags)||ISUNION(t->flags)){ |
| 723 | if(t->exact->label>0){ |
| 724 | l=t->exact->label; |
| 725 | }else{ |
| 726 | int i,*tl;zmax offset=l2zm(0L),al; |
| 727 | type *tp; |
| 728 | l=++label; |
| 729 | t->exact->label=l; |
| 730 | tl=mymalloc(t->exact->count*sizeof(*tl)); |
| 731 | for(i=0;i<t->exact->count;i++) |
| 732 | tl[i]=dwarf2_type(f,(*t->exact->sl)[i].styp); |
| 733 | emit(f,"%s%d:\n",lp,l); |
| 734 | if(t->exact->identifier){ |
| 735 | if(ISSTRUCT(t->flags)) |
| 736 | dwarf2_print_uleb128(f,STRUCTTAG); |
| 737 | else |
| 738 | dwarf2_print_uleb128(f,UNIONTAG); |
| 739 | dwarf2_print_uleb128(f,szof(t)); |
| 740 | for(p=t->exact->identifier;*p;p++) emit(f,"\t%s\t%d\n",dwarfd1,*p); |
| 741 | emit(f,"\t%s\t0\n",dwarfd1); |
| 742 | }else{ |
| 743 | if(ISSTRUCT(t->flags)) |
| 744 | dwarf2_print_uleb128(f,STRUCTTYPE); |
| 745 | else |
| 746 | dwarf2_print_uleb128(f,UNIONTYPE); |
| 747 | dwarf2_print_uleb128(f,szof(t)); |
| 748 | } |
| 749 | for(i=0;i<t->exact->count;i++){ |
| 750 | dwarf2_print_uleb128(f,MEMBERTYPE); |
| 751 | for(p=(*t->exact->sl)[i].identifier;*p;p++) emit(f,"\t%s\t%d\n",dwarfd1,*p); |
| 752 | emit(f,"\t%s\t0\n",dwarfd1); |
| 753 | emit(f,"\t%s\t%s%d\n",da,lp,tl[i]); |
| 754 | dwarf2_print_uleb128(f,zumadd(dwarf2_uleb128_size(zm2zum(offset)),ul2zum(1L))); |
| 755 | tp=(*t->exact->sl)[i].styp; |
| 756 | al=falign(tp); |
| 757 | offset=zmmult(zmdiv(zmadd(offset,zmsub(al,l2zm(1L))),al),al); |
| 758 | emit(f,"\t%s\t%d\n",dwarfd1,DW_OP_plus_uconst); |
| 759 | dwarf2_print_uleb128(f,zm2zum(offset)); |
| 760 | if(ISSTRUCT(t->flags)) |
| 761 | offset=zmadd(offset,szof(tp)); |
| 762 | } |
| 763 | emit(f,"\t%s\t0\n",dwarfd1); |
| 764 | free(tl); |
| 765 | } |
| 766 | }else if(ISFUNC(t->flags)){ |
| 767 | int *tl,i; |
| 768 | l=++label; |
| 769 | tl=mymalloc(t->exact->count*sizeof(*tl)); |
| 770 | for(i=0;i<t->exact->count;i++){ |
| 771 | if(((*t->exact->sl)[i].styp->flags&NQ)!=VOID) |
| 772 | tl[i]=dwarf2_type(f,(*t->exact->sl)[i].styp); |
| 773 | } |
| 774 | if((t->next->flags&NQ)==VOID){ |
| 775 | emit(f,"%s%d:\n",lp,l); |
| 776 | dwarf2_print_uleb128(f,VOIDFUNCTYPE); |
| 777 | }else{ |
| 778 | lo=dwarf2_type(f,t->next); |
| 779 | emit(f,"%s%d:\n",lp,l); |
| 780 | dwarf2_print_uleb128(f,FUNCTYPE); |
| 781 | emit(f,"\t%s\t%s%d\n",da,lp,lo); |
| 782 | } |
| 783 | for(i=0;i<t->exact->count;i++){ |
| 784 | if(((*t->exact->sl)[i].styp->flags&NQ)!=VOID){ |
| 785 | dwarf2_print_uleb128(f,PARMTYPE); |
| 786 | emit(f,"\t%s\t%s%d\n",da,lp,tl[i]); |
| 787 | } |
| 788 | } |
| 789 | emit(f,"\t%s\t0\n",dwarfd1); |
| 790 | free(tl); |
| 791 | }else{ |
| 792 | printf("%d\n",t->flags); |
| 793 | ierror(0); |
| 794 | } |
| 795 | if(t->flags&VOLATILE){ |
| 796 | lo=l;l=++label; |
| 797 | emit(f,"%s%d:\n",lp,l); |
| 798 | dwarf2_print_uleb128(f,ul2zum(VOLATILETYPE)); |
| 799 | emit(f,"\t%s\t%s%d\n",da,lp,lo); |
| 800 | } |
| 801 | if(t->flags&CONST){ |
| 802 | lo=l;l=++label; |
| 803 | emit(f,"%s%d:\n",lp,l); |
| 804 | dwarf2_print_uleb128(f,ul2zum(CONSTTYPE)); |
| 805 | emit(f,"\t%s\t%s%d\n",da,lp,lo); |
| 806 | } |
| 807 | return l; |
| 808 | } |
| 809 | static void dwarf2_var(FILE *f,Var *v) |
| 810 | { |
| 811 | char *p;int l; |
| 812 | if(!(v->flags&(DEFINED|TENTATIVE))) return; |
| 813 | if(v->storage_class==STATIC&&v->nesting>0&&!(v->flags&(USEDASSOURCE|USEDASDEST))) return; |
| 814 | |
| 815 | if(ISFUNC(v->vtyp->flags)) return; |
| 816 | if(*v->identifier&&v->storage_class!=TYPEDEF){ |
| 817 | l=dwarf2_type(f,v->vtyp); |
| 818 | if((v->storage_class==AUTO||v->storage_class==REGISTER)&&(!zmleq(l2zm(0L),v->offset)||v->reg)){ |
| 819 | dwarf2_print_uleb128(f,ul2zum(FORMALPARAMETER)); |
| 820 | }else{ |
| 821 | dwarf2_print_uleb128(f,ul2zum(VARIABLE)); |
| 822 | } |
| 823 | for(p=v->identifier;*p;p++) emit(f,"\t%s\t%d\n",dwarfd1,*p); |
| 824 | emit(f,"\t%s\t0\n",dwarfd1); |
| 825 | emit(f,"\t%s\t%s%d\n",da,lp,l); |
| 826 | if((v->storage_class==AUTO||v->storage_class==REGISTER)&&(!zmleq(l2zm(0L),v->offset)||v->reg)){ |
| 827 | /* no external flag for formal-parameter */ |
| 828 | }else{ |
| 829 | emit(f,"\t%s\t%d\n",dwarfd1,(v->storage_class==EXTERN)); |
| 830 | } |
| 831 | if((!v->dfilename||!v->dline)&&(!v->filename||!v->line)) ierror(0); |
| 832 | if(v->dfilename){ |
| 833 | dwarf2_print_uleb128(f,ul2zum((unsigned long)dwarf2_file(v->dfilename))); |
| 834 | dwarf2_print_uleb128(f,ul2zum((unsigned long)v->dline)); |
| 835 | }else{ |
| 836 | dwarf2_print_uleb128(f,ul2zum((unsigned long)dwarf2_file(v->filename))); |
| 837 | dwarf2_print_uleb128(f,ul2zum((unsigned long)v->line)); |
| 838 | } |
| 839 | { /*FIXME!*/ |
| 840 | obj o; |
| 841 | o.flags=VAR; |
| 842 | o.val.vmax=l2zm(0L); |
| 843 | o.v=v; |
| 844 | #if HAVE_LOCATION_LISTS |
| 845 | emit(f,"\t%s\t\".debug_loc\"\n",dsec); |
| 846 | ++label; |
| 847 | emit(f,"%s%d:\n",lp,label); |
| 848 | emit(f,"\t%s\t0\n",da); |
| 849 | emit(f,"\t%s\t-1\n",da); |
| 850 | dwarf2_print_location(f,&o); |
| 851 | emit(f,"\t%s\t0\n",da); |
| 852 | emit(f,"\t%s\t0\n",da); |
| 853 | emit(f,"\t%s\t\".debug_info\"\n",dsec); |
| 854 | emit(f,"\t%s\t%s%d\n",da,lp,label); |
| 855 | #else |
| 856 | dwarf2_print_location(f,&o); |
| 857 | #endif |
| 858 | } |
| 859 | } |
| 860 | } |
| 861 | static void dwarf2_print_comp_unit_header(FILE *f) |
| 862 | { |
| 863 | char *p; |
| 864 | extern char *copyright; /* not nice */ |
| 865 | extern char *inname; /* not nice */ |
| 866 | |
| 867 | abbrev_label=++label; |
| 868 | emit(f,"\t%s\t\".debug_abbrev\"\n",dsec); |
| 869 | emit(f,"%s%d:\n",lp,abbrev_label); |
| 870 | |
| 871 | dwarf2_print_uleb128(f,ul2zum(COMP_UNIT)); |
| 872 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_compile_unit)); |
| 873 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_yes)); |
| 874 | dwarf2_print_uleb128(f,ul2zum(DW_AT_language)); |
| 875 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 876 | dwarf2_print_uleb128(f,ul2zum(DW_AT_stmt_list)); |
| 877 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 878 | dwarf2_print_uleb128(f,ul2zum(DW_AT_producer)); |
| 879 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_string)); |
| 880 | dwarf2_print_uleb128(f,ul2zum(DW_AT_identifier_case)); |
| 881 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 882 | dwarf2_print_uleb128(f,ul2zum(DW_AT_name)); |
| 883 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_string)); |
| 884 | dwarf2_print_uleb128(f,ul2zum(0UL)); |
| 885 | dwarf2_print_uleb128(f,ul2zum(0UL)); |
| 886 | |
| 887 | dwarf2_print_uleb128(f,ul2zum(SUBPROGRAM)); |
| 888 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_subprogram)); |
| 889 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_yes)); |
| 890 | dwarf2_print_uleb128(f,ul2zum(DW_AT_name)); |
| 891 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_string)); |
| 892 | dwarf2_print_uleb128(f,ul2zum(DW_AT_low_pc)); |
| 893 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_addr)); |
| 894 | dwarf2_print_uleb128(f,ul2zum(DW_AT_high_pc)); |
| 895 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_addr)); |
| 896 | dwarf2_print_uleb128(f,ul2zum(DW_AT_type)); |
| 897 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 898 | dwarf2_print_uleb128(f,ul2zum(DW_AT_external)); |
| 899 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_flag)); |
| 900 | dwarf2_print_uleb128(f,ul2zum(DW_AT_decl_file)); |
| 901 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 902 | dwarf2_print_uleb128(f,ul2zum(DW_AT_decl_line)); |
| 903 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 904 | dwarf2_print_uleb128(f,ul2zum(DW_AT_frame_base)); |
| 905 | #if HAVE_LOCATION_LISTS |
| 906 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 907 | #else |
| 908 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_block2)); |
| 909 | #endif |
| 910 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 911 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 912 | |
| 913 | dwarf2_print_uleb128(f,ul2zum(SUBPROGRAMVOID)); |
| 914 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_subprogram)); |
| 915 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_yes)); |
| 916 | dwarf2_print_uleb128(f,ul2zum(DW_AT_name)); |
| 917 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_string)); |
| 918 | dwarf2_print_uleb128(f,ul2zum(DW_AT_low_pc)); |
| 919 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_addr)); |
| 920 | dwarf2_print_uleb128(f,ul2zum(DW_AT_high_pc)); |
| 921 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_addr)); |
| 922 | dwarf2_print_uleb128(f,ul2zum(DW_AT_external)); |
| 923 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_flag)); |
| 924 | dwarf2_print_uleb128(f,ul2zum(DW_AT_decl_file)); |
| 925 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 926 | dwarf2_print_uleb128(f,ul2zum(DW_AT_decl_line)); |
| 927 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 928 | dwarf2_print_uleb128(f,ul2zum(DW_AT_frame_base)); |
| 929 | #if HAVE_LOCATION_LISTS |
| 930 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 931 | #else |
| 932 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_block2)); |
| 933 | #endif |
| 934 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 935 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 936 | |
| 937 | dwarf2_print_uleb128(f,ul2zum(FORMALPARAMETER)); |
| 938 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_formal_parameter)); |
| 939 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_no)); |
| 940 | dwarf2_print_uleb128(f,ul2zum(DW_AT_name)); |
| 941 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_string)); |
| 942 | dwarf2_print_uleb128(f,ul2zum(DW_AT_type)); |
| 943 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 944 | dwarf2_print_uleb128(f,ul2zum(DW_AT_decl_file)); |
| 945 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 946 | dwarf2_print_uleb128(f,ul2zum(DW_AT_decl_line)); |
| 947 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 948 | dwarf2_print_uleb128(f,ul2zum(DW_AT_location)); |
| 949 | #if HAVE_LOCATION_LISTS |
| 950 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 951 | #else |
| 952 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_block2)); |
| 953 | #endif |
| 954 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 955 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 956 | |
| 957 | dwarf2_print_uleb128(f,ul2zum(VARIABLE)); |
| 958 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_variable)); |
| 959 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_no)); |
| 960 | dwarf2_print_uleb128(f,ul2zum(DW_AT_name)); |
| 961 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_string)); |
| 962 | dwarf2_print_uleb128(f,ul2zum(DW_AT_type)); |
| 963 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 964 | dwarf2_print_uleb128(f,ul2zum(DW_AT_external)); |
| 965 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_flag)); |
| 966 | dwarf2_print_uleb128(f,ul2zum(DW_AT_decl_file)); |
| 967 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 968 | dwarf2_print_uleb128(f,ul2zum(DW_AT_decl_line)); |
| 969 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 970 | dwarf2_print_uleb128(f,ul2zum(DW_AT_location)); |
| 971 | #if HAVE_LOCATION_LISTS |
| 972 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 973 | #else |
| 974 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_block2)); |
| 975 | #endif |
| 976 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 977 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 978 | |
| 979 | dwarf2_print_uleb128(f,ul2zum(BASETYPE)); |
| 980 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_base_type)); |
| 981 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_no)); |
| 982 | dwarf2_print_uleb128(f,ul2zum(DW_AT_name)); |
| 983 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_string)); |
| 984 | dwarf2_print_uleb128(f,ul2zum(DW_AT_encoding)); |
| 985 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 986 | dwarf2_print_uleb128(f,ul2zum(DW_AT_byte_size)); |
| 987 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 988 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 989 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 990 | |
| 991 | dwarf2_print_uleb128(f,ul2zum(POINTERTYPE)); |
| 992 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_pointer_type)); |
| 993 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_no)); |
| 994 | dwarf2_print_uleb128(f,ul2zum(DW_AT_type)); |
| 995 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 996 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 997 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 998 | |
| 999 | dwarf2_print_uleb128(f,ul2zum(CONSTTYPE)); |
| 1000 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_const_type)); |
| 1001 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_no)); |
| 1002 | dwarf2_print_uleb128(f,ul2zum(DW_AT_type)); |
| 1003 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 1004 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1005 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1006 | |
| 1007 | dwarf2_print_uleb128(f,ul2zum(VOLATILETYPE)); |
| 1008 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_volatile_type)); |
| 1009 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_no)); |
| 1010 | dwarf2_print_uleb128(f,ul2zum(DW_AT_type)); |
| 1011 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 1012 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1013 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1014 | |
| 1015 | dwarf2_print_uleb128(f,ul2zum(ARRAYTYPE)); |
| 1016 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_array_type)); |
| 1017 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_yes)); |
| 1018 | dwarf2_print_uleb128(f,ul2zum(DW_AT_type)); |
| 1019 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 1020 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1021 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1022 | |
| 1023 | dwarf2_print_uleb128(f,ul2zum(ARRAYDIM)); |
| 1024 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_subrange_type)); |
| 1025 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_no)); |
| 1026 | dwarf2_print_uleb128(f,ul2zum(DW_AT_upper_bound)); |
| 1027 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 1028 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1029 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1030 | |
| 1031 | dwarf2_print_uleb128(f,ul2zum(STRUCTTYPE)); |
| 1032 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_structure_type)); |
| 1033 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_yes)); |
| 1034 | dwarf2_print_uleb128(f,ul2zum(DW_AT_byte_size)); |
| 1035 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 1036 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1037 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1038 | |
| 1039 | dwarf2_print_uleb128(f,ul2zum(UNIONTYPE)); |
| 1040 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_union_type)); |
| 1041 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_yes)); |
| 1042 | dwarf2_print_uleb128(f,ul2zum(DW_AT_byte_size)); |
| 1043 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 1044 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1045 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1046 | |
| 1047 | dwarf2_print_uleb128(f,ul2zum(STRUCTTAG)); |
| 1048 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_structure_type)); |
| 1049 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_yes)); |
| 1050 | dwarf2_print_uleb128(f,ul2zum(DW_AT_byte_size)); |
| 1051 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 1052 | dwarf2_print_uleb128(f,ul2zum(DW_AT_name)); |
| 1053 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_string)); |
| 1054 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1055 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1056 | |
| 1057 | dwarf2_print_uleb128(f,ul2zum(UNIONTAG)); |
| 1058 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_union_type)); |
| 1059 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_yes)); |
| 1060 | dwarf2_print_uleb128(f,ul2zum(DW_AT_byte_size)); |
| 1061 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_udata)); |
| 1062 | dwarf2_print_uleb128(f,ul2zum(DW_AT_name)); |
| 1063 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_string)); |
| 1064 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1065 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1066 | |
| 1067 | dwarf2_print_uleb128(f,ul2zum(MEMBERTYPE)); |
| 1068 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_member)); |
| 1069 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_no)); |
| 1070 | dwarf2_print_uleb128(f,ul2zum(DW_AT_name)); |
| 1071 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_string)); |
| 1072 | dwarf2_print_uleb128(f,ul2zum(DW_AT_type)); |
| 1073 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 1074 | dwarf2_print_uleb128(f,ul2zum(DW_AT_data_member_location)); |
| 1075 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_block)); |
| 1076 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1077 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1078 | |
| 1079 | dwarf2_print_uleb128(f,ul2zum(FUNCTYPE)); |
| 1080 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_subroutine_type)); |
| 1081 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_yes)); |
| 1082 | dwarf2_print_uleb128(f,ul2zum(DW_AT_type)); |
| 1083 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 1084 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1085 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1086 | |
| 1087 | dwarf2_print_uleb128(f,ul2zum(VOIDFUNCTYPE)); |
| 1088 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_subroutine_type)); |
| 1089 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_yes)); |
| 1090 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1091 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1092 | |
| 1093 | dwarf2_print_uleb128(f,ul2zum(PARMTYPE)); |
| 1094 | dwarf2_print_uleb128(f,ul2zum(DW_TAG_formal_parameter)); |
| 1095 | dwarf2_print_uleb128(f,ul2zum(DW_CHILDREN_no)); |
| 1096 | dwarf2_print_uleb128(f,ul2zum(DW_AT_type)); |
| 1097 | dwarf2_print_uleb128(f,ul2zum(DW_FORM_ref_addr)); |
| 1098 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1099 | dwarf2_print_uleb128(f,ul2zum(0L)); |
| 1100 | |
| 1101 | |
| 1102 | info_start=++label;info_end=++label; |
| 1103 | emit(f,"\t%s\t\".debug_info\"\n",dsec); |
| 1104 | |
| 1105 | /* header */ |
| 1106 | emit(f,"%s%d:\n",lp,info_start); |
| 1107 | emit(f,"\t%s\t%s%d-%s%d-4\n",dwarfd4,lp,info_end,lp,info_start); |
| 1108 | emit(f,"\t%s\t2\n",dwarfd2); /* version */ |
| 1109 | emit(f,"\t%s\t%s%d\n",dwarfd4,lp,abbrev_label); |
| 1110 | emit(f,"\t%s\t%d\n",dwarfd1,sizeof_addr); |
| 1111 | |
| 1112 | /* compile_unit */ |
| 1113 | dwarf2_print_uleb128(f,ul2zum(COMP_UNIT)); |
| 1114 | dwarf2_print_uleb128(f,ul2zum(DW_LANG_C89)); |
| 1115 | line_start=++label;line_end=++label; |
| 1116 | emit(f,"\t%s\t%s%d\n",da,lp,line_start); |
| 1117 | for(p=copyright;*p;p++) emit(f,"\t%s\t%d\n",dwarfd1,*p); |
| 1118 | emit(f,"\t%s\t0\n",dwarfd1); |
| 1119 | emit(f,"\t%s\t%d\n",dwarfd1,DW_ID_case_sensitive); |
| 1120 | for(p=inname?inname:"<multiple>";*p;p++) emit(f,"\t%s\t%d\n",dwarfd1,*p); |
| 1121 | emit(f,"\t%s\t0\n",dwarfd1); |
| 1122 | } |
| 1123 | static void dwarf2_cleanup(FILE *f) |
| 1124 | { |
| 1125 | int i,line,file,label,length;char *p; |
| 1126 | tdwarf2_line_info *li,*m; |
| 1127 | Var *vl; |
| 1128 | struct_declaration *sd; |
| 1129 | emit(f,"\t%s\t\".debug_line\"\n",dsec); |
| 1130 | /* line info */ |
| 1131 | emit(f,"%s%d:\n",lp,line_start); |
| 1132 | emit(f,"\t%s\t%s%d-%s%d-4\n",dwarfd4,lp,line_end,lp,line_start); /* length */ |
| 1133 | emit(f,"\t%s\t2\n",dwarfd2); /* version */ |
| 1134 | length=16; |
| 1135 | for(i=0;i<namecount;i++) length+=strlen(names[i])+4; |
| 1136 | emit(f,"\t%s\t%d\n",dwarfd4,length); /* prologue length */ |
| 1137 | emit(f,"\t%s\t1\n",dwarfd1); /* instruction_length */ |
| 1138 | emit(f,"\t%s\t1\n",dwarfd1); /* is_stmt */ |
| 1139 | emit(f,"\t%s\t-10\n",dwarfd1); /* line_base */ |
| 1140 | emit(f,"\t%s\t245\n",dwarfd1); /* line_range */ |
| 1141 | emit(f,"\t%s\t10\n",dwarfd1); /* opcode_base */ |
| 1142 | emit(f,"\t%s\t0\n",dwarfd1); /* standard opcode arguments */ |
| 1143 | emit(f,"\t%s\t1\n",dwarfd1); |
| 1144 | emit(f,"\t%s\t1\n",dwarfd1); |
| 1145 | emit(f,"\t%s\t1\n",dwarfd1); |
| 1146 | emit(f,"\t%s\t1\n",dwarfd1); |
| 1147 | emit(f,"\t%s\t0\n",dwarfd1); |
| 1148 | emit(f,"\t%s\t0\n",dwarfd1); |
| 1149 | emit(f,"\t%s\t0\n",dwarfd1); |
| 1150 | emit(f,"\t%s\t1\n",dwarfd1); |
| 1151 | emit(f,"\t%s\t0\n",dwarfd1); /* include directories */ |
| 1152 | for(i=0;i<namecount;i++){ |
| 1153 | for(p=names[i];*p;p++) emit(f,"\t%s\t%d\n",dwarfd1,*p); |
| 1154 | emit(f,"\t%s\t0\n",dwarfd1); |
| 1155 | emit(f,"\t%s\t0\n",dwarfd1); |
| 1156 | emit(f,"\t%s\t0\n",dwarfd1); |
| 1157 | emit(f,"\t%s\t0\n",dwarfd1); |
| 1158 | } |
| 1159 | emit(f,"\t%s\t0\n",dwarfd1); /* file names */ |
| 1160 | |
| 1161 | file=-1;line=1;label=-1; |
| 1162 | li=dwarf2_first_li; |
| 1163 | while(li){ |
| 1164 | m=li->next; |
| 1165 | if(li->file!=file){ |
| 1166 | file=li->file; |
| 1167 | emit(f,"\t%s\t%d\n",dwarfd1,DW_LNS_set_file); |
| 1168 | dwarf2_print_uleb128(f,ul2zum((long)file)); |
| 1169 | } |
| 1170 | if(!li->id&&li->label!=label){ |
| 1171 | label=li->label; |
| 1172 | emit(f,"\t%s\t0\n",dwarfd1); /* extended opcode */ |
| 1173 | emit(f,"\t%s\t%d\n",dwarfd1,1+sizeof_addr); /* length */ |
| 1174 | emit(f,"\t%s\t%d\n",dwarfd1,DW_LNE_set_address); |
| 1175 | emit(f,"\t%s\t%s%d\n",da,lp,label); |
| 1176 | } |
| 1177 | if(li->id){ |
| 1178 | emit(f,"\t%s\t0\n",dwarfd1); /* extended opcode */ |
| 1179 | emit(f,"\t%s\t%d\n",dwarfd1,1+sizeof_addr); /* length */ |
| 1180 | emit(f,"\t%s\t%d\n",dwarfd1,DW_LNE_set_address); |
| 1181 | emit(f,"\t%s\t%s%s\n",da,ip,li->id); |
| 1182 | free(li->id); |
| 1183 | } |
| 1184 | if(li->line!=line){ |
| 1185 | emit(f,"\t%s\t%d\n",dwarfd1,DW_LNS_advance_line); |
| 1186 | dwarf2_print_sleb128(f,l2zm((long)(li->line-line))); |
| 1187 | line=li->line; |
| 1188 | } |
| 1189 | emit(f,"\t%s\t%d\n",dwarfd1,DW_LNS_copy); |
| 1190 | free(li); |
| 1191 | li=m; |
| 1192 | } |
| 1193 | emit(f,"\t%s\t0,1,1\n",dwarfd1); /* end_sequence */ |
| 1194 | emit(f,"%s%d:\n",lp,line_end); |
| 1195 | emit(f,"\t%s\t\".debug_info\"\n",dsec); |
| 1196 | for(sd=first_sd[0];sd;sd=sd->next){ |
| 1197 | if(sd->identifier){ |
| 1198 | static type styp; |
| 1199 | styp.flags=sd->typ; |
| 1200 | styp.exact=sd; |
| 1201 | sd->label=0; |
| 1202 | dwarf2_type(f,&styp); |
| 1203 | } |
| 1204 | } |
| 1205 | for(vl=first_var[0];vl;vl=vl->next) |
| 1206 | dwarf2_var(f,vl); |
| 1207 | for(vl=first_ext;vl;vl=vl->next) |
| 1208 | dwarf2_var(f,vl); |
| 1209 | emit(f,"\t%s\t0\n",dwarfd1); |
| 1210 | emit(f,"%s%d:\n",lp,info_end); |
| 1211 | for(i=0;i<namecount;i++) free(names[i]); |
| 1212 | free(names); |
| 1213 | } |
| 1214 | /* generate line info for IC p, return 0 if nothing had to be generated */ |
| 1215 | static void dwarf2_line_info(FILE *f,IC *p) |
| 1216 | { |
| 1217 | static int line,file,n; |
| 1218 | tdwarf2_line_info *new; |
| 1219 | if(!f) return; |
| 1220 | if(p->line==0) return; |
| 1221 | if(!p->file) ierror(0); |
| 1222 | n=dwarf2_file(p->file); |
| 1223 | if(n!=file||p->line!=line){ |
| 1224 | file=n; |
| 1225 | line=p->line; |
| 1226 | emit(f,"%s%d:\n",lp,++label); |
| 1227 | dwarf2_add_line(file,line,label,0); |
| 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | static void dwarf2_function(FILE *f,Var *v,int endlabel) |
| 1232 | { |
| 1233 | char *p;int l;Var *vl; |
| 1234 | struct struct_identifier *si; |
| 1235 | /* subprogram */ |
| 1236 | if(!f) return; |
| 1237 | emit(f,"\t%s\t\".debug_info\"\n",dsec); |
| 1238 | if(!v->vtyp||!v->vtyp->next) ierror(0); |
| 1239 | if((v->vtyp->next->flags&NQ)==VOID){ |
| 1240 | dwarf2_print_uleb128(f,ul2zum(SUBPROGRAMVOID)); |
| 1241 | }else{ |
| 1242 | l=dwarf2_type(f,v->vtyp->next); |
| 1243 | dwarf2_print_uleb128(f,ul2zum(SUBPROGRAM)); |
| 1244 | } |
| 1245 | for(p=ip;*p;p++) emit(f,"\t%s\t%d\n",dwarfd1,*p); |
| 1246 | for(p=v->identifier;*p;p++) emit(f,"\t%s\t%d\n",dwarfd1,*p); |
| 1247 | emit(f,"\t%s\t0\n",dwarfd1); |
| 1248 | if(v->storage_class==EXTERN){ |
| 1249 | emit(f,"\t%s\t%s%s\n",da,ip,v->identifier); |
| 1250 | }else{ |
| 1251 | emit(f,"\t%s\t%s%ld\n",da,lp,zm2l(v->offset)); |
| 1252 | } |
| 1253 | emit(f,"\t%s\t%s%d\n",da,lp,endlabel); |
| 1254 | if((v->vtyp->next->flags&NQ)!=VOID) |
| 1255 | emit(f,"\t%s\t%s%d\n",da,lp,l); |
| 1256 | if(!v->dfilename||v->dline<=0) ierror(0); |
| 1257 | emit(f,"\t%s\t%d\n",dwarfd1,(v->storage_class==EXTERN)); |
| 1258 | if(v->storage_class==EXTERN) |
| 1259 | dwarf2_add_line(dwarf2_file(v->dfilename),v->dline,0,v->identifier); |
| 1260 | else |
| 1261 | dwarf2_add_line(dwarf2_file(v->dfilename),v->dline,(int)zm2l(v->offset),0); |
| 1262 | dwarf2_print_uleb128(f,ul2zum((long)dwarf2_file(v->dfilename))); |
| 1263 | dwarf2_print_uleb128(f,ul2zum((long)v->dline)); |
| 1264 | #if HAVE_LOCATION_LISTS |
| 1265 | emit(f,"\t%s\t\".debug_loc\"\n",dsec); |
| 1266 | emit(f,"%s%d:\n",lp,++label); |
| 1267 | emit(f,"\t%s\t0\n",da); |
| 1268 | emit(f,"\t%s\t-1\n",da); |
| 1269 | dwarf2_print_frame_location(f,v); |
| 1270 | emit(f,"\t%s\t0\n",da); |
| 1271 | emit(f,"\t%s\t0\n",da); |
| 1272 | emit(f,"\t%s\t\".debug_info\"\n",dsec); |
| 1273 | emit(f,"\t%s\t%s%d\n",da,lp,label); |
| 1274 | #else |
| 1275 | dwarf2_print_frame_location(f,v); |
| 1276 | #endif |
| 1277 | |
| 1278 | /* children */ |
| 1279 | |
| 1280 | /*FIXME: not nice */ |
| 1281 | if(cross_module){ |
| 1282 | if(!v->fi) ierror(0); |
| 1283 | for(vl=v->fi->vars;vl;vl=vl->next) |
| 1284 | dwarf2_var(f,vl); |
| 1285 | }else{ |
| 1286 | for(vl=first_var[1];vl;vl=vl->next) |
| 1287 | dwarf2_var(f,vl); |
| 1288 | for(vl=merk_varf;vl;vl=vl->next) |
| 1289 | dwarf2_var(f,vl); |
| 1290 | } |
| 1291 | |
| 1292 | |
| 1293 | emit(f,"\t%s\t0\n",dwarfd1); |
| 1294 | } |