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

Unified Diff: chrome_elf/chrome_elf_main.cc

Issue 2183263003: [chrome_elf] Big ELF cleanup. Part 1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update with latest trunk. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_elf/chrome_elf.gyp ('k') | chrome_elf/chrome_elf_security.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_elf/chrome_elf_main.cc
diff --git a/chrome_elf/chrome_elf_main.cc b/chrome_elf/chrome_elf_main.cc
index c85d666058ed8c5faa67fabda1000ebb838a9e60..fa60e2de4b472615b7aa81def3da820d234c0d95 100644
--- a/chrome_elf/chrome_elf_main.cc
+++ b/chrome_elf/chrome_elf_main.cc
@@ -4,102 +4,40 @@
#include "chrome_elf/chrome_elf_main.h"
+#include <assert.h>
#include <windows.h>
-#include <algorithm>
-#include "base/lazy_instance.h"
-#include "base/strings/string16.h"
-#include "base/win/iat_patch_function.h"
-#include "build/build_config.h"
-#include "chrome/app/chrome_crash_reporter_client_win.h"
#include "chrome/install_static/install_util.h"
#include "chrome_elf/blacklist/blacklist.h"
-#include "chrome_elf/blacklist/crashpad_helper.h"
-#include "chrome_elf/chrome_elf_constants.h"
-#include "components/crash/content/app/crashpad.h"
-#include "components/crash/core/common/crash_keys.h"
-
-namespace {
-
-base::LazyInstance<std::vector<crash_reporter::Report>>::Leaky g_crash_reports =
- LAZY_INSTANCE_INITIALIZER;
-
-#if !defined(ADDRESS_SANITIZER)
-// chrome_elf loads early in the process and initializes Crashpad. That in turn
-// uses the SetUnhandledExceptionFilter API to set a top level exception
-// handler for the process. When the process eventually initializes, CRT sets
-// an exception handler which calls TerminateProcess which effectively bypasses
-// us. Ideally we want to be at the top of the unhandled exception filter
-// chain. However we don't have a good way of intercepting the
-// SetUnhandledExceptionFilter API in the sandbox. EAT patching kernel32 or
-// kernelbase should ideally work. However the kernel32 kernelbase dlls are
-// prebound which causes EAT patching to not work. Sidestep works. However it
-// is only supported for 32 bit. For now we use IAT patching for the
-// executable.
-// TODO(ananta).
-// Check if it is possible to fix EAT patching or use sidestep patching for
-// 32 bit and 64 bit for this purpose.
-base::win::IATPatchFunction g_set_unhandled_exception_filter;
-
-LPTOP_LEVEL_EXCEPTION_FILTER WINAPI
-SetUnhandledExceptionFilterPatch(LPTOP_LEVEL_EXCEPTION_FILTER filter) {
- // Don't set the exception filter. Please see above for comments.
- return nullptr;
-}
-
-// Please refer above to more information about why we intercept the
-// SetUnhandledExceptionFilter API.
-void DisableSetUnhandledExceptionFilter() {
- DWORD patched = g_set_unhandled_exception_filter.PatchFromModule(
- GetModuleHandle(nullptr), "kernel32.dll", "SetUnhandledExceptionFilter",
- SetUnhandledExceptionFilterPatch);
- CHECK(patched == 0);
-}
-#endif // !defined(ADDRESS_SANITIZER)
-
-} // namespace
+#include "chrome_elf/crash/crash_helper.h"
void SignalChromeElf() {
blacklist::ResetBeacon();
}
-// This helper is invoked by code in chrome.dll to retrieve the crash reports.
-// See CrashUploadListCrashpad. Note that we do not pass an std::vector here,
-// because we do not want to allocate/free in different modules. The returned
-// pointer is read-only.
-extern "C" __declspec(dllexport) void GetCrashReportsImpl(
- const crash_reporter::Report** reports,
- size_t* report_count) {
- crash_reporter::GetReports(g_crash_reports.Pointer());
- *reports = g_crash_reports.Pointer()->data();
- *report_count = g_crash_reports.Pointer()->size();
-}
-
-// This helper is invoked by debugging code in chrome to register the client
-// id.
-extern "C" __declspec(dllexport) void SetMetricsClientId(
- const char* client_id) {
- if (client_id)
- crash_keys::SetMetricsClientIdFromGUID(client_id);
-}
-
BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) {
if (reason == DLL_PROCESS_ATTACH) {
- ChromeCrashReporterClient::InitializeCrashReportingForProcess();
- // CRT on initialization installs an exception filter which calls
- // TerminateProcess. We need to hook CRT's attempt to set an exception
- // handler and ignore it. Don't do this when ASan is present, or ASan will
- // fail to install its own unhandled exception filter.
+ if (!elf_crash::InitializeCrashReporting()) {
+#ifdef _DEBUG
+ assert(false);
+#endif // _DEBUG
+ }
+// CRT on initialization installs an exception filter which calls
+// TerminateProcess. We need to hook CRT's attempt to set an exception.
+// NOTE: Do not hook if ASan is present, or ASan will fail to install
+// its own unhandled exception filter.
#if !defined(ADDRESS_SANITIZER)
- DisableSetUnhandledExceptionFilter();
-#endif
+ elf_crash::DisableSetUnhandledExceptionFilter();
+#endif // !defined (ADDRESS_SANITIZER)
install_static::InitializeProcessType();
__try {
blacklist::Initialize(false); // Don't force, abort if beacon is present.
- } __except(GenerateCrashDump(GetExceptionInformation())) {
+ } __except (elf_crash::GenerateCrashDump(GetExceptionInformation())) {
}
+ } else if (reason == DLL_PROCESS_DETACH) {
+ elf_crash::ShutdownCrashReporting();
}
return TRUE;
}
« no previous file with comments | « chrome_elf/chrome_elf.gyp ('k') | chrome_elf/chrome_elf_security.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698