Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: src/common/linux/file_id.h

Issue 1688743002: Switch the Linux minidump writer to use MDCVInfoELF for CV data. (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Rework to handle arbitrary size build ids Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/common/linux/dump_symbols.cc ('k') | src/common/linux/file_id.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006, Google Inc. 1 // Copyright (c) 2006, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 19 matching lines...) Expand all
30 // file_id.h: Return a unique identifier for a file 30 // file_id.h: Return a unique identifier for a file
31 // 31 //
32 32
33 #ifndef COMMON_LINUX_FILE_ID_H__ 33 #ifndef COMMON_LINUX_FILE_ID_H__
34 #define COMMON_LINUX_FILE_ID_H__ 34 #define COMMON_LINUX_FILE_ID_H__
35 35
36 #include <limits.h> 36 #include <limits.h>
37 #include <string> 37 #include <string>
38 38
39 #include "common/linux/guid_creator.h" 39 #include "common/linux/guid_creator.h"
40 #include "common/memory.h"
40 41
41 namespace google_breakpad { 42 namespace google_breakpad {
42 43
43 static const size_t kMDGUIDSize = sizeof(MDGUID); 44 // GNU binutils' ld defaults to 'sha1', which is 160 bits == 20 bytes,
45 // so this is enough to fit that, which most binaries will use.
46 static const size_t kDefaultBuildIdSize = 20;
44 47
45 class FileID { 48 class FileID {
46 public: 49 public:
47 explicit FileID(const char* path); 50 explicit FileID(const char* path);
48 ~FileID() {} 51 ~FileID() {}
49 52
50 // Load the identifier for the elf file path specified in the constructor into 53 // Load the identifier for the elf file path specified in the constructor into
51 // |identifier|. Return false if the identifier could not be created for the 54 // |identifier|.
52 // file. 55 //
53 // The current implementation will look for a .note.gnu.build-id 56 // The current implementation will look for a .note.gnu.build-id
54 // section and use that as the file id, otherwise it falls back to 57 // section and use that as the file id, otherwise it falls back to
55 // XORing the first 4096 bytes of the .text section to generate an identifier. 58 // XORing the first 4096 bytes of the .text section to generate an identifier.
56 bool ElfFileIdentifier(uint8_t identifier[kMDGUIDSize]); 59 bool ElfFileIdentifier(wasteful_vector<uint8_t>& identifier);
57 60
58 // Load the identifier for the elf file mapped into memory at |base| into 61 // Load the identifier for the elf file mapped into memory at |base| into
59 // |identifier|. Return false if the identifier could not be created for the 62 // |identifier|. Return false if the identifier could not be created for this
60 // file. 63 // file.
61 static bool ElfFileIdentifierFromMappedFile(const void* base, 64 static bool ElfFileIdentifierFromMappedFile(
62 uint8_t identifier[kMDGUIDSize]); 65 const void* base,
66 wasteful_vector<uint8_t>& identifier);
63 67
64 // Convert the |identifier| data to a NULL terminated string. The string will 68 // Convert the |identifier| data to a NULL terminated string. The string will
65 // be formatted as a UUID (e.g., 22F065BB-FC9C-49F7-80FE-26A7CEBD7BCE). 69 // be formatted as a UUID in all uppercase without dashes.
66 // The |buffer| should be at least 37 bytes long to receive all of the data 70 // (e.g., 22F065BBFC9C49F780FE26A7CEBD7BCE).
67 // and termination. Shorter buffers will contain truncated data. 71 static std::string ConvertIdentifierToUUIDString(
68 static void ConvertIdentifierToString(const uint8_t identifier[kMDGUIDSize], 72 const wasteful_vector<uint8_t>& identifier);
69 char* buffer, int buffer_length);
70 73
71 private: 74 private:
72 // Storage for the path specified 75 // Storage for the path specified
73 std::string path_; 76 std::string path_;
74 }; 77 };
75 78
76 } // namespace google_breakpad 79 } // namespace google_breakpad
77 80
78 #endif // COMMON_LINUX_FILE_ID_H__ 81 #endif // COMMON_LINUX_FILE_ID_H__
OLDNEW
« no previous file with comments | « src/common/linux/dump_symbols.cc ('k') | src/common/linux/file_id.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698