| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 7 |
| 8 #include "components/crash/content/app/breakpad_linux.h" | 8 #include "components/crash/content/app/breakpad_linux.h" |
| 9 | 9 |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 if (!succeeded) { | 732 if (!succeeded) { |
| 733 static const char msg[] = "Microdump crash handler failed.\n"; | 733 static const char msg[] = "Microdump crash handler failed.\n"; |
| 734 WriteLog(msg, sizeof(msg) - 1); | 734 WriteLog(msg, sizeof(msg) - 1); |
| 735 return false; | 735 return false; |
| 736 } | 736 } |
| 737 | 737 |
| 738 const bool is_browser_process = (context != nullptr); | 738 const bool is_browser_process = (context != nullptr); |
| 739 return FinalizeCrashDoneAndroid(is_browser_process); | 739 return FinalizeCrashDoneAndroid(is_browser_process); |
| 740 } | 740 } |
| 741 | 741 |
| 742 // The microdump handler does NOT upload anything. It just dumps out on the | |
| 743 // system console (logcat) a restricted and serialized variant of a minidump. | |
| 744 // See crbug.com/410294 for more details. | |
| 745 void InitMicrodumpCrashHandlerIfNecessary(const std::string& process_type) { | |
| 746 if (!GetCrashReporterClient()->ShouldEnableBreakpadMicrodumps()) | |
| 747 return; | |
| 748 | |
| 749 VLOG(1) << "Enabling microdumps crash handler (process_type:" | |
| 750 << process_type << ")"; | |
| 751 | |
| 752 // The exception handler runs in a compromised context and cannot use c_str() | |
| 753 // as that would require the heap. Therefore, we have to guarantee that the | |
| 754 // build fingerprint and product info pointers are always valid. | |
| 755 const char* product_name = nullptr; | |
| 756 const char* product_version = nullptr; | |
| 757 GetCrashReporterClient()->GetProductNameAndVersion(&product_name, | |
| 758 &product_version); | |
| 759 | |
| 760 const char* android_build_fp = | |
| 761 base::android::BuildInfo::GetInstance()->android_build_fp(); | |
| 762 | |
| 763 g_microdump_info.Get().Initialize(process_type, product_name, product_version, | |
| 764 android_build_fp); | |
| 765 } | |
| 766 | |
| 767 bool CrashDoneInProcessNoUpload( | 742 bool CrashDoneInProcessNoUpload( |
| 768 const google_breakpad::MinidumpDescriptor& descriptor, | 743 const google_breakpad::MinidumpDescriptor& descriptor, |
| 769 void* context, | 744 void* context, |
| 770 const bool succeeded) { | 745 const bool succeeded) { |
| 771 // WARNING: this code runs in a compromised context. It may not call into | 746 // WARNING: this code runs in a compromised context. It may not call into |
| 772 // libc nor allocate memory normally. | 747 // libc nor allocate memory normally. |
| 773 if (!succeeded) { | 748 if (!succeeded) { |
| 774 static const char msg[] = "Crash dump generation failed.\n"; | 749 static const char msg[] = "Crash dump generation failed.\n"; |
| 775 WriteLog(msg, sizeof(msg) - 1); | 750 WriteLog(msg, sizeof(msg) - 1); |
| 776 return false; | 751 return false; |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1851 GetCrashReporterClient()->GetAndroidMinidumpDescriptor()); | 1826 GetCrashReporterClient()->GetAndroidMinidumpDescriptor()); |
| 1852 if (minidump_fd < 0) { | 1827 if (minidump_fd < 0) { |
| 1853 NOTREACHED() << "Could not find minidump FD, crash reporting disabled."; | 1828 NOTREACHED() << "Could not find minidump FD, crash reporting disabled."; |
| 1854 } else { | 1829 } else { |
| 1855 InitCrashKeys(); | 1830 InitCrashKeys(); |
| 1856 EnableNonBrowserCrashDumping(process_type, minidump_fd); | 1831 EnableNonBrowserCrashDumping(process_type, minidump_fd); |
| 1857 } | 1832 } |
| 1858 } | 1833 } |
| 1859 } | 1834 } |
| 1860 | 1835 |
| 1836 // The microdump handler does NOT upload anything. It just dumps out on the |
| 1837 // system console (logcat) a restricted and serialized variant of a minidump. |
| 1838 // See crbug.com/410294 for more details. |
| 1839 void InitMicrodumpCrashHandlerIfNecessary(const std::string& process_type) { |
| 1840 if (!GetCrashReporterClient()->ShouldEnableBreakpadMicrodumps()) |
| 1841 return; |
| 1842 |
| 1843 VLOG(1) << "Enabling microdumps crash handler (process_type:" |
| 1844 << process_type << ")"; |
| 1845 |
| 1846 // The exception handler runs in a compromised context and cannot use c_str() |
| 1847 // as that would require the heap. Therefore, we have to guarantee that the |
| 1848 // build fingerprint and product info pointers are always valid. |
| 1849 const char* product_name = nullptr; |
| 1850 const char* product_version = nullptr; |
| 1851 GetCrashReporterClient()->GetProductNameAndVersion(&product_name, |
| 1852 &product_version); |
| 1853 |
| 1854 const char* android_build_fp = |
| 1855 base::android::BuildInfo::GetInstance()->android_build_fp(); |
| 1856 |
| 1857 g_microdump_info.Get().Initialize(process_type, product_name, product_version, |
| 1858 android_build_fp); |
| 1859 } |
| 1860 |
| 1861 void AddGpuFingerprintToMicrodumpCrashHandler( | 1861 void AddGpuFingerprintToMicrodumpCrashHandler( |
| 1862 const std::string& gpu_fingerprint) { | 1862 const std::string& gpu_fingerprint) { |
| 1863 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint); | 1863 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint); |
| 1864 } | 1864 } |
| 1865 #endif // OS_ANDROID | 1865 #endif // OS_ANDROID |
| 1866 | 1866 |
| 1867 bool IsCrashReporterEnabled() { | 1867 bool IsCrashReporterEnabled() { |
| 1868 return g_is_crash_reporter_enabled; | 1868 return g_is_crash_reporter_enabled; |
| 1869 } | 1869 } |
| 1870 | 1870 |
| 1871 } // namespace breakpad | 1871 } // namespace breakpad |
| OLD | NEW |