case DW_TAG_imported_unit: return "DW_TAG_imported_unit";
case DW_TAG_condition: return "DW_TAG_condition";
case DW_TAG_shared_type: return "DW_TAG_shared_type";
+ /* DWARF 4. */
+ case DW_TAG_type_unit: return "DW_TAG_type_unit";
+ case DW_TAG_rvalue_reference_type: return "DW_TAG_rvalue_reference_type";
+ case DW_TAG_template_alias: return "DW_TAG_template_alias";
/* SGI/MIPS Extensions. */
case DW_TAG_MIPS_loop: return "DW_TAG_MIPS_loop";
/* HP extensions. See:
case DW_FORM_ref8: return "DW_FORM_ref8";
case DW_FORM_ref_udata: return "DW_FORM_ref_udata";
case DW_FORM_indirect: return "DW_FORM_indirect";
+ case DW_FORM_sec_offset:return "DW_FORM_sec_offset";
+ case DW_FORM_exprloc: return "DW_FORM_exprloc";
+ case DW_FORM_flag_present:return "DW_FORM_flag_present";
+ case DW_FORM_ref_sig8: return "DW_FORM_ref_sig8";
default: return "DW_FORM_???";
}
}
case DW_AT_elemental: return "DW_AT_elemental";
case DW_AT_pure: return "DW_AT_pure";
case DW_AT_recursive: return "DW_AT_recursive";
+ /* DWARF 4 values. */
+ case DW_AT_signature: return "DW_AT_signature";
+ case DW_AT_main_subprogram: return "DW_AT_main_subprogram";
+ case DW_AT_data_bit_offset: return "DW_AT_data_bit_offset";
+ case DW_AT_const_expr: return "DW_AT_const_expr";
+ case DW_AT_enum_class: return "DW_AT_enum_class";
+ case DW_AT_linkage_name: return "DW_AT_linkage_name";
/* SGI/MIPS extensions. */
/* case DW_AT_MIPS_fde: return "DW_AT_MIPS_fde"; */
/* DW_AT_MIPS_fde == DW_AT_HP_unmodifiable */
DW_TAG_imported_unit = 0x3d,
DW_TAG_condition = 0x3f,
DW_TAG_shared_type = 0x40,
+ /* DWARF 4. */
+ DW_TAG_type_unit = 0x41,
+ DW_TAG_rvalue_reference_type = 0x42,
+ DW_TAG_template_alias = 0x43,
/* SGI/MIPS Extensions. */
DW_TAG_MIPS_loop = 0x4081,
/* HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz . */
DW_LANG_ObjC_plus_plus = 0x0011,
DW_LANG_UPC = 0x0012,
DW_LANG_D = 0x0013,
+ /* DWARF 4. */
+ DW_LANG_Python = 0x0014,
/* MIPS. */
DW_LANG_Mips_Assembler = 0x8001,
/* UPC. */
DW_FORM_ref4 = 0x13,
DW_FORM_ref8 = 0x14,
DW_FORM_ref_udata = 0x15,
- DW_FORM_indirect = 0x16
+ DW_FORM_indirect = 0x16,
+ /* DWARF 4 values. */
+ DW_FORM_sec_offset = 0x17,
+ DW_FORM_exprloc = 0x18,
+ DW_FORM_flag_present = 0x19,
+ DW_FORM_ref_sig8 = 0x20
}
DW_FORM;
DW_AT_elemental = 0x66,
DW_AT_pure = 0x67,
DW_AT_recursive = 0x68,
+ /* DWARF 4 values. */
+ DW_AT_signature = 0x69,
+ DW_AT_main_subprogram = 0x6a,
+ DW_AT_data_bit_offset = 0x6b,
+ DW_AT_const_expr = 0x6c,
+ DW_AT_enum_class = 0x6d,
+ DW_AT_linkage_name = 0x6e,
/* SGI/MIPS extensions. */
DW_AT_MIPS_fde = 0x2001,
DW_AT_MIPS_loop_begin = 0x2002,
/*--------------------------------------------------------------------*/
-/*--- Read DWARF1/2/3 debug info. readdwarf.c ---*/
+/*--- Read DWARF1/2/3/4 debug info. readdwarf.c ---*/
/*--------------------------------------------------------------------*/
/*
UShort li_version;
ULong li_header_length;
UChar li_min_insn_length;
+ UChar li_max_ops_per_insn;
UChar li_default_is_stmt;
Int li_line_base;
UChar li_line_range;
{
DW_LNE_end_sequence = 1,
DW_LNE_set_address = 2,
- DW_LNE_define_file = 3
+ DW_LNE_define_file = 3,
+ DW_LNE_set_discriminator = 4
};
typedef struct
UInt column;
Int is_stmt;
Int basic_block;
- Int end_sequence;
+ UChar end_sequence;
} LineSMR;
VG_(printf)(" DWARF2-line: set_address\n");
break;
+ case DW_LNE_set_discriminator:
+ read_leb128 (data, & bytes_read, 0);
+ data += bytes_read;
+ break;
+
default:
if (di->ddump_line)
VG_(printf)("process_extended_line_op:default\n");
VG_(printf)(" DWARF Version: %d\n",
(Int)info.li_version);
- if (info.li_version != 2 && info.li_version != 3) {
+ if (info.li_version != 2 && info.li_version != 3 && info.li_version != 4) {
ML_(symerr)(di, True,
- "Only DWARF version 2 and 3 line info "
+ "Only DWARF version 2, 3 and 4 line info "
"is currently supported.");
goto out;
}
VG_(printf)(" Minimum Instruction Length: %d\n",
(Int)info.li_min_insn_length);
+ /* We only support machines with one opcode per instruction
+ for now. If we ever want to support VLIW machines there is
+ code to handle multiple opcodes per instruction in the
+ patch attached to BZ#233595.
+ */
+ if (info.li_version >= 4) {
+ info.li_max_ops_per_insn = * ((UChar *)external);
+ if (info.li_max_ops_per_insn != 1) {
+ ML_(symerr)(di, True,
+ "Invalid Maximum Ops Per Insn in line info.");
+ goto out;
+ }
+ external += 1;
+ if (di->ddump_line)
+ VG_(printf)(" Maximum Ops Per Insn: %d\n",
+ (Int)info.li_max_ops_per_insn);
+ } else {
+ info.li_max_ops_per_insn = 1;
+ }
+
info.li_default_is_stmt = * ((UChar *)external);
external += 1;
if (di->ddump_line)
Int advAddr;
op_code -= info.li_opcode_base;
- adv = (op_code / info.li_line_range)
+ adv = (op_code / info.li_line_range)
* info.li_min_insn_length;
advAddr = adv;
state_machine_regs.address += adv;
break;
case DW_LNS_advance_pc:
- adv = info.li_min_insn_length
+ adv = info.li_min_insn_length
* read_leb128 (data, & bytes_read, 0);
data += bytes_read;
state_machine_regs.address += adv;
blklen = read_initial_length_field( p, &ui->dw64 );
p += ui->dw64 ? 12 : 4;
- /* version should be 2 */
+ /* version should be 2, 3 or 4 */
ver = *((UShort*)p);
p += 2;
classes) use FORM_data8, not FORM_data4. Also,
FORM_ref_addr and FORM_strp are 64-bit values, not 32-bit
values. */
+ /* TJH 27 Apr 10: in DWARF 4 lineptr (and loclistptr,macptr,
+ rangelistptr classes) use FORM_sec_offset which is 64 bits
+ in 64 bit DWARF and 32 bits in 32 bit DWARF. */
switch( form ) {
/* Those cases extract the data properly */
case 0x05: /* FORM_data2 */ cval = *((UShort*)p); p +=2; break;
case 0x08: /* FORM_string */ sval = (Char*)p;
p += VG_(strlen)((Char*)p) + 1; break;
case 0x0b: /* FORM_data1 */ cval = *p; p++; break;
-
+ case 0x17: /* FORM_sec_offset */if (ui->dw64) {
+ cval = *((ULong*)p); p += 8;
+ } else {
+ cval = *((UInt*)p); p += 4;
+ }; break;
/* TODO : Following ones just skip data - implement if you need */
case 0x01: /* FORM_addr */ p += addr_size; break;
case 0x03: /* FORM_block2 */ p += *((UShort*)p) + 2; break;
case 0x13: /* FORM_ref4 */ p += 4; break;
case 0x14: /* FORM_ref8 */ p += 8; break;
case 0x15: /* FORM_ref_udata */ read_leb128U( &p ); break;
-
+ case 0x18: /* FORM_exprloc */ p += read_leb128U( &p ); break;
+ case 0x19: /* FORM_flag_present */break;
+ case 0x20: /* FORM_ref_sig8 */ p += 8; break;
+
default:
VG_(printf)( "### unhandled dwarf2 abbrev form code 0x%x\n", form );
break;
/* version should be 2 */
ver = *((UShort*)( block_img + blklen_len ));
- if ( ver != 2 && ver != 3 ) {
+ if ( ver != 2 && ver != 3 && ver != 4 ) {
ML_(symerr)( di, True,
- "Ignoring non-Dwarf2/3 block in .debug_info" );
+ "Ignoring non-Dwarf2/3/4 block in .debug_info" );
continue;
}
VG_(printf)("cie.version = %d\n", (Int)cie_version);
if (di->ddump_frames)
VG_(printf)(" Version: %d\n", (Int)cie_version);
- if (cie_version != 1 && cie_version != 3) {
- how = "unexpected CIE version (not 1 nor 3)";
+ if (cie_version != 1 && cie_version != 3 && cie_version != 4) {
+ how = "unexpected CIE version (not 1 nor 3 nor 4)";
goto bad;
}
cie_augmentation += 2;
}
+ if (cie_version >= 4) {
+ if (read_UChar(data) != sizeof(Addr)) {
+ how = "unexpected address size";
+ goto bad;
+ }
+ data += sizeof(UChar);
+ if (read_UChar(data) != 0) {
+ how = "unexpected non-zero segment size";
+ goto bad;
+ }
+ data += sizeof(UChar);
+ }
+
the_CIEs[this_CIE].code_a_f = read_leb128( data, &nbytes, 0);
data += nbytes;
if (di->trace_cfi)
/*--------------------------------------------------------------------*/
-/*--- Read DWARF3 ".debug_info" sections (DIE trees). ---*/
+/*--- Read DWARF3/4 ".debug_info" sections (DIE trees). ---*/
/*--- readdwarf3.c ---*/
/*--------------------------------------------------------------------*/
void (*barf)( HChar* ) __attribute__((noreturn));
/* Is this 64-bit DWARF ? */
Bool is_dw64;
- /* Which DWARF version ? (2 or 3) */
+ /* Which DWARF version ? (2, 3 or 4) */
UShort version;
/* Length of this Compilation Unit, as stated in the
.unit_length :: InitialLength field of the CU Header.
/* version */
cc->version = get_UShort( c );
- if (cc->version != 2 && cc->version != 3)
- cc->barf( "parse_CU_Header: is neither DWARF2 nor DWARF3" );
+ if (cc->version != 2 && cc->version != 3 && cc->version != 4)
+ cc->barf( "parse_CU_Header: is neither DWARF2 nor DWARF3 nor DWARF4" );
TRACE_D3(" Version: %d\n", (Int)cc->version );
/* debug_abbrev_offset */
*ctsSzB = 8;
TRACE_D3("%llu", *cts);
break;
+ case DW_FORM_sec_offset:
+ *cts = (ULong)get_Dwarfish_UWord( c, cc->is_dw64 );
+ *ctsSzB = cc->is_dw64 ? 8 : 4;
+ TRACE_D3("%llu", *cts);
+ break;
case DW_FORM_sdata:
*cts = (ULong)(Long)get_SLEB128(c);
*ctsSzB = 8;
TRACE_D3("%lld", (Long)*cts);
break;
+ case DW_FORM_udata:
+ *cts = (ULong)(Long)get_ULEB128(c);
+ *ctsSzB = 8;
+ TRACE_D3("%llu", (Long)*cts);
+ break;
case DW_FORM_addr:
/* note, this is a hack. DW_FORM_addr is defined as getting
a word the size of the target machine as defined by the
*ctsMemSzB = 1 + (ULong)VG_(strlen)(str);
break;
}
+ case DW_FORM_ref1: {
+ UChar u8 = get_UChar(c);
+ UWord res = cc->cu_start_offset + (UWord)u8;
+ *cts = (ULong)res;
+ *ctsSzB = sizeof(UWord);
+ TRACE_D3("<%lx>", res);
+ break;
+ }
+ case DW_FORM_ref2: {
+ UShort u16 = get_UShort(c);
+ UWord res = cc->cu_start_offset + (UWord)u16;
+ *cts = (ULong)res;
+ *ctsSzB = sizeof(UWord);
+ TRACE_D3("<%lx>", res);
+ break;
+ }
case DW_FORM_ref4: {
UInt u32 = get_UInt(c);
UWord res = cc->cu_start_offset + (UWord)u32;
TRACE_D3("<%lx>", res);
break;
}
+ case DW_FORM_ref8: {
+ ULong u64 = get_ULong(c);
+ UWord res = cc->cu_start_offset + (UWord)u64;
+ *cts = (ULong)res;
+ *ctsSzB = sizeof(UWord);
+ TRACE_D3("<%lx>", res);
+ break;
+ }
+ case DW_FORM_ref_udata: {
+ ULong u64 = get_ULEB128(c);
+ UWord res = cc->cu_start_offset + (UWord)u64;
+ *cts = (ULong)res;
+ *ctsSzB = sizeof(UWord);
+ TRACE_D3("<%lx>", res);
+ break;
+ }
case DW_FORM_flag: {
UChar u8 = get_UChar(c);
TRACE_D3("%u", (UInt)u8);
*ctsSzB = 1;
break;
}
+ case DW_FORM_flag_present:
+ TRACE_D3("1");
+ *cts = 1;
+ *ctsSzB = 1;
+ break;
case DW_FORM_block1: {
ULong u64b;
ULong u64 = (ULong)get_UChar(c);
*ctsMemSzB = (UWord)u64;
break;
}
+ case DW_FORM_block4: {
+ ULong u64b;
+ ULong u64 = (ULong)get_UInt(c);
+ UChar* block = get_address_of_Cursor(c);
+ TRACE_D3("%llu byte block: ", u64);
+ for (u64b = u64; u64b > 0; u64b--) {
+ UChar u8 = get_UChar(c);
+ TRACE_D3("%x ", (UInt)u8);
+ }
+ *cts = (ULong)(UWord)block;
+ *ctsMemSzB = (UWord)u64;
+ break;
+ }
+ case DW_FORM_exprloc:
+ case DW_FORM_block: {
+ ULong u64b;
+ ULong u64 = (ULong)get_ULEB128(c);
+ UChar* block = get_address_of_Cursor(c);
+ TRACE_D3("%llu byte block: ", u64);
+ for (u64b = u64; u64b > 0; u64b--) {
+ UChar u8 = get_UChar(c);
+ TRACE_D3("%x ", (UInt)u8);
+ }
+ *cts = (ULong)(UWord)block;
+ *ctsMemSzB = (UWord)u64;
+ break;
+ }
+ case DW_FORM_ref_sig8: {
+ ULong u64b;
+ UChar* block = get_address_of_Cursor(c);
+ TRACE_D3("8 byte signature: ");
+ for (u64b = 8; u64b > 0; u64b--) {
+ UChar u8 = get_UChar(c);
+ TRACE_D3("%x ", (UInt)u8);
+ }
+ *cts = (ULong)(UWord)block;
+ *ctsMemSzB = 8;
+ break;
+ }
+ case DW_FORM_indirect:
+ get_Form_contents (cts, ctsSzB, ctsMemSzB, cc, c, td3,
+ (DW_FORM)get_ULEB128(c));
+ return;
+
default:
VG_(printf)(
"get_Form_contents: unhandled %d (%s) at <%lx>\n",
get_Initial_Length( &is_dw64, &c,
"read_filename_table: invalid initial-length field" );
version = get_UShort( &c );
- if (version != 2 && version != 3)
- cc->barf("read_filename_table: Only DWARF version 2 and 3 line info "
+ if (version != 2 && version != 3 && version != 4)
+ cc->barf("read_filename_table: Only DWARF version 2, 3 and 4 line info "
"is currently supported.");
/*header_length = (ULong)*/ get_Dwarfish_UWord( &c, is_dw64 );
/*minimum_instruction_length = */ get_UChar( &c );
+ if (version >= 4)
+ /*maximum_operations_per_insn = */ get_UChar( &c );
/*default_is_stmt = */ get_UChar( &c );
/*line_base = (Char)*/ get_UChar( &c );
/*line_range = */ get_UChar( &c );
case DW_LANG_C89: case DW_LANG_C:
case DW_LANG_C_plus_plus: case DW_LANG_ObjC:
case DW_LANG_ObjC_plus_plus: case DW_LANG_UPC:
- case DW_LANG_Upc:
+ case DW_LANG_Upc: case DW_LANG_C99:
parser->language = 'C'; break;
case DW_LANG_Fortran77: case DW_LANG_Fortran90:
case DW_LANG_Fortran95:
case DW_LANG_Ada83: case DW_LANG_Cobol74:
case DW_LANG_Cobol85: case DW_LANG_Pascal83:
case DW_LANG_Modula2: case DW_LANG_Java:
- case DW_LANG_C99: case DW_LANG_Ada95:
- case DW_LANG_PLI: case DW_LANG_D:
+ case DW_LANG_Ada95: case DW_LANG_PLI:
+ case DW_LANG_D: case DW_LANG_Python:
case DW_LANG_Mips_Assembler:
parser->language = '?'; break;
default: