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()); | |
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. | |
Lei Zhang
2012/09/06 19:13:36
nit: CrashDoneNonBrowserAndroid()
cjhopman
2012/09/07 18:09:20
Done.
| |
620 return false; | |
621 #else | |
581 return true; | 622 return true; |
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 #if defined(OS_ANDROID) | |
589 g_breakpad = new ExceptionHandler( | 632 g_breakpad = new ExceptionHandler( |
590 MinidumpDescriptor("/tmp"), // Unused but needed or Breakpad will assert. | 633 MinidumpDescriptor("/tmp"), // Unused but needed or Breakpad will assert. |
591 NULL, | 634 NULL, |
635 CrashDoneNonBrowserAndroid, | |
Lei Zhang
2012/09/06 19:13:36
Would it be easier to avoid duplicating the code b
cjhopman
2012/09/07 18:09:20
Done.
| |
636 reinterpret_cast<void*>(fd), // Param passed to the crash handler. | |
637 true, | |
638 -1); | |
639 #else | |
640 g_breakpad = new ExceptionHandler( | |
641 MinidumpDescriptor("/tmp"), // Unused but needed or Breakpad will assert. | |
642 NULL, | |
592 NULL, | 643 NULL, |
593 reinterpret_cast<void*>(fd), // Param passed to the crash handler. | 644 reinterpret_cast<void*>(fd), // Param passed to the crash handler. |
594 true, | 645 true, |
595 -1); | 646 -1); |
647 #endif | |
596 g_breakpad->set_crash_handler(NonBrowserCrashHandler); | 648 g_breakpad->set_crash_handler(NonBrowserCrashHandler); |
597 } | 649 } |
598 | 650 |
599 } // namespace | 651 } // namespace |
600 | 652 |
601 void LoadDataFromFile(google_breakpad::PageAllocator& allocator, | 653 void LoadDataFromFile(google_breakpad::PageAllocator& allocator, |
602 const BreakpadInfo& info, const char* filename, | 654 const BreakpadInfo& info, const char* filename, |
603 int* fd, uint8_t** file_data, size_t* size) { | 655 int* fd, uint8_t** file_data, size_t* size) { |
604 // WARNING: this code runs in a compromised context. It may not call into | 656 // WARNING: this code runs in a compromised context. It may not call into |
605 // libc nor allocate memory normally. | 657 // libc nor allocate memory normally. |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1253 logging::SetDumpWithoutCrashingFunction(&DumpProcess); | 1305 logging::SetDumpWithoutCrashingFunction(&DumpProcess); |
1254 #if defined(ADDRESS_SANITIZER) | 1306 #if defined(ADDRESS_SANITIZER) |
1255 // Register the callback for AddressSanitizer error reporting. | 1307 // Register the callback for AddressSanitizer error reporting. |
1256 __asan_set_error_report_callback(AsanLinuxBreakpadCallback); | 1308 __asan_set_error_report_callback(AsanLinuxBreakpadCallback); |
1257 #endif | 1309 #endif |
1258 } | 1310 } |
1259 | 1311 |
1260 bool IsCrashReporterEnabled() { | 1312 bool IsCrashReporterEnabled() { |
1261 return g_is_crash_reporter_enabled; | 1313 return g_is_crash_reporter_enabled; |
1262 } | 1314 } |
OLD | NEW |