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

Side by Side Diff: components/crash/content/app/breakpad_linux.cc

Issue 1525023003: Distinguish in the browser between renderer crashes and kills (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed Created 5 years 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
« no previous file with comments | « components/crash.gypi ('k') | components/crash/content/browser/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 bool g_is_crash_reporter_enabled = false; 89 bool g_is_crash_reporter_enabled = false;
90 uint64_t g_process_start_time = 0; 90 uint64_t g_process_start_time = 0;
91 pid_t g_pid = 0; 91 pid_t g_pid = 0;
92 char* g_crash_log_path = nullptr; 92 char* g_crash_log_path = nullptr;
93 ExceptionHandler* g_breakpad = nullptr; 93 ExceptionHandler* g_breakpad = nullptr;
94 94
95 #if defined(ADDRESS_SANITIZER) 95 #if defined(ADDRESS_SANITIZER)
96 const char* g_asan_report_str = nullptr; 96 const char* g_asan_report_str = nullptr;
97 #endif 97 #endif
98 #if defined(OS_ANDROID) 98 #if defined(OS_ANDROID)
99 const char kWebViewProcessType[] = "webview";
99 char* g_process_type = nullptr; 100 char* g_process_type = nullptr;
100 ExceptionHandler* g_microdump = nullptr; 101 ExceptionHandler* g_microdump = nullptr;
102 int g_signal_code_pipe_fd = -1;
101 103
102 class MicrodumpInfo { 104 class MicrodumpInfo {
103 public: 105 public:
104 MicrodumpInfo() 106 MicrodumpInfo()
105 : microdump_build_fingerprint_(nullptr), 107 : microdump_build_fingerprint_(nullptr),
106 microdump_product_info_(nullptr), 108 microdump_product_info_(nullptr),
107 microdump_gpu_fingerprint_(nullptr) {} 109 microdump_gpu_fingerprint_(nullptr) {}
108 110
109 // The order in which SetGpuFingerprint and Initialize are called 111 // The order in which SetGpuFingerprint and Initialize are called
110 // may be dependent on the timing of the availability of GPU 112 // may be dependent on the timing of the availability of GPU
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 // WARNING: this code runs in a compromised context. It may not call into 732 // WARNING: this code runs in a compromised context. It may not call into
731 // libc nor allocate memory normally. 733 // libc nor allocate memory normally.
732 if (!succeeded) { 734 if (!succeeded) {
733 static const char msg[] = "Microdump crash handler failed.\n"; 735 static const char msg[] = "Microdump crash handler failed.\n";
734 WriteLog(msg, sizeof(msg) - 1); 736 WriteLog(msg, sizeof(msg) - 1);
735 return false; 737 return false;
736 } 738 }
737 739
738 const bool is_browser_process = (context != nullptr); 740 const bool is_browser_process = (context != nullptr);
739 return FinalizeCrashDoneAndroid(is_browser_process); 741 return FinalizeCrashDoneAndroid(is_browser_process);
740 } 742 }
743
744 bool WriteSignalCodeToPipe(const void* crash_context,
745 size_t crash_context_size,
746 void* context) {
747 if (g_signal_code_pipe_fd == -1 ||
748 crash_context_size != sizeof(ExceptionHandler::CrashContext))
749 return false;
Peter Wen 2015/12/21 14:49:24 If context size is wrong, then should this be trea
mnaganov (inactive) 2015/12/21 17:24:44 If the context size is of an unexpected value, tha
750 const ExceptionHandler::CrashContext* eh_context =
751 static_cast<const ExceptionHandler::CrashContext*>(crash_context);
752 int signo = eh_context->siginfo.si_signo;
753 sys_write(g_signal_code_pipe_fd, &signo, sizeof(signo));
754 IGNORE_RET(sys_close(g_signal_code_pipe_fd));
755 g_signal_code_pipe_fd = -1;
756 return false;
757 }
741 758
742 bool CrashDoneInProcessNoUpload( 759 bool CrashDoneInProcessNoUpload(
743 const google_breakpad::MinidumpDescriptor& descriptor, 760 const google_breakpad::MinidumpDescriptor& descriptor,
744 void* context, 761 void* context,
745 const bool succeeded) { 762 const bool succeeded) {
746 // WARNING: this code runs in a compromised context. It may not call into 763 // WARNING: this code runs in a compromised context. It may not call into
747 // libc nor allocate memory normally. 764 // libc nor allocate memory normally.
748 if (!succeeded) { 765 if (!succeeded) {
749 static const char msg[] = "Crash dump generation failed.\n"; 766 static const char msg[] = "Crash dump generation failed.\n";
750 WriteLog(msg, sizeof(msg) - 1); 767 WriteLog(msg, sizeof(msg) - 1);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 g_microdump->set_minidump_descriptor(minidump_descriptor); 840 g_microdump->set_minidump_descriptor(minidump_descriptor);
824 } 841 }
825 } 842 }
826 843
827 void MicrodumpInfo::Initialize(const std::string& process_type, 844 void MicrodumpInfo::Initialize(const std::string& process_type,
828 const char* product_name, 845 const char* product_name,
829 const char* product_version, 846 const char* product_version,
830 const char* android_build_fp) { 847 const char* android_build_fp) {
831 DCHECK(thread_checker_.CalledOnValidThread()); 848 DCHECK(thread_checker_.CalledOnValidThread());
832 DCHECK(!g_microdump); 849 DCHECK(!g_microdump);
833 bool is_browser_process = process_type.empty() || process_type == "webview"; 850 bool is_browser_process =
851 process_type.empty() || process_type == kWebViewProcessType;
834 852
835 MinidumpDescriptor descriptor(MinidumpDescriptor::kMicrodumpOnConsole); 853 MinidumpDescriptor descriptor(MinidumpDescriptor::kMicrodumpOnConsole);
836 854
837 if (product_name && product_version) { 855 if (product_name && product_version) {
838 microdump_product_info_ = 856 microdump_product_info_ =
839 strdup((product_name + std::string(":") + product_version).c_str()); 857 strdup((product_name + std::string(":") + product_version).c_str());
840 ANNOTATE_LEAKING_OBJECT_PTR(microdump_product_info_); 858 ANNOTATE_LEAKING_OBJECT_PTR(microdump_product_info_);
841 descriptor.microdump_extra_info()->product_info = microdump_product_info_; 859 descriptor.microdump_extra_info()->product_info = microdump_product_info_;
842 } 860 }
843 861
844 if (android_build_fp) { 862 if (android_build_fp) {
845 microdump_build_fingerprint_ = strdup(android_build_fp); 863 microdump_build_fingerprint_ = strdup(android_build_fp);
846 ANNOTATE_LEAKING_OBJECT_PTR(microdump_build_fingerprint_); 864 ANNOTATE_LEAKING_OBJECT_PTR(microdump_build_fingerprint_);
847 descriptor.microdump_extra_info()->build_fingerprint = 865 descriptor.microdump_extra_info()->build_fingerprint =
848 microdump_build_fingerprint_; 866 microdump_build_fingerprint_;
849 } 867 }
850 868
851 if (microdump_gpu_fingerprint_) { 869 if (microdump_gpu_fingerprint_) {
852 descriptor.microdump_extra_info()->gpu_fingerprint = 870 descriptor.microdump_extra_info()->gpu_fingerprint =
853 microdump_gpu_fingerprint_; 871 microdump_gpu_fingerprint_;
854 } 872 }
855 873
856 g_microdump = 874 g_microdump =
857 new ExceptionHandler(descriptor, nullptr, MicrodumpCrashDone, 875 new ExceptionHandler(descriptor, nullptr, MicrodumpCrashDone,
858 reinterpret_cast<void*>(is_browser_process), 876 reinterpret_cast<void*>(is_browser_process),
859 true, // Install handlers. 877 true, // Install handlers.
860 -1); // Server file descriptor. -1 for in-process. 878 -1); // Server file descriptor. -1 for in-process.
861 879
862 if (process_type == "webview") { 880 if (process_type == kWebViewProcessType) {
863 // We do not use |DumpProcess()| for handling programatically 881 // We do not use |DumpProcess()| for handling programatically
864 // generated dumps for WebView because we only know the file 882 // generated dumps for WebView because we only know the file
865 // descriptor to which we are dumping at the time of the call to 883 // descriptor to which we are dumping at the time of the call to
866 // |DumpWithoutCrashing()|. Therefore we need to construct the 884 // |DumpWithoutCrashing()|. Therefore we need to construct the
867 // |MinidumpDescriptor| and |ExceptionHandler| instances as 885 // |MinidumpDescriptor| and |ExceptionHandler| instances as
868 // needed, instead of setting up |g_breakpad| at initialization 886 // needed, instead of setting up |g_breakpad| at initialization
869 // time. 887 // time.
870 base::debug::SetDumpWithoutCrashingFunction( 888 base::debug::SetDumpWithoutCrashingFunction(
871 &GenerateMinidumpOnDemandForAndroid); 889 &GenerateMinidumpOnDemandForAndroid);
890 } else if (!process_type.empty()) {
891 g_signal_code_pipe_fd =
892 GetCrashReporterClient()->GetAndroidMinidumpDescriptor();
893 if (g_signal_code_pipe_fd != -1)
894 g_microdump->set_crash_handler(WriteSignalCodeToPipe);
872 } 895 }
873 } 896 }
874 897
875 #else 898 #else
876 // Non-Browser = Extension, Gpu, Plugins, Ppapi and Renderer 899 // Non-Browser = Extension, Gpu, Plugins, Ppapi and Renderer
877 class NonBrowserCrashHandler : public google_breakpad::CrashGenerationClient { 900 class NonBrowserCrashHandler : public google_breakpad::CrashGenerationClient {
878 public: 901 public:
879 NonBrowserCrashHandler() 902 NonBrowserCrashHandler()
880 : server_fd_(base::GlobalDescriptors::GetInstance()->Get( 903 : server_fd_(base::GlobalDescriptors::GetInstance()->Get(
881 kCrashDumpSignal)) { 904 kCrashDumpSignal)) {
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 const std::string& gpu_fingerprint) { 1885 const std::string& gpu_fingerprint) {
1863 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint); 1886 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint);
1864 } 1887 }
1865 #endif // OS_ANDROID 1888 #endif // OS_ANDROID
1866 1889
1867 bool IsCrashReporterEnabled() { 1890 bool IsCrashReporterEnabled() {
1868 return g_is_crash_reporter_enabled; 1891 return g_is_crash_reporter_enabled;
1869 } 1892 }
1870 1893
1871 } // namespace breakpad 1894 } // namespace breakpad
OLDNEW
« no previous file with comments | « components/crash.gypi ('k') | components/crash/content/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698