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

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: Sort out the case of wrong context size 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 return false;
749 int signo = 66; // The code that doesn't correspond to any real signal.
Torne 2016/01/04 11:28:51 Why 66 in particular? maximum int or something see
mnaganov (inactive) 2016/01/04 17:17:20 Done.
750 if (crash_context_size == sizeof(ExceptionHandler::CrashContext)) {
751 const ExceptionHandler::CrashContext* eh_context =
752 static_cast<const ExceptionHandler::CrashContext*>(crash_context);
753 signo = eh_context->siginfo.si_signo;
754 }
755 sys_write(g_signal_code_pipe_fd, &signo, sizeof(signo));
756 IGNORE_RET(sys_close(g_signal_code_pipe_fd));
757 g_signal_code_pipe_fd = -1;
758 return false;
759 }
741 760
742 bool CrashDoneInProcessNoUpload( 761 bool CrashDoneInProcessNoUpload(
743 const google_breakpad::MinidumpDescriptor& descriptor, 762 const google_breakpad::MinidumpDescriptor& descriptor,
744 void* context, 763 void* context,
745 const bool succeeded) { 764 const bool succeeded) {
746 // WARNING: this code runs in a compromised context. It may not call into 765 // WARNING: this code runs in a compromised context. It may not call into
747 // libc nor allocate memory normally. 766 // libc nor allocate memory normally.
748 if (!succeeded) { 767 if (!succeeded) {
749 static const char msg[] = "Crash dump generation failed.\n"; 768 static const char msg[] = "Crash dump generation failed.\n";
750 WriteLog(msg, sizeof(msg) - 1); 769 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); 842 g_microdump->set_minidump_descriptor(minidump_descriptor);
824 } 843 }
825 } 844 }
826 845
827 void MicrodumpInfo::Initialize(const std::string& process_type, 846 void MicrodumpInfo::Initialize(const std::string& process_type,
828 const char* product_name, 847 const char* product_name,
829 const char* product_version, 848 const char* product_version,
830 const char* android_build_fp) { 849 const char* android_build_fp) {
831 DCHECK(thread_checker_.CalledOnValidThread()); 850 DCHECK(thread_checker_.CalledOnValidThread());
832 DCHECK(!g_microdump); 851 DCHECK(!g_microdump);
833 bool is_browser_process = process_type.empty() || process_type == "webview"; 852 bool is_browser_process =
853 process_type.empty() || process_type == kWebViewProcessType;
834 854
835 MinidumpDescriptor descriptor(MinidumpDescriptor::kMicrodumpOnConsole); 855 MinidumpDescriptor descriptor(MinidumpDescriptor::kMicrodumpOnConsole);
836 856
837 if (product_name && product_version) { 857 if (product_name && product_version) {
838 microdump_product_info_ = 858 microdump_product_info_ =
839 strdup((product_name + std::string(":") + product_version).c_str()); 859 strdup((product_name + std::string(":") + product_version).c_str());
840 ANNOTATE_LEAKING_OBJECT_PTR(microdump_product_info_); 860 ANNOTATE_LEAKING_OBJECT_PTR(microdump_product_info_);
841 descriptor.microdump_extra_info()->product_info = microdump_product_info_; 861 descriptor.microdump_extra_info()->product_info = microdump_product_info_;
842 } 862 }
843 863
844 if (android_build_fp) { 864 if (android_build_fp) {
845 microdump_build_fingerprint_ = strdup(android_build_fp); 865 microdump_build_fingerprint_ = strdup(android_build_fp);
846 ANNOTATE_LEAKING_OBJECT_PTR(microdump_build_fingerprint_); 866 ANNOTATE_LEAKING_OBJECT_PTR(microdump_build_fingerprint_);
847 descriptor.microdump_extra_info()->build_fingerprint = 867 descriptor.microdump_extra_info()->build_fingerprint =
848 microdump_build_fingerprint_; 868 microdump_build_fingerprint_;
849 } 869 }
850 870
851 if (microdump_gpu_fingerprint_) { 871 if (microdump_gpu_fingerprint_) {
852 descriptor.microdump_extra_info()->gpu_fingerprint = 872 descriptor.microdump_extra_info()->gpu_fingerprint =
853 microdump_gpu_fingerprint_; 873 microdump_gpu_fingerprint_;
854 } 874 }
855 875
856 g_microdump = 876 g_microdump =
857 new ExceptionHandler(descriptor, nullptr, MicrodumpCrashDone, 877 new ExceptionHandler(descriptor, nullptr, MicrodumpCrashDone,
858 reinterpret_cast<void*>(is_browser_process), 878 reinterpret_cast<void*>(is_browser_process),
859 true, // Install handlers. 879 true, // Install handlers.
860 -1); // Server file descriptor. -1 for in-process. 880 -1); // Server file descriptor. -1 for in-process.
861 881
862 if (process_type == "webview") { 882 if (process_type == kWebViewProcessType) {
863 // We do not use |DumpProcess()| for handling programatically 883 // We do not use |DumpProcess()| for handling programatically
864 // generated dumps for WebView because we only know the file 884 // generated dumps for WebView because we only know the file
865 // descriptor to which we are dumping at the time of the call to 885 // descriptor to which we are dumping at the time of the call to
866 // |DumpWithoutCrashing()|. Therefore we need to construct the 886 // |DumpWithoutCrashing()|. Therefore we need to construct the
867 // |MinidumpDescriptor| and |ExceptionHandler| instances as 887 // |MinidumpDescriptor| and |ExceptionHandler| instances as
868 // needed, instead of setting up |g_breakpad| at initialization 888 // needed, instead of setting up |g_breakpad| at initialization
869 // time. 889 // time.
870 base::debug::SetDumpWithoutCrashingFunction( 890 base::debug::SetDumpWithoutCrashingFunction(
871 &GenerateMinidumpOnDemandForAndroid); 891 &GenerateMinidumpOnDemandForAndroid);
892 } else if (!process_type.empty()) {
893 g_signal_code_pipe_fd =
894 GetCrashReporterClient()->GetAndroidMinidumpDescriptor();
895 if (g_signal_code_pipe_fd != -1)
896 g_microdump->set_crash_handler(WriteSignalCodeToPipe);
872 } 897 }
873 } 898 }
874 899
875 #else 900 #else
876 // Non-Browser = Extension, Gpu, Plugins, Ppapi and Renderer 901 // Non-Browser = Extension, Gpu, Plugins, Ppapi and Renderer
877 class NonBrowserCrashHandler : public google_breakpad::CrashGenerationClient { 902 class NonBrowserCrashHandler : public google_breakpad::CrashGenerationClient {
878 public: 903 public:
879 NonBrowserCrashHandler() 904 NonBrowserCrashHandler()
880 : server_fd_(base::GlobalDescriptors::GetInstance()->Get( 905 : server_fd_(base::GlobalDescriptors::GetInstance()->Get(
881 kCrashDumpSignal)) { 906 kCrashDumpSignal)) {
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 const std::string& gpu_fingerprint) { 1887 const std::string& gpu_fingerprint) {
1863 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint); 1888 g_microdump_info.Get().SetGpuFingerprint(gpu_fingerprint);
1864 } 1889 }
1865 #endif // OS_ANDROID 1890 #endif // OS_ANDROID
1866 1891
1867 bool IsCrashReporterEnabled() { 1892 bool IsCrashReporterEnabled() {
1868 return g_is_crash_reporter_enabled; 1893 return g_is_crash_reporter_enabled;
1869 } 1894 }
1870 1895
1871 } // namespace breakpad 1896 } // 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