Files
llvm-project/lldb/source/Initialization/SystemInitializerCommon.cpp
T

114 lines
3.8 KiB
C++
Raw Normal View History

2015-03-31 21:03:22 +00:00
//===-- SystemInitializerCommon.cpp -----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Initialization/SystemInitializerCommon.h"
2015-04-15 09:47:02 +00:00
#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
2015-05-15 06:53:30 +00:00
#include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
2015-05-07 05:56:27 +00:00
#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
2015-03-31 21:03:22 +00:00
#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
2017-03-03 20:56:28 +00:00
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Timer.h"
2015-03-31 21:03:22 +00:00
2017-03-21 17:26:55 +00:00
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
2015-03-31 21:03:22 +00:00
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#endif
#if defined(_MSC_VER)
#include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"
#include "lldb/Host/windows/windows.h"
2015-03-31 21:03:22 +00:00
#endif
2016-12-14 21:31:31 +00:00
#include "llvm/Support/PrettyStackTrace.h"
2015-03-31 21:03:22 +00:00
#include "llvm/Support/TargetSelect.h"
#include <string>
using namespace lldb_private;
SystemInitializerCommon::SystemInitializerCommon() {}
2015-03-31 21:03:22 +00:00
SystemInitializerCommon::~SystemInitializerCommon() {}
2015-03-31 21:03:22 +00:00
void SystemInitializerCommon::Initialize() {
2015-03-31 21:03:22 +00:00
#if defined(_MSC_VER)
const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
if (disable_crash_dialog_var &&
llvm::StringRef(disable_crash_dialog_var).equals_lower("true")) {
// This will prevent Windows from displaying a dialog box requiring user
// interaction when
// LLDB crashes. This is mostly useful when automating LLDB, for example
// via the test
// suite, so that a crash in LLDB does not prevent completion of the test
// suite.
::SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS |
SEM_NOGPFAULTERRORBOX);
2015-03-31 21:03:22 +00:00
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
}
2015-03-31 21:03:22 +00:00
#endif
#if not defined(__APPLE__)
2016-12-14 21:31:31 +00:00
llvm::EnablePrettyStackTrace();
#endif
2017-10-23 19:41:17 +00:00
Log::Initialize();
HostInfo::Initialize();
2017-05-15 13:02:37 +00:00
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
2015-03-31 21:03:22 +00:00
process_gdb_remote::ProcessGDBRemoteLog::Initialize();
2015-03-31 21:03:22 +00:00
// Initialize plug-ins
ObjectContainerBSDArchive::Initialize();
2015-03-31 21:03:22 +00:00
EmulateInstructionARM::Initialize();
EmulateInstructionMIPS::Initialize();
EmulateInstructionMIPS64::Initialize();
2015-03-31 21:03:22 +00:00
//----------------------------------------------------------------------
// Apple/Darwin hosted plugins
//----------------------------------------------------------------------
ObjectContainerUniversalMachO::Initialize();
2015-03-31 21:03:22 +00:00
2017-03-21 17:26:55 +00:00
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
ProcessPOSIXLog::Initialize();
2015-03-31 21:03:22 +00:00
#endif
2015-04-10 16:18:08 +00:00
#if defined(_MSC_VER)
ProcessWindowsLog::Initialize();
2015-04-10 16:18:08 +00:00
#endif
2015-03-31 21:03:22 +00:00
}
void SystemInitializerCommon::Terminate() {
2017-05-15 13:02:37 +00:00
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
ObjectContainerBSDArchive::Terminate();
2015-03-31 21:03:22 +00:00
EmulateInstructionARM::Terminate();
EmulateInstructionMIPS::Terminate();
EmulateInstructionMIPS64::Terminate();
2015-04-15 09:47:02 +00:00
ObjectContainerUniversalMachO::Terminate();
2015-03-31 21:03:22 +00:00
#if defined(_MSC_VER)
ProcessWindowsLog::Terminate();
2015-05-07 21:39:33 +00:00
#endif
HostInfo::Terminate();
Log::DisableAllLogChannels();
2015-03-31 21:03:22 +00:00
}