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

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: Remove std::move for a value in return Created 4 years, 11 months 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 bool g_is_crash_reporter_enabled = false; 93 bool g_is_crash_reporter_enabled = false;
94 uint64_t g_process_start_time = 0; 94 uint64_t g_process_start_time = 0;
95 pid_t g_pid = 0; 95 pid_t g_pid = 0;
96 char* g_crash_log_path = nullptr; 96 char* g_crash_log_path = nullptr;
97 ExceptionHandler* g_breakpad = nullptr; 97 ExceptionHandler* g_breakpad = nullptr;
98 98
99 #if defined(ADDRESS_SANITIZER) 99 #if defined(ADDRESS_SANITIZER)
100 const char* g_asan_report_str = nullptr; 100 const char* g_asan_report_str = nullptr;
101 #endif 101 #endif
102 #if defined(OS_ANDROID) 102 #if defined(OS_ANDROID)
103 const char kWebViewProcessType[] = "webview";
103 char* g_process_type = nullptr; 104 char* g_process_type = nullptr;
104 ExceptionHandler* g_microdump = nullptr; 105 ExceptionHandler* g_microdump = nullptr;
106 int g_signal_code_pipe_fd = -1;
105 107
106 class MicrodumpInfo { 108 class MicrodumpInfo {
107 public: 109 public:
108 MicrodumpInfo() 110 MicrodumpInfo()
109 : microdump_build_fingerprint_(nullptr), 111 : microdump_build_fingerprint_(nullptr),
110 microdump_product_info_(nullptr), 112 microdump_product_info_(nullptr),
111 microdump_gpu_fingerprint_(nullptr) {} 113 microdump_gpu_fingerprint_(nullptr) {}
112 114
113 // The order in which SetGpuFingerprint and Initialize are called 115 // The order in which SetGpuFingerprint and Initialize are called
114 // may be dependent on the timing of the availability of GPU 116 // may be dependent on the timing of the availability of GPU
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 // WARNING: this code runs in a compromised context. It may not call into 736 // WARNING: this code runs in a compromised context. It may not call into
735 // libc nor allocate memory normally. 737 // libc nor allocate memory normally.
736 if (!succeeded) { 738 if (!succeeded) {
737 static const char msg[] = "Microdump crash handler failed.\n"; 739 static const char msg[] = "Microdump crash handler failed.\n";
738 WriteLog(msg, sizeof(msg) - 1); 740 WriteLog(msg, sizeof(msg) - 1);
739 return false; 741 return false;
740 } 742 }
741 743
742 const bool is_browser_process = (context != nullptr); 744 const bool is_browser_process = (context != nullptr);
743 return FinalizeCrashDoneAndroid(is_browser_process); 745 return FinalizeCrashDoneAndroid(is_browser_process);
744 } 746 }
747
748 bool WriteSignalCodeToPipe(const void* crash_context,
749 size_t crash_context_size,
750 void* context) {
751 if (g_signal_code_pipe_fd == -1)
752 return false;
753 int signo = INT_MAX;
754 if (crash_context_size == sizeof(ExceptionHandler::CrashContext)) {
755 const ExceptionHandler::CrashContext* eh_context =
756 static_cast<const ExceptionHandler::CrashContext*>(crash_context);
757 signo = eh_context->siginfo.si_signo;
758 }
759 sys_write(g_signal_code_pipe_fd, &signo, sizeof(signo));
760 IGNORE_RET(sys_close(g_signal_code_pipe_fd));
761 g_signal_code_pipe_fd = -1;
762 return false;
763 }
745 764
746 bool CrashDoneInProcessNoUpload( 765 bool CrashDoneInProcessNoUpload(
747 const google_breakpad::MinidumpDescriptor& descriptor, 766 const google_breakpad::MinidumpDescriptor& descriptor,
748 void* context, 767 void* context,
749 const bool succeeded) { 768 const bool succeeded) {
750 // WARNING: this code runs in a compromised context. It may not call into 769 // WARNING: this code runs in a compromised context. It may not call into
751 // libc nor allocate memory normally. 770 // libc nor allocate memory normally.
752 if (!succeeded) { 771 if (!succeeded) {
753 static const char msg[] = "Crash dump generation failed.\n"; 772 static const char msg[] = "Crash dump generation failed.\n";
754 WriteLog(msg, sizeof(msg) - 1); 773 WriteLog(msg, sizeof(msg) - 1);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 g_microdump->set_minidump_descriptor(minidump_descriptor); 846 g_microdump->set_minidump_descriptor(minidump_descriptor);
828 } 847 }
829 } 848 }
830 849
831 void MicrodumpInfo::Initialize(const std::string& process_type, 850 void MicrodumpInfo::Initialize(const std::string& process_type,
832 const char* product_name, 851 const char* product_name,
833 const char* product_version, 852 const char* product_version,
834 const char* android_build_fp) { 853 const char* android_build_fp) {
835 DCHECK(thread_checker_.CalledOnValidThread()); 854 DCHECK(thread_checker_.CalledOnValidThread());
836 DCHECK(!g_microdump); 855 DCHECK(!g_microdump);
837 bool is_browser_process = process_type.empty() || process_type == "webview"; 856 bool is_browser_process =
857 process_type.empty() || process_type == kWebViewProcessType;
838 858
839 MinidumpDescriptor descriptor(MinidumpDescriptor::kMicrodumpOnConsole); 859 MinidumpDescriptor descriptor(MinidumpDescriptor::kMicrodumpOnConsole);
840 860
841 if (product_name && product_version) { 861 if (product_name && product_version) {
842 microdump_product_info_ = 862 microdump_product_info_ =
843 strdup((product_name + std::string(":") + product_version).c_str()); 863 strdup((product_name + std::string(":") + product_version).c_str());
844 ANNOTATE_LEAKING_OBJECT_PTR(microdump_product_info_); 864 ANNOTATE_LEAKING_OBJECT_PTR(microdump_product_info_);
845 descriptor.microdump_extra_info()->product_info = microdump_product_info_; 865 descriptor.microdump_extra_info()->product_info = microdump_product_info_;
846 } 866 }
847 867
848 if (android_build_fp) { 868 if (android_build_fp) {
849 microdump_build_fingerprint_ = strdup(android_build_fp); 869 microdump_build_fingerprint_ = strdup(android_build_fp);
850 ANNOTATE_LEAKING_OBJECT_PTR(microdump_build_fingerprint_); 870 ANNOTATE_LEAKING_OBJECT_PTR(microdump_build_fingerprint_);
851 descriptor.microdump_extra_info()->build_fingerprint = 871 descriptor.microdump_extra_info()->build_fingerprint =
852 microdump_build_fingerprint_; 872 microdump_build_fingerprint_;
853 } 873 }
854 874
855 if (microdump_gpu_fingerprint_) { 875 if (microdump_gpu_fingerprint_) {
856 descriptor.microdump_extra_info()->gpu_fingerprint = 876 descriptor.microdump_extra_info()->gpu_fingerprint =
857 microdump_gpu_fingerprint_; 877 microdump_gpu_fingerprint_;
858 } 878 }
859 879
860 g_microdump = 880 g_microdump =
861 new ExceptionHandler(descriptor, nullptr, MicrodumpCrashDone, 881 new ExceptionHandler(descriptor, nullptr, MicrodumpCrashDone,
862 reinterpret_cast<void*>(is_browser_process), 882 reinterpret_cast<void*>(is_browser_process),
863 true, // Install handlers. 883 true, // Install handlers.
864 -1); // Server file descriptor. -1 for in-process. 884 -1); // Server file descriptor. -1 for in-process.
865 885
866 if (process_type == "webview") { 886 if (process_type == kWebViewProcessType) {
867 // We do not use |DumpProcess()| for handling programatically 887 // We do not use |DumpProcess()| for handling programatically
868 // generated dumps for WebView because we only know the file 888 // generated dumps for WebView because we only know the file
869 // descriptor to which we are dumping at the time of the call to 889 // descriptor to which we are dumping at the time of the call to
870 // |DumpWithoutCrashing()|. Therefore we need to construct the 890 // |DumpWithoutCrashing()|. Therefore we need to construct the
871 // |MinidumpDescriptor| and |ExceptionHandler| instances as 891 // |MinidumpDescriptor| and |ExceptionHandler| instances as
872 // needed, instead of setting up |g_breakpad| at initialization 892 // needed, instead of setting up |g_breakpad| at initialization
873 // time. 893 // time.
874 base::debug::SetDumpWithoutCrashingFunction( 894 base::debug::SetDumpWithoutCrashingFunction(
875 &GenerateMinidumpOnDemandForAndroid); 895 &GenerateMinidumpOnDemandForAndroid);
896 } else if (!process_type.empty()) {
897 g_signal_code_pipe_fd =
898 GetCrashReporterClient()->GetAndroidMinidumpDescriptor();
899 if (g_signal_code_pipe_fd != -1)
900 g_microdump->set_crash_handler(WriteSignalCodeToPipe);
876 } 901 }
877 } 902 }
878 903
879 #else 904 #else
880 // Non-Browser = Extension, Gpu, Plugins, Ppapi and Renderer 905 // Non-Browser = Extension, Gpu, Plugins, Ppapi and Renderer
881 class NonBrowserCrashHandler : public google_breakpad::CrashGenerationClient { 906 class NonBrowserCrashHandler : public google_breakpad::CrashGenerationClient {
882 public: 907 public:
883 NonBrowserCrashHandler() 908 NonBrowserCrashHandler()
884 : server_fd_(base::GlobalDescriptors::GetInstance()->Get( 909 : server_fd_(base::GlobalDescriptors::GetInstance()->Get(
885 kCrashDumpSignal)) { 910 kCrashDumpSignal)) {
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 const std::string& gpu_fingerprint) { 1891 const std::string& gpu_fingerprint) {
1867 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint); 1892 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint);
1868 } 1893 }
1869 #endif // OS_ANDROID 1894 #endif // OS_ANDROID
1870 1895
1871 bool IsCrashReporterEnabled() { 1896 bool IsCrashReporterEnabled() {
1872 return g_is_crash_reporter_enabled; 1897 return g_is_crash_reporter_enabled;
1873 } 1898 }
1874 1899
1875 } // namespace breakpad 1900 } // 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