mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2024-12-23 05:25:39 +00:00
Breakpad DWARF parser: Add method to read DWARF "Initial length".
This patch moves the ReadInitialFunction from dwarf2reader.cc, where it was a static function, to being a member function of google_breakpad::ByteReader. a=jimblandy, r=nealsid git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@504 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
03ebc1d245
commit
1ac84da26d
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2006 Google Inc. All Rights Reserved.
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
|
@ -60,4 +60,21 @@ void ByteReader::SetAddressSize(uint8 size) {
|
|||
}
|
||||
}
|
||||
|
||||
uint64 ByteReader::ReadInitialLength(const char* start, size_t* len) {
|
||||
const uint64 initial_length = ReadFourBytes(start);
|
||||
start += 4;
|
||||
|
||||
// In DWARF2/3, if the initial length is all 1 bits, then the offset
|
||||
// size is 8 and we need to read the next 8 bytes for the real length.
|
||||
if (initial_length == 0xffffffff) {
|
||||
SetOffsetSize(8);
|
||||
*len = 12;
|
||||
return ReadOffset(start);
|
||||
} else {
|
||||
SetOffsetSize(4);
|
||||
*len = 4;
|
||||
}
|
||||
return initial_length;
|
||||
}
|
||||
|
||||
} // namespace dwarf2reader
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// Copyright 2006 Google Inc. All Rights Reserved.
|
||||
// -*- mode: C++ -*-
|
||||
|
||||
// Copyright 2010 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
|
@ -104,6 +106,12 @@ class ByteReader {
|
|||
// and will CHECK on anything else.
|
||||
uint64 ReadAddress(const char* buffer) const;
|
||||
|
||||
// Read a DWARF2/3 initial length field from START, and report the
|
||||
// length of the length field in LEN. Return the value of the length
|
||||
// field. Set this reader's offset size as indicated by the length
|
||||
// field's encoding.
|
||||
uint64 ReadInitialLength(const char* start, size_t* len);
|
||||
|
||||
private:
|
||||
|
||||
// Function pointer type for our address and offset readers.
|
||||
|
|
|
@ -40,27 +40,6 @@
|
|||
|
||||
namespace dwarf2reader {
|
||||
|
||||
// Read a DWARF2/3 initial length field from START, using READER, and
|
||||
// report the length in LEN. Return the actual initial length.
|
||||
|
||||
static uint64 ReadInitialLength(const char* start,
|
||||
ByteReader* reader, size_t* len) {
|
||||
const uint64 initial_length = reader->ReadFourBytes(start);
|
||||
start += 4;
|
||||
|
||||
// In DWARF2/3, if the initial length is all 1 bits, then the offset
|
||||
// size is 8 and we need to read the next 8 bytes for the real length.
|
||||
if (initial_length == 0xffffffff) {
|
||||
reader->SetOffsetSize(8);
|
||||
*len = 12;
|
||||
return reader->ReadOffset(start);
|
||||
} else {
|
||||
reader->SetOffsetSize(4);
|
||||
*len = 4;
|
||||
}
|
||||
return initial_length;
|
||||
}
|
||||
|
||||
CompilationUnit::CompilationUnit(const SectionMap& sections, uint64 offset,
|
||||
ByteReader* reader, Dwarf2Handler* handler)
|
||||
: offset_from_section_start_(offset), reader_(reader),
|
||||
|
@ -243,8 +222,8 @@ void CompilationUnit::ReadHeader() {
|
|||
size_t initial_length_size;
|
||||
|
||||
assert(headerptr + 4 < buffer_ + buffer_length_);
|
||||
const uint64 initial_length = ReadInitialLength(headerptr, reader_,
|
||||
&initial_length_size);
|
||||
const uint64 initial_length
|
||||
= reader_->ReadInitialLength(headerptr, &initial_length_size);
|
||||
headerptr += initial_length_size;
|
||||
header_.length = initial_length;
|
||||
|
||||
|
@ -563,8 +542,8 @@ void LineInfo::ReadHeader() {
|
|||
const char* lineptr = buffer_;
|
||||
size_t initial_length_size;
|
||||
|
||||
const uint64 initial_length = ReadInitialLength(lineptr, reader_,
|
||||
&initial_length_size);
|
||||
const uint64 initial_length
|
||||
= reader_->ReadInitialLength(lineptr, &initial_length_size);
|
||||
|
||||
lineptr += initial_length_size;
|
||||
header_.total_length = initial_length;
|
||||
|
|
Loading…
Reference in a new issue