diff options
Diffstat (limited to 'src/common/linux/file_id.h')
-rw-r--r-- | src/common/linux/file_id.h | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/common/linux/file_id.h b/src/common/linux/file_id.h index 2642722a..80e5a8e9 100644 --- a/src/common/linux/file_id.h +++ b/src/common/linux/file_id.h @@ -37,10 +37,15 @@ #include <string> #include "common/linux/guid_creator.h" +#include "common/memory.h" namespace google_breakpad { -static const size_t kMDGUIDSize = sizeof(MDGUID); +// GNU binutils' ld defaults to 'sha1', which is 160 bits == 20 bytes, +// so this is enough to fit that, which most binaries will use. +// This is just a sensible default for auto_wasteful_vector so most +// callers can get away with stack allocation. +static const size_t kDefaultBuildIdSize = 20; class FileID { public: @@ -48,25 +53,25 @@ class FileID { ~FileID() {} // Load the identifier for the elf file path specified in the constructor into - // |identifier|. Return false if the identifier could not be created for the - // file. + // |identifier|. + // // The current implementation will look for a .note.gnu.build-id // section and use that as the file id, otherwise it falls back to // XORing the first 4096 bytes of the .text section to generate an identifier. - bool ElfFileIdentifier(uint8_t identifier[kMDGUIDSize]); + bool ElfFileIdentifier(wasteful_vector<uint8_t>& identifier); // Load the identifier for the elf file mapped into memory at |base| into - // |identifier|. Return false if the identifier could not be created for the + // |identifier|. Return false if the identifier could not be created for this // file. - static bool ElfFileIdentifierFromMappedFile(const void* base, - uint8_t identifier[kMDGUIDSize]); + static bool ElfFileIdentifierFromMappedFile( + const void* base, + wasteful_vector<uint8_t>& identifier); - // Convert the |identifier| data to a NULL terminated string. The string will - // be formatted as a UUID (e.g., 22F065BB-FC9C-49F7-80FE-26A7CEBD7BCE). - // The |buffer| should be at least 37 bytes long to receive all of the data - // and termination. Shorter buffers will contain truncated data. - static void ConvertIdentifierToString(const uint8_t identifier[kMDGUIDSize], - char* buffer, int buffer_length); + // Convert the |identifier| data to a string. The string will + // be formatted as a UUID in all uppercase without dashes. + // (e.g., 22F065BBFC9C49F780FE26A7CEBD7BCE). + static std::string ConvertIdentifierToUUIDString( + const wasteful_vector<uint8_t>& identifier); private: // Storage for the path specified |