| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 static const char kMicrodumpEnd[] = "-----END BREAKPAD MICRODUMP-----"; | 54 static const char kMicrodumpEnd[] = "-----END BREAKPAD MICRODUMP-----"; |
| 55 static const char kOsKey[] = ": O "; | 55 static const char kOsKey[] = ": O "; |
| 56 static const char kCpuKey[] = ": C "; | 56 static const char kCpuKey[] = ": C "; |
| 57 static const char kGpuKey[] = ": G "; | 57 static const char kGpuKey[] = ": G "; |
| 58 static const char kMmapKey[] = ": M "; | 58 static const char kMmapKey[] = ": M "; |
| 59 static const char kStackKey[] = ": S "; | 59 static const char kStackKey[] = ": S "; |
| 60 static const char kStackFirstLineKey[] = ": S 0 "; | 60 static const char kStackFirstLineKey[] = ": S 0 "; |
| 61 static const char kArmArchitecture[] = "arm"; | 61 static const char kArmArchitecture[] = "arm"; |
| 62 static const char kArm64Architecture[] = "arm64"; | 62 static const char kArm64Architecture[] = "arm64"; |
| 63 static const char kX86Architecture[] = "x86"; | 63 static const char kX86Architecture[] = "x86"; |
| 64 static const char kMipsArchitecture[] = "mips"; |
| 65 static const char kMips64Architecture[] = "mips64"; |
| 64 static const char kGpuUnknown[] = "UNKNOWN"; | 66 static const char kGpuUnknown[] = "UNKNOWN"; |
| 65 | 67 |
| 66 template<typename T> | 68 template<typename T> |
| 67 T HexStrToL(const string& str) { | 69 T HexStrToL(const string& str) { |
| 68 uint64_t res = 0; | 70 uint64_t res = 0; |
| 69 std::istringstream ss(str); | 71 std::istringstream ss(str); |
| 70 ss >> std::hex >> res; | 72 ss >> std::hex >> res; |
| 71 return static_cast<T>(res); | 73 return static_cast<T>(res); |
| 72 } | 74 } |
| 73 | 75 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 DumpContext::SetContextARM64(arm64); | 126 DumpContext::SetContextARM64(arm64); |
| 125 valid_ = true; | 127 valid_ = true; |
| 126 } | 128 } |
| 127 | 129 |
| 128 void MicrodumpContext::SetContextX86(MDRawContextX86* x86) { | 130 void MicrodumpContext::SetContextX86(MDRawContextX86* x86) { |
| 129 DumpContext::SetContextFlags(MD_CONTEXT_X86); | 131 DumpContext::SetContextFlags(MD_CONTEXT_X86); |
| 130 DumpContext::SetContextX86(x86); | 132 DumpContext::SetContextX86(x86); |
| 131 valid_ = true; | 133 valid_ = true; |
| 132 } | 134 } |
| 133 | 135 |
| 136 void MicrodumpContext::SetContextMIPS(MDRawContextMIPS* mips) { |
| 137 DumpContext::SetContextFlags(MD_CONTEXT_MIPS); |
| 138 DumpContext::SetContextMIPS(mips); |
| 139 valid_ = true; |
| 140 } |
| 141 |
| 142 void MicrodumpContext::SetContextMIPS64(MDRawContextMIPS* mips64) { |
| 143 DumpContext::SetContextFlags(MD_CONTEXT_MIPS64); |
| 144 DumpContext::SetContextMIPS(mips64); |
| 145 valid_ = true; |
| 146 } |
| 147 |
| 134 | 148 |
| 135 // | 149 // |
| 136 // MicrodumpMemoryRegion | 150 // MicrodumpMemoryRegion |
| 137 // | 151 // |
| 138 | 152 |
| 139 MicrodumpMemoryRegion::MicrodumpMemoryRegion() : base_address_(0) { } | 153 MicrodumpMemoryRegion::MicrodumpMemoryRegion() : base_address_(0) { } |
| 140 | 154 |
| 141 void MicrodumpMemoryRegion::Init(uint64_t base_address, | 155 void MicrodumpMemoryRegion::Init(uint64_t base_address, |
| 142 const std::vector<uint8_t>& contents) { | 156 const std::vector<uint8_t>& contents) { |
| 143 base_address_ = base_address; | 157 base_address_ = base_address; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 stack_start = start_addr; | 288 stack_start = start_addr; |
| 275 } | 289 } |
| 276 std::vector<uint8_t> chunk = ParseHexBuf(raw_content); | 290 std::vector<uint8_t> chunk = ParseHexBuf(raw_content); |
| 277 stack_content.insert(stack_content.end(), chunk.begin(), chunk.end()); | 291 stack_content.insert(stack_content.end(), chunk.begin(), chunk.end()); |
| 278 | 292 |
| 279 } else if ((pos = line.find(kCpuKey)) != string::npos) { | 293 } else if ((pos = line.find(kCpuKey)) != string::npos) { |
| 280 string cpu_state_str(line, pos + strlen(kCpuKey)); | 294 string cpu_state_str(line, pos + strlen(kCpuKey)); |
| 281 std::vector<uint8_t> cpu_state_raw = ParseHexBuf(cpu_state_str); | 295 std::vector<uint8_t> cpu_state_raw = ParseHexBuf(cpu_state_str); |
| 282 if (strcmp(arch.c_str(), kArmArchitecture) == 0) { | 296 if (strcmp(arch.c_str(), kArmArchitecture) == 0) { |
| 283 if (cpu_state_raw.size() != sizeof(MDRawContextARM)) { | 297 if (cpu_state_raw.size() != sizeof(MDRawContextARM)) { |
| 284 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() << | 298 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() |
| 285 " bytes instead of " << sizeof(MDRawContextARM) << std::endl; | 299 << " bytes instead of " << sizeof(MDRawContextARM) |
| 300 << std::endl; |
| 286 continue; | 301 continue; |
| 287 } | 302 } |
| 288 MDRawContextARM* arm = new MDRawContextARM(); | 303 MDRawContextARM* arm = new MDRawContextARM(); |
| 289 memcpy(arm, &cpu_state_raw[0], cpu_state_raw.size()); | 304 memcpy(arm, &cpu_state_raw[0], cpu_state_raw.size()); |
| 290 context_->SetContextARM(arm); | 305 context_->SetContextARM(arm); |
| 291 } else if (strcmp(arch.c_str(), kArm64Architecture) == 0) { | 306 } else if (strcmp(arch.c_str(), kArm64Architecture) == 0) { |
| 292 if (cpu_state_raw.size() != sizeof(MDRawContextARM64)) { | 307 if (cpu_state_raw.size() != sizeof(MDRawContextARM64)) { |
| 293 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() << | 308 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() |
| 294 " bytes instead of " << sizeof(MDRawContextARM64) << std::endl; | 309 << " bytes instead of " << sizeof(MDRawContextARM64) |
| 310 << std::endl; |
| 295 continue; | 311 continue; |
| 296 } | 312 } |
| 297 MDRawContextARM64* arm = new MDRawContextARM64(); | 313 MDRawContextARM64* arm = new MDRawContextARM64(); |
| 298 memcpy(arm, &cpu_state_raw[0], cpu_state_raw.size()); | 314 memcpy(arm, &cpu_state_raw[0], cpu_state_raw.size()); |
| 299 context_->SetContextARM64(arm); | 315 context_->SetContextARM64(arm); |
| 300 } else if (strcmp(arch.c_str(), kX86Architecture) == 0) { | 316 } else if (strcmp(arch.c_str(), kX86Architecture) == 0) { |
| 301 if (cpu_state_raw.size() != sizeof(MDRawContextX86)) { | 317 if (cpu_state_raw.size() != sizeof(MDRawContextX86)) { |
| 302 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() << | 318 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() |
| 303 " bytes instead of " << sizeof(MDRawContextX86) << std::endl; | 319 << " bytes instead of " << sizeof(MDRawContextX86) |
| 320 << std::endl; |
| 304 continue; | 321 continue; |
| 305 } | 322 } |
| 306 MDRawContextX86* x86 = new MDRawContextX86(); | 323 MDRawContextX86* x86 = new MDRawContextX86(); |
| 307 memcpy(x86, &cpu_state_raw[0], cpu_state_raw.size()); | 324 memcpy(x86, &cpu_state_raw[0], cpu_state_raw.size()); |
| 308 context_->SetContextX86(x86); | 325 context_->SetContextX86(x86); |
| 326 } else if (strcmp(arch.c_str(), kMipsArchitecture) == 0) { |
| 327 if (cpu_state_raw.size() != sizeof(MDRawContextMIPS)) { |
| 328 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() |
| 329 << " bytes instead of " << sizeof(MDRawContextMIPS) |
| 330 << std::endl; |
| 331 continue; |
| 332 } |
| 333 MDRawContextMIPS* mips = new MDRawContextMIPS(); |
| 334 memcpy(mips, &cpu_state_raw[0], cpu_state_raw.size()); |
| 335 context_->SetContextMIPS(mips); |
| 336 } else if (strcmp(arch.c_str(), kMips64Architecture) == 0) { |
| 337 if (cpu_state_raw.size() != sizeof(MDRawContextMIPS)) { |
| 338 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() |
| 339 << " bytes instead of " << sizeof(MDRawContextMIPS) |
| 340 << std::endl; |
| 341 continue; |
| 342 } |
| 343 MDRawContextMIPS* mips64 = new MDRawContextMIPS(); |
| 344 memcpy(mips64, &cpu_state_raw[0], cpu_state_raw.size()); |
| 345 context_->SetContextMIPS64(mips64); |
| 309 } else { | 346 } else { |
| 310 std::cerr << "Unsupported architecture: " << arch << std::endl; | 347 std::cerr << "Unsupported architecture: " << arch << std::endl; |
| 311 } | 348 } |
| 312 } else if ((pos = line.find(kGpuKey)) != string::npos) { | 349 } else if ((pos = line.find(kGpuKey)) != string::npos) { |
| 313 string gpu_str(line, pos + strlen(kGpuKey)); | 350 string gpu_str(line, pos + strlen(kGpuKey)); |
| 314 if (strcmp(gpu_str.c_str(), kGpuUnknown) != 0) { | 351 if (strcmp(gpu_str.c_str(), kGpuUnknown) != 0) { |
| 315 std::istringstream gpu_tokens(gpu_str); | 352 std::istringstream gpu_tokens(gpu_str); |
| 316 std::getline(gpu_tokens, system_info_->gl_version, '|'); | 353 std::getline(gpu_tokens, system_info_->gl_version, '|'); |
| 317 std::getline(gpu_tokens, system_info_->gl_vendor, '|'); | 354 std::getline(gpu_tokens, system_info_->gl_vendor, '|'); |
| 318 std::getline(gpu_tokens, system_info_->gl_renderer, '|'); | 355 std::getline(gpu_tokens, system_info_->gl_renderer, '|'); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 335 filename, // debug_file | 372 filename, // debug_file |
| 336 identifier, // debug_identifier | 373 identifier, // debug_identifier |
| 337 "")); // version | 374 "")); // version |
| 338 } | 375 } |
| 339 } | 376 } |
| 340 stack_region_->Init(stack_start, stack_content); | 377 stack_region_->Init(stack_start, stack_content); |
| 341 } | 378 } |
| 342 | 379 |
| 343 } // namespace google_breakpad | 380 } // namespace google_breakpad |
| 344 | 381 |
| OLD | NEW |