From: Julian Seward Date: Tue, 18 Jun 2002 01:04:57 +0000 (+0000) Subject: - Check DWARF2 reader against spec. Add some clarifications and X-Git-Tag: svn/VALGRIND_1_0_3~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54661408ffbb61dc3806b561f1b8986a7a37c25e;p=thirdparty%2Fvalgrind.git - Check DWARF2 reader against spec. Add some clarifications and fix a minor error, but basically no significant changes. - Disable debug info printing entirely in addLineInfo. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@433 --- diff --git a/coregrind/vg_symtab2.c b/coregrind/vg_symtab2.c index fb40bdf575..8330794ee3 100644 --- a/coregrind/vg_symtab2.c +++ b/coregrind/vg_symtab2.c @@ -272,22 +272,16 @@ void addLineInfo ( SegInfo* si, } if (size > MAX_LOC_SIZE) { + if (0) VG_(message)(Vg_DebugMsg, "warning: line info address range too large " "at entry %d: %d", entry, size); size = 1; } - -#if 0 - if (this >= 0 && this < 1000) { - this += si->start; - next += si->start; - } -#endif - /* vg_assert(this < si->start + si->size && next-1 >= si->start); */ if (this >= si->start + si->size || next-1 < si->start) { + if (0) VG_(message)(Vg_DebugMsg, "warning: ignoring line info entry falling " "outside current SegInfo: %p %p %p %p", @@ -857,6 +851,7 @@ typedef struct UChar li_opcode_base [1]; } DWARF2_External_LineInfo; + typedef struct { UInt li_length; @@ -869,6 +864,7 @@ typedef struct UChar li_opcode_base; } DWARF2_Internal_LineInfo; + /* Line number opcodes. */ enum dwarf_line_number_ops { @@ -988,6 +984,9 @@ int process_extended_line_op( SegInfo *si, UInt** fnames, case DW_LNE_end_sequence: if (0) VG_(printf)("1001: si->o %p, smr.a %p\n", si->offset, state_machine_regs.address ); + state_machine_regs.end_sequence = 1; /* JRS: added for compliance + with spec; is pointless due to reset_state_machine below + */ addLineInfo (si, (*fnames)[state_machine_regs.file], si->offset + (state_machine_regs.address - 1), si->offset + (state_machine_regs.address), @@ -1041,6 +1040,10 @@ void read_debuginfo_dwarf2 ( SegInfo* si, UChar* dwarf2, Int dwarf2_sz ) UChar * end_of_sequence; UInt * fnames = NULL; + /* Fails due to gcc padding ... + vg_assert(sizeof(DWARF2_External_LineInfo) + == sizeof(DWARF2_Internal_LineInfo)); + */ while (data < end) { @@ -1071,12 +1074,15 @@ void read_debuginfo_dwarf2 ( SegInfo* si, UChar* dwarf2, Int dwarf2_sz ) return; } - info.li_prologue_length = *((UInt *)(external->li_prologue_length)); - info.li_min_insn_length = *((UChar *) (external->li_min_insn_length)); - info.li_default_is_stmt = *((UChar *) (external->li_default_is_stmt)); - info.li_line_base = *((Int *) (external->li_line_base)); - info.li_line_range = *((UChar *) (external->li_line_range)); - info.li_opcode_base = *((UChar *) (external->li_opcode_base)); + info.li_prologue_length = * ((UInt *) (external->li_prologue_length)); + info.li_min_insn_length = * ((UChar *)(external->li_min_insn_length)); + info.li_default_is_stmt = * ((UChar *)(external->li_default_is_stmt)); + + /* JRS: changed (UInt*) to (UChar*) */ + info.li_line_base = * ((UChar *)(external->li_line_base)); + + info.li_line_range = * ((UChar *)(external->li_line_range)); + info.li_opcode_base = * ((UChar *)(external->li_opcode_base)); /* Sign extend the line base field. */ info.li_line_base <<= 24; @@ -1107,6 +1113,10 @@ void read_debuginfo_dwarf2 ( SegInfo* si, UChar* dwarf2, Int dwarf2_sz ) } /* Skip the NUL at the end of the table. */ + if (*data != 0) { + vg_symerr("can't find NUL at end of DWARF2 directory table"); + return; + } data ++; /* Read the contents of the File Name table. */ @@ -1144,6 +1154,10 @@ void read_debuginfo_dwarf2 ( SegInfo* si, UChar* dwarf2, Int dwarf2_sz ) } /* Skip the NUL at the end of the table. */ + if (*data != 0) { + vg_symerr("can't find NUL at end of DWARF2 file name table"); + return; + } data ++; /* Now display the statements. */ @@ -1190,6 +1204,7 @@ void read_debuginfo_dwarf2 ( SegInfo* si, UChar* dwarf2, Int dwarf2_sz ) si->offset + state_machine_regs.address, si->offset + (state_machine_regs.address + 1), state_machine_regs.line , 0); + state_machine_regs.basic_block = 0; /* JRS added */ break; case DW_LNS_advance_pc: diff --git a/vg_symtab2.c b/vg_symtab2.c index fb40bdf575..8330794ee3 100644 --- a/vg_symtab2.c +++ b/vg_symtab2.c @@ -272,22 +272,16 @@ void addLineInfo ( SegInfo* si, } if (size > MAX_LOC_SIZE) { + if (0) VG_(message)(Vg_DebugMsg, "warning: line info address range too large " "at entry %d: %d", entry, size); size = 1; } - -#if 0 - if (this >= 0 && this < 1000) { - this += si->start; - next += si->start; - } -#endif - /* vg_assert(this < si->start + si->size && next-1 >= si->start); */ if (this >= si->start + si->size || next-1 < si->start) { + if (0) VG_(message)(Vg_DebugMsg, "warning: ignoring line info entry falling " "outside current SegInfo: %p %p %p %p", @@ -857,6 +851,7 @@ typedef struct UChar li_opcode_base [1]; } DWARF2_External_LineInfo; + typedef struct { UInt li_length; @@ -869,6 +864,7 @@ typedef struct UChar li_opcode_base; } DWARF2_Internal_LineInfo; + /* Line number opcodes. */ enum dwarf_line_number_ops { @@ -988,6 +984,9 @@ int process_extended_line_op( SegInfo *si, UInt** fnames, case DW_LNE_end_sequence: if (0) VG_(printf)("1001: si->o %p, smr.a %p\n", si->offset, state_machine_regs.address ); + state_machine_regs.end_sequence = 1; /* JRS: added for compliance + with spec; is pointless due to reset_state_machine below + */ addLineInfo (si, (*fnames)[state_machine_regs.file], si->offset + (state_machine_regs.address - 1), si->offset + (state_machine_regs.address), @@ -1041,6 +1040,10 @@ void read_debuginfo_dwarf2 ( SegInfo* si, UChar* dwarf2, Int dwarf2_sz ) UChar * end_of_sequence; UInt * fnames = NULL; + /* Fails due to gcc padding ... + vg_assert(sizeof(DWARF2_External_LineInfo) + == sizeof(DWARF2_Internal_LineInfo)); + */ while (data < end) { @@ -1071,12 +1074,15 @@ void read_debuginfo_dwarf2 ( SegInfo* si, UChar* dwarf2, Int dwarf2_sz ) return; } - info.li_prologue_length = *((UInt *)(external->li_prologue_length)); - info.li_min_insn_length = *((UChar *) (external->li_min_insn_length)); - info.li_default_is_stmt = *((UChar *) (external->li_default_is_stmt)); - info.li_line_base = *((Int *) (external->li_line_base)); - info.li_line_range = *((UChar *) (external->li_line_range)); - info.li_opcode_base = *((UChar *) (external->li_opcode_base)); + info.li_prologue_length = * ((UInt *) (external->li_prologue_length)); + info.li_min_insn_length = * ((UChar *)(external->li_min_insn_length)); + info.li_default_is_stmt = * ((UChar *)(external->li_default_is_stmt)); + + /* JRS: changed (UInt*) to (UChar*) */ + info.li_line_base = * ((UChar *)(external->li_line_base)); + + info.li_line_range = * ((UChar *)(external->li_line_range)); + info.li_opcode_base = * ((UChar *)(external->li_opcode_base)); /* Sign extend the line base field. */ info.li_line_base <<= 24; @@ -1107,6 +1113,10 @@ void read_debuginfo_dwarf2 ( SegInfo* si, UChar* dwarf2, Int dwarf2_sz ) } /* Skip the NUL at the end of the table. */ + if (*data != 0) { + vg_symerr("can't find NUL at end of DWARF2 directory table"); + return; + } data ++; /* Read the contents of the File Name table. */ @@ -1144,6 +1154,10 @@ void read_debuginfo_dwarf2 ( SegInfo* si, UChar* dwarf2, Int dwarf2_sz ) } /* Skip the NUL at the end of the table. */ + if (*data != 0) { + vg_symerr("can't find NUL at end of DWARF2 file name table"); + return; + } data ++; /* Now display the statements. */ @@ -1190,6 +1204,7 @@ void read_debuginfo_dwarf2 ( SegInfo* si, UChar* dwarf2, Int dwarf2_sz ) si->offset + state_machine_regs.address, si->offset + (state_machine_regs.address + 1), state_machine_regs.line , 0); + state_machine_regs.basic_block = 0; /* JRS added */ break; case DW_LNS_advance_pc: