1 //===-- SystemInitializerCommon.cpp -----------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/Initialization/SystemInitializerCommon.h" 11 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" 22 23 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) 24 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h" 25 #endif 26 27 #if defined(_MSC_VER) 28 #include "Plugins/Process/Windows/Common/ProcessWindowsLog.h" 29 #include "lldb/Host/windows/windows.h" 30 #endif 31 32 #include "llvm/Support/TargetSelect.h" 33 34 #include <string> 35 36 using namespace lldb_private; 37 38 SystemInitializerCommon::SystemInitializerCommon() {} 39 40 SystemInitializerCommon::~SystemInitializerCommon() {} 41 42 void SystemInitializerCommon::Initialize() { 43 #if defined(_MSC_VER) 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 48 // interaction when 49 // LLDB crashes. This is mostly useful when automating LLDB, for example 50 // via the test 51 // suite, so that a crash in LLDB does not prevent completion of the test 52 // suite. 53 ::SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS | 54 SEM_NOGPFAULTERRORBOX); 55 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); 62 } 63 #endif 64 65 Log::Initialize(); 66 HostInfo::Initialize(); 67 static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); 68 Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION); 69 70 process_gdb_remote::ProcessGDBRemoteLog::Initialize(); 71 72 // Initialize plug-ins 73 ObjectContainerBSDArchive::Initialize(); 74 75 EmulateInstructionARM::Initialize(); 76 EmulateInstructionMIPS::Initialize(); 77 EmulateInstructionMIPS64::Initialize(); 78 79 //---------------------------------------------------------------------- 80 // Apple/Darwin hosted plugins 81 //---------------------------------------------------------------------- 82 ObjectContainerUniversalMachO::Initialize(); 83 84 #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) 85 ProcessPOSIXLog::Initialize(); 86 #endif 87 #if defined(_MSC_VER) 88 ProcessWindowsLog::Initialize(); 89 #endif 90 } 91 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(); 96 97 EmulateInstructionARM::Terminate(); 98 EmulateInstructionMIPS::Terminate(); 99 EmulateInstructionMIPS64::Terminate(); 100 101 ObjectContainerUniversalMachO::Terminate(); 102 103 #if defined(_MSC_VER) 104 ProcessWindowsLog::Terminate(); 105 #endif 106 107 HostInfo::Terminate(); 108 Log::DisableAllLogChannels(); 109 } 110