Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // For linux_syscall_support.h. This makes it safe to call embedded system | 5 // For linux_syscall_support.h. This makes it safe to call embedded system |
| 6 // calls when in seccomp mode. | 6 // calls when in seccomp mode. |
| 7 #define SYS_SYSCALL_ENTRYPOINT "playground$syscallEntryPoint" | 7 #define SYS_SYSCALL_ENTRYPOINT "playground$syscallEntryPoint" |
| 8 | 8 |
| 9 #include "chrome/app/breakpad_linux.h" | 9 #include "chrome/app/breakpad_linux.h" |
| 10 | 10 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 const char kGoogleBreakpad[] = "google-breakpad"; | 369 const char kGoogleBreakpad[] = "google-breakpad"; |
| 370 | 370 |
| 371 size_t WriteLog(const char* buf, size_t nbytes) { | 371 size_t WriteLog(const char* buf, size_t nbytes) { |
| 372 #if defined(OS_ANDROID) | 372 #if defined(OS_ANDROID) |
| 373 return __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, buf); | 373 return __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, buf); |
| 374 #else | 374 #else |
| 375 return sys_write(2, buf, nbytes); | 375 return sys_write(2, buf, nbytes); |
| 376 #endif | 376 #endif |
| 377 } | 377 } |
| 378 | 378 |
| 379 #if defined(OS_ANDROID) | |
| 380 // Android's native crash handler outputs a diagnostic tombstone to the device | |
| 381 // log. By returning false from the HandlerCallbacks, breakpad will reinstall | |
| 382 // the previous (i.e. native) signal handlers before returning from its own | |
| 383 // handler. A Chrome build fingerprint is written to the log, so that the | |
| 384 // specific build of Chrome can be determined directly from it. | |
| 385 bool FinalizeCrashDoneAndroid() { | |
| 386 base::android::BuildInfo* android_build_info = | |
| 387 base::android::BuildInfo::GetInstance(); | |
| 388 | |
| 389 __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, | |
| 390 "### ### ### ### ### ### ### ### ### ### ### ### ###"); | |
| 391 __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, | |
| 392 "Chrome build fingerprint:"); | |
| 393 __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, | |
| 394 android_build_info->package_version_name()); | |
| 395 __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, | |
| 396 android_build_info->package_version_code()); | |
|
Mark Mentovai
2012/09/07 20:22:36
Isn’t the name and version number of an official b
| |
| 397 __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, | |
| 398 CHROME_SYMBOLS_LOCATION); | |
| 399 __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, | |
| 400 "### ### ### ### ### ### ### ### ### ### ### ### ###"); | |
| 401 return false; | |
| 402 } | |
| 403 | |
| 404 bool CrashDoneNonBrowserAndroid(const MinidumpDescriptor& minidump, | |
| 405 void* context, | |
| 406 bool succeeded) { | |
| 407 return FinalizeCrashDoneAndroid(); | |
| 408 } | |
| 409 #endif | |
| 379 | 410 |
| 380 bool CrashDone(const MinidumpDescriptor& minidump, | 411 bool CrashDone(const MinidumpDescriptor& minidump, |
| 381 const bool upload, | 412 const bool upload, |
| 382 const bool succeeded) { | 413 const bool succeeded) { |
| 383 // WARNING: this code runs in a compromised context. It may not call into | 414 // WARNING: this code runs in a compromised context. It may not call into |
| 384 // libc nor allocate memory normally. | 415 // libc nor allocate memory normally. |
| 385 if (!succeeded) | 416 if (!succeeded) |
| 386 return false; | 417 return false; |
| 387 | 418 |
| 388 DCHECK(!minidump.IsFD()); | 419 DCHECK(!minidump.IsFD()); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 404 info.crash_url_length = 0; | 435 info.crash_url_length = 0; |
| 405 info.guid = child_process_logging::g_client_id; | 436 info.guid = child_process_logging::g_client_id; |
| 406 info.guid_length = my_strlen(child_process_logging::g_client_id); | 437 info.guid_length = my_strlen(child_process_logging::g_client_id); |
| 407 info.distro = base::g_linux_distro; | 438 info.distro = base::g_linux_distro; |
| 408 info.distro_length = my_strlen(base::g_linux_distro); | 439 info.distro_length = my_strlen(base::g_linux_distro); |
| 409 info.upload = upload; | 440 info.upload = upload; |
| 410 info.process_start_time = g_process_start_time; | 441 info.process_start_time = g_process_start_time; |
| 411 info.oom_size = base::g_oom_size; | 442 info.oom_size = base::g_oom_size; |
| 412 info.pid = 0; | 443 info.pid = 0; |
| 413 HandleCrashDump(info); | 444 HandleCrashDump(info); |
| 445 #if defined(OS_ANDROID) | |
| 446 return FinalizeCrashDoneAndroid(); | |
| 447 #else | |
| 414 return true; | 448 return true; |
| 449 #endif | |
| 415 } | 450 } |
| 416 | 451 |
| 417 // Wrapper function, do not add more code here. | 452 // Wrapper function, do not add more code here. |
| 418 bool CrashDoneNoUpload(const MinidumpDescriptor& minidump, | 453 bool CrashDoneNoUpload(const MinidumpDescriptor& minidump, |
| 419 void* context, | 454 void* context, |
| 420 bool succeeded) { | 455 bool succeeded) { |
| 421 return CrashDone(minidump, false, succeeded); | 456 return CrashDone(minidump, false, succeeded); |
| 422 } | 457 } |
| 423 | 458 |
| 424 #if !defined(OS_ANDROID) | 459 #if !defined(OS_ANDROID) |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 IGNORE_RET(sys_close(fds[1])); | 606 IGNORE_RET(sys_close(fds[1])); |
| 572 return false; | 607 return false; |
| 573 } | 608 } |
| 574 IGNORE_RET(sys_close(fds[1])); | 609 IGNORE_RET(sys_close(fds[1])); |
| 575 | 610 |
| 576 if (HANDLE_EINTR(sys_read(fds[0], &b, 1)) != 1) { | 611 if (HANDLE_EINTR(sys_read(fds[0], &b, 1)) != 1) { |
| 577 static const char errmsg[] = "Parent failed to complete crash dump.\n"; | 612 static const char errmsg[] = "Parent failed to complete crash dump.\n"; |
| 578 WriteLog(errmsg, sizeof(errmsg)-1); | 613 WriteLog(errmsg, sizeof(errmsg)-1); |
| 579 } | 614 } |
| 580 | 615 |
| 616 #if defined(OS_ANDROID) | |
| 617 // When false is returned, breakpad will continue to its minidump generator | |
| 618 // and then to the HandlerCallback, which, in this case, is | |
| 619 // CrashDoneNonBrowserAndroid(). | |
| 620 return false; | |
| 621 #else | |
| 581 return true; | 622 return true; |
|
Yaron
2012/09/07 20:15:17
Just wondering why other ports return true here as
| |
| 623 #endif | |
| 582 } | 624 } |
| 583 | 625 |
| 584 void EnableNonBrowserCrashDumping() { | 626 void EnableNonBrowserCrashDumping() { |
| 585 const int fd = base::GlobalDescriptors::GetInstance()->Get(kCrashDumpSignal); | 627 const int fd = base::GlobalDescriptors::GetInstance()->Get(kCrashDumpSignal); |
| 586 g_is_crash_reporter_enabled = true; | 628 g_is_crash_reporter_enabled = true; |
| 587 // We deliberately leak this object. | 629 // We deliberately leak this object. |
| 588 DCHECK(!g_breakpad); | 630 DCHECK(!g_breakpad); |
| 631 | |
| 632 ExceptionHandler::MinidumpCallback crash_done_callback = NULL; | |
| 633 #if defined(OS_ANDROID) | |
| 634 crash_done_callback = CrashDoneNonBrowserAndroid; | |
| 635 #endif | |
| 636 | |
| 589 g_breakpad = new ExceptionHandler( | 637 g_breakpad = new ExceptionHandler( |
| 590 MinidumpDescriptor("/tmp"), // Unused but needed or Breakpad will assert. | 638 MinidumpDescriptor("/tmp"), // Unused but needed or Breakpad will assert. |
| 591 NULL, | 639 NULL, |
| 592 NULL, | 640 crash_done_callback, |
| 593 reinterpret_cast<void*>(fd), // Param passed to the crash handler. | 641 reinterpret_cast<void*>(fd), // Param passed to the crash handler. |
| 594 true, | 642 true, |
| 595 -1); | 643 -1); |
| 596 g_breakpad->set_crash_handler(NonBrowserCrashHandler); | 644 g_breakpad->set_crash_handler(NonBrowserCrashHandler); |
| 597 } | 645 } |
| 598 | 646 |
| 599 } // namespace | 647 } // namespace |
| 600 | 648 |
| 601 void LoadDataFromFile(google_breakpad::PageAllocator& allocator, | 649 void LoadDataFromFile(google_breakpad::PageAllocator& allocator, |
| 602 const BreakpadInfo& info, const char* filename, | 650 const BreakpadInfo& info, const char* filename, |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1253 logging::SetDumpWithoutCrashingFunction(&DumpProcess); | 1301 logging::SetDumpWithoutCrashingFunction(&DumpProcess); |
| 1254 #if defined(ADDRESS_SANITIZER) | 1302 #if defined(ADDRESS_SANITIZER) |
| 1255 // Register the callback for AddressSanitizer error reporting. | 1303 // Register the callback for AddressSanitizer error reporting. |
| 1256 __asan_set_error_report_callback(AsanLinuxBreakpadCallback); | 1304 __asan_set_error_report_callback(AsanLinuxBreakpadCallback); |
| 1257 #endif | 1305 #endif |
| 1258 } | 1306 } |
| 1259 | 1307 |
| 1260 bool IsCrashReporterEnabled() { | 1308 bool IsCrashReporterEnabled() { |
| 1261 return g_is_crash_reporter_enabled; | 1309 return g_is_crash_reporter_enabled; |
| 1262 } | 1310 } |
| OLD | NEW |