| 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) { |
| 80 if (std::getline(*istream, *str)) { |
| 81 // Trim any trailing newline from the end of the line. Allows us |
| 82 // to seamlessly handle both Windows/DOS and Unix formatted input. The |
| 83 // adb tool generally writes logcat dumps in Windows/DOS format. |
| 84 if (!str->empty() && str->at(str->size() - 1) == '\r') { |
| 85 str->erase(str->size() - 1); |
| 86 } |
| 87 return true; |
| 88 } |
| 89 return false; |
| 90 } |
| 91 |
| 79 } // namespace | 92 } // namespace |
| 80 | 93 |
| 81 namespace google_breakpad { | 94 namespace google_breakpad { |
| 82 | 95 |
| 83 // | 96 // |
| 84 // MicrodumpModules | 97 // MicrodumpModules |
| 85 // | 98 // |
| 86 | 99 |
| 87 void MicrodumpModules::Add(const CodeModule* module) { | 100 void MicrodumpModules::Add(const CodeModule* module) { |
| 88 linked_ptr<const CodeModule> module_ptr(module); | 101 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()) { | 189 system_info_(new SystemInfo()) { |
| 177 assert(!contents.empty()); | 190 assert(!contents.empty()); |
| 178 | 191 |
| 179 bool in_microdump = false; | 192 bool in_microdump = false; |
| 180 string line; | 193 string line; |
| 181 uint64_t stack_start = 0; | 194 uint64_t stack_start = 0; |
| 182 std::vector<uint8_t> stack_content; | 195 std::vector<uint8_t> stack_content; |
| 183 string arch; | 196 string arch; |
| 184 | 197 |
| 185 std::istringstream stream(contents); | 198 std::istringstream stream(contents); |
| 186 while (std::getline(stream, line)) { | 199 while (GetLine(&stream, &line)) { |
| 187 if (line.find(kGoogleBreakpadKey) == string::npos) { | 200 if (line.find(kGoogleBreakpadKey) == string::npos) { |
| 188 continue; | 201 continue; |
| 189 } | 202 } |
| 190 if (line.find(kMicrodumpBegin) != string::npos) { | 203 if (line.find(kMicrodumpBegin) != string::npos) { |
| 191 in_microdump = true; | 204 in_microdump = true; |
| 192 continue; | 205 continue; |
| 193 } | 206 } |
| 194 if (line.find(kMicrodumpEnd) != string::npos) { | 207 if (line.find(kMicrodumpEnd) != string::npos) { |
| 195 break; | 208 break; |
| 196 } | 209 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 207 string num_cpus; | 220 string num_cpus; |
| 208 string os_version; | 221 string os_version; |
| 209 // This reflect the actual HW arch and might not match the arch emulated | 222 // 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). | 223 // for the execution (e.g., running a 32-bit binary on a 64-bit cpu). |
| 211 string hw_arch; | 224 string hw_arch; |
| 212 | 225 |
| 213 os_tokens >> os_id; | 226 os_tokens >> os_id; |
| 214 os_tokens >> arch; | 227 os_tokens >> arch; |
| 215 os_tokens >> num_cpus; | 228 os_tokens >> num_cpus; |
| 216 os_tokens >> hw_arch; | 229 os_tokens >> hw_arch; |
| 217 std::getline(os_tokens, os_version); | 230 GetLine(&os_tokens, &os_version); |
| 218 os_version.erase(0, 1); // remove leading space. | 231 os_version.erase(0, 1); // remove leading space. |
| 219 | 232 |
| 220 system_info_->cpu = hw_arch; | 233 system_info_->cpu = hw_arch; |
| 221 system_info_->cpu_count = HexStrToL<uint8_t>(num_cpus); | 234 system_info_->cpu_count = HexStrToL<uint8_t>(num_cpus); |
| 222 system_info_->os_version = os_version; | 235 system_info_->os_version = os_version; |
| 223 | 236 |
| 224 if (os_id == "L") { | 237 if (os_id == "L") { |
| 225 system_info_->os = "Linux"; | 238 system_info_->os = "Linux"; |
| 226 system_info_->os_short = "linux"; | 239 system_info_->os_short = "linux"; |
| 227 } else if (os_id == "A") { | 240 } else if (os_id == "A") { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 filename, // debug_file | 310 filename, // debug_file |
| 298 identifier, // debug_identifier | 311 identifier, // debug_identifier |
| 299 "")); // version | 312 "")); // version |
| 300 } | 313 } |
| 301 } | 314 } |
| 302 stack_region_->Init(stack_start, stack_content); | 315 stack_region_->Init(stack_start, stack_content); |
| 303 } | 316 } |
| 304 | 317 |
| 305 } // namespace google_breakpad | 318 } // namespace google_breakpad |
| 306 | 319 |
| OLD | NEW |