1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/app/chrome_main_delegate.h"
7 #include "content/public/app/content_main.h"
10 #include "base/debug/dump_without_crashing.h"
11 #include "base/win/win_util.h"
12 #include "chrome/common/chrome_constants.h"
14 #define DLLEXPORT __declspec(dllexport)
16 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling.
18 DLLEXPORT
int __cdecl
ChromeMain(HINSTANCE instance
,
19 sandbox::SandboxInterfaceInfo
* sandbox_info
);
21 #elif defined(OS_POSIX)
23 __attribute__((visibility("default")))
24 int ChromeMain(int argc
, const char** argv
);
29 DLLEXPORT
int __cdecl
ChromeMain(HINSTANCE instance
,
30 sandbox::SandboxInterfaceInfo
* sandbox_info
) {
31 #elif defined(OS_POSIX)
32 int ChromeMain(int argc
, const char** argv
) {
34 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64)
35 // VS2013 only checks the existence of FMA3 instructions, not the enabled-ness
36 // of them at the OS level (this is fixed in VS2015). We force off usage of
37 // FMA3 instructions in the CRT to avoid using that path and hitting illegal
38 // instructions when running on CPUs that support FMA3, but OSs that don't.
39 // See http://crbug.com/436603.
41 #endif // WIN && ARCH_CPU_X86_64
43 ChromeMainDelegate chrome_main_delegate
;
44 content::ContentMainParams
params(&chrome_main_delegate
);
47 // The process should crash when going through abnormal termination.
48 base::win::SetShouldCrashOnProcessDetach(true);
49 base::win::SetAbortBehaviorForCrashReporting();
50 params
.instance
= instance
;
51 params
.sandbox_info
= sandbox_info
;
53 // SetDumpWithoutCrashingFunction must be passed the DumpProcess function
54 // from the EXE and not from the DLL in order for DumpWithoutCrashing to
55 // function correctly.
56 typedef void (__cdecl
*DumpProcessFunction
)();
57 DumpProcessFunction DumpProcess
= reinterpret_cast<DumpProcessFunction
>(
58 ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName
),
59 "DumpProcessWithoutCrash"));
60 base::debug::SetDumpWithoutCrashingFunction(DumpProcess
);
66 int rv
= content::ContentMain(params
);
69 base::win::SetShouldCrashOnProcessDetach(false);