| 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 and the location of the archived Chrome symbols can |
| 385 // be determined directly from it. |
| 386 bool FinalizeCrashDoneAndroid() { |
| 387 base::android::BuildInfo* android_build_info = |
| 388 base::android::BuildInfo::GetInstance(); |
| 389 |
| 390 __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, |
| 391 "### ### ### ### ### ### ### ### ### ### ### ### ###"); |
| 392 __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, |
| 393 "Chrome build fingerprint:"); |
| 394 __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, |
| 395 android_build_info->package_version_name()); |
| 396 __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, |
| 397 android_build_info->package_version_code()); |
| 398 __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, |
| 399 CHROME_SYMBOLS_ID); |
| 400 __android_log_write(ANDROID_LOG_WARN, kGoogleBreakpad, |
| 401 "### ### ### ### ### ### ### ### ### ### ### ### ###"); |
| 402 return false; |
| 403 } |
| 404 |
| 405 bool CrashDoneNonBrowserAndroid(const MinidumpDescriptor& minidump, |
| 406 void* context, |
| 407 bool succeeded) { |
| 408 return FinalizeCrashDoneAndroid(); |
| 409 } |
| 410 #endif |
| 379 | 411 |
| 380 bool CrashDone(const MinidumpDescriptor& minidump, | 412 bool CrashDone(const MinidumpDescriptor& minidump, |
| 381 const bool upload, | 413 const bool upload, |
| 382 const bool succeeded) { | 414 const bool succeeded) { |
| 383 // WARNING: this code runs in a compromised context. It may not call into | 415 // WARNING: this code runs in a compromised context. It may not call into |
| 384 // libc nor allocate memory normally. | 416 // libc nor allocate memory normally. |
| 385 if (!succeeded) | 417 if (!succeeded) |
| 386 return false; | 418 return false; |
| 387 | 419 |
| 388 DCHECK(!minidump.IsFD()); | 420 DCHECK(!minidump.IsFD()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 404 info.crash_url_length = 0; | 436 info.crash_url_length = 0; |
| 405 info.guid = child_process_logging::g_client_id; | 437 info.guid = child_process_logging::g_client_id; |
| 406 info.guid_length = my_strlen(child_process_logging::g_client_id); | 438 info.guid_length = my_strlen(child_process_logging::g_client_id); |
| 407 info.distro = base::g_linux_distro; | 439 info.distro = base::g_linux_distro; |
| 408 info.distro_length = my_strlen(base::g_linux_distro); | 440 info.distro_length = my_strlen(base::g_linux_distro); |
| 409 info.upload = upload; | 441 info.upload = upload; |
| 410 info.process_start_time = g_process_start_time; | 442 info.process_start_time = g_process_start_time; |
| 411 info.oom_size = base::g_oom_size; | 443 info.oom_size = base::g_oom_size; |
| 412 info.pid = 0; | 444 info.pid = 0; |
| 413 HandleCrashDump(info); | 445 HandleCrashDump(info); |
| 446 #if defined(OS_ANDROID) |
| 447 return FinalizeCrashDoneAndroid(); |
| 448 #else |
| 414 return true; | 449 return true; |
| 450 #endif |
| 415 } | 451 } |
| 416 | 452 |
| 417 // Wrapper function, do not add more code here. | 453 // Wrapper function, do not add more code here. |
| 418 bool CrashDoneNoUpload(const MinidumpDescriptor& minidump, | 454 bool CrashDoneNoUpload(const MinidumpDescriptor& minidump, |
| 419 void* context, | 455 void* context, |
| 420 bool succeeded) { | 456 bool succeeded) { |
| 421 return CrashDone(minidump, false, succeeded); | 457 return CrashDone(minidump, false, succeeded); |
| 422 } | 458 } |
| 423 | 459 |
| 424 #if !defined(OS_ANDROID) | 460 #if !defined(OS_ANDROID) |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 IGNORE_RET(sys_close(fds[1])); | 607 IGNORE_RET(sys_close(fds[1])); |
| 572 return false; | 608 return false; |
| 573 } | 609 } |
| 574 IGNORE_RET(sys_close(fds[1])); | 610 IGNORE_RET(sys_close(fds[1])); |
| 575 | 611 |
| 576 if (HANDLE_EINTR(sys_read(fds[0], &b, 1)) != 1) { | 612 if (HANDLE_EINTR(sys_read(fds[0], &b, 1)) != 1) { |
| 577 static const char errmsg[] = "Parent failed to complete crash dump.\n"; | 613 static const char errmsg[] = "Parent failed to complete crash dump.\n"; |
| 578 WriteLog(errmsg, sizeof(errmsg)-1); | 614 WriteLog(errmsg, sizeof(errmsg)-1); |
| 579 } | 615 } |
| 580 | 616 |
| 617 #if defined(OS_ANDROID) |
| 618 // When false is returned, breakpad will continue to its minidump generator |
| 619 // and then to the HandlerCallback, which, in this case, is |
| 620 // CrashDoneNonBrowserAndroid(). |
| 621 return false; |
| 622 #else |
| 581 return true; | 623 return true; |
| 624 #endif |
| 582 } | 625 } |
| 583 | 626 |
| 584 void EnableNonBrowserCrashDumping() { | 627 void EnableNonBrowserCrashDumping() { |
| 585 const int fd = base::GlobalDescriptors::GetInstance()->Get(kCrashDumpSignal); | 628 const int fd = base::GlobalDescriptors::GetInstance()->Get(kCrashDumpSignal); |
| 586 g_is_crash_reporter_enabled = true; | 629 g_is_crash_reporter_enabled = true; |
| 587 // We deliberately leak this object. | 630 // We deliberately leak this object. |
| 588 DCHECK(!g_breakpad); | 631 DCHECK(!g_breakpad); |
| 632 |
| 633 ExceptionHandler::MinidumpCallback crash_done_callback = NULL; |
| 634 #if defined(OS_ANDROID) |
| 635 crash_done_callback = CrashDoneNonBrowserAndroid; |
| 636 #endif |
| 637 |
| 589 g_breakpad = new ExceptionHandler( | 638 g_breakpad = new ExceptionHandler( |
| 590 MinidumpDescriptor("/tmp"), // Unused but needed or Breakpad will assert. | 639 MinidumpDescriptor("/tmp"), // Unused but needed or Breakpad will assert. |
| 591 NULL, | 640 NULL, |
| 592 NULL, | 641 crash_done_callback, |
| 593 reinterpret_cast<void*>(fd), // Param passed to the crash handler. | 642 reinterpret_cast<void*>(fd), // Param passed to the crash handler. |
| 594 true, | 643 true, |
| 595 -1); | 644 -1); |
| 596 g_breakpad->set_crash_handler(NonBrowserCrashHandler); | 645 g_breakpad->set_crash_handler(NonBrowserCrashHandler); |
| 597 } | 646 } |
| 598 | 647 |
| 599 } // namespace | 648 } // namespace |
| 600 | 649 |
| 601 void LoadDataFromFile(google_breakpad::PageAllocator& allocator, | 650 void LoadDataFromFile(google_breakpad::PageAllocator& allocator, |
| 602 const BreakpadInfo& info, const char* filename, | 651 const BreakpadInfo& info, const char* filename, |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 logging::SetDumpWithoutCrashingFunction(&DumpProcess); | 1302 logging::SetDumpWithoutCrashingFunction(&DumpProcess); |
| 1254 #if defined(ADDRESS_SANITIZER) | 1303 #if defined(ADDRESS_SANITIZER) |
| 1255 // Register the callback for AddressSanitizer error reporting. | 1304 // Register the callback for AddressSanitizer error reporting. |
| 1256 __asan_set_error_report_callback(AsanLinuxBreakpadCallback); | 1305 __asan_set_error_report_callback(AsanLinuxBreakpadCallback); |
| 1257 #endif | 1306 #endif |
| 1258 } | 1307 } |
| 1259 | 1308 |
| 1260 bool IsCrashReporterEnabled() { | 1309 bool IsCrashReporterEnabled() { |
| 1261 return g_is_crash_reporter_enabled; | 1310 return g_is_crash_reporter_enabled; |
| 1262 } | 1311 } |
| OLD | NEW |