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"
|
2016-09-06 20:57:50 +00:00
|
|
|
#include "lldb/Host/Host.h"
|
|
|
|
|
#include "lldb/Host/HostInfo.h"
|
2017-03-03 20:56:28 +00:00
|
|
|
#include "lldb/Utility/Log.h"
|
2017-06-29 14:32:17 +00:00
|
|
|
#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)
|
2015-10-28 18:21:45 +00:00
|
|
|
#include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"
|
2016-03-02 22:05:52 +00:00
|
|
|
#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;
|
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SystemInitializerCommon::SystemInitializerCommon() {}
|
2015-03-31 21:03:22 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SystemInitializerCommon::~SystemInitializerCommon() {}
|
2015-03-31 21:03:22 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
void SystemInitializerCommon::Initialize() {
|
2015-03-31 21:03:22 +00:00
|
|
|
#if defined(_MSC_VER)
|
2016-09-06 20:57:50 +00:00
|
|
|
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
|
|
|
|
2016-09-06 20:57:50 +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
|
|
|
|
|
|
2017-12-02 00:11:18 +00:00
|
|
|
#if not defined(__APPLE__)
|
2016-12-14 21:31:31 +00:00
|
|
|
llvm::EnablePrettyStackTrace();
|
2017-12-02 00:11:18 +00:00
|
|
|
#endif
|
2017-10-23 19:41:17 +00:00
|
|
|
Log::Initialize();
|
2016-09-06 20:57:50 +00:00
|
|
|
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
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
process_gdb_remote::ProcessGDBRemoteLog::Initialize();
|
2015-03-31 21:03:22 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
// Initialize plug-ins
|
|
|
|
|
ObjectContainerBSDArchive::Initialize();
|
2015-03-31 21:03:22 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
EmulateInstructionARM::Initialize();
|
|
|
|
|
EmulateInstructionMIPS::Initialize();
|
|
|
|
|
EmulateInstructionMIPS64::Initialize();
|
2015-03-31 21:03:22 +00:00
|
|
|
|
2016-09-06 20:57:50 +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__)
|
2017-02-23 10:33:16 +00:00
|
|
|
ProcessPOSIXLog::Initialize();
|
2015-03-31 21:03:22 +00:00
|
|
|
#endif
|
2015-04-10 16:18:08 +00:00
|
|
|
#if defined(_MSC_VER)
|
2016-09-06 20:57:50 +00:00
|
|
|
ProcessWindowsLog::Initialize();
|
2015-04-10 16:18:08 +00:00
|
|
|
#endif
|
2015-03-31 21:03:22 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-06 20:57:50 +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);
|
2016-09-06 20:57:50 +00:00
|
|
|
ObjectContainerBSDArchive::Terminate();
|
2015-03-31 21:03:22 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
EmulateInstructionARM::Terminate();
|
|
|
|
|
EmulateInstructionMIPS::Terminate();
|
|
|
|
|
EmulateInstructionMIPS64::Terminate();
|
2015-04-15 09:47:02 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
ObjectContainerUniversalMachO::Terminate();
|
2015-03-31 21:03:22 +00:00
|
|
|
|
2015-09-04 16:34:19 +00:00
|
|
|
#if defined(_MSC_VER)
|
2016-09-06 20:57:50 +00:00
|
|
|
ProcessWindowsLog::Terminate();
|
2015-05-07 21:39:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
HostInfo::Terminate();
|
2017-03-15 09:06:58 +00:00
|
|
|
Log::DisableAllLogChannels();
|
2015-03-31 21:03:22 +00:00
|
|
|
}
|