diff options
Diffstat (limited to 'src/common/dwarf/bytereader.h')
-rw-r--r-- | src/common/dwarf/bytereader.h | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/common/dwarf/bytereader.h b/src/common/dwarf/bytereader.h index 2b37a12d..761eaf68 100644 --- a/src/common/dwarf/bytereader.h +++ b/src/common/dwarf/bytereader.h @@ -1,6 +1,6 @@ // -*- mode: C++ -*- -// Copyright (c) 2010 Google Inc. All Rights Reserved. +// Copyright 2010 Google LLC // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -12,7 +12,7 @@ // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. -// * Neither the name of Google Inc. nor the names of its +// * Neither the name of Google LLC nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // @@ -38,7 +38,7 @@ #include "common/dwarf/types.h" #include "common/dwarf/dwarf2enums.h" -namespace dwarf2reader { +namespace google_breakpad { // We can't use the obvious name of LITTLE_ENDIAN and BIG_ENDIAN // because it conflicts with a macro @@ -62,22 +62,27 @@ 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 + // for various index-related DW_FORMs. + uint64_t ReadThreeBytes(const uint8_t* buffer) const; // Read four bytes from BUFFER and return them as an unsigned 32 bit // number, using this ByteReader's endianness. This function returns // 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 @@ -96,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. @@ -115,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 @@ -138,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 @@ -175,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. @@ -237,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. @@ -276,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, @@ -307,9 +312,9 @@ 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 +} // namespace google_breakpad #endif // COMMON_DWARF_BYTEREADER_H__ |