Revert "Add dwarf5 compilation-unit header handling."

This reverts commit dbd454dbe4.

Reason for revert: The parent CL is causing breakage on CrOS due to
unhandled enums.  Before we can revert that, we need to revert this.

Bug: google-breakpad:812
Change-Id: I7c2446f3cd8ed9f6411e90dbdd2434bc463b2f6c
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2095798
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Mike Frysinger 2020-03-09 23:59:12 +00:00
parent 52b33b2a4b
commit fea1913f29
5 changed files with 18 additions and 105 deletions

View File

@ -686,7 +686,7 @@ enum DwarfLanguage
DW_LANG_ObjC_plus_plus =0x0011, DW_LANG_ObjC_plus_plus =0x0011,
DW_LANG_UPC =0x0012, DW_LANG_UPC =0x0012,
DW_LANG_D =0x0013, DW_LANG_D =0x0013,
DW_LANG_Python =0x0014, DW_LANG__Python =0x0014,
DW_LANG_OpenCL =0x0015, DW_LANG_OpenCL =0x0015,
DW_LANG_Go =0x0016, DW_LANG_Go =0x0016,
DW_LANG_Modula3 =0x0017, DW_LANG_Modula3 =0x0017,

View File

@ -243,51 +243,11 @@ const uint8_t *CompilationUnit::SkipAttribute(const uint8_t *start,
return NULL; return NULL;
} }
// Read the abbreviation offset from a compilation unit header. // Read a DWARF2/3 header.
int CompilationUnit::ReadAbbrevOffset(const uint8_t *headerptr) { // The header is variable length in DWARF3 (and DWARF2 as extended by
assert(headerptr + reader_->OffsetSize() < buffer_ + buffer_length_);
header_.abbrev_offset = reader_->ReadOffset(headerptr);
return reader_->OffsetSize();
}
// Read the address size from a compilation unit header.
int CompilationUnit::ReadAddressSize(const uint8_t *headerptr) {
// Compare against less than or equal because this may be the last
// section in the file.
assert(headerptr + 1 <= buffer_ + buffer_length_);
header_.address_size = reader_->ReadOneByte(headerptr);
reader_->SetAddressSize(header_.address_size);
return 1;
}
// Read the DWO id from a split or skeleton compilation unit header.
int CompilationUnit::ReadDwoId(const uint8_t *headerptr) {
assert(headerptr + 8 <= buffer_ + buffer_length_);
dwo_id_ = reader_->ReadEightBytes(headerptr);
return 8;
}
// Read the type signature from a type or split type compilation unit header.
int CompilationUnit::ReadTypeSignature(const uint8_t *headerptr) {
assert(headerptr + 8 <= buffer_ + buffer_length_);
type_signature_ = reader_->ReadEightBytes(headerptr);
return 8;
}
// Read the DWO id from a split or skeleton compilation unit header.
int CompilationUnit::ReadTypeOffset(const uint8_t *headerptr) {
assert(headerptr + reader_->OffsetSize() < buffer_ + buffer_length_);
type_offset_ = reader_->ReadOffset(headerptr);
return reader_->OffsetSize();
}
// Read a DWARF header.
// The header is variable length in DWARF3 and DWARF4 (and DWARF2 as extended by
// most compilers), and consists of an length field, a version number, // most compilers), and consists of an length field, a version number,
// the offset in the .debug_abbrev section for our abbrevs, and an // the offset in the .debug_abbrev section for our abbrevs, and an
// address size. DWARF5 adds a unit_type to distinguish between // address size.
// partial-, full-, skeleton-, split-, and type- compilation units.
void CompilationUnit::ReadHeader() { void CompilationUnit::ReadHeader() {
const uint8_t *headerptr = buffer_; const uint8_t *headerptr = buffer_;
size_t initial_length_size; size_t initial_length_size;
@ -302,33 +262,17 @@ void CompilationUnit::ReadHeader() {
header_.version = reader_->ReadTwoBytes(headerptr); header_.version = reader_->ReadTwoBytes(headerptr);
headerptr += 2; headerptr += 2;
if (header_.version <= 4) { assert(headerptr + reader_->OffsetSize() < buffer_ + buffer_length_);
// Older versions of dwarf have a relatively simple structure. header_.abbrev_offset = reader_->ReadOffset(headerptr);
headerptr += ReadAbbrevOffset(headerptr); headerptr += reader_->OffsetSize();
headerptr += ReadAddressSize(headerptr);
} else { // Compare against less than or equal because this may be the last
// DWARF5 adds a unit_type field, and various fields based on unit_type. // section in the file.
assert(headerptr + 1 < buffer_ + buffer_length_); assert(headerptr + 1 <= buffer_ + buffer_length_);
int unit_type = reader_->ReadOneByte(headerptr); header_.address_size = reader_->ReadOneByte(headerptr);
reader_->SetAddressSize(header_.address_size);
headerptr += 1; headerptr += 1;
headerptr += ReadAddressSize(headerptr);
headerptr += ReadAbbrevOffset(headerptr);
switch (unit_type) {
case DW_UT_compile:
case DW_UT_partial:
// nothing else to read
break;
case DW_UT_skeleton:
case DW_UT_split_compile:
headerptr += ReadDwoId(headerptr);;
break;
case DW_UT_type:
case DW_UT_split_type:
headerptr += ReadTypeSignature(headerptr);;
headerptr += ReadTypeOffset(headerptr);;
break;
}
}
after_header_ = headerptr; after_header_ = headerptr;
// This check ensures that we don't have to do checking during the // This check ensures that we don't have to do checking during the

View File

@ -410,21 +410,6 @@ class CompilationUnit {
// Reads the DWARF2/3 abbreviations for this compilation unit // Reads the DWARF2/3 abbreviations for this compilation unit
void ReadAbbrevs(); void ReadAbbrevs();
// Read the abbreviation offset for this compilation unit
int ReadAbbrevOffset(const uint8_t *headerptr);
// Read the address size for this compilation unit
int ReadAddressSize(const uint8_t *headerptr);
// Read the DWO id from a split or skeleton compilation unit header
int ReadDwoId(const uint8_t *headerptr);
// Read the type signature from a type or split type compilation unit header
int ReadTypeSignature(const uint8_t *headerptr);
// Read the DWO id from a split or skeleton compilation unit header
int ReadTypeOffset(const uint8_t *headerptr);
// Processes a single DIE for this compilation unit and return a new // Processes a single DIE for this compilation unit and return a new
// pointer just past the end of it // pointer just past the end of it
const uint8_t *ProcessDIE(uint64 dieoffset, const uint8_t *ProcessDIE(uint64 dieoffset,
@ -579,12 +564,6 @@ class CompilationUnit {
// The value of the DW_AT_GNU_dwo_id attribute, if any. // The value of the DW_AT_GNU_dwo_id attribute, if any.
uint64 dwo_id_; uint64 dwo_id_;
// The value of the DW_AT_GNU_type_signature attribute, if any.
uint64 type_signature_;
// The value of the DW_AT_GNU_type_offset attribute, if any.
size_t type_offset_;
// The value of the DW_AT_GNU_dwo_name attribute, if any. // The value of the DW_AT_GNU_dwo_name attribute, if any.
const char* dwo_name_; const char* dwo_name_;

View File

@ -217,8 +217,6 @@ INSTANTIATE_TEST_CASE_P(
DwarfHeaderParams(kLittleEndian, 8, 3, 8), DwarfHeaderParams(kLittleEndian, 8, 3, 8),
DwarfHeaderParams(kLittleEndian, 8, 4, 4), DwarfHeaderParams(kLittleEndian, 8, 4, 4),
DwarfHeaderParams(kLittleEndian, 8, 4, 8), DwarfHeaderParams(kLittleEndian, 8, 4, 8),
DwarfHeaderParams(kLittleEndian, 8, 5, 4),
DwarfHeaderParams(kLittleEndian, 8, 5, 8),
DwarfHeaderParams(kBigEndian, 4, 2, 4), DwarfHeaderParams(kBigEndian, 4, 2, 4),
DwarfHeaderParams(kBigEndian, 4, 2, 8), DwarfHeaderParams(kBigEndian, 4, 2, 8),
DwarfHeaderParams(kBigEndian, 4, 3, 4), DwarfHeaderParams(kBigEndian, 4, 3, 4),
@ -230,9 +228,7 @@ INSTANTIATE_TEST_CASE_P(
DwarfHeaderParams(kBigEndian, 8, 3, 4), DwarfHeaderParams(kBigEndian, 8, 3, 4),
DwarfHeaderParams(kBigEndian, 8, 3, 8), DwarfHeaderParams(kBigEndian, 8, 3, 8),
DwarfHeaderParams(kBigEndian, 8, 4, 4), DwarfHeaderParams(kBigEndian, 8, 4, 4),
DwarfHeaderParams(kBigEndian, 8, 4, 8), DwarfHeaderParams(kBigEndian, 8, 4, 8)));
DwarfHeaderParams(kBigEndian, 8, 5, 4),
DwarfHeaderParams(kBigEndian, 8, 5, 8)));
struct DwarfFormsFixture: public DIEFixture { struct DwarfFormsFixture: public DIEFixture {
// Start a compilation unit, as directed by |params|, containing one // Start a compilation unit, as directed by |params|, containing one

View File

@ -80,14 +80,8 @@ class TestCompilationUnit: public google_breakpad::test_assembler::Section {
} }
post_length_offset_ = Size(); post_length_offset_ = Size();
D16(version); D16(version);
if (version <= 4) {
SectionOffset(abbrev_offset); SectionOffset(abbrev_offset);
D8(address_size); D8(address_size);
} else {
D8(0x01); // DW_UT_compile
D8(address_size);
SectionOffset(abbrev_offset);
}
return *this; return *this;
} }