2015-04-01 05:03:22 +08: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"
|
|
|
|
|
|
|
|
#include "lldb/Host/Host.h"
|
|
|
|
#include "lldb/Host/HostInfo.h"
|
|
|
|
#include "lldb/Core/Log.h"
|
|
|
|
#include "lldb/Core/Timer.h"
|
2015-04-15 17:47:02 +08:00
|
|
|
#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
|
2015-05-15 14:53:30 +08:00
|
|
|
#include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
|
2015-05-07 13:56:27 +08:00
|
|
|
#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
|
2015-04-01 05:03:22 +08:00
|
|
|
#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
|
|
|
|
#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
|
|
|
|
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
|
|
|
|
#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
|
|
|
|
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
|
|
|
|
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__linux__)
|
|
|
|
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
2015-10-29 02:21:45 +08:00
|
|
|
#include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"
|
Add support for reading line tables from PDB files.
PDB is Microsoft's debug information format, and although we
cannot yet generate it, we still must be able to consume it.
Reason for this is that debug information for system libraries
(e.g. kernel32, C Runtime Library, etc) only have debug info
in PDB format, so in order to be able to support debugging
of system code, we must support it.
Currently this code should compile on every platform, but on
non-Windows platforms the PDB plugin will return 0 capabilities,
meaning that for now PDB is only supported on Windows. This
may change in the future, but the API is designed in such a way
that this will require few (if any) changes on the LLDB side.
In the future we can just flip a switch and everything will
work.
This patch only adds support for line tables. It does not return
information about functions, types, global variables, or anything
else. This functionality will be added in a followup patch.
Differential Revision: http://reviews.llvm.org/D17363
Reviewed by: Greg Clayton
llvm-svn: 262528
2016-03-03 06:05:52 +08:00
|
|
|
#include "lldb/Host/windows/windows.h"
|
2015-04-01 05:03:22 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "llvm/Support/TargetSelect.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
static void
|
|
|
|
fatal_error_handler(void *user_data, const std::string &reason, bool gen_crash_diag)
|
|
|
|
{
|
|
|
|
Host::SetCrashDescription(reason.c_str());
|
|
|
|
::abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
SystemInitializerCommon::SystemInitializerCommon()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SystemInitializerCommon::~SystemInitializerCommon()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SystemInitializerCommon::Initialize()
|
|
|
|
{
|
|
|
|
#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);
|
|
|
|
|
|
|
|
_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);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Log::Initialize();
|
|
|
|
HostInfo::Initialize();
|
2016-08-10 07:06:08 +08:00
|
|
|
Timer scoped_timer(LLVM_PRETTY_FUNCTION, LLVM_PRETTY_FUNCTION);
|
2015-04-01 05:03:22 +08:00
|
|
|
|
|
|
|
llvm::install_fatal_error_handler(fatal_error_handler, 0);
|
|
|
|
|
|
|
|
process_gdb_remote::ProcessGDBRemoteLog::Initialize();
|
|
|
|
|
|
|
|
// Initialize plug-ins
|
|
|
|
ObjectContainerBSDArchive::Initialize();
|
|
|
|
ObjectFileELF::Initialize();
|
|
|
|
ObjectFilePECOFF::Initialize();
|
|
|
|
|
2015-04-15 17:47:02 +08:00
|
|
|
EmulateInstructionARM::Initialize();
|
2015-05-15 14:53:30 +08:00
|
|
|
EmulateInstructionMIPS::Initialize();
|
2015-05-07 13:56:27 +08:00
|
|
|
EmulateInstructionMIPS64::Initialize();
|
2015-04-15 17:47:02 +08:00
|
|
|
|
2015-04-01 05:03:22 +08:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Apple/Darwin hosted plugins
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
ObjectContainerUniversalMachO::Initialize();
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
ObjectFileMachO::Initialize();
|
|
|
|
#endif
|
|
|
|
#if defined(__linux__)
|
|
|
|
static ConstString g_linux_log_name("linux");
|
|
|
|
ProcessPOSIXLog::Initialize(g_linux_log_name);
|
|
|
|
#endif
|
2015-04-11 00:18:08 +08:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
ProcessWindowsLog::Initialize();
|
|
|
|
#endif
|
2015-04-01 05:03:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SystemInitializerCommon::Terminate()
|
|
|
|
{
|
2016-08-10 07:06:08 +08:00
|
|
|
Timer scoped_timer(LLVM_PRETTY_FUNCTION, LLVM_PRETTY_FUNCTION);
|
2015-04-01 05:03:22 +08:00
|
|
|
ObjectContainerBSDArchive::Terminate();
|
|
|
|
ObjectFileELF::Terminate();
|
|
|
|
ObjectFilePECOFF::Terminate();
|
|
|
|
|
2015-04-15 17:47:02 +08:00
|
|
|
EmulateInstructionARM::Terminate();
|
2015-05-15 14:53:30 +08:00
|
|
|
EmulateInstructionMIPS::Terminate();
|
2015-05-07 13:56:27 +08:00
|
|
|
EmulateInstructionMIPS64::Terminate();
|
2015-04-15 17:47:02 +08:00
|
|
|
|
2016-06-29 21:58:27 +08:00
|
|
|
ObjectContainerUniversalMachO::Terminate();
|
2015-04-01 05:03:22 +08:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
ObjectFileMachO::Terminate();
|
|
|
|
#endif
|
|
|
|
|
2015-09-05 00:34:19 +08:00
|
|
|
#if defined(_MSC_VER)
|
2015-05-08 05:39:33 +08:00
|
|
|
ProcessWindowsLog::Terminate();
|
|
|
|
#endif
|
|
|
|
|
2016-02-20 03:20:44 +08:00
|
|
|
HostInfo::Terminate();
|
2015-04-01 05:03:22 +08:00
|
|
|
Log::Terminate();
|
|
|
|
}
|