OLD | NEW |
---|---|
1 // Copyright (c) 2014 Google Inc. | 1 // Copyright (c) 2014 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 } | 69 } |
70 | 70 |
71 std::vector<uint8_t> ParseHexBuf(const string& str) { | 71 std::vector<uint8_t> ParseHexBuf(const string& str) { |
72 std::vector<uint8_t> buf; | 72 std::vector<uint8_t> buf; |
73 for (size_t i = 0; i < str.length(); i += 2) { | 73 for (size_t i = 0; i < str.length(); i += 2) { |
74 buf.push_back(HexStrToL<uint8_t>(str.substr(i, 2))); | 74 buf.push_back(HexStrToL<uint8_t>(str.substr(i, 2))); |
75 } | 75 } |
76 return buf; | 76 return buf; |
77 } | 77 } |
78 | 78 |
79 bool GetLine(std::istringstream* istream, string* str) { | |
Primiano Tucci (use gerrit)
2015/06/18 10:59:39
Maybe add a comment explaining that this removes W
simonb (inactive)
2015/06/18 16:24:39
Removed from this review in later patch sets, sinc
| |
80 if (std::getline(*istream, *str)) { | |
81 if (str->size() > 0 && str->at(str->size() - 1) == '\r') { | |
82 str->erase(str->size() - 1); | |
83 } | |
84 return true; | |
85 } | |
86 return false; | |
87 } | |
88 | |
79 } // namespace | 89 } // namespace |
80 | 90 |
81 namespace google_breakpad { | 91 namespace google_breakpad { |
82 | 92 |
83 // | 93 // |
84 // MicrodumpModules | 94 // MicrodumpModules |
85 // | 95 // |
86 | 96 |
87 void MicrodumpModules::Add(const CodeModule* module) { | 97 void MicrodumpModules::Add(const CodeModule* module) { |
88 linked_ptr<const CodeModule> module_ptr(module); | 98 linked_ptr<const CodeModule> module_ptr(module); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 system_info_(new SystemInfo()) { | 186 system_info_(new SystemInfo()) { |
177 assert(!contents.empty()); | 187 assert(!contents.empty()); |
178 | 188 |
179 bool in_microdump = false; | 189 bool in_microdump = false; |
180 string line; | 190 string line; |
181 uint64_t stack_start = 0; | 191 uint64_t stack_start = 0; |
182 std::vector<uint8_t> stack_content; | 192 std::vector<uint8_t> stack_content; |
183 string arch; | 193 string arch; |
184 | 194 |
185 std::istringstream stream(contents); | 195 std::istringstream stream(contents); |
186 while (std::getline(stream, line)) { | 196 while (GetLine(&stream, &line)) { |
rmcilroy
2015/06/18 09:42:11
Is there a reason you needed to write your own Get
simonb (inactive)
2015/06/18 10:46:39
This is the diff from a separate code review that
| |
187 if (line.find(kGoogleBreakpadKey) == string::npos) { | 197 if (line.find(kGoogleBreakpadKey) == string::npos) { |
188 continue; | 198 continue; |
189 } | 199 } |
190 if (line.find(kMicrodumpBegin) != string::npos) { | 200 if (line.find(kMicrodumpBegin) != string::npos) { |
191 in_microdump = true; | 201 in_microdump = true; |
192 continue; | 202 continue; |
193 } | 203 } |
194 if (line.find(kMicrodumpEnd) != string::npos) { | 204 if (line.find(kMicrodumpEnd) != string::npos) { |
195 break; | 205 break; |
196 } | 206 } |
(...skipping 10 matching lines...) Expand all Loading... | |
207 string num_cpus; | 217 string num_cpus; |
208 string os_version; | 218 string os_version; |
209 // This reflect the actual HW arch and might not match the arch emulated | 219 // This reflect the actual HW arch and might not match the arch emulated |
210 // for the execution (e.g., running a 32-bit binary on a 64-bit cpu). | 220 // for the execution (e.g., running a 32-bit binary on a 64-bit cpu). |
211 string hw_arch; | 221 string hw_arch; |
212 | 222 |
213 os_tokens >> os_id; | 223 os_tokens >> os_id; |
214 os_tokens >> arch; | 224 os_tokens >> arch; |
215 os_tokens >> num_cpus; | 225 os_tokens >> num_cpus; |
216 os_tokens >> hw_arch; | 226 os_tokens >> hw_arch; |
217 std::getline(os_tokens, os_version); | 227 GetLine(&os_tokens, &os_version); |
218 os_version.erase(0, 1); // remove leading space. | 228 os_version.erase(0, 1); // remove leading space. |
219 | 229 |
220 system_info_->cpu = hw_arch; | 230 system_info_->cpu = hw_arch; |
221 system_info_->cpu_count = HexStrToL<uint8_t>(num_cpus); | 231 system_info_->cpu_count = HexStrToL<uint8_t>(num_cpus); |
222 system_info_->os_version = os_version; | 232 system_info_->os_version = os_version; |
223 | 233 |
224 if (os_id == "L") { | 234 if (os_id == "L") { |
225 system_info_->os = "Linux"; | 235 system_info_->os = "Linux"; |
226 system_info_->os_short = "linux"; | 236 system_info_->os_short = "linux"; |
227 } else if (os_id == "A") { | 237 } else if (os_id == "A") { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 filename, // debug_file | 307 filename, // debug_file |
298 identifier, // debug_identifier | 308 identifier, // debug_identifier |
299 "")); // version | 309 "")); // version |
300 } | 310 } |
301 } | 311 } |
302 stack_region_->Init(stack_start, stack_content); | 312 stack_region_->Init(stack_start, stack_content); |
303 } | 313 } |
304 | 314 |
305 } // namespace google_breakpad | 315 } // namespace google_breakpad |
306 | 316 |
OLD | NEW |