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

Side by Side 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 unified diff | 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 »
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 158
159 bool FileID::ElfFileIdentifier(wasteful_vector<uint8_t>& identifier) { 159 bool FileID::ElfFileIdentifier(wasteful_vector<uint8_t>& identifier) {
160 MemoryMappedFile mapped_file(path_.c_str(), 0); 160 MemoryMappedFile mapped_file(path_.c_str(), 0);
161 if (!mapped_file.data()) // Should probably check if size >= ElfW(Ehdr)? 161 if (!mapped_file.data()) // Should probably check if size >= ElfW(Ehdr)?
162 return false; 162 return false;
163 163
164 return ElfFileIdentifierFromMappedFile(mapped_file.data(), identifier); 164 return ElfFileIdentifierFromMappedFile(mapped_file.data(), identifier);
165 } 165 }
166 166
167 // This function is not ever called in an unsafe context, so it's OK 167 // These three functions are not ever called in an unsafe context, so it's OK
168 // to allocate memory and use libc. 168 // to allocate memory and use libc.
169 static string bytes_to_hex_string(const uint8_t* bytes, size_t count) {
170 string result;
171 for (unsigned int idx = 0; idx < count; ++idx) {
172 char buf[3];
173 snprintf(buf, sizeof(buf), "%02X", bytes[idx]);
174 result.append(buf);
175 }
176 return result;
177 }
178
169 // static 179 // static
170 string FileID::ConvertIdentifierToUUIDString( 180 string FileID::ConvertIdentifierToUUIDString(
171 const wasteful_vector<uint8_t>& identifier) { 181 const wasteful_vector<uint8_t>& identifier) {
172 uint8_t identifier_swapped[kMDGUIDSize] = { 0 }; 182 uint8_t identifier_swapped[kMDGUIDSize] = { 0 };
173 183
174 // Endian-ness swap to match dump processor expectation. 184 // Endian-ness swap to match dump processor expectation.
175 memcpy(identifier_swapped, &identifier[0], 185 memcpy(identifier_swapped, &identifier[0],
176 std::min(kMDGUIDSize, identifier.size())); 186 std::min(kMDGUIDSize, identifier.size()));
177 uint32_t* data1 = reinterpret_cast<uint32_t*>(identifier_swapped); 187 uint32_t* data1 = reinterpret_cast<uint32_t*>(identifier_swapped);
178 *data1 = htonl(*data1); 188 *data1 = htonl(*data1);
179 uint16_t* data2 = reinterpret_cast<uint16_t*>(identifier_swapped + 4); 189 uint16_t* data2 = reinterpret_cast<uint16_t*>(identifier_swapped + 4);
180 *data2 = htons(*data2); 190 *data2 = htons(*data2);
181 uint16_t* data3 = reinterpret_cast<uint16_t*>(identifier_swapped + 6); 191 uint16_t* data3 = reinterpret_cast<uint16_t*>(identifier_swapped + 6);
182 *data3 = htons(*data3); 192 *data3 = htons(*data3);
183 193
184 string result; 194 return bytes_to_hex_string(identifier_swapped, kMDGUIDSize);
185 for (unsigned int idx = 0; idx < kMDGUIDSize; ++idx) { 195 }
186 char buf[3]; 196
187 snprintf(buf, sizeof(buf), "%02X", identifier_swapped[idx]); 197 // static
188 result.append(buf); 198 string FileID::ConvertIdentifierToString(
189 } 199 const wasteful_vector<uint8_t>& identifier) {
190 return result; 200 return bytes_to_hex_string(&identifier[0], identifier.size());
191 } 201 }
192 202
193 } // namespace google_breakpad 203 } // namespace google_breakpad
OLDNEW
« 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