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

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

Issue 1731923002: Support processing microdump for mips architecture (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
68
Primiano Tucci (use gerrit) 2016/02/25 01:08:07 nit: spurious extra line?
mveljko 2016/02/25 09:29:50 Done. Removed it.
66 template<typename T> 69 template<typename T>
67 T HexStrToL(const string& str) { 70 T HexStrToL(const string& str) {
68 uint64_t res = 0; 71 uint64_t res = 0;
69 std::istringstream ss(str); 72 std::istringstream ss(str);
70 ss >> std::hex >> res; 73 ss >> std::hex >> res;
71 return static_cast<T>(res); 74 return static_cast<T>(res);
72 } 75 }
73 76
74 std::vector<uint8_t> ParseHexBuf(const string& str) { 77 std::vector<uint8_t> ParseHexBuf(const string& str) {
75 std::vector<uint8_t> buf; 78 std::vector<uint8_t> buf;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 DumpContext::SetContextARM64(arm64); 127 DumpContext::SetContextARM64(arm64);
125 valid_ = true; 128 valid_ = true;
126 } 129 }
127 130
128 void MicrodumpContext::SetContextX86(MDRawContextX86* x86) { 131 void MicrodumpContext::SetContextX86(MDRawContextX86* x86) {
129 DumpContext::SetContextFlags(MD_CONTEXT_X86); 132 DumpContext::SetContextFlags(MD_CONTEXT_X86);
130 DumpContext::SetContextX86(x86); 133 DumpContext::SetContextX86(x86);
131 valid_ = true; 134 valid_ = true;
132 } 135 }
133 136
137 void MicrodumpContext::SetContextMIPS(MDRawContextMIPS* mips, bool arch64) {
vapier 2016/02/24 22:35:43 i haven't looked closely, but why do we need these
mveljko 2016/02/25 09:29:51 I don't know really why, maybe so that the code wo
138 if (arch64) {
139 DumpContext::SetContextFlags(MD_CONTEXT_MIPS64);
140 } else {
141 DumpContext::SetContextFlags(MD_CONTEXT_MIPS);
142 }
143 DumpContext::SetContextMIPS(mips);
144 valid_ = true;
145 }
146
134 147
135 // 148 //
136 // MicrodumpMemoryRegion 149 // MicrodumpMemoryRegion
137 // 150 //
138 151
139 MicrodumpMemoryRegion::MicrodumpMemoryRegion() : base_address_(0) { } 152 MicrodumpMemoryRegion::MicrodumpMemoryRegion() : base_address_(0) { }
140 153
141 void MicrodumpMemoryRegion::Init(uint64_t base_address, 154 void MicrodumpMemoryRegion::Init(uint64_t base_address,
142 const std::vector<uint8_t>& contents) { 155 const std::vector<uint8_t>& contents) {
143 base_address_ = base_address; 156 base_address_ = base_address;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 context_->SetContextARM64(arm); 313 context_->SetContextARM64(arm);
301 } else if (strcmp(arch.c_str(), kX86Architecture) == 0) { 314 } else if (strcmp(arch.c_str(), kX86Architecture) == 0) {
302 if (cpu_state_raw.size() != sizeof(MDRawContextX86)) { 315 if (cpu_state_raw.size() != sizeof(MDRawContextX86)) {
303 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() << 316 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() <<
304 " bytes instead of " << sizeof(MDRawContextX86) << std::endl; 317 " bytes instead of " << sizeof(MDRawContextX86) << std::endl;
305 continue; 318 continue;
306 } 319 }
307 MDRawContextX86* x86 = new MDRawContextX86(); 320 MDRawContextX86* x86 = new MDRawContextX86();
308 memcpy(x86, &cpu_state_raw[0], cpu_state_raw.size()); 321 memcpy(x86, &cpu_state_raw[0], cpu_state_raw.size());
309 context_->SetContextX86(x86); 322 context_->SetContextX86(x86);
323 } else if (strcmp(arch.c_str(), kMipsArchitecture) == 0 ||
324 strcmp(arch.c_str(), kMips64Architecture) == 0) {
vapier 2016/02/24 22:35:43 indentation looks off here
mveljko 2016/02/25 09:29:50 Fixed this when I separated the functions.
325 if (cpu_state_raw.size() != sizeof(MDRawContextMIPS)) {
326 std::cerr << "Malformed CPU context. Got " << cpu_state_raw.size() <<
327 " bytes instead of " << sizeof(MDRawContextMIPS) << std::endl;
vapier 2016/02/24 22:35:43 indentation looks off here
mveljko 2016/02/25 09:29:50 I checked the if branches for arm/arm64/x86 and th
vapier 2016/02/25 16:15:44 this looks like the only file that wraps cout/cerr
mveljko 2016/02/25 16:35:25 So should I fix this in the whole file or just MIP
Primiano Tucci (use gerrit) 2016/02/25 17:00:15 Fix also the others. I think it's easier if you ru
mveljko 2016/02/26 10:43:54 I ran the file through clang-format and the result
328 continue;
329 }
330 MDRawContextMIPS* mips = new MDRawContextMIPS();
331 memcpy(mips, &cpu_state_raw[0], cpu_state_raw.size());
332 context_->SetContextMIPS(mips,
333 strcmp(arch.c_str(), kMips64Architecture)? false:true);
310 } else { 334 } else {
311 std::cerr << "Unsupported architecture: " << arch << std::endl; 335 std::cerr << "Unsupported architecture: " << arch << std::endl;
312 } 336 }
313 } else if ((pos = line.find(kGpuKey)) != string::npos) { 337 } else if ((pos = line.find(kGpuKey)) != string::npos) {
314 string gpu_str(line, pos + strlen(kGpuKey)); 338 string gpu_str(line, pos + strlen(kGpuKey));
315 if (strcmp(gpu_str.c_str(), kGpuUnknown) != 0) { 339 if (strcmp(gpu_str.c_str(), kGpuUnknown) != 0) {
316 std::istringstream gpu_tokens(gpu_str); 340 std::istringstream gpu_tokens(gpu_str);
317 std::getline(gpu_tokens, system_info_->gl_version, '|'); 341 std::getline(gpu_tokens, system_info_->gl_version, '|');
318 std::getline(gpu_tokens, system_info_->gl_vendor, '|'); 342 std::getline(gpu_tokens, system_info_->gl_vendor, '|');
319 std::getline(gpu_tokens, system_info_->gl_renderer, '|'); 343 std::getline(gpu_tokens, system_info_->gl_renderer, '|');
(...skipping 16 matching lines...) Expand all
336 filename, // debug_file 360 filename, // debug_file
337 identifier, // debug_identifier 361 identifier, // debug_identifier
338 "")); // version 362 "")); // version
339 } 363 }
340 } 364 }
341 stack_region_->Init(stack_start, stack_content); 365 stack_region_->Init(stack_start, stack_content);
342 } 366 }
343 367
344 } // namespace google_breakpad 368 } // namespace google_breakpad
345 369
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698