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

Unified Diff: src/common/linux/file_id.cc

Issue 2052263002: Dump INFO CODE_ID containing Build ID in Linux dump_syms (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Oops, it's supposed to be INFO CODE_ID Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/common/linux/file_id.h ('k') | src/common/linux/file_id_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/common/linux/file_id.cc
diff --git a/src/common/linux/file_id.cc b/src/common/linux/file_id.cc
index e8dc528d07684c687a10865436864adeee32620d..02207758acc91d6bbc54478d289455ecb4abf6ae 100644
--- a/src/common/linux/file_id.cc
+++ b/src/common/linux/file_id.cc
@@ -164,8 +164,18 @@ bool FileID::ElfFileIdentifier(wasteful_vector<uint8_t>& identifier) {
return ElfFileIdentifierFromMappedFile(mapped_file.data(), identifier);
}
-// This function is not ever called in an unsafe context, so it's OK
+// These three functions are not ever called in an unsafe context, so it's OK
// to allocate memory and use libc.
+static string bytes_to_hex_string(const uint8_t* bytes, size_t count) {
+ string result;
+ for (unsigned int idx = 0; idx < count; ++idx) {
+ char buf[3];
+ snprintf(buf, sizeof(buf), "%02X", bytes[idx]);
+ result.append(buf);
+ }
+ return result;
+}
+
// static
string FileID::ConvertIdentifierToUUIDString(
const wasteful_vector<uint8_t>& identifier) {
@@ -181,13 +191,13 @@ string FileID::ConvertIdentifierToUUIDString(
uint16_t* data3 = reinterpret_cast<uint16_t*>(identifier_swapped + 6);
*data3 = htons(*data3);
- string result;
- for (unsigned int idx = 0; idx < kMDGUIDSize; ++idx) {
- char buf[3];
- snprintf(buf, sizeof(buf), "%02X", identifier_swapped[idx]);
- result.append(buf);
- }
- return result;
+ return bytes_to_hex_string(identifier_swapped, kMDGUIDSize);
+}
+
+// static
+string FileID::ConvertIdentifierToString(
+ const wasteful_vector<uint8_t>& identifier) {
+ return bytes_to_hex_string(&identifier[0], identifier.size());
}
} // namespace google_breakpad
« no previous file with comments | « src/common/linux/file_id.h ('k') | src/common/linux/file_id_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698