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

Side by Side Diff: chrome_elf/chrome_elf_main.cc

Issue 2431483004: Signal chrome_elf to initialize crash reporting, rather than doing it in DllMain (Closed)
Patch Set: Created 4 years, 2 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 | « chrome_elf/chrome_elf_main.h ('k') | no next file » | 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 #include "chrome_elf/chrome_elf_main.h" 5 #include "chrome_elf/chrome_elf_main.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 void DisableSetUnhandledExceptionFilter() { 77 void DisableSetUnhandledExceptionFilter() {
78 DWORD patched = g_set_unhandled_exception_filter.PatchFromModule( 78 DWORD patched = g_set_unhandled_exception_filter.PatchFromModule(
79 GetModuleHandle(nullptr), "kernel32.dll", "SetUnhandledExceptionFilter", 79 GetModuleHandle(nullptr), "kernel32.dll", "SetUnhandledExceptionFilter",
80 SetUnhandledExceptionFilterPatch); 80 SetUnhandledExceptionFilterPatch);
81 CHECK(patched == 0); 81 CHECK(patched == 0);
82 } 82 }
83 #endif // !defined(ADDRESS_SANITIZER) 83 #endif // !defined(ADDRESS_SANITIZER)
84 84
85 } // namespace 85 } // namespace
86 86
87 // This function is a temporary workaround for https://crbug.com/655788. We
88 // need to come up with a better way to initialize crash reporting that can
89 // happen inside DllMain().
90 void SignalInitializeCrashReporting() {
91 InitializeCrashReportingForProcess();
92 }
93
87 void SignalChromeElf() { 94 void SignalChromeElf() {
88 blacklist::ResetBeacon(); 95 blacklist::ResetBeacon();
89 } 96 }
90 97
91 // This helper is invoked by code in chrome.dll to retrieve the crash reports. 98 // This helper is invoked by code in chrome.dll to retrieve the crash reports.
92 // See CrashUploadListCrashpad. Note that we do not pass an std::vector here, 99 // See CrashUploadListCrashpad. Note that we do not pass an std::vector here,
93 // because we do not want to allocate/free in different modules. The returned 100 // because we do not want to allocate/free in different modules. The returned
94 // pointer is read-only. 101 // pointer is read-only.
95 extern "C" __declspec(dllexport) void GetCrashReportsImpl( 102 extern "C" __declspec(dllexport) void GetCrashReportsImpl(
96 const crash_reporter::Report** reports, 103 const crash_reporter::Report** reports,
97 size_t* report_count) { 104 size_t* report_count) {
98 crash_reporter::GetReports(g_crash_reports.Pointer()); 105 crash_reporter::GetReports(g_crash_reports.Pointer());
99 *reports = g_crash_reports.Pointer()->data(); 106 *reports = g_crash_reports.Pointer()->data();
100 *report_count = g_crash_reports.Pointer()->size(); 107 *report_count = g_crash_reports.Pointer()->size();
101 } 108 }
102 109
103 // This helper is invoked by debugging code in chrome to register the client 110 // This helper is invoked by debugging code in chrome to register the client
104 // id. 111 // id.
105 extern "C" __declspec(dllexport) void SetMetricsClientId( 112 extern "C" __declspec(dllexport) void SetMetricsClientId(
106 const char* client_id) { 113 const char* client_id) {
107 if (client_id) 114 if (client_id)
108 crash_keys::SetMetricsClientIdFromGUID(client_id); 115 crash_keys::SetMetricsClientIdFromGUID(client_id);
109 } 116 }
110 117
111 BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) { 118 BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) {
112 if (reason == DLL_PROCESS_ATTACH) { 119 if (reason == DLL_PROCESS_ATTACH) {
113 InitializeCrashReportingForProcess();
114 // CRT on initialization installs an exception filter which calls
115 // TerminateProcess. We need to hook CRT's attempt to set an exception
116 // handler and ignore it. Don't do this when ASan is present, or ASan will
117 // fail to install its own unhandled exception filter.
118 #if !defined(ADDRESS_SANITIZER) 120 #if !defined(ADDRESS_SANITIZER)
119 DisableSetUnhandledExceptionFilter(); 121 DisableSetUnhandledExceptionFilter();
120 #endif 122 #endif
121 123
122 install_static::InitializeProcessType(); 124 install_static::InitializeProcessType();
123 125
124 __try { 126 __try {
125 blacklist::Initialize(false); // Don't force, abort if beacon is present. 127 blacklist::Initialize(false); // Don't force, abort if beacon is present.
126 } __except(GenerateCrashDump(GetExceptionInformation())) { 128 } __except(GenerateCrashDump(GetExceptionInformation())) {
127 } 129 }
128 } 130 }
129 return TRUE; 131 return TRUE;
130 } 132 }
OLDNEW
« no previous file with comments | « chrome_elf/chrome_elf_main.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698