From 3e7e915dca7dd543f11bdb6312e95a857df22618 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Tue, 20 Oct 2015 00:23:46 +0000 Subject: Added support for the "--repl" argument to LLDB. This makes LLDB launch and create a REPL, specifying no target so that the REPL can create one for itself. Also added the "--repl-language" option, which specifies the language to use. Plumbed the relevant arguments and errors through the REPL creation mechanism. llvm-svn: 250773 --- lldb/source/Core/Debugger.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'lldb/source/Core/Debugger.cpp') diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index e1779abb961..c5f46779fa5 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -31,6 +31,7 @@ #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/DataFormatters/TypeSummary.h" +#include "lldb/Expression/REPL.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/Terminal.h" @@ -44,6 +45,7 @@ #include "lldb/Symbol/Symbol.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/TargetList.h" +#include "lldb/Target/Language.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/SectionLoadList.h" @@ -1798,3 +1800,35 @@ Debugger::GetSelectedOrDummyTarget(bool prefer_dummy) return GetDummyTarget(); } +Error +Debugger::RunREPL (LanguageType language, const char *repl_options) +{ + Error err; + FileSpec repl_executable; + if (language == eLanguageTypeUnknown) + { + err.SetErrorString ("must specify a language for a REPL"); // TODO make it possible to specify a default language + return err; + } + + Target *const target = nullptr; // passing in an empty target means the REPL must create one + + REPLSP repl_sp(REPL::Create(err, language, target, repl_options)); + + if (!err.Success()) + { + return err; + } + + if (!repl_sp) + { + err.SetErrorStringWithFormat("couldn't find a REPL for %s", Language::GetNameForLanguageType(language)); + return err; + } + + repl_sp->SetCompilerOptions(repl_options); + repl_sp->RunLoop(); + + return err; +} + -- cgit v1.2.3