[Lldb-commits] [lldb] r143147 - in /lldb/trunk: include/lldb/Host/Host.h source/Commands/CommandObjectExpression.cpp source/Host/common/Host.cpp

Sean Callanan scallanan at apple.com
Thu Oct 27 14:22:25 PDT 2011


Author: spyffe
Date: Thu Oct 27 16:22:25 2011
New Revision: 143147

URL: http://llvm.org/viewvc/llvm-project?rev=143147&view=rev
Log:
Added a function to the Host that gets a dummy target
for it, so that people who want to use LLDB as a
calculator can run simple expressions without needing
a target or process.

Modified:
    lldb/trunk/include/lldb/Host/Host.h
    lldb/trunk/source/Commands/CommandObjectExpression.cpp
    lldb/trunk/source/Host/common/Host.cpp

Modified: lldb/trunk/include/lldb/Host/Host.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=143147&r1=143146&r2=143147&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Host.h (original)
+++ lldb/trunk/include/lldb/Host/Host.h Thu Oct 27 16:22:25 2011
@@ -355,6 +355,9 @@
     static Error
     LaunchProcess (ProcessLaunchInfo &launch_info);
     
+    static lldb::TargetSP
+    GetDummyTarget (Debugger &debugger);
+    
     static bool
     OpenFileInExternalEditor (const FileSpec &file_spec, 
                               uint32_t line_no);

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=143147&r1=143146&r2=143147&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu Oct 27 16:22:25 2011
@@ -283,6 +283,10 @@
 )
 {
     Target *target = m_exe_ctx.GetTargetPtr();
+    
+    if (!target)
+        target = Host::GetDummyTarget(m_interpreter.GetDebugger()).get();
+    
     if (target)
     {
         lldb::ValueObjectSP result_valobj_sp;

Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=143147&r1=143146&r2=143147&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Thu Oct 27 16:22:25 2011
@@ -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 @@
 }
 #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)





More information about the lldb-commits mailing list