Initialize LLVM when LLDB is initialized, and

install a crash handler.

<rdar://problem/18083226>

llvm-svn: 216309
This commit is contained in:
Sean Callanan 2014-08-23 00:47:22 +00:00
parent 62e9fb9727
commit 0de7ecd346
2 changed files with 16 additions and 11 deletions

View File

@ -103,16 +103,6 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
m_compiler (),
m_code_generator ()
{
// Initialize targets first, so that --version shows registered targets.
static struct InitializeLLVM {
InitializeLLVM() {
llvm::InitializeAllTargets();
llvm::InitializeAllAsmPrinters();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllDisassemblers();
}
} InitializeLLVM;
// 1. Create a new compiler instance.
m_compiler.reset(new CompilerInstance());

View File

@ -25,6 +25,7 @@
#include "lldb/Target/Thread.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/TargetSelect.h"
#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
@ -95,6 +96,12 @@
using namespace lldb;
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();
}
void
lldb_private::Initialize ()
{
@ -110,7 +117,15 @@ lldb_private::Initialize ()
HostInfo::Initialize();
Timer::Initialize ();
Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
// Initialize LLVM and Clang
llvm::InitializeAllTargets();
llvm::InitializeAllAsmPrinters();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllDisassemblers();
llvm::install_fatal_error_handler(fatal_error_handler, 0);
// Initialize plug-ins
ABIMacOSX_i386::Initialize();
ABIMacOSX_arm::Initialize();
ABIMacOSX_arm64::Initialize();