1 //===-- SystemInitializerCommon.cpp -----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Initialization/SystemInitializerCommon.h"
12 #include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
13 #include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
14 #include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
15 #include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
16 #include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
17 #include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
18 #include "lldb/Host/Host.h"
19 #include "lldb/Host/HostInfo.h"
20 #include "lldb/Utility/Log.h"
21 #include "lldb/Utility/Timer.h"
23 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
24 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
28 #include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"
29 #include "lldb/Host/windows/windows.h"
32 #include "llvm/Support/TargetSelect.h"
36 using namespace lldb_private;
38 SystemInitializerCommon::SystemInitializerCommon() {}
40 SystemInitializerCommon::~SystemInitializerCommon() {}
42 void SystemInitializerCommon::Initialize() {
44 const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
45 if (disable_crash_dialog_var &&
46 llvm::StringRef(disable_crash_dialog_var).equals_lower("true")) {
47 // This will prevent Windows from displaying a dialog box requiring user
49 // LLDB crashes. This is mostly useful when automating LLDB, for example
51 // suite, so that a crash in LLDB does not prevent completion of the test
53 ::SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS |
54 SEM_NOGPFAULTERRORBOX);
56 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
57 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
58 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
59 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
60 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
61 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
66 HostInfo::Initialize();
67 static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
68 Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
70 process_gdb_remote::ProcessGDBRemoteLog::Initialize();
72 // Initialize plug-ins
73 ObjectContainerBSDArchive::Initialize();
75 EmulateInstructionARM::Initialize();
76 EmulateInstructionMIPS::Initialize();
77 EmulateInstructionMIPS64::Initialize();
79 //----------------------------------------------------------------------
80 // Apple/Darwin hosted plugins
81 //----------------------------------------------------------------------
82 ObjectContainerUniversalMachO::Initialize();
84 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
85 ProcessPOSIXLog::Initialize();
88 ProcessWindowsLog::Initialize();
92 void SystemInitializerCommon::Terminate() {
93 static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
94 Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
95 ObjectContainerBSDArchive::Terminate();
97 EmulateInstructionARM::Terminate();
98 EmulateInstructionMIPS::Terminate();
99 EmulateInstructionMIPS64::Terminate();
101 ObjectContainerUniversalMachO::Terminate();
103 #if defined(_MSC_VER)
104 ProcessWindowsLog::Terminate();
107 HostInfo::Terminate();
108 Log::DisableAllLogChannels();