mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-03-11 23:46:32 +00:00
fix pointer style to match the style guide
We do this in a lot of places, but we're inconsistent. Normalize the code to the Google C++ style guide. Change-Id: Ic2aceab661ce8f6b993dda21b1cdf5d2198dcbbf Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2262932 Reviewed-by: Sterling Augustine <saugustine@google.com> Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
@@ -36,11 +36,11 @@
|
||||
|
||||
namespace dwarf2reader {
|
||||
|
||||
inline uint8_t ByteReader::ReadOneByte(const uint8_t *buffer) const {
|
||||
inline uint8_t ByteReader::ReadOneByte(const uint8_t* buffer) const {
|
||||
return buffer[0];
|
||||
}
|
||||
|
||||
inline uint16_t ByteReader::ReadTwoBytes(const uint8_t *buffer) const {
|
||||
inline uint16_t ByteReader::ReadTwoBytes(const uint8_t* buffer) const {
|
||||
const uint16_t buffer0 = buffer[0];
|
||||
const uint16_t buffer1 = buffer[1];
|
||||
if (endian_ == ENDIANNESS_LITTLE) {
|
||||
@@ -61,7 +61,7 @@ inline uint64_t ByteReader::ReadThreeBytes(const uint8_t* buffer) const {
|
||||
}
|
||||
}
|
||||
|
||||
inline uint64_t ByteReader::ReadFourBytes(const uint8_t *buffer) const {
|
||||
inline uint64_t ByteReader::ReadFourBytes(const uint8_t* buffer) const {
|
||||
const uint32_t buffer0 = buffer[0];
|
||||
const uint32_t buffer1 = buffer[1];
|
||||
const uint32_t buffer2 = buffer[2];
|
||||
@@ -73,7 +73,7 @@ inline uint64_t ByteReader::ReadFourBytes(const uint8_t *buffer) const {
|
||||
}
|
||||
}
|
||||
|
||||
inline uint64_t ByteReader::ReadEightBytes(const uint8_t *buffer) const {
|
||||
inline uint64_t ByteReader::ReadEightBytes(const uint8_t* buffer) const {
|
||||
const uint64_t buffer0 = buffer[0];
|
||||
const uint64_t buffer1 = buffer[1];
|
||||
const uint64_t buffer2 = buffer[2];
|
||||
@@ -95,7 +95,7 @@ inline uint64_t ByteReader::ReadEightBytes(const uint8_t *buffer) const {
|
||||
// information, plus one bit saying whether the number continues or
|
||||
// not.
|
||||
|
||||
inline uint64_t ByteReader::ReadUnsignedLEB128(const uint8_t *buffer,
|
||||
inline uint64_t ByteReader::ReadUnsignedLEB128(const uint8_t* buffer,
|
||||
size_t* len) const {
|
||||
uint64_t result = 0;
|
||||
size_t num_read = 0;
|
||||
@@ -120,7 +120,7 @@ inline uint64_t ByteReader::ReadUnsignedLEB128(const uint8_t *buffer,
|
||||
// Read a signed LEB128 number. These are like regular LEB128
|
||||
// numbers, except the last byte may have a sign bit set.
|
||||
|
||||
inline int64_t ByteReader::ReadSignedLEB128(const uint8_t *buffer,
|
||||
inline int64_t ByteReader::ReadSignedLEB128(const uint8_t* buffer,
|
||||
size_t* len) const {
|
||||
int64_t result = 0;
|
||||
unsigned int shift = 0;
|
||||
@@ -140,18 +140,18 @@ inline int64_t ByteReader::ReadSignedLEB128(const uint8_t *buffer,
|
||||
return result;
|
||||
}
|
||||
|
||||
inline uint64_t ByteReader::ReadOffset(const uint8_t *buffer) const {
|
||||
inline uint64_t ByteReader::ReadOffset(const uint8_t* buffer) const {
|
||||
assert(this->offset_reader_);
|
||||
return (this->*offset_reader_)(buffer);
|
||||
}
|
||||
|
||||
inline uint64_t ByteReader::ReadAddress(const uint8_t *buffer) const {
|
||||
inline uint64_t ByteReader::ReadAddress(const uint8_t* buffer) const {
|
||||
assert(this->address_reader_);
|
||||
return (this->*address_reader_)(buffer);
|
||||
}
|
||||
|
||||
inline void ByteReader::SetCFIDataBase(uint64_t section_base,
|
||||
const uint8_t *buffer_base) {
|
||||
const uint8_t* buffer_base) {
|
||||
section_base_ = section_base;
|
||||
buffer_base_ = buffer_base;
|
||||
have_section_base_ = true;
|
||||
|
||||
@@ -63,7 +63,7 @@ void ByteReader::SetAddressSize(uint8_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t ByteReader::ReadInitialLength(const uint8_t *start, size_t* len) {
|
||||
uint64_t ByteReader::ReadInitialLength(const uint8_t* start, size_t* len) {
|
||||
const uint64_t initial_length = ReadFourBytes(start);
|
||||
start += 4;
|
||||
|
||||
@@ -101,9 +101,9 @@ bool ByteReader::UsableEncoding(DwarfPointerEncoding encoding) const {
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t ByteReader::ReadEncodedPointer(const uint8_t *buffer,
|
||||
uint64_t ByteReader::ReadEncodedPointer(const uint8_t* buffer,
|
||||
DwarfPointerEncoding encoding,
|
||||
size_t *len) const {
|
||||
size_t* len) const {
|
||||
// UsableEncoding doesn't approve of DW_EH_PE_omit, so we shouldn't
|
||||
// see it here.
|
||||
assert(encoding != DW_EH_PE_omit);
|
||||
@@ -130,7 +130,7 @@ uint64_t ByteReader::ReadEncodedPointer(const uint8_t *buffer,
|
||||
// Round up to the next boundary.
|
||||
uint64_t aligned = (offset + AddressSize() - 1) & -AddressSize();
|
||||
// Convert back to a pointer.
|
||||
const uint8_t *aligned_buffer = buffer_base_ + (aligned - skew);
|
||||
const uint8_t* aligned_buffer = buffer_base_ + (aligned - skew);
|
||||
// Finally, store the length and actually fetch the pointer.
|
||||
*len = aligned_buffer - buffer + AddressSize();
|
||||
return ReadAddress(aligned_buffer);
|
||||
|
||||
@@ -62,11 +62,11 @@ class ByteReader {
|
||||
|
||||
// Read a single byte from BUFFER and return it as an unsigned 8 bit
|
||||
// number.
|
||||
uint8_t ReadOneByte(const uint8_t *buffer) const;
|
||||
uint8_t ReadOneByte(const uint8_t* buffer) const;
|
||||
|
||||
// Read two bytes from BUFFER and return them as an unsigned 16 bit
|
||||
// number, using this ByteReader's endianness.
|
||||
uint16_t ReadTwoBytes(const uint8_t *buffer) const;
|
||||
uint16_t ReadTwoBytes(const uint8_t* buffer) const;
|
||||
|
||||
// Read three bytes from BUFFER and return them as an unsigned 64 bit
|
||||
// number, using this ByteReader's endianness. DWARF 5 uses this encoding
|
||||
@@ -78,11 +78,11 @@ class ByteReader {
|
||||
// a uint64_t so that it is compatible with ReadAddress and
|
||||
// ReadOffset. The number it returns will never be outside the range
|
||||
// of an unsigned 32 bit integer.
|
||||
uint64_t ReadFourBytes(const uint8_t *buffer) const;
|
||||
uint64_t ReadFourBytes(const uint8_t* buffer) const;
|
||||
|
||||
// Read eight bytes from BUFFER and return them as an unsigned 64
|
||||
// bit number, using this ByteReader's endianness.
|
||||
uint64_t ReadEightBytes(const uint8_t *buffer) const;
|
||||
uint64_t ReadEightBytes(const uint8_t* buffer) const;
|
||||
|
||||
// Read an unsigned LEB128 (Little Endian Base 128) number from
|
||||
// BUFFER and return it as an unsigned 64 bit integer. Set LEN to
|
||||
@@ -101,7 +101,7 @@ class ByteReader {
|
||||
// In other words, we break VALUE into groups of seven bits, put
|
||||
// them in little-endian order, and then write them as eight-bit
|
||||
// bytes with the high bit on all but the last.
|
||||
uint64_t ReadUnsignedLEB128(const uint8_t *buffer, size_t *len) const;
|
||||
uint64_t ReadUnsignedLEB128(const uint8_t* buffer, size_t* len) const;
|
||||
|
||||
// Read a signed LEB128 number from BUFFER and return it as an
|
||||
// signed 64 bit integer. Set LEN to the number of bytes read.
|
||||
@@ -120,7 +120,7 @@ class ByteReader {
|
||||
// In other words, we break VALUE into groups of seven bits, put
|
||||
// them in little-endian order, and then write them as eight-bit
|
||||
// bytes with the high bit on all but the last.
|
||||
int64_t ReadSignedLEB128(const uint8_t *buffer, size_t *len) const;
|
||||
int64_t ReadSignedLEB128(const uint8_t* buffer, size_t* len) const;
|
||||
|
||||
// Indicate that addresses on this architecture are SIZE bytes long. SIZE
|
||||
// must be either 4 or 8. (DWARF allows addresses to be any number of
|
||||
@@ -143,7 +143,7 @@ class ByteReader {
|
||||
// Read an address from BUFFER and return it as an unsigned 64 bit
|
||||
// integer, respecting this ByteReader's endianness and address size. You
|
||||
// must call SetAddressSize before calling this function.
|
||||
uint64_t ReadAddress(const uint8_t *buffer) const;
|
||||
uint64_t ReadAddress(const uint8_t* buffer) const;
|
||||
|
||||
// DWARF actually defines two slightly different formats: 32-bit DWARF
|
||||
// and 64-bit DWARF. This is *not* related to the size of registers or
|
||||
@@ -180,14 +180,14 @@ class ByteReader {
|
||||
// - The 32-bit value 0xffffffff, followed by a 64-bit byte count,
|
||||
// indicating that the data whose length is being measured uses
|
||||
// the 64-bit DWARF format.
|
||||
uint64_t ReadInitialLength(const uint8_t *start, size_t *len);
|
||||
uint64_t ReadInitialLength(const uint8_t* start, size_t* len);
|
||||
|
||||
// Read an offset from BUFFER and return it as an unsigned 64 bit
|
||||
// integer, respecting the ByteReader's endianness. In 32-bit DWARF, the
|
||||
// offset is 4 bytes long; in 64-bit DWARF, the offset is eight bytes
|
||||
// long. You must call ReadInitialLength or SetOffsetSize before calling
|
||||
// this function; see the comments above for details.
|
||||
uint64_t ReadOffset(const uint8_t *buffer) const;
|
||||
uint64_t ReadOffset(const uint8_t* buffer) const;
|
||||
|
||||
// Return the current offset size, in bytes.
|
||||
// A return value of 4 indicates that we are reading 32-bit DWARF.
|
||||
@@ -242,7 +242,7 @@ class ByteReader {
|
||||
// is BUFFER_BASE. This allows us to find the address that a given
|
||||
// byte in our buffer would have when loaded into the program the
|
||||
// data describes. We need this to resolve DW_EH_PE_pcrel pointers.
|
||||
void SetCFIDataBase(uint64_t section_base, const uint8_t *buffer_base);
|
||||
void SetCFIDataBase(uint64_t section_base, const uint8_t* buffer_base);
|
||||
|
||||
// Indicate that the base address of the program's ".text" section
|
||||
// is TEXT_BASE. We need this to resolve DW_EH_PE_textrel pointers.
|
||||
@@ -281,15 +281,15 @@ class ByteReader {
|
||||
// base address this reader hasn't been given, so you should check
|
||||
// with ValidEncoding and UsableEncoding first if you would rather
|
||||
// die in a more helpful way.
|
||||
uint64_t ReadEncodedPointer(const uint8_t *buffer,
|
||||
uint64_t ReadEncodedPointer(const uint8_t* buffer,
|
||||
DwarfPointerEncoding encoding,
|
||||
size_t *len) const;
|
||||
size_t* len) const;
|
||||
|
||||
Endianness GetEndianness() const;
|
||||
private:
|
||||
|
||||
// Function pointer type for our address and offset readers.
|
||||
typedef uint64_t (ByteReader::*AddressReader)(const uint8_t *) const;
|
||||
typedef uint64_t (ByteReader::*AddressReader)(const uint8_t*) const;
|
||||
|
||||
// Read an offset from BUFFER and return it as an unsigned 64 bit
|
||||
// integer. DWARF2/3 define offsets as either 4 or 8 bytes,
|
||||
@@ -312,7 +312,7 @@ class ByteReader {
|
||||
bool have_section_base_, have_text_base_, have_data_base_;
|
||||
bool have_function_base_;
|
||||
uint64_t section_base_, text_base_, data_base_, function_base_;
|
||||
const uint8_t *buffer_base_;
|
||||
const uint8_t* buffer_base_;
|
||||
};
|
||||
|
||||
} // namespace dwarf2reader
|
||||
|
||||
@@ -73,7 +73,7 @@ TEST_F(Reader, SimpleConstructor) {
|
||||
.LEB128(-0x4f337badf4483f83LL)
|
||||
.D32(0xfec319c9);
|
||||
ASSERT_TRUE(section.GetContents(&contents));
|
||||
const uint8_t *data = reinterpret_cast<const uint8_t *>(contents.data());
|
||||
const uint8_t* data = reinterpret_cast<const uint8_t*>(contents.data());
|
||||
EXPECT_EQ(0xc0U, reader.ReadOneByte(data));
|
||||
EXPECT_EQ(0xcf0dU, reader.ReadTwoBytes(data + 1));
|
||||
EXPECT_EQ(0x96fdd219U, reader.ReadFourBytes(data + 3));
|
||||
|
||||
@@ -41,11 +41,11 @@ namespace google_breakpad {
|
||||
|
||||
using dwarf2reader::DwarfPointerEncoding;
|
||||
|
||||
CFISection &CFISection::CIEHeader(uint64_t code_alignment_factor,
|
||||
CFISection& CFISection::CIEHeader(uint64_t code_alignment_factor,
|
||||
int data_alignment_factor,
|
||||
unsigned return_address_register,
|
||||
uint8_t version,
|
||||
const string &augmentation,
|
||||
const string& augmentation,
|
||||
bool dwarf64,
|
||||
uint8_t address_size,
|
||||
uint8_t segment_size) {
|
||||
@@ -78,7 +78,7 @@ CFISection &CFISection::CIEHeader(uint64_t code_alignment_factor,
|
||||
return *this;
|
||||
}
|
||||
|
||||
CFISection &CFISection::FDEHeader(Label cie_pointer,
|
||||
CFISection& CFISection::FDEHeader(Label cie_pointer,
|
||||
uint64_t initial_location,
|
||||
uint64_t address_range,
|
||||
bool dwarf64) {
|
||||
@@ -113,7 +113,7 @@ CFISection &CFISection::FDEHeader(Label cie_pointer,
|
||||
return *this;
|
||||
}
|
||||
|
||||
CFISection &CFISection::FinishEntry() {
|
||||
CFISection& CFISection::FinishEntry() {
|
||||
assert(entry_length_);
|
||||
Align(address_size_, dwarf2reader::DW_CFA_nop);
|
||||
entry_length_->length = Here() - entry_length_->start;
|
||||
@@ -123,9 +123,9 @@ CFISection &CFISection::FinishEntry() {
|
||||
return *this;
|
||||
}
|
||||
|
||||
CFISection &CFISection::EncodedPointer(uint64_t address,
|
||||
CFISection& CFISection::EncodedPointer(uint64_t address,
|
||||
DwarfPointerEncoding encoding,
|
||||
const EncodedPointerBases &bases) {
|
||||
const EncodedPointerBases& bases) {
|
||||
// Omitted data is extremely easy to emit.
|
||||
if (encoding == dwarf2reader::DW_EH_PE_omit)
|
||||
return *this;
|
||||
|
||||
@@ -120,7 +120,7 @@ class CFISection: public Section {
|
||||
// Use the addresses in BASES as the base addresses for encoded
|
||||
// pointers in subsequent calls to FDEHeader or EncodedPointer.
|
||||
// This function makes a copy of BASES.
|
||||
void SetEncodedPointerBases(const EncodedPointerBases &bases) {
|
||||
void SetEncodedPointerBases(const EncodedPointerBases& bases) {
|
||||
encoded_pointer_bases_ = bases;
|
||||
}
|
||||
|
||||
@@ -133,11 +133,11 @@ class CFISection: public Section {
|
||||
// Before calling this function, you will typically want to use Mark
|
||||
// or Here to make a label to pass to FDEHeader that refers to this
|
||||
// CIE's position in the section.
|
||||
CFISection &CIEHeader(uint64_t code_alignment_factor,
|
||||
CFISection& CIEHeader(uint64_t code_alignment_factor,
|
||||
int data_alignment_factor,
|
||||
unsigned return_address_register,
|
||||
uint8_t version = 3,
|
||||
const string &augmentation = "",
|
||||
const string& augmentation = "",
|
||||
bool dwarf64 = false,
|
||||
uint8_t address_size = 8,
|
||||
uint8_t segment_size = 0);
|
||||
@@ -152,7 +152,7 @@ class CFISection: public Section {
|
||||
// 0xffffff00 bytes. (The "initial length" is always a 32-bit
|
||||
// value.) Nor does it support .debug_frame sections longer than
|
||||
// 0xffffff00 bytes.
|
||||
CFISection &FDEHeader(Label cie_pointer,
|
||||
CFISection& FDEHeader(Label cie_pointer,
|
||||
uint64_t initial_location,
|
||||
uint64_t address_range,
|
||||
bool dwarf64 = false);
|
||||
@@ -161,11 +161,11 @@ class CFISection: public Section {
|
||||
// started, after padding with DW_CFA_nops for alignment. This
|
||||
// defines the label representing the entry's length, cited in the
|
||||
// entry's header. Return a reference to this section.
|
||||
CFISection &FinishEntry();
|
||||
CFISection& FinishEntry();
|
||||
|
||||
// Append the contents of BLOCK as a DW_FORM_block value: an
|
||||
// unsigned LEB128 length, followed by that many bytes of data.
|
||||
CFISection &Block(const string &block) {
|
||||
CFISection& Block(const string& block) {
|
||||
ULEB128(block.size());
|
||||
Append(block);
|
||||
return *this;
|
||||
@@ -173,11 +173,11 @@ class CFISection: public Section {
|
||||
|
||||
// Append ADDRESS to this section, in the appropriate size and
|
||||
// endianness. Return a reference to this section.
|
||||
CFISection &Address(uint64_t address) {
|
||||
CFISection& Address(uint64_t address) {
|
||||
Section::Append(endianness(), address_size_, address);
|
||||
return *this;
|
||||
}
|
||||
CFISection &Address(Label address) {
|
||||
CFISection& Address(Label address) {
|
||||
Section::Append(endianness(), address_size_, address);
|
||||
return *this;
|
||||
}
|
||||
@@ -191,26 +191,26 @@ class CFISection: public Section {
|
||||
//
|
||||
// (C++ doesn't let me use default arguments here, because I want to
|
||||
// refer to members of *this in the default argument expression.)
|
||||
CFISection &EncodedPointer(uint64_t address) {
|
||||
CFISection& EncodedPointer(uint64_t address) {
|
||||
return EncodedPointer(address, pointer_encoding_, encoded_pointer_bases_);
|
||||
}
|
||||
CFISection &EncodedPointer(uint64_t address, DwarfPointerEncoding encoding) {
|
||||
CFISection& EncodedPointer(uint64_t address, DwarfPointerEncoding encoding) {
|
||||
return EncodedPointer(address, encoding, encoded_pointer_bases_);
|
||||
}
|
||||
CFISection &EncodedPointer(uint64_t address, DwarfPointerEncoding encoding,
|
||||
const EncodedPointerBases &bases);
|
||||
CFISection& EncodedPointer(uint64_t address, DwarfPointerEncoding encoding,
|
||||
const EncodedPointerBases& bases);
|
||||
|
||||
// Restate some member functions, to keep chaining working nicely.
|
||||
CFISection &Mark(Label *label) { Section::Mark(label); return *this; }
|
||||
CFISection &D8(uint8_t v) { Section::D8(v); return *this; }
|
||||
CFISection &D16(uint16_t v) { Section::D16(v); return *this; }
|
||||
CFISection &D16(Label v) { Section::D16(v); return *this; }
|
||||
CFISection &D32(uint32_t v) { Section::D32(v); return *this; }
|
||||
CFISection &D32(const Label &v) { Section::D32(v); return *this; }
|
||||
CFISection &D64(uint64_t v) { Section::D64(v); return *this; }
|
||||
CFISection &D64(const Label &v) { Section::D64(v); return *this; }
|
||||
CFISection &LEB128(long long v) { Section::LEB128(v); return *this; }
|
||||
CFISection &ULEB128(uint64_t v) { Section::ULEB128(v); return *this; }
|
||||
CFISection& Mark(Label* label) { Section::Mark(label); return *this; }
|
||||
CFISection& D8(uint8_t v) { Section::D8(v); return *this; }
|
||||
CFISection& D16(uint16_t v) { Section::D16(v); return *this; }
|
||||
CFISection& D16(Label v) { Section::D16(v); return *this; }
|
||||
CFISection& D32(uint32_t v) { Section::D32(v); return *this; }
|
||||
CFISection& D32(const Label& v) { Section::D32(v); return *this; }
|
||||
CFISection& D64(uint64_t v) { Section::D64(v); return *this; }
|
||||
CFISection& D64(const Label& v) { Section::D64(v); return *this; }
|
||||
CFISection& LEB128(long long v) { Section::LEB128(v); return *this; }
|
||||
CFISection& ULEB128(uint64_t v) { Section::ULEB128(v); return *this; }
|
||||
|
||||
private:
|
||||
// A length value that we've appended to the section, but is not yet
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace dwarf2reader {
|
||||
|
||||
DIEDispatcher::~DIEDispatcher() {
|
||||
while (!die_handlers_.empty()) {
|
||||
HandlerStack &entry = die_handlers_.top();
|
||||
HandlerStack& entry = die_handlers_.top();
|
||||
if (entry.handler_ != root_handler_)
|
||||
delete entry.handler_;
|
||||
die_handlers_.pop();
|
||||
@@ -60,7 +60,7 @@ bool DIEDispatcher::StartCompilationUnit(uint64_t offset, uint8_t address_size,
|
||||
|
||||
bool DIEDispatcher::StartDIE(uint64_t offset, enum DwarfTag tag) {
|
||||
// The stack entry for the parent of this DIE, if there is one.
|
||||
HandlerStack *parent = die_handlers_.empty() ? NULL : &die_handlers_.top();
|
||||
HandlerStack* parent = die_handlers_.empty() ? NULL : &die_handlers_.top();
|
||||
|
||||
// Does this call indicate that we're done receiving the parent's
|
||||
// attributes' values? If so, call its EndAttributes member function.
|
||||
@@ -78,7 +78,7 @@ bool DIEDispatcher::StartDIE(uint64_t offset, enum DwarfTag tag) {
|
||||
}
|
||||
|
||||
// Find a handler for this DIE.
|
||||
DIEHandler *handler;
|
||||
DIEHandler* handler;
|
||||
if (parent) {
|
||||
if (parent->handler_)
|
||||
// Ask the parent to find a handler.
|
||||
@@ -115,7 +115,7 @@ bool DIEDispatcher::StartDIE(uint64_t offset, enum DwarfTag tag) {
|
||||
|
||||
void DIEDispatcher::EndDIE(uint64_t offset) {
|
||||
assert(!die_handlers_.empty());
|
||||
HandlerStack *entry = &die_handlers_.top();
|
||||
HandlerStack* entry = &die_handlers_.top();
|
||||
if (entry->handler_) {
|
||||
// This entry had better be the handler for this DIE.
|
||||
assert(entry->offset_ == offset);
|
||||
@@ -139,7 +139,7 @@ void DIEDispatcher::ProcessAttributeUnsigned(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
uint64_t data) {
|
||||
HandlerStack ¤t = die_handlers_.top();
|
||||
HandlerStack& current = die_handlers_.top();
|
||||
// This had better be an attribute of the DIE we were meant to handle.
|
||||
assert(offset == current.offset_);
|
||||
current.handler_->ProcessAttributeUnsigned(attr, form, data);
|
||||
@@ -149,7 +149,7 @@ void DIEDispatcher::ProcessAttributeSigned(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
int64_t data) {
|
||||
HandlerStack ¤t = die_handlers_.top();
|
||||
HandlerStack& current = die_handlers_.top();
|
||||
// This had better be an attribute of the DIE we were meant to handle.
|
||||
assert(offset == current.offset_);
|
||||
current.handler_->ProcessAttributeSigned(attr, form, data);
|
||||
@@ -159,7 +159,7 @@ void DIEDispatcher::ProcessAttributeReference(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
uint64_t data) {
|
||||
HandlerStack ¤t = die_handlers_.top();
|
||||
HandlerStack& current = die_handlers_.top();
|
||||
// This had better be an attribute of the DIE we were meant to handle.
|
||||
assert(offset == current.offset_);
|
||||
current.handler_->ProcessAttributeReference(attr, form, data);
|
||||
@@ -168,9 +168,9 @@ void DIEDispatcher::ProcessAttributeReference(uint64_t offset,
|
||||
void DIEDispatcher::ProcessAttributeBuffer(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const uint8_t *data,
|
||||
const uint8_t* data,
|
||||
uint64_t len) {
|
||||
HandlerStack ¤t = die_handlers_.top();
|
||||
HandlerStack& current = die_handlers_.top();
|
||||
// This had better be an attribute of the DIE we were meant to handle.
|
||||
assert(offset == current.offset_);
|
||||
current.handler_->ProcessAttributeBuffer(attr, form, data, len);
|
||||
@@ -180,7 +180,7 @@ void DIEDispatcher::ProcessAttributeString(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const string& data) {
|
||||
HandlerStack ¤t = die_handlers_.top();
|
||||
HandlerStack& current = die_handlers_.top();
|
||||
// This had better be an attribute of the DIE we were meant to handle.
|
||||
assert(offset == current.offset_);
|
||||
current.handler_->ProcessAttributeString(attr, form, data);
|
||||
@@ -190,7 +190,7 @@ void DIEDispatcher::ProcessAttributeSignature(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
uint64_t signature) {
|
||||
HandlerStack ¤t = die_handlers_.top();
|
||||
HandlerStack& current = die_handlers_.top();
|
||||
// This had better be an attribute of the DIE we were meant to handle.
|
||||
assert(offset == current.offset_);
|
||||
current.handler_->ProcessAttributeSignature(attr, form, signature);
|
||||
|
||||
@@ -208,7 +208,7 @@ class DIEHandler {
|
||||
uint64_t data) { }
|
||||
virtual void ProcessAttributeBuffer(enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const uint8_t *data,
|
||||
const uint8_t* data,
|
||||
uint64_t len) { }
|
||||
virtual void ProcessAttributeString(enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
@@ -244,7 +244,7 @@ class DIEHandler {
|
||||
// it is.
|
||||
//
|
||||
// The default definition skips all children.
|
||||
virtual DIEHandler *FindChildHandler(uint64_t offset, enum DwarfTag tag) {
|
||||
virtual DIEHandler* FindChildHandler(uint64_t offset, enum DwarfTag tag) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ class DIEDispatcher: public Dwarf2Handler {
|
||||
// Create a Dwarf2Handler which uses ROOT_HANDLER as the handler for
|
||||
// the compilation unit's root die, as described for the DIEHandler
|
||||
// class.
|
||||
DIEDispatcher(RootDIEHandler *root_handler) : root_handler_(root_handler) { }
|
||||
DIEDispatcher(RootDIEHandler* root_handler) : root_handler_(root_handler) { }
|
||||
// Destroying a DIEDispatcher destroys all active handler objects
|
||||
// except the root handler.
|
||||
~DIEDispatcher();
|
||||
@@ -311,12 +311,12 @@ class DIEDispatcher: public Dwarf2Handler {
|
||||
void ProcessAttributeBuffer(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const uint8_t *data,
|
||||
const uint8_t* data,
|
||||
uint64_t len);
|
||||
void ProcessAttributeString(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const string &data);
|
||||
const string& data);
|
||||
void ProcessAttributeSignature(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
@@ -335,7 +335,7 @@ class DIEDispatcher: public Dwarf2Handler {
|
||||
|
||||
// The handler object interested in this DIE's attributes and
|
||||
// children. If NULL, we're not interested in either.
|
||||
DIEHandler *handler_;
|
||||
DIEHandler* handler_;
|
||||
|
||||
// Have we reported the end of this DIE's attributes to the handler?
|
||||
bool reported_attributes_end_;
|
||||
@@ -358,7 +358,7 @@ class DIEDispatcher: public Dwarf2Handler {
|
||||
|
||||
// The root handler. We don't push it on die_handlers_ until we
|
||||
// actually get the StartDIE call for the root.
|
||||
RootDIEHandler *root_handler_;
|
||||
RootDIEHandler* root_handler_;
|
||||
};
|
||||
|
||||
} // namespace dwarf2reader
|
||||
|
||||
@@ -69,9 +69,9 @@ class MockDIEHandler: public DIEHandler {
|
||||
MOCK_METHOD3(ProcessAttributeReference,
|
||||
void(DwarfAttribute, DwarfForm, uint64_t));
|
||||
MOCK_METHOD4(ProcessAttributeBuffer,
|
||||
void(DwarfAttribute, DwarfForm, const uint8_t *, uint64_t));
|
||||
void(DwarfAttribute, DwarfForm, const uint8_t*, uint64_t));
|
||||
MOCK_METHOD3(ProcessAttributeString,
|
||||
void(DwarfAttribute, DwarfForm, const string &));
|
||||
void(DwarfAttribute, DwarfForm, const string&));
|
||||
MOCK_METHOD3(ProcessAttributeSignature,
|
||||
void(DwarfAttribute, DwarfForm, uint64_t));
|
||||
MOCK_METHOD0(EndAttributes, bool());
|
||||
@@ -88,9 +88,9 @@ class MockRootDIEHandler: public RootDIEHandler {
|
||||
MOCK_METHOD3(ProcessAttributeReference,
|
||||
void(DwarfAttribute, DwarfForm, uint64_t));
|
||||
MOCK_METHOD4(ProcessAttributeBuffer,
|
||||
void(DwarfAttribute, DwarfForm, const uint8_t *, uint64_t));
|
||||
void(DwarfAttribute, DwarfForm, const uint8_t*, uint64_t));
|
||||
MOCK_METHOD3(ProcessAttributeString,
|
||||
void(DwarfAttribute, DwarfForm, const string &));
|
||||
void(DwarfAttribute, DwarfForm, const string&));
|
||||
MOCK_METHOD3(ProcessAttributeSignature,
|
||||
void(DwarfAttribute, DwarfForm, uint64_t));
|
||||
MOCK_METHOD0(EndAttributes, bool());
|
||||
@@ -339,7 +339,7 @@ TEST(Dwarf2DIEHandler, FindAndSkipChildren) {
|
||||
EXPECT_CALL(mock_root_handler,
|
||||
FindChildHandler(0x97412be24875de9dLL,
|
||||
(DwarfTag) 0x505a068b))
|
||||
.WillOnce(Return((DIEHandler *) NULL));
|
||||
.WillOnce(Return((DIEHandler*) NULL));
|
||||
|
||||
// Third child DIE.
|
||||
EXPECT_CALL(mock_root_handler,
|
||||
|
||||
@@ -122,9 +122,9 @@ void CompilationUnit::ReadAbbrevs() {
|
||||
// The only way to check whether we are reading over the end of the
|
||||
// buffer would be to first compute the size of the leb128 data by
|
||||
// reading it, then go back and read it again.
|
||||
const uint8_t *abbrev_start = iter->second.first +
|
||||
const uint8_t* abbrev_start = iter->second.first +
|
||||
header_.abbrev_offset;
|
||||
const uint8_t *abbrevptr = abbrev_start;
|
||||
const uint8_t* abbrevptr = abbrev_start;
|
||||
#ifndef NDEBUG
|
||||
const uint64_t abbrev_length = iter->second.second - header_.abbrev_offset;
|
||||
#endif
|
||||
@@ -171,7 +171,7 @@ void CompilationUnit::ReadAbbrevs() {
|
||||
}
|
||||
|
||||
// Skips a single DIE's attributes.
|
||||
const uint8_t *CompilationUnit::SkipDIE(const uint8_t* start,
|
||||
const uint8_t* CompilationUnit::SkipDIE(const uint8_t* start,
|
||||
const Abbrev& abbrev) {
|
||||
for (AttributeList::const_iterator i = abbrev.attributes.begin();
|
||||
i != abbrev.attributes.end();
|
||||
@@ -182,7 +182,7 @@ const uint8_t *CompilationUnit::SkipDIE(const uint8_t* start,
|
||||
}
|
||||
|
||||
// Skips a single attribute form's data.
|
||||
const uint8_t *CompilationUnit::SkipAttribute(const uint8_t *start,
|
||||
const uint8_t* CompilationUnit::SkipAttribute(const uint8_t* start,
|
||||
enum DwarfForm form) {
|
||||
size_t len;
|
||||
|
||||
@@ -219,7 +219,7 @@ const uint8_t *CompilationUnit::SkipAttribute(const uint8_t *start,
|
||||
case DW_FORM_ref_sig8:
|
||||
return start + 8;
|
||||
case DW_FORM_string:
|
||||
return start + strlen(reinterpret_cast<const char *>(start)) + 1;
|
||||
return start + strlen(reinterpret_cast<const char*>(start)) + 1;
|
||||
case DW_FORM_udata:
|
||||
case DW_FORM_ref_udata:
|
||||
case DW_FORM_strx:
|
||||
@@ -311,7 +311,7 @@ size_t CompilationUnit::ReadTypeOffset(const uint8_t* headerptr) {
|
||||
// abbrevs, and an address size. DWARF5 adds a unit_type to distinguish
|
||||
// between partial-, full-, skeleton-, split-, and type- compilation units.
|
||||
void CompilationUnit::ReadHeader() {
|
||||
const uint8_t *headerptr = buffer_;
|
||||
const uint8_t* headerptr = buffer_;
|
||||
size_t initial_length_size;
|
||||
|
||||
assert(headerptr + 4 < buffer_ + buffer_length_);
|
||||
@@ -455,8 +455,8 @@ void CompilationUnit::ProcessFormStringIndex(
|
||||
// If one really wanted, you could merge SkipAttribute and
|
||||
// ProcessAttribute
|
||||
// This is all boring data manipulation and calling of the handler.
|
||||
const uint8_t *CompilationUnit::ProcessAttribute(
|
||||
uint64_t dieoffset, const uint8_t *start, enum DwarfAttribute attr,
|
||||
const uint8_t* CompilationUnit::ProcessAttribute(
|
||||
uint64_t dieoffset, const uint8_t* start, enum DwarfAttribute attr,
|
||||
enum DwarfForm form) {
|
||||
size_t len;
|
||||
|
||||
@@ -490,7 +490,7 @@ const uint8_t *CompilationUnit::ProcessAttribute(
|
||||
reader_->ReadEightBytes(start));
|
||||
return start + 8;
|
||||
case DW_FORM_string: {
|
||||
const char *str = reinterpret_cast<const char *>(start);
|
||||
const char* str = reinterpret_cast<const char*>(start);
|
||||
ProcessAttributeString(dieoffset, attr, form, str);
|
||||
return start + strlen(str) + 1;
|
||||
}
|
||||
@@ -588,7 +588,7 @@ const uint8_t *CompilationUnit::ProcessAttribute(
|
||||
const uint64_t offset = reader_->ReadOffset(start);
|
||||
assert(string_buffer_ + offset < string_buffer_ + string_buffer_length_);
|
||||
|
||||
const char *str = reinterpret_cast<const char *>(string_buffer_ + offset);
|
||||
const char* str = reinterpret_cast<const char*>(string_buffer_ + offset);
|
||||
ProcessAttributeString(dieoffset, attr, form, str);
|
||||
return start + reader_->OffsetSize();
|
||||
}
|
||||
@@ -662,8 +662,8 @@ const uint8_t *CompilationUnit::ProcessAttribute(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const uint8_t *CompilationUnit::ProcessDIE(uint64_t dieoffset,
|
||||
const uint8_t *start,
|
||||
const uint8_t* CompilationUnit::ProcessDIE(uint64_t dieoffset,
|
||||
const uint8_t* start,
|
||||
const Abbrev& abbrev) {
|
||||
for (AttributeList::const_iterator i = abbrev.attributes.begin();
|
||||
i != abbrev.attributes.end();
|
||||
@@ -684,12 +684,12 @@ const uint8_t *CompilationUnit::ProcessDIE(uint64_t dieoffset,
|
||||
}
|
||||
|
||||
void CompilationUnit::ProcessDIEs() {
|
||||
const uint8_t *dieptr = after_header_;
|
||||
const uint8_t* dieptr = after_header_;
|
||||
size_t len;
|
||||
|
||||
// lengthstart is the place the length field is based on.
|
||||
// It is the point in the header after the initial length field
|
||||
const uint8_t *lengthstart = buffer_;
|
||||
const uint8_t* lengthstart = buffer_;
|
||||
|
||||
// In 64 bit dwarf, the initial length is 12 bytes, because of the
|
||||
// 0xffffffff at the start.
|
||||
@@ -827,7 +827,7 @@ void CompilationUnit::ReadDebugSectionsFromDwo(ElfReader* elf_reader,
|
||||
if (section_data != NULL)
|
||||
sections->insert(std::make_pair(
|
||||
base_name, std::make_pair(
|
||||
reinterpret_cast<const uint8_t *>(section_data),
|
||||
reinterpret_cast<const uint8_t*>(section_data),
|
||||
section_size)));
|
||||
}
|
||||
}
|
||||
@@ -856,11 +856,11 @@ void DwpReader::Initialize() {
|
||||
&string_buffer_size_);
|
||||
|
||||
version_ = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(cu_index_));
|
||||
reinterpret_cast<const uint8_t*>(cu_index_));
|
||||
|
||||
if (version_ == 1) {
|
||||
nslots_ = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(cu_index_)
|
||||
reinterpret_cast<const uint8_t*>(cu_index_)
|
||||
+ 3 * sizeof(uint32_t));
|
||||
phash_ = cu_index_ + 4 * sizeof(uint32_t);
|
||||
pindex_ = phash_ + nslots_ * sizeof(uint64_t);
|
||||
@@ -870,11 +870,11 @@ void DwpReader::Initialize() {
|
||||
}
|
||||
} else if (version_ == 2) {
|
||||
ncolumns_ = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(cu_index_) + sizeof(uint32_t));
|
||||
reinterpret_cast<const uint8_t*>(cu_index_) + sizeof(uint32_t));
|
||||
nunits_ = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(cu_index_) + 2 * sizeof(uint32_t));
|
||||
reinterpret_cast<const uint8_t*>(cu_index_) + 2 * sizeof(uint32_t));
|
||||
nslots_ = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(cu_index_) + 3 * sizeof(uint32_t));
|
||||
reinterpret_cast<const uint8_t*>(cu_index_) + 3 * sizeof(uint32_t));
|
||||
phash_ = cu_index_ + 4 * sizeof(uint32_t);
|
||||
pindex_ = phash_ + nslots_ * sizeof(uint64_t);
|
||||
offset_table_ = pindex_ + nslots_ * sizeof(uint32_t);
|
||||
@@ -902,7 +902,7 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id,
|
||||
// can read a list of section indexes for the debug sections
|
||||
// for the CU whose dwo_id we are looking for.
|
||||
int index = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(pindex_)
|
||||
reinterpret_cast<const uint8_t*>(pindex_)
|
||||
+ slot * sizeof(uint32_t));
|
||||
const char* shndx_list = shndx_pool_ + index * sizeof(uint32_t);
|
||||
for (;;) {
|
||||
@@ -911,7 +911,7 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id,
|
||||
return;
|
||||
}
|
||||
unsigned int shndx = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(shndx_list));
|
||||
reinterpret_cast<const uint8_t*>(shndx_list));
|
||||
shndx_list += sizeof(uint32_t);
|
||||
if (shndx == 0)
|
||||
break;
|
||||
@@ -925,26 +925,26 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id,
|
||||
section_data = elf_reader_->GetSectionByIndex(shndx, §ion_size);
|
||||
sections->insert(std::make_pair(
|
||||
".debug_abbrev",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (section_data),
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (section_data),
|
||||
section_size)));
|
||||
} else if (!strncmp(section_name, ".debug_info", strlen(".debug_info"))) {
|
||||
section_data = elf_reader_->GetSectionByIndex(shndx, §ion_size);
|
||||
sections->insert(std::make_pair(
|
||||
".debug_info",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (section_data),
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (section_data),
|
||||
section_size)));
|
||||
} else if (!strncmp(section_name, ".debug_str_offsets",
|
||||
strlen(".debug_str_offsets"))) {
|
||||
section_data = elf_reader_->GetSectionByIndex(shndx, §ion_size);
|
||||
sections->insert(std::make_pair(
|
||||
".debug_str_offsets",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (section_data),
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (section_data),
|
||||
section_size)));
|
||||
}
|
||||
}
|
||||
sections->insert(std::make_pair(
|
||||
".debug_str",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (string_buffer_),
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (string_buffer_),
|
||||
string_buffer_size_)));
|
||||
} else if (version_ == 2) {
|
||||
uint32_t index = LookupCUv2(dwo_id);
|
||||
@@ -969,33 +969,33 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id,
|
||||
}
|
||||
for (unsigned int col = 0u; col < ncolumns_; ++col) {
|
||||
uint32_t section_id =
|
||||
byte_reader_.ReadFourBytes(reinterpret_cast<const uint8_t *>(id_row)
|
||||
byte_reader_.ReadFourBytes(reinterpret_cast<const uint8_t*>(id_row)
|
||||
+ col * sizeof(uint32_t));
|
||||
uint32_t offset = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(offset_row)
|
||||
reinterpret_cast<const uint8_t*>(offset_row)
|
||||
+ col * sizeof(uint32_t));
|
||||
uint32_t size = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(size_row) + col * sizeof(uint32_t));
|
||||
reinterpret_cast<const uint8_t*>(size_row) + col * sizeof(uint32_t));
|
||||
if (section_id == DW_SECT_ABBREV) {
|
||||
sections->insert(std::make_pair(
|
||||
".debug_abbrev",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (abbrev_data_)
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (abbrev_data_)
|
||||
+ offset, size)));
|
||||
} else if (section_id == DW_SECT_INFO) {
|
||||
sections->insert(std::make_pair(
|
||||
".debug_info",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (info_data_)
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (info_data_)
|
||||
+ offset, size)));
|
||||
} else if (section_id == DW_SECT_STR_OFFSETS) {
|
||||
sections->insert(std::make_pair(
|
||||
".debug_str_offsets",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (str_offsets_data_)
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (str_offsets_data_)
|
||||
+ offset, size)));
|
||||
}
|
||||
}
|
||||
sections->insert(std::make_pair(
|
||||
".debug_str",
|
||||
std::make_pair(reinterpret_cast<const uint8_t *> (string_buffer_),
|
||||
std::make_pair(reinterpret_cast<const uint8_t*> (string_buffer_),
|
||||
string_buffer_size_)));
|
||||
}
|
||||
}
|
||||
@@ -1003,14 +1003,14 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id,
|
||||
int DwpReader::LookupCU(uint64_t dwo_id) {
|
||||
uint32_t slot = static_cast<uint32_t>(dwo_id) & (nslots_ - 1);
|
||||
uint64_t probe = byte_reader_.ReadEightBytes(
|
||||
reinterpret_cast<const uint8_t *>(phash_) + slot * sizeof(uint64_t));
|
||||
reinterpret_cast<const uint8_t*>(phash_) + slot * sizeof(uint64_t));
|
||||
if (probe != 0 && probe != dwo_id) {
|
||||
uint32_t secondary_hash =
|
||||
(static_cast<uint32_t>(dwo_id >> 32) & (nslots_ - 1)) | 1;
|
||||
do {
|
||||
slot = (slot + secondary_hash) & (nslots_ - 1);
|
||||
probe = byte_reader_.ReadEightBytes(
|
||||
reinterpret_cast<const uint8_t *>(phash_) + slot * sizeof(uint64_t));
|
||||
reinterpret_cast<const uint8_t*>(phash_) + slot * sizeof(uint64_t));
|
||||
} while (probe != 0 && probe != dwo_id);
|
||||
}
|
||||
if (probe == 0)
|
||||
@@ -1021,24 +1021,24 @@ int DwpReader::LookupCU(uint64_t dwo_id) {
|
||||
uint32_t DwpReader::LookupCUv2(uint64_t dwo_id) {
|
||||
uint32_t slot = static_cast<uint32_t>(dwo_id) & (nslots_ - 1);
|
||||
uint64_t probe = byte_reader_.ReadEightBytes(
|
||||
reinterpret_cast<const uint8_t *>(phash_) + slot * sizeof(uint64_t));
|
||||
reinterpret_cast<const uint8_t*>(phash_) + slot * sizeof(uint64_t));
|
||||
uint32_t index = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(pindex_) + slot * sizeof(uint32_t));
|
||||
reinterpret_cast<const uint8_t*>(pindex_) + slot * sizeof(uint32_t));
|
||||
if (index != 0 && probe != dwo_id) {
|
||||
uint32_t secondary_hash =
|
||||
(static_cast<uint32_t>(dwo_id >> 32) & (nslots_ - 1)) | 1;
|
||||
do {
|
||||
slot = (slot + secondary_hash) & (nslots_ - 1);
|
||||
probe = byte_reader_.ReadEightBytes(
|
||||
reinterpret_cast<const uint8_t *>(phash_) + slot * sizeof(uint64_t));
|
||||
reinterpret_cast<const uint8_t*>(phash_) + slot * sizeof(uint64_t));
|
||||
index = byte_reader_.ReadFourBytes(
|
||||
reinterpret_cast<const uint8_t *>(pindex_) + slot * sizeof(uint32_t));
|
||||
reinterpret_cast<const uint8_t*>(pindex_) + slot * sizeof(uint32_t));
|
||||
} while (index != 0 && probe != dwo_id);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
LineInfo::LineInfo(const uint8_t *buffer, uint64_t buffer_length,
|
||||
LineInfo::LineInfo(const uint8_t* buffer, uint64_t buffer_length,
|
||||
ByteReader* reader, const uint8_t* string_buffer,
|
||||
size_t string_buffer_length,
|
||||
const uint8_t* line_string_buffer,
|
||||
@@ -1185,7 +1185,7 @@ void LineInfo::ReadFileRow(const uint8_t** lineptr,
|
||||
// The header for a debug_line section is mildly complicated, because
|
||||
// the line info is very tightly encoded.
|
||||
void LineInfo::ReadHeader() {
|
||||
const uint8_t *lineptr = buffer_;
|
||||
const uint8_t* lineptr = buffer_;
|
||||
size_t initial_length_size;
|
||||
|
||||
const uint64_t initial_length
|
||||
@@ -1331,12 +1331,12 @@ void LineInfo::ReadHeader() {
|
||||
/* static */
|
||||
bool LineInfo::ProcessOneOpcode(ByteReader* reader,
|
||||
LineInfoHandler* handler,
|
||||
const struct LineInfoHeader &header,
|
||||
const uint8_t *start,
|
||||
const struct LineInfoHeader& header,
|
||||
const uint8_t* start,
|
||||
struct LineStateMachine* lsm,
|
||||
size_t* len,
|
||||
uintptr pc,
|
||||
bool *lsm_passes_pc) {
|
||||
bool* lsm_passes_pc) {
|
||||
size_t oplen = 0;
|
||||
size_t templen;
|
||||
uint8_t opcode = reader->ReadOneByte(start);
|
||||
@@ -1473,7 +1473,7 @@ bool LineInfo::ProcessOneOpcode(ByteReader* reader,
|
||||
}
|
||||
break;
|
||||
case DW_LNE_define_file: {
|
||||
const char *filename = reinterpret_cast<const char *>(start);
|
||||
const char* filename = reinterpret_cast<const char*>(start);
|
||||
|
||||
templen = strlen(filename) + 1;
|
||||
start += templen;
|
||||
@@ -1520,7 +1520,7 @@ void LineInfo::ReadLines() {
|
||||
|
||||
// lengthstart is the place the length field is based on.
|
||||
// It is the point in the header after the initial length field
|
||||
const uint8_t *lengthstart = buffer_;
|
||||
const uint8_t* lengthstart = buffer_;
|
||||
|
||||
// In 64 bit dwarf, the initial length is 12 bytes, because of the
|
||||
// 0xffffffff at the start.
|
||||
@@ -1529,7 +1529,7 @@ void LineInfo::ReadLines() {
|
||||
else
|
||||
lengthstart += 4;
|
||||
|
||||
const uint8_t *lineptr = after_header_;
|
||||
const uint8_t* lineptr = after_header_;
|
||||
lsm.Reset(header_.default_is_stmt);
|
||||
|
||||
// The LineInfoHandler interface expects each line's length along
|
||||
@@ -1568,8 +1568,8 @@ void LineInfo::ReadLines() {
|
||||
after_header_ = lengthstart + header_.total_length;
|
||||
}
|
||||
|
||||
RangeListReader::RangeListReader(const uint8_t *buffer, uint64_t size,
|
||||
ByteReader *reader, RangeListHandler *handler)
|
||||
RangeListReader::RangeListReader(const uint8_t* buffer, uint64_t size,
|
||||
ByteReader* reader, RangeListHandler* handler)
|
||||
: buffer_(buffer), size_(size), reader_(reader), handler_(handler) { }
|
||||
|
||||
bool RangeListReader::ReadRangeList(uint64_t offset) {
|
||||
@@ -1625,17 +1625,17 @@ class CallFrameInfo::Rule {
|
||||
// this rule. If REG is kCFARegister, then this rule describes how to compute
|
||||
// the canonical frame address. Return what the HANDLER member function
|
||||
// returned.
|
||||
virtual bool Handle(Handler *handler,
|
||||
virtual bool Handle(Handler* handler,
|
||||
uint64_t address, int reg) const = 0;
|
||||
|
||||
// Equality on rules. We use these to decide which rules we need
|
||||
// to report after a DW_CFA_restore_state instruction.
|
||||
virtual bool operator==(const Rule &rhs) const = 0;
|
||||
virtual bool operator==(const Rule& rhs) const = 0;
|
||||
|
||||
bool operator!=(const Rule &rhs) const { return ! (*this == rhs); }
|
||||
bool operator!=(const Rule& rhs) const { return ! (*this == rhs); }
|
||||
|
||||
// Return a pointer to a copy of this rule.
|
||||
virtual Rule *Copy() const = 0;
|
||||
virtual Rule* Copy() const = 0;
|
||||
|
||||
// If this is a base+offset rule, change its base register to REG.
|
||||
// Otherwise, do nothing. (Ugly, but required for DW_CFA_def_cfa_register.)
|
||||
@@ -1651,16 +1651,16 @@ class CallFrameInfo::UndefinedRule: public CallFrameInfo::Rule {
|
||||
public:
|
||||
UndefinedRule() { }
|
||||
~UndefinedRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->UndefinedRule(address, reg);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const UndefinedRule *our_rhs = dynamic_cast<const UndefinedRule *>(&rhs);
|
||||
const UndefinedRule* our_rhs = dynamic_cast<const UndefinedRule*>(&rhs);
|
||||
return (our_rhs != NULL);
|
||||
}
|
||||
Rule *Copy() const { return new UndefinedRule(*this); }
|
||||
Rule* Copy() const { return new UndefinedRule(*this); }
|
||||
};
|
||||
|
||||
// Rule: the register's value is the same as that it had in the caller.
|
||||
@@ -1668,16 +1668,16 @@ class CallFrameInfo::SameValueRule: public CallFrameInfo::Rule {
|
||||
public:
|
||||
SameValueRule() { }
|
||||
~SameValueRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->SameValueRule(address, reg);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const SameValueRule *our_rhs = dynamic_cast<const SameValueRule *>(&rhs);
|
||||
const SameValueRule* our_rhs = dynamic_cast<const SameValueRule*>(&rhs);
|
||||
return (our_rhs != NULL);
|
||||
}
|
||||
Rule *Copy() const { return new SameValueRule(*this); }
|
||||
Rule* Copy() const { return new SameValueRule(*this); }
|
||||
};
|
||||
|
||||
// Rule: the register is saved at OFFSET from BASE_REGISTER. BASE_REGISTER
|
||||
@@ -1687,18 +1687,18 @@ class CallFrameInfo::OffsetRule: public CallFrameInfo::Rule {
|
||||
OffsetRule(int base_register, long offset)
|
||||
: base_register_(base_register), offset_(offset) { }
|
||||
~OffsetRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->OffsetRule(address, reg, base_register_, offset_);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const OffsetRule *our_rhs = dynamic_cast<const OffsetRule *>(&rhs);
|
||||
const OffsetRule* our_rhs = dynamic_cast<const OffsetRule*>(&rhs);
|
||||
return (our_rhs &&
|
||||
base_register_ == our_rhs->base_register_ &&
|
||||
offset_ == our_rhs->offset_);
|
||||
}
|
||||
Rule *Copy() const { return new OffsetRule(*this); }
|
||||
Rule* Copy() const { return new OffsetRule(*this); }
|
||||
// We don't actually need SetBaseRegister or SetOffset here, since they
|
||||
// are only ever applied to CFA rules, for DW_CFA_def_cfa_offset, and it
|
||||
// doesn't make sense to use OffsetRule for computing the CFA: it
|
||||
@@ -1716,18 +1716,18 @@ class CallFrameInfo::ValOffsetRule: public CallFrameInfo::Rule {
|
||||
ValOffsetRule(int base_register, long offset)
|
||||
: base_register_(base_register), offset_(offset) { }
|
||||
~ValOffsetRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->ValOffsetRule(address, reg, base_register_, offset_);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const ValOffsetRule *our_rhs = dynamic_cast<const ValOffsetRule *>(&rhs);
|
||||
const ValOffsetRule* our_rhs = dynamic_cast<const ValOffsetRule*>(&rhs);
|
||||
return (our_rhs &&
|
||||
base_register_ == our_rhs->base_register_ &&
|
||||
offset_ == our_rhs->offset_);
|
||||
}
|
||||
Rule *Copy() const { return new ValOffsetRule(*this); }
|
||||
Rule* Copy() const { return new ValOffsetRule(*this); }
|
||||
void SetBaseRegister(unsigned reg) { base_register_ = reg; }
|
||||
void SetOffset(long long offset) { offset_ = offset; }
|
||||
private:
|
||||
@@ -1741,16 +1741,16 @@ class CallFrameInfo::RegisterRule: public CallFrameInfo::Rule {
|
||||
explicit RegisterRule(int register_number)
|
||||
: register_number_(register_number) { }
|
||||
~RegisterRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->RegisterRule(address, reg, register_number_);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const RegisterRule *our_rhs = dynamic_cast<const RegisterRule *>(&rhs);
|
||||
const RegisterRule* our_rhs = dynamic_cast<const RegisterRule*>(&rhs);
|
||||
return (our_rhs && register_number_ == our_rhs->register_number_);
|
||||
}
|
||||
Rule *Copy() const { return new RegisterRule(*this); }
|
||||
Rule* Copy() const { return new RegisterRule(*this); }
|
||||
private:
|
||||
int register_number_;
|
||||
};
|
||||
@@ -1758,19 +1758,19 @@ class CallFrameInfo::RegisterRule: public CallFrameInfo::Rule {
|
||||
// Rule: EXPRESSION evaluates to the address at which the register is saved.
|
||||
class CallFrameInfo::ExpressionRule: public CallFrameInfo::Rule {
|
||||
public:
|
||||
explicit ExpressionRule(const string &expression)
|
||||
explicit ExpressionRule(const string& expression)
|
||||
: expression_(expression) { }
|
||||
~ExpressionRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->ExpressionRule(address, reg, expression_);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const ExpressionRule *our_rhs = dynamic_cast<const ExpressionRule *>(&rhs);
|
||||
const ExpressionRule* our_rhs = dynamic_cast<const ExpressionRule*>(&rhs);
|
||||
return (our_rhs && expression_ == our_rhs->expression_);
|
||||
}
|
||||
Rule *Copy() const { return new ExpressionRule(*this); }
|
||||
Rule* Copy() const { return new ExpressionRule(*this); }
|
||||
private:
|
||||
string expression_;
|
||||
};
|
||||
@@ -1778,20 +1778,20 @@ class CallFrameInfo::ExpressionRule: public CallFrameInfo::Rule {
|
||||
// Rule: EXPRESSION evaluates to the address at which the register is saved.
|
||||
class CallFrameInfo::ValExpressionRule: public CallFrameInfo::Rule {
|
||||
public:
|
||||
explicit ValExpressionRule(const string &expression)
|
||||
explicit ValExpressionRule(const string& expression)
|
||||
: expression_(expression) { }
|
||||
~ValExpressionRule() { }
|
||||
bool Handle(Handler *handler, uint64_t address, int reg) const {
|
||||
bool Handle(Handler* handler, uint64_t address, int reg) const {
|
||||
return handler->ValExpressionRule(address, reg, expression_);
|
||||
}
|
||||
bool operator==(const Rule &rhs) const {
|
||||
bool operator==(const Rule& rhs) const {
|
||||
// dynamic_cast is allowed by the Google C++ Style Guide, if the use has
|
||||
// been carefully considered; cheap RTTI-like workarounds are forbidden.
|
||||
const ValExpressionRule *our_rhs =
|
||||
dynamic_cast<const ValExpressionRule *>(&rhs);
|
||||
const ValExpressionRule* our_rhs =
|
||||
dynamic_cast<const ValExpressionRule*>(&rhs);
|
||||
return (our_rhs && expression_ == our_rhs->expression_);
|
||||
}
|
||||
Rule *Copy() const { return new ValExpressionRule(*this); }
|
||||
Rule* Copy() const { return new ValExpressionRule(*this); }
|
||||
private:
|
||||
string expression_;
|
||||
};
|
||||
@@ -1800,51 +1800,51 @@ class CallFrameInfo::ValExpressionRule: public CallFrameInfo::Rule {
|
||||
class CallFrameInfo::RuleMap {
|
||||
public:
|
||||
RuleMap() : cfa_rule_(NULL) { }
|
||||
RuleMap(const RuleMap &rhs) : cfa_rule_(NULL) { *this = rhs; }
|
||||
RuleMap(const RuleMap& rhs) : cfa_rule_(NULL) { *this = rhs; }
|
||||
~RuleMap() { Clear(); }
|
||||
|
||||
RuleMap &operator=(const RuleMap &rhs);
|
||||
RuleMap& operator=(const RuleMap& rhs);
|
||||
|
||||
// Set the rule for computing the CFA to RULE. Take ownership of RULE.
|
||||
void SetCFARule(Rule *rule) { delete cfa_rule_; cfa_rule_ = rule; }
|
||||
void SetCFARule(Rule* rule) { delete cfa_rule_; cfa_rule_ = rule; }
|
||||
|
||||
// Return the current CFA rule. Unlike RegisterRule, this RuleMap retains
|
||||
// ownership of the rule. We use this for DW_CFA_def_cfa_offset and
|
||||
// DW_CFA_def_cfa_register, and for detecting references to the CFA before
|
||||
// a rule for it has been established.
|
||||
Rule *CFARule() const { return cfa_rule_; }
|
||||
Rule* CFARule() const { return cfa_rule_; }
|
||||
|
||||
// Return the rule for REG, or NULL if there is none. The caller takes
|
||||
// ownership of the result.
|
||||
Rule *RegisterRule(int reg) const;
|
||||
Rule* RegisterRule(int reg) const;
|
||||
|
||||
// Set the rule for computing REG to RULE. Take ownership of RULE.
|
||||
void SetRegisterRule(int reg, Rule *rule);
|
||||
void SetRegisterRule(int reg, Rule* rule);
|
||||
|
||||
// Make all the appropriate calls to HANDLER as if we were changing from
|
||||
// this RuleMap to NEW_RULES at ADDRESS. We use this to implement
|
||||
// DW_CFA_restore_state, where lots of rules can change simultaneously.
|
||||
// Return true if all handlers returned true; otherwise, return false.
|
||||
bool HandleTransitionTo(Handler *handler, uint64_t address,
|
||||
const RuleMap &new_rules) const;
|
||||
bool HandleTransitionTo(Handler* handler, uint64_t address,
|
||||
const RuleMap& new_rules) const;
|
||||
|
||||
private:
|
||||
// A map from register numbers to Rules.
|
||||
typedef std::map<int, Rule *> RuleByNumber;
|
||||
typedef std::map<int, Rule*> RuleByNumber;
|
||||
|
||||
// Remove all register rules and clear cfa_rule_.
|
||||
void Clear();
|
||||
|
||||
// The rule for computing the canonical frame address. This RuleMap owns
|
||||
// this rule.
|
||||
Rule *cfa_rule_;
|
||||
Rule* cfa_rule_;
|
||||
|
||||
// A map from register numbers to postfix expressions to recover
|
||||
// their values. This RuleMap owns the Rules the map refers to.
|
||||
RuleByNumber registers_;
|
||||
};
|
||||
|
||||
CallFrameInfo::RuleMap &CallFrameInfo::RuleMap::operator=(const RuleMap &rhs) {
|
||||
CallFrameInfo::RuleMap& CallFrameInfo::RuleMap::operator=(const RuleMap& rhs) {
|
||||
Clear();
|
||||
// Since each map owns the rules it refers to, assignment must copy them.
|
||||
if (rhs.cfa_rule_) cfa_rule_ = rhs.cfa_rule_->Copy();
|
||||
@@ -1854,7 +1854,7 @@ CallFrameInfo::RuleMap &CallFrameInfo::RuleMap::operator=(const RuleMap &rhs) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
CallFrameInfo::Rule *CallFrameInfo::RuleMap::RegisterRule(int reg) const {
|
||||
CallFrameInfo::Rule* CallFrameInfo::RuleMap::RegisterRule(int reg) const {
|
||||
assert(reg != Handler::kCFARegister);
|
||||
RuleByNumber::const_iterator it = registers_.find(reg);
|
||||
if (it != registers_.end())
|
||||
@@ -1863,18 +1863,18 @@ CallFrameInfo::Rule *CallFrameInfo::RuleMap::RegisterRule(int reg) const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CallFrameInfo::RuleMap::SetRegisterRule(int reg, Rule *rule) {
|
||||
void CallFrameInfo::RuleMap::SetRegisterRule(int reg, Rule* rule) {
|
||||
assert(reg != Handler::kCFARegister);
|
||||
assert(rule);
|
||||
Rule **slot = ®isters_[reg];
|
||||
Rule** slot = ®isters_[reg];
|
||||
delete *slot;
|
||||
*slot = rule;
|
||||
}
|
||||
|
||||
bool CallFrameInfo::RuleMap::HandleTransitionTo(
|
||||
Handler *handler,
|
||||
Handler* handler,
|
||||
uint64_t address,
|
||||
const RuleMap &new_rules) const {
|
||||
const RuleMap& new_rules) const {
|
||||
// Transition from cfa_rule_ to new_rules.cfa_rule_.
|
||||
if (cfa_rule_ && new_rules.cfa_rule_) {
|
||||
if (*cfa_rule_ != *new_rules.cfa_rule_ &&
|
||||
@@ -1954,7 +1954,7 @@ class CallFrameInfo::State {
|
||||
public:
|
||||
// Create a call frame information interpreter state with the given
|
||||
// reporter, reader, handler, and initial call frame info address.
|
||||
State(ByteReader *reader, Handler *handler, Reporter *reporter,
|
||||
State(ByteReader* reader, Handler* handler, Reporter* reporter,
|
||||
uint64_t address)
|
||||
: reader_(reader), handler_(handler), reporter_(reporter),
|
||||
address_(address), entry_(NULL), cursor_(NULL) { }
|
||||
@@ -1962,11 +1962,11 @@ class CallFrameInfo::State {
|
||||
// Interpret instructions from CIE, save the resulting rule set for
|
||||
// DW_CFA_restore instructions, and return true. On error, report
|
||||
// the problem to reporter_ and return false.
|
||||
bool InterpretCIE(const CIE &cie);
|
||||
bool InterpretCIE(const CIE& cie);
|
||||
|
||||
// Interpret instructions from FDE, and return true. On error,
|
||||
// report the problem to reporter_ and return false.
|
||||
bool InterpretFDE(const FDE &fde);
|
||||
bool InterpretFDE(const FDE& fde);
|
||||
|
||||
private:
|
||||
// The operands of a CFI instruction, for ParseOperands.
|
||||
@@ -1996,7 +1996,7 @@ class CallFrameInfo::State {
|
||||
// '8' an eight-byte offset (OPERANDS->offset)
|
||||
// 'e' a DW_FORM_block holding a (OPERANDS->expression)
|
||||
// DWARF expression
|
||||
bool ParseOperands(const char *format, Operands *operands);
|
||||
bool ParseOperands(const char* format, Operands* operands);
|
||||
|
||||
// Interpret one CFI instruction from STATE's instruction stream, update
|
||||
// STATE, report any rule changes to handler_, and return true. On
|
||||
@@ -2019,7 +2019,7 @@ class CallFrameInfo::State {
|
||||
|
||||
// Specify that REG can be recovered using RULE, and return true. On
|
||||
// failure, report and return false.
|
||||
bool DoRule(unsigned reg, Rule *rule);
|
||||
bool DoRule(unsigned reg, Rule* rule);
|
||||
|
||||
// Specify that REG can be found at OFFSET from the CFA, and return true.
|
||||
// On failure, report and return false. (Subroutine for DW_CFA_offset,
|
||||
@@ -2047,23 +2047,23 @@ class CallFrameInfo::State {
|
||||
}
|
||||
|
||||
// For reading multi-byte values with the appropriate endianness.
|
||||
ByteReader *reader_;
|
||||
ByteReader* reader_;
|
||||
|
||||
// The handler to which we should report the data we find.
|
||||
Handler *handler_;
|
||||
Handler* handler_;
|
||||
|
||||
// For reporting problems in the info we're parsing.
|
||||
Reporter *reporter_;
|
||||
Reporter* reporter_;
|
||||
|
||||
// The code address to which the next instruction in the stream applies.
|
||||
uint64_t address_;
|
||||
|
||||
// The entry whose instructions we are currently processing. This is
|
||||
// first a CIE, and then an FDE.
|
||||
const Entry *entry_;
|
||||
const Entry* entry_;
|
||||
|
||||
// The next instruction to process.
|
||||
const uint8_t *cursor_;
|
||||
const uint8_t* cursor_;
|
||||
|
||||
// The current set of rules.
|
||||
RuleMap rules_;
|
||||
@@ -2078,7 +2078,7 @@ class CallFrameInfo::State {
|
||||
std::stack<RuleMap> saved_rules_;
|
||||
};
|
||||
|
||||
bool CallFrameInfo::State::InterpretCIE(const CIE &cie) {
|
||||
bool CallFrameInfo::State::InterpretCIE(const CIE& cie) {
|
||||
entry_ = &cie;
|
||||
cursor_ = entry_->instructions;
|
||||
while (cursor_ < entry_->end)
|
||||
@@ -2090,7 +2090,7 @@ bool CallFrameInfo::State::InterpretCIE(const CIE &cie) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CallFrameInfo::State::InterpretFDE(const FDE &fde) {
|
||||
bool CallFrameInfo::State::InterpretFDE(const FDE& fde) {
|
||||
entry_ = &fde;
|
||||
cursor_ = entry_->instructions;
|
||||
while (cursor_ < entry_->end)
|
||||
@@ -2099,10 +2099,10 @@ bool CallFrameInfo::State::InterpretFDE(const FDE &fde) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CallFrameInfo::State::ParseOperands(const char *format,
|
||||
Operands *operands) {
|
||||
bool CallFrameInfo::State::ParseOperands(const char* format,
|
||||
Operands* operands) {
|
||||
size_t len;
|
||||
const char *operand;
|
||||
const char* operand;
|
||||
|
||||
for (operand = format; *operand; operand++) {
|
||||
size_t bytes_left = entry_->end - cursor_;
|
||||
@@ -2161,7 +2161,7 @@ bool CallFrameInfo::State::ParseOperands(const char *format,
|
||||
if (len > bytes_left || expression_length > bytes_left - len)
|
||||
return ReportIncomplete();
|
||||
cursor_ += len;
|
||||
operands->expression = string(reinterpret_cast<const char *>(cursor_),
|
||||
operands->expression = string(reinterpret_cast<const char*>(cursor_),
|
||||
expression_length);
|
||||
cursor_ += expression_length;
|
||||
break;
|
||||
@@ -2176,7 +2176,7 @@ bool CallFrameInfo::State::ParseOperands(const char *format,
|
||||
}
|
||||
|
||||
bool CallFrameInfo::State::DoInstruction() {
|
||||
CIE *cie = entry_->cie;
|
||||
CIE* cie = entry_->cie;
|
||||
Operands ops;
|
||||
|
||||
// Our entry's kind should have been set by now.
|
||||
@@ -2266,7 +2266,7 @@ bool CallFrameInfo::State::DoInstruction() {
|
||||
// Change the base register used to compute the CFA.
|
||||
case DW_CFA_def_cfa_register: {
|
||||
if (!ParseOperands("r", &ops)) return false;
|
||||
Rule *cfa_rule = rules_.CFARule();
|
||||
Rule* cfa_rule = rules_.CFARule();
|
||||
if (!cfa_rule) {
|
||||
if (!DoDefCFA(ops.register_number, ops.offset)) {
|
||||
reporter_->NoCFARule(entry_->offset, entry_->kind, CursorOffset());
|
||||
@@ -2299,7 +2299,7 @@ bool CallFrameInfo::State::DoInstruction() {
|
||||
case DW_CFA_def_cfa_expression: {
|
||||
if (!ParseOperands("e", &ops))
|
||||
return false;
|
||||
Rule *rule = new ValExpressionRule(ops.expression);
|
||||
Rule* rule = new ValExpressionRule(ops.expression);
|
||||
rules_.SetCFARule(rule);
|
||||
if (!rule->Handle(handler_, address_,
|
||||
Handler::kCFARegister))
|
||||
@@ -2406,7 +2406,7 @@ bool CallFrameInfo::State::DoInstruction() {
|
||||
CursorOffset());
|
||||
return false;
|
||||
}
|
||||
const RuleMap &new_rules = saved_rules_.top();
|
||||
const RuleMap& new_rules = saved_rules_.top();
|
||||
if (rules_.CFARule() && !new_rules.CFARule()) {
|
||||
reporter_->ClearingCFARule(entry_->offset, entry_->kind,
|
||||
CursorOffset());
|
||||
@@ -2458,14 +2458,14 @@ bool CallFrameInfo::State::DoInstruction() {
|
||||
}
|
||||
|
||||
bool CallFrameInfo::State::DoDefCFA(unsigned base_register, long offset) {
|
||||
Rule *rule = new ValOffsetRule(base_register, offset);
|
||||
Rule* rule = new ValOffsetRule(base_register, offset);
|
||||
rules_.SetCFARule(rule);
|
||||
return rule->Handle(handler_, address_,
|
||||
Handler::kCFARegister);
|
||||
}
|
||||
|
||||
bool CallFrameInfo::State::DoDefCFAOffset(long offset) {
|
||||
Rule *cfa_rule = rules_.CFARule();
|
||||
Rule* cfa_rule = rules_.CFARule();
|
||||
if (!cfa_rule) {
|
||||
reporter_->NoCFARule(entry_->offset, entry_->kind, CursorOffset());
|
||||
return false;
|
||||
@@ -2475,7 +2475,7 @@ bool CallFrameInfo::State::DoDefCFAOffset(long offset) {
|
||||
Handler::kCFARegister);
|
||||
}
|
||||
|
||||
bool CallFrameInfo::State::DoRule(unsigned reg, Rule *rule) {
|
||||
bool CallFrameInfo::State::DoRule(unsigned reg, Rule* rule) {
|
||||
rules_.SetRegisterRule(reg, rule);
|
||||
return rule->Handle(handler_, address_, reg);
|
||||
}
|
||||
@@ -2504,7 +2504,7 @@ bool CallFrameInfo::State::DoRestore(unsigned reg) {
|
||||
reporter_->RestoreInCIE(entry_->offset, CursorOffset());
|
||||
return false;
|
||||
}
|
||||
Rule *rule = cie_rules_.RegisterRule(reg);
|
||||
Rule* rule = cie_rules_.RegisterRule(reg);
|
||||
if (!rule) {
|
||||
// This isn't really the right thing to do, but since CFI generally
|
||||
// only mentions callee-saves registers, and GCC's convention for
|
||||
@@ -2515,8 +2515,8 @@ bool CallFrameInfo::State::DoRestore(unsigned reg) {
|
||||
return DoRule(reg, rule);
|
||||
}
|
||||
|
||||
bool CallFrameInfo::ReadEntryPrologue(const uint8_t *cursor, Entry *entry) {
|
||||
const uint8_t *buffer_end = buffer_ + buffer_length_;
|
||||
bool CallFrameInfo::ReadEntryPrologue(const uint8_t* cursor, Entry* entry) {
|
||||
const uint8_t* buffer_end = buffer_ + buffer_length_;
|
||||
|
||||
// Initialize enough of ENTRY for use in error reporting.
|
||||
entry->offset = cursor - buffer_;
|
||||
@@ -2593,8 +2593,8 @@ bool CallFrameInfo::ReadEntryPrologue(const uint8_t *cursor, Entry *entry) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CallFrameInfo::ReadCIEFields(CIE *cie) {
|
||||
const uint8_t *cursor = cie->fields;
|
||||
bool CallFrameInfo::ReadCIEFields(CIE* cie) {
|
||||
const uint8_t* cursor = cie->fields;
|
||||
size_t len;
|
||||
|
||||
assert(cie->kind == kCIE);
|
||||
@@ -2625,13 +2625,13 @@ bool CallFrameInfo::ReadCIEFields(CIE *cie) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint8_t *augmentation_start = cursor;
|
||||
const uint8_t *augmentation_end =
|
||||
reinterpret_cast<const uint8_t *>(memchr(augmentation_start, '\0',
|
||||
const uint8_t* augmentation_start = cursor;
|
||||
const uint8_t* augmentation_end =
|
||||
reinterpret_cast<const uint8_t*>(memchr(augmentation_start, '\0',
|
||||
cie->end - augmentation_start));
|
||||
if (! augmentation_end) return ReportIncomplete(cie);
|
||||
cursor = augmentation_end;
|
||||
cie->augmentation = string(reinterpret_cast<const char *>(augmentation_start),
|
||||
cie->augmentation = string(reinterpret_cast<const char*>(augmentation_start),
|
||||
cursor - augmentation_start);
|
||||
// Skip the terminating '\0'.
|
||||
cursor++;
|
||||
@@ -2692,9 +2692,9 @@ bool CallFrameInfo::ReadCIEFields(CIE *cie) {
|
||||
if (size_t(cie->end - cursor) < len + data_size)
|
||||
return ReportIncomplete(cie);
|
||||
cursor += len;
|
||||
const uint8_t *data = cursor;
|
||||
const uint8_t* data = cursor;
|
||||
cursor += data_size;
|
||||
const uint8_t *data_end = cursor;
|
||||
const uint8_t* data_end = cursor;
|
||||
|
||||
cie->has_z_lsda = false;
|
||||
cie->has_z_personality = false;
|
||||
@@ -2785,8 +2785,8 @@ bool CallFrameInfo::ReadCIEFields(CIE *cie) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CallFrameInfo::ReadFDEFields(FDE *fde) {
|
||||
const uint8_t *cursor = fde->fields;
|
||||
bool CallFrameInfo::ReadFDEFields(FDE* fde) {
|
||||
const uint8_t* cursor = fde->fields;
|
||||
size_t size;
|
||||
|
||||
fde->address = reader_->ReadEncodedPointer(cursor, fde->cie->pointer_encoding,
|
||||
@@ -2852,10 +2852,10 @@ bool CallFrameInfo::ReadFDEFields(FDE *fde) {
|
||||
}
|
||||
|
||||
bool CallFrameInfo::Start() {
|
||||
const uint8_t *buffer_end = buffer_ + buffer_length_;
|
||||
const uint8_t *cursor;
|
||||
const uint8_t* buffer_end = buffer_ + buffer_length_;
|
||||
const uint8_t* cursor;
|
||||
bool all_ok = true;
|
||||
const uint8_t *entry_end;
|
||||
const uint8_t* entry_end;
|
||||
bool ok;
|
||||
|
||||
// Traverse all the entries in buffer_, skipping CIEs and offering
|
||||
@@ -2986,7 +2986,7 @@ bool CallFrameInfo::Start() {
|
||||
return all_ok;
|
||||
}
|
||||
|
||||
const char *CallFrameInfo::KindName(EntryKind kind) {
|
||||
const char* CallFrameInfo::KindName(EntryKind kind) {
|
||||
if (kind == CallFrameInfo::kUnknown)
|
||||
return "entry";
|
||||
else if (kind == CallFrameInfo::kCIE)
|
||||
@@ -2999,7 +2999,7 @@ const char *CallFrameInfo::KindName(EntryKind kind) {
|
||||
}
|
||||
}
|
||||
|
||||
bool CallFrameInfo::ReportIncomplete(Entry *entry) {
|
||||
bool CallFrameInfo::ReportIncomplete(Entry* entry) {
|
||||
reporter_->Incomplete(entry->offset, entry->kind);
|
||||
return false;
|
||||
}
|
||||
@@ -3058,7 +3058,7 @@ void CallFrameInfo::Reporter::UnrecognizedVersion(uint64_t offset, int version)
|
||||
}
|
||||
|
||||
void CallFrameInfo::Reporter::UnrecognizedAugmentation(uint64_t offset,
|
||||
const string &aug) {
|
||||
const string& aug) {
|
||||
fprintf(stderr,
|
||||
"%s: CFI frame description entry at offset 0x%" PRIx64 " in '%s':"
|
||||
" CIE specifies unrecognized augmentation: '%s'\n",
|
||||
|
||||
@@ -64,13 +64,13 @@ class DwpReader;
|
||||
|
||||
// This maps from a string naming a section to a pair containing a
|
||||
// the data for the section, and the size of the section.
|
||||
typedef std::map<string, std::pair<const uint8_t *, uint64_t> > SectionMap;
|
||||
typedef std::map<string, std::pair<const uint8_t*, uint64_t> > SectionMap;
|
||||
|
||||
// Abstract away the difference between elf and mach-o section names.
|
||||
// Elf-names use ".section_name, mach-o uses "__section_name". Pass "name" in
|
||||
// the elf form, ".section_name".
|
||||
const SectionMap::const_iterator GetSectionByName(const SectionMap&
|
||||
sections, const char *name);
|
||||
sections, const char* name);
|
||||
|
||||
typedef std::list<std::pair<enum DwarfAttribute, enum DwarfForm> >
|
||||
AttributeList;
|
||||
@@ -88,7 +88,7 @@ struct LineInfoHeader {
|
||||
uint8_t opcode_base;
|
||||
// Use a pointer so that signalsafe_addr2line is able to use this structure
|
||||
// without heap allocation problem.
|
||||
std::vector<unsigned char> *std_opcode_lengths;
|
||||
std::vector<unsigned char>* std_opcode_lengths;
|
||||
};
|
||||
|
||||
class LineInfo {
|
||||
@@ -125,12 +125,12 @@ class LineInfo {
|
||||
// lsm's old address < PC <= lsm's new address
|
||||
static bool ProcessOneOpcode(ByteReader* reader,
|
||||
LineInfoHandler* handler,
|
||||
const struct LineInfoHeader &header,
|
||||
const uint8_t *start,
|
||||
const struct LineInfoHeader& header,
|
||||
const uint8_t* start,
|
||||
struct LineStateMachine* lsm,
|
||||
size_t* len,
|
||||
uintptr pc,
|
||||
bool *lsm_passes_pc);
|
||||
bool* lsm_passes_pc);
|
||||
|
||||
private:
|
||||
// Reads the DWARF2/3 header for this line info.
|
||||
@@ -171,7 +171,7 @@ class LineInfo {
|
||||
// buffer is the buffer for our line info, starting at exactly where
|
||||
// the line info to read is. after_header is the place right after
|
||||
// the end of the line information header.
|
||||
const uint8_t *buffer_;
|
||||
const uint8_t* buffer_;
|
||||
#ifndef NDEBUG
|
||||
uint64_t buffer_length_;
|
||||
#endif
|
||||
@@ -182,7 +182,7 @@ class LineInfo {
|
||||
const uint8_t* line_string_buffer_;
|
||||
uint64_t line_string_buffer_length_;
|
||||
|
||||
const uint8_t *after_header_;
|
||||
const uint8_t* after_header_;
|
||||
};
|
||||
|
||||
// This class is the main interface between the line info reader and
|
||||
@@ -239,16 +239,16 @@ class RangeListHandler {
|
||||
|
||||
class RangeListReader {
|
||||
public:
|
||||
RangeListReader(const uint8_t *buffer, uint64_t size, ByteReader *reader,
|
||||
RangeListHandler *handler);
|
||||
RangeListReader(const uint8_t* buffer, uint64_t size, ByteReader* reader,
|
||||
RangeListHandler* handler);
|
||||
|
||||
bool ReadRangeList(uint64_t offset);
|
||||
|
||||
private:
|
||||
const uint8_t *buffer_;
|
||||
const uint8_t* buffer_;
|
||||
uint64_t size_;
|
||||
ByteReader* reader_;
|
||||
RangeListHandler *handler_;
|
||||
RangeListHandler* handler_;
|
||||
};
|
||||
|
||||
// This class is the main interface between the reader and the
|
||||
@@ -322,7 +322,7 @@ class Dwarf2Handler {
|
||||
virtual void ProcessAttributeBuffer(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const uint8_t *data,
|
||||
const uint8_t* data,
|
||||
uint64_t len) { }
|
||||
|
||||
// Called when we have an attribute with string data to give to our handler.
|
||||
@@ -461,14 +461,14 @@ class CompilationUnit {
|
||||
|
||||
// Processes a single DIE for this compilation unit and return a new
|
||||
// pointer just past the end of it
|
||||
const uint8_t *ProcessDIE(uint64_t dieoffset,
|
||||
const uint8_t *start,
|
||||
const uint8_t* ProcessDIE(uint64_t dieoffset,
|
||||
const uint8_t* start,
|
||||
const Abbrev& abbrev);
|
||||
|
||||
// Processes a single attribute and return a new pointer just past the
|
||||
// end of it
|
||||
const uint8_t *ProcessAttribute(uint64_t dieoffset,
|
||||
const uint8_t *start,
|
||||
const uint8_t* ProcessAttribute(uint64_t dieoffset,
|
||||
const uint8_t* start,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form);
|
||||
|
||||
@@ -564,11 +564,11 @@ class CompilationUnit {
|
||||
|
||||
// Skips the die with attributes specified in ABBREV starting at
|
||||
// START, and return the new place to position the stream to.
|
||||
const uint8_t *SkipDIE(const uint8_t *start, const Abbrev& abbrev);
|
||||
const uint8_t* SkipDIE(const uint8_t* start, const Abbrev& abbrev);
|
||||
|
||||
// Skips the attribute starting at START, with FORM, and return the
|
||||
// new place to position the stream to.
|
||||
const uint8_t *SkipAttribute(const uint8_t *start, enum DwarfForm form);
|
||||
const uint8_t* SkipAttribute(const uint8_t* start, enum DwarfForm form);
|
||||
|
||||
// Process the actual debug information in a split DWARF file.
|
||||
void ProcessSplitDwarf();
|
||||
@@ -587,9 +587,9 @@ class CompilationUnit {
|
||||
// buffer is the buffer for our CU, starting at .debug_info + offset
|
||||
// passed in from constructor.
|
||||
// after_header points to right after the compilation unit header.
|
||||
const uint8_t *buffer_;
|
||||
const uint8_t* buffer_;
|
||||
uint64_t buffer_length_;
|
||||
const uint8_t *after_header_;
|
||||
const uint8_t* after_header_;
|
||||
|
||||
// The associated ByteReader that handles endianness issues for us
|
||||
ByteReader* reader_;
|
||||
@@ -608,7 +608,7 @@ class CompilationUnit {
|
||||
// String section buffer and length, if we have a string section.
|
||||
// This is here to avoid doing a section lookup for strings in
|
||||
// ProcessAttribute, which is in the hot path for DWARF2 reading.
|
||||
const uint8_t *string_buffer_;
|
||||
const uint8_t* string_buffer_;
|
||||
uint64_t string_buffer_length_;
|
||||
|
||||
// Similarly for .debug_line_string.
|
||||
@@ -984,8 +984,8 @@ class CallFrameInfo {
|
||||
// The mechanics of C++ exception handling, personality routines,
|
||||
// and language-specific data areas are described here, rather nicely:
|
||||
// http://www.codesourcery.com/public/cxx-abi/abi-eh.html
|
||||
CallFrameInfo(const uint8_t *buffer, size_t buffer_length,
|
||||
ByteReader *reader, Handler *handler, Reporter *reporter,
|
||||
CallFrameInfo(const uint8_t* buffer, size_t buffer_length,
|
||||
ByteReader* reader, Handler* handler, Reporter* reporter,
|
||||
bool eh_frame = false)
|
||||
: buffer_(buffer), buffer_length_(buffer_length),
|
||||
reader_(reader), handler_(handler), reporter_(reporter),
|
||||
@@ -999,7 +999,7 @@ class CallFrameInfo {
|
||||
bool Start();
|
||||
|
||||
// Return the textual name of KIND. For error reporting.
|
||||
static const char *KindName(EntryKind kind);
|
||||
static const char* KindName(EntryKind kind);
|
||||
|
||||
private:
|
||||
|
||||
@@ -1012,7 +1012,7 @@ class CallFrameInfo {
|
||||
size_t offset;
|
||||
|
||||
// The start of this entry in the buffer.
|
||||
const uint8_t *start;
|
||||
const uint8_t* start;
|
||||
|
||||
// Which kind of entry this is.
|
||||
//
|
||||
@@ -1023,16 +1023,16 @@ class CallFrameInfo {
|
||||
|
||||
// The end of this entry's common prologue (initial length and id), and
|
||||
// the start of this entry's kind-specific fields.
|
||||
const uint8_t *fields;
|
||||
const uint8_t* fields;
|
||||
|
||||
// The start of this entry's instructions.
|
||||
const uint8_t *instructions;
|
||||
const uint8_t* instructions;
|
||||
|
||||
// The address past the entry's last byte in the buffer. (Note that
|
||||
// since offset points to the entry's initial length field, and the
|
||||
// length field is the number of bytes after that field, this is not
|
||||
// simply buffer_ + offset + length.)
|
||||
const uint8_t *end;
|
||||
const uint8_t* end;
|
||||
|
||||
// For both DWARF CFI and .eh_frame sections, this is the CIE id in a
|
||||
// CIE, and the offset of the associated CIE in an FDE.
|
||||
@@ -1040,7 +1040,7 @@ class CallFrameInfo {
|
||||
|
||||
// The CIE that applies to this entry, if we've parsed it. If this is a
|
||||
// CIE, then this field points to this structure.
|
||||
CIE *cie;
|
||||
CIE* cie;
|
||||
};
|
||||
|
||||
// A common information entry (CIE).
|
||||
@@ -1114,14 +1114,14 @@ class CallFrameInfo {
|
||||
// true. On failure, report the problem, and return false. Even if we
|
||||
// return false, set ENTRY->end to the first byte after the entry if we
|
||||
// were able to figure that out, or NULL if we weren't.
|
||||
bool ReadEntryPrologue(const uint8_t *cursor, Entry *entry);
|
||||
bool ReadEntryPrologue(const uint8_t* cursor, Entry* entry);
|
||||
|
||||
// Parse the fields of a CIE after the entry prologue, including any 'z'
|
||||
// augmentation data. Assume that the 'Entry' fields of CIE are
|
||||
// populated; use CIE->fields and CIE->end as the start and limit for
|
||||
// parsing. On success, populate the rest of *CIE, and return true; on
|
||||
// failure, report the problem and return false.
|
||||
bool ReadCIEFields(CIE *cie);
|
||||
bool ReadCIEFields(CIE* cie);
|
||||
|
||||
// Parse the fields of an FDE after the entry prologue, including any 'z'
|
||||
// augmentation data. Assume that the 'Entry' fields of *FDE are
|
||||
@@ -1129,12 +1129,12 @@ class CallFrameInfo {
|
||||
// parsing. Assume that FDE->cie is fully initialized. On success,
|
||||
// populate the rest of *FDE, and return true; on failure, report the
|
||||
// problem and return false.
|
||||
bool ReadFDEFields(FDE *fde);
|
||||
bool ReadFDEFields(FDE* fde);
|
||||
|
||||
// Report that ENTRY is incomplete, and return false. This is just a
|
||||
// trivial wrapper for invoking reporter_->Incomplete; it provides a
|
||||
// little brevity.
|
||||
bool ReportIncomplete(Entry *entry);
|
||||
bool ReportIncomplete(Entry* entry);
|
||||
|
||||
// Return true if ENCODING has the DW_EH_PE_indirect bit set.
|
||||
static bool IsIndirectEncoding(DwarfPointerEncoding encoding) {
|
||||
@@ -1142,17 +1142,17 @@ class CallFrameInfo {
|
||||
}
|
||||
|
||||
// The contents of the DWARF .debug_info section we're parsing.
|
||||
const uint8_t *buffer_;
|
||||
const uint8_t* buffer_;
|
||||
size_t buffer_length_;
|
||||
|
||||
// For reading multi-byte values with the appropriate endianness.
|
||||
ByteReader *reader_;
|
||||
ByteReader* reader_;
|
||||
|
||||
// The handler to which we should report the data we find.
|
||||
Handler *handler_;
|
||||
Handler* handler_;
|
||||
|
||||
// For reporting problems in the info we're parsing.
|
||||
Reporter *reporter_;
|
||||
Reporter* reporter_;
|
||||
|
||||
// True if we are processing .eh_frame-format data.
|
||||
bool eh_frame_;
|
||||
@@ -1185,7 +1185,7 @@ class CallFrameInfo::Handler {
|
||||
// process a given FDE, the parser reiterates the appropriate CIE's
|
||||
// contents at the beginning of the FDE's rules.
|
||||
virtual bool Entry(size_t offset, uint64_t address, uint64_t length,
|
||||
uint8_t version, const string &augmentation,
|
||||
uint8_t version, const string& augmentation,
|
||||
unsigned return_address) = 0;
|
||||
|
||||
// When the Entry function returns true, the parser calls these
|
||||
@@ -1234,13 +1234,13 @@ class CallFrameInfo::Handler {
|
||||
// At ADDRESS, the DWARF expression EXPRESSION yields the address at
|
||||
// which REG was saved.
|
||||
virtual bool ExpressionRule(uint64_t address, int reg,
|
||||
const string &expression) = 0;
|
||||
const string& expression) = 0;
|
||||
|
||||
// At ADDRESS, the DWARF expression EXPRESSION yields the caller's
|
||||
// value for REG. (This rule doesn't provide an address at which the
|
||||
// register's value is saved.)
|
||||
virtual bool ValExpressionRule(uint64_t address, int reg,
|
||||
const string &expression) = 0;
|
||||
const string& expression) = 0;
|
||||
|
||||
// Indicate that the rules for the address range reported by the
|
||||
// last call to Entry are complete. End should return true if
|
||||
@@ -1317,8 +1317,8 @@ class CallFrameInfo::Reporter {
|
||||
// in a Mach-O section named __debug_frame. If we support
|
||||
// Linux-style exception handling data, we could be reading an
|
||||
// .eh_frame section.
|
||||
Reporter(const string &filename,
|
||||
const string §ion = ".debug_frame")
|
||||
Reporter(const string& filename,
|
||||
const string& section = ".debug_frame")
|
||||
: filename_(filename), section_(section) { }
|
||||
virtual ~Reporter() { }
|
||||
|
||||
@@ -1358,7 +1358,7 @@ class CallFrameInfo::Reporter {
|
||||
// which we don't recognize. We cannot parse DWARF CFI if it uses
|
||||
// augmentations we don't recognize.
|
||||
virtual void UnrecognizedAugmentation(uint64_t offset,
|
||||
const string &augmentation);
|
||||
const string& augmentation);
|
||||
|
||||
// The pointer encoding ENCODING, specified by the CIE at OFFSET, is not
|
||||
// a valid encoding.
|
||||
|
||||
@@ -87,7 +87,7 @@ using testing::_;
|
||||
|
||||
#ifdef WRITE_ELF
|
||||
void WriteELFFrameSection(const char *filename, const char *section_name,
|
||||
const CFISection §ion);
|
||||
const CFISection& section);
|
||||
#define PERHAPS_WRITE_DEBUG_FRAME_FILE(name, section) \
|
||||
WriteELFFrameSection("cfitest-" name, ".debug_frame", section);
|
||||
#define PERHAPS_WRITE_EH_FRAME_FILE(name, section) \
|
||||
@@ -100,7 +100,7 @@ void WriteELFFrameSection(const char *filename, const char *section_name,
|
||||
class MockCallFrameInfoHandler: public CallFrameInfo::Handler {
|
||||
public:
|
||||
MOCK_METHOD6(Entry, bool(size_t offset, uint64_t address, uint64_t length,
|
||||
uint8_t version, const string &augmentation,
|
||||
uint8_t version, const string& augmentation,
|
||||
unsigned return_address));
|
||||
MOCK_METHOD2(UndefinedRule, bool(uint64_t address, int reg));
|
||||
MOCK_METHOD2(SameValueRule, bool(uint64_t address, int reg));
|
||||
@@ -110,9 +110,9 @@ class MockCallFrameInfoHandler: public CallFrameInfo::Handler {
|
||||
long offset));
|
||||
MOCK_METHOD3(RegisterRule, bool(uint64_t address, int reg, int base_register));
|
||||
MOCK_METHOD3(ExpressionRule, bool(uint64_t address, int reg,
|
||||
const string &expression));
|
||||
const string& expression));
|
||||
MOCK_METHOD3(ValExpressionRule, bool(uint64_t address, int reg,
|
||||
const string &expression));
|
||||
const string& expression));
|
||||
MOCK_METHOD0(End, bool());
|
||||
MOCK_METHOD2(PersonalityRoutine, bool(uint64_t address, bool indirect));
|
||||
MOCK_METHOD2(LanguageSpecificDataArea, bool(uint64_t address, bool indirect));
|
||||
@@ -129,7 +129,7 @@ class MockCallFrameErrorReporter: public CallFrameInfo::Reporter {
|
||||
MOCK_METHOD2(UnexpectedAddressSize, void(uint64_t, uint8_t));
|
||||
MOCK_METHOD2(UnexpectedSegmentSize, void(uint64_t, uint8_t));
|
||||
MOCK_METHOD2(UnrecognizedVersion, void(uint64_t, int version));
|
||||
MOCK_METHOD2(UnrecognizedAugmentation, void(uint64_t, const string &));
|
||||
MOCK_METHOD2(UnrecognizedAugmentation, void(uint64_t, const string&));
|
||||
MOCK_METHOD2(InvalidPointerEncoding, void(uint64_t, uint8_t));
|
||||
MOCK_METHOD2(UnusablePointerEncoding, void(uint64_t, uint8_t));
|
||||
MOCK_METHOD2(RestoreInCIE, void(uint64_t, uint64_t));
|
||||
@@ -218,7 +218,7 @@ TEST_F(CFI, IncompleteLength32) {
|
||||
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(8);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size() - 2,
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
@@ -244,7 +244,7 @@ TEST_F(CFI, IncompleteLength64) {
|
||||
|
||||
ByteReader byte_reader(ENDIANNESS_LITTLE);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size() - 4,
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
@@ -269,7 +269,7 @@ TEST_F(CFI, IncompleteId32) {
|
||||
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(8);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
@@ -296,7 +296,7 @@ TEST_F(CFI, BadId32) {
|
||||
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(8);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
@@ -318,7 +318,7 @@ TEST_F(CFI, SingleCIE) {
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_LITTLE);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
@@ -349,7 +349,7 @@ TEST_F(CFI, OneFDE) {
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
@@ -393,7 +393,7 @@ TEST_F(CFI, TwoFDEsOneCIE) {
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
@@ -443,7 +443,7 @@ TEST_F(CFI, TwoFDEsTwoCIEs) {
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_LITTLE);
|
||||
byte_reader.SetAddressSize(8);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
@@ -488,7 +488,7 @@ TEST_F(CFI, BadVersion) {
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
@@ -533,7 +533,7 @@ TEST_F(CFI, BadAugmentation) {
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
@@ -568,7 +568,7 @@ TEST_F(CFI, CIEVersion1ReturnColumn) {
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
@@ -603,7 +603,7 @@ TEST_F(CFI, CIEVersion3ReturnColumn) {
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
byte_reader.SetAddressSize(4);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
@@ -633,7 +633,7 @@ TEST_F(CFI, CIEVersion4AdditionalFields) {
|
||||
string contents;
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
@@ -663,7 +663,7 @@ TEST_F(CFI, CIEVersion4AdditionalFields32BitAddress) {
|
||||
string contents;
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_TRUE(parser.Start());
|
||||
@@ -690,7 +690,7 @@ TEST_F(CFI, CIEVersion4AdditionalFieldsUnexpectedAddressSize) {
|
||||
string contents;
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
@@ -715,7 +715,7 @@ TEST_F(CFI, CIEVersion4AdditionalFieldsUnexpectedSegmentSize) {
|
||||
string contents;
|
||||
EXPECT_TRUE(section.GetContents(&contents));
|
||||
ByteReader byte_reader(ENDIANNESS_BIG);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
EXPECT_FALSE(parser.Start());
|
||||
@@ -797,7 +797,7 @@ struct CFIInsnFixture: public CFIFixture {
|
||||
}
|
||||
ByteReader byte_reader(endianness);
|
||||
byte_reader.SetAddressSize(section->AddressSize());
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter);
|
||||
if (succeeds)
|
||||
@@ -2120,10 +2120,10 @@ struct EHFrameFixture: public CFIInsnFixture {
|
||||
ByteReader byte_reader(endianness);
|
||||
byte_reader.SetAddressSize(section->AddressSize());
|
||||
byte_reader.SetCFIDataBase(encoded_pointer_bases.cfi,
|
||||
reinterpret_cast<const uint8_t *>(contents.data()));
|
||||
reinterpret_cast<const uint8_t*>(contents.data()));
|
||||
byte_reader.SetTextBase(encoded_pointer_bases.text);
|
||||
byte_reader.SetDataBase(encoded_pointer_bases.data);
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()),
|
||||
CallFrameInfo parser(reinterpret_cast<const uint8_t*>(contents.data()),
|
||||
contents.size(),
|
||||
&byte_reader, &handler, &reporter, true);
|
||||
if (succeeds)
|
||||
@@ -2468,7 +2468,7 @@ struct ELFSectionHeader {
|
||||
uint64_t entry_size;
|
||||
};
|
||||
|
||||
void AppendSectionHeader(CFISection *table, const ELFSectionHeader &header) {
|
||||
void AppendSectionHeader(CFISection* table, const ELFSectionHeader& header) {
|
||||
(*table)
|
||||
.D32(header.name) // name, index in string tbl
|
||||
.D32(header.type) // type
|
||||
@@ -2483,7 +2483,7 @@ void AppendSectionHeader(CFISection *table, const ELFSectionHeader &header) {
|
||||
}
|
||||
|
||||
void WriteELFFrameSection(const char *filename, const char *cfi_name,
|
||||
const CFISection &cfi) {
|
||||
const CFISection& cfi) {
|
||||
int elf_class = cfi.AddressSize() == 4 ? ELFCLASS32 : ELFCLASS64;
|
||||
int elf_data = (cfi.endianness() == kBigEndian
|
||||
? ELFDATA2MSB : ELFDATA2LSB);
|
||||
|
||||
@@ -93,7 +93,7 @@ class MockDwarf2Handler: public Dwarf2Handler {
|
||||
MOCK_METHOD5(ProcessAttributeBuffer, void(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const uint8_t *data,
|
||||
const uint8_t* data,
|
||||
uint64_t len));
|
||||
MOCK_METHOD4(ProcessAttributeString, void(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
@@ -128,17 +128,17 @@ struct DIEFixture {
|
||||
// to |info|, and whose .debug_abbrev section refers to |abbrevs|. This
|
||||
// function returns a reference to the same SectionMap each time; new
|
||||
// calls wipe out maps established by earlier calls.
|
||||
const SectionMap &MakeSectionMap() {
|
||||
const SectionMap& MakeSectionMap() {
|
||||
// Copy the sections' contents into strings that will live as long as
|
||||
// the map itself.
|
||||
assert(info.GetContents(&info_contents));
|
||||
assert(abbrevs.GetContents(&abbrevs_contents));
|
||||
section_map.clear();
|
||||
section_map[".debug_info"].first
|
||||
= reinterpret_cast<const uint8_t *>(info_contents.data());
|
||||
= reinterpret_cast<const uint8_t*>(info_contents.data());
|
||||
section_map[".debug_info"].second = info_contents.size();
|
||||
section_map[".debug_abbrev"].first
|
||||
= reinterpret_cast<const uint8_t *>(abbrevs_contents.data());
|
||||
= reinterpret_cast<const uint8_t*>(abbrevs_contents.data());
|
||||
section_map[".debug_abbrev"].second = abbrevs_contents.size();
|
||||
return section_map;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ struct DwarfFormsFixture: public DIEFixture {
|
||||
// childless DIE of the given tag, with one attribute of the given name
|
||||
// and form. The 'info' fixture member is left just after the abbrev
|
||||
// code, waiting for the attribute value to be appended.
|
||||
void StartSingleAttributeDIE(const DwarfHeaderParams ¶ms,
|
||||
void StartSingleAttributeDIE(const DwarfHeaderParams& params,
|
||||
DwarfTag tag, DwarfAttribute name,
|
||||
DwarfForm form) {
|
||||
// Create the abbreviation table.
|
||||
@@ -260,7 +260,7 @@ struct DwarfFormsFixture: public DIEFixture {
|
||||
// Set up handler to expect a compilation unit matching |params|,
|
||||
// containing one childless DIE of the given tag, in the sequence s. Stop
|
||||
// just before the expectations.
|
||||
void ExpectBeginCompilationUnit(const DwarfHeaderParams ¶ms,
|
||||
void ExpectBeginCompilationUnit(const DwarfHeaderParams& params,
|
||||
DwarfTag tag, uint64_t offset=0) {
|
||||
EXPECT_CALL(handler,
|
||||
StartCompilationUnit(offset, params.address_size,
|
||||
@@ -279,7 +279,7 @@ struct DwarfFormsFixture: public DIEFixture {
|
||||
.WillOnce(Return());
|
||||
}
|
||||
|
||||
void ParseCompilationUnit(const DwarfHeaderParams ¶ms,
|
||||
void ParseCompilationUnit(const DwarfHeaderParams& params,
|
||||
uint64_t offset=0) {
|
||||
ByteReader byte_reader(params.endianness == kLittleEndian ?
|
||||
ENDIANNESS_LITTLE : ENDIANNESS_BIG);
|
||||
|
||||
@@ -70,7 +70,7 @@ class TestCompilationUnit: public google_breakpad::test_assembler::Section {
|
||||
|
||||
// Append a DWARF compilation unit header to the section, with the given
|
||||
// DWARF version, abbrev table offset, and address size.
|
||||
TestCompilationUnit &Header(int version, const Label &abbrev_offset,
|
||||
TestCompilationUnit& Header(int version, const Label& abbrev_offset,
|
||||
size_t address_size) {
|
||||
if (format_size_ == 4) {
|
||||
D32(length_);
|
||||
@@ -92,7 +92,7 @@ class TestCompilationUnit: public google_breakpad::test_assembler::Section {
|
||||
}
|
||||
|
||||
// Mark the end of this header's DIEs.
|
||||
TestCompilationUnit &Finish() {
|
||||
TestCompilationUnit& Finish() {
|
||||
length_ = Size() - post_length_offset_;
|
||||
return *this;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class TestAbbrevTable: public google_breakpad::test_assembler::Section {
|
||||
// Start a new abbreviation table entry for abbreviation code |code|,
|
||||
// encoding a DIE whose tag is |tag|, and which has children if and only
|
||||
// if |has_children| is true.
|
||||
TestAbbrevTable &Abbrev(int code, DwarfTag tag, DwarfHasChild has_children) {
|
||||
TestAbbrevTable& Abbrev(int code, DwarfTag tag, DwarfHasChild has_children) {
|
||||
assert(code != 0);
|
||||
ULEB128(code);
|
||||
ULEB128(static_cast<unsigned>(tag));
|
||||
@@ -132,21 +132,21 @@ class TestAbbrevTable: public google_breakpad::test_assembler::Section {
|
||||
|
||||
// Add an attribute to the current abbreviation code whose name is |name|
|
||||
// and whose form is |form|.
|
||||
TestAbbrevTable &Attribute(DwarfAttribute name, DwarfForm form) {
|
||||
TestAbbrevTable& Attribute(DwarfAttribute name, DwarfForm form) {
|
||||
ULEB128(static_cast<unsigned>(name));
|
||||
ULEB128(static_cast<unsigned>(form));
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Finish the current abbreviation code.
|
||||
TestAbbrevTable &EndAbbrev() {
|
||||
TestAbbrevTable& EndAbbrev() {
|
||||
ULEB128(0);
|
||||
ULEB128(0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Finish the current abbreviation table.
|
||||
TestAbbrevTable &EndTable() {
|
||||
TestAbbrevTable& EndTable() {
|
||||
ULEB128(0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -130,11 +130,11 @@ class Elf32 {
|
||||
static const int kElfClass = ELFCLASS32;
|
||||
|
||||
// Given a symbol pointer, return the binding type (eg STB_WEAK).
|
||||
static char Bind(const Elf32_Sym *sym) {
|
||||
static char Bind(const Elf32_Sym* sym) {
|
||||
return ELF32_ST_BIND(sym->st_info);
|
||||
}
|
||||
// Given a symbol pointer, return the symbol type (eg STT_FUNC).
|
||||
static char Type(const Elf32_Sym *sym) {
|
||||
static char Type(const Elf32_Sym* sym) {
|
||||
return ELF32_ST_TYPE(sym->st_info);
|
||||
}
|
||||
|
||||
@@ -158,10 +158,10 @@ class Elf64 {
|
||||
// What should be in the EI_CLASS header.
|
||||
static const int kElfClass = ELFCLASS64;
|
||||
|
||||
static char Bind(const Elf64_Sym *sym) {
|
||||
static char Bind(const Elf64_Sym* sym) {
|
||||
return ELF64_ST_BIND(sym->st_info);
|
||||
}
|
||||
static char Type(const Elf64_Sym *sym) {
|
||||
static char Type(const Elf64_Sym* sym) {
|
||||
return ELF64_ST_TYPE(sym->st_info);
|
||||
}
|
||||
static int r_sym(const Elf64_Xword r_info) {
|
||||
@@ -182,8 +182,8 @@ class Elf64 {
|
||||
template<class ElfArch>
|
||||
class ElfSectionReader {
|
||||
public:
|
||||
ElfSectionReader(const char *name, const string &path, int fd,
|
||||
const typename ElfArch::Shdr §ion_header)
|
||||
ElfSectionReader(const char* name, const string& path, int fd,
|
||||
const typename ElfArch::Shdr& section_header)
|
||||
: contents_aligned_(NULL),
|
||||
contents_(NULL),
|
||||
header_(section_header) {
|
||||
@@ -199,7 +199,7 @@ class ElfSectionReader {
|
||||
contents_aligned_ = mmap(NULL, size_aligned_, PROT_READ, MAP_SHARED,
|
||||
fd, offset_aligned);
|
||||
// Set where the offset really should begin.
|
||||
contents_ = reinterpret_cast<char *>(contents_aligned_) +
|
||||
contents_ = reinterpret_cast<char*>(contents_aligned_) +
|
||||
(header_.sh_offset - offset_aligned);
|
||||
|
||||
// Check for and handle any compressed contents.
|
||||
@@ -217,24 +217,24 @@ class ElfSectionReader {
|
||||
}
|
||||
|
||||
// Return the section header for this section.
|
||||
typename ElfArch::Shdr const &header() const { return header_; }
|
||||
typename ElfArch::Shdr const& header() const { return header_; }
|
||||
|
||||
// Return memory at the given offset within this section.
|
||||
const char *GetOffset(typename ElfArch::Word bytes) const {
|
||||
const char* GetOffset(typename ElfArch::Word bytes) const {
|
||||
return contents_ + bytes;
|
||||
}
|
||||
|
||||
const char *contents() const { return contents_; }
|
||||
const char* contents() const { return contents_; }
|
||||
size_t section_size() const { return section_size_; }
|
||||
|
||||
private:
|
||||
// page-aligned file contents
|
||||
void *contents_aligned_;
|
||||
void* contents_aligned_;
|
||||
// contents as usable by the client. For non-compressed sections,
|
||||
// pointer within contents_aligned_ to where the section data
|
||||
// begins; for compressed sections, pointer to the decompressed
|
||||
// data.
|
||||
char *contents_;
|
||||
char* contents_;
|
||||
// size of contents_aligned_
|
||||
size_t size_aligned_;
|
||||
// size of contents.
|
||||
@@ -249,7 +249,7 @@ class ElfSectionReader {
|
||||
template<class ElfArch>
|
||||
class SymbolIterator {
|
||||
public:
|
||||
SymbolIterator(ElfReaderImpl<ElfArch> *reader,
|
||||
SymbolIterator(ElfReaderImpl<ElfArch>* reader,
|
||||
typename ElfArch::Word section_type)
|
||||
: symbol_section_(reader->GetSectionByType(section_type)),
|
||||
string_section_(NULL),
|
||||
@@ -280,7 +280,7 @@ class SymbolIterator {
|
||||
|
||||
// Return a pointer to the current symbol.
|
||||
// REQUIRES: !done()
|
||||
const typename ElfArch::Sym *GetSymbol() const {
|
||||
const typename ElfArch::Sym* GetSymbol() const {
|
||||
return reinterpret_cast<const typename ElfArch::Sym*>(
|
||||
symbol_section_->GetOffset(symbol_within_section_ *
|
||||
symbol_section_->header().sh_entsize));
|
||||
@@ -288,7 +288,7 @@ class SymbolIterator {
|
||||
|
||||
// Return the name of the current symbol, NULL if it has none.
|
||||
// REQUIRES: !done()
|
||||
const char *GetSymbolName() const {
|
||||
const char* GetSymbolName() const {
|
||||
int name_offset = GetSymbol()->st_name;
|
||||
if (name_offset == 0)
|
||||
return NULL;
|
||||
@@ -300,8 +300,8 @@ class SymbolIterator {
|
||||
}
|
||||
|
||||
private:
|
||||
const ElfSectionReader<ElfArch> *const symbol_section_;
|
||||
const ElfSectionReader<ElfArch> *string_section_;
|
||||
const ElfSectionReader<ElfArch>* const symbol_section_;
|
||||
const ElfSectionReader<ElfArch>* string_section_;
|
||||
int num_symbols_in_section_;
|
||||
int symbol_within_section_;
|
||||
};
|
||||
@@ -326,7 +326,7 @@ static inline bool MyHasSuffixString(const string& str, const string& suffix) {
|
||||
template<class ElfArch>
|
||||
class ElfReaderImpl {
|
||||
public:
|
||||
explicit ElfReaderImpl(const string &path, int fd)
|
||||
explicit ElfReaderImpl(const string& path, int fd)
|
||||
: path_(path),
|
||||
fd_(fd),
|
||||
section_headers_(NULL),
|
||||
@@ -347,7 +347,7 @@ class ElfReaderImpl {
|
||||
// "opd_section_" must always be checked for NULL before use.
|
||||
opd_section_ = GetSectionInfoByName(".opd", &opd_info_);
|
||||
for (unsigned int k = 0u; k < GetNumSections(); ++k) {
|
||||
const char *name = GetSectionName(section_headers_[k].sh_name);
|
||||
const char* name = GetSectionName(section_headers_[k].sh_name);
|
||||
if (strncmp(name, ".text", strlen(".text")) == 0) {
|
||||
base_for_text_ =
|
||||
section_headers_[k].sh_addr - section_headers_[k].sh_offset;
|
||||
@@ -384,7 +384,7 @@ class ElfReaderImpl {
|
||||
// to see if the ELF file appears to match the current
|
||||
// architecture. If error is non-NULL, it will be set with a reason
|
||||
// in case of failure.
|
||||
static bool IsArchElfFile(int fd, string *error) {
|
||||
static bool IsArchElfFile(int fd, string* error) {
|
||||
unsigned char header[EI_NIDENT];
|
||||
if (pread(fd, header, sizeof(header), 0) != sizeof(header)) {
|
||||
if (error != NULL) *error = "Could not read header";
|
||||
@@ -415,7 +415,7 @@ class ElfReaderImpl {
|
||||
}
|
||||
|
||||
// Return true if we can use this symbol in Address-to-Symbol map.
|
||||
bool CanUseSymbol(const char *name, const typename ElfArch::Sym *sym) {
|
||||
bool CanUseSymbol(const char* name, const typename ElfArch::Sym* sym) {
|
||||
// For now we only save FUNC and NOTYPE symbols. For now we just
|
||||
// care about functions, but some functions written in assembler
|
||||
// don't have a proper ELF type attached to them, so we store
|
||||
@@ -444,7 +444,7 @@ class ElfReaderImpl {
|
||||
// Iterate over the symbols in a section, either SHT_DYNSYM or
|
||||
// SHT_SYMTAB. Add all symbols to the given SymbolMap.
|
||||
/*
|
||||
void GetSymbolPositions(SymbolMap *symbols,
|
||||
void GetSymbolPositions(SymbolMap* symbols,
|
||||
typename ElfArch::Word section_type,
|
||||
uint64_t mem_offset,
|
||||
uint64_t file_offset) {
|
||||
@@ -453,10 +453,10 @@ class ElfReaderImpl {
|
||||
AddrToSymMap addr_to_sym_map;
|
||||
for (SymbolIterator<ElfArch> it(this, section_type);
|
||||
!it.done(); it.Next()) {
|
||||
const char *name = it.GetSymbolName();
|
||||
const char* name = it.GetSymbolName();
|
||||
if (name == NULL)
|
||||
continue;
|
||||
const typename ElfArch::Sym *sym = it.GetSymbol();
|
||||
const typename ElfArch::Sym* sym = it.GetSymbol();
|
||||
if (CanUseSymbol(name, sym)) {
|
||||
const int sec = sym->st_shndx;
|
||||
|
||||
@@ -519,9 +519,9 @@ class ElfReaderImpl {
|
||||
if (addr_to_sym_map.empty()) {
|
||||
return;
|
||||
}
|
||||
const ElfSectionReader<ElfArch> *const symbol_section =
|
||||
const ElfSectionReader<ElfArch>* const symbol_section =
|
||||
this->GetSectionByType(section_type);
|
||||
const ElfSectionReader<ElfArch> *const string_section =
|
||||
const ElfSectionReader<ElfArch>* const string_section =
|
||||
this->GetSection(symbol_section->header().sh_link);
|
||||
|
||||
typename AddrToSymMap::iterator curr = addr_to_sym_map.begin();
|
||||
@@ -532,8 +532,8 @@ class ElfReaderImpl {
|
||||
for (; curr != addr_to_sym_map.end(); ++curr) {
|
||||
const uint64_t prev_addr = prev->first;
|
||||
const uint64_t curr_addr = curr->first;
|
||||
const typename ElfArch::Sym *const prev_sym = prev->second;
|
||||
const typename ElfArch::Sym *const curr_sym = curr->second;
|
||||
const typename ElfArch::Sym* const prev_sym = prev->second;
|
||||
const typename ElfArch::Sym* const curr_sym = curr->second;
|
||||
if (prev_addr + prev_sym->st_size <= curr_addr ||
|
||||
// The next condition is true if two symbols overlap like this:
|
||||
//
|
||||
@@ -552,7 +552,7 @@ class ElfReaderImpl {
|
||||
// (e.g. 0619e071) will produce the current symbol,
|
||||
// which is the desired outcome.
|
||||
prev_addr + prev_sym->st_size < curr_addr + curr_sym->st_size) {
|
||||
const char *name = string_section->GetOffset(curr_sym->st_name);
|
||||
const char* name = string_section->GetOffset(curr_sym->st_name);
|
||||
symbols->AddSymbol(name, curr_addr, curr_sym->st_size);
|
||||
prev = curr;
|
||||
} else {
|
||||
@@ -572,20 +572,20 @@ class ElfReaderImpl {
|
||||
*/
|
||||
|
||||
void VisitSymbols(typename ElfArch::Word section_type,
|
||||
ElfReader::SymbolSink *sink) {
|
||||
ElfReader::SymbolSink* sink) {
|
||||
VisitSymbols(section_type, sink, -1, -1, false);
|
||||
}
|
||||
|
||||
void VisitSymbols(typename ElfArch::Word section_type,
|
||||
ElfReader::SymbolSink *sink,
|
||||
ElfReader::SymbolSink* sink,
|
||||
int symbol_binding,
|
||||
int symbol_type,
|
||||
bool get_raw_symbol_values) {
|
||||
for (SymbolIterator<ElfArch> it(this, section_type);
|
||||
!it.done(); it.Next()) {
|
||||
const char *name = it.GetSymbolName();
|
||||
const char* name = it.GetSymbolName();
|
||||
if (!name) continue;
|
||||
const typename ElfArch::Sym *sym = it.GetSymbol();
|
||||
const typename ElfArch::Sym* sym = it.GetSymbol();
|
||||
if ((symbol_binding < 0 || ElfArch::Bind(sym) == symbol_binding) &&
|
||||
(symbol_type < 0 || ElfArch::Type(sym) == symbol_type)) {
|
||||
typename ElfArch::Sym symbol = *sym;
|
||||
@@ -691,7 +691,7 @@ class ElfReaderImpl {
|
||||
// Return an ElfSectionReader for the first section of the given
|
||||
// type by iterating through all section headers. Returns NULL if
|
||||
// the section type is not found.
|
||||
const ElfSectionReader<ElfArch> *GetSectionByType(
|
||||
const ElfSectionReader<ElfArch>* GetSectionByType(
|
||||
typename ElfArch::Word section_type) {
|
||||
for (unsigned int k = 0u; k < GetNumSections(); ++k) {
|
||||
if (section_headers_[k].sh_type == section_type) {
|
||||
@@ -703,14 +703,14 @@ class ElfReaderImpl {
|
||||
|
||||
// Return the name of section "shndx". Returns NULL if the section
|
||||
// is not found.
|
||||
const char *GetSectionNameByIndex(int shndx) {
|
||||
const char* GetSectionNameByIndex(int shndx) {
|
||||
return GetSectionName(section_headers_[shndx].sh_name);
|
||||
}
|
||||
|
||||
// Return a pointer to section "shndx", and store the size in
|
||||
// "size". Returns NULL if the section is not found.
|
||||
const char *GetSectionContentsByIndex(int shndx, size_t *size) {
|
||||
const ElfSectionReader<ElfArch> *section = GetSection(shndx);
|
||||
const char* GetSectionContentsByIndex(int shndx, size_t* size) {
|
||||
const ElfSectionReader<ElfArch>* section = GetSection(shndx);
|
||||
if (section != NULL) {
|
||||
*size = section->section_size();
|
||||
return section->contents();
|
||||
@@ -721,16 +721,16 @@ class ElfReaderImpl {
|
||||
// Return a pointer to the first section of the given name by
|
||||
// iterating through all section headers, and store the size in
|
||||
// "size". Returns NULL if the section name is not found.
|
||||
const char *GetSectionContentsByName(const string §ion_name,
|
||||
size_t *size) {
|
||||
const char* GetSectionContentsByName(const string& section_name,
|
||||
size_t* size) {
|
||||
for (unsigned int k = 0u; k < GetNumSections(); ++k) {
|
||||
// When searching for sections in a .dwp file, the sections
|
||||
// we're looking for will always be at the end of the section
|
||||
// table, so reverse the direction of iteration.
|
||||
int shndx = is_dwp_ ? GetNumSections() - k - 1 : k;
|
||||
const char *name = GetSectionName(section_headers_[shndx].sh_name);
|
||||
const char* name = GetSectionName(section_headers_[shndx].sh_name);
|
||||
if (name != NULL && ElfReader::SectionNamesMatch(section_name, name)) {
|
||||
const ElfSectionReader<ElfArch> *section = GetSection(shndx);
|
||||
const ElfSectionReader<ElfArch>* section = GetSection(shndx);
|
||||
if (section == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
@@ -744,16 +744,16 @@ class ElfReaderImpl {
|
||||
|
||||
// This is like GetSectionContentsByName() but it returns a lot of extra
|
||||
// information about the section.
|
||||
const char *GetSectionInfoByName(const string §ion_name,
|
||||
ElfReader::SectionInfo *info) {
|
||||
const char* GetSectionInfoByName(const string& section_name,
|
||||
ElfReader::SectionInfo* info) {
|
||||
for (unsigned int k = 0u; k < GetNumSections(); ++k) {
|
||||
// When searching for sections in a .dwp file, the sections
|
||||
// we're looking for will always be at the end of the section
|
||||
// table, so reverse the direction of iteration.
|
||||
int shndx = is_dwp_ ? GetNumSections() - k - 1 : k;
|
||||
const char *name = GetSectionName(section_headers_[shndx].sh_name);
|
||||
const char* name = GetSectionName(section_headers_[shndx].sh_name);
|
||||
if (name != NULL && ElfReader::SectionNamesMatch(section_name, name)) {
|
||||
const ElfSectionReader<ElfArch> *section = GetSection(shndx);
|
||||
const ElfSectionReader<ElfArch>* section = GetSection(shndx);
|
||||
if (section == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
@@ -797,7 +797,7 @@ class ElfReaderImpl {
|
||||
// Debug sections are likely to be near the end, so reverse the
|
||||
// direction of iteration.
|
||||
for (int k = GetNumSections() - 1; k >= 0; --k) {
|
||||
const char *name = GetSectionName(section_headers_[k].sh_name);
|
||||
const char* name = GetSectionName(section_headers_[k].sh_name);
|
||||
if (strncmp(name, ".debug", strlen(".debug")) == 0) return true;
|
||||
if (strncmp(name, ".zdebug", strlen(".zdebug")) == 0) return true;
|
||||
}
|
||||
@@ -816,7 +816,7 @@ class ElfReaderImpl {
|
||||
}
|
||||
|
||||
private:
|
||||
typedef vector<pair<uint64_t, const typename ElfArch::Sym *> > AddrToSymMap;
|
||||
typedef vector<pair<uint64_t, const typename ElfArch::Sym*> > AddrToSymMap;
|
||||
|
||||
static bool AddrToSymSorter(const typename AddrToSymMap::value_type& lhs,
|
||||
const typename AddrToSymMap::value_type& rhs) {
|
||||
@@ -854,8 +854,8 @@ class ElfReaderImpl {
|
||||
|
||||
// Given an offset into the section header string table, return the
|
||||
// section name.
|
||||
const char *GetSectionName(typename ElfArch::Word sh_name) {
|
||||
const ElfSectionReader<ElfArch> *shstrtab =
|
||||
const char* GetSectionName(typename ElfArch::Word sh_name) {
|
||||
const ElfSectionReader<ElfArch>* shstrtab =
|
||||
GetSection(GetStringTableIndex());
|
||||
if (shstrtab != NULL) {
|
||||
return shstrtab->GetOffset(sh_name);
|
||||
@@ -865,15 +865,15 @@ class ElfReaderImpl {
|
||||
|
||||
// Return an ElfSectionReader for the given section. The reader will
|
||||
// be freed when this object is destroyed.
|
||||
const ElfSectionReader<ElfArch> *GetSection(int num) {
|
||||
const char *name;
|
||||
const ElfSectionReader<ElfArch>* GetSection(int num) {
|
||||
const char* name;
|
||||
// Hard-coding the name for the section-name string table prevents
|
||||
// infinite recursion.
|
||||
if (num == GetStringTableIndex())
|
||||
name = ".shstrtab";
|
||||
else
|
||||
name = GetSectionNameByIndex(num);
|
||||
ElfSectionReader<ElfArch> *& reader = sections_[num];
|
||||
ElfSectionReader<ElfArch>*& reader = sections_[num];
|
||||
if (reader == NULL)
|
||||
reader = new ElfSectionReader<ElfArch>(name, path_, fd_,
|
||||
section_headers_[num]);
|
||||
@@ -883,7 +883,7 @@ class ElfReaderImpl {
|
||||
// Parse out the overall header information from the file and assert
|
||||
// that it looks sane. This contains information like the magic
|
||||
// number and target architecture.
|
||||
bool ParseHeaders(int fd, const string &path) {
|
||||
bool ParseHeaders(int fd, const string& path) {
|
||||
// Read in the global ELF header.
|
||||
if (pread(fd, &header_, sizeof(header_), 0) != sizeof(header_)) {
|
||||
return false;
|
||||
@@ -985,11 +985,11 @@ class ElfReaderImpl {
|
||||
|
||||
// Array of GetNumSections() section headers, allocated when we read
|
||||
// in the global header.
|
||||
typename ElfArch::Shdr *section_headers_;
|
||||
typename ElfArch::Shdr* section_headers_;
|
||||
|
||||
// Array of GetNumProgramHeaders() program headers, allocated when we read
|
||||
// in the global header.
|
||||
typename ElfArch::Phdr *program_headers_;
|
||||
typename ElfArch::Phdr* program_headers_;
|
||||
|
||||
// An array of pointers to ElfSectionReaders. Sections are
|
||||
// mmaped as they're needed and not released until this object is
|
||||
@@ -1000,7 +1000,7 @@ class ElfReaderImpl {
|
||||
// values for funtion symbols values. Function descriptors are kept in the
|
||||
// .opd section and are dereferenced to find the function address.
|
||||
ElfReader::SectionInfo opd_info_;
|
||||
const char *opd_section_; // Must be checked for NULL before use.
|
||||
const char* opd_section_; // Must be checked for NULL before use.
|
||||
int64_t base_for_text_;
|
||||
|
||||
// Read PLT-related sections for the current architecture.
|
||||
@@ -1026,7 +1026,7 @@ class ElfReaderImpl {
|
||||
bool is_dwp_;
|
||||
};
|
||||
|
||||
ElfReader::ElfReader(const string &path)
|
||||
ElfReader::ElfReader(const string& path)
|
||||
: path_(path), fd_(-1), impl32_(NULL), impl64_(NULL) {
|
||||
// linux 2.6.XX kernel can show deleted files like this:
|
||||
// /var/run/nscd/dbYLJYaE (deleted)
|
||||
@@ -1063,7 +1063,7 @@ ElfReader::~ElfReader() {
|
||||
#endif
|
||||
|
||||
template <typename ElfArch>
|
||||
static bool IsElfFile(const int fd, const string &path) {
|
||||
static bool IsElfFile(const int fd, const string& path) {
|
||||
if (fd < 0)
|
||||
return false;
|
||||
if (!ElfReaderImpl<ElfArch>::IsArchElfFile(fd, NULL)) {
|
||||
@@ -1086,7 +1086,7 @@ bool ElfReader::IsElf64File() const {
|
||||
}
|
||||
|
||||
/*
|
||||
void ElfReader::AddSymbols(SymbolMap *symbols,
|
||||
void ElfReader::AddSymbols(SymbolMap* symbols,
|
||||
uint64_t mem_offset, uint64_t file_offset,
|
||||
uint64_t length) {
|
||||
if (fd_ < 0)
|
||||
@@ -1109,17 +1109,17 @@ void ElfReader::AddSymbols(SymbolMap *symbols,
|
||||
}
|
||||
*/
|
||||
|
||||
void ElfReader::VisitSymbols(ElfReader::SymbolSink *sink) {
|
||||
void ElfReader::VisitSymbols(ElfReader::SymbolSink* sink) {
|
||||
VisitSymbols(sink, -1, -1);
|
||||
}
|
||||
|
||||
void ElfReader::VisitSymbols(ElfReader::SymbolSink *sink,
|
||||
void ElfReader::VisitSymbols(ElfReader::SymbolSink* sink,
|
||||
int symbol_binding,
|
||||
int symbol_type) {
|
||||
VisitSymbols(sink, symbol_binding, symbol_type, false);
|
||||
}
|
||||
|
||||
void ElfReader::VisitSymbols(ElfReader::SymbolSink *sink,
|
||||
void ElfReader::VisitSymbols(ElfReader::SymbolSink* sink,
|
||||
int symbol_binding,
|
||||
int symbol_type,
|
||||
bool get_raw_symbol_values) {
|
||||
@@ -1148,7 +1148,7 @@ uint64_t ElfReader::VaddrOfFirstLoadSegment() {
|
||||
}
|
||||
}
|
||||
|
||||
const char *ElfReader::GetSectionName(int shndx) {
|
||||
const char* ElfReader::GetSectionName(int shndx) {
|
||||
if (shndx < 0 || static_cast<unsigned int>(shndx) >= GetNumSections()) return NULL;
|
||||
if (IsElf32File()) {
|
||||
return GetImpl32()->GetSectionNameByIndex(shndx);
|
||||
@@ -1169,7 +1169,7 @@ uint64_t ElfReader::GetNumSections() {
|
||||
}
|
||||
}
|
||||
|
||||
const char *ElfReader::GetSectionByIndex(int shndx, size_t *size) {
|
||||
const char* ElfReader::GetSectionByIndex(int shndx, size_t* size) {
|
||||
if (IsElf32File()) {
|
||||
return GetImpl32()->GetSectionContentsByIndex(shndx, size);
|
||||
} else if (IsElf64File()) {
|
||||
@@ -1179,8 +1179,8 @@ const char *ElfReader::GetSectionByIndex(int shndx, size_t *size) {
|
||||
}
|
||||
}
|
||||
|
||||
const char *ElfReader::GetSectionByName(const string §ion_name,
|
||||
size_t *size) {
|
||||
const char* ElfReader::GetSectionByName(const string& section_name,
|
||||
size_t* size) {
|
||||
if (IsElf32File()) {
|
||||
return GetImpl32()->GetSectionContentsByName(section_name, size);
|
||||
} else if (IsElf64File()) {
|
||||
@@ -1190,8 +1190,8 @@ const char *ElfReader::GetSectionByName(const string §ion_name,
|
||||
}
|
||||
}
|
||||
|
||||
const char *ElfReader::GetSectionInfoByName(const string §ion_name,
|
||||
SectionInfo *info) {
|
||||
const char* ElfReader::GetSectionInfoByName(const string& section_name,
|
||||
SectionInfo* info) {
|
||||
if (IsElf32File()) {
|
||||
return GetImpl32()->GetSectionInfoByName(section_name, info);
|
||||
} else if (IsElf64File()) {
|
||||
@@ -1201,7 +1201,7 @@ const char *ElfReader::GetSectionInfoByName(const string §ion_name,
|
||||
}
|
||||
}
|
||||
|
||||
bool ElfReader::SectionNamesMatch(const string &name, const string &sh_name) {
|
||||
bool ElfReader::SectionNamesMatch(const string& name, const string& sh_name) {
|
||||
if ((name.find(".debug_", 0) == 0) && (sh_name.find(".zdebug_", 0) == 0)) {
|
||||
const string name_suffix(name, strlen(".debug_"));
|
||||
const string sh_name_suffix(sh_name, strlen(".zdebug_"));
|
||||
@@ -1220,14 +1220,14 @@ bool ElfReader::IsDynamicSharedObject() {
|
||||
}
|
||||
}
|
||||
|
||||
ElfReaderImpl<Elf32> *ElfReader::GetImpl32() {
|
||||
ElfReaderImpl<Elf32>* ElfReader::GetImpl32() {
|
||||
if (impl32_ == NULL) {
|
||||
impl32_ = new ElfReaderImpl<Elf32>(path_, fd_);
|
||||
}
|
||||
return impl32_;
|
||||
}
|
||||
|
||||
ElfReaderImpl<Elf64> *ElfReader::GetImpl64() {
|
||||
ElfReaderImpl<Elf64>* ElfReader::GetImpl64() {
|
||||
if (impl64_ == NULL) {
|
||||
impl64_ = new ElfReaderImpl<Elf64>(path_, fd_);
|
||||
}
|
||||
@@ -1238,7 +1238,7 @@ ElfReaderImpl<Elf64> *ElfReader::GetImpl64() {
|
||||
// debug info (debug_only=true) or symbol table (debug_only=false).
|
||||
// Otherwise, return false.
|
||||
template <typename ElfArch>
|
||||
static bool IsNonStrippedELFBinaryImpl(const string &path, const int fd,
|
||||
static bool IsNonStrippedELFBinaryImpl(const string& path, const int fd,
|
||||
bool debug_only) {
|
||||
if (!ElfReaderImpl<ElfArch>::IsArchElfFile(fd, NULL)) return false;
|
||||
ElfReaderImpl<ElfArch> elf_reader(path, fd);
|
||||
@@ -1248,7 +1248,7 @@ static bool IsNonStrippedELFBinaryImpl(const string &path, const int fd,
|
||||
}
|
||||
|
||||
// Helper for the IsNon[Debug]StrippedELFBinary functions.
|
||||
static bool IsNonStrippedELFBinaryHelper(const string &path,
|
||||
static bool IsNonStrippedELFBinaryHelper(const string& path,
|
||||
bool debug_only) {
|
||||
const int fd = open(path.c_str(), O_RDONLY);
|
||||
if (fd == -1) {
|
||||
@@ -1264,11 +1264,11 @@ static bool IsNonStrippedELFBinaryHelper(const string &path,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ElfReader::IsNonStrippedELFBinary(const string &path) {
|
||||
bool ElfReader::IsNonStrippedELFBinary(const string& path) {
|
||||
return IsNonStrippedELFBinaryHelper(path, false);
|
||||
}
|
||||
|
||||
bool ElfReader::IsNonDebugStrippedELFBinary(const string &path) {
|
||||
bool ElfReader::IsNonDebugStrippedELFBinary(const string& path) {
|
||||
return IsNonStrippedELFBinaryHelper(path, true);
|
||||
}
|
||||
} // namespace dwarf2reader
|
||||
|
||||
@@ -34,7 +34,7 @@ class ElfReaderImpl;
|
||||
|
||||
class ElfReader {
|
||||
public:
|
||||
explicit ElfReader(const string &path);
|
||||
explicit ElfReader(const string& path);
|
||||
~ElfReader();
|
||||
|
||||
// Parse the ELF prologue of this file and return whether it was
|
||||
@@ -62,29 +62,29 @@ class ElfReader {
|
||||
// mem_offset - position at which the segment is mapped into memory
|
||||
// file_offset - offset in the file where the mapping begins
|
||||
// length - length of the mapped segment
|
||||
void AddSymbols(SymbolMap *symbols,
|
||||
void AddSymbols(SymbolMap* symbols,
|
||||
uint64_t mem_offset, uint64_t file_offset,
|
||||
uint64_t length);
|
||||
|
||||
class SymbolSink {
|
||||
public:
|
||||
virtual ~SymbolSink() {}
|
||||
virtual void AddSymbol(const char *name, uint64_t address,
|
||||
virtual void AddSymbol(const char* name, uint64_t address,
|
||||
uint64_t size) = 0;
|
||||
};
|
||||
|
||||
// Like AddSymbols above, but with no address correction.
|
||||
// Processes any SHT_SYMTAB section, followed by any SHT_DYNSYM section.
|
||||
void VisitSymbols(SymbolSink *sink);
|
||||
void VisitSymbols(SymbolSink* sink);
|
||||
|
||||
// Like VisitSymbols above, but for a specific symbol binding/type.
|
||||
// A negative value for the binding and type parameters means any
|
||||
// binding or type.
|
||||
void VisitSymbols(SymbolSink *sink, int symbol_binding, int symbol_type);
|
||||
void VisitSymbols(SymbolSink* sink, int symbol_binding, int symbol_type);
|
||||
|
||||
// Like VisitSymbols above but can optionally export raw symbol values instead
|
||||
// of adjusted ones.
|
||||
void VisitSymbols(SymbolSink *sink, int symbol_binding, int symbol_type,
|
||||
void VisitSymbols(SymbolSink* sink, int symbol_binding, int symbol_type,
|
||||
bool get_raw_symbol_values);
|
||||
|
||||
// p_vaddr of the first PT_LOAD segment (if any), or 0 if no PT_LOAD
|
||||
@@ -95,7 +95,7 @@ class ElfReader {
|
||||
|
||||
// Return the name of section "shndx". Returns NULL if the section
|
||||
// is not found.
|
||||
const char *GetSectionName(int shndx);
|
||||
const char* GetSectionName(int shndx);
|
||||
|
||||
// Return the number of sections in the given ELF file.
|
||||
uint64_t GetNumSections();
|
||||
@@ -104,14 +104,14 @@ class ElfReader {
|
||||
// the pointer to the section and store the size in "size".
|
||||
// On error, return NULL. The returned section data is only valid
|
||||
// until the ElfReader gets destroyed.
|
||||
const char *GetSectionByIndex(int shndx, size_t *size);
|
||||
const char* GetSectionByIndex(int shndx, size_t* size);
|
||||
|
||||
// Get section with "section_name" (ex. ".text", ".symtab") in the
|
||||
// given ELF file. On success, return the pointer to the section
|
||||
// and store the size in "size". On error, return NULL. The
|
||||
// returned section data is only valid until the ElfReader gets
|
||||
// destroyed.
|
||||
const char *GetSectionByName(const string §ion_name, size_t *size);
|
||||
const char* GetSectionByName(const string& section_name, size_t* size);
|
||||
|
||||
// This is like GetSectionByName() but it returns a lot of extra information
|
||||
// about the section. The SectionInfo structure is almost identical to
|
||||
@@ -129,37 +129,37 @@ class ElfReader {
|
||||
uint64_t addralign; // Section alignment.
|
||||
uint64_t entsize; // Entry size if section holds a table.
|
||||
};
|
||||
const char *GetSectionInfoByName(const string §ion_name,
|
||||
SectionInfo *info);
|
||||
const char* GetSectionInfoByName(const string& section_name,
|
||||
SectionInfo* info);
|
||||
|
||||
// Check if "path" is an ELF binary that has not been stripped of symbol
|
||||
// tables. This function supports both 32-bit and 64-bit ELF binaries.
|
||||
static bool IsNonStrippedELFBinary(const string &path);
|
||||
static bool IsNonStrippedELFBinary(const string& path);
|
||||
|
||||
// Check if "path" is an ELF binary that has not been stripped of debug
|
||||
// info. Unlike IsNonStrippedELFBinary, this function will return
|
||||
// false for binaries passed through "strip -S".
|
||||
static bool IsNonDebugStrippedELFBinary(const string &path);
|
||||
static bool IsNonDebugStrippedELFBinary(const string& path);
|
||||
|
||||
// Match a requested section name with the section name as it
|
||||
// appears in the elf-file, adjusting for compressed debug section
|
||||
// names. For example, returns true if name == ".debug_abbrev" and
|
||||
// sh_name == ".zdebug_abbrev"
|
||||
static bool SectionNamesMatch(const string &name, const string &sh_name);
|
||||
static bool SectionNamesMatch(const string& name, const string& sh_name);
|
||||
|
||||
private:
|
||||
// Lazily initialize impl32_ and return it.
|
||||
ElfReaderImpl<Elf32> *GetImpl32();
|
||||
ElfReaderImpl<Elf32>* GetImpl32();
|
||||
// Ditto for impl64_.
|
||||
ElfReaderImpl<Elf64> *GetImpl64();
|
||||
ElfReaderImpl<Elf64>* GetImpl64();
|
||||
|
||||
// Path of the file we're reading.
|
||||
const string path_;
|
||||
// Read-only file descriptor for the file. May be -1 if there was an
|
||||
// error during open.
|
||||
int fd_;
|
||||
ElfReaderImpl<Elf32> *impl32_;
|
||||
ElfReaderImpl<Elf64> *impl64_;
|
||||
ElfReaderImpl<Elf32>* impl32_;
|
||||
ElfReaderImpl<Elf64>* impl64_;
|
||||
};
|
||||
|
||||
} // namespace dwarf2reader
|
||||
|
||||
@@ -144,7 +144,7 @@ bool CUFunctionInfoHandler::StartDIE(uint64_t offset, enum DwarfTag tag) {
|
||||
void CUFunctionInfoHandler::ProcessAttributeString(uint64_t offset,
|
||||
enum DwarfAttribute attr,
|
||||
enum DwarfForm form,
|
||||
const string &data) {
|
||||
const string& data) {
|
||||
if (current_function_info_) {
|
||||
if (attr == DW_AT_name)
|
||||
current_function_info_->name = data;
|
||||
|
||||
Reference in New Issue
Block a user