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

Side by Side Diff: src/processor/microdump.cc

Issue 1704243002: Support processing microdumps for x86 architecture. (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Add the testdata file. Created 4 years, 10 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
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 static const char kMicrodumpBegin[] = "-----BEGIN BREAKPAD MICRODUMP-----"; 53 static const char kMicrodumpBegin[] = "-----BEGIN BREAKPAD MICRODUMP-----";
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 kGpuUnknown[] = "UNKNOWN"; 64 static const char kGpuUnknown[] = "UNKNOWN";
64 65
65 template<typename T> 66 template<typename T>
66 T HexStrToL(const string& str) { 67 T HexStrToL(const string& str) {
67 uint64_t res = 0; 68 uint64_t res = 0;
68 std::istringstream ss(str); 69 std::istringstream ss(str);
69 ss >> std::hex >> res; 70 ss >> std::hex >> res;
70 return static_cast<T>(res); 71 return static_cast<T>(res);
71 } 72 }
72 73
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 DumpContext::SetContextARM(arm); 118 DumpContext::SetContextARM(arm);
118 valid_ = true; 119 valid_ = true;
119 } 120 }
120 121
121 void MicrodumpContext::SetContextARM64(MDRawContextARM64* arm64) { 122 void MicrodumpContext::SetContextARM64(MDRawContextARM64* arm64) {
122 DumpContext::SetContextFlags(MD_CONTEXT_ARM64); 123 DumpContext::SetContextFlags(MD_CONTEXT_ARM64);
123 DumpContext::SetContextARM64(arm64); 124 DumpContext::SetContextARM64(arm64);
124 valid_ = true; 125 valid_ = true;
125 } 126 }
126 127
128 void MicrodumpContext::SetContextX86(MDRawContextX86* x86) {
129 DumpContext::SetContextFlags(MD_CONTEXT_X86);
130 DumpContext::SetContextX86(x86);
131 valid_ = true;
132 }
133
127 134
128 // 135 //
129 // MicrodumpMemoryRegion 136 // MicrodumpMemoryRegion
130 // 137 //
131 138
132 MicrodumpMemoryRegion::MicrodumpMemoryRegion() : base_address_(0) { } 139 MicrodumpMemoryRegion::MicrodumpMemoryRegion() : base_address_(0) { }
133 140
134 void MicrodumpMemoryRegion::Init(uint64_t base_address, 141 void MicrodumpMemoryRegion::Init(uint64_t base_address,
135 const std::vector<uint8_t>& contents) { 142 const std::vector<uint8_t>& contents) {
136 base_address_ = base_address; 143 base_address_ = base_address;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 context_->SetContextARM(arm); 291 context_->SetContextARM(arm);
285 } else if (strcmp(arch.c_str(), kArm64Architecture) == 0) { 292 } else if (strcmp(arch.c_str(), kArm64Architecture) == 0) {
286 if (cpu_state_raw.size() != sizeof(MDRawContextARM64)) { 293 if (cpu_state_raw.size() != sizeof(MDRawContextARM64)) {
287 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() << 294 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() <<
288 " bytes instead of " << sizeof(MDRawContextARM64) << std::endl; 295 " bytes instead of " << sizeof(MDRawContextARM64) << std::endl;
289 continue; 296 continue;
290 } 297 }
291 MDRawContextARM64* arm = new MDRawContextARM64(); 298 MDRawContextARM64* arm = new MDRawContextARM64();
292 memcpy(arm, &cpu_state_raw[0], cpu_state_raw.size()); 299 memcpy(arm, &cpu_state_raw[0], cpu_state_raw.size());
293 context_->SetContextARM64(arm); 300 context_->SetContextARM64(arm);
301 } else if (strcmp(arch.c_str(), kX86Architecture) == 0) {
302 if (cpu_state_raw.size() != sizeof(MDRawContextX86)) {
303 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() <<
304 " bytes instead of " << sizeof(MDRawContextX86) << std::endl;
305 continue;
306 }
307 MDRawContextX86* x86 = new MDRawContextX86();
308 memcpy(x86, &cpu_state_raw[0], cpu_state_raw.size());
309 context_->SetContextX86(x86);
294 } else { 310 } else {
295 std::cerr << "Unsupported architecture: " << arch << std::endl; 311 std::cerr << "Unsupported architecture: " << arch << std::endl;
296 } 312 }
297 } else if ((pos = line.find(kGpuKey)) != string::npos) { 313 } else if ((pos = line.find(kGpuKey)) != string::npos) {
298 string gpu_str(line, pos + strlen(kGpuKey)); 314 string gpu_str(line, pos + strlen(kGpuKey));
299 if (strcmp(gpu_str.c_str(), kGpuUnknown) != 0) { 315 if (strcmp(gpu_str.c_str(), kGpuUnknown) != 0) {
300 std::istringstream gpu_tokens(gpu_str); 316 std::istringstream gpu_tokens(gpu_str);
301 std::getline(gpu_tokens, system_info_->gl_version, '|'); 317 std::getline(gpu_tokens, system_info_->gl_version, '|');
302 std::getline(gpu_tokens, system_info_->gl_vendor, '|'); 318 std::getline(gpu_tokens, system_info_->gl_vendor, '|');
303 std::getline(gpu_tokens, system_info_->gl_renderer, '|'); 319 std::getline(gpu_tokens, system_info_->gl_renderer, '|');
(...skipping 16 matching lines...) Expand all
320 filename, // debug_file 336 filename, // debug_file
321 identifier, // debug_identifier 337 identifier, // debug_identifier
322 "")); // version 338 "")); // version
323 } 339 }
324 } 340 }
325 stack_region_->Init(stack_start, stack_content); 341 stack_region_->Init(stack_start, stack_content);
326 } 342 }
327 343
328 } // namespace google_breakpad 344 } // namespace google_breakpad
329 345
OLDNEW
« no previous file with comments | « src/google_breakpad/processor/microdump.h ('k') | src/processor/microdump_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698