diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h index 0e0577c1859f..7745a50efda9 100644 --- a/lldb/include/lldb/Host/Host.h +++ b/lldb/include/lldb/Host/Host.h @@ -355,6 +355,9 @@ public: static Error LaunchProcess (ProcessLaunchInfo &launch_info); + static lldb::TargetSP + GetDummyTarget (Debugger &debugger); + static bool OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no); diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 3ec585ee33d9..5134b28b08d9 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -283,6 +283,10 @@ CommandObjectExpression::EvaluateExpression ) { Target *target = m_exe_ctx.GetTargetPtr(); + + if (!target) + target = Host::GetDummyTarget(m_interpreter.GetDebugger()).get(); + if (target) { lldb::ValueObjectSP result_valobj_sp; diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index f88c76b0c606..ebb15cc5ff10 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -10,6 +10,7 @@ #include "lldb/Host/Host.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/ConstString.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Error.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" @@ -18,6 +19,7 @@ #include "lldb/Host/FileSpec.h" #include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" +#include "lldb/Target/TargetList.h" #include "llvm/Support/Host.h" #include "llvm/Support/MachO.h" @@ -1165,6 +1167,24 @@ Host::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) } #endif +lldb::TargetSP +Host::GetDummyTarget (lldb_private::Debugger &debugger) +{ + static TargetSP dummy_target; + + if (!dummy_target) + { + Error err = debugger.GetTargetList().CreateTarget(debugger, + FileSpec(), + Host::GetTargetTriple().AsCString(), + false, + NULL, + dummy_target); + } + + return dummy_target; +} + #if !defined (__APPLE__) bool Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no)