[llvm-branch-commits] [lldb] r183468 - Update platform branch with top of tree.

Greg Clayton gclayton at apple.com
Thu Jun 6 17:08:11 PDT 2013


Modified: lldb/branches/lldb-platform-work/source/API/SBProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBProcess.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBProcess.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBProcess.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/API/SBProcess.h"
 
 #include "lldb/lldb-defines.h"
@@ -15,6 +17,7 @@
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/State.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Core/StreamFile.h"
@@ -80,6 +83,29 @@ SBProcess::GetBroadcasterClassName ()
     return Process::GetStaticBroadcasterClass().AsCString();
 }
 
+const char *
+SBProcess::GetPluginName ()
+{
+    ProcessSP process_sp(GetSP());
+    if (process_sp)
+    {
+        return process_sp->GetPluginName().GetCString();
+    }
+    return "<Unknown>";
+}
+
+const char *
+SBProcess::GetShortPluginName ()
+{
+    ProcessSP process_sp(GetSP());
+    if (process_sp)
+    {
+        return process_sp->GetPluginName().GetCString();
+    }
+    return "<Unknown>";
+}
+
+
 lldb::ProcessSP
 SBProcess::GetSP() const
 {
@@ -102,7 +128,8 @@ SBProcess::Clear ()
 bool
 SBProcess::IsValid() const
 {
-    return m_opaque_wp.lock().get() != NULL;
+    ProcessSP process_sp(m_opaque_wp.lock());
+    return ((bool) process_sp && process_sp->IsValid());
 }
 
 bool
@@ -116,7 +143,7 @@ SBProcess::RemoteLaunch (char const **ar
                          bool stop_at_entry,
                          lldb::SBError& error)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log) {
         log->Printf ("SBProcess(%p)::RemoteLaunch (argv=%p, envp=%p, stdin=%s, stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, stop_at_entry=%i, &error (%p))...",
                      m_opaque_wp.lock().get(),
@@ -195,11 +222,11 @@ SBProcess::RemoteAttachToProcessWithID (
         error.SetErrorString ("unable to attach pid");
     }
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log) {
         SBStream sstr;
         error.GetDescription (sstr);
-        log->Printf ("SBProcess(%p)::RemoteAttachToProcessWithID (%llu) => SBError (%p): %s", process_sp.get(), pid, error.get(), sstr.GetData());
+        log->Printf ("SBProcess(%p)::RemoteAttachToProcessWithID (%" PRIu64 ") => SBError (%p): %s", process_sp.get(), pid, error.get(), sstr.GetData());
     }
 
     return error.Success();
@@ -209,7 +236,7 @@ SBProcess::RemoteAttachToProcessWithID (
 uint32_t
 SBProcess::GetNumThreads ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     uint32_t num_threads = 0;
     ProcessSP process_sp(GetSP());
@@ -231,7 +258,7 @@ SBProcess::GetNumThreads ()
 SBThread
 SBProcess::GetSelectedThread () const
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBThread sb_thread;
     ThreadSP thread_sp;
@@ -251,10 +278,31 @@ SBProcess::GetSelectedThread () const
     return sb_thread;
 }
 
+SBThread
+SBProcess::CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context)
+{
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    
+    SBThread sb_thread;
+    ThreadSP thread_sp;
+    ProcessSP process_sp(GetSP());
+    if (process_sp)
+    {
+        Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
+        thread_sp = process_sp->CreateOSPluginThread(tid, context);
+        sb_thread.SetThread (thread_sp);
+    }
+    
+    if (log)
+        log->Printf ("SBProcess(%p)::CreateOSPluginThread (tid=0x%" PRIx64 ", context=0x%" PRIx64 ") => SBThread(%p)", process_sp.get(), tid, context, thread_sp.get());
+    
+    return sb_thread;
+}
+
 SBTarget
 SBProcess::GetTarget() const
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBTarget sb_target;
     TargetSP target_sp;
@@ -275,7 +323,7 @@ SBProcess::GetTarget() const
 size_t
 SBProcess::PutSTDIN (const char *src, size_t src_len)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     size_t ret_val = 0;
     ProcessSP process_sp(GetSP());
@@ -306,10 +354,14 @@ SBProcess::GetSTDOUT (char *dst, size_t
         bytes_read = process_sp->GetSTDOUT (dst, dst_len, error);
     }
     
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
-        log->Printf ("SBProcess(%p)::GetSTDOUT (dst=\"%.*s\", dst_len=%zu) => %zu", 
-                     process_sp.get(), (int) bytes_read, dst, dst_len, bytes_read);
+        log->Printf ("SBProcess(%p)::GetSTDOUT (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64,
+                     process_sp.get(),
+                     (int) bytes_read,
+                     dst,
+                     (uint64_t)dst_len,
+                     (uint64_t)bytes_read);
 
     return bytes_read;
 }
@@ -325,14 +377,41 @@ SBProcess::GetSTDERR (char *dst, size_t
         bytes_read = process_sp->GetSTDERR (dst, dst_len, error);
     }
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
-        log->Printf ("SBProcess(%p)::GetSTDERR (dst=\"%.*s\", dst_len=%zu) => %zu",
-                     process_sp.get(), (int) bytes_read, dst, dst_len, bytes_read);
+        log->Printf ("SBProcess(%p)::GetSTDERR (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64,
+                     process_sp.get(),
+                     (int) bytes_read,
+                     dst,
+                     (uint64_t)dst_len,
+                     (uint64_t)bytes_read);
 
     return bytes_read;
 }
 
+size_t
+SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const
+{
+    size_t bytes_read = 0;
+    ProcessSP process_sp(GetSP());
+    if (process_sp)
+    {
+        Error error;
+        bytes_read = process_sp->GetAsyncProfileData (dst, dst_len, error);
+    }
+    
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    if (log)
+        log->Printf ("SBProcess(%p)::GetProfileData (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64,
+                     process_sp.get(),
+                     (int) bytes_read,
+                     dst,
+                     (uint64_t)dst_len,
+                     (uint64_t)bytes_read);
+    
+    return bytes_read;
+}
+
 void
 SBProcess::ReportEventState (const SBEvent &event, FILE *out) const
 {
@@ -346,7 +425,7 @@ SBProcess::ReportEventState (const SBEve
         char message[1024];
         int message_len = ::snprintf (message,
                                       sizeof (message),
-                                      "Process %llu %s\n",
+                                      "Process %" PRIu64 " %s\n",
                                       process_sp->GetID(),
                                       SBDebugger::StateAsCString (event_state));
 
@@ -365,7 +444,7 @@ SBProcess::AppendEventStateReport (const
         char message[1024];
         ::snprintf (message,
                     sizeof (message),
-                    "Process %llu %s\n",
+                    "Process %" PRIu64 " %s\n",
                     process_sp->GetID(),
                     SBDebugger::StateAsCString (event_state));
 
@@ -386,9 +465,9 @@ SBProcess::SetSelectedThread (const SBTh
 }
 
 bool
-SBProcess::SetSelectedThreadByID (uint32_t tid)
+SBProcess::SetSelectedThreadByID (lldb::tid_t tid)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     bool ret_val = false;
     ProcessSP process_sp(GetSP());
@@ -399,7 +478,7 @@ SBProcess::SetSelectedThreadByID (uint32
     }
 
     if (log)
-        log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=0x%4.4x) => %s", 
+        log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=0x%4.4" PRIx64 ") => %s",
                      process_sp.get(), tid, (ret_val ? "true" : "false"));
 
     return ret_val;
@@ -408,7 +487,7 @@ SBProcess::SetSelectedThreadByID (uint32
 bool
 SBProcess::SetSelectedThreadByIndexID (uint32_t index_id)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     bool ret_val = false;
     ProcessSP process_sp(GetSP());
@@ -428,7 +507,7 @@ SBProcess::SetSelectedThreadByIndexID (u
 SBThread
 SBProcess::GetThreadAtIndex (size_t index)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBThread sb_thread;
     ThreadSP thread_sp;
@@ -451,6 +530,21 @@ SBProcess::GetThreadAtIndex (size_t inde
     return sb_thread;
 }
 
+uint32_t
+SBProcess::GetStopID(bool include_expression_stops)
+{
+    ProcessSP process_sp(GetSP());
+    if (process_sp)
+    {
+        Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
+        if (include_expression_stops)
+            return process_sp->GetStopID();
+        else
+            return process_sp->GetLastNaturalStopID();
+    }
+    return 0;
+}
+
 StateType
 SBProcess::GetState ()
 {
@@ -463,7 +557,7 @@ SBProcess::GetState ()
         ret_val = process_sp->GetState();
     }
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBProcess(%p)::GetState () => %s", 
                      process_sp.get(),
@@ -483,7 +577,7 @@ SBProcess::GetExitStatus ()
         Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
         exit_status = process_sp->GetExitStatus ();
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBProcess(%p)::GetExitStatus () => %i (0x%8.8x)", 
                      process_sp.get(), exit_status, exit_status);
@@ -501,7 +595,7 @@ SBProcess::GetExitDescription ()
         Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
         exit_desc = process_sp->GetExitDescription ();
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBProcess(%p)::GetExitDescription () => %s", 
                      process_sp.get(), exit_desc);
@@ -516,13 +610,26 @@ SBProcess::GetProcessID ()
     if (process_sp)
         ret_val = process_sp->GetID();
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
-        log->Printf ("SBProcess(%p)::GetProcessID () => %llu", process_sp.get(), ret_val);
+        log->Printf ("SBProcess(%p)::GetProcessID () => %" PRIu64, process_sp.get(), ret_val);
 
     return ret_val;
 }
 
+uint32_t
+SBProcess::GetUniqueID()
+{
+    uint32_t ret_val = 0;
+    ProcessSP process_sp(GetSP());
+    if (process_sp)
+        ret_val = process_sp->GetUniqueID();
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    if (log)
+        log->Printf ("SBProcess(%p)::GetUniqueID () => %" PRIu32, process_sp.get(), ret_val);
+    return ret_val;
+}
+
 ByteOrder
 SBProcess::GetByteOrder () const
 {
@@ -531,7 +638,7 @@ SBProcess::GetByteOrder () const
     if (process_sp)
         byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder();
     
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBProcess(%p)::GetByteOrder () => %d", process_sp.get(), byteOrder);
 
@@ -546,7 +653,7 @@ SBProcess::GetAddressByteSize () const
     if (process_sp)
         size =  process_sp->GetTarget().GetArchitecture().GetAddressByteSize();
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBProcess(%p)::GetAddressByteSize () => %d", process_sp.get(), size);
 
@@ -556,7 +663,7 @@ SBProcess::GetAddressByteSize () const
 SBError
 SBProcess::Continue ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     
     SBError sb_error;
     ProcessSP process_sp(GetSP());
@@ -607,7 +714,7 @@ SBProcess::Destroy ()
     else
         sb_error.SetErrorString ("SBProcess is invalid");
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         SBStream sstr;
@@ -635,7 +742,7 @@ SBProcess::Stop ()
     else
         sb_error.SetErrorString ("SBProcess is invalid");
     
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         SBStream sstr;
@@ -662,7 +769,7 @@ SBProcess::Kill ()
     else
         sb_error.SetErrorString ("SBProcess is invalid");
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         SBStream sstr;
@@ -679,12 +786,20 @@ SBProcess::Kill ()
 SBError
 SBProcess::Detach ()
 {
+    // FIXME: This should come from a process default.
+    bool keep_stopped = false;
+    return Detach (keep_stopped);
+}
+
+SBError
+SBProcess::Detach (bool keep_stopped)
+{
     SBError sb_error;
     ProcessSP process_sp(GetSP());
     if (process_sp)
     {
         Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
-        sb_error.SetError (process_sp->Detach());
+        sb_error.SetError (process_sp->Detach(keep_stopped));
     }
     else
         sb_error.SetErrorString ("SBProcess is invalid");    
@@ -704,7 +819,7 @@ SBProcess::Signal (int signo)
     }
     else
         sb_error.SetErrorString ("SBProcess is invalid");    
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         SBStream sstr;
@@ -743,10 +858,10 @@ SBProcess::GetThreadByID (tid_t tid)
         sb_thread.SetThread (thread_sp);
     }
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
-        log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%4.4llx) => SBThread (%p)", 
+        log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%4.4" PRIx64 ") => SBThread (%p)",
                      process_sp.get(), 
                      tid,
                      thread_sp.get());
@@ -770,7 +885,7 @@ SBProcess::GetThreadByIndexID (uint32_t
         sb_thread.SetThread (thread_sp);
     }
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%x) => SBThread (%p)", 
@@ -785,7 +900,7 @@ SBProcess::GetThreadByIndexID (uint32_t
 StateType
 SBProcess::GetStateFromEvent (const SBEvent &event)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     StateType ret_val = Process::ProcessEventData::GetStateFromEvent (event.get());
     
@@ -802,6 +917,18 @@ SBProcess::GetRestartedFromEvent (const
     return Process::ProcessEventData::GetRestartedFromEvent (event.get());
 }
 
+size_t
+SBProcess::GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event)
+{
+    return Process::ProcessEventData::GetNumRestartedReasons(event.get());
+}
+
+const char *
+SBProcess::GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx)
+{
+    return Process::ProcessEventData::GetRestartedReasonAtIndex(event.get(), idx);
+}
+
 SBProcess
 SBProcess::GetProcessFromEvent (const SBEvent &event)
 {
@@ -818,7 +945,7 @@ SBProcess::EventIsProcessEvent (const SB
 SBBroadcaster
 SBProcess::GetBroadcaster () const
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     ProcessSP process_sp(GetSP());
 
@@ -840,7 +967,7 @@ SBProcess::GetBroadcasterClass ()
 size_t
 SBProcess::ReadMemory (addr_t addr, void *dst, size_t dst_len, SBError &sb_error)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     size_t bytes_read = 0;
 
@@ -848,11 +975,11 @@ SBProcess::ReadMemory (addr_t addr, void
 
     if (log)
     {
-        log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%llx, dst=%p, dst_len=%zu, SBError (%p))...",
+        log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64 ", dst=%p, dst_len=%" PRIu64 ", SBError (%p))...",
                      process_sp.get(), 
                      addr, 
                      dst, 
-                     dst_len, 
+                     (uint64_t)dst_len,
                      sb_error.get());
     }
     
@@ -880,14 +1007,14 @@ SBProcess::ReadMemory (addr_t addr, void
     {
         SBStream sstr;
         sb_error.GetDescription (sstr);
-        log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%llx, dst=%p, dst_len=%zu, SBError (%p): %s) => %zu", 
+        log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64 ", dst=%p, dst_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64,
                      process_sp.get(), 
                      addr, 
                      dst, 
-                     dst_len, 
+                     (uint64_t)dst_len,
                      sb_error.get(), 
                      sstr.GetData(),
-                     bytes_read);
+                     (uint64_t)bytes_read);
     }
 
     return bytes_read;
@@ -908,7 +1035,7 @@ SBProcess::ReadCStringFromMemory (addr_t
         }
         else
         {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+            Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
             if (log)
                 log->Printf ("SBProcess(%p)::ReadCStringFromMemory() => error: process is running", process_sp.get());
             sb_error.SetErrorString("process is running");
@@ -936,7 +1063,7 @@ SBProcess::ReadUnsignedFromMemory (addr_
         }
         else
         {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+            Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
             if (log)
                 log->Printf ("SBProcess(%p)::ReadUnsignedFromMemory() => error: process is running", process_sp.get());
             sb_error.SetErrorString("process is running");
@@ -964,7 +1091,7 @@ SBProcess::ReadPointerFromMemory (addr_t
         }
         else
         {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+            Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
             if (log)
                 log->Printf ("SBProcess(%p)::ReadPointerFromMemory() => error: process is running", process_sp.get());
             sb_error.SetErrorString("process is running");
@@ -982,17 +1109,17 @@ SBProcess::WriteMemory (addr_t addr, con
 {
     size_t bytes_written = 0;
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     ProcessSP process_sp(GetSP());
 
     if (log)
     {
-        log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%llx, src=%p, dst_len=%zu, SBError (%p))...",
+        log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64 ", src=%p, src_len=%" PRIu64 ", SBError (%p))...",
                      process_sp.get(), 
                      addr, 
                      src, 
-                     src_len, 
+                     (uint64_t)src_len,
                      sb_error.get());
     }
 
@@ -1016,14 +1143,14 @@ SBProcess::WriteMemory (addr_t addr, con
     {
         SBStream sstr;
         sb_error.GetDescription (sstr);
-        log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%llx, src=%p, dst_len=%zu, SBError (%p): %s) => %zu", 
+        log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64 ", src=%p, src_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64,
                      process_sp.get(), 
                      addr, 
                      src, 
-                     src_len, 
+                     (uint64_t)src_len, 
                      sb_error.get(), 
                      sstr.GetData(),
-                     bytes_written);
+                     (uint64_t)bytes_written);
     }
 
     return bytes_written;
@@ -1044,7 +1171,7 @@ SBProcess::GetDescription (SBStream &des
         if (exe_module)
             exe_name = exe_module->GetFileSpec().GetFilename().AsCString();
 
-        strm.Printf ("SBProcess: pid = %llu, state = %s, threads = %d%s%s", 
+        strm.Printf ("SBProcess: pid = %" PRIu64 ", state = %s, threads = %d%s%s",
                      process_sp->GetID(),
                      lldb_private::StateAsCString (GetState()), 
                      GetNumThreads(),
@@ -1060,7 +1187,7 @@ SBProcess::GetDescription (SBStream &des
 uint32_t
 SBProcess::GetNumSupportedHardwareWatchpoints (lldb::SBError &sb_error) const
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     uint32_t num = 0;
     ProcessSP process_sp(GetSP());
@@ -1068,7 +1195,6 @@ SBProcess::GetNumSupportedHardwareWatchp
     {
         Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
         sb_error.SetError(process_sp->GetWatchpointSupportInfo (num));
-        LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
         if (log)
             log->Printf ("SBProcess(%p)::GetNumSupportedHardwareWatchpoints () => %u",
                          process_sp.get(), num);
@@ -1094,7 +1220,7 @@ SBProcess::LoadImage (lldb::SBFileSpec &
         }
         else
         {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+            Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
             if (log)
                 log->Printf ("SBProcess(%p)::LoadImage() => error: process is running", process_sp.get());
             sb_error.SetErrorString("process is running");
@@ -1118,7 +1244,7 @@ SBProcess::UnloadImage (uint32_t image_t
         }
         else
         {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+            Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
             if (log)
                 log->Printf ("SBProcess(%p)::UnloadImage() => error: process is running", process_sp.get());
             sb_error.SetErrorString("process is running");

Modified: lldb/branches/lldb-platform-work/source/API/SBSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBSection.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBSection.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBSection.cpp Thu Jun  6 19:06:43 2013
@@ -16,6 +16,7 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Core/StreamString.h"
+#include "lldb/Symbol/ObjectFile.h"
 
 
 using namespace lldb;
@@ -162,7 +163,7 @@ SBSection::GetFileOffset ()
         {
             ObjectFile *objfile = module_sp->GetObjectFile();
             if (objfile)
-                return objfile->GetOffset() + section_sp->GetFileOffset();
+                return objfile->GetFileOffset() + section_sp->GetFileOffset();
         }
     }
     return UINT64_MAX;
@@ -199,7 +200,7 @@ SBSection::GetSectionData (uint64_t offs
                 ObjectFile *objfile = module_sp->GetObjectFile();
                 if (objfile)
                 {
-                    const uint64_t sect_file_offset = objfile->GetOffset() + section_sp->GetFileOffset();
+                    const uint64_t sect_file_offset = objfile->GetFileOffset() + section_sp->GetFileOffset();
                     const uint64_t file_offset = sect_file_offset + offset;
                     uint64_t file_size = size;
                     if (file_size == UINT64_MAX)
@@ -263,7 +264,7 @@ SBSection::GetDescription (SBStream &des
     if (section_sp)
     {
         const addr_t file_addr = section_sp->GetFileAddress();
-        strm.Printf ("[0x%16.16llx-0x%16.16llx) ", file_addr, file_addr + section_sp->GetByteSize());
+        strm.Printf ("[0x%16.16" PRIx64 "-0x%16.16" PRIx64 ") ", file_addr, file_addr + section_sp->GetByteSize());
         section_sp->DumpName(&strm);
     }
     else

Modified: lldb/branches/lldb-platform-work/source/API/SBSourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBSourceManager.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBSourceManager.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBSourceManager.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBSourceManager.h"
 #include "lldb/API/SBTarget.h"
@@ -25,22 +27,24 @@ namespace lldb_private
     class SourceManagerImpl
     {
     public:
-        SourceManagerImpl (const lldb::DebuggerSP &debugger_sp)
+        SourceManagerImpl (const lldb::DebuggerSP &debugger_sp) :
+            m_debugger_wp (debugger_sp),
+            m_target_wp ()
         {
-            m_debugger_sp = debugger_sp;
         }
         
-        SourceManagerImpl (const lldb::TargetSP &target_sp)
+        SourceManagerImpl (const lldb::TargetSP &target_sp) :
+            m_debugger_wp (),
+            m_target_wp (target_sp)
         {
-            m_target_sp = target_sp;
         }
         
         SourceManagerImpl (const SourceManagerImpl &rhs)
         {
             if (&rhs == this)
                 return;
-            m_debugger_sp = rhs.m_debugger_sp;
-            m_target_sp   = rhs.m_target_sp;
+            m_debugger_wp = rhs.m_debugger_wp;
+            m_target_wp   = rhs.m_target_wp;
         }
         
         size_t
@@ -54,27 +58,35 @@ namespace lldb_private
             if (!file)
                 return 0;
             
-            if (m_debugger_sp)
-                return m_debugger_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (file,
-                                                                                            line,
-                                                                                            context_before,
-                                                                                            context_after,
-                                                                                            current_line_cstr,
-                                                                                            s);
-            else if (m_target_sp)
-                return m_target_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (file,
-                                                                                          line,
-                                                                                          context_before,
-                                                                                          context_after,
-                                                                                          current_line_cstr,
-                                                                                          s);
+            lldb::TargetSP target_sp (m_target_wp.lock());
+            if (target_sp)
+            {
+                return target_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (file,
+                                                                                        line,
+                                                                                        context_before,
+                                                                                        context_after,
+                                                                                        current_line_cstr,
+                                                                                        s);
+            }
             else
-                return 0;
+            {
+                lldb::DebuggerSP debugger_sp (m_debugger_wp.lock());
+                if (debugger_sp)
+                {
+                    return debugger_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers (file,
+                                                                                              line,
+                                                                                              context_before,
+                                                                                              context_after,
+                                                                                              current_line_cstr,
+                                                                                              s);
+                }
+            }
+            return 0;
         }
         
     private:
-        lldb::DebuggerSP m_debugger_sp;
-        lldb::TargetSP   m_target_sp;
+        lldb::DebuggerWP m_debugger_wp;
+        lldb::TargetWP   m_target_wp;
         
     };
 }

Modified: lldb/branches/lldb-platform-work/source/API/SBSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBSymbol.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBSymbol.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBSymbol.cpp Thu Jun  6 19:06:43 2013
@@ -65,7 +65,7 @@ SBSymbol::GetName() const
     if (m_opaque_ptr)
         name = m_opaque_ptr->GetMangled().GetName().AsCString();
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBSymbol(%p)::GetName () => \"%s\"", m_opaque_ptr, name ? name : "");
     return name;
@@ -77,7 +77,7 @@ SBSymbol::GetMangledName () const
     const char *name = NULL;
     if (m_opaque_ptr)
         name = m_opaque_ptr->GetMangled().GetMangledName().AsCString();
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBSymbol(%p)::GetMangledName () => \"%s\"", m_opaque_ptr, name ? name : "");
 
@@ -113,11 +113,15 @@ SBSymbol::GetDescription (SBStream &desc
     return true;
 }
 
-
-
 SBInstructionList
 SBSymbol::GetInstructions (SBTarget target)
 {
+    return GetInstructions (target, NULL);
+}
+
+SBInstructionList
+SBSymbol::GetInstructions (SBTarget target, const char *flavor_string)
+{
     SBInstructionList sb_instructions;
     if (m_opaque_ptr)
     {
@@ -137,6 +141,7 @@ SBSymbol::GetInstructions (SBTarget targ
                 AddressRange symbol_range (m_opaque_ptr->GetAddress(), m_opaque_ptr->GetByteSize());
                 sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module_sp->GetArchitecture (),
                                                                                  NULL,
+                                                                                 flavor_string,
                                                                                  exe_ctx,
                                                                                  symbol_range));
             }

Modified: lldb/branches/lldb-platform-work/source/API/SBSymbolContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBSymbolContext.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBSymbolContext.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBSymbolContext.cpp Thu Jun  6 19:06:43 2013
@@ -72,7 +72,7 @@ SBSymbolContext::SetSymbolContext (const
     else
     {
         if (m_opaque_ap.get())
-            m_opaque_ap->Clear();
+            m_opaque_ap->Clear(true);
     }
 }
 
@@ -87,7 +87,7 @@ SBSymbolContext::IsValid () const
 SBModule
 SBSymbolContext::GetModule ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBModule sb_module;
     ModuleSP module_sp;
@@ -117,7 +117,7 @@ SBSymbolContext::GetCompileUnit ()
 SBFunction
 SBSymbolContext::GetFunction ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     Function *function = NULL;
     
@@ -142,7 +142,7 @@ SBSymbolContext::GetBlock ()
 SBLineEntry
 SBSymbolContext::GetLineEntry ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBLineEntry sb_line_entry;
     if (m_opaque_ap.get())
@@ -160,7 +160,7 @@ SBSymbolContext::GetLineEntry ()
 SBSymbol
 SBSymbolContext::GetSymbol ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     Symbol *symbol = NULL;
     

Modified: lldb/branches/lldb-platform-work/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBTarget.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBTarget.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBTarget.cpp Thu Jun  6 19:06:43 2013
@@ -7,12 +7,15 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/API/SBTarget.h"
 
 #include "lldb/lldb-public.h"
 
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBBreakpoint.h"
+#include "lldb/API/SBExpressionOptions.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBListener.h"
 #include "lldb/API/SBModule.h"
@@ -31,14 +34,18 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Disassembler.h"
 #include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/RegularExpression.h"
 #include "lldb/Core/SearchFilter.h"
+#include "lldb/Core/Section.h"
 #include "lldb/Core/STLUtils.h"
 #include "lldb/Core/ValueObjectList.h"
 #include "lldb/Core/ValueObjectVariable.h"
 #include "lldb/Host/FileSpec.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Interpreter/Args.h"
+#include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/LanguageRuntime.h"
@@ -529,7 +536,7 @@ SBTarget::GetProcess ()
         sb_process.SetSP (process_sp);
     }
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         log->Printf ("SBTarget(%p)::GetProcess () => SBProcess(%p)", 
@@ -550,6 +557,26 @@ SBTarget::GetDebugger () const
 }
 
 SBProcess
+SBTarget::LoadCore (const char *core_file)
+{
+    SBProcess sb_process;
+    TargetSP target_sp(GetSP());
+    if (target_sp)
+    {
+        FileSpec filespec(core_file, true);
+        ProcessSP process_sp (target_sp->CreateProcess(target_sp->GetDebugger().GetListener(),
+                                                       NULL,
+                                                       &filespec));
+        if (process_sp)
+        {
+            process_sp->LoadCore();
+            sb_process.SetSP (process_sp);
+        }
+    }
+    return sb_process;
+}
+
+SBProcess
 SBTarget::LaunchSimple
 (
     char const **argv,
@@ -591,7 +618,7 @@ SBTarget::Launch
     lldb::SBError& error
 )
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBProcess sb_process;
     ProcessSP process_sp;
@@ -706,7 +733,7 @@ SBTarget::Launch
     log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
     if (log)
     {
-        log->Printf ("SBTarget(%p)::Launch (...) => SBProceess(%p)", 
+        log->Printf ("SBTarget(%p)::Launch (...) => SBProcess(%p)", 
                      target_sp.get(), process_sp.get());
     }
 
@@ -716,7 +743,7 @@ SBTarget::Launch
 SBProcess
 SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     
     SBProcess sb_process;
     ProcessSP process_sp;
@@ -806,7 +833,7 @@ SBTarget::Launch (SBLaunchInfo &sb_launc
     log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
     if (log)
     {
-        log->Printf ("SBTarget(%p)::Launch (...) => SBProceess(%p)", 
+        log->Printf ("SBTarget(%p)::Launch (...) => SBProcess(%p)", 
                      target_sp.get(), process_sp.get());
     }
     
@@ -816,9 +843,17 @@ SBTarget::Launch (SBLaunchInfo &sb_launc
 lldb::SBProcess
 SBTarget::Attach (SBAttachInfo &sb_attach_info, SBError& error)
 {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    
     SBProcess sb_process;
     ProcessSP process_sp;
     TargetSP target_sp(GetSP());
+    
+    if (log)
+    {
+        log->Printf ("SBTarget(%p)::Attach (sb_attach_info, error)...", target_sp.get());
+    }
+    
     if (target_sp)
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
@@ -835,6 +870,11 @@ SBTarget::Attach (SBAttachInfo &sb_attac
                     error.SetErrorString ("process attach is in progress");
                 else
                     error.SetErrorString ("a process is already being debugged");
+                if (log)
+                {
+                    log->Printf ("SBTarget(%p)::Attach (...) => error %s",
+                                 target_sp.get(), error.GetCString());
+                }
                 return sb_process;
             }            
         }
@@ -845,14 +885,28 @@ SBTarget::Attach (SBAttachInfo &sb_attac
         if (process_sp)
         {
             ProcessAttachInfo &attach_info = sb_attach_info.ref();
-            lldb::pid_t attach_pid = attach_info.GetProcessID();
-            if (attach_pid != LLDB_INVALID_PROCESS_ID)
+            if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid())
             {
                 PlatformSP platform_sp = target_sp->GetPlatform();
-                ProcessInstanceInfo instance_info;
-                if (platform_sp->GetProcessInfo(attach_pid, instance_info))
+                // See if we can pre-verify if a process exists or not
+                if (platform_sp && platform_sp->IsConnected())
                 {
-                    attach_info.SetUserID(instance_info.GetEffectiveUserID());
+                    lldb::pid_t attach_pid = attach_info.GetProcessID();
+                    ProcessInstanceInfo instance_info;
+                    if (platform_sp->GetProcessInfo(attach_pid, instance_info))
+                    {
+                        attach_info.SetUserID(instance_info.GetEffectiveUserID());
+                    }
+                    else
+                    {
+                        error.ref().SetErrorStringWithFormat("no process found with process ID %" PRIu64, attach_pid);
+                        if (log)
+                        {
+                            log->Printf ("SBTarget(%p)::Attach (...) => error %s",
+                                         target_sp.get(), error.GetCString());
+                        }
+                        return sb_process;
+                    }
                 }
             }
             error.SetError (process_sp->Attach (attach_info));
@@ -874,6 +928,13 @@ SBTarget::Attach (SBAttachInfo &sb_attac
     {
         error.SetErrorString ("SBTarget is invalid");
     }
+    
+    if (log)
+    {
+        log->Printf ("SBTarget(%p)::Attach (...) => SBProcess(%p)",
+                     target_sp.get(), process_sp.get());
+    }
+    
     return sb_process;
 }
 
@@ -898,9 +959,17 @@ SBTarget::AttachToProcessWithID
     SBError& error  // An error explaining what went wrong if attach fails
 )
 {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
     SBProcess sb_process;
     ProcessSP process_sp;
     TargetSP target_sp(GetSP());
+
+    if (log)
+    {
+        log->Printf ("SBTarget(%p)::AttachToProcessWithID (listener, pid=%" PRId64 ", error)...", target_sp.get(), pid);
+    }
+    
     if (target_sp)
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
@@ -953,10 +1022,13 @@ SBTarget::AttachToProcessWithID
                 attach_info.SetUserID(instance_info.GetEffectiveUserID());
             }
             error.SetError (process_sp->Attach (attach_info));            
-            // If we are doing synchronous mode, then wait for the
-            // process to stop!
-            if (target_sp->GetDebugger().GetAsyncExecution () == false)
+            if (error.Success())
+            {
+                // If we are doing synchronous mode, then wait for the
+                // process to stop!
+                if (target_sp->GetDebugger().GetAsyncExecution () == false)
                 process_sp->WaitForProcessToStop (NULL);
+            }
         }
         else
         {
@@ -967,8 +1039,13 @@ SBTarget::AttachToProcessWithID
     {
         error.SetErrorString ("SBTarget is invalid");
     }
+    
+    if (log)
+    {
+        log->Printf ("SBTarget(%p)::AttachToProcessWithID (...) => SBProcess(%p)",
+                     target_sp.get(), process_sp.get());
+    }
     return sb_process;
-
 }
 
 lldb::SBProcess
@@ -980,9 +1057,17 @@ SBTarget::AttachToProcessWithName
     SBError& error      // An error explaining what went wrong if attach fails
 )
 {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    
     SBProcess sb_process;
     ProcessSP process_sp;
     TargetSP target_sp(GetSP());
+    
+    if (log)
+    {
+        log->Printf ("SBTarget(%p)::AttachToProcessWithName (listener, name=%s, wait_for=%s, error)...", target_sp.get(), name, wait_for ? "true" : "false");
+    }
+    
     if (name && target_sp)
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
@@ -1029,10 +1114,13 @@ SBTarget::AttachToProcessWithName
             attach_info.GetExecutableFile().SetFile(name, false);
             attach_info.SetWaitForLaunch(wait_for);
             error.SetError (process_sp->Attach (attach_info));
-            // If we are doing synchronous mode, then wait for the
-            // process to stop!
-            if (target_sp->GetDebugger().GetAsyncExecution () == false)
-                process_sp->WaitForProcessToStop (NULL);
+            if (error.Success())
+            {
+                // If we are doing synchronous mode, then wait for the
+                // process to stop!
+                if (target_sp->GetDebugger().GetAsyncExecution () == false)
+                    process_sp->WaitForProcessToStop (NULL);
+            }
         }
         else
         {
@@ -1043,8 +1131,13 @@ SBTarget::AttachToProcessWithName
     {
         error.SetErrorString ("SBTarget is invalid");
     }
+    
+    if (log)
+    {
+        log->Printf ("SBTarget(%p)::AttachToPorcessWithName (...) => SBProcess(%p)",
+                     target_sp.get(), process_sp.get());
+    }
     return sb_process;
-
 }
 
 lldb::SBProcess
@@ -1056,9 +1149,17 @@ SBTarget::ConnectRemote
     SBError& error
 )
 {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
     SBProcess sb_process;
     ProcessSP process_sp;
     TargetSP target_sp(GetSP());
+    
+    if (log)
+    {
+        log->Printf ("SBTarget(%p)::ConnectRemote (listener, url=%s, plugin_name=%s, error)...", target_sp.get(), url, plugin_name);
+    }
+    
     if (target_sp)
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
@@ -1071,7 +1172,7 @@ SBTarget::ConnectRemote
         if (process_sp)
         {
             sb_process.SetSP (process_sp);
-            error.SetError (process_sp->ConnectRemote (url));
+            error.SetError (process_sp->ConnectRemote (NULL, url));
         }
         else
         {
@@ -1082,6 +1183,12 @@ SBTarget::ConnectRemote
     {
         error.SetErrorString ("SBTarget is invalid");
     }
+    
+    if (log)
+    {
+        log->Printf ("SBTarget(%p)::ConnectRemote (...) => SBProcess(%p)",
+                     target_sp.get(), process_sp.get());
+    }
     return sb_process;
 }
 
@@ -1098,7 +1205,7 @@ SBTarget::GetExecutable ()
             exe_file_spec.SetFileSpec (exe_module->GetFileSpec());
     }
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)", 
@@ -1174,7 +1281,7 @@ SBTarget::BreakpointCreateByLocation (co
 SBBreakpoint
 SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t line)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBBreakpoint sb_bp;
     TargetSP target_sp(GetSP());
@@ -1182,9 +1289,9 @@ SBTarget::BreakpointCreateByLocation (co
     {
         Mutex::Locker api_locker (target_sp->GetAPIMutex());
         
-        const bool check_inlines = true;
-        const bool internal = false;
+        const LazyBool check_inlines = eLazyBoolCalculate;
         const LazyBool skip_prologue = eLazyBoolCalculate;
+        const bool internal = false;
         *sb_bp = target_sp->CreateBreakpoint (NULL, *sb_file_spec, line, check_inlines, skip_prologue, internal);
     }
 
@@ -1208,7 +1315,7 @@ SBTarget::BreakpointCreateByLocation (co
 SBBreakpoint
 SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_name)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBBreakpoint sb_bp;
     TargetSP target_sp(GetSP());
@@ -1254,7 +1361,7 @@ SBTarget::BreakpointCreateByName (const
                             const SBFileSpecList &module_list, 
                             const SBFileSpecList &comp_unit_list)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBBreakpoint sb_bp;
     TargetSP target_sp(GetSP());
@@ -1287,7 +1394,7 @@ SBTarget::BreakpointCreateByNames (const
                                    const SBFileSpecList &module_list,
                                    const SBFileSpecList &comp_unit_list)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBBreakpoint sb_bp;
     TargetSP target_sp(GetSP());
@@ -1330,7 +1437,7 @@ SBTarget::BreakpointCreateByNames (const
 SBBreakpoint
 SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBBreakpoint sb_bp;
     TargetSP target_sp(GetSP());
@@ -1368,7 +1475,7 @@ SBTarget::BreakpointCreateByRegex (const
                          const SBFileSpecList &module_list, 
                          const SBFileSpecList &comp_unit_list)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBBreakpoint sb_bp;
     TargetSP target_sp(GetSP());
@@ -1394,7 +1501,7 @@ SBTarget::BreakpointCreateByRegex (const
 SBBreakpoint
 SBTarget::BreakpointCreateByAddress (addr_t address)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBBreakpoint sb_bp;
     TargetSP target_sp(GetSP());
@@ -1406,7 +1513,7 @@ SBTarget::BreakpointCreateByAddress (add
     
     if (log)
     {
-        log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%llu) => SBBreakpoint(%p)", target_sp.get(), (uint64_t) address, sb_bp.get());
+        log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%" PRIu64 ") => SBBreakpoint(%p)", target_sp.get(), (uint64_t) address, sb_bp.get());
     }
 
     return sb_bp;
@@ -1415,7 +1522,7 @@ SBTarget::BreakpointCreateByAddress (add
 lldb::SBBreakpoint
 SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBBreakpoint sb_bp;
     TargetSP target_sp(GetSP());
@@ -1455,7 +1562,7 @@ SBTarget::BreakpointCreateBySourceRegex
                                const SBFileSpecList &module_list, 
                                const lldb::SBFileSpecList &source_file_list)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBBreakpoint sb_bp;
     TargetSP target_sp(GetSP());
@@ -1480,7 +1587,7 @@ SBTarget::BreakpointCreateForException
                                bool catch_bp,
                                bool throw_bp)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBBreakpoint sb_bp;
     TargetSP target_sp(GetSP());
@@ -1531,7 +1638,7 @@ SBTarget::GetBreakpointAtIndex (uint32_t
 bool
 SBTarget::BreakpointDelete (break_id_t bp_id)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     bool result = false;
     TargetSP target_sp(GetSP());
@@ -1552,7 +1659,7 @@ SBTarget::BreakpointDelete (break_id_t b
 SBBreakpoint
 SBTarget::FindBreakpointByID (break_id_t bp_id)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBBreakpoint sb_breakpoint;
     TargetSP target_sp(GetSP());
@@ -1638,7 +1745,7 @@ SBTarget::GetWatchpointAtIndex (uint32_t
 bool
 SBTarget::DeleteWatchpoint (watch_id_t wp_id)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     bool result = false;
     TargetSP target_sp(GetSP());
@@ -1661,7 +1768,7 @@ SBTarget::DeleteWatchpoint (watch_id_t w
 SBWatchpoint
 SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBWatchpoint sb_watchpoint;
     lldb::WatchpointSP watchpoint_sp;
@@ -1687,7 +1794,7 @@ SBTarget::FindWatchpointByID (lldb::watc
 lldb::SBWatchpoint
 SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, SBError &error)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     
     SBWatchpoint sb_watchpoint;
     lldb::WatchpointSP watchpoint_sp;
@@ -1702,14 +1809,16 @@ SBTarget::WatchAddress (lldb::addr_t add
             watch_type |= LLDB_WATCH_TYPE_WRITE;
         // Target::CreateWatchpoint() is thread safe.
         Error cw_error;
-        watchpoint_sp = target_sp->CreateWatchpoint(addr, size, watch_type, cw_error);
+        // This API doesn't take in a type, so we can't figure out what it is.
+        ClangASTType *type = NULL;
+        watchpoint_sp = target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
         error.SetError(cw_error);
         sb_watchpoint.SetSP (watchpoint_sp);
     }
     
     if (log)
     {
-        log->Printf ("SBTarget(%p)::WatchAddress (addr=0x%llx, 0x%u) => SBWatchpoint(%p)", 
+        log->Printf ("SBTarget(%p)::WatchAddress (addr=0x%" PRIx64 ", 0x%u) => SBWatchpoint(%p)",
                      target_sp.get(), addr, (uint32_t) size, watchpoint_sp.get());
     }
     
@@ -1785,7 +1894,7 @@ SBTarget::AddModule (const char *path,
             module_spec.GetFileSpec().SetFile(path, false);
         
         if (uuid_cstr)
-            module_spec.GetUUID().SetfromCString(uuid_cstr);
+            module_spec.GetUUID().SetFromCString(uuid_cstr);
         
         if (triple)
             module_spec.GetArchitecture().SetTriple (triple, target_sp->GetPlatform ().get());
@@ -1813,7 +1922,7 @@ SBTarget::AddModule (lldb::SBModule &mod
 uint32_t
 SBTarget::GetNumModules () const
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     uint32_t num = 0;
     TargetSP target_sp(GetSP());
@@ -1832,7 +1941,7 @@ SBTarget::GetNumModules () const
 void
 SBTarget::Clear ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     if (log)
         log->Printf ("SBTarget(%p)::Clear ()", m_opaque_sp.get());
@@ -1893,7 +2002,7 @@ SBTarget::GetAddressByteSize()
 SBModule
 SBTarget::GetModuleAtIndex (uint32_t idx)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBModule sb_module;
     ModuleSP module_sp;
@@ -1927,7 +2036,7 @@ SBTarget::RemoveModule (lldb::SBModule m
 SBBroadcaster
 SBTarget::GetBroadcaster () const
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     TargetSP target_sp(GetSP());
     SBBroadcaster broadcaster(target_sp.get(), false);
@@ -1979,52 +2088,138 @@ SBTarget::FindFunctions (const char *nam
 }
 
 lldb::SBType
-SBTarget::FindFirstType (const char* type)
+SBTarget::FindFirstType (const char* typename_cstr)
 {
     TargetSP target_sp(GetSP());
-    if (type && target_sp)
+    if (typename_cstr && typename_cstr[0] && target_sp)
     {
-        size_t count = target_sp->GetImages().GetSize();
+        ConstString const_typename(typename_cstr);
+        SymbolContext sc;
+        const bool exact_match = false;
+
+        const ModuleList &module_list = target_sp->GetImages();
+        size_t count = module_list.GetSize();
         for (size_t idx = 0; idx < count; idx++)
         {
-            SBType found_at_idx = GetModuleAtIndex(idx).FindFirstType(type);
+            ModuleSP module_sp (module_list.GetModuleAtIndex(idx));
+            if (module_sp)
+            {
+                TypeSP type_sp (module_sp->FindFirstType(sc, const_typename, exact_match));
+                if (type_sp)
+                    return SBType(type_sp);
+            }
+        }
+        
+        // Didn't find the type in the symbols; try the Objective-C runtime
+        // if one is installed
+        
+        ProcessSP process_sp(target_sp->GetProcessSP());
+        
+        if (process_sp)
+        {
+            ObjCLanguageRuntime *objc_language_runtime = process_sp->GetObjCLanguageRuntime();
             
-            if (found_at_idx.IsValid())
-                return found_at_idx;
+            if (objc_language_runtime)
+            {
+                TypeVendor *objc_type_vendor = objc_language_runtime->GetTypeVendor();
+                
+                if (objc_type_vendor)
+                {
+                    std::vector <ClangASTType> types;
+                    
+                    if (objc_type_vendor->FindTypes(const_typename, true, 1, types) > 0)
+                        return SBType(types[0]);
+                }
+            }
         }
+
+        // No matches, search for basic typename matches
+        ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
+        if (clang_ast)
+            return SBType (ClangASTType::GetBasicType (clang_ast->getASTContext(), const_typename));
     }
     return SBType();
 }
 
+SBType
+SBTarget::GetBasicType(lldb::BasicType type)
+{
+    TargetSP target_sp(GetSP());
+    if (target_sp)
+    {
+        ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
+        if (clang_ast)
+            return SBType (ClangASTType::GetBasicType (clang_ast->getASTContext(), type));
+    }
+    return SBType();
+}
+
+
 lldb::SBTypeList
-SBTarget::FindTypes (const char* type)
+SBTarget::FindTypes (const char* typename_cstr)
 {
-    
-    SBTypeList retval;
-    
+    SBTypeList sb_type_list;
     TargetSP target_sp(GetSP());
-    if (type && target_sp)
+    if (typename_cstr && typename_cstr[0] && target_sp)
     {
         ModuleList& images = target_sp->GetImages();
-        ConstString name_const(type);
+        ConstString const_typename(typename_cstr);
         bool exact_match = false;
         SymbolContext sc;
         TypeList type_list;
         
         uint32_t num_matches = images.FindTypes (sc,
-                                                 name_const,
+                                                 const_typename,
                                                  exact_match,
                                                  UINT32_MAX,
                                                  type_list);
         
-        for (size_t idx = 0; idx < num_matches; idx++)
+        if (num_matches > 0)
+        {
+            for (size_t idx = 0; idx < num_matches; idx++)
+            {
+                TypeSP type_sp (type_list.GetTypeAtIndex(idx));
+                if (type_sp)
+                    sb_type_list.Append(SBType(type_sp));
+            }
+        }
+        
+        // Try the Objective-C runtime if one is installed
+        
+        ProcessSP process_sp(target_sp->GetProcessSP());
+        
+        if (process_sp)
+        {
+            ObjCLanguageRuntime *objc_language_runtime = process_sp->GetObjCLanguageRuntime();
+            
+            if (objc_language_runtime)
+            {
+                TypeVendor *objc_type_vendor = objc_language_runtime->GetTypeVendor();
+                
+                if (objc_type_vendor)
+                {
+                    std::vector <ClangASTType> types;
+                    
+                    if (objc_type_vendor->FindTypes(const_typename, true, UINT32_MAX, types))
+                    {
+                        for (ClangASTType &type : types)
+                        {
+                            sb_type_list.Append(SBType(type));
+                        }
+                    }
+                }
+            }
+        }
+        
+        if (sb_type_list.GetSize() == 0)
         {
-            TypeSP type_sp (type_list.GetTypeAtIndex(idx));
-            if (type_sp)
-                retval.Append(SBType(type_sp));
+            // No matches, search for basic typename matches
+            ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
+            if (clang_ast)
+                sb_type_list.Append (SBType (ClangASTType::GetBasicType (clang_ast->getASTContext(), const_typename)));
         }
     }
-    return retval;
+    return sb_type_list;
 }
 
 SBValueList
@@ -2047,12 +2242,11 @@ SBTarget::FindGlobalVariables (const cha
             ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
             if (exe_scope == NULL)
                 exe_scope = target_sp.get();
-            ValueObjectList &value_object_list = sb_value_list.ref();
             for (uint32_t i=0; i<match_count; ++i)
             {
                 lldb::ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_scope, variable_list.GetVariableAtIndex(i)));
                 if (valobj_sp)
-                    value_object_list.Append(valobj_sp);
+                    sb_value_list.Append(SBValue(valobj_sp));
             }
         }
     }
@@ -2060,6 +2254,15 @@ SBTarget::FindGlobalVariables (const cha
     return sb_value_list;
 }
 
+lldb::SBValue
+SBTarget::FindFirstGlobalVariable (const char* name)
+{
+    SBValueList sb_value_list(FindGlobalVariables(name, 1));
+    if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
+        return sb_value_list.GetValueAtIndex(0);
+    return SBValue();
+}
+
 SBSourceManager
 SBTarget::GetSourceManager()
 {
@@ -2070,6 +2273,12 @@ SBTarget::GetSourceManager()
 lldb::SBInstructionList
 SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count)
 {
+    return ReadInstructions (base_addr, count, NULL);
+}
+
+lldb::SBInstructionList
+SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string)
+{
     SBInstructionList sb_instructions;
     
     TargetSP target_sp(GetSP());
@@ -2082,13 +2291,22 @@ SBTarget::ReadInstructions (lldb::SBAddr
             DataBufferHeap data (target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0);
             bool prefer_file_cache = false;
             lldb_private::Error error;
-            const size_t bytes_read = target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(), data.GetByteSize(), error);
+            lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
+            const size_t bytes_read = target_sp->ReadMemory(*addr_ptr,
+                                                            prefer_file_cache,
+                                                            data.GetBytes(),
+                                                            data.GetByteSize(),
+                                                            error,
+                                                            &load_addr);
+            const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
             sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
                                                                              NULL,
+                                                                             flavor_string,
                                                                              *addr_ptr,
                                                                              data.GetBytes(),
                                                                              bytes_read,
-                                                                             count));
+                                                                             count,
+                                                                             data_from_file));
         }
     }
     
@@ -2099,6 +2317,12 @@ SBTarget::ReadInstructions (lldb::SBAddr
 lldb::SBInstructionList
 SBTarget::GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size)
 {
+    return GetInstructionsWithFlavor (base_addr, NULL, buf, size);
+}
+
+lldb::SBInstructionList
+SBTarget::GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size)
+{
     SBInstructionList sb_instructions;
     
     TargetSP target_sp(GetSP());
@@ -2109,11 +2333,16 @@ SBTarget::GetInstructions (lldb::SBAddre
         if (base_addr.get())
             addr = *base_addr.get();
         
+        const bool data_from_file = true;
+
         sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
                                                                          NULL,
+                                                                         flavor_string,
                                                                          addr,
                                                                          buf,
-                                                                         size));
+                                                                         size,
+                                                                         UINT32_MAX,
+                                                                         data_from_file));
     }
 
     return sb_instructions;
@@ -2122,7 +2351,13 @@ SBTarget::GetInstructions (lldb::SBAddre
 lldb::SBInstructionList
 SBTarget::GetInstructions (lldb::addr_t base_addr, const void *buf, size_t size)
 {
-    return GetInstructions (ResolveLoadAddress(base_addr), buf, size);
+    return GetInstructionsWithFlavor (ResolveLoadAddress(base_addr), NULL, buf, size);
+}
+
+lldb::SBInstructionList
+SBTarget::GetInstructionsWithFlavor (lldb::addr_t base_addr, const char *flavor_string, const void *buf, size_t size)
+{
+    return GetInstructionsWithFlavor (ResolveLoadAddress(base_addr), flavor_string, buf, size);
 }
 
 SBError
@@ -2148,7 +2383,13 @@ SBTarget::SetSectionLoadAddress (lldb::S
                 }
                 else
                 {
-                    target_sp->GetSectionLoadList().SetSectionLoadAddress (section_sp, section_base_addr);
+                    if (target_sp->GetSectionLoadList().SetSectionLoadAddress (section_sp, section_base_addr))
+                    {
+                        // Flush info in the process (stack frames, etc)
+                        ProcessSP process_sp (target_sp->GetProcessSP());
+                        if (process_sp)
+                            process_sp->Flush();
+                    }
                 }
             }
         }
@@ -2174,7 +2415,13 @@ SBTarget::ClearSectionLoadAddress (lldb:
         }
         else
         {
-            target_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSP());
+            if (target_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSP()))
+            {
+                // Flush info in the process (stack frames, etc)
+                ProcessSP process_sp (target_sp->GetProcessSP());
+                if (process_sp)
+                    process_sp->Flush();                
+            }
         }
     }
     else
@@ -2205,6 +2452,10 @@ SBTarget::SetModuleLoadAddress (lldb::SB
                     ModuleList module_list;
                     module_list.Append(module_sp);
                     target_sp->ModulesDidLoad (module_list);
+                    // Flush info in the process (stack frames, etc)
+                    ProcessSP process_sp (target_sp->GetProcessSP());
+                    if (process_sp)
+                        process_sp->Flush();
                 }
             }
         }
@@ -2239,12 +2490,20 @@ SBTarget::ClearModuleLoadAddress (lldb::
                 SectionList *section_list = objfile->GetSectionList();
                 if (section_list)
                 {
+                    bool changed = false;
                     const size_t num_sections = section_list->GetSize();
                     for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx)
                     {
                         SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx));
                         if (section_sp)
-                            target_sp->GetSectionLoadList().SetSectionUnloaded (section_sp);
+                            changed |= target_sp->GetSectionLoadList().SetSectionUnloaded (section_sp) > 0;
+                    }
+                    if (changed)
+                    {
+                        // Flush info in the process (stack frames, etc)
+                        ProcessSP process_sp (target_sp->GetProcessSP());
+                        if (process_sp)
+                            process_sp->Flush();                        
                     }
                 }
                 else
@@ -2272,3 +2531,113 @@ SBTarget::ClearModuleLoadAddress (lldb::
 }
 
 
+lldb::SBSymbolContextList
+SBTarget::FindSymbols (const char *name, lldb::SymbolType symbol_type)
+{
+    SBSymbolContextList sb_sc_list;
+    if (name && name[0])
+    {
+        TargetSP target_sp(GetSP());
+        if (target_sp)
+        {
+            bool append = true;
+            target_sp->GetImages().FindSymbolsWithNameAndType (ConstString(name),
+                                                               symbol_type,
+                                                               *sb_sc_list,
+                                                               append);
+        }
+    }
+    return sb_sc_list;
+    
+}
+
+
+lldb::SBValue
+SBTarget::EvaluateExpression (const char *expr, const SBExpressionOptions &options)
+{
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log * expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    SBValue expr_result;
+    ExecutionResults exe_results = eExecutionSetupError;
+    ValueObjectSP expr_value_sp;
+    TargetSP target_sp(GetSP());
+    StackFrame *frame = NULL;
+    if (target_sp)
+    {
+        if (expr == NULL || expr[0] == '\0')
+        {
+            if (log)
+                log->Printf ("SBTarget::EvaluateExpression called with an empty expression");
+            return expr_result;
+        }
+        
+        Mutex::Locker api_locker (target_sp->GetAPIMutex());
+        ExecutionContext exe_ctx (m_opaque_sp.get());
+        
+        if (log)
+            log->Printf ("SBTarget()::EvaluateExpression (expr=\"%s\")...", expr);
+        
+        frame = exe_ctx.GetFramePtr();
+        Target *target = exe_ctx.GetTargetPtr();
+        
+        if (target)
+        {
+#ifdef LLDB_CONFIGURATION_DEBUG
+            StreamString frame_description;
+            if (frame)
+                frame->DumpUsingSettingsFormat (&frame_description);
+            Host::SetCrashDescriptionWithFormat ("SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s",
+                                                 expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str());
+#endif
+            exe_results = target->EvaluateExpression (expr,
+                                                      frame,
+                                                      expr_value_sp,
+                                                      options.ref());
+
+            expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
+#ifdef LLDB_CONFIGURATION_DEBUG
+            Host::SetCrashDescription (NULL);
+#endif
+        }
+        else
+        {
+            if (log)
+                log->Printf ("SBTarget::EvaluateExpression () => error: could not reconstruct frame object for this SBTarget.");
+        }
+    }
+#ifndef LLDB_DISABLE_PYTHON
+    if (expr_log)
+        expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is %s, summary %s **",
+                         expr_result.GetValue(),
+                         expr_result.GetSummary());
+    
+    if (log)
+        log->Printf ("SBTarget(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)",
+                     frame,
+                     expr,
+                     expr_value_sp.get(),
+                     exe_results);
+#endif
+    
+    return expr_result;
+}
+
+
+lldb::addr_t
+SBTarget::GetStackRedZoneSize()
+{
+    TargetSP target_sp(GetSP());
+    if (target_sp)
+    {
+        ABISP abi_sp;
+        ProcessSP process_sp (target_sp->GetProcessSP());
+        if (process_sp)
+            abi_sp = process_sp->GetABI();
+        else
+            abi_sp = ABI::FindPlugin(target_sp->GetArchitecture());
+        if (abi_sp)
+            return abi_sp->GetRedZoneSize();
+    }
+    return 0;
+}
+

Modified: lldb/branches/lldb-platform-work/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBThread.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBThread.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBThread.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/API/SBThread.h"
 
 #include "lldb/API/SBSymbolContext.h"
@@ -14,6 +16,7 @@
 #include "lldb/API/SBStream.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Debugger.h"
+#include "lldb/Core/State.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
@@ -32,6 +35,7 @@
 
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBEvent.h"
 #include "lldb/API/SBFrame.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBValue.h"
@@ -39,6 +43,12 @@
 using namespace lldb;
 using namespace lldb_private;
 
+const char *
+SBThread::GetBroadcasterClassName ()
+{
+    return Thread::GetStaticBroadcasterClass().AsCString();
+}
+
 //----------------------------------------------------------------------
 // Constructors
 //----------------------------------------------------------------------
@@ -93,19 +103,18 @@ SBThread::Clear ()
 StopReason
 SBThread::GetStopReason()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     StopReason reason = eStopReasonInvalid;
-    ExecutionContext exe_ctx (m_opaque_sp.get());
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
     if (exe_ctx.HasThreadScope())
     {
         Process::StopLocker stop_locker;
         if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
         {
-            Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
-            StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo ();
-            if (stop_info_sp)
-                reason =  stop_info_sp->GetStopReason();
+            return exe_ctx.GetThreadPtr()->GetStopReason();
         }
         else
         {
@@ -124,13 +133,14 @@ SBThread::GetStopReason()
 size_t
 SBThread::GetStopReasonDataCount ()
 {
-    ExecutionContext exe_ctx (m_opaque_sp.get());
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
     if (exe_ctx.HasThreadScope())
     {
         Process::StopLocker stop_locker;
         if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
         {
-            Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
             StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo ();
             if (stop_info_sp)
             {
@@ -140,7 +150,9 @@ SBThread::GetStopReasonDataCount ()
                 case eStopReasonInvalid:
                 case eStopReasonNone:
                 case eStopReasonTrace:
+                case eStopReasonExec:
                 case eStopReasonPlanComplete:
+                case eStopReasonThreadExiting:
                     // There is no data for these stop reasons.
                     return 0;
 
@@ -168,7 +180,7 @@ SBThread::GetStopReasonDataCount ()
         }
         else
         {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+            Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
             if (log)
                 log->Printf ("SBThread(%p)::GetStopReasonDataCount() => error: process is running", exe_ctx.GetThreadPtr());
         }
@@ -179,14 +191,14 @@ SBThread::GetStopReasonDataCount ()
 uint64_t
 SBThread::GetStopReasonDataAtIndex (uint32_t idx)
 {
-    ExecutionContext exe_ctx (m_opaque_sp.get());
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
     if (exe_ctx.HasThreadScope())
     {
         Process::StopLocker stop_locker;
         if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
         {
-
-            Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
             Thread *thread = exe_ctx.GetThreadPtr();
             StopInfoSP stop_info_sp = thread->GetStopInfo ();
             if (stop_info_sp)
@@ -197,7 +209,9 @@ SBThread::GetStopReasonDataAtIndex (uint
                 case eStopReasonInvalid:
                 case eStopReasonNone:
                 case eStopReasonTrace:
+                case eStopReasonExec:
                 case eStopReasonPlanComplete:
+                case eStopReasonThreadExiting:
                     // There is no data for these stop reasons.
                     return 0;
 
@@ -240,7 +254,7 @@ SBThread::GetStopReasonDataAtIndex (uint
         }
         else
         {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+            Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
             if (log)
                 log->Printf ("SBThread(%p)::GetStopReasonDataAtIndex() => error: process is running", exe_ctx.GetThreadPtr());
         }
@@ -251,16 +265,17 @@ SBThread::GetStopReasonDataAtIndex (uint
 size_t
 SBThread::GetStopDescription (char *dst, size_t dst_len)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
 
-    ExecutionContext exe_ctx (m_opaque_sp.get());
     if (exe_ctx.HasThreadScope())
     {
         Process::StopLocker stop_locker;
         if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
         {
 
-            Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
             StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo ();
             if (stop_info_sp)
             {
@@ -328,6 +343,21 @@ SBThread::GetStopDescription (char *dst,
                         }
                         break;          
 
+                    case eStopReasonExec:
+                        {
+                            char exc_desc[] = "exec";
+                            stop_desc = exc_desc;
+                            stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
+                        }
+                        break;
+
+                    case eStopReasonThreadExiting:
+                        {
+                            char limbo_desc[] = "thread exiting";
+                            stop_desc = limbo_desc;
+                            stop_desc_len = sizeof(limbo_desc);
+                        }
+                        break;
                     default:
                         break;
                     }
@@ -351,7 +381,7 @@ SBThread::GetStopDescription (char *dst,
         }
         else
         {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+            Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
             if (log)
                 log->Printf ("SBThread(%p)::GetStopDescription() => error: process is running", exe_ctx.GetThreadPtr());
         }
@@ -364,15 +394,16 @@ SBThread::GetStopDescription (char *dst,
 SBValue
 SBThread::GetStopReturnValue ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     ValueObjectSP return_valobj_sp;
-    ExecutionContext exe_ctx (m_opaque_sp.get());
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
     if (exe_ctx.HasThreadScope())
     {
         Process::StopLocker stop_locker;
         if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
         {
-            Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
             StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo ();
             if (stop_info_sp)
             {
@@ -423,15 +454,16 @@ SBThread::GetIndexID () const
 const char *
 SBThread::GetName () const
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     const char *name = NULL;
-    ExecutionContext exe_ctx (m_opaque_sp.get());
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
     if (exe_ctx.HasThreadScope())
     {
         Process::StopLocker stop_locker;
         if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
         {
-            Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
             name = exe_ctx.GetThreadPtr()->GetName();
         }
         else
@@ -451,14 +483,15 @@ const char *
 SBThread::GetQueueName () const
 {
     const char *name = NULL;
-    ExecutionContext exe_ctx (m_opaque_sp.get());
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (exe_ctx.HasThreadScope())
     {
         Process::StopLocker stop_locker;
         if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
         {
-            Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
             name = exe_ctx.GetThreadPtr()->GetQueueName();
         }
         else
@@ -519,9 +552,11 @@ SBThread::ResumeNewPlan (ExecutionContex
 void
 SBThread::StepOver (lldb::RunMode stop_other_threads)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
 
-    ExecutionContext exe_ctx (m_opaque_sp.get());
 
     if (log)
         log->Printf ("SBThread(%p)::StepOver (stop_other_threads='%s')", exe_ctx.GetThreadPtr(), 
@@ -529,7 +564,6 @@ SBThread::StepOver (lldb::RunMode stop_o
     
     if (exe_ctx.HasThreadScope())
     {
-        Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
         Thread *thread = exe_ctx.GetThreadPtr();
         bool abort_other_plans = false;
         StackFrameSP frame_sp(thread->GetStackFrameAtIndex (0));
@@ -540,13 +574,10 @@ SBThread::StepOver (lldb::RunMode stop_o
             if (frame_sp->HasDebugInformation ())
             {
                 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
-                new_plan = thread->QueueThreadPlanForStepRange (abort_other_plans,
-                                                                eStepTypeOver,
-                                                                sc.line_entry.range,
-                                                                sc,
-                                                                stop_other_threads,
-                                                                false);
-                
+                new_plan = thread->QueueThreadPlanForStepOverRange (abort_other_plans,
+                                                                    sc.line_entry.range,
+                                                                    sc,
+                                                                    stop_other_threads);
             }
             else
             {
@@ -564,16 +595,25 @@ SBThread::StepOver (lldb::RunMode stop_o
 void
 SBThread::StepInto (lldb::RunMode stop_other_threads)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    StepInto (NULL, stop_other_threads);
+}
 
-    ExecutionContext exe_ctx (m_opaque_sp.get());
+void
+SBThread::StepInto (const char *target_name, lldb::RunMode stop_other_threads)
+{
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
 
     if (log)
-        log->Printf ("SBThread(%p)::StepInto (stop_other_threads='%s')", exe_ctx.GetThreadPtr(),
+        log->Printf ("SBThread(%p)::StepInto (target_name='%s', stop_other_threads='%s')",
+                     exe_ctx.GetThreadPtr(),
+                     target_name? target_name: "<NULL>",
                      Thread::RunModeAsCString (stop_other_threads));
+    
     if (exe_ctx.HasThreadScope())
     {
-        Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
         bool abort_other_plans = false;
 
         Thread *thread = exe_ctx.GetThreadPtr();
@@ -584,12 +624,12 @@ SBThread::StepInto (lldb::RunMode stop_o
         {
             bool avoid_code_without_debug_info = true;
             SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
-            new_plan = thread->QueueThreadPlanForStepRange (abort_other_plans,
-                                                            eStepTypeInto,
-                                                            sc.line_entry.range,
-                                                            sc,
-                                                            stop_other_threads,
-                                                            avoid_code_without_debug_info);
+            new_plan = thread->QueueThreadPlanForStepInRange (abort_other_plans,
+                                                              sc.line_entry.range,
+                                                              sc,
+                                                              target_name,
+                                                              stop_other_threads,
+                                                              avoid_code_without_debug_info);
         }
         else
         {
@@ -606,18 +646,19 @@ SBThread::StepInto (lldb::RunMode stop_o
 void
 SBThread::StepOut ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
 
-    ExecutionContext exe_ctx (m_opaque_sp.get());
 
     if (log)
         log->Printf ("SBThread(%p)::StepOut ()", exe_ctx.GetThreadPtr());
     
     if (exe_ctx.HasThreadScope())
     {
-        Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
         bool abort_other_plans = false;
-        bool stop_other_threads = true;
+        bool stop_other_threads = false;
 
         Thread *thread = exe_ctx.GetThreadPtr();
 
@@ -637,9 +678,11 @@ SBThread::StepOut ()
 void
 SBThread::StepOutOfFrame (lldb::SBFrame &sb_frame)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
 
-    ExecutionContext exe_ctx (m_opaque_sp.get());
     StackFrameSP frame_sp (sb_frame.GetFrameSP());
     if (log)
     {
@@ -650,9 +693,8 @@ SBThread::StepOutOfFrame (lldb::SBFrame
 
     if (exe_ctx.HasThreadScope())
     {
-        Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
         bool abort_other_plans = false;
-        bool stop_other_threads = true;
+        bool stop_other_threads = false;
         Thread *thread = exe_ctx.GetThreadPtr();
 
         ThreadPlan *new_plan = thread->QueueThreadPlanForStepOut (abort_other_plans,
@@ -671,9 +713,11 @@ SBThread::StepOutOfFrame (lldb::SBFrame
 void
 SBThread::StepInstruction (bool step_over)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
 
-    ExecutionContext exe_ctx (m_opaque_sp.get());
 
 
     if (log)
@@ -681,7 +725,6 @@ SBThread::StepInstruction (bool step_ove
     
     if (exe_ctx.HasThreadScope())
     {
-        Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
         Thread *thread = exe_ctx.GetThreadPtr();
         ThreadPlan *new_plan = thread->QueueThreadPlanForStepSingleInstruction (step_over, true, true);
         
@@ -693,16 +736,17 @@ SBThread::StepInstruction (bool step_ove
 void
 SBThread::RunToAddress (lldb::addr_t addr)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
 
-    ExecutionContext exe_ctx (m_opaque_sp.get());
 
     if (log)
-        log->Printf ("SBThread(%p)::RunToAddress (addr=0x%llx)", exe_ctx.GetThreadPtr(), addr);
+        log->Printf ("SBThread(%p)::RunToAddress (addr=0x%" PRIx64 ")", exe_ctx.GetThreadPtr(), addr);
     
     if (exe_ctx.HasThreadScope())
     {
-        Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
         bool abort_other_plans = false;
         bool stop_other_threads = true;
 
@@ -723,10 +767,12 @@ SBThread::StepOverUntil (lldb::SBFrame &
                          uint32_t line)
 {
     SBError sb_error;
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     char path[PATH_MAX];
     
-    ExecutionContext exe_ctx (m_opaque_sp.get());
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
     StackFrameSP frame_sp (sb_frame.GetFrameSP());
 
     if (log)
@@ -744,7 +790,6 @@ SBThread::StepOverUntil (lldb::SBFrame &
     if (exe_ctx.HasThreadScope())
     {
         Target *target = exe_ctx.GetTargetPtr();
-        Mutex::Locker api_locker (target->GetAPIMutex());
         Thread *thread = exe_ctx.GetThreadPtr();
 
         if (line == 0)
@@ -753,7 +798,6 @@ SBThread::StepOverUntil (lldb::SBFrame &
             return sb_error;
         }
         
-        StackFrameSP frame_sp;
         if (!frame_sp)
         {
             frame_sp = thread->GetSelectedFrame ();
@@ -807,7 +851,7 @@ SBThread::StepOverUntil (lldb::SBFrame &
         
         std::vector<addr_t> step_over_until_addrs;
         const bool abort_other_plans = false;
-        const bool stop_other_threads = true;
+        const bool stop_other_threads = false;
         const bool check_inlines = true;
         const bool exact = false;
 
@@ -865,11 +909,34 @@ SBThread::StepOverUntil (lldb::SBFrame &
     return sb_error;
 }
 
+SBError
+SBThread::ReturnFromFrame (SBFrame &frame, SBValue &return_value)
+{
+    SBError sb_error;
+    
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
+
+    if (log)
+        log->Printf ("SBThread(%p)::ReturnFromFrame (frame=%d)", exe_ctx.GetThreadPtr(), frame.GetFrameID());
+    
+    if (exe_ctx.HasThreadScope())
+    {
+        Thread *thread = exe_ctx.GetThreadPtr();
+        sb_error.SetError (thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP()));
+    }
+    
+    return sb_error;
+}
+
 
 bool
 SBThread::Suspend()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     ExecutionContext exe_ctx (m_opaque_sp.get());
     bool result = false;
     if (exe_ctx.HasThreadScope())
@@ -894,7 +961,7 @@ SBThread::Suspend()
 bool
 SBThread::Resume ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     ExecutionContext exe_ctx (m_opaque_sp.get());
     bool result = false;
     if (exe_ctx.HasThreadScope())
@@ -925,12 +992,19 @@ SBThread::IsSuspended()
     return false;
 }
 
+bool
+SBThread::IsStopped()
+{
+    ExecutionContext exe_ctx (m_opaque_sp.get());
+    if (exe_ctx.HasThreadScope())
+        return StateIsStoppedState(exe_ctx.GetThreadPtr()->GetState(), true);
+    return false;
+}
+
 SBProcess
 SBThread::GetProcess ()
 {
-
     SBProcess sb_process;
-    ProcessSP process_sp;
     ExecutionContext exe_ctx (m_opaque_sp.get());
     if (exe_ctx.HasThreadScope())
     {
@@ -938,13 +1012,13 @@ SBThread::GetProcess ()
         sb_process.SetSP (exe_ctx.GetProcessSP());
     }
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         SBStream frame_desc_strm;
         sb_process.GetDescription (frame_desc_strm);
         log->Printf ("SBThread(%p)::GetProcess () => SBProcess(%p): %s", exe_ctx.GetThreadPtr(),
-                     process_sp.get(), frame_desc_strm.GetData());
+                     sb_process.GetSP().get(), frame_desc_strm.GetData());
     }
 
     return sb_process;
@@ -953,16 +1027,17 @@ SBThread::GetProcess ()
 uint32_t
 SBThread::GetNumFrames ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     uint32_t num_frames = 0;
-    ExecutionContext exe_ctx (m_opaque_sp.get());
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
     if (exe_ctx.HasThreadScope())
     {
         Process::StopLocker stop_locker;
         if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
         {
-            Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
             num_frames = exe_ctx.GetThreadPtr()->GetStackFrameCount();
         }
         else
@@ -981,17 +1056,18 @@ SBThread::GetNumFrames ()
 SBFrame
 SBThread::GetFrameAtIndex (uint32_t idx)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBFrame sb_frame;
     StackFrameSP frame_sp;
-    ExecutionContext exe_ctx (m_opaque_sp.get());
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
     if (exe_ctx.HasThreadScope())
     {
         Process::StopLocker stop_locker;
         if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
         {
-            Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
             frame_sp = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex (idx);
             sb_frame.SetFrameSP (frame_sp);
         }
@@ -1016,17 +1092,18 @@ SBThread::GetFrameAtIndex (uint32_t idx)
 lldb::SBFrame
 SBThread::GetSelectedFrame ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBFrame sb_frame;
     StackFrameSP frame_sp;
-    ExecutionContext exe_ctx (m_opaque_sp.get());
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
     if (exe_ctx.HasThreadScope())
     {
         Process::StopLocker stop_locker;
         if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
         {
-            Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
             frame_sp = exe_ctx.GetThreadPtr()->GetSelectedFrame ();
             sb_frame.SetFrameSP (frame_sp);
         }
@@ -1051,17 +1128,18 @@ SBThread::GetSelectedFrame ()
 lldb::SBFrame
 SBThread::SetSelectedFrame (uint32_t idx)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBFrame sb_frame;
     StackFrameSP frame_sp;
-    ExecutionContext exe_ctx (m_opaque_sp.get());
+    Mutex::Locker api_locker;
+    ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
+
     if (exe_ctx.HasThreadScope())
     {
         Process::StopLocker stop_locker;
         if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
         {
-            Mutex::Locker api_locker (exe_ctx.GetTargetPtr()->GetAPIMutex());
             Thread *thread = exe_ctx.GetThreadPtr();
             frame_sp = thread->GetStackFrameAtIndex (idx);
             if (frame_sp)
@@ -1087,6 +1165,24 @@ SBThread::SetSelectedFrame (uint32_t idx
     return sb_frame;
 }
 
+bool
+SBThread::EventIsThreadEvent (const SBEvent &event)
+{
+    return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != NULL;
+}
+
+SBFrame
+SBThread::GetStackFrameFromEvent (const SBEvent &event)
+{
+    return Thread::ThreadEventData::GetStackFrameFromEvent (event.get());
+
+}
+
+SBThread
+SBThread::GetThreadFromEvent (const SBEvent &event)
+{
+    return Thread::ThreadEventData::GetThreadFromEvent (event.get());
+}
 
 bool
 SBThread::operator == (const SBThread &rhs) const
@@ -1101,6 +1197,22 @@ SBThread::operator != (const SBThread &r
 }
 
 bool
+SBThread::GetStatus (SBStream &status) const
+{
+    Stream &strm = status.ref();
+
+    ExecutionContext exe_ctx (m_opaque_sp.get());
+    if (exe_ctx.HasThreadScope())
+    {
+        exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1);
+    }
+    else
+        strm.PutCString ("No status");
+    
+    return true;
+}
+
+bool
 SBThread::GetDescription (SBStream &description) const
 {
     Stream &strm = description.ref();
@@ -1108,7 +1220,7 @@ SBThread::GetDescription (SBStream &desc
     ExecutionContext exe_ctx (m_opaque_sp.get());
     if (exe_ctx.HasThreadScope())
     {
-        strm.Printf("SBThread: tid = 0x%4.4llx", exe_ctx.GetThreadPtr()->GetID());
+        strm.Printf("SBThread: tid = 0x%4.4" PRIx64, exe_ctx.GetThreadPtr()->GetID());
     }
     else
         strm.PutCString ("No value");

Modified: lldb/branches/lldb-platform-work/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBType.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBType.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBType.cpp Thu Jun  6 19:06:43 2013
@@ -136,7 +136,7 @@ SBType::IsValid() const
     return m_opaque_sp->IsValid();
 }
 
-size_t
+uint64_t
 SBType::GetByteSize()
 {
     if (!IsValid())
@@ -219,6 +219,51 @@ SBType::GetDereferencedType()
     return SBType(ClangASTType(m_opaque_sp->GetASTContext(),qt.getNonReferenceType().getAsOpaquePtr()));
 }
 
+bool 
+SBType::IsFunctionType ()
+{
+    if (IsValid())
+    {
+        QualType qual_type(QualType::getFromOpaquePtr(m_opaque_sp->GetOpaqueQualType()));
+        const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr());
+        return func != NULL;
+    }
+    return false;
+}
+
+lldb::SBType
+SBType::GetFunctionReturnType ()
+{
+    if (IsValid())
+    {
+        QualType qual_type(QualType::getFromOpaquePtr(m_opaque_sp->GetOpaqueQualType()));
+        const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr());
+        
+        if (func)
+            return SBType(ClangASTType(m_opaque_sp->GetASTContext(),
+                                       func->getResultType().getAsOpaquePtr()));
+    }
+    return lldb::SBType();
+}
+
+lldb::SBTypeList
+SBType::GetFunctionArgumentTypes ()
+{
+    SBTypeList sb_type_list;
+    if (IsValid())
+    {
+        QualType qual_type(QualType::getFromOpaquePtr(m_opaque_sp->GetOpaqueQualType()));
+        const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr());
+        if (func)
+        {
+            const uint32_t num_args = func->getNumArgs();
+            for (uint32_t i=0; i<num_args; ++i)
+                sb_type_list.Append (SBType(ClangASTType(m_opaque_sp->GetASTContext(), func->getArgType(i).getAsOpaquePtr())));
+        }
+    }
+    return sb_type_list;
+}
+
 lldb::SBType
 SBType::GetUnqualifiedType()
 {
@@ -229,101 +274,32 @@ SBType::GetUnqualifiedType()
     return SBType(ClangASTType(m_opaque_sp->GetASTContext(),qt.getUnqualifiedType().getAsOpaquePtr()));
 }
 
+lldb::SBType
+SBType::GetCanonicalType()
+{
+    if (IsValid())
+    {
+        QualType qt (QualType::getFromOpaquePtr(m_opaque_sp->GetOpaqueQualType()));
+        return SBType(ClangASTType(m_opaque_sp->GetASTContext(),qt.getCanonicalType().getAsOpaquePtr()));
+    }
+    return SBType();
+}
+
+
+lldb::BasicType
+SBType::GetBasicType()
+{
+    if (IsValid())
+        return ClangASTContext::GetLLDBBasicTypeEnumeration (m_opaque_sp->GetOpaqueQualType());
+    return eBasicTypeInvalid;
+}
 
 SBType
 SBType::GetBasicType(lldb::BasicType type)
 {
-    
-    if (!IsValid())
-        return SBType();
-    
-    clang::CanQualType base_type_qual;
-    
-    switch (type)
-    {
-        case eBasicTypeChar:
-            base_type_qual = m_opaque_sp->GetASTContext()->CharTy;
-            break;
-        case eBasicTypeSignedChar:
-            base_type_qual = m_opaque_sp->GetASTContext()->SignedCharTy;
-            break;
-        case eBasicTypeShort:
-            base_type_qual = m_opaque_sp->GetASTContext()->ShortTy;
-            break;
-        case eBasicTypeUnsignedShort:
-            base_type_qual = m_opaque_sp->GetASTContext()->UnsignedShortTy;
-            break;
-        case eBasicTypeInt:
-            base_type_qual = m_opaque_sp->GetASTContext()->IntTy;
-            break;
-        case eBasicTypeUnsignedInt:
-            base_type_qual = m_opaque_sp->GetASTContext()->UnsignedIntTy;
-            break;
-        case eBasicTypeLong:
-            base_type_qual = m_opaque_sp->GetASTContext()->LongTy;
-            break;
-        case eBasicTypeUnsignedLong:
-            base_type_qual = m_opaque_sp->GetASTContext()->UnsignedLongTy;
-            break;
-        case eBasicTypeBool:
-            base_type_qual = m_opaque_sp->GetASTContext()->BoolTy;
-            break;
-        case eBasicTypeFloat:
-            base_type_qual = m_opaque_sp->GetASTContext()->FloatTy;
-            break;
-        case eBasicTypeDouble:
-            base_type_qual = m_opaque_sp->GetASTContext()->DoubleTy;
-            break;
-        case eBasicTypeObjCID:
-            base_type_qual = m_opaque_sp->GetASTContext()->ObjCBuiltinIdTy;
-            break;
-        case eBasicTypeVoid:
-            base_type_qual = m_opaque_sp->GetASTContext()->VoidTy;
-            break;
-        case eBasicTypeWChar:
-            base_type_qual = m_opaque_sp->GetASTContext()->WCharTy;
-            break;
-        case eBasicTypeChar16:
-            base_type_qual = m_opaque_sp->GetASTContext()->Char16Ty;
-            break;
-        case eBasicTypeChar32:
-            base_type_qual = m_opaque_sp->GetASTContext()->Char32Ty;
-            break;
-        case eBasicTypeLongLong:
-            base_type_qual = m_opaque_sp->GetASTContext()->LongLongTy;
-            break;
-        case eBasicTypeUnsignedLongLong:
-            base_type_qual = m_opaque_sp->GetASTContext()->UnsignedLongLongTy;
-            break;
-        case eBasicTypeInt128:
-            base_type_qual = m_opaque_sp->GetASTContext()->Int128Ty;
-            break;
-        case eBasicTypeUnsignedInt128:
-            base_type_qual = m_opaque_sp->GetASTContext()->UnsignedInt128Ty;
-            break;
-        case eBasicTypeLongDouble:
-            base_type_qual = m_opaque_sp->GetASTContext()->LongDoubleTy;
-            break;
-        case eBasicTypeFloatComplex:
-            base_type_qual = m_opaque_sp->GetASTContext()->FloatComplexTy;
-            break;
-        case eBasicTypeDoubleComplex:
-            base_type_qual = m_opaque_sp->GetASTContext()->DoubleComplexTy;
-            break;
-        case eBasicTypeLongDoubleComplex:
-            base_type_qual = m_opaque_sp->GetASTContext()->LongDoubleComplexTy;
-            break;
-        case eBasicTypeObjCClass:
-            base_type_qual = m_opaque_sp->GetASTContext()->ObjCBuiltinClassTy;
-            break;
-        case eBasicTypeObjCSel:
-            base_type_qual = m_opaque_sp->GetASTContext()->ObjCBuiltinSelTy;
-            break;
-        default:
-            return SBType();
-    }
-    
-    return SBType(ClangASTType(m_opaque_sp->GetASTContext(), base_type_qual.getAsOpaquePtr()));
+    if (IsValid())
+        return SBType (ClangASTType::GetBasicType (m_opaque_sp->GetASTContext(), type));
+    return SBType();
 }
 
 uint32_t
@@ -558,7 +534,7 @@ SBTypeList::~SBTypeList()
 bool
 SBType::IsPointerType (void *opaque_type)
 {
-    LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     
     bool ret_value = ClangASTContext::IsPointerType (opaque_type);
     

Modified: lldb/branches/lldb-platform-work/source/API/SBTypeCategory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBTypeCategory.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBTypeCategory.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBTypeCategory.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/API/SBTypeCategory.h"
 
 #include "lldb/API/SBTypeFilter.h"
@@ -16,8 +18,8 @@
 #include "lldb/API/SBTypeNameSpecifier.h"
 #include "lldb/API/SBStream.h"
 
-#include "lldb/Core/DataVisualization.h"
 #include "lldb/Core/Debugger.h"
+#include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
 
@@ -167,7 +169,7 @@ SBTypeCategory::GetFilterForType (SBType
     if (!children_sp)
         return lldb::SBTypeFilter();
     
-    TypeFilterImplSP filter_sp = STD_STATIC_POINTER_CAST(TypeFilterImpl,children_sp);
+    TypeFilterImplSP filter_sp = std::static_pointer_cast<TypeFilterImpl>(children_sp);
     
     return lldb::SBTypeFilter(filter_sp);
 
@@ -231,7 +233,7 @@ SBTypeCategory::GetSyntheticForType (SBT
     if (!children_sp)
         return lldb::SBTypeSynthetic();
     
-    TypeSyntheticImplSP synth_sp = STD_STATIC_POINTER_CAST(TypeSyntheticImpl,children_sp);
+    ScriptedSyntheticChildrenSP synth_sp = std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
     
     return lldb::SBTypeSynthetic(synth_sp);
 }
@@ -248,7 +250,7 @@ SBTypeCategory::GetFilterAtIndex (uint32
     if (!children_sp.get())
         return lldb::SBTypeFilter();
     
-    TypeFilterImplSP filter_sp = STD_STATIC_POINTER_CAST(TypeFilterImpl,children_sp);
+    TypeFilterImplSP filter_sp = std::static_pointer_cast<TypeFilterImpl>(children_sp);
     
     return lldb::SBTypeFilter(filter_sp);
 }
@@ -283,7 +285,7 @@ SBTypeCategory::GetSyntheticAtIndex (uin
     if (!children_sp.get())
         return lldb::SBTypeSynthetic();
     
-    TypeSyntheticImplSP synth_sp = STD_STATIC_POINTER_CAST(TypeSyntheticImpl,children_sp);
+    ScriptedSyntheticChildrenSP synth_sp = std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
     
     return lldb::SBTypeSynthetic(synth_sp);
 }

Modified: lldb/branches/lldb-platform-work/source/API/SBTypeFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBTypeFilter.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBTypeFilter.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBTypeFilter.cpp Thu Jun  6 19:06:43 2013
@@ -7,11 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/API/SBTypeFilter.h"
 
 #include "lldb/API/SBStream.h"
 
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
 
 using namespace lldb;
 using namespace lldb_private;

Modified: lldb/branches/lldb-platform-work/source/API/SBTypeFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBTypeFormat.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBTypeFormat.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBTypeFormat.cpp Thu Jun  6 19:06:43 2013
@@ -7,11 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/API/SBTypeFormat.h"
 
 #include "lldb/API/SBStream.h"
 
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
 
 using namespace lldb;
 using namespace lldb_private;

Modified: lldb/branches/lldb-platform-work/source/API/SBTypeNameSpecifier.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBTypeNameSpecifier.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBTypeNameSpecifier.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBTypeNameSpecifier.cpp Thu Jun  6 19:06:43 2013
@@ -7,12 +7,14 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/API/SBTypeNameSpecifier.h"
 
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBType.h"
 
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -116,6 +118,8 @@ SBTypeNameSpecifier::IsEqualTo (lldb::SB
     
     if (IsRegex() != rhs.IsRegex())
         return false;
+    if (GetName() == NULL || rhs.GetName() == NULL)
+        return false;
     
     return (strcmp(GetName(), rhs.GetName()) == 0);
 }

Modified: lldb/branches/lldb-platform-work/source/API/SBTypeSummary.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBTypeSummary.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBTypeSummary.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBTypeSummary.cpp Thu Jun  6 19:06:43 2013
@@ -7,11 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/API/SBTypeSummary.h"
 
 #include "lldb/API/SBStream.h"
 
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -99,6 +101,9 @@ SBTypeSummary::IsSummaryString()
     if (!IsValid())
         return false;
     
+    if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback)
+        return false;
+    
     return !m_opaque_sp->IsScripted();
 }
 
@@ -107,6 +112,8 @@ SBTypeSummary::GetData ()
 {
     if (!IsValid())
         return NULL;
+    if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback)
+        return NULL;
     if (m_opaque_sp->IsScripted())
     {
         ScriptSummaryFormat* script_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get();
@@ -144,7 +151,7 @@ SBTypeSummary::SetSummaryString (const c
 {
     if (!IsValid())
         return;
-    if (m_opaque_sp->IsScripted())
+    if (m_opaque_sp->IsScripted() || (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback))
         ChangeSummaryType(false);
     ((StringSummaryFormat*)m_opaque_sp.get())->SetSummaryString(data);
 }
@@ -205,6 +212,16 @@ SBTypeSummary::IsEqualTo (lldb::SBTypeSu
 {
     if (IsValid() == false)
         return !rhs.IsValid();
+
+    if (m_opaque_sp->GetType() != rhs.m_opaque_sp->GetType())
+        return false;
+    
+    if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback)
+    {
+        lldb_private::CXXFunctionSummaryFormat *self_cxx = (lldb_private::CXXFunctionSummaryFormat*)m_opaque_sp.get();
+        lldb_private::CXXFunctionSummaryFormat *other_cxx = (lldb_private::CXXFunctionSummaryFormat*)rhs.m_opaque_sp.get();
+        return (self_cxx->m_impl == other_cxx->m_impl);
+    }
     
     if (m_opaque_sp->IsScripted() != rhs.m_opaque_sp->IsScripted())
         return false;
@@ -218,7 +235,7 @@ SBTypeSummary::IsEqualTo (lldb::SBTypeSu
     if (IsFunctionName() != rhs.IsFunctionName())
         return false;
     
-    if ( strcmp(GetData(), rhs.GetData()) )
+    if ( GetData() == NULL || rhs.GetData() == NULL || strcmp(GetData(), rhs.GetData()) )
         return false;
     
     return GetOptions() == rhs.GetOptions();
@@ -255,12 +272,20 @@ SBTypeSummary::CopyOnWrite_Impl()
 {
     if (!IsValid())
         return false;
+    
     if (m_opaque_sp.unique())
         return true;
     
     TypeSummaryImplSP new_sp;
     
-    if (m_opaque_sp->IsScripted())
+    if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback)
+    {
+        CXXFunctionSummaryFormat* current_summary_ptr = (CXXFunctionSummaryFormat*)m_opaque_sp.get();
+        new_sp = TypeSummaryImplSP(new CXXFunctionSummaryFormat(GetOptions(),
+                                                                current_summary_ptr->m_impl,
+                                                                current_summary_ptr->m_description.c_str()));
+    }
+    else if (m_opaque_sp->IsScripted())
     {
         ScriptSummaryFormat* current_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get();
         new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(GetOptions(),
@@ -284,15 +309,23 @@ SBTypeSummary::ChangeSummaryType (bool w
     if (!IsValid())
         return false;
     
-    if (want_script == m_opaque_sp->IsScripted())
-        return CopyOnWrite_Impl();
-    
     TypeSummaryImplSP new_sp;
     
-    if (want_script)
-        new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(GetOptions(), "", ""));
-    else
-        new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), ""));
+    if (want_script == m_opaque_sp->IsScripted())
+    {
+        if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback && !want_script)
+            new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), ""));
+        else
+            return CopyOnWrite_Impl();
+    }
+    
+    if (!new_sp)
+    {
+        if (want_script)
+            new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(GetOptions(), "", ""));
+        else
+            new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), ""));
+    }
     
     SetSP(new_sp);
     

Modified: lldb/branches/lldb-platform-work/source/API/SBTypeSynthetic.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBTypeSynthetic.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBTypeSynthetic.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBTypeSynthetic.cpp Thu Jun  6 19:06:43 2013
@@ -7,11 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/API/SBTypeSynthetic.h"
 
 #include "lldb/API/SBStream.h"
 
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -28,7 +30,7 @@ SBTypeSynthetic::CreateWithClassName (co
 {
     if (!data || data[0] == 0)
         return SBTypeSynthetic();
-    return SBTypeSynthetic(TypeSyntheticImplSP(new TypeSyntheticImpl(options, data, "")));
+    return SBTypeSynthetic(ScriptedSyntheticChildrenSP(new ScriptedSyntheticChildren(options, data, "")));
 }
 
 SBTypeSynthetic
@@ -36,7 +38,7 @@ SBTypeSynthetic::CreateWithScriptCode (c
 {
     if (!data || data[0] == 0)
         return SBTypeSynthetic();
-    return SBTypeSynthetic(TypeSyntheticImplSP(new TypeSyntheticImpl(options, "", data)));
+    return SBTypeSynthetic(ScriptedSyntheticChildrenSP(new ScriptedSyntheticChildren(options, "", data)));
 }
 
 SBTypeSynthetic::SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs) :
@@ -170,19 +172,19 @@ SBTypeSynthetic::operator != (lldb::SBTy
     return m_opaque_sp != rhs.m_opaque_sp;
 }
 
-lldb::TypeSyntheticImplSP
+lldb::ScriptedSyntheticChildrenSP
 SBTypeSynthetic::GetSP ()
 {
     return m_opaque_sp;
 }
 
 void
-SBTypeSynthetic::SetSP (const lldb::TypeSyntheticImplSP &TypeSynthetic_impl_sp)
+SBTypeSynthetic::SetSP (const lldb::ScriptedSyntheticChildrenSP &TypeSynthetic_impl_sp)
 {
     m_opaque_sp = TypeSynthetic_impl_sp;
 }
 
-SBTypeSynthetic::SBTypeSynthetic (const lldb::TypeSyntheticImplSP &TypeSynthetic_impl_sp) :
+SBTypeSynthetic::SBTypeSynthetic (const lldb::ScriptedSyntheticChildrenSP &TypeSynthetic_impl_sp) :
 m_opaque_sp(TypeSynthetic_impl_sp)
 {
 }
@@ -195,7 +197,7 @@ SBTypeSynthetic::CopyOnWrite_Impl()
     if (m_opaque_sp.unique())
         return true;
     
-    TypeSyntheticImplSP new_sp(new TypeSyntheticImpl(m_opaque_sp->GetOptions(),
+    ScriptedSyntheticChildrenSP new_sp(new ScriptedSyntheticChildren(m_opaque_sp->GetOptions(),
                                                      m_opaque_sp->GetPythonClassName(),
                                                      m_opaque_sp->GetPythonCode()));
     

Modified: lldb/branches/lldb-platform-work/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBValue.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBValue.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBValue.cpp Thu Jun  6 19:06:43 2013
@@ -7,8 +7,11 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/API/SBValue.h"
 
+#include "lldb/API/SBDeclaration.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBTypeFilter.h"
 #include "lldb/API/SBTypeFormat.h"
@@ -17,16 +20,18 @@
 
 #include "lldb/Breakpoint/Watchpoint.h"
 #include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/DataVisualization.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/Scalar.h"
+#include "lldb/Core/Section.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Core/Value.h"
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/Declaration.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Type.h"
 #include "lldb/Symbol/Variable.h"
@@ -37,28 +42,218 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBExpressionOptions.h"
+#include "lldb/API/SBFrame.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBTarget.h"
 #include "lldb/API/SBThread.h"
-#include "lldb/API/SBFrame.h"
-#include "lldb/API/SBDebugger.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
+class ValueImpl
+{
+public:
+    ValueImpl ()
+    {
+    }
+    
+    ValueImpl (lldb::ValueObjectSP in_valobj_sp,
+               lldb::DynamicValueType use_dynamic,
+               bool use_synthetic,
+               const char *name = NULL) :
+    m_valobj_sp(in_valobj_sp),
+    m_use_dynamic(use_dynamic),
+    m_use_synthetic(use_synthetic),
+    m_name (name)
+    {
+        if (!m_name.IsEmpty() && m_valobj_sp)
+            m_valobj_sp->SetName(m_name);
+    }
+    
+    ValueImpl (const ValueImpl& rhs) :
+    m_valobj_sp(rhs.m_valobj_sp),
+    m_use_dynamic(rhs.m_use_dynamic),
+    m_use_synthetic(rhs.m_use_synthetic),
+    m_name (rhs.m_name)
+    {
+    }
+    
+    ValueImpl &
+    operator = (const ValueImpl &rhs)
+    {
+        if (this != &rhs)
+        {
+            m_valobj_sp = rhs.m_valobj_sp;
+            m_use_dynamic = rhs.m_use_dynamic;
+            m_use_synthetic = rhs.m_use_synthetic;
+            m_name = rhs.m_name;
+        }
+        return *this;
+    }
+    
+    bool
+    IsValid ()
+    {
+        return m_valobj_sp.get() != NULL;
+    }
+    
+    lldb::ValueObjectSP
+    GetRootSP ()
+    {
+        return m_valobj_sp;
+    }
+    
+    lldb::ValueObjectSP
+    GetSP (Process::StopLocker &stop_locker, Mutex::Locker &api_locker, Error &error)
+    {
+        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+        if (!m_valobj_sp)
+        {
+            error.SetErrorString("invalid value object");
+            return m_valobj_sp;
+        }
+        
+        lldb::ValueObjectSP value_sp = m_valobj_sp;
+        
+        Target *target = value_sp->GetTargetSP().get();
+        if (target)
+            api_locker.Lock(target->GetAPIMutex());
+        
+        ProcessSP process_sp(value_sp->GetProcessSP());
+        if (process_sp && !stop_locker.TryLock (&process_sp->GetRunLock()))
+        {
+            // We don't allow people to play around with ValueObject if the process is running.
+            // If you want to look at values, pause the process, then look.
+            if (log)
+                log->Printf ("SBValue(%p)::GetSP() => error: process is running", value_sp.get());
+            error.SetErrorString ("process must be stopped.");
+            return ValueObjectSP();
+        }
+        
+        if (value_sp->GetDynamicValue(m_use_dynamic))
+            value_sp = value_sp->GetDynamicValue(m_use_dynamic);
+        if (value_sp->GetSyntheticValue(m_use_synthetic))
+            value_sp = value_sp->GetSyntheticValue(m_use_synthetic);
+        if (!value_sp)
+            error.SetErrorString("invalid value object");
+        if (!m_name.IsEmpty())
+            value_sp->SetName(m_name);
+        
+        return value_sp;
+    }
+    
+    void
+    SetUseDynamic (lldb::DynamicValueType use_dynamic)
+    {
+        m_use_dynamic = use_dynamic;
+    }
+    
+    void
+    SetUseSynthetic (bool use_synthetic)
+    {
+        m_use_synthetic = use_synthetic;
+    }
+    
+    lldb::DynamicValueType
+    GetUseDynamic ()
+    {
+        return m_use_dynamic;
+    }
+    
+    bool
+    GetUseSynthetic ()
+    {
+        return m_use_synthetic;
+    }
+    
+    // All the derived values that we would make from the m_valobj_sp will share
+    // the ExecutionContext with m_valobj_sp, so we don't need to do the calculations
+    // in GetSP to return the Target, Process, Thread or Frame.  It is convenient to
+    // provide simple accessors for these, which I do here.
+    TargetSP
+    GetTargetSP ()
+    {
+        if (m_valobj_sp)
+            return m_valobj_sp->GetTargetSP();
+        else
+            return TargetSP();
+    }
+    
+    ProcessSP
+    GetProcessSP ()
+    {
+        if (m_valobj_sp)
+            return m_valobj_sp->GetProcessSP();
+        else
+            return ProcessSP();
+    }
+    
+    ThreadSP
+    GetThreadSP ()
+    {
+        if (m_valobj_sp)
+            return m_valobj_sp->GetThreadSP();
+        else
+            return ThreadSP();
+    }
+    
+    StackFrameSP
+    GetFrameSP ()
+    {
+        if (m_valobj_sp)
+            return m_valobj_sp->GetFrameSP();
+        else
+            return StackFrameSP();
+    }
+    
+private:
+    lldb::ValueObjectSP m_valobj_sp;
+    lldb::DynamicValueType m_use_dynamic;
+    bool m_use_synthetic;
+    ConstString m_name;
+};
+
+class ValueLocker
+{
+public:
+    ValueLocker ()
+    {
+    }
+    
+    ValueObjectSP
+    GetLockedSP(ValueImpl &in_value)
+    {
+        return in_value.GetSP(m_stop_locker, m_api_locker, m_lock_error);
+    }
+    
+    Error &
+    GetError()
+    {
+        return m_lock_error;
+    }
+    
+private:
+    Process::StopLocker m_stop_locker;
+    Mutex::Locker m_api_locker;
+    Error m_lock_error;
+    
+};
+
 SBValue::SBValue () :
-    m_opaque_sp ()
+m_opaque_sp ()
 {
 }
 
 SBValue::SBValue (const lldb::ValueObjectSP &value_sp)
 {
-    SetSP(value_sp); // whenever setting the SP call SetSP() since it knows how to deal with synthetic values properly
+    SetSP(value_sp);
 }
 
 SBValue::SBValue(const SBValue &rhs)
 {
-    SetSP(rhs.m_opaque_sp); // whenever setting the SP call SetSP() since it knows how to deal with synthetic values properly
+    SetSP(rhs.m_opaque_sp);
 }
 
 SBValue &
@@ -66,7 +261,7 @@ SBValue::operator = (const SBValue &rhs)
 {
     if (this != &rhs)
     {
-        SetSP(rhs.m_opaque_sp); // whenever setting the SP call SetSP() since it knows how to deal with synthetic values properly
+        SetSP(rhs.m_opaque_sp);
     }
     return *this;
 }
@@ -81,7 +276,7 @@ SBValue::IsValid ()
     // If this function ever changes to anything that does more than just
     // check if the opaque shared pointer is non NULL, then we need to update
     // all "if (m_opaque_sp)" code in this file.
-    return m_opaque_sp.get() != NULL;
+    return m_opaque_sp.get() != NULL && m_opaque_sp->GetRootSP().get() != NULL;
 }
 
 void
@@ -95,11 +290,12 @@ SBValue::GetError()
 {
     SBError sb_error;
     
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
         sb_error.SetError(value_sp->GetError());
     else
-        sb_error.SetErrorString("error: invalid value");
+        sb_error.SetErrorStringWithFormat ("error: %s", locker.GetError().AsCString());
     
     return sb_error;
 }
@@ -107,7 +303,8 @@ SBValue::GetError()
 user_id_t
 SBValue::GetID()
 {
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
         return value_sp->GetID();
     return LLDB_INVALID_UID;
@@ -116,13 +313,13 @@ SBValue::GetID()
 const char *
 SBValue::GetName()
 {
-
     const char *name = NULL;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
         name = value_sp->GetName().GetCString();
-
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         if (name)
@@ -130,18 +327,22 @@ SBValue::GetName()
         else
             log->Printf ("SBValue(%p)::GetName () => NULL", value_sp.get());
     }
-
+    
     return name;
 }
 
 const char *
 SBValue::GetTypeName ()
 {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     const char *name = NULL;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
+    {
         name = value_sp->GetQualifiedTypeName().GetCString();
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    }
+    
     if (log)
     {
         if (name)
@@ -149,23 +350,26 @@ SBValue::GetTypeName ()
         else
             log->Printf ("SBValue(%p)::GetTypeName () => NULL", value_sp.get());
     }
-
+    
     return name;
 }
 
 size_t
 SBValue::GetByteSize ()
 {
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     size_t result = 0;
-
-    lldb::ValueObjectSP value_sp(GetSP());
+    
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
+    {
         result = value_sp->GetByteSize();
-
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    }
+    
     if (log)
-        log->Printf ("SBValue(%p)::GetByteSize () => %zu", value_sp.get(), result);
-
+        log->Printf ("SBValue(%p)::GetByteSize () => %" PRIu64, value_sp.get(), (uint64_t)result);
+    
     return result;
 }
 
@@ -173,50 +377,32 @@ bool
 SBValue::IsInScope ()
 {
     bool result = false;
-
-    lldb::ValueObjectSP value_sp(GetSP());
+    
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        TargetSP target_sp(value_sp->GetTargetSP());
-        if (target_sp)
-        {
-            Mutex::Locker api_locker (target_sp->GetAPIMutex());
-            result = value_sp->IsInScope ();
-        }
+        result = value_sp->IsInScope ();
     }
-
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBValue(%p)::IsInScope () => %i", value_sp.get(), result);
-
+    
     return result;
 }
 
 const char *
 SBValue::GetValue ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    
     const char *cstr = NULL;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            if (log)
-                log->Printf ("SBValue(%p)::GetValue() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                cstr = value_sp->GetValueAsCString ();
-            }
-        }
+        cstr = value_sp->GetValueAsCString ();
     }
     if (log)
     {
@@ -225,7 +411,7 @@ SBValue::GetValue ()
         else
             log->Printf ("SBValue(%p)::GetValue() => NULL", value_sp.get());
     }
-
+    
     return cstr;
 }
 
@@ -233,23 +419,24 @@ ValueType
 SBValue::GetValueType ()
 {
     ValueType result = eValueTypeInvalid;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
         result = value_sp->GetValueType();
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         switch (result)
         {
-        case eValueTypeInvalid:         log->Printf ("SBValue(%p)::GetValueType () => eValueTypeInvalid", value_sp.get()); break;
-        case eValueTypeVariableGlobal:  log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal", value_sp.get()); break;
-        case eValueTypeVariableStatic:  log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableStatic", value_sp.get()); break;
-        case eValueTypeVariableArgument:log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableArgument", value_sp.get()); break;
-        case eValueTypeVariableLocal:   log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableLocal", value_sp.get()); break;
-        case eValueTypeRegister:        log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegister", value_sp.get()); break;
-        case eValueTypeRegisterSet:     log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegisterSet", value_sp.get()); break;
-        case eValueTypeConstResult:     log->Printf ("SBValue(%p)::GetValueType () => eValueTypeConstResult", value_sp.get()); break;
-        default:     log->Printf ("SBValue(%p)::GetValueType () => %i ???", value_sp.get(), result); break;
+            case eValueTypeInvalid:         log->Printf ("SBValue(%p)::GetValueType () => eValueTypeInvalid", value_sp.get()); break;
+            case eValueTypeVariableGlobal:  log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal", value_sp.get()); break;
+            case eValueTypeVariableStatic:  log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableStatic", value_sp.get()); break;
+            case eValueTypeVariableArgument:log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableArgument", value_sp.get()); break;
+            case eValueTypeVariableLocal:   log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableLocal", value_sp.get()); break;
+            case eValueTypeRegister:        log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegister", value_sp.get()); break;
+            case eValueTypeRegisterSet:     log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegisterSet", value_sp.get()); break;
+            case eValueTypeConstResult:     log->Printf ("SBValue(%p)::GetValueType () => eValueTypeConstResult", value_sp.get()); break;
         }
     }
     return result;
@@ -258,27 +445,13 @@ SBValue::GetValueType ()
 const char *
 SBValue::GetObjectDescription ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     const char *cstr = NULL;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            if (log)
-                log->Printf ("SBValue(%p)::GetObjectDescription() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                cstr = value_sp->GetObjectDescription ();
-            }
-        }
+        cstr = value_sp->GetObjectDescription ();
     }
     if (log)
     {
@@ -293,29 +466,15 @@ SBValue::GetObjectDescription ()
 SBType
 SBValue::GetType()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     SBType sb_type;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     TypeImplSP type_sp;
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            if (log)
-                log->Printf ("SBValue(%p)::GetType() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                type_sp.reset (new TypeImpl(ClangASTType (value_sp->GetClangAST(), value_sp->GetClangType())));
-                sb_type.SetSP(type_sp);
-            }
-        }
+        type_sp.reset (new TypeImpl(ClangASTType (value_sp->GetClangAST(), value_sp->GetClangType())));
+        sb_type.SetSP(type_sp);
     }
     if (log)
     {
@@ -330,31 +489,17 @@ SBValue::GetType()
 bool
 SBValue::GetValueDidChange ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     bool result = false;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            if (log)
-                log->Printf ("SBValue(%p)::GetValueDidChange() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                result = value_sp->GetValueDidChange ();
-            }
-        }
+        result = value_sp->GetValueDidChange ();
     }
     if (log)
         log->Printf ("SBValue(%p)::GetValueDidChange() => %i", value_sp.get(), result);
-
+    
     return result;
 }
 
@@ -362,27 +507,13 @@ SBValue::GetValueDidChange ()
 const char *
 SBValue::GetSummary ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     const char *cstr = NULL;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            if (log)
-                log->Printf ("SBValue(%p)::GetSummary() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                cstr = value_sp->GetSummaryAsCString();
-            }
-        }
+        cstr = value_sp->GetSummaryAsCString();
     }
     if (log)
     {
@@ -398,27 +529,13 @@ SBValue::GetSummary ()
 const char *
 SBValue::GetLocation ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     const char *cstr = NULL;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            if (log)
-                log->Printf ("SBValue(%p)::GetLocation() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                cstr = value_sp->GetLocationAsCString();
-            }
-        }
+        cstr = value_sp->GetLocationAsCString();
     }
     if (log)
     {
@@ -442,30 +559,19 @@ bool
 SBValue::SetValueFromCString (const char *value_str, lldb::SBError& error)
 {
     bool success = false;
-    lldb::ValueObjectSP value_sp(GetSP());
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            if (log)
-                log->Printf ("SBValue(%p)::SetValueFromCString() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                success = value_sp->SetValueFromCString (value_str,error.ref());
-            }
-        }
+        success = value_sp->SetValueFromCString (value_str,error.ref());
     }
+    else
+        error.SetErrorStringWithFormat ("Could not get value: %s", locker.GetError().AsCString());
+    
     if (log)
         log->Printf ("SBValue(%p)::SetValueFromCString(\"%s\") => %i", value_sp.get(), value_str, success);
-
+    
     return success;
 }
 
@@ -473,30 +579,15 @@ lldb::SBTypeFormat
 SBValue::GetTypeFormat ()
 {
     lldb::SBTypeFormat format;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-            if (log)
-                log->Printf ("SBValue(%p)::GetTypeFormat() => error: process is running", value_sp.get());
-        }
-        else
+        if (value_sp->UpdateValueIfNeeded(true))
         {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                if (value_sp->UpdateValueIfNeeded(true))
-                {
-                    lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
-                    if (format_sp)
-                        format.SetSP(format_sp);
-                }
-            }
+            lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
+            if (format_sp)
+                format.SetSP(format_sp);
         }
     }
     return format;
@@ -507,30 +598,15 @@ lldb::SBTypeSummary
 SBValue::GetTypeSummary ()
 {
     lldb::SBTypeSummary summary;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
+        if (value_sp->UpdateValueIfNeeded(true))
         {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-            if (log)
-                log->Printf ("SBValue(%p)::GetTypeSummary() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                if (value_sp->UpdateValueIfNeeded(true))
-                {
-                    lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat();
-                    if (summary_sp)
-                        summary.SetSP(summary_sp);
-                }
-            }
+            lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat();
+            if (summary_sp)
+                summary.SetSP(summary_sp);
         }
     }
     return summary;
@@ -541,33 +617,18 @@ lldb::SBTypeFilter
 SBValue::GetTypeFilter ()
 {
     lldb::SBTypeFilter filter;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-            if (log)
-                log->Printf ("SBValue(%p)::GetTypeFilter() => error: process is running", value_sp.get());
-        }
-        else
+        if (value_sp->UpdateValueIfNeeded(true))
         {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
+            lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren();
+            
+            if (synthetic_sp && !synthetic_sp->IsScripted())
             {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                if (value_sp->UpdateValueIfNeeded(true))
-                {
-                    lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren();
-                    
-                    if (synthetic_sp && !synthetic_sp->IsScripted())
-                    {
-                        TypeFilterImplSP filter_sp = STD_STATIC_POINTER_CAST(TypeFilterImpl,synthetic_sp);
-                        filter.SetSP(filter_sp);
-                    }
-                }
+                TypeFilterImplSP filter_sp = std::static_pointer_cast<TypeFilterImpl>(synthetic_sp);
+                filter.SetSP(filter_sp);
             }
         }
     }
@@ -579,33 +640,18 @@ lldb::SBTypeSynthetic
 SBValue::GetTypeSynthetic ()
 {
     lldb::SBTypeSynthetic synthetic;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
+        if (value_sp->UpdateValueIfNeeded(true))
         {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-            if (log)
-                log->Printf ("SBValue(%p)::GetTypeSynthetic() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
+            lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren();
+            
+            if (children_sp && children_sp->IsScripted())
             {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                if (value_sp->UpdateValueIfNeeded(true))
-                {
-                    lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren();
-                    
-                    if (children_sp && children_sp->IsScripted())
-                    {
-                        TypeSyntheticImplSP synth_sp = STD_STATIC_POINTER_CAST(TypeSyntheticImpl,children_sp);
-                        synthetic.SetSP(synth_sp);
-                    }
-                }
+                ScriptedSyntheticChildrenSP synth_sp = std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
+                synthetic.SetSP(synth_sp);
             }
         }
     }
@@ -617,42 +663,27 @@ lldb::SBValue
 SBValue::CreateChildAtOffset (const char *name, uint32_t offset, SBType type)
 {
     lldb::SBValue sb_value;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     lldb::ValueObjectSP new_value_sp;
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-            if (log)
-                log->Printf ("SBValue(%p)::CreateChildAtOffset() => error: process is running", value_sp.get());
-        }
-        else
+        TypeImplSP type_sp (type.GetSP());
+        if (type.IsValid())
         {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                TypeImplSP type_sp (type.GetSP());
-                if (type.IsValid())
-                {
-                    sb_value = SBValue(value_sp->GetSyntheticChildAtOffset(offset, type_sp->GetClangASTType(), true));
-                    new_value_sp = sb_value.GetSP();
-                    if (new_value_sp)
-                        new_value_sp->SetName(ConstString(name));
-                }
-            }
+            sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(offset, type_sp->GetClangASTType(), true),GetPreferDynamicValue(),GetPreferSyntheticValue(), name);
         }
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         if (new_value_sp)
-            log->Printf ("SBValue(%p)::CreateChildAtOffset => \"%s\"", value_sp.get(), new_value_sp->GetName().AsCString());
+            log->Printf ("SBValue(%p)::CreateChildAtOffset => \"%s\"",
+                         value_sp.get(),
+                         new_value_sp->GetName().AsCString());
         else
-            log->Printf ("SBValue(%p)::CreateChildAtOffset => NULL", value_sp.get());
+            log->Printf ("SBValue(%p)::CreateChildAtOffset => NULL",
+                         value_sp.get());
     }
     return sb_value;
 }
@@ -661,48 +692,45 @@ lldb::SBValue
 SBValue::Cast (SBType type)
 {
     lldb::SBValue sb_value;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     TypeImplSP type_sp (type.GetSP());
     if (value_sp && type_sp)
-        sb_value.SetSP(value_sp->Cast(type_sp->GetClangASTType()));
+        sb_value.SetSP(value_sp->Cast(type_sp->GetClangASTType()),GetPreferDynamicValue(),GetPreferSyntheticValue());
     return sb_value;
 }
 
 lldb::SBValue
 SBValue::CreateValueFromExpression (const char *name, const char* expression)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    SBExpressionOptions options;
+    options.ref().SetKeepInMemory(true);
+    return CreateValueFromExpression (name, expression, options);
+}
+
+lldb::SBValue
+SBValue::CreateValueFromExpression (const char *name, const char *expression, SBExpressionOptions &options)
+{
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     lldb::SBValue sb_value;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     lldb::ValueObjectSP new_value_sp;
     if (value_sp)
     {
         ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
-        ProcessSP process_sp(exe_ctx.GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            if (log)
-                log->Printf ("SBValue(%p)::CreateValueFromExpression() => error: process is running", value_sp.get());
-        }
-        else
+        Target* target = exe_ctx.GetTargetPtr();
+        if (target)
         {
-            Target* target = exe_ctx.GetTargetPtr();
-            if (target)
+            options.ref().SetKeepInMemory(true);
+            target->EvaluateExpression (expression,
+                                        exe_ctx.GetFramePtr(),
+                                        new_value_sp,
+                                        options.ref());
+            if (new_value_sp)
             {
-                target->EvaluateExpression (expression,
-                                            exe_ctx.GetFramePtr(),
-                                            eExecutionPolicyOnlyWhenNeeded,
-                                            false, // coerce to id
-                                            true, // unwind on error
-                                            true, // keep in memory
-                                            eNoDynamicValues,
-                                            new_value_sp);
-                if (new_value_sp)
-                {
-                    new_value_sp->SetName(ConstString(name));
-                    sb_value.SetSP(new_value_sp);
-                }
+                new_value_sp->SetName(ConstString(name));
+                sb_value.SetSP(new_value_sp);
             }
         }
     }
@@ -727,7 +755,8 @@ lldb::SBValue
 SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType sb_type)
 {
     lldb::SBValue sb_value;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     lldb::ValueObjectSP new_value_sp;
     lldb::TypeImplSP type_impl_sp (sb_type.GetSP());
     if (value_sp && type_impl_sp)
@@ -736,18 +765,18 @@ SBValue::CreateValueFromAddress(const ch
         lldb::TypeImplSP pointee_type_impl_sp (new TypeImpl(pointee_ast_type));
         if (pointee_type_impl_sp)
         {
-        
+            
             lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));
-        
+            
             ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
             ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
                                                                                pointee_type_impl_sp->GetASTContext(),
                                                                                pointee_type_impl_sp->GetOpaqueQualType(),
                                                                                ConstString(name),
                                                                                buffer,
-                                                                               lldb::endian::InlHostByteOrder(), 
+                                                                               lldb::endian::InlHostByteOrder(),
                                                                                exe_ctx.GetAddressByteSize()));
-        
+            
             if (ptr_result_valobj_sp)
             {
                 ptr_result_valobj_sp->GetValue().SetValueType(Value::eValueTypeLoadAddress);
@@ -759,7 +788,7 @@ SBValue::CreateValueFromAddress(const ch
             sb_value.SetSP(new_value_sp);
         }
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         if (new_value_sp)
@@ -775,11 +804,12 @@ SBValue::CreateValueFromData (const char
 {
     lldb::SBValue sb_value;
     lldb::ValueObjectSP new_value_sp;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
         ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
-
+        
         new_value_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
                                                        type.m_opaque_sp->GetASTContext() ,
                                                        type.m_opaque_sp->GetOpaqueQualType(),
@@ -789,7 +819,7 @@ SBValue::CreateValueFromData (const char
         new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
         sb_value.SetSP(new_value_sp);
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         if (new_value_sp)
@@ -805,13 +835,13 @@ SBValue::GetChildAtIndex (uint32_t idx)
 {
     const bool can_create_synthetic = false;
     lldb::DynamicValueType use_dynamic = eNoDynamicValues;
-    lldb::ValueObjectSP value_sp(GetSP());
-    if (value_sp)
-    {
-        TargetSP target_sp(value_sp->GetTargetSP());
-        if (target_sp)
-            use_dynamic = target_sp->GetPreferDynamicValue();
-    }
+    TargetSP target_sp;
+    if (m_opaque_sp)
+        target_sp = m_opaque_sp->GetTargetSP();
+    
+    if (target_sp)
+        use_dynamic = target_sp->GetPreferDynamicValue();
+    
     return GetChildAtIndex (idx, use_dynamic, can_create_synthetic);
 }
 
@@ -819,55 +849,32 @@ SBValue
 SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic)
 {
     lldb::ValueObjectSP child_sp;
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
-    lldb::ValueObjectSP value_sp(GetSP());
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            if (log)
-                log->Printf ("SBValue(%p)::GetChildAtIndex() => error: process is running", value_sp.get());
-        }
-        else
+        const bool can_create = true;
+        child_sp = value_sp->GetChildAtIndex (idx, can_create);
+        if (can_create_synthetic && !child_sp)
         {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
+            if (value_sp->IsPointerType())
             {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                const bool can_create = true;
-                child_sp = value_sp->GetChildAtIndex (idx, can_create);
-                if (can_create_synthetic && !child_sp)
-                {
-                    if (value_sp->IsPointerType())
-                    {
-                        child_sp = value_sp->GetSyntheticArrayMemberFromPointer(idx, can_create);
-                    }
-                    else if (value_sp->IsArrayType())
-                    {
-                        child_sp = value_sp->GetSyntheticArrayMemberFromArray(idx, can_create);
-                    }
-                }
-                    
-                if (child_sp)
-                {
-                    if (use_dynamic != lldb::eNoDynamicValues)
-                    {
-                        lldb::ValueObjectSP dynamic_sp(child_sp->GetDynamicValue (use_dynamic));
-                        if (dynamic_sp)
-                            child_sp = dynamic_sp;
-                    }
-                }
+                child_sp = value_sp->GetSyntheticArrayMemberFromPointer(idx, can_create);
+            }
+            else if (value_sp->IsArrayType())
+            {
+                child_sp = value_sp->GetSyntheticArrayMemberFromArray(idx, can_create);
             }
         }
     }
     
-    SBValue sb_value (child_sp);
+    SBValue sb_value;
+    sb_value.SetSP (child_sp, use_dynamic, GetPreferSyntheticValue());
     if (log)
         log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)", value_sp.get(), idx, value_sp.get());
-
+    
     return sb_value;
 }
 
@@ -875,18 +882,13 @@ uint32_t
 SBValue::GetIndexOfChildWithName (const char *name)
 {
     uint32_t idx = UINT32_MAX;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        TargetSP target_sp(value_sp->GetTargetSP());
-        if (target_sp)
-        {
-            Mutex::Locker api_locker (target_sp->GetAPIMutex());
-        
-            idx = value_sp->GetIndexOfChildWithName (ConstString(name));
-        }
+        idx = value_sp->GetIndexOfChildWithName (ConstString(name));
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         if (idx == UINT32_MAX)
@@ -900,19 +902,14 @@ SBValue::GetIndexOfChildWithName (const
 SBValue
 SBValue::GetChildMemberWithName (const char *name)
 {
-    lldb::ValueObjectSP value_sp(GetSP());
-    if (value_sp)
-    {
-        lldb::DynamicValueType use_dynamic_value = eNoDynamicValues;
-        TargetSP target_sp(value_sp->GetTargetSP());
-        if (target_sp)
-        {
-            Mutex::Locker api_locker (target_sp->GetAPIMutex());
-            use_dynamic_value = target_sp->GetPreferDynamicValue();
-        }
-        return GetChildMemberWithName (name, use_dynamic_value);
-    }
-    return SBValue();
+    lldb::DynamicValueType use_dynamic_value = eNoDynamicValues;
+    TargetSP target_sp;
+    if (m_opaque_sp)
+        target_sp = m_opaque_sp->GetTargetSP();
+    
+    if (target_sp)
+        use_dynamic_value = target_sp->GetPreferDynamicValue();
+    return GetChildMemberWithName (name, use_dynamic_value);
 }
 
 SBValue
@@ -920,160 +917,126 @@ SBValue::GetChildMemberWithName (const c
 {
     lldb::ValueObjectSP child_sp;
     const ConstString str_name (name);
-
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
-    lldb::ValueObjectSP value_sp(GetSP());
+    
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            if (log)
-                log->Printf ("SBValue(%p)::GetChildMemberWithName() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                child_sp = value_sp->GetChildMemberWithName (str_name, true);
-                if (use_dynamic_value != lldb::eNoDynamicValues)
-                {
-                    if (child_sp)
-                    {
-                        lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic_value);
-                        if (dynamic_sp)
-                            child_sp = dynamic_sp;
-                    }
-                }
-            }
-        }
+        child_sp = value_sp->GetChildMemberWithName (str_name, true);
     }
     
-    SBValue sb_value (child_sp);
-
+    SBValue sb_value;
+    sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue());
+    
     if (log)
         log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)", value_sp.get(), name, value_sp.get());
-
+    
     return sb_value;
 }
 
 lldb::SBValue
 SBValue::GetDynamicValue (lldb::DynamicValueType use_dynamic)
 {
-    lldb::ValueObjectSP value_sp(GetSP());
-    if (value_sp)
+    SBValue value_sb;
+    if (IsValid())
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-            if (log)
-                log->Printf ("SBValue(%p)::GetDynamicValue() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                return SBValue (value_sp->GetDynamicValue(use_dynamic));
-            }
-        }
+        ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),use_dynamic,m_opaque_sp->GetUseSynthetic()));
+        value_sb.SetSP(proxy_sp);
     }
-    
-    return SBValue();
+    return value_sb;
 }
 
 lldb::SBValue
 SBValue::GetStaticValue ()
 {
-    lldb::ValueObjectSP value_sp(GetSP());
-    if (value_sp)
+    SBValue value_sb;
+    if (IsValid())
     {
-        TargetSP target_sp(value_sp->GetTargetSP());
-        if (target_sp)
-        {
-            Mutex::Locker api_locker (target_sp->GetAPIMutex());
-            return SBValue(value_sp->GetStaticValue());
-        }
+        ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),eNoDynamicValues,m_opaque_sp->GetUseSynthetic()));
+        value_sb.SetSP(proxy_sp);
     }
-    
-    return SBValue();
+    return value_sb;
 }
 
 lldb::SBValue
 SBValue::GetNonSyntheticValue ()
 {
-    SBValue sb_value;
-    lldb::ValueObjectSP value_sp(GetSP());
-    if (value_sp)
+    SBValue value_sb;
+    if (IsValid())
     {
-        if (value_sp->IsSynthetic())
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                // deliberately breaking the rules here to optimize the case where we DO NOT want
-                // the synthetic value to be returned to the user - if we did not do this, we would have to tell
-                // the target to suppress the synthetic value, and then return the flag to its original value
-                if (value_sp->GetNonSyntheticValue())
-                    sb_value.m_opaque_sp = value_sp->GetNonSyntheticValue();
-            }
-        }
+        ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),m_opaque_sp->GetUseDynamic(),false));
+        value_sb.SetSP(proxy_sp);
     }
-    return sb_value;
+    return value_sb;
+}
+
+lldb::DynamicValueType
+SBValue::GetPreferDynamicValue ()
+{
+    if (!IsValid())
+        return eNoDynamicValues;
+    return m_opaque_sp->GetUseDynamic();
+}
+
+void
+SBValue::SetPreferDynamicValue (lldb::DynamicValueType use_dynamic)
+{
+    if (IsValid())
+        return m_opaque_sp->SetUseDynamic (use_dynamic);
+}
+
+bool
+SBValue::GetPreferSyntheticValue ()
+{
+    if (!IsValid())
+        return false;
+    return m_opaque_sp->GetUseSynthetic();
+}
+
+void
+SBValue::SetPreferSyntheticValue (bool use_synthetic)
+{
+    if (IsValid())
+        return m_opaque_sp->SetUseSynthetic (use_synthetic);
 }
 
 bool
 SBValue::IsDynamic()
 {
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
-    {
-        TargetSP target_sp(value_sp->GetTargetSP());
-        if (target_sp)
-        {
-            Mutex::Locker api_locker (target_sp->GetAPIMutex());
-            return value_sp->IsDynamic();
-        }
-    }
+        return value_sp->IsDynamic();
+    return false;
+}
+
+bool
+SBValue::IsSynthetic ()
+{
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
+    if (value_sp)
+        return value_sp->IsSynthetic();
     return false;
 }
 
 lldb::SBValue
 SBValue::GetValueForExpressionPath(const char* expr_path)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     lldb::ValueObjectSP child_sp;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            if (log)
-                log->Printf ("SBValue(%p)::GetValueForExpressionPath() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                // using default values for all the fancy options, just do it if you can
-                child_sp = value_sp->GetValueForExpressionPath(expr_path);
-            }
-        }
+        // using default values for all the fancy options, just do it if you can
+        child_sp = value_sp->GetValueForExpressionPath(expr_path);
     }
     
-    SBValue sb_value (child_sp);
+    SBValue sb_value;
+    sb_value.SetSP(child_sp,GetPreferDynamicValue(),GetPreferSyntheticValue());
     
     if (log)
         log->Printf ("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => SBValue(%p)", value_sp.get(), expr_path, value_sp.get());
@@ -1085,35 +1048,19 @@ int64_t
 SBValue::GetValueAsSigned(SBError& error, int64_t fail_value)
 {
     error.Clear();
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-            if (log)
-                log->Printf ("SBValue(%p)::GetValueAsSigned() => error: process is running", value_sp.get());
-            error.SetErrorString("process is running");
-        }
+        Scalar scalar;
+        if (value_sp->ResolveValue (scalar))
+            return scalar.SLongLong (fail_value);
         else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                Scalar scalar;
-                if (value_sp->ResolveValue (scalar))
-                    return scalar.GetRawBits64(fail_value);
-                else
-                    error.SetErrorString("could not get value");
-            }
-            else
-                error.SetErrorString("could not get target");
-        }
+            error.SetErrorString ("could not resolve value");
     }
-    error.SetErrorString("invalid SBValue");
+    else
+        error.SetErrorStringWithFormat ("could not get SBValue: %s", locker.GetError().AsCString());
+    
     return fail_value;
 }
 
@@ -1121,63 +1068,32 @@ uint64_t
 SBValue::GetValueAsUnsigned(SBError& error, uint64_t fail_value)
 {
     error.Clear();
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-            if (log)
-                log->Printf ("SBValue(%p)::GetValueAsUnsigned() => error: process is running", value_sp.get());
-            error.SetErrorString("process is running");
-        }
+        Scalar scalar;
+        if (value_sp->ResolveValue (scalar))
+            return scalar.ULongLong(fail_value);
         else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                Scalar scalar;
-                if (value_sp->ResolveValue (scalar))
-                    return scalar.GetRawBits64(fail_value);
-                else
-                    error.SetErrorString("could not get value");
-            }
-            else
-                error.SetErrorString("could not get target");
-        }
+            error.SetErrorString("could not resolve value");
     }
-    error.SetErrorString("invalid SBValue");
+    else
+        error.SetErrorStringWithFormat ("could not get SBValue: %s", locker.GetError().AsCString());
+    
     return fail_value;
 }
 
 int64_t
 SBValue::GetValueAsSigned(int64_t fail_value)
 {
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-            if (log)
-                log->Printf ("SBValue(%p)::GetValueAsSigned() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                Scalar scalar;
-                if (value_sp->ResolveValue (scalar))
-                    return scalar.GetRawBits64(fail_value);
-            }
-        }
+        Scalar scalar;
+        if (value_sp->ResolveValue (scalar))
+            return scalar.SLongLong(fail_value);
     }
     return fail_value;
 }
@@ -1185,63 +1101,46 @@ SBValue::GetValueAsSigned(int64_t fail_v
 uint64_t
 SBValue::GetValueAsUnsigned(uint64_t fail_value)
 {
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-            if (log)
-                log->Printf ("SBValue(%p)::GetValueAsUnsigned() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                Scalar scalar;
-                if (value_sp->ResolveValue (scalar))
-                    return scalar.GetRawBits64(fail_value);
-            }
-        }
+        Scalar scalar;
+        if (value_sp->ResolveValue (scalar))
+            return scalar.ULongLong(fail_value);
     }
     return fail_value;
 }
 
+bool
+SBValue::MightHaveChildren ()
+{
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    bool has_children = false;
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
+    if (value_sp)
+        has_children = value_sp->MightHaveChildren();
+    
+    if (log)
+        log->Printf ("SBValue(%p)::MightHaveChildren() => %i", value_sp.get(), has_children);
+    return has_children;
+}
+
 uint32_t
 SBValue::GetNumChildren ()
 {
     uint32_t num_children = 0;
-
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-    lldb::ValueObjectSP value_sp(GetSP());
+    
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
-    {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            if (log)
-                log->Printf ("SBValue(%p)::GetNumChildren() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp(value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-
-                num_children = value_sp->GetNumChildren();
-            }
-        }
-    }
-
+        num_children = value_sp->GetNumChildren();
+    
     if (log)
         log->Printf ("SBValue(%p)::GetNumChildren () => %u", value_sp.get(), num_children);
-
+    
     return num_children;
 }
 
@@ -1250,22 +1149,17 @@ SBValue
 SBValue::Dereference ()
 {
     SBValue sb_value;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        TargetSP target_sp(value_sp->GetTargetSP());
-        if (target_sp)
-        {
-            Mutex::Locker api_locker (target_sp->GetAPIMutex());
-
-            Error error;
-            sb_value = value_sp->Dereference (error);
-        }
+        Error error;
+        sb_value = value_sp->Dereference (error);
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)", value_sp.get(), value_sp.get());
-
+    
     return sb_value;
 }
 
@@ -1273,41 +1167,27 @@ bool
 SBValue::TypeIsPointerType ()
 {
     bool is_ptr_type = false;
-
-    lldb::ValueObjectSP value_sp(GetSP());
+    
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
-    {
-        TargetSP target_sp(value_sp->GetTargetSP());
-        if (target_sp)
-        {
-            Mutex::Locker api_locker (target_sp->GetAPIMutex());
-
-            is_ptr_type = value_sp->IsPointerType();
-        }
-    }
-
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+        is_ptr_type = value_sp->IsPointerType();
+    
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBValue(%p)::TypeIsPointerType () => %i", value_sp.get(), is_ptr_type);
-
-
+    
+    
     return is_ptr_type;
 }
 
 void *
 SBValue::GetOpaqueType()
 {
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
-    {
-        TargetSP target_sp(value_sp->GetTargetSP());
-        if (target_sp)
-        {
-            Mutex::Locker api_locker (target_sp->GetAPIMutex());
-
-            return value_sp->GetClangType();
-        }
-    }
+        return value_sp->GetClangType();
     return NULL;
 }
 
@@ -1316,19 +1196,18 @@ SBValue::GetTarget()
 {
     SBTarget sb_target;
     TargetSP target_sp;
-    lldb::ValueObjectSP value_sp(GetSP());
-    if (value_sp)
+    if (m_opaque_sp)
     {
-        target_sp = value_sp->GetTargetSP();
+        target_sp = m_opaque_sp->GetTargetSP();
         sb_target.SetSP (target_sp);
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         if (target_sp.get() == NULL)
-            log->Printf ("SBValue(%p)::GetTarget () => NULL", value_sp.get());
+            log->Printf ("SBValue(%p)::GetTarget () => NULL", m_opaque_sp.get());
         else
-            log->Printf ("SBValue(%p)::GetTarget () => %p", value_sp.get(), target_sp.get());
+            log->Printf ("SBValue(%p)::GetTarget () => %p", m_opaque_sp.get(), target_sp.get());
     }
     return sb_target;
 }
@@ -1338,20 +1217,18 @@ SBValue::GetProcess()
 {
     SBProcess sb_process;
     ProcessSP process_sp;
-    lldb::ValueObjectSP value_sp(GetSP());
-    if (value_sp)
+    if (m_opaque_sp)
     {
-        process_sp = value_sp->GetProcessSP();
-        if (process_sp)
-            sb_process.SetSP (process_sp);
+        process_sp = m_opaque_sp->GetProcessSP();
+        sb_process.SetSP (process_sp);
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         if (process_sp.get() == NULL)
-            log->Printf ("SBValue(%p)::GetProcess () => NULL", value_sp.get());
+            log->Printf ("SBValue(%p)::GetProcess () => NULL", m_opaque_sp.get());
         else
-            log->Printf ("SBValue(%p)::GetProcess () => %p", value_sp.get(), process_sp.get());
+            log->Printf ("SBValue(%p)::GetProcess () => %p", m_opaque_sp.get(), process_sp.get());
     }
     return sb_process;
 }
@@ -1361,19 +1238,18 @@ SBValue::GetThread()
 {
     SBThread sb_thread;
     ThreadSP thread_sp;
-    lldb::ValueObjectSP value_sp(GetSP());
-    if (value_sp)
+    if (m_opaque_sp)
     {
-        thread_sp = value_sp->GetThreadSP();
+        thread_sp = m_opaque_sp->GetThreadSP();
         sb_thread.SetThread(thread_sp);
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         if (thread_sp.get() == NULL)
-            log->Printf ("SBValue(%p)::GetThread () => NULL", value_sp.get());
+            log->Printf ("SBValue(%p)::GetThread () => NULL", m_opaque_sp.get());
         else
-            log->Printf ("SBValue(%p)::GetThread () => %p", value_sp.get(), thread_sp.get());
+            log->Printf ("SBValue(%p)::GetThread () => %p", m_opaque_sp.get(), thread_sp.get());
     }
     return sb_thread;
 }
@@ -1383,43 +1259,116 @@ SBValue::GetFrame()
 {
     SBFrame sb_frame;
     StackFrameSP frame_sp;
-    lldb::ValueObjectSP value_sp(GetSP());
-    if (value_sp)
+    if (m_opaque_sp)
     {
-        frame_sp = value_sp->GetFrameSP();
+        frame_sp = m_opaque_sp->GetFrameSP();
         sb_frame.SetFrameSP (frame_sp);
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
         if (frame_sp.get() == NULL)
-            log->Printf ("SBValue(%p)::GetFrame () => NULL", value_sp.get());
+            log->Printf ("SBValue(%p)::GetFrame () => NULL", m_opaque_sp.get());
         else
-            log->Printf ("SBValue(%p)::GetFrame () => %p", value_sp.get(), frame_sp.get());
+            log->Printf ("SBValue(%p)::GetFrame () => %p", m_opaque_sp.get(), frame_sp.get());
     }
     return sb_frame;
 }
 
 
 lldb::ValueObjectSP
+SBValue::GetSP (ValueLocker &locker) const
+{
+    if (!m_opaque_sp || !m_opaque_sp->IsValid())
+        return ValueObjectSP();
+    return locker.GetLockedSP(*m_opaque_sp.get());
+}
+
+lldb::ValueObjectSP
 SBValue::GetSP () const
 {
-    return m_opaque_sp;
+    ValueLocker locker;
+    return GetSP(locker);
+}
+
+void
+SBValue::SetSP (ValueImplSP impl_sp)
+{
+    m_opaque_sp = impl_sp;
 }
 
 void
 SBValue::SetSP (const lldb::ValueObjectSP &sp)
 {
-    m_opaque_sp = sp;
-    if (IsValid() && m_opaque_sp->HasSyntheticValue())
-        m_opaque_sp = m_opaque_sp->GetSyntheticValue();
+    if (sp)
+    {
+        lldb::TargetSP target_sp(sp->GetTargetSP());
+        if (target_sp)
+        {
+            lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
+            bool use_synthetic = target_sp->TargetProperties::GetEnableSyntheticValue();
+            m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
+        }
+        else
+            m_opaque_sp = ValueImplSP(new ValueImpl(sp,eNoDynamicValues,true));
+    }
+    else
+        m_opaque_sp = ValueImplSP(new ValueImpl(sp,eNoDynamicValues,false));
+}
+
+void
+SBValue::SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic)
+{
+    if (sp)
+    {
+        lldb::TargetSP target_sp(sp->GetTargetSP());
+        if (target_sp)
+        {
+            bool use_synthetic = target_sp->TargetProperties::GetEnableSyntheticValue();
+            SetSP (sp, use_dynamic, use_synthetic);
+        }
+        else
+            SetSP (sp, use_dynamic, true);
+    }
+    else
+        SetSP (sp, use_dynamic, false);
+}
+
+void
+SBValue::SetSP (const lldb::ValueObjectSP &sp, bool use_synthetic)
+{
+    if (sp)
+    {
+        lldb::TargetSP target_sp(sp->GetTargetSP());
+        if (target_sp)
+        {
+            lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
+            SetSP (sp, use_dynamic, use_synthetic);
+        }
+        else
+            SetSP (sp, eNoDynamicValues, use_synthetic);
+    }
+    else
+        SetSP (sp, eNoDynamicValues, use_synthetic);
+}
+
+void
+SBValue::SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic, bool use_synthetic)
+{
+    m_opaque_sp = ValueImplSP(new ValueImpl(sp,use_dynamic,use_synthetic));
 }
 
+void
+SBValue::SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, const char *name)
+{
+    m_opaque_sp = ValueImplSP(new ValueImpl(sp,use_dynamic,use_synthetic, name));
+}
 
 bool
 SBValue::GetExpressionPath (SBStream &description)
 {
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
         value_sp->GetExpressionPath (description.ref(), false);
@@ -1431,7 +1380,8 @@ SBValue::GetExpressionPath (SBStream &de
 bool
 SBValue::GetExpressionPath (SBStream &description, bool qualify_cxx_base_classes)
 {
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
         value_sp->GetExpressionPath (description.ref(), qualify_cxx_base_classes);
@@ -1444,33 +1394,24 @@ bool
 SBValue::GetDescription (SBStream &description)
 {
     Stream &strm = description.ref();
-
-    lldb::ValueObjectSP value_sp(GetSP());
+    
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-            if (log)
-                log->Printf ("SBValue(%p)::GetDescription() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            ValueObject::DumpValueObject (strm, value_sp.get());
-        }
+        ValueObject::DumpValueObject (strm, value_sp.get());
     }
     else
         strm.PutCString ("No value");
-
+    
     return true;
 }
 
 lldb::Format
 SBValue::GetFormat ()
 {
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
         return value_sp->GetFormat();
     return eFormatDefault;
@@ -1479,7 +1420,8 @@ SBValue::GetFormat ()
 void
 SBValue::SetFormat (lldb::Format format)
 {
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
         value_sp->SetFormat(format);
 }
@@ -1488,18 +1430,14 @@ lldb::SBValue
 SBValue::AddressOf()
 {
     SBValue sb_value;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        TargetSP target_sp (value_sp->GetTargetSP());
-        if (target_sp)
-        {
-            Mutex::Locker api_locker (target_sp->GetAPIMutex());
-            Error error;
-            sb_value = value_sp->AddressOf (error);
-        }
+        Error error;
+        sb_value.SetSP(value_sp->AddressOf (error),GetPreferDynamicValue(), GetPreferSyntheticValue());
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBValue(%p)::AddressOf () => SBValue(%p)", value_sp.get(), value_sp.get());
     
@@ -1510,13 +1448,13 @@ lldb::addr_t
 SBValue::GetLoadAddress()
 {
     lldb::addr_t value = LLDB_INVALID_ADDRESS;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
         TargetSP target_sp (value_sp->GetTargetSP());
         if (target_sp)
         {
-            Mutex::Locker api_locker (target_sp->GetAPIMutex());
             const bool scalar_is_load_address = true;
             AddressType addr_type;
             value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
@@ -1536,9 +1474,9 @@ SBValue::GetLoadAddress()
                 value = LLDB_INVALID_ADDRESS;
         }
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
-        log->Printf ("SBValue(%p)::GetLoadAddress () => (%llu)", value_sp.get(), value);
+        log->Printf ("SBValue(%p)::GetLoadAddress () => (%" PRIu64 ")", value_sp.get(), value);
     
     return value;
 }
@@ -1547,14 +1485,14 @@ lldb::SBAddress
 SBValue::GetAddress()
 {
     Address addr;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
         TargetSP target_sp (value_sp->GetTargetSP());
         if (target_sp)
         {
             lldb::addr_t value = LLDB_INVALID_ADDRESS;
-            Mutex::Locker api_locker (target_sp->GetAPIMutex());
             const bool scalar_is_load_address = true;
             AddressType addr_type;
             value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
@@ -1573,9 +1511,11 @@ SBValue::GetAddress()
             }
         }
     }
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
-        log->Printf ("SBValue(%p)::GetAddress () => (%s,%llu)", value_sp.get(), (addr.GetSection() ? addr.GetSection()->GetName().GetCString() : "NULL"), addr.GetOffset());
+        log->Printf ("SBValue(%p)::GetAddress () => (%s,%" PRIu64 ")", value_sp.get(),
+                     (addr.GetSection() ? addr.GetSection()->GetName().GetCString() : "NULL"),
+                     addr.GetOffset());
     return SBAddress(new Address(addr));
 }
 
@@ -1583,29 +1523,19 @@ lldb::SBData
 SBValue::GetPointeeData (uint32_t item_idx,
                          uint32_t item_count)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     lldb::SBData sb_data;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
+        TargetSP target_sp (value_sp->GetTargetSP());
+        if (target_sp)
         {
-            if (log)
-                log->Printf ("SBValue(%p)::GetPointeeData() => error: process is running", value_sp.get());
-        }
-        else
-        {
-            TargetSP target_sp (value_sp->GetTargetSP());
-            if (target_sp)
-            {
-                DataExtractorSP data_sp(new DataExtractor());
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                value_sp->GetPointeeData(*data_sp, item_idx, item_count);
-                if (data_sp->GetByteSize() > 0)
-                    *sb_data = data_sp;
-            }
+            DataExtractorSP data_sp(new DataExtractor());
+            value_sp->GetPointeeData(*data_sp, item_idx, item_count);
+            if (data_sp->GetByteSize() > 0)
+                *sb_data = data_sp;
         }
     }
     if (log)
@@ -1621,37 +1551,85 @@ SBValue::GetPointeeData (uint32_t item_i
 lldb::SBData
 SBValue::GetData ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     lldb::SBData sb_data;
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     if (value_sp)
     {
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
+        DataExtractorSP data_sp(new DataExtractor());
+        value_sp->GetData(*data_sp);
+        if (data_sp->GetByteSize() > 0)
+            *sb_data = data_sp;
+    }
+    if (log)
+        log->Printf ("SBValue(%p)::GetData () => SBData(%p)",
+                     value_sp.get(),
+                     sb_data.get());
+    
+    return sb_data;
+}
+
+bool
+SBValue::SetData (lldb::SBData &data, SBError &error)
+{
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
+    bool ret = true;
+    
+    if (value_sp)
+    {
+        DataExtractor *data_extractor = data.get();
+        
+        if (!data_extractor)
         {
             if (log)
-                log->Printf ("SBValue(%p)::GetData() => error: process is running", value_sp.get());
+                log->Printf ("SBValue(%p)::SetData() => error: no data to set", value_sp.get());
+            
+            error.SetErrorString("No data to set");
+            ret = false;
         }
         else
         {
-            TargetSP target_sp (value_sp->GetTargetSP());
-            if (target_sp)
+            Error set_error;
+            
+            value_sp->SetData(*data_extractor, set_error);
+            
+            if (!set_error.Success())
             {
-                Mutex::Locker api_locker (target_sp->GetAPIMutex());
-                DataExtractorSP data_sp(new DataExtractor());
-                value_sp->GetData(*data_sp);
-                if (data_sp->GetByteSize() > 0)
-                    *sb_data = data_sp;
+                error.SetErrorStringWithFormat("Couldn't set data: %s", set_error.AsCString());
+                ret = false;
             }
         }
     }
+    else
+    {
+        error.SetErrorStringWithFormat ("Couldn't set data: could not get SBValue: %s", locker.GetError().AsCString());
+        ret = false;
+    }
+    
     if (log)
-        log->Printf ("SBValue(%p)::GetData () => SBData(%p)",
+        log->Printf ("SBValue(%p)::SetData (%p) => %s",
                      value_sp.get(),
-                     sb_data.get());
-    
-    return sb_data;
+                     data.get(),
+                     ret ? "true" : "false");
+    return ret;
+}
+
+lldb::SBDeclaration
+SBValue::GetDeclaration ()
+{
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
+    SBDeclaration decl_sb;
+    if (value_sp)
+    {
+        Declaration decl;
+        if (value_sp->GetDeclaration(decl))
+            decl_sb.SetDeclaration(decl);
+    }
+    return decl_sb;
 }
 
 lldb::SBWatchpoint
@@ -1660,21 +1638,11 @@ SBValue::Watch (bool resolve_location, b
     SBWatchpoint sb_watchpoint;
     
     // If the SBValue is not valid, there's no point in even trying to watch it.
-    lldb::ValueObjectSP value_sp(GetSP());
+    ValueLocker locker;
+    lldb::ValueObjectSP value_sp(GetSP(locker));
     TargetSP target_sp (GetTarget().GetSP());
     if (value_sp && target_sp)
     {
-        // Can't watch this if the process is running
-        ProcessSP process_sp(value_sp->GetProcessSP());
-        Process::StopLocker stop_locker;
-        if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock()))
-        {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-            if (log)
-                log->Printf ("SBValue(%p)::Watch() => error: process is running", value_sp.get());
-            return sb_watchpoint;
-        }
-
         // Read and Write cannot both be false.
         if (!read && !write)
             return sb_watchpoint;
@@ -1689,7 +1657,7 @@ SBValue::Watch (bool resolve_location, b
         size_t byte_size = GetByteSize();
         if (byte_size == 0)
             return sb_watchpoint;
-                
+        
         uint32_t watch_type = 0;
         if (read)
             watch_type |= LLDB_WATCH_TYPE_READ;
@@ -1697,16 +1665,17 @@ SBValue::Watch (bool resolve_location, b
             watch_type |= LLDB_WATCH_TYPE_WRITE;
         
         Error rc;
-        WatchpointSP watchpoint_sp = target_sp->CreateWatchpoint(addr, byte_size, watch_type, rc);
+        ClangASTType type (value_sp->GetClangAST(), value_sp->GetClangType());
+        WatchpointSP watchpoint_sp = target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc);
         error.SetError(rc);
-                
-        if (watchpoint_sp) 
+        
+        if (watchpoint_sp)
         {
             sb_watchpoint.SetSP (watchpoint_sp);
             Declaration decl;
             if (value_sp->GetDeclaration (decl))
             {
-                if (decl.GetFile()) 
+                if (decl.GetFile())
                 {
                     StreamString ss;
                     // True to show fullpath for declaration file.
@@ -1716,6 +1685,22 @@ SBValue::Watch (bool resolve_location, b
             }
         }
     }
+    else if (target_sp)
+    {
+        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+        if (log)
+            log->Printf ("SBValue(%p)::Watch() => error getting SBValue: %s", value_sp.get(), locker.GetError().AsCString());
+        
+        error.SetErrorStringWithFormat("could not get SBValue: %s", locker.GetError().AsCString());
+    }
+    else
+    {
+        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+        if (log)
+            log->Printf ("SBValue(%p)::Watch() => error getting SBValue: no target", value_sp.get());
+        error.SetErrorString("could not set watchpoint, a target is required");
+    }
+    
     return sb_watchpoint;
 }
 
@@ -1736,4 +1721,3 @@ SBValue::WatchPointee (bool resolve_loca
         sb_watchpoint = Dereference().Watch (resolve_location, read, write, error);
     return sb_watchpoint;
 }
-

Modified: lldb/branches/lldb-platform-work/source/API/SBValueList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBValueList.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBValueList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBValueList.cpp Thu Jun  6 19:06:43 2013
@@ -14,9 +14,75 @@
 #include "lldb/Core/Log.h"
 #include "lldb/Core/ValueObjectList.h"
 
+#include <vector>
+
 using namespace lldb;
 using namespace lldb_private;
 
+class ValueListImpl
+{
+public:
+    ValueListImpl () :
+    m_values()
+    {
+    }
+    
+    ValueListImpl (const ValueListImpl& rhs) :
+    m_values(rhs.m_values)
+    {
+    }
+    
+    ValueListImpl&
+    operator = (const ValueListImpl& rhs)
+    {
+        if (this == &rhs)
+            return *this;
+        m_values = rhs.m_values;
+        return *this;
+    };
+    
+    uint32_t
+    GetSize ()
+    {
+        return m_values.size();
+    }
+    
+    void
+    Append (const lldb::SBValue& sb_value)
+    {
+        m_values.push_back(sb_value);
+    }
+    
+    void
+    Append (const ValueListImpl& list)
+    {
+        for (auto val : list.m_values)
+            Append (val);
+    }
+    
+    lldb::SBValue
+    GetValueAtIndex (uint32_t index)
+    {
+        if (index >= GetSize())
+            return lldb::SBValue();
+        return m_values[index];
+    }
+    
+    lldb::SBValue
+    FindValueByUID (lldb::user_id_t uid)
+    {
+        for (auto val : m_values)
+        {
+            if (val.IsValid() && val.GetID() == uid)
+                return val;
+        }
+        return lldb::SBValue();
+    }
+
+private:
+    std::vector<lldb::SBValue> m_values;
+};
+
 SBValueList::SBValueList () :
     m_opaque_ap ()
 {
@@ -25,10 +91,10 @@ SBValueList::SBValueList () :
 SBValueList::SBValueList (const SBValueList &rhs) :
     m_opaque_ap ()
 {
-    LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     if (rhs.IsValid())
-        m_opaque_ap.reset (new ValueObjectList (*rhs));
+        m_opaque_ap.reset (new ValueListImpl (*rhs));
 
     if (log)
     {
@@ -38,13 +104,13 @@ SBValueList::SBValueList (const SBValueL
     }
 }
 
-SBValueList::SBValueList (const ValueObjectList *lldb_object_ptr) :
+SBValueList::SBValueList (const ValueListImpl *lldb_object_ptr) :
     m_opaque_ap ()
 {
-    LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     if (lldb_object_ptr)
-        m_opaque_ap.reset (new ValueObjectList (*lldb_object_ptr));
+        m_opaque_ap.reset (new ValueListImpl (*lldb_object_ptr));
 
     if (log)
     {
@@ -76,32 +142,32 @@ SBValueList::operator = (const SBValueLi
     if (this != &rhs)
     {
         if (rhs.IsValid())
-            m_opaque_ap.reset (new ValueObjectList (*rhs));
+            m_opaque_ap.reset (new ValueListImpl (*rhs));
         else
             m_opaque_ap.reset ();
     }
     return *this;
 }
 
-ValueObjectList *
+ValueListImpl *
 SBValueList::operator->()
 {
     return m_opaque_ap.get();
 }
 
-ValueObjectList &
+ValueListImpl &
 SBValueList::operator*()
 {
     return *m_opaque_ap;
 }
 
-const ValueObjectList *
+const ValueListImpl *
 SBValueList::operator->() const
 {
     return m_opaque_ap.get();
 }
 
-const ValueObjectList &
+const ValueListImpl &
 SBValueList::operator*() const
 {
     return *m_opaque_ap;
@@ -110,12 +176,8 @@ SBValueList::operator*() const
 void
 SBValueList::Append (const SBValue &val_obj)
 {
-    ValueObjectSP value_sp (val_obj.GetSP());
-    if (value_sp)
-    {
-        CreateIfNeeded ();
-        m_opaque_ap->Append (value_sp);
-    }
+    CreateIfNeeded ();
+    m_opaque_ap->Append (val_obj);
 }
 
 void
@@ -124,7 +186,7 @@ SBValueList::Append (lldb::ValueObjectSP
     if (val_obj_sp)
     {
         CreateIfNeeded ();
-        m_opaque_ap->Append (val_obj_sp);
+        m_opaque_ap->Append (SBValue(val_obj_sp));
     }
 }
 
@@ -142,25 +204,21 @@ SBValueList::Append (const lldb::SBValue
 SBValue
 SBValueList::GetValueAtIndex (uint32_t idx) const
 {
-    LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     //if (log)
     //    log->Printf ("SBValueList::GetValueAtIndex (uint32_t idx) idx = %d", idx);
 
     SBValue sb_value;
-    ValueObjectSP value_sp;
     if (m_opaque_ap.get())
-    {
-        value_sp = m_opaque_ap->GetValueObjectAtIndex (idx);
-        sb_value.SetSP (value_sp);
-    }
+        sb_value = m_opaque_ap->GetValueAtIndex (idx);
 
     if (log)
     {
         SBStream sstr;
         sb_value.GetDescription (sstr);
         log->Printf ("SBValueList::GetValueAtIndex (this.ap=%p, idx=%d) => SBValue (this.sp = %p, '%s')", 
-                     m_opaque_ap.get(), idx, value_sp.get(), sstr.GetData());
+                     m_opaque_ap.get(), idx, sb_value.GetSP().get(), sstr.GetData());
     }
 
     return sb_value;
@@ -169,7 +227,7 @@ SBValueList::GetValueAtIndex (uint32_t i
 uint32_t
 SBValueList::GetSize () const
 {
-    LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     //if (log)
     //    log->Printf ("SBValueList::GetSize ()");
@@ -188,7 +246,7 @@ void
 SBValueList::CreateIfNeeded ()
 {
     if (m_opaque_ap.get() == NULL)
-        m_opaque_ap.reset (new ValueObjectList());
+        m_opaque_ap.reset (new ValueListImpl());
 }
 
 
@@ -197,17 +255,17 @@ SBValueList::FindValueObjectByUID (lldb:
 {
     SBValue sb_value;
     if (m_opaque_ap.get())
-        sb_value.SetSP (m_opaque_ap->FindValueObjectByUID (uid));
+        sb_value = m_opaque_ap->FindValueByUID(uid);
     return sb_value;
 }
 
-ValueObjectList *
-SBValueList::get ()
+void *
+SBValueList::opaque_ptr ()
 {
     return m_opaque_ap.get();
 }
 
-ValueObjectList &
+ValueListImpl &
 SBValueList::ref ()
 {
     CreateIfNeeded();

Modified: lldb/branches/lldb-platform-work/source/API/SBWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/API/SBWatchpoint.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/API/SBWatchpoint.cpp (original)
+++ lldb/branches/lldb-platform-work/source/API/SBWatchpoint.cpp Thu Jun  6 19:06:43 2013
@@ -11,6 +11,7 @@
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBEvent.h"
 #include "lldb/API/SBStream.h"
 
 #include "lldb/lldb-types.h"
@@ -34,7 +35,7 @@ SBWatchpoint::SBWatchpoint () :
 SBWatchpoint::SBWatchpoint (const lldb::WatchpointSP &wp_sp) :
     m_opaque_sp (wp_sp)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     if (log)
     {
@@ -66,7 +67,7 @@ SBWatchpoint::~SBWatchpoint ()
 watch_id_t
 SBWatchpoint::GetID ()
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     watch_id_t watch_id = LLDB_INVALID_WATCH_ID;
     lldb::WatchpointSP watchpoint_sp(GetSP());
@@ -182,7 +183,7 @@ SBWatchpoint::GetHitCount ()
         count = watchpoint_sp->GetHitCount();
     }
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
         log->Printf ("SBWatchpoint(%p)::GetHitCount () => %u", watchpoint_sp.get(), count);
 
@@ -271,3 +272,27 @@ SBWatchpoint::SetSP (const lldb::Watchpo
 {
     m_opaque_sp = sp;
 }
+
+bool
+SBWatchpoint::EventIsWatchpointEvent (const lldb::SBEvent &event)
+{
+    return Watchpoint::WatchpointEventData::GetEventDataFromEvent(event.get()) != NULL;
+
+}
+
+WatchpointEventType
+SBWatchpoint::GetWatchpointEventTypeFromEvent (const SBEvent& event)
+{
+    if (event.IsValid())
+        return Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent (event.GetSP());
+    return eWatchpointEventTypeInvalidType;
+}
+
+SBWatchpoint
+SBWatchpoint::GetWatchpointFromEvent (const lldb::SBEvent& event)
+{
+    SBWatchpoint sb_watchpoint;
+    if (event.IsValid())
+        sb_watchpoint.m_opaque_sp = Watchpoint::WatchpointEventData::GetWatchpointFromEvent (event.GetSP());
+    return sb_watchpoint;
+}

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/Breakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/Breakpoint.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/Breakpoint.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/Breakpoint.cpp Thu Jun  6 19:06:43 2013
@@ -22,6 +22,7 @@
 #include "lldb/Core/Log.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/SearchFilter.h"
+#include "lldb/Core/Section.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Core/StreamString.h"
 #include "lldb/Symbol/SymbolContext.h"
@@ -107,7 +108,7 @@ Breakpoint::FindLocationByID (break_id_t
 }
 
 BreakpointLocationSP
-Breakpoint::GetLocationAtIndex (uint32_t index)
+Breakpoint::GetLocationAtIndex (size_t index)
 {
     return m_locations.GetByIndex(index);
 }
@@ -188,6 +189,18 @@ Breakpoint::GetHitCount () const
     return m_locations.GetHitCount();
 }
 
+bool
+Breakpoint::IsOneShot () const
+{
+    return m_options.IsOneShot();
+}
+
+void
+Breakpoint::SetOneShot (bool one_shot)
+{
+    m_options.SetOneShot (one_shot);
+}
+
 void
 Breakpoint::SetThreadID (lldb::tid_t thread_id)
 {
@@ -229,7 +242,8 @@ Breakpoint::GetThreadIndex() const
 void
 Breakpoint::SetThreadName (const char *thread_name)
 {
-    if (::strcmp (m_options.GetThreadSpec()->GetName(), thread_name) == 0)
+    if (m_options.GetThreadSpec()->GetName() != NULL
+        && ::strcmp (m_options.GetThreadSpec()->GetName(), thread_name) == 0)
         return;
         
     m_options.GetThreadSpec()->SetName (thread_name);
@@ -248,7 +262,8 @@ Breakpoint::GetThreadName () const
 void 
 Breakpoint::SetQueueName (const char *queue_name)
 {
-    if (::strcmp (m_options.GetThreadSpec()->GetQueueName(), queue_name) == 0)
+    if (m_options.GetThreadSpec()->GetQueueName() != NULL
+        && ::strcmp (m_options.GetThreadSpec()->GetQueueName(), queue_name) == 0)
         return;
         
     m_options.GetThreadSpec()->SetQueueName (queue_name);
@@ -378,7 +393,7 @@ Breakpoint::ModulesChanged (ModuleList &
 
                     if (!break_loc->ResolveBreakpointSite())
                     {
-                        LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+                        Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
                         if (log)
                             log->Printf ("Warning: could not set breakpoint site for breakpoint location %d of breakpoint %d.\n",
                                          break_loc->GetID(), GetID());
@@ -511,22 +526,39 @@ void
 Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_locations)
 {
     assert (s != NULL);
-    s->Printf("%i: ", GetID());
-    GetResolverDescription (s);
-    GetFilterDescription (s);
-
+    
+    if (!m_kind_description.empty())
+    {
+        if (eDescriptionLevelBrief)
+        {
+            s->PutCString (GetBreakpointKind());
+            return;
+        }
+        else
+            s->Printf("Kind: %s\n", GetBreakpointKind ());
+    }
+    
     const size_t num_locations = GetNumLocations ();
     const size_t num_resolved_locations = GetNumResolvedLocations ();
-
+    
+    // They just made the breakpoint, they don't need to be told HOW they made it...
+    // Also, we'll print the breakpoint number differently depending on whether there is 1 or more locations.
+    if (level != eDescriptionLevelInitial)
+    {
+        s->Printf("%i: ", GetID());
+        GetResolverDescription (s);
+        GetFilterDescription (s);
+    }
+    
     switch (level)
     {
     case lldb::eDescriptionLevelBrief:
     case lldb::eDescriptionLevelFull:
         if (num_locations > 0)
         {
-            s->Printf(", locations = %zu", num_locations);
+            s->Printf(", locations = %" PRIu64, (uint64_t)num_locations);
             if (num_resolved_locations > 0)
-                s->Printf(", resolved = %zu", num_resolved_locations);
+                s->Printf(", resolved = %" PRIu64, (uint64_t)num_resolved_locations);
         }
         else
         {
@@ -544,7 +576,32 @@ Breakpoint::GetDescription (Stream *s, l
             s->EOL();
         }
         break;
-
+        
+    case lldb::eDescriptionLevelInitial:
+        s->Printf ("Breakpoint %i: ", GetID());
+        if (num_locations == 0)
+        {
+            s->Printf ("no locations (pending).");
+        }
+        else if (num_locations == 1)
+        {
+            // If there is one location only, we'll just print that location information.  But don't do this if
+            // show locations is true, then that will be handled below.
+            if (show_locations == false)
+            {
+                GetLocationAtIndex(0)->GetDescription(s, level);
+            }
+            else
+            {
+                s->Printf ("%zd locations.", num_locations);
+            }
+        }
+        else
+        {
+            s->Printf ("%zd locations.", num_locations);
+        }
+        s->EOL();
+        break;
     case lldb::eDescriptionLevelVerbose:
         // Verbose mode does a debug dump of the breakpoint
         Dump (s);
@@ -712,7 +769,7 @@ Breakpoint::BreakpointEventData::GetBrea
     return bp_sp;
 }
 
-uint32_t
+size_t
 Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent (const EventSP &event_sp)
 {
     const BreakpointEventData *data = GetEventDataFromEvent (event_sp.get());

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointID.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointID.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointID.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointID.cpp Thu Jun  6 19:06:43 2013
@@ -9,12 +9,15 @@
 
 
 // C Includes
+#include <stdio.h>
+
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
 
 #include "lldb/Breakpoint/BreakpointID.h"
 #include "lldb/Breakpoint/Breakpoint.h"
+#include "lldb/Core/Stream.h"
 
 using namespace lldb;
 using namespace lldb_private;

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointIDList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointIDList.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointIDList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointIDList.cpp Thu Jun  6 19:06:43 2013
@@ -38,7 +38,7 @@ BreakpointIDList::GetSize()
 }
 
 BreakpointID &
-BreakpointIDList::GetBreakpointIDAtIndex (uint32_t index)
+BreakpointIDList::GetBreakpointIDAtIndex (size_t index)
 {
     if (index < m_breakpoint_ids.size())
         return m_breakpoint_ids[index];
@@ -47,7 +47,7 @@ BreakpointIDList::GetBreakpointIDAtIndex
 }
 
 bool
-BreakpointIDList::RemoveBreakpointIDAtIndex (uint32_t index)
+BreakpointIDList::RemoveBreakpointIDAtIndex (size_t index)
 {
     if (index >= m_breakpoint_ids.size())
         return false;
@@ -89,10 +89,8 @@ BreakpointIDList::AddBreakpointID (const
 }
 
 bool
-BreakpointIDList::FindBreakpointID (BreakpointID &bp_id, uint32_t *position)
+BreakpointIDList::FindBreakpointID (BreakpointID &bp_id, size_t *position)
 {
-    BreakpointIDArray::iterator tmp_pos;
-
     for (size_t i = 0; i < m_breakpoint_ids.size(); ++i)
     {
         BreakpointID tmp_id = m_breakpoint_ids[i];
@@ -108,7 +106,7 @@ BreakpointIDList::FindBreakpointID (Brea
 }
 
 bool
-BreakpointIDList::FindBreakpointID (const char *bp_id_str, uint32_t *position)
+BreakpointIDList::FindBreakpointID (const char *bp_id_str, size_t *position)
 {
     BreakpointID temp_bp_id;
     break_id_t bp_id;
@@ -124,7 +122,7 @@ BreakpointIDList::FindBreakpointID (cons
 }
 
 void
-BreakpointIDList::InsertStringArray (const char **string_array, uint32_t array_size, CommandReturnObject &result)
+BreakpointIDList::InsertStringArray (const char **string_array, size_t array_size, CommandReturnObject &result)
 {
     if (string_array == NULL)
         return;
@@ -174,8 +172,8 @@ BreakpointIDList::FindAndReplaceIDRanges
         bool is_range = false;
         current_arg = old_args.GetArgumentAtIndex (i);
 
-        uint32_t range_start_len = 0;
-        uint32_t range_end_pos = 0;
+        size_t range_start_len = 0;
+        size_t range_end_pos = 0;
         if (BreakpointIDList::StringContainsIDRangeExpression (current_arg, &range_start_len, &range_end_pos))
         {
             is_range = true;
@@ -350,8 +348,8 @@ BreakpointIDList::FindAndReplaceIDRanges
 
 bool
 BreakpointIDList::StringContainsIDRangeExpression (const char *in_string, 
-                                                   uint32_t *range_start_len, 
-                                                   uint32_t *range_end_pos)
+                                                   size_t *range_start_len,
+                                                   size_t *range_end_pos)
 {
     bool is_range_expression = false;
     std::string arg_str = in_string;
@@ -368,7 +366,7 @@ BreakpointIDList::StringContainsIDRangeE
     for (int i = 0; i < specifiers_size && !is_range_expression; ++i)
     {
         const char *specifier_str = BreakpointID::g_range_specifiers[i];
-        int len = strlen (specifier_str);
+        size_t len = strlen (specifier_str);
         idx = arg_str.find (BreakpointID::g_range_specifiers[i]);
         if (idx != std::string::npos)
         {

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointList.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointList.cpp Thu Jun  6 19:06:43 2013
@@ -88,9 +88,14 @@ BreakpointList::RemoveAll (bool notify)
     {
         bp_collection::iterator pos, end = m_breakpoints.end();
         for (pos = m_breakpoints.begin(); pos != end; ++pos)
+        {
             if ((*pos)->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
+            {
                 (*pos)->GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged,
-                                                    new Breakpoint::BreakpointEventData (eBreakpointEventTypeRemoved, *pos));
+                                                    new Breakpoint::BreakpointEventData (eBreakpointEventTypeRemoved,
+                                                                                         *pos));
+            }
+        }
     }
     m_breakpoints.erase (m_breakpoints.begin(), m_breakpoints.end());
 }
@@ -167,13 +172,13 @@ BreakpointList::Dump (Stream *s) const
 
 
 BreakpointSP
-BreakpointList::GetBreakpointAtIndex (uint32_t i)
+BreakpointList::GetBreakpointAtIndex (size_t i)
 {
     Mutex::Locker locker(m_mutex);
     BreakpointSP stop_sp;
     bp_collection::iterator end = m_breakpoints.end();
     bp_collection::iterator pos;
-    uint32_t curr_i = 0;
+    size_t curr_i = 0;
     for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i)
     {
         if (curr_i == i)
@@ -183,13 +188,13 @@ BreakpointList::GetBreakpointAtIndex (ui
 }
 
 const BreakpointSP
-BreakpointList::GetBreakpointAtIndex (uint32_t i) const
+BreakpointList::GetBreakpointAtIndex (size_t i) const
 {
     Mutex::Locker locker(m_mutex);
     BreakpointSP stop_sp;
     bp_collection::const_iterator end = m_breakpoints.end();
     bp_collection::const_iterator pos;
-    uint32_t curr_i = 0;
+    size_t curr_i = 0;
     for (pos = m_breakpoints.begin(), curr_i = 0; pos != end; ++pos, ++curr_i)
     {
         if (curr_i == i)

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocation.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocation.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocation.cpp Thu Jun  6 19:06:43 2013
@@ -7,22 +7,26 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 // C Includes
 // C++ Includes
 #include <string>
 
 // Other libraries and framework includes
 // Project includes
+#include "lldb/lldb-private-log.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Breakpoint/BreakpointID.h"
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Target/Target.h"
-#include "lldb/Target/ThreadPlan.h"
 #include "lldb/Target/Process.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/lldb-private-log.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadSpec.h"
 
@@ -42,7 +46,8 @@ BreakpointLocation::BreakpointLocation
     m_address (addr),
     m_owner (owner),
     m_options_ap (),
-    m_bp_site_sp ()
+    m_bp_site_sp (),
+    m_condition_mutex ()
 {
     SetThreadID (tid);
     m_being_created = false;
@@ -236,9 +241,120 @@ BreakpointLocation::SetCondition (const
 }
 
 const char *
-BreakpointLocation::GetConditionText () const
+BreakpointLocation::GetConditionText (size_t *hash) const
 {
-    return GetOptionsNoCreate()->GetConditionText();
+    return GetOptionsNoCreate()->GetConditionText(hash);
+}
+
+bool
+BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error)
+{
+    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
+ 
+    Mutex::Locker evaluation_locker(m_condition_mutex);
+    
+    size_t condition_hash;
+    const char *condition_text = GetConditionText(&condition_hash);
+    
+    if (!condition_text)
+    {
+        m_user_expression_sp.reset();
+        return false;
+    }
+    
+    if (condition_hash != m_condition_hash ||
+        !m_user_expression_sp ||
+        !m_user_expression_sp->MatchesContext(exe_ctx))
+    {
+        m_user_expression_sp.reset(new ClangUserExpression(condition_text,
+                                                           NULL,
+                                                           lldb::eLanguageTypeUnknown,
+                                                           ClangUserExpression::eResultTypeAny));
+        
+        StreamString errors;
+        
+        if (!m_user_expression_sp->Parse(errors,
+                                         exe_ctx,
+                                         eExecutionPolicyOnlyWhenNeeded,
+                                         true))
+        {
+            error.SetErrorStringWithFormat("Couldn't parse conditional expression:\n%s",
+                                           errors.GetData());
+            m_user_expression_sp.reset();
+            return false;
+        }
+        
+        m_condition_hash = condition_hash;
+    }
+
+    // We need to make sure the user sees any parse errors in their condition, so we'll hook the
+    // constructor errors up to the debugger's Async I/O.
+        
+    ValueObjectSP result_value_sp;
+    const bool unwind_on_error = true;
+    const bool ignore_breakpoints = true;
+    const bool try_all_threads = true;
+    
+    Error expr_error;
+    
+    StreamString execution_errors;
+    
+    ClangExpressionVariableSP result_variable_sp;
+    
+    ExecutionResults result_code =
+    m_user_expression_sp->Execute(execution_errors,
+                                  exe_ctx,
+                                  unwind_on_error,
+                                  ignore_breakpoints,
+                                  m_user_expression_sp,
+                                  result_variable_sp,
+                                  try_all_threads,
+                                  ClangUserExpression::kDefaultTimeout);
+    
+    bool ret;
+    
+    if (result_code == eExecutionCompleted)
+    {
+        if (!result_variable_sp)
+        {
+            ret = false;
+            error.SetErrorString("Expression did not return a result");
+        }
+        
+        result_value_sp = result_variable_sp->GetValueObject();
+
+        if (result_value_sp)
+        {
+            Scalar scalar_value;
+            if (result_value_sp->ResolveValue (scalar_value))
+            {
+                if (scalar_value.ULongLong(1) == 0)
+                    ret = false;
+                else
+                    ret = true;
+                if (log)
+                    log->Printf("Condition successfully evaluated, result is %s.\n",
+                                ret ? "true" : "false");
+            }
+            else
+            {
+                ret = false;
+                error.SetErrorString("Failed to get an integer result from the expression");
+            }
+        }
+        else
+        {
+            ret = false;
+            error.SetErrorString("Failed to get any result from the expression");
+        }
+    }
+    else
+    {
+        ret = false;
+        error.SetErrorStringWithFormat("Couldn't execute expression:\n%s", execution_errors.GetData());
+    }
+    
+    return ret;
 }
 
 uint32_t
@@ -318,7 +434,7 @@ bool
 BreakpointLocation::ShouldStop (StoppointCallbackContext *context)
 {
     bool should_stop = true;
-    LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
+    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
 
     IncrementHitCount();
 
@@ -374,9 +490,9 @@ BreakpointLocation::ResolveBreakpointSit
 
     if (new_id == LLDB_INVALID_BREAK_ID)
     {
-        LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
+        Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
         if (log)
-            log->Warning ("Tried to add breakpoint site at 0x%llx but it was already present.\n",
+            log->Warning ("Tried to add breakpoint site at 0x%" PRIx64 " but it was already present.\n",
                           m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()));
         return false;
     }
@@ -408,13 +524,20 @@ void
 BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level)
 {
     SymbolContext sc;
-    s->Indent();
-    BreakpointID::GetCanonicalReference(s, m_owner.GetID(), GetID());
-
+    
+    // If the description level is "initial" then the breakpoint is printing out our initial state,
+    // and we should let it decide how it wants to print our label.
+    if (level != eDescriptionLevelInitial)
+    {
+        s->Indent();
+        BreakpointID::GetCanonicalReference(s, m_owner.GetID(), GetID());
+    }
+    
     if (level == lldb::eDescriptionLevelBrief)
         return;
 
-    s->PutCString(": ");
+    if (level != eDescriptionLevelInitial)
+        s->PutCString(": ");
 
     if (level == lldb::eDescriptionLevelVerbose)
         s->IndentMore();
@@ -423,7 +546,7 @@ BreakpointLocation::GetDescription (Stre
     {
         m_address.CalculateSymbolContext(&sc);
 
-        if (level == lldb::eDescriptionLevelFull)
+        if (level == lldb::eDescriptionLevelFull || level == eDescriptionLevelInitial)
         {
             s->PutCString("where = ");
             sc.DumpStopContext (s, m_owner.GetTarget().GetProcessSP().get(), m_address, false, true, false);
@@ -476,7 +599,11 @@ BreakpointLocation::GetDescription (Stre
         s->EOL();
         s->Indent();
     }
-    s->Printf ("%saddress = ", (level == lldb::eDescriptionLevelFull && m_address.IsSectionOffset()) ? ", " : "");
+    
+    if (m_address.IsSectionOffset() && (level == eDescriptionLevelFull || level == eDescriptionLevelInitial))
+        s->Printf (", ");
+    s->Printf ("address = ");
+    
     ExecutionContextScope *exe_scope = NULL;
     Target *target = &m_owner.GetTarget();
     if (target)
@@ -484,7 +611,10 @@ BreakpointLocation::GetDescription (Stre
     if (exe_scope == NULL)
         exe_scope = target;
 
-    m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress);
+    if (eDescriptionLevelInitial)
+        m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
+    else
+        m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress);
 
     if (level == lldb::eDescriptionLevelVerbose)
     {
@@ -503,7 +633,7 @@ BreakpointLocation::GetDescription (Stre
         }
         s->IndentLess();
     }
-    else
+    else if (level != eDescriptionLevelInitial)
     {
         s->Printf(", %sresolved, hit count = %u ",
                   (IsResolved() ? "" : "un"),
@@ -521,7 +651,7 @@ BreakpointLocation::Dump(Stream *s) cons
     if (s == NULL)
         return;
 
-    s->Printf("BreakpointLocation %u: tid = %4.4llx  load addr = 0x%8.8llx  state = %s  type = %s breakpoint  "
+    s->Printf("BreakpointLocation %u: tid = %4.4" PRIx64 "  load addr = 0x%8.8" PRIx64 "  state = %s  type = %s breakpoint  "
               "hw_index = %i  hit_count = %-4u  ignore_count = %-4u",
               GetID(),
               GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(),

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocationCollection.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocationCollection.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocationCollection.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocationCollection.cpp Thu Jun  6 19:06:43 2013
@@ -115,7 +115,7 @@ BreakpointLocationCollection::FindByIDPa
 }
 
 BreakpointLocationSP
-BreakpointLocationCollection::GetByIndex (uint32_t i)
+BreakpointLocationCollection::GetByIndex (size_t i)
 {
     BreakpointLocationSP stop_sp;
     if (i < m_break_loc_collection.size())
@@ -125,7 +125,7 @@ BreakpointLocationCollection::GetByIndex
 }
 
 const BreakpointLocationSP
-BreakpointLocationCollection::GetByIndex (uint32_t i) const
+BreakpointLocationCollection::GetByIndex (size_t i) const
 {
     BreakpointLocationSP stop_sp;
     if (i < m_break_loc_collection.size())
@@ -162,6 +162,25 @@ BreakpointLocationCollection::ValidForTh
     return false;
 }
 
+bool 
+BreakpointLocationCollection::IsInternal () const
+{
+    collection::const_iterator pos,
+        begin = m_break_loc_collection.begin(),
+        end = m_break_loc_collection.end();
+
+    bool is_internal = true;
+    
+    for (pos = begin; pos != end; ++pos)
+    {
+        if (!(*pos)->GetBreakpoint().IsInternal ())
+        {
+            is_internal = false;
+            break;
+        }
+    }
+    return is_internal;
+}
 
 void
 BreakpointLocationCollection::GetDescription (Stream *s, lldb::DescriptionLevel level)

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocationList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocationList.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocationList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointLocationList.cpp Thu Jun  6 19:06:43 2013
@@ -14,8 +14,7 @@
 // Project includes
 #include "lldb/Breakpoint/BreakpointLocationList.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/ModuleList.h"
-#include "lldb/Target/Target.h"
+#include "lldb/Core/Section.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -129,7 +128,7 @@ BreakpointLocationList::Dump (Stream *s)
     s->Printf("%p: ", this);
     //s->Indent();
     Mutex::Locker locker (m_mutex);
-    s->Printf("BreakpointLocationList with %zu BreakpointLocations:\n", m_locations.size());
+    s->Printf("BreakpointLocationList with %" PRIu64 " BreakpointLocations:\n", (uint64_t)m_locations.size());
     s->IndentMore();
     collection::const_iterator pos, end = m_locations.end();
     for (pos = m_locations.begin(); pos != end; ++pos)
@@ -139,7 +138,7 @@ BreakpointLocationList::Dump (Stream *s)
 
 
 BreakpointLocationSP
-BreakpointLocationList::GetByIndex (uint32_t i)
+BreakpointLocationList::GetByIndex (size_t i)
 {
     Mutex::Locker locker (m_mutex);
     BreakpointLocationSP bp_loc_sp;
@@ -150,7 +149,7 @@ BreakpointLocationList::GetByIndex (uint
 }
 
 const BreakpointLocationSP
-BreakpointLocationList::GetByIndex (uint32_t i) const
+BreakpointLocationList::GetByIndex (size_t i) const
 {
     Mutex::Locker locker (m_mutex);
     BreakpointLocationSP bp_loc_sp;

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointOptions.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointOptions.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointOptions.cpp Thu Jun  6 19:06:43 2013
@@ -39,9 +39,11 @@ BreakpointOptions::BreakpointOptions() :
     m_callback_baton_sp (),
     m_callback_is_synchronous (false),
     m_enabled (true),
+    m_one_shot (false),
     m_ignore_count (0),
-    m_thread_spec_ap (NULL),
-    m_condition_ap()
+    m_thread_spec_ap (),
+    m_condition_text (),
+    m_condition_text_hash (0)
 {
 }
 
@@ -53,14 +55,14 @@ BreakpointOptions::BreakpointOptions(con
     m_callback_baton_sp (rhs.m_callback_baton_sp),
     m_callback_is_synchronous (rhs.m_callback_is_synchronous),
     m_enabled (rhs.m_enabled),
+    m_one_shot (rhs.m_one_shot),
     m_ignore_count (rhs.m_ignore_count),
-    m_thread_spec_ap (NULL),
-    m_condition_ap (NULL)
+    m_thread_spec_ap ()
 {
     if (rhs.m_thread_spec_ap.get() != NULL)
         m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get()));
-    if (rhs.m_condition_ap.get())
-        m_condition_ap.reset (new ClangUserExpression (rhs.m_condition_ap->GetUserText(), NULL, lldb::eLanguageTypeUnknown, ClangUserExpression::eResultTypeAny));
+    m_condition_text = rhs.m_condition_text;
+    m_condition_text_hash = rhs.m_condition_text_hash;
 }
 
 //----------------------------------------------------------------------
@@ -73,11 +75,12 @@ BreakpointOptions::operator=(const Break
     m_callback_baton_sp = rhs.m_callback_baton_sp;
     m_callback_is_synchronous = rhs.m_callback_is_synchronous;
     m_enabled = rhs.m_enabled;
+    m_one_shot = rhs.m_one_shot;
     m_ignore_count = rhs.m_ignore_count;
     if (rhs.m_thread_spec_ap.get() != NULL)
         m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
-    if (rhs.m_condition_ap.get())
-        m_condition_ap.reset (new ClangUserExpression (rhs.m_condition_ap->GetUserText(), NULL, lldb::eLanguageTypeUnknown, ClangUserExpression::eResultTypeAny));
+    m_condition_text = rhs.m_condition_text;
+    m_condition_text_hash = rhs.m_condition_text_hash;
     return *this;
 }
 
@@ -159,51 +162,28 @@ BreakpointOptions::HasCallback ()
 void 
 BreakpointOptions::SetCondition (const char *condition)
 {
-    if (condition == NULL || condition[0] == '\0')
-    {
-        if (m_condition_ap.get())
-            m_condition_ap.reset();
-    }
-    else
-    {
-        m_condition_ap.reset(new ClangUserExpression (condition, NULL, lldb::eLanguageTypeUnknown, ClangUserExpression::eResultTypeAny));
-    }
+    if (!condition)
+        condition = "";
+    
+    m_condition_text.assign(condition);
+    std::hash<std::string> hasher;
+    m_condition_text_hash = hasher(m_condition_text);
 }
 
 const char *
-BreakpointOptions::GetConditionText () const
+BreakpointOptions::GetConditionText (size_t *hash) const
 {
-    if (m_condition_ap.get())
-        return m_condition_ap->GetUserText();
+    if (!m_condition_text.empty())
+    {
+        if (hash)
+            *hash = m_condition_text_hash;
+        
+        return m_condition_text.c_str();
+    }
     else
+    {
         return NULL;
-}
-
-//------------------------------------------------------------------
-// Enabled/Ignore Count
-//------------------------------------------------------------------
-bool
-BreakpointOptions::IsEnabled () const
-{
-    return m_enabled;
-}
-
-void
-BreakpointOptions::SetEnabled (bool enabled)
-{
-    m_enabled = enabled;
-}
-
-uint32_t
-BreakpointOptions::GetIgnoreCount () const
-{
-    return m_ignore_count;
-}
-
-void
-BreakpointOptions::SetIgnoreCount (uint32_t n)
-{
-    m_ignore_count = n;
+    }
 }
 
 const ThreadSpec *
@@ -234,7 +214,7 @@ BreakpointOptions::GetDescription (Strea
     // Figure out if there are any options not at their default value, and only print 
     // anything if there are:
     
-    if (m_ignore_count != 0 || !m_enabled || (GetThreadSpecNoCreate() != NULL && GetThreadSpecNoCreate()->HasSpecification ()))
+    if (m_ignore_count != 0 || !m_enabled || m_one_shot || (GetThreadSpecNoCreate() != NULL && GetThreadSpecNoCreate()->HasSpecification ()))
     {
         if (level == lldb::eDescriptionLevelVerbose)
         {
@@ -252,6 +232,9 @@ BreakpointOptions::GetDescription (Strea
             s->Printf("ignore: %d ", m_ignore_count);
         s->Printf("%sabled ", m_enabled ? "en" : "dis");
         
+        if (m_one_shot)
+            s->Printf ("one-shot ");
+        
         if (m_thread_spec_ap.get())
             m_thread_spec_ap->GetDescription (s, level);
         else if (level == eDescriptionLevelBrief)
@@ -271,12 +254,12 @@ BreakpointOptions::GetDescription (Strea
             m_callback_baton_sp->GetDescription (s, level);
         }
     }
-    if (m_condition_ap.get())
+    if (!m_condition_text.empty())
     {
        if (level != eDescriptionLevelBrief)
        {
             s->EOL();
-            s->Printf("Condition: %s\n", m_condition_ap->GetUserText());
+            s->Printf("Condition: %s\n", m_condition_text.c_str());
         }
     }    
 }

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverAddress.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverAddress.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverAddress.cpp Thu Jun  6 19:06:43 2013
@@ -83,7 +83,7 @@ BreakpointResolverAddress::SearchCallbac
         {
             StreamString s;
             bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+            Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
             if (log)
                 log->Printf ("Added location: %s\n", s.GetData());
         }

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverFileLine.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverFileLine.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverFileLine.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverFileLine.cpp Thu Jun  6 19:06:43 2013
@@ -15,8 +15,10 @@
 // Project includes
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/StreamString.h"
-#include "lldb/Target/Target.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/Function.h"
 #include "lldb/lldb-private-log.h"
 
 using namespace lldb;
@@ -57,7 +59,7 @@ BreakpointResolverFileLine::SearchCallba
     SymbolContextList sc_list;
 
     assert (m_breakpoint != NULL);
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
     
     // There is a tricky bit here.  You can have two compilation units that #include the same file, and
     // in one of them the function at m_line_number is used (and so code and a line entry for it is generated) but in the
@@ -71,8 +73,8 @@ BreakpointResolverFileLine::SearchCallba
     // So we go through the match list and pull out the sets that have the same file spec in their line_entry
     // and treat each set separately.
     
-    uint32_t num_comp_units = context.module_sp->GetNumCompileUnits();
-    for (uint32_t i = 0; i < num_comp_units; i++)
+    const size_t num_comp_units = context.module_sp->GetNumCompileUnits();
+    for (size_t i = 0; i < num_comp_units; i++)
     {
         CompUnitSP cu_sp (context.module_sp->GetCompileUnitAtIndex (i));
         if (cu_sp)
@@ -121,85 +123,101 @@ BreakpointResolverFileLine::SearchCallba
                 current_idx++;
         }
             
-        // Okay, we've found the closest line number match, now throw away all the others, 
+        // Okay, we've found the closest line number match, now throw away all the others:
+        
+        current_idx = 0;
+        while (current_idx < tmp_sc_list.GetSize())
+        {
+            if (tmp_sc_list.GetContextAtIndex(current_idx, sc))
+            {
+                if (sc.line_entry.line != closest_line_number)
+                    tmp_sc_list.RemoveContextAtIndex(current_idx);
+                else
+                    current_idx++;
+            }
+        }
+        
+        // Next go through and see if there are line table entries that are contiguous, and if so keep only the
+        // first of the contiguous range:
+        
+        lldb::addr_t last_end_addr = LLDB_INVALID_ADDRESS;
+        current_idx = 0;
+        while (current_idx < tmp_sc_list.GetSize())
+        {
+            if (tmp_sc_list.GetContextAtIndex(current_idx, sc))
+            {
+                lldb::addr_t start_file_addr = sc.line_entry.range.GetBaseAddress().GetFileAddress();
+                lldb::addr_t end_file_addr   = start_file_addr + sc.line_entry.range.GetByteSize();
+                
+                if (start_file_addr == last_end_addr)
+                    tmp_sc_list.RemoveContextAtIndex(current_idx);
+                else
+                    current_idx++;
+
+                last_end_addr = end_file_addr;
+            }
+        }
+        
         // and make breakpoints out of the closest line number match.
         
         uint32_t tmp_sc_list_size = tmp_sc_list.GetSize();
         
         for (uint32_t i = 0; i < tmp_sc_list_size; i++)
         {
-            SymbolContext sc;
             if (tmp_sc_list.GetContextAtIndex(i, sc))
             {
-                if (sc.line_entry.line == closest_line_number)
+                Address line_start = sc.line_entry.range.GetBaseAddress();
+                if (line_start.IsValid())
                 {
-                    Address line_start = sc.line_entry.range.GetBaseAddress();
-                    if (line_start.IsValid())
+                    if (filter.AddressPasses(line_start))
                     {
-                        if (filter.AddressPasses(line_start))
+                        // If the line number is before the prologue end, move it there...
+                        bool skipped_prologue = false;
+                        if (m_skip_prologue)
                         {
-                            // If the line number is before the prologue end, move it there...
-                            bool skipped_prologue = false;
-                            if (m_skip_prologue)
+                            if (sc.function)
                             {
-                                if (sc.function)
+                                Address prologue_addr(sc.function->GetAddressRange().GetBaseAddress());
+                                if (prologue_addr.IsValid() && (line_start == prologue_addr))
                                 {
-                                    Address prologue_addr(sc.function->GetAddressRange().GetBaseAddress());
-                                    if (prologue_addr.IsValid() && (line_start == prologue_addr))
+                                    const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
+                                    if (prologue_byte_size)
                                     {
-                                        const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
-                                        if (prologue_byte_size)
+                                        prologue_addr.Slide(prologue_byte_size);
+                 
+                                        if (filter.AddressPasses(prologue_addr))
                                         {
-                                            prologue_addr.Slide(prologue_byte_size);
-                     
-                                            if (filter.AddressPasses(prologue_addr))
-                                            {
-                                                skipped_prologue = true;
-                                                line_start = prologue_addr;
-                                            }
+                                            skipped_prologue = true;
+                                            line_start = prologue_addr;
                                         }
                                     }
                                 }
                             }
-                        
-                            BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start));
-                            if (log && bp_loc_sp && !m_breakpoint->IsInternal())
-                            {
-                                StreamString s;
-                                bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose);
-                                log->Printf ("Added location (skipped prologue: %s): %s \n", skipped_prologue ? "yes" : "no", s.GetData());
-                            }
                         }
-                        else if (log)
+                    
+                        BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start));
+                        if (log && bp_loc_sp && !m_breakpoint->IsInternal())
                         {
-                            log->Printf ("Breakpoint at file address 0x%llx for %s:%d didn't pass the filter.\n",
-                                         line_start.GetFileAddress(),
-                                         m_file_spec.GetFilename().AsCString("<Unknown>"),
-                                         m_line_number);
+                            StreamString s;
+                            bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose);
+                            log->Printf ("Added location (skipped prologue: %s): %s \n", skipped_prologue ? "yes" : "no", s.GetData());
                         }
                     }
-                    else
+                    else if (log)
                     {
-                        if (log)
-                            log->Printf ("error: Unable to set breakpoint at file address 0x%llx for %s:%d\n",
-                                         line_start.GetFileAddress(),
-                                         m_file_spec.GetFilename().AsCString("<Unknown>"),
-                                         m_line_number);
+                        log->Printf ("Breakpoint at file address 0x%" PRIx64 " for %s:%d didn't pass the filter.\n",
+                                     line_start.GetFileAddress(),
+                                     m_file_spec.GetFilename().AsCString("<Unknown>"),
+                                     m_line_number);
                     }
                 }
                 else
                 {
-        #if 0
-                    s << "error: Breakpoint at '" << pos->c_str() << "' isn't resolved yet: \n";
-                    if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionNameOffset))
-                        s.EOL();
-                    if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionPointerOffset))
-                        s.EOL();
-                    if (sc.line_entry.address.Dump(&s, Address::DumpStyleFileAddress))
-                        s.EOL();
-                    if (sc.line_entry.address.Dump(&s, Address::DumpStyleLoadAddress))
-                        s.EOL();
-        #endif
+                    if (log)
+                        log->Printf ("error: Unable to set breakpoint at file address 0x%" PRIx64 " for %s:%d\n",
+                                     line_start.GetFileAddress(),
+                                     m_file_spec.GetFilename().AsCString("<Unknown>"),
+                                     m_line_number);
                 }
             }
         }

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverFileRegex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverFileRegex.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverFileRegex.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverFileRegex.cpp Thu Jun  6 19:06:43 2013
@@ -17,6 +17,7 @@
 #include "lldb/Core/SourceManager.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/StreamString.h"
+#include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Target/Target.h"
 #include "lldb/lldb-private-log.h"
 
@@ -54,7 +55,7 @@ BreakpointResolverFileRegex::SearchCallb
     if (!context.target_sp)
         return eCallbackReturnContinue;
         
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
 
     CompileUnit *cu = context.comp_unit;
     FileSpec cu_file_spec = *(static_cast<FileSpec *>(cu));
@@ -91,7 +92,7 @@ BreakpointResolverFileRegex::SearchCallb
                 }
                 else if (log)
                 {
-                    log->Printf ("Breakpoint at file address 0x%llx for %s:%d didn't pass filter.\n",
+                    log->Printf ("Breakpoint at file address 0x%" PRIx64 " for %s:%d didn't pass filter.\n",
                                  line_start.GetFileAddress(),
                                  cu_file_spec.GetFilename().AsCString("<Unknown>"),
                                  line_matches[i]);
@@ -100,7 +101,7 @@ BreakpointResolverFileRegex::SearchCallb
             else
             {
                 if (log)
-                    log->Printf ("error: Unable to set breakpoint at file address 0x%llx for %s:%d\n",
+                    log->Printf ("error: Unable to set breakpoint at file address 0x%" PRIx64 " for %s:%d\n",
                                  line_start.GetFileAddress(),
                                  cu_file_spec.GetFilename().AsCString("<Unknown>"),
                                  line_matches[i]);

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverName.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverName.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointResolverName.cpp Thu Jun  6 19:06:43 2013
@@ -15,23 +15,24 @@
 // Project includes
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/StreamString.h"
 #include "lldb/Symbol/ClangNamespaceDecl.h"
-#include "lldb/Target/Target.h"
+#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/Symbol.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-BreakpointResolverName::BreakpointResolverName
-(
-    Breakpoint *bkpt,
-    const char *func_name,
-    uint32_t func_name_type_mask,
-    Breakpoint::MatchType type,
-    bool skip_prologue
-) :
+BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
+                                                const char *name_cstr,
+                                                uint32_t name_type_mask,
+                                                Breakpoint::MatchType type,
+                                                bool skip_prologue) :
     BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
-    m_func_name_type_mask (func_name_type_mask),
     m_class_name (),
     m_regex (),
     m_match_type (type),
@@ -40,17 +41,17 @@ BreakpointResolverName::BreakpointResolv
     
     if (m_match_type == Breakpoint::Regexp)
     {
-        if (!m_regex.Compile (func_name))
+        if (!m_regex.Compile (name_cstr))
         {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+            Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
 
             if (log)
-                log->Warning ("function name regexp: \"%s\" did not compile.", func_name);
+                log->Warning ("function name regexp: \"%s\" did not compile.", name_cstr);
         }
     }
     else
     {
-        m_func_names.push_back(ConstString(func_name));
+        AddNameLookup (ConstString(name_cstr), name_type_mask);
     }
 }
 
@@ -60,13 +61,12 @@ BreakpointResolverName::BreakpointResolv
                                                 uint32_t name_type_mask,
                                                 bool skip_prologue) :
     BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
-    m_func_name_type_mask (name_type_mask),
     m_match_type (Breakpoint::Exact),
     m_skip_prologue (skip_prologue)
 {
     for (size_t i = 0; i < num_names; i++)
     {
-        m_func_names.push_back (ConstString (names[i]));
+        AddNameLookup (ConstString (names[i]), name_type_mask);
     }
 }
 
@@ -75,24 +75,18 @@ BreakpointResolverName::BreakpointResolv
                                                 uint32_t name_type_mask,
                                                 bool skip_prologue) :
     BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
-    m_func_name_type_mask (name_type_mask),
     m_match_type (Breakpoint::Exact),
     m_skip_prologue (skip_prologue)
 {
-    size_t num_names = names.size();
-    
-    for (size_t i = 0; i < num_names; i++)
+    for (const std::string& name : names)
     {
-        m_func_names.push_back (ConstString (names[i].c_str()));
+        AddNameLookup (ConstString (name.c_str(), name.size()), name_type_mask);
     }
 }
 
-BreakpointResolverName::BreakpointResolverName
-(
-    Breakpoint *bkpt,
-    RegularExpression &func_regex,
-    bool skip_prologue
-) :
+BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt,
+                                                RegularExpression &func_regex,
+                                                bool skip_prologue) :
     BreakpointResolver (bkpt, BreakpointResolver::NameResolver),
     m_class_name (NULL),
     m_regex (func_regex),
@@ -115,13 +109,71 @@ BreakpointResolverName::BreakpointResolv
     m_match_type (type),
     m_skip_prologue (skip_prologue)
 {
-    m_func_names.push_back(ConstString(method));
+    LookupInfo lookup;
+    lookup.name.SetCString(method);
+    lookup.lookup_name = lookup.name;
+    lookup.name_type_mask = eFunctionNameTypeMethod;
+    lookup.match_name_after_lookup = false;
+    m_lookups.push_back (lookup);
 }
 
 BreakpointResolverName::~BreakpointResolverName ()
 {
 }
 
+void
+BreakpointResolverName::AddNameLookup (const ConstString &name, uint32_t name_type_mask)
+{
+    ObjCLanguageRuntime::MethodName objc_method(name.GetCString(), false);
+    if (objc_method.IsValid(false))
+    {
+        std::vector<ConstString> objc_names;
+        objc_method.GetFullNames(objc_names, true);
+        for (ConstString objc_name : objc_names)
+        {
+            LookupInfo lookup;
+            lookup.name = name;
+            lookup.lookup_name = objc_name;
+            lookup.name_type_mask = eFunctionNameTypeFull;
+            lookup.match_name_after_lookup = false;
+            m_lookups.push_back (lookup);
+        }
+    }
+    else
+    {
+        LookupInfo lookup;
+        lookup.name = name;
+        Module::PrepareForFunctionNameLookup(lookup.name, name_type_mask, lookup.lookup_name, lookup.name_type_mask, lookup.match_name_after_lookup);
+        m_lookups.push_back (lookup);
+    }
+}
+
+
+void
+BreakpointResolverName::LookupInfo::Prune (SymbolContextList &sc_list, size_t start_idx) const
+{
+    if (match_name_after_lookup && name)
+    {
+        SymbolContext sc;
+        size_t i = start_idx;
+        while (i < sc_list.GetSize())
+        {
+            if (!sc_list.GetContextAtIndex(i, sc))
+                break;
+            ConstString full_name (sc.GetFunctionName());
+            if (full_name && ::strstr(full_name.GetCString(), name.GetCString()) == NULL)
+            {
+                sc_list.RemoveContextAtIndex(i);
+            }
+            else
+            {
+                ++i;
+            }
+        }
+    }
+}
+
+
 // FIXME: Right now we look at the module level, and call the module's "FindFunctions".
 // Greg says he will add function tables, maybe at the CompileUnit level to accelerate function
 // lookup.  At that point, we should switch the depth to CompileUnit, and look in these tables.
@@ -140,11 +192,10 @@ BreakpointResolverName::SearchCallback
     
     uint32_t i;
     bool new_location;
-    SymbolContext sc;
     Address break_addr;
     assert (m_breakpoint != NULL);
     
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
     
     if (m_class_name)
     {
@@ -163,23 +214,29 @@ BreakpointResolverName::SearchCallback
         case Breakpoint::Exact:
             if (context.module_sp)
             {
-                size_t num_names = m_func_names.size();
-                for (int i = 0; i < num_names; i++)
+                for (const LookupInfo &lookup : m_lookups)
                 {
-                    uint32_t num_functions = context.module_sp->FindFunctions (m_func_names[i], 
-                                                                               NULL,
-                                                                               m_func_name_type_mask, 
-                                                                               include_symbols,
-                                                                               include_inlines, 
-                                                                               append, 
-                                                                               func_list);
+                    const size_t start_func_idx = func_list.GetSize();
+                    context.module_sp->FindFunctions (lookup.lookup_name,
+                                                      NULL,
+                                                      lookup.name_type_mask,
+                                                      include_symbols,
+                                                      include_inlines,
+                                                      append,
+                                                      func_list);
+                    const size_t end_func_idx = func_list.GetSize();
+
+                    if (start_func_idx < end_func_idx)
+                        lookup.Prune (func_list, start_func_idx);
                     // If the search filter specifies a Compilation Unit, then we don't need to bother to look in plain
                     // symbols, since all the ones from a set compilation unit will have been found above already.
-                    
-                    if (num_functions == 0 && !filter_by_cu)
+                    else if (!filter_by_cu)
                     {
-                        if (m_func_name_type_mask & (eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeAuto))
-                            context.module_sp->FindSymbolsWithNameAndType (m_func_names[i], eSymbolTypeCode, sym_list);
+                        const size_t start_symbol_idx = sym_list.GetSize();
+                        context.module_sp->FindFunctionSymbols (lookup.lookup_name, lookup.name_type_mask, sym_list);
+                        const size_t end_symbol_idx = sym_list.GetSize();
+                        if (start_symbol_idx < end_symbol_idx)
+                            lookup.Prune (func_list, start_symbol_idx);
                     }
                 }
             }
@@ -221,6 +278,7 @@ BreakpointResolverName::SearchCallback
     }
 
     // Remove any duplicates between the funcion list and the symbol list
+    SymbolContext sc;
     if (func_list.GetSize())
     {
         for (i = 0; i < func_list.GetSize(); i++)
@@ -338,17 +396,17 @@ BreakpointResolverName::GetDescription (
         s->Printf("regex = '%s'", m_regex.GetText());
     else
     {
-        size_t num_names = m_func_names.size();
+        size_t num_names = m_lookups.size();
         if (num_names == 1)
-            s->Printf("name = '%s'", m_func_names[0].AsCString());
+            s->Printf("name = '%s'", m_lookups[0].name.GetCString());
         else
         {
             s->Printf("names = {");
             for (size_t i = 0; i < num_names - 1; i++)
             {
-                s->Printf ("'%s', ", m_func_names[i].AsCString());
+                s->Printf ("'%s', ", m_lookups[i].name.GetCString());
             }
-            s->Printf ("'%s'}", m_func_names[num_names - 1].AsCString());
+            s->Printf ("'%s'}", m_lookups[num_names - 1].name.GetCString());
         }
     }
 }

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointSite.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointSite.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointSite.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointSite.cpp Thu Jun  6 19:06:43 2013
@@ -25,10 +25,9 @@ BreakpointSite::BreakpointSite
     BreakpointSiteList *list,
     const BreakpointLocationSP& owner,
     lldb::addr_t addr,
-    lldb::tid_t tid,
     bool use_hardware
 ) :
-    StoppointLocation(GetNextID(), addr, tid, use_hardware),
+    StoppointLocation(GetNextID(), addr, 0, use_hardware),
     m_type (eSoftware), // Process subclasses need to set this correctly using SetType()
     m_saved_opcode(),
     m_trap_opcode(),
@@ -83,7 +82,7 @@ BreakpointSite::Dump(Stream *s) const
     if (s == NULL)
         return;
 
-    s->Printf("BreakpointSite %u: addr = 0x%8.8llx  type = %s breakpoint  hw_index = %i  hit_count = %-4u",
+    s->Printf("BreakpointSite %u: addr = 0x%8.8" PRIx64 "  type = %s breakpoint  hw_index = %i  hit_count = %-4u",
             GetID(),
             (uint64_t)m_addr,
             IsHardware() ? "hardware" : "software",
@@ -95,10 +94,16 @@ void
 BreakpointSite::GetDescription (Stream *s, lldb::DescriptionLevel level)
 {
     if (level != lldb::eDescriptionLevelBrief)
-        s->Printf ("breakpoint site: %d at 0x%8.8llx", GetID(), GetLoadAddress());
+        s->Printf ("breakpoint site: %d at 0x%8.8" PRIx64, GetID(), GetLoadAddress());
     m_owners.GetDescription (s, level);
 }
 
+bool
+BreakpointSite::IsInternal() const
+{
+    return m_owners.IsInternal();
+}
+
 uint8_t *
 BreakpointSite::GetTrapOpcodeBytes()
 {
@@ -118,7 +123,7 @@ BreakpointSite::GetTrapOpcodeMaxByteSize
 }
 
 bool
-BreakpointSite::SetTrapOpcode (const uint8_t *trap_opcode, size_t trap_opcode_size)
+BreakpointSite::SetTrapOpcode (const uint8_t *trap_opcode, uint32_t trap_opcode_size)
 {
     if (trap_opcode_size > 0 && trap_opcode_size <= sizeof(m_trap_opcode))
     {
@@ -160,21 +165,21 @@ BreakpointSite::AddOwner (const Breakpoi
     m_owners.Add(owner);
 }
 
-uint32_t
+size_t
 BreakpointSite::RemoveOwner (lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
 {
     m_owners.Remove(break_id, break_loc_id);
     return m_owners.GetSize();
 }
 
-uint32_t
+size_t
 BreakpointSite::GetNumberOfOwners ()
 {
     return m_owners.GetSize();
 }
 
 BreakpointLocationSP
-BreakpointSite::GetOwnerAtIndex (uint32_t index)
+BreakpointSite::GetOwnerAtIndex (size_t index)
 {
     return m_owners.GetByIndex (index);
 }

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointSiteList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointSiteList.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointSiteList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/BreakpointSiteList.cpp Thu Jun  6 19:06:43 2013
@@ -69,10 +69,10 @@ BreakpointSiteList::FindIDByAddress (lld
     BreakpointSiteSP bp = FindByAddress (addr);
     if (bp)
     {
-        //DBLogIf(PD_LOG_BREAKPOINTS, "BreakpointSiteList::%s ( addr = 0x%8.8llx ) => %u", __FUNCTION__, (uint64_t)addr, bp->GetID());
+        //DBLogIf(PD_LOG_BREAKPOINTS, "BreakpointSiteList::%s ( addr = 0x%8.8" PRIx64 " ) => %u", __FUNCTION__, (uint64_t)addr, bp->GetID());
         return bp.get()->GetID();
     }
-    //DBLogIf(PD_LOG_BREAKPOINTS, "BreakpointSiteList::%s ( addr = 0x%8.8llx ) => NONE", __FUNCTION__, (uint64_t)addr);
+    //DBLogIf(PD_LOG_BREAKPOINTS, "BreakpointSiteList::%s ( addr = 0x%8.8" PRIx64 " ) => NONE", __FUNCTION__, (uint64_t)addr);
     return LLDB_INVALID_BREAK_ID;
 }
 
@@ -169,7 +169,7 @@ BreakpointSiteList::BreakpointSiteContai
 {
     collection::const_iterator pos = GetIDConstIterator(bp_site_id);
     if (pos != m_bp_site_list.end())
-        pos->second->IsBreakpointAtThisSite (bp_id);
+        return pos->second->IsBreakpointAtThisSite (bp_id);
 
     return false;
 }

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/Watchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/Watchpoint.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/Watchpoint.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/Watchpoint.cpp Thu Jun  6 19:06:43 2013
@@ -15,6 +15,10 @@
 // Project includes
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
 #include "lldb/Core/Stream.h"
+#include "lldb/Core/Value.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Core/ValueObjectMemory.h"
+#include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/ThreadSpec.h"
@@ -23,26 +27,45 @@
 using namespace lldb;
 using namespace lldb_private;
 
-Watchpoint::Watchpoint (lldb::addr_t addr, size_t size, bool hardware) :
+Watchpoint::Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const ClangASTType *type, bool hardware) :
     StoppointLocation (0, addr, size, hardware),
-    m_target(NULL),
+    m_target(target),
     m_enabled(false),
     m_is_hardware(hardware),
     m_is_watch_variable(false),
+    m_is_ephemeral(false),
+    m_disabled_count(0),
     m_watch_read(0),
     m_watch_write(0),
     m_watch_was_read(0),
     m_watch_was_written(0),
     m_ignore_count(0),
+    m_false_alarms(0),
     m_decl_str(),
     m_watch_spec_str(),
-    m_snapshot_old_str(),
-    m_snapshot_new_str(),
-    m_snapshot_old_val(0),
-    m_snapshot_new_val(0),
+    m_type(),
     m_error(),
-    m_options ()
+    m_options (),
+    m_being_created(true)
 {
+    if (type && type->IsValid())
+        m_type = *type;
+    else
+    {
+        // If we don't have a known type, then we force it to unsigned int of the right size.
+        ClangASTContext *ast_context = target.GetScratchClangASTContext();
+        clang_type_t clang_type = ast_context->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 8 * size);
+        m_type.SetClangType(ast_context->getASTContext(), clang_type);
+    }
+    
+    // Set the initial value of the watched variable:
+    if (m_target.GetProcessSP())
+    {
+        ExecutionContext exe_ctx;
+        m_target.GetProcessSP()->CalculateExecutionContext(exe_ctx);
+        CaptureWatchedValue (exe_ctx);
+    }
+    m_being_created = false;
 }
 
 Watchpoint::~Watchpoint()
@@ -57,7 +80,7 @@ Watchpoint::SetCallback (WatchpointHitCa
     // or delete it when it goes goes out of scope.
     m_options.SetCallback(callback, BatonSP (new Baton(baton)), is_synchronous);
     
-    //SendWatchpointChangedEvent (eWatchpointEventTypeCommandChanged);
+    SendWatchpointChangedEvent (eWatchpointEventTypeCommandChanged);
 }
 
 // This function is used when a baton needs to be freed and therefore is 
@@ -66,12 +89,14 @@ void
 Watchpoint::SetCallback (WatchpointHitCallback callback, const BatonSP &callback_baton_sp, bool is_synchronous)
 {
     m_options.SetCallback(callback, callback_baton_sp, is_synchronous);
+    SendWatchpointChangedEvent (eWatchpointEventTypeCommandChanged);
 }
 
 void
 Watchpoint::ClearCallback ()
 {
     m_options.ClearCallback ();
+    SendWatchpointChangedEvent (eWatchpointEventTypeCommandChanged);
 }
 
 void
@@ -94,60 +119,6 @@ Watchpoint::SetWatchSpec (const std::str
     return;
 }
 
-std::string
-Watchpoint::GetOldSnapshot() const
-{
-    return m_snapshot_old_str;
-}
-
-void
-Watchpoint::SetOldSnapshot (const std::string &str)
-{
-    m_snapshot_old_str = str;
-    return;
-}
-
-std::string
-Watchpoint::GetNewSnapshot() const
-{
-    return m_snapshot_new_str;
-}
-
-void
-Watchpoint::SetNewSnapshot (const std::string &str)
-{
-    m_snapshot_old_str = m_snapshot_new_str;
-    m_snapshot_new_str = str;
-    return;
-}
-
-uint64_t
-Watchpoint::GetOldSnapshotVal() const
-{
-    return m_snapshot_old_val;
-}
-
-void
-Watchpoint::SetOldSnapshotVal (uint64_t val)
-{
-    m_snapshot_old_val = val;
-    return;
-}
-
-uint64_t
-Watchpoint::GetNewSnapshotVal() const
-{
-    return m_snapshot_new_val;
-}
-
-void
-Watchpoint::SetNewSnapshotVal (uint64_t val)
-{
-    m_snapshot_old_val = m_snapshot_new_val;
-    m_snapshot_new_val = val;
-    return;
-}
-
 // Override default impl of StoppointLocation::IsHardware() since m_is_hardware
 // member field is more accurate.
 bool
@@ -168,6 +139,47 @@ Watchpoint::SetWatchVariable(bool val)
     m_is_watch_variable = val;
 }
 
+bool
+Watchpoint::CaptureWatchedValue (const ExecutionContext &exe_ctx)
+{
+    ConstString watch_name("$__lldb__watch_value");
+    m_old_value_sp = m_new_value_sp;
+    Address watch_address(GetLoadAddress());
+    if (!m_type.IsValid())
+    {
+        // Don't know how to report new & old values, since we couldn't make a scalar type for this watchpoint.
+        // This works around an assert in ValueObjectMemory::Create.
+        // FIXME: This should not happen, but if it does in some case we care about,
+        // we can go grab the value raw and print it as unsigned.
+        return false;
+    }
+    m_new_value_sp = ValueObjectMemory::Create (exe_ctx.GetBestExecutionContextScope(), watch_name.AsCString(), watch_address, m_type);
+    m_new_value_sp = m_new_value_sp->CreateConstantValue(watch_name);
+    if (m_new_value_sp && m_new_value_sp->GetError().Success())
+        return true;
+    else
+        return false;
+}
+
+void
+Watchpoint::IncrementFalseAlarmsAndReviseHitCount()
+{
+    ++m_false_alarms;
+    if (m_false_alarms)
+    {
+        if (m_hit_count >= m_false_alarms)
+        {
+            m_hit_count -= m_false_alarms;
+            m_false_alarms = 0;
+        }
+        else
+        {
+            m_false_alarms -= m_hit_count;
+            m_hit_count = 0;
+        }
+    }
+}
+
 // RETURNS - true if we should stop at this breakpoint, false if we
 // should continue.
 
@@ -198,21 +210,23 @@ Watchpoint::Dump(Stream *s) const
     DumpWithLevel(s, lldb::eDescriptionLevelBrief);
 }
 
+// If prefix is NULL, we display the watch id and ignore the prefix altogether.
 void
-Watchpoint::DumpSnapshots(const char *prefix, Stream *s) const
+Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const
 {
-    if (IsWatchVariable())
+    if (!prefix)
     {
-        if (!m_snapshot_old_str.empty())
-            s->Printf("\n%swatchpoint old value:\n\t%s", prefix, m_snapshot_old_str.c_str());
-        if (!m_snapshot_new_str.empty())
-            s->Printf("\n%swatchpoint new value:\n\t%s", prefix, m_snapshot_new_str.c_str());
+        s->Printf("\nWatchpoint %u hit:", GetID());
+        prefix = "";
     }
-    else
+    
+    if (m_old_value_sp)
+    {
+        s->Printf("\n%sold value: %s", prefix, m_old_value_sp->GetValueAsCString());
+    }
+    if (m_new_value_sp)
     {
-        uint32_t num_hex_digits = GetByteSize() * 2;
-        s->Printf("\n%swatchpoint old value:0x%0*.*llx", prefix, num_hex_digits, num_hex_digits, m_snapshot_old_val);
-        s->Printf("\n%swatchpoint new value:0x%0*.*llx", prefix, num_hex_digits, num_hex_digits, m_snapshot_new_val);
+        s->Printf("\n%snew value: %s", prefix, m_new_value_sp->GetValueAsCString());
     }
 }
 
@@ -225,7 +239,7 @@ Watchpoint::DumpWithLevel(Stream *s, lld
     assert(description_level >= lldb::eDescriptionLevelBrief &&
            description_level <= lldb::eDescriptionLevelVerbose);
 
-    s->Printf("Watchpoint %u: addr = 0x%8.8llx size = %u state = %s type = %s%s",
+    s->Printf("Watchpoint %u: addr = 0x%8.8" PRIx64 " size = %u state = %s type = %s%s",
               GetID(),
               GetLoadAddress(),
               m_byte_size,
@@ -240,7 +254,7 @@ Watchpoint::DumpWithLevel(Stream *s, lld
             s->Printf("\n    watchpoint spec = '%s'", m_watch_spec_str.c_str());
 
         // Dump the snapshots we have taken.
-        DumpSnapshots("   ", s);
+        DumpSnapshots(s, "    ");
 
         if (GetConditionText())
             s->Printf("\n    condition = '%s'", GetConditionText());
@@ -262,19 +276,58 @@ Watchpoint::IsEnabled() const
     return m_enabled;
 }
 
+// Within StopInfo.cpp, we purposely turn on the ephemeral mode right before temporarily disable the watchpoint
+// in order to perform possible watchpoint actions without triggering further watchpoint events.
+// After the temporary disabled watchpoint is enabled, we then turn off the ephemeral mode.
+
 void
-Watchpoint::SetEnabled(bool enabled)
+Watchpoint::TurnOnEphemeralMode()
+{
+    m_is_ephemeral = true;
+}
+
+void
+Watchpoint::TurnOffEphemeralMode()
+{
+    m_is_ephemeral = false;
+    // Leaving ephemeral mode, reset the m_disabled_count!
+    m_disabled_count = 0;
+}
+
+bool
+Watchpoint::IsDisabledDuringEphemeralMode()
+{
+    return m_disabled_count > 1;
+}
+
+void
+Watchpoint::SetEnabled(bool enabled, bool notify)
 {
     if (!enabled)
-        SetHardwareIndex(LLDB_INVALID_INDEX32);
+    {
+        if (!m_is_ephemeral)
+            SetHardwareIndex(LLDB_INVALID_INDEX32);
+        else
+            ++m_disabled_count;
+
+        // Don't clear the snapshots for now.
+        // Within StopInfo.cpp, we purposely do disable/enable watchpoint while performing watchpoint actions.
+    }
+    bool changed = enabled != m_enabled;
     m_enabled = enabled;
+    if (notify && !m_is_ephemeral && changed)
+        SendWatchpointChangedEvent (enabled ? eWatchpointEventTypeEnabled : eWatchpointEventTypeDisabled);
 }
 
 void
-Watchpoint::SetWatchpointType (uint32_t type)
+Watchpoint::SetWatchpointType (uint32_t type, bool notify)
 {
+    int old_watch_read = m_watch_read;
+    int old_watch_write = m_watch_write;
     m_watch_read = (type & LLDB_WATCH_TYPE_READ) != 0;
     m_watch_write = (type & LLDB_WATCH_TYPE_WRITE) != 0;
+    if (notify && (old_watch_read != m_watch_read || old_watch_write != m_watch_write))
+        SendWatchpointChangedEvent (eWatchpointEventTypeTypeChanged);
 }
 
 bool
@@ -296,7 +349,10 @@ Watchpoint::GetIgnoreCount () const
 void
 Watchpoint::SetIgnoreCount (uint32_t n)
 {
+    bool changed = m_ignore_count != n;
     m_ignore_count = n;
+    if (changed)
+        SendWatchpointChangedEvent (eWatchpointEventTypeIgnoreChanged);
 }
 
 bool
@@ -318,6 +374,7 @@ Watchpoint::SetCondition (const char *co
         // Pass NULL for expr_prefix (no translation-unit level definitions).
         m_condition_ap.reset(new ClangUserExpression (condition, NULL, lldb::eLanguageTypeUnknown, ClangUserExpression::eResultTypeAny));
     }
+    SendWatchpointChangedEvent (eWatchpointEventTypeConditionChanged);
 }
 
 const char *
@@ -329,3 +386,105 @@ Watchpoint::GetConditionText () const
         return NULL;
 }
 
+void
+Watchpoint::SendWatchpointChangedEvent (lldb::WatchpointEventType eventKind)
+{
+    if (!m_being_created
+        && GetTarget().EventTypeHasListeners(Target::eBroadcastBitWatchpointChanged))
+    {
+        WatchpointEventData *data = new Watchpoint::WatchpointEventData (eventKind, shared_from_this());
+        GetTarget().BroadcastEvent (Target::eBroadcastBitWatchpointChanged, data);
+    }
+}
+
+void
+Watchpoint::SendWatchpointChangedEvent (WatchpointEventData *data)
+{
+
+    if (data == NULL)
+        return;
+        
+    if (!m_being_created
+        && GetTarget().EventTypeHasListeners(Target::eBroadcastBitWatchpointChanged))
+        GetTarget().BroadcastEvent (Target::eBroadcastBitWatchpointChanged, data);
+    else
+        delete data;
+}
+
+Watchpoint::WatchpointEventData::WatchpointEventData (WatchpointEventType sub_type, 
+                                                      const WatchpointSP &new_watchpoint_sp) :
+    EventData (),
+    m_watchpoint_event (sub_type),
+    m_new_watchpoint_sp (new_watchpoint_sp)
+{
+}
+
+Watchpoint::WatchpointEventData::~WatchpointEventData ()
+{
+}
+
+const ConstString &
+Watchpoint::WatchpointEventData::GetFlavorString ()
+{
+    static ConstString g_flavor ("Watchpoint::WatchpointEventData");
+    return g_flavor;
+}
+
+const ConstString &
+Watchpoint::WatchpointEventData::GetFlavor () const
+{
+    return WatchpointEventData::GetFlavorString ();
+}
+
+
+WatchpointSP &
+Watchpoint::WatchpointEventData::GetWatchpoint ()
+{
+    return m_new_watchpoint_sp;
+}
+
+WatchpointEventType
+Watchpoint::WatchpointEventData::GetWatchpointEventType () const
+{
+    return m_watchpoint_event;
+}
+
+void
+Watchpoint::WatchpointEventData::Dump (Stream *s) const
+{
+}
+
+const Watchpoint::WatchpointEventData *
+Watchpoint::WatchpointEventData::GetEventDataFromEvent (const Event *event)
+{
+    if (event)
+    {
+        const EventData *event_data = event->GetData();
+        if (event_data && event_data->GetFlavor() == WatchpointEventData::GetFlavorString())
+            return static_cast <const WatchpointEventData *> (event->GetData());
+    }
+    return NULL;
+}
+
+WatchpointEventType
+Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent (const EventSP &event_sp)
+{
+    const WatchpointEventData *data = GetEventDataFromEvent (event_sp.get());
+
+    if (data == NULL)
+        return eWatchpointEventTypeInvalidType;
+    else
+        return data->GetWatchpointEventType();
+}
+
+WatchpointSP
+Watchpoint::WatchpointEventData::GetWatchpointFromEvent (const EventSP &event_sp)
+{
+    WatchpointSP wp_sp;
+
+    const WatchpointEventData *data = GetEventDataFromEvent (event_sp.get());
+    if (data)
+        wp_sp = data->m_new_watchpoint_sp;
+
+    return wp_sp;
+}

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/WatchpointList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/WatchpointList.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/WatchpointList.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/WatchpointList.cpp Thu Jun  6 19:06:43 2013
@@ -31,11 +31,17 @@ WatchpointList::~WatchpointList()
 
 // Add a watchpoint to the list.
 lldb::watch_id_t
-WatchpointList::Add (const WatchpointSP &wp_sp)
+WatchpointList::Add (const WatchpointSP &wp_sp, bool notify)
 {
     Mutex::Locker locker (m_mutex);
     wp_sp->SetID(++m_next_wp_id);
     m_watchpoints.push_back(wp_sp);
+    if (notify)
+    {
+        if (wp_sp->GetTarget().EventTypeHasListeners(Target::eBroadcastBitWatchpointChanged))
+            wp_sp->GetTarget().BroadcastEvent (Target::eBroadcastBitWatchpointChanged,
+                                               new Watchpoint::WatchpointEventData (eWatchpointEventTypeAdded, wp_sp));
+    }
     return wp_sp->GetID();
 }
 
@@ -51,8 +57,8 @@ WatchpointList::DumpWithLevel (Stream *s
     Mutex::Locker locker (m_mutex);
     s->Printf("%p: ", this);
     //s->Indent();
-    s->Printf("WatchpointList with %zu Watchpoints:\n",
-              m_watchpoints.size());
+    s->Printf("WatchpointList with %" PRIu64 " Watchpoints:\n",
+              (uint64_t)m_watchpoints.size());
     s->IndentMore();
     wp_collection::const_iterator pos, end = m_watchpoints.end();
     for (pos = m_watchpoints.begin(); pos != end; ++pos)
@@ -200,12 +206,19 @@ WatchpointList::GetWatchpointIDs() const
 }
 
 bool
-WatchpointList::Remove (lldb::watch_id_t watch_id)
+WatchpointList::Remove (lldb::watch_id_t watch_id, bool notify)
 {
     Mutex::Locker locker (m_mutex);
     wp_collection::iterator pos = GetIDIterator(watch_id);
     if (pos != m_watchpoints.end())
     {
+        WatchpointSP wp_sp = *pos;
+        if (notify)
+        {
+            if (wp_sp->GetTarget().EventTypeHasListeners(Target::eBroadcastBitWatchpointChanged))
+                wp_sp->GetTarget().BroadcastEvent (Target::eBroadcastBitWatchpointChanged,
+                                                   new Watchpoint::WatchpointEventData (eWatchpointEventTypeRemoved, wp_sp));
+        }
         m_watchpoints.erase(pos);
         return true;
     }
@@ -264,9 +277,25 @@ WatchpointList::SetEnabledAll (bool enab
 }
 
 void
-WatchpointList::RemoveAll ()
+WatchpointList::RemoveAll (bool notify)
 {
     Mutex::Locker locker(m_mutex);
+    if (notify)
+    {
+        
+        {
+            wp_collection::iterator pos, end = m_watchpoints.end();
+            for (pos = m_watchpoints.begin(); pos != end; ++pos)
+            {
+                if ((*pos)->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
+                {
+                    (*pos)->GetTarget().BroadcastEvent (Target::eBroadcastBitWatchpointChanged,
+                                                        new Watchpoint::WatchpointEventData (eWatchpointEventTypeRemoved,
+                                                                                             *pos));
+                }
+            }
+        }
+    }
     m_watchpoints.clear();
 }
 

Modified: lldb/branches/lldb-platform-work/source/Breakpoint/WatchpointOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Breakpoint/WatchpointOptions.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Breakpoint/WatchpointOptions.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Breakpoint/WatchpointOptions.cpp Thu Jun  6 19:06:43 2013
@@ -38,7 +38,7 @@ WatchpointOptions::WatchpointOptions() :
     m_callback (WatchpointOptions::NullCallback),
     m_callback_baton_sp (),
     m_callback_is_synchronous (false),
-    m_thread_spec_ap (NULL)
+    m_thread_spec_ap ()
 {
 }
 
@@ -49,7 +49,7 @@ WatchpointOptions::WatchpointOptions(con
     m_callback (rhs.m_callback),
     m_callback_baton_sp (rhs.m_callback_baton_sp),
     m_callback_is_synchronous (rhs.m_callback_is_synchronous),
-    m_thread_spec_ap (NULL)
+    m_thread_spec_ap ()
 {
     if (rhs.m_thread_spec_ap.get() != NULL)
         m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get()));

Copied: lldb/branches/lldb-platform-work/source/CMakeLists.txt (from r182522, lldb/trunk/source/CMakeLists.txt)
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/CMakeLists.txt?p2=lldb/branches/lldb-platform-work/source/CMakeLists.txt&p1=lldb/trunk/source/CMakeLists.txt&r1=182522&r2=183468&rev=183468&view=diff
==============================================================================
--- lldb/trunk/source/CMakeLists.txt (original)
+++ lldb/branches/lldb-platform-work/source/CMakeLists.txt Thu Jun  6 19:06:43 2013
@@ -7,6 +7,13 @@ include_directories(
   )
 endif ()
 
+if ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
+include_directories(
+  Plugins/Process/FreeBSD
+  Plugins/Process/POSIX
+  )
+endif ()
+
 add_subdirectory(API)
 add_subdirectory(Breakpoint)
 add_subdirectory(Commands)
@@ -85,12 +92,27 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
     )
 endif ()
 
+# FreeBSD-only libraries
+if ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
+  list(APPEND LLDB_USED_LIBS
+    lldbHostFreeBSD
+    lldbPluginProcessFreeBSD
+    lldbPluginProcessPOSIX
+    )
+endif ()
+
 # Darwin-only libraries
 if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
+  set(LLDB_VERS_GENERATED_FILE ${LLDB_BINARY_DIR}/source/LLDB_vers.c)
+  add_custom_command(OUTPUT ${LLDB_VERS_GENERATED_FILE}
+    COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
+            ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj
+            > ${LLDB_VERS_GENERATED_FILE})
+
+  set_source_files_properties(${LLDB_VERS_GENERATED_FILE} PROPERTIES GENERATED 1)
   list(APPEND LLDB_USED_LIBS
     lldbHostMacOSX
     lldbPluginDynamicLoaderDarwinKernel
-    lldbPluginOSDarwinKernel
     lldbPluginProcessMacOSXKernel
     lldbPluginSymbolVendorMacOSX
     )
@@ -143,13 +165,17 @@ add_lldb_library(liblldb
   lldb.cpp
   lldb-log.cpp
   ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp
+  ${LLDB_VERS_GENERATED_FILE}
   )
 set_target_properties(liblldb
   PROPERTIES
   OUTPUT_NAME lldb
   VERSION ${LLDB_VERSION}
   )
-add_dependencies(liblldb ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp)
+add_dependencies(liblldb
+  ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp
+  ${LLDB_VERS_GENERATED_FILE}
+  )
 target_link_libraries(liblldb ${LLDB_SYSTEM_LIBS})
 
 # Determine LLDB revision and repository. GetSourceVersion and GetRepositoryPath are shell-scripts, and as

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandCompletions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandCompletions.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandCompletions.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandCompletions.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
 
 // C Includes
 #include <sys/stat.h>
@@ -21,9 +22,12 @@
 #include "lldb/Host/FileSpec.h"
 #include "lldb/Core/FileSpecList.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Interpreter/CommandCompletions.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/Variable.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/CleanUp.h"
 
@@ -41,6 +45,7 @@ CommandCompletions::g_common_completions
     {eSettingsNameCompletion,    CommandCompletions::SettingsNames},
     {ePlatformPluginCompletion,  CommandCompletions::PlatformPluginNames},
     {eArchitectureCompletion,    CommandCompletions::ArchitectureNames},
+    {eVariablePathCompletion,    CommandCompletions::VariablePath},
     {eNoCompletion,              NULL}      // This one has to be last in the list.
 };
 
@@ -128,7 +133,7 @@ DiskFilesOrDirectories
     // I'm going to  use the "glob" function with GLOB_TILDE for user directory expansion.  
     // If it is not defined on your host system, you'll need to implement it yourself...
     
-    int partial_name_len = strlen(partial_file_name);
+    size_t partial_name_len = strlen(partial_file_name);
     
     if (partial_name_len >= PATH_MAX)
         return matches.GetSize();
@@ -405,15 +410,25 @@ CommandCompletions::SettingsNames (Comma
                                    bool &word_complete,
                                    StringList &matches)
 {
-    lldb::UserSettingsControllerSP root_settings = Debugger::GetSettingsController();
-    Args partial_setting_name_pieces = UserSettingsController::BreakNameIntoPieces (partial_setting_name);
-
-    return UserSettingsController::CompleteSettingsNames (root_settings,
-                                                          partial_setting_name_pieces,
-                                                          word_complete,
-                                                          matches);
-
-    //return matches.GetSize();
+    // Cache the full setting name list
+    static StringList g_property_names;
+    if (g_property_names.GetSize() == 0)
+    {
+        // Generate the full setting name list on demand
+        lldb::OptionValuePropertiesSP properties_sp (interpreter.GetDebugger().GetValueProperties());
+        if (properties_sp)
+        {
+            StreamString strm;
+            properties_sp->DumpValue(NULL, strm, OptionValue::eDumpOptionName);
+            const std::string &str = strm.GetString();
+            g_property_names.SplitIntoLines(str.c_str(), str.size());
+        }
+    }
+    
+    size_t exact_matches_idx = SIZE_MAX;
+    const size_t num_matches = g_property_names.AutoComplete (partial_setting_name, matches, exact_matches_idx);
+    word_complete = exact_matches_idx != SIZE_MAX;
+    return num_matches;
 }
 
 
@@ -446,6 +461,19 @@ CommandCompletions::ArchitectureNames (C
 }
 
 
+int
+CommandCompletions::VariablePath (CommandInterpreter &interpreter,
+                                  const char *partial_name,
+                                  int match_start_point,
+                                  int max_return_elements,
+                                  SearchFilter *searcher,
+                                  bool &word_complete,
+                                  lldb_private::StringList &matches)
+{
+    return Variable::AutoComplete (interpreter.GetExecutionContext(), partial_name, matches, word_complete);
+}
+
+
 CommandCompletions::Completer::Completer 
 (
     CommandInterpreter &interpreter,

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectApropos.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectApropos.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectApropos.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectApropos.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectApropos.h"
 
 // C Includes
@@ -54,7 +56,7 @@ CommandObjectApropos::~CommandObjectApro
 bool
 CommandObjectApropos::DoExecute (Args& args, CommandReturnObject &result)
 {
-    const int argc = args.GetArgumentCount ();
+    const size_t argc = args.GetArgumentCount ();
 
     if (argc == 1)
     {
@@ -66,47 +68,72 @@ CommandObjectApropos::DoExecute (Args& a
             // is private.
             StringList commands_found;
             StringList commands_help;
-            m_interpreter.FindCommandsForApropos (search_word, commands_found, commands_help);
-            if (commands_found.GetSize() == 0)
+            StringList user_commands_found;
+            StringList user_commands_help;
+            
+            m_interpreter.FindCommandsForApropos (search_word, commands_found, commands_help, true, false);
+            m_interpreter.FindCommandsForApropos (search_word, user_commands_found, user_commands_help, false, true);
+            
+            if (commands_found.GetSize() == 0 && user_commands_found.GetSize() == 0)
             {
                 result.AppendMessageWithFormat ("No commands found pertaining to '%s'. Try 'help' to see a complete list of debugger commands.\n", search_word);
             }
             else
             {
-                result.AppendMessageWithFormat ("The following commands may relate to '%s':\n", search_word);
-                size_t max_len = 0;
-
-                for (size_t i = 0; i < commands_found.GetSize(); ++i)
+                if (commands_found.GetSize() > 0)
                 {
-                    size_t len = strlen (commands_found.GetStringAtIndex (i));
-                    if (len > max_len)
-                        max_len = len;
+                    result.AppendMessageWithFormat ("The following built-in commands may relate to '%s':\n", search_word);
+                    size_t max_len = 0;
+
+                    for (size_t i = 0; i < commands_found.GetSize(); ++i)
+                    {
+                        size_t len = strlen (commands_found.GetStringAtIndex (i));
+                        if (len > max_len)
+                            max_len = len;
+                    }
+
+                    for (size_t i = 0; i < commands_found.GetSize(); ++i)
+                        m_interpreter.OutputFormattedHelpText (result.GetOutputStream(), 
+                                                               commands_found.GetStringAtIndex(i),
+                                                               "--",
+                                                               commands_help.GetStringAtIndex(i),
+                                                               max_len);
+                    if (user_commands_found.GetSize() > 0)
+                        result.AppendMessage("");
                 }
+                
+                if (user_commands_found.GetSize() > 0)
+                {
+                    result.AppendMessageWithFormat ("The following user commands may relate to '%s':\n", search_word);
+                    size_t max_len = 0;
 
-                for (size_t i = 0; i < commands_found.GetSize(); ++i)
-                    m_interpreter.OutputFormattedHelpText (result.GetOutputStream(), 
-                                                           commands_found.GetStringAtIndex(i),
-                                                           "--", commands_help.
-                                                           GetStringAtIndex(i), 
-                                                           max_len);
+                    for (size_t i = 0; i < user_commands_found.GetSize(); ++i)
+                    {
+                        size_t len = strlen (user_commands_found.GetStringAtIndex (i));
+                        if (len > max_len)
+                            max_len = len;
+                    }
+
+                    for (size_t i = 0; i < user_commands_found.GetSize(); ++i)
+                        m_interpreter.OutputFormattedHelpText (result.GetOutputStream(), 
+                                                               user_commands_found.GetStringAtIndex(i),
+                                                               "--",
+                                                               user_commands_help.GetStringAtIndex(i),
+                                                               max_len);
+                }
                 
             }
             
             
-            StreamString settings_search_results;
-            lldb::UserSettingsControllerSP root = Debugger::GetSettingsController ();
-            const char *settings_prefix = root->GetLevelName().GetCString();
-             
-            UserSettingsController::SearchAllSettingsDescriptions (m_interpreter, 
-                                                                   root, 
-                                                                   settings_prefix, 
-                                                                   search_word,
-                                                                   settings_search_results);
-            
-            if (settings_search_results.GetSize() > 0)
+            std::vector<const Property *> properties;
+            const size_t num_properties = m_interpreter.GetDebugger().Apropos(search_word, properties);
+            if (num_properties)
             {
+                const bool dump_qualified_name = true;
                 result.AppendMessageWithFormat ("\nThe following settings variables may relate to '%s': \n\n", search_word);
-                result.AppendMessageWithFormat ("%s", settings_search_results.GetData());
+                for (size_t i=0; i<num_properties; ++i)
+                    properties[i]->DumpDescription (m_interpreter, result.GetOutputStream(), 0, dump_qualified_name);
+
             }
             
             result.SetStatus (eReturnStatusSuccessFinishNoResult);

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectArgs.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectArgs.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectArgs.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectArgs.h"
 
 // C Includes
@@ -14,13 +16,14 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Interpreter/Args.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/Value.h"
 #include "lldb/Expression/ClangExpression.h"
 #include "lldb/Expression/ClangExpressionVariable.h"
 #include "lldb/Expression/ClangFunction.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Core/Debugger.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Variable.h"
@@ -53,7 +56,7 @@ CommandObjectArgs::CommandOptions::SetOp
 {
     Error error;
     
-    char short_option = (char) m_getopt_table[option_idx].val;
+    const int short_option = m_getopt_table[option_idx].val;
     
     switch (short_option)
     {
@@ -101,7 +104,7 @@ CommandObjectArgs::DoExecute (Args& args
     ConstString target_triple;
     
     
-    Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+    Process *process = m_exe_ctx.GetProcessPtr();
     if (!process)
     {
         result.AppendError ("Args found no process.");
@@ -117,7 +120,7 @@ CommandObjectArgs::DoExecute (Args& args
         return false;
     }
     
-    int num_args = args.GetArgumentCount ();
+    const size_t num_args = args.GetArgumentCount ();
     int arg_index;
     
     if (!num_args)
@@ -127,7 +130,7 @@ CommandObjectArgs::DoExecute (Args& args
         return false;
     }
     
-    Thread *thread = m_interpreter.GetExecutionContext ().GetThreadPtr();
+    Thread *thread = m_exe_ctx.GetThreadPtr();
     
     if (!thread)
     {
@@ -265,6 +268,6 @@ OptionDefinition
 CommandObjectArgs::CommandOptions::g_option_table[] =
 {
     { LLDB_OPT_SET_1, false, "debug", 'g', no_argument, NULL, 0, eArgTypeNone, "Enable verbose debug logging of the expression parsing and evaluation."},
-    { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL }
+    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectBreakpoint.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectBreakpoint.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectBreakpoint.h"
 #include "CommandObjectBreakpointCommand.h"
 
@@ -91,7 +93,6 @@ public:
             m_filenames (),
             m_line_num (0),
             m_column (0),
-            m_check_inlines (true),
             m_func_names (),
             m_func_name_type_mask (eFunctionNameTypeNone),
             m_func_regexp (),
@@ -104,9 +105,10 @@ public:
             m_thread_name(),
             m_queue_name(),
             m_catch_bp (false),
-            m_throw_bp (false),
+            m_throw_bp (true),
             m_language (eLanguageTypeUnknown),
-            m_skip_prologue (eLazyBoolCalculate)
+            m_skip_prologue (eLazyBoolCalculate),
+            m_one_shot (false)
         {
         }
 
@@ -118,17 +120,20 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
                 case 'a':
-                    m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
-                    if (m_load_addr == LLDB_INVALID_ADDRESS)
-                        m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
+                    {
+                        ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+                        m_load_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
+                    }
+                    break;
 
-                    if (m_load_addr == LLDB_INVALID_ADDRESS)
-                        error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg);
+                case 'b':
+                    m_func_names.push_back (option_arg);
+                    m_func_name_type_mask |= eFunctionNameTypeBase;
                     break;
 
                 case 'C':
@@ -139,59 +144,116 @@ public:
                     m_condition.assign(option_arg);
                     break;
 
+                case 'E':
+                {
+                    LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg);
+
+                    switch (language)
+                    {
+                        case eLanguageTypeC89:
+                        case eLanguageTypeC:
+                        case eLanguageTypeC99:
+                            m_language = eLanguageTypeC;
+                            break;
+                        case eLanguageTypeC_plus_plus:
+                            m_language = eLanguageTypeC_plus_plus;
+                            break;
+                        case eLanguageTypeObjC:
+                            m_language = eLanguageTypeObjC;
+                            break;
+                        case eLanguageTypeObjC_plus_plus:
+                            error.SetErrorStringWithFormat ("Set exception breakpoints separately for c++ and objective-c");
+                            break;
+                        case eLanguageTypeUnknown:
+                            error.SetErrorStringWithFormat ("Unknown language type: '%s' for exception breakpoint", option_arg);
+                            break;
+                        default:
+                            error.SetErrorStringWithFormat ("Unsupported language type: '%s' for exception breakpoint", option_arg);
+                    }
+                }
+                break;
+
                 case 'f':
                     m_filenames.AppendIfUnique (FileSpec(option_arg, false));
                     break;
 
-                case 'l':
-                    m_line_num = Args::StringToUInt32 (option_arg, 0);
+                case 'F':
+                    m_func_names.push_back (option_arg);
+                    m_func_name_type_mask |= eFunctionNameTypeFull;
                     break;
 
-                case 'b':
-                    m_func_names.push_back (option_arg);
-                    m_func_name_type_mask |= eFunctionNameTypeBase;
+                case 'h':
+                {
+                    bool success;
+                    m_catch_bp = Args::StringToBoolean (option_arg, true, &success);
+                    if (!success)
+                        error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg);
+                }
+                break;
+                case 'i':
+                {
+                    m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
+                    if (m_ignore_count == UINT32_MAX)
+                       error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
                     break;
+                }
 
-                case 'n':
-                    m_func_names.push_back (option_arg);
-                    m_func_name_type_mask |= eFunctionNameTypeAuto;
+                case 'K':
+                {
+                    bool success;
+                    bool value;
+                    value = Args::StringToBoolean (option_arg, true, &success);
+                    if (value)
+                        m_skip_prologue = eLazyBoolYes;
+                    else
+                        m_skip_prologue = eLazyBoolNo;
+                        
+                    if (!success)
+                        error.SetErrorStringWithFormat ("Invalid boolean value for skip prologue option: '%s'", option_arg);
+                }
+                break;
+
+                case 'l':
+                    m_line_num = Args::StringToUInt32 (option_arg, 0);
                     break;
 
-                case 'F':
+                case 'M':
                     m_func_names.push_back (option_arg);
-                    m_func_name_type_mask |= eFunctionNameTypeFull;
+                    m_func_name_type_mask |= eFunctionNameTypeMethod;
                     break;
 
-                case 'S':
+                case 'n':
                     m_func_names.push_back (option_arg);
-                    m_func_name_type_mask |= eFunctionNameTypeSelector;
+                    m_func_name_type_mask |= eFunctionNameTypeAuto;
                     break;
 
-                case 'M':
-                    m_func_names.push_back (option_arg);
-                    m_func_name_type_mask |= eFunctionNameTypeMethod;
+                case 'o':
+                    m_one_shot = true;
                     break;
 
                 case 'p':
                     m_source_text_regexp.assign (option_arg);
                     break;
                     
+                case 'q':
+                    m_queue_name.assign (option_arg);
+                    break;
+
                 case 'r':
                     m_func_regexp.assign (option_arg);
                     break;
 
                 case 's':
-                    {
-                        m_modules.AppendIfUnique (FileSpec (option_arg, false));
-                        break;
-                    }
-                case 'i':
                 {
-                    m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
-                    if (m_ignore_count == UINT32_MAX)
-                       error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
+                    m_modules.AppendIfUnique (FileSpec (option_arg, false));
+                    break;
                 }
-                break;
+                    
+                case 'S':
+                    m_func_names.push_back (option_arg);
+                    m_func_name_type_mask |= eFunctionNameTypeSelector;
+                    break;
+
                 case 't' :
                 {
                     m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
@@ -199,48 +261,11 @@ public:
                        error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
                 }
                 break;
+
                 case 'T':
                     m_thread_name.assign (option_arg);
                     break;
-                case 'q':
-                    m_queue_name.assign (option_arg);
-                    break;
-                case 'x':
-                {
-                    m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
-                    if (m_thread_id == UINT32_MAX)
-                       error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
-                    
-                }
-                break;
-                case 'E':
-                {
-                    LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg);
 
-                    switch (language)
-                    {
-                        case eLanguageTypeC89:
-                        case eLanguageTypeC:
-                        case eLanguageTypeC99:
-                            m_language = eLanguageTypeC;
-                            break;
-                        case eLanguageTypeC_plus_plus:
-                            m_language = eLanguageTypeC_plus_plus;
-                            break;
-                        case eLanguageTypeObjC:
-                            m_language = eLanguageTypeObjC;
-                            break;
-                        case eLanguageTypeObjC_plus_plus:
-                            error.SetErrorStringWithFormat ("Set exception breakpoints separately for c++ and objective-c");
-                            break;
-                        case eLanguageTypeUnknown:
-                            error.SetErrorStringWithFormat ("Unknown language type: '%s' for exception breakpoint", option_arg);
-                            break;
-                        default:
-                            error.SetErrorStringWithFormat ("Unsupported language type: '%s' for exception breakpoint", option_arg);
-                    }
-                }
-                break;
                 case 'w':
                 {
                     bool success;
@@ -249,27 +274,16 @@ public:
                         error.SetErrorStringWithFormat ("Invalid boolean value for on-throw option: '%s'", option_arg);
                 }
                 break;
-                case 'h':
-                {
-                    bool success;
-                    m_catch_bp = Args::StringToBoolean (option_arg, true, &success);
-                    if (!success)
-                        error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg);
-                }
-                case 'K':
+
+                case 'x':
                 {
-                    bool success;
-                    bool value;
-                    value = Args::StringToBoolean (option_arg, true, &success);
-                    if (value)
-                        m_skip_prologue = eLazyBoolYes;
-                    else
-                        m_skip_prologue = eLazyBoolNo;
-                        
-                    if (!success)
-                        error.SetErrorStringWithFormat ("Invalid boolean value for skip prologue option: '%s'", option_arg);
+                    m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
+                    if (m_thread_id == UINT32_MAX)
+                       error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
+                    
                 }
                 break;
+
                 default:
                     error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
                     break;
@@ -285,19 +299,21 @@ public:
             m_line_num = 0;
             m_column = 0;
             m_func_names.clear();
-            m_func_name_type_mask = 0;
+            m_func_name_type_mask = eFunctionNameTypeNone;
             m_func_regexp.clear();
-            m_load_addr = LLDB_INVALID_ADDRESS;
+            m_source_text_regexp.clear();
             m_modules.Clear();
+            m_load_addr = LLDB_INVALID_ADDRESS;
             m_ignore_count = 0;
             m_thread_id = LLDB_INVALID_THREAD_ID;
             m_thread_index = UINT32_MAX;
             m_thread_name.clear();
             m_queue_name.clear();
-            m_language = eLanguageTypeUnknown;
             m_catch_bp = false;
             m_throw_bp = true;
+            m_language = eLanguageTypeUnknown;
             m_skip_prologue = eLazyBoolCalculate;
+            m_one_shot = false;
         }
     
         const OptionDefinition*
@@ -316,7 +332,6 @@ public:
         FileSpecList m_filenames;
         uint32_t m_line_num;
         uint32_t m_column;
-        bool m_check_inlines;
         std::vector<std::string> m_func_names;
         uint32_t m_func_name_type_mask;
         std::string m_func_regexp;
@@ -332,6 +347,7 @@ public:
         bool m_throw_bp;
         lldb::LanguageType m_language;
         LazyBool m_skip_prologue;
+        bool m_one_shot;
 
     };
 
@@ -380,7 +396,7 @@ protected:
             case eSetTypeFileAndLine: // Breakpoint by source position
                 {
                     FileSpec file;
-                    uint32_t num_files = m_options.m_filenames.GetSize();
+                    const size_t num_files = m_options.m_filenames.GetSize();
                     if (num_files == 0)
                     {
                         if (!GetDefaultFile (target, file, result))
@@ -398,11 +414,14 @@ protected:
                     }
                     else
                         file = m_options.m_filenames.GetFileSpecAtIndex(0);
-                        
+                    
+                    // Only check for inline functions if 
+                    LazyBool check_inlines = eLazyBoolCalculate;
+                    
                     bp = target->CreateBreakpoint (&(m_options.m_modules),
                                                    file,
                                                    m_options.m_line_num,
-                                                   m_options.m_check_inlines,
+                                                   check_inlines,
                                                    m_options.m_skip_prologue,
                                                    internal).get();
                 }
@@ -450,7 +469,7 @@ protected:
                 break;
             case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.
                 {
-                    int num_files = m_options.m_filenames.GetSize();
+                    const size_t num_files = m_options.m_filenames.GetSize();
                     
                     if (num_files == 0)
                     {
@@ -509,14 +528,15 @@ protected:
 
             if (!m_options.m_condition.empty())
                 bp->GetOptions()->SetCondition(m_options.m_condition.c_str());
+            
+            bp->SetOneShot (m_options.m_one_shot);
         }
         
         if (bp)
         {
             Stream &output_stream = result.GetOutputStream();
-            output_stream.Printf ("Breakpoint created: ");
-            bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
-            output_stream.EOL();
+            const bool show_locations = false;
+            bp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial, show_locations);
             // Don't print out this warning for exception breakpoints.  They can get set before the target
             // is set, but we won't know how to actually set the breakpoint till we run.
             if (bp->GetNumLocations() == 0 && break_type != eSetTypeException)
@@ -541,7 +561,7 @@ private:
         // Then use the current stack frame's file.
         if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line))
         {
-            StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr();
+            StackFrame *cur_frame = m_exe_ctx.GetFramePtr();
             if (cur_frame == NULL)
             {
                 result.AppendError ("No selected frame to use to find the default file.");
@@ -590,11 +610,14 @@ CommandObjectBreakpointSet::CommandOptio
     { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument,   NULL, 0, eArgTypeCount,
         "Set the number of times this breakpoint is skipped before stopping." },
 
+    { LLDB_OPT_SET_ALL, false, "one-shot", 'o', no_argument,   NULL, 0, eArgTypeNone,
+        "The breakpoint is deleted the first time it causes a stop." },
+
     { LLDB_OPT_SET_ALL, false, "condition",    'c', required_argument, NULL, 0, eArgTypeExpression,
         "The breakpoint stops only if this condition expression evaluates to true."},
 
     { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex,
-        "The breakpoint stops only for the thread whose index matches this argument."},
+        "The breakpoint stops only for the thread whose indeX matches this argument."},
 
     { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, 0, eArgTypeThreadID,
         "The breakpoint stops only for the thread whose TID matches this argument."},
@@ -606,7 +629,10 @@ CommandObjectBreakpointSet::CommandOptio
         "The breakpoint stops only for threads in the queue whose name is given by this argument."},
 
     { LLDB_OPT_FILE, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
-        "Specifies the source file in which to set this breakpoint."},
+        "Specifies the source file in which to set this breakpoint.  "
+        "Note, by default lldb only looks for files that are #included if they use the standard include file extensions.  "
+        "To set breakpoints on .c/.cpp/.m/.mm files that are #included, set target.inline-breakpoint-strategy"
+        " to \"always\"."},
 
     { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
         "Specifies the line number on which to set this breakpoint."},
@@ -616,11 +642,11 @@ CommandObjectBreakpointSet::CommandOptio
     //    { 0, false, "column",     'C', required_argument, NULL, "<column>",
     //    "Set the breakpoint by source location at this particular column."},
 
-    { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress,
+    { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddressOrExpression,
         "Set the breakpoint by address, at the specified address."},
 
     { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
-        "Set the breakpoint by function name.  Can be repeated multiple times to make one breakpoint for multiple snames" },
+        "Set the breakpoint by function name.  Can be repeated multiple times to make one breakpoint for multiple names" },
 
     { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName,
         "Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguments, and "
@@ -706,11 +732,13 @@ public:
             m_thread_name(),
             m_queue_name(),
             m_condition (),
+            m_one_shot (false),
             m_enable_passed (false),
             m_enable_value (false),
             m_name_passed (false),
             m_queue_passed (false),
-            m_condition_passed (false)
+            m_condition_passed (false),
+            m_one_shot_passed (false)
         {
         }
 
@@ -721,7 +749,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
@@ -747,6 +775,19 @@ public:
                        error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
                 }
                 break;
+                case 'o':
+                {
+                    bool value, success;
+                    value = Args::StringToBoolean(option_arg, false, &success);
+                    if (success)
+                    {
+                        m_one_shot_passed = true;
+                        m_one_shot = value;
+                    }
+                    else
+                        error.SetErrorStringWithFormat("invalid boolean value '%s' passed for -o option", option_arg);
+                }
+                break;
                 case 't' :
                 {
                     if (option_arg[0] == '\0')
@@ -813,10 +854,12 @@ public:
             m_thread_name.clear();
             m_queue_name.clear();
             m_condition.clear();
+            m_one_shot = false;
             m_enable_passed = false;
             m_queue_passed = false;
             m_name_passed = false;
             m_condition_passed = false;
+            m_one_shot_passed = false;
         }
         
         const OptionDefinition*
@@ -840,11 +883,13 @@ public:
         std::string m_thread_name;
         std::string m_queue_name;
         std::string m_condition;
+        bool m_one_shot;
         bool m_enable_passed;
         bool m_enable_value;
         bool m_name_passed;
         bool m_queue_passed;
         bool m_condition_passed;
+        bool m_one_shot_passed;
 
     };
 
@@ -943,14 +988,15 @@ OptionDefinition
 CommandObjectBreakpointModify::CommandOptions::g_option_table[] =
 {
 { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." },
-{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose indeX matches this argument."},
+{ LLDB_OPT_SET_ALL, false, "one-shot",     'o', required_argument, NULL, 0, eArgTypeBoolean, "The breakpoint is deleted the first time it stop causes a stop." },
+{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose index matches this argument."},
 { LLDB_OPT_SET_ALL, false, "thread-id",    't', required_argument, NULL, 0, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument."},
 { LLDB_OPT_SET_ALL, false, "thread-name",  'T', required_argument, NULL, 0, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument."},
 { LLDB_OPT_SET_ALL, false, "queue-name",   'q', required_argument, NULL, 0, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."},
 { LLDB_OPT_SET_ALL, false, "condition",    'c', required_argument, NULL, 0, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."},
 { LLDB_OPT_SET_1,   false, "enable",       'e', no_argument,       NULL, 0, eArgTypeNone, "Enable the breakpoint."},
 { LLDB_OPT_SET_2,   false, "disable",      'd', no_argument,       NULL, 0, eArgTypeNone, "Disable the breakpoint."},
-{ 0,                false, NULL,            0 , 0,                 NULL, 0,    eArgTypeNone, NULL }
+{ 0,                false, NULL,            0 , 0,                 NULL, 0, eArgTypeNone, NULL }
 };
 
 //-------------------------------------------------------------------------
@@ -1067,10 +1113,30 @@ public:
                              "Disable the specified breakpoint(s) without removing it/them.  If no breakpoints are specified, disable them all.",
                              NULL)
     {
+        SetHelpLong(
+"Disable the specified breakpoint(s) without removing it/them.  \n\
+If no breakpoints are specified, disable them all.\n\
+\n\
+Note: disabling a breakpoint will cause none of its locations to be hit\n\
+regardless of whether they are enabled or disabled.  So the sequence: \n\
+\n\
+    (lldb) break disable 1\n\
+    (lldb) break enable 1.1\n\
+\n\
+will NOT cause location 1.1 to get hit.  To achieve that, do:\n\
+\n\
+    (lldb) break disable 1.*\n\
+    (lldb) break enable 1.1\n\
+\n\
+The first command disables all the locations of breakpoint 1, \n\
+the second re-enables the first location."
+                    );
+        
         CommandArgumentEntry arg;
         CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
         // Add the entry for the first argument for this command to the object's arguments vector.
-        m_arguments.push_back (arg);   
+        m_arguments.push_back (arg);
+
     }
 
 
@@ -1210,7 +1276,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
@@ -1398,7 +1464,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
@@ -1608,7 +1674,7 @@ protected:
             else
             {
                 target->RemoveAllBreakpoints ();
-                result.AppendMessageWithFormat ("All breakpoints removed. (%lu breakpoints)\n", num_breakpoints);
+                result.AppendMessageWithFormat ("All breakpoints removed. (%lu %s)\n", num_breakpoints, num_breakpoints > 1 ? "breakpoints" : "breakpoint");
             }
             result.SetStatus (eReturnStatusSuccessFinishNoResult);
         }
@@ -1751,7 +1817,7 @@ CommandObjectMultiwordBreakpoint::Verify
             Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
             if (breakpoint != NULL)
             {
-                int num_locations = breakpoint->GetNumLocations();
+                const size_t num_locations = breakpoint->GetNumLocations();
                 if (cur_bp_id.GetLocationID() > num_locations)
                 {
                     StreamString id_str;

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectBreakpointCommand.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectBreakpointCommand.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectBreakpointCommand.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectBreakpointCommand.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 // C Includes
 // C++ Includes
 
@@ -44,71 +46,86 @@ public:
         m_options (interpreter)
     {
         SetHelpLong (
-"\nGeneral information about entering breakpoint commands \n\
------------------------------------------------------- \n\
- \n\
-This command will cause you to be prompted to enter the command or set \n\
-of commands you wish to be executed when the specified breakpoint is \n\
-hit.  You will be told to enter your command(s), and will see a '> ' \n\
-prompt. Because you can enter one or many commands to be executed when \n\
-a breakpoint is hit, you will continue to be prompted after each \n\
-new-line that you enter, until you enter the word 'DONE', which will \n\
-cause the commands you have entered to be stored with the breakpoint \n\
-and executed when the breakpoint is hit. \n\
- \n\
-Syntax checking is not necessarily done when breakpoint commands are \n\
-entered.  An improperly written breakpoint command will attempt to get \n\
-executed when the breakpoint gets hit, and usually silently fail.  If \n\
-your breakpoint command does not appear to be getting executed, go \n\
-back and check your syntax. \n\
- \n\
- \n\
-Special information about PYTHON breakpoint commands                            \n\
-----------------------------------------------------                            \n\
-                                                                                \n\
-You may enter either one line of Python or multiple lines of Python             \n\
-(including defining whole functions, if desired).  If you enter a               \n\
-single line of Python, that will be passed to the Python interpreter            \n\
-'as is' when the breakpoint gets hit.  If you enter function                    \n\
-definitions, they will be passed to the Python interpreter as soon as           \n\
-you finish entering the breakpoint command, and they can be called              \n\
-later (don't forget to add calls to them, if you want them called when          \n\
-the breakpoint is hit).  If you enter multiple lines of Python that             \n\
-are not function definitions, they will be collected into a new,                \n\
-automatically generated Python function, and a call to the newly                \n\
-generated function will be attached to the breakpoint.                          \n\
-                                                                                \n\
-This auto-generated function is passed in two arguments:                        \n\
-                                                                                \n\
-    frame:  an SBFrame object representing the frame which hit the breakpoint.  \n\
-            From the frame you can get back to the thread and process.          \n\
-    bp_loc: the number of the breakpoint location that was hit.                 \n\
-            This is useful since one breakpoint can have many locations.        \n\
-                                                                                \n\
-Important Note: Because loose Python code gets collected into functions,        \n\
-if you want to access global variables in the 'loose' code, you need to         \n\
-specify that they are global, using the 'global' keyword.  Be sure to           \n\
-use correct Python syntax, including indentation, when entering Python          \n\
-breakpoint commands.                                                            \n\
-                                                                                \n\
-As a third option, you can pass the name of an already existing Python function \n\
-and that function will be attached to the breakpoint. It will get passed the    \n\
-frame and bp_loc arguments mentioned above.                                     \n\
-                                                                                \n\
-Example Python one-line breakpoint command: \n\
- \n\
-(lldb) breakpoint command add -s python 1 \n\
-Enter your Python command(s). Type 'DONE' to end. \n\
-> print \"Hit this breakpoint!\" \n\
-> DONE \n\
- \n\
-As a convenience, this also works for a short Python one-liner: \n\
-(lldb) breakpoint command add -s python 1 -o \"import time; print time.asctime()\" \n\
-(lldb) run \n\
-Launching '.../a.out'  (x86_64) \n\
-(lldb) Fri Sep 10 12:17:45 2010 \n\
-Process 21778 Stopped \n\
-* thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread \n\
+"\nGeneral information about entering breakpoint commands\n\
+------------------------------------------------------\n\
+\n\
+This command will cause you to be prompted to enter the command or set of\n\
+commands you wish to be executed when the specified breakpoint is hit. You\n\
+will be told to enter your command(s), and will see a '> 'prompt. Because\n\
+you can enter one or many commands to be executed when a breakpoint is hit,\n\
+you will continue to be prompted after each new-line that you enter, until you\n\
+enter the word 'DONE', which will cause the commands you have entered to be\n\
+stored with the breakpoint and executed when the breakpoint is hit.\n\
+\n\
+Syntax checking is not necessarily done when breakpoint commands are entered.\n\
+An improperly written breakpoint command will attempt to get executed when the\n\
+breakpoint gets hit, and usually silently fail.  If your breakpoint command does\n\
+not appear to be getting executed, go back and check your syntax.\n\
+\n\
+Special information about PYTHON breakpoint commands\n\
+----------------------------------------------------\n\
+\n\
+You may enter either one line of Python, multiple lines of Python (including\n\
+function definitions), or specify a Python function in a module that has already,\n\
+or will be imported.  If you enter a single line of Python, that will be passed\n\
+to the Python interpreter 'as is' when the breakpoint gets hit.  If you enter\n\
+function definitions, they will be passed to the Python interpreter as soon as\n\
+you finish entering the breakpoint command, and they can be called later (don't\n\
+forget to add calls to them, if you want them called when the breakpoint is\n\
+hit).  If you enter multiple lines of Python that are not function definitions,\n\
+they will be collected into a new, automatically generated Python function, and\n\
+a call to the newly generated function will be attached to the breakpoint.\n\
+\n\
+\n\
+This auto-generated function is passed in three arguments:\n\
+\n\
+    frame:  a lldb.SBFrame object for the frame which hit breakpoint.\n\
+    bp_loc: a lldb.SBBreakpointLocation object that represents the breakpoint\n\
+            location that was hit.\n\
+    dict:   the python session dictionary hit.\n\
+\n\
+When specifying a python function with the --python-function option, you need\n\
+to supply the function name prepended by the module name. So if you import a\n\
+module named 'myutils' that contains a 'breakpoint_callback' function, you would\n\
+specify the option as:\n\
+\n\
+    --python-function myutils.breakpoint_callback\n\
+\n\
+The function itself must have the following prototype:\n\
+\n\
+def breakpoint_callback(frame, bp_loc, dict):\n\
+  # Your code goes here\n\
+\n\
+The arguments are the same as the 3 auto generation function arguments listed\n\
+above. Note that the global variable 'lldb.frame' will NOT be setup when this\n\
+function is called, so be sure to use the 'frame' argument. The 'frame' argument\n\
+can get you to the thread (frame.GetThread()), the thread can get you to the\n\
+process (thread.GetProcess()), and the process can get you back to the target\n\
+(process.GetTarget()).\n\
+\n\
+Important Note: Because loose Python code gets collected into functions, if you\n\
+want to access global variables in the 'loose' code, you need to specify that\n\
+they are global, using the 'global' keyword.  Be sure to use correct Python\n\
+syntax, including indentation, when entering Python breakpoint commands.\n\
+\n\
+As a third option, you can pass the name of an already existing Python function\n\
+and that function will be attached to the breakpoint. It will get passed the\n\
+frame and bp_loc arguments mentioned above.\n\
+\n\
+Example Python one-line breakpoint command:\n\
+\n\
+(lldb) breakpoint command add -s python 1\n\
+Enter your Python command(s). Type 'DONE' to end.\n\
+> print \"Hit this breakpoint!\"\n\
+> DONE\n\
+\n\
+As a convenience, this also works for a short Python one-liner:\n\
+(lldb) breakpoint command add -s python 1 -o \"import time; print time.asctime()\"\n\
+(lldb) run\n\
+Launching '.../a.out'  (x86_64)\n\
+(lldb) Fri Sep 10 12:17:45 2010\n\
+Process 21778 Stopped\n\
+* thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread\n\
   36   	\n\
   37   	int c(int val)\n\
   38   	{\n\
@@ -116,50 +133,56 @@ Process 21778 Stopped \n\
   40   	}\n\
   41   	\n\
   42   	int main (int argc, char const *argv[])\n\
-(lldb) \n\
- \n\
-Example multiple line Python breakpoint command, using function definition: \n\
- \n\
-(lldb) breakpoint command add -s python 1 \n\
-Enter your Python command(s). Type 'DONE' to end. \n\
-> def breakpoint_output (bp_no): \n\
->     out_string = \"Hit breakpoint number \" + repr (bp_no) \n\
->     print out_string \n\
->     return True \n\
-> breakpoint_output (1) \n\
-> DONE \n\
- \n\
- \n\
-Example multiple line Python breakpoint command, using 'loose' Python: \n\
- \n\
-(lldb) breakpoint command add -s p 1 \n\
-Enter your Python command(s). Type 'DONE' to end. \n\
-> global bp_count \n\
-> bp_count = bp_count + 1 \n\
-> print \"Hit this breakpoint \" + repr(bp_count) + \" times!\" \n\
-> DONE \n\
- \n\
-In this case, since there is a reference to a global variable, \n\
-'bp_count', you will also need to make sure 'bp_count' exists and is \n\
-initialized: \n\
- \n\
-(lldb) script \n\
->>> bp_count = 0 \n\
->>> quit() \n\
- \n\
-(lldb)  \n\
- \n\
- \n\
-Final Note:  If you get a warning that no breakpoint command was generated, \n\
-but you did not get any syntax errors, you probably forgot to add a call \n\
-to your functions. \n\
- \n\
-Special information about debugger command breakpoint commands \n\
--------------------------------------------------------------- \n\
- \n\
-You may enter any debugger command, exactly as you would at the \n\
-debugger prompt.  You may enter as many debugger commands as you like, \n\
-but do NOT enter more than one command per line. \n" );
+(lldb)\n\
+\n\
+Example multiple line Python breakpoint command, using function definition:\n\
+\n\
+(lldb) breakpoint command add -s python 1\n\
+Enter your Python command(s). Type 'DONE' to end.\n\
+> def breakpoint_output (bp_no):\n\
+>     out_string = \"Hit breakpoint number \" + repr (bp_no)\n\
+>     print out_string\n\
+>     return True\n\
+> breakpoint_output (1)\n\
+> DONE\n\
+\n\
+\n\
+Example multiple line Python breakpoint command, using 'loose' Python:\n\
+\n\
+(lldb) breakpoint command add -s p 1\n\
+Enter your Python command(s). Type 'DONE' to end.\n\
+> global bp_count\n\
+> bp_count = bp_count + 1\n\
+> print \"Hit this breakpoint \" + repr(bp_count) + \" times!\"\n\
+> DONE\n\
+\n\
+In this case, since there is a reference to a global variable,\n\
+'bp_count', you will also need to make sure 'bp_count' exists and is\n\
+initialized:\n\
+\n\
+(lldb) script\n\
+>>> bp_count = 0\n\
+>>> quit()\n\
+\n\
+(lldb)\n\
+\n\
+\n\
+Your Python code, however organized, can optionally return a value.\n\
+If the returned value is False, that tells LLDB not to stop at the breakpoint\n\
+to which the code is associated. Returning anything other than False, or even\n\
+returning None, or even omitting a return statement entirely, will cause\n\
+LLDB to stop.\n\
+\n\
+Final Note:  If you get a warning that no breakpoint command was generated, but\n\
+you did not get any syntax errors, you probably forgot to add a call to your\n\
+functions.\n\
+\n\
+Special information about debugger command breakpoint commands\n\
+--------------------------------------------------------------\n\
+\n\
+You may enter any debugger command, exactly as you would at the debugger prompt.\n\
+You may enter as many debugger commands as you like, but do NOT enter more than\n\
+one command per line.\n" );
 
         CommandArgumentEntry arg;
         CommandArgumentData bp_id_arg;
@@ -189,7 +212,7 @@ but do NOT enter more than one command p
                                              CommandReturnObject &result)
     {
         InputReaderSP reader_sp (new InputReader(m_interpreter.GetDebugger()));
-        std::auto_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData());
+        std::unique_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData());
         if (reader_sp && data_ap.get())
         {
             BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release()));
@@ -225,7 +248,7 @@ but do NOT enter more than one command p
     SetBreakpointCommandCallback (BreakpointOptions *bp_options,
                                   const char *oneliner)
     {
-        std::auto_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData());
+        std::unique_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData());
 
         // It's necessary to set both user_source and script_source to the oneliner.
         // The former is used to generate callback description (as in breakpoint command list)
@@ -398,7 +421,7 @@ but do NOT enter more than one command p
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
@@ -517,6 +540,13 @@ protected:
         if (result.Succeeded())
         {
             const size_t count = valid_bp_ids.GetSize();
+            if (count > 1)
+            {
+                result.AppendError ("can only add commands to one breakpoint at a time.");
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            }
+            
             for (size_t i = 0; i < count; ++i)
             {
                 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
@@ -557,7 +587,8 @@ protected:
                         // what the user would do manually: make their breakpoint command be a function call
                         else if (m_options.m_function_name.size())
                         {
-                            std::string oneliner(m_options.m_function_name);
+                            std::string oneliner("return ");
+                            oneliner += m_options.m_function_name;
                             oneliner += "(frame, bp_loc, internal_dict)";
                             m_interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options,
                                                                                                 oneliner.c_str());
@@ -609,16 +640,16 @@ g_script_option_enumeration[4] =
 OptionDefinition
 CommandObjectBreakpointCommandAdd::CommandOptions::g_option_table[] =
 {
-    { LLDB_OPT_SET_1, false, "one-liner", 'o', required_argument, NULL, NULL, eArgTypeOneLiner,
+    { LLDB_OPT_SET_1, false, "one-liner", 'o', required_argument, NULL, 0, eArgTypeOneLiner,
         "Specify a one-line breakpoint command inline. Be sure to surround it with quotes." },
 
-    { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', required_argument, NULL, NULL, eArgTypeBoolean,
+    { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', required_argument, NULL, 0, eArgTypeBoolean,
         "Specify whether breakpoint command execution should terminate on error." },
 
-    { LLDB_OPT_SET_ALL,   false, "script-type",     's', required_argument, g_script_option_enumeration, NULL, eArgTypeNone,
+    { LLDB_OPT_SET_ALL,   false, "script-type",     's', required_argument, g_script_option_enumeration, 0, eArgTypeNone,
         "Specify the language for the commands - if none is specified, the lldb command interpreter will be used."},
 
-    { LLDB_OPT_SET_2,   false, "python-function",     'F', required_argument, NULL, NULL, eArgTypePythonFunction,
+    { LLDB_OPT_SET_2,   false, "python-function",     'F', required_argument, NULL, 0, eArgTypePythonFunction,
         "Give the name of a Python function to run as command for this breakpoint. Be sure to give a module name if appropriate."},
     
     { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectCommands.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectCommands.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectCommands.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectCommands.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectCommands.h"
 
 // C Includes
@@ -72,7 +74,7 @@ protected:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             bool success;
             
             switch (short_option)
@@ -186,7 +188,7 @@ public:
         return "";
     }
     
-    int
+    virtual int
     HandleArgumentCompletion (Args &input,
                               int &cursor_index,
                               int &cursor_char_position,
@@ -234,7 +236,7 @@ protected:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             bool success;
             
             switch (short_option)
@@ -283,7 +285,7 @@ protected:
     bool
     DoExecute(Args& command, CommandReturnObject &result)
     {
-        const int argc = command.GetArgumentCount();
+        const size_t argc = command.GetArgumentCount();
         if (argc == 1)
         {
             const char *filename = command.GetArgumentAtIndex(0);
@@ -599,8 +601,7 @@ protected:
                      {
                          const std::string sub_command = args.GetArgumentAtIndex(0);
                          assert (sub_command.length() != 0);
-                         subcommand_obj_sp =
-                                           (((CommandObjectMultiword *) cmd_obj)->GetSubcommandSP (sub_command.c_str()));
+                         subcommand_obj_sp = cmd_obj->GetSubcommandSP (sub_command.c_str());
                          if (subcommand_obj_sp.get())
                          {
                              sub_cmd_obj = subcommand_obj_sp.get();
@@ -792,10 +793,12 @@ public:
 "\n"
 "EXAMPLES\n"
 "\n"
-"The following example with define a regular expression command named 'f' that\n"
+"The following example will define a regular expression command named 'f' that\n"
 "will call 'finish' if there are no arguments, or 'frame select <frame-idx>' if\n"
 "a number follows 'f':\n"
-"(lldb) command regex f s/^$/finish/ 's/([0-9]+)/frame select %1/'\n"
+"\n"
+"    (lldb) command regex f s/^$/finish/ 's/([0-9]+)/frame select %1/'\n"
+"\n"
                     );
     }
     
@@ -1063,7 +1066,7 @@ protected:
     }
 
 private:
-    std::auto_ptr<CommandObjectRegexCommand> m_regex_cmd_ap;    
+    std::unique_ptr<CommandObjectRegexCommand> m_regex_cmd_ap;
 
      class CommandOptions : public Options
      {
@@ -1081,7 +1084,7 @@ private:
          SetOptionValue (uint32_t option_idx, const char *option_arg)
          {
              Error error;
-             char short_option = (char) m_getopt_table[option_idx].val;
+             const int short_option = m_getopt_table[option_idx].val;
              
              switch (short_option)
              {
@@ -1160,6 +1163,7 @@ class CommandObjectPythonFunction : publ
 private:
     std::string m_function_name;
     ScriptedCommandSynchronicity m_synchro;
+    bool m_fetched_help_long;
     
 public:
     
@@ -1172,15 +1176,9 @@ public:
                           (std::string("Run Python function ") + funct).c_str(),
                           NULL),
         m_function_name(funct),
-        m_synchro(synch)
+        m_synchro(synch),
+        m_fetched_help_long(false)
     {
-        ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter();
-        if (scripter)
-        {
-            std::string docstring = scripter->GetDocumentationForItem(funct.c_str());
-            if (!docstring.empty())
-                SetHelpLong(docstring);
-        }
     }
     
     virtual
@@ -1189,7 +1187,7 @@ public:
     }
     
     virtual bool
-    IsRemovable ()
+    IsRemovable () const
     {
         return true;
     }
@@ -1206,6 +1204,23 @@ public:
         return m_synchro;
     }
     
+    virtual const char *
+    GetHelpLong ()
+    {
+        if (!m_fetched_help_long)
+        {
+            ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter();
+            if (scripter)
+            {
+                std::string docstring;
+                m_fetched_help_long = scripter->GetDocumentationForItem(m_function_name.c_str(),docstring);
+                if (!docstring.empty())
+                    SetHelpLong(docstring);
+            }
+        }
+        return CommandObjectRaw::GetHelpLong();
+    }
+    
 protected:
     virtual bool
     DoExecute (const char *raw_command_line, CommandReturnObject &result)
@@ -1274,7 +1289,7 @@ public:
     {
     }
     
-    int
+    virtual int
     HandleArgumentCompletion (Args &input,
                               int &cursor_index,
                               int &cursor_char_position,
@@ -1322,7 +1337,7 @@ protected:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
@@ -1340,7 +1355,7 @@ protected:
         void
         OptionParsingStarting ()
         {
-            m_allow_reload = false;
+            m_allow_reload = true;
         }
         
         const OptionDefinition*
@@ -1381,8 +1396,17 @@ protected:
         std::string path = command.GetArgumentAtIndex(0);
         Error error;
         
+        const bool init_session = true;
+        // FIXME: this is necessary because CommandObject::CheckRequirements() assumes that
+        // commands won't ever be recursively invoked, but it's actually possible to craft
+        // a Python script that does other "command script imports" in __lldb_init_module
+        // the real fix is to have recursive commands possible with a CommandInvocation object
+        // separate from the CommandObject itself, so that recursive command invocations
+        // won't stomp on each other (wrt to execution contents, options, and more)
+        m_exe_ctx.Clear();
         if (m_interpreter.GetScriptInterpreter()->LoadScriptingModule(path.c_str(),
                                                                       m_options.m_allow_reload,
+                                                                      init_session,
                                                                       error))
         {
             result.SetStatus (eReturnStatusSuccessFinishNoResult);
@@ -1402,7 +1426,7 @@ protected:
 OptionDefinition
 CommandObjectCommandsScriptImport::CommandOptions::g_option_table[] =
 {
-    { LLDB_OPT_SET_1, false, "allow-reload", 'r', no_argument, NULL, 0, eArgTypeNone,        "Allow the script to be loaded even if it was already loaded before (for Python, the __lldb_init_module function will be called again, but the module will not be reloaded from disk)."},
+    { LLDB_OPT_SET_1, false, "allow-reload", 'r', no_argument, NULL, 0, eArgTypeNone,        "Allow the script to be loaded even if it was already loaded before. This argument exists for backwards compatibility, but reloading is always allowed, whether you specify it or not."},
     { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 
@@ -1463,7 +1487,7 @@ protected:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {

Removed: lldb/branches/lldb-platform-work/source/Commands/CommandObjectCrossref.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectCrossref.cpp?rev=183467&view=auto
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectCrossref.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectCrossref.cpp (removed)
@@ -1,88 +0,0 @@
-//===-- CommandObjectCrossref.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/Interpreter/CommandObjectCrossref.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Interpreter/CommandReturnObject.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-//-------------------------------------------------------------------------
-// CommandObjectCrossref
-//-------------------------------------------------------------------------
-
-CommandObjectCrossref::CommandObjectCrossref
-(
-    CommandInterpreter &interpreter,
-    const char *name,
-    const char *help,
-    const char *syntax
-) :
-    CommandObjectParsed (interpreter, name, help, syntax),
-    m_crossref_object_types()
-{
-}
-
-CommandObjectCrossref::~CommandObjectCrossref ()
-{
-}
-
-bool
-CommandObjectCrossref::DoExecute (Args& command, CommandReturnObject &result)
-{
-    if (m_crossref_object_types.GetArgumentCount() == 0)
-    {
-        result.AppendErrorWithFormat ("There are no objects for which you can call '%s'.\n", GetCommandName());
-        result.SetStatus (eReturnStatusFailed);
-    }
-    else
-    {
-        GenerateHelpText (result);
-    }
-    return result.Succeeded();
-}
-
-void
-CommandObjectCrossref::AddObject (const char *obj_name)
-{
-    m_crossref_object_types.AppendArgument (obj_name);
-}
-
-const char **
-CommandObjectCrossref::GetObjectTypes () const
-{
-    return m_crossref_object_types.GetConstArgumentVector();
-}
-
-void
-CommandObjectCrossref::GenerateHelpText (CommandReturnObject &result)
-{
-    result.AppendMessage ("This command can be called on the following types of objects:");
-
-    const size_t count = m_crossref_object_types.GetArgumentCount();
-    for (size_t i = 0; i < count; ++i)
-    {
-        const char *obj_name = m_crossref_object_types.GetArgumentAtIndex(i);
-        result.AppendMessageWithFormat ("    %s    (e.g.  '%s %s')\n", obj_name,
-                                        obj_name, GetCommandName());
-    }
-
-    result.SetStatus (eReturnStatusSuccessFinishNoResult);
-}
-
-bool
-CommandObjectCrossref::IsCrossRefObject ()
-{
-    return true;
-}

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectDisassemble.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectDisassemble.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectDisassemble.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectDisassemble.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectDisassemble.h"
 
 // C Includes
@@ -14,16 +16,18 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Core/AddressRange.h"
+#include "lldb/Core/Disassembler.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/SourceManager.h"
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Interpreter/CommandCompletions.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Core/Disassembler.h"
 #include "lldb/Interpreter/Options.h"
-#include "lldb/Core/SourceManager.h"
-#include "lldb/Target/StackFrame.h"
+#include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Target/Process.h"
+#include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Target.h"
 
 #define DEFAULT_DISASM_BYTE_SIZE 32
@@ -37,14 +41,16 @@ CommandObjectDisassemble::CommandOptions
     num_lines_context(0),
     num_instructions (0),
     func_name(),
-    cur_function (false),
+    current_function (false),
     start_addr(),
     end_addr (),
     at_pc (false),
     frame_line (false),
     plugin_name (),
+    flavor_string(),
     arch(),
-    some_location_specified (false) 
+    some_location_specified (false),
+    symbol_containing_addr () 
 {
     OptionParsingStarting();
 }
@@ -58,7 +64,7 @@ CommandObjectDisassemble::CommandOptions
 {
     Error error;
 
-    char short_option = (char) m_getopt_table[option_idx].val;
+    const int short_option = m_getopt_table[option_idx].val;
 
     bool success;
     
@@ -85,23 +91,21 @@ CommandObjectDisassemble::CommandOptions
         break;
 
     case 's':
-        start_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
-        if (start_addr == LLDB_INVALID_ADDRESS)
-            start_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
-
-        if (start_addr == LLDB_INVALID_ADDRESS)
-            error.SetErrorStringWithFormat ("invalid start address string '%s'", option_arg);
-        some_location_specified = true;
+        {
+            ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+            start_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
+            if (start_addr != LLDB_INVALID_ADDRESS)
+                some_location_specified = true;
+        }
         break;
     case 'e':
-        end_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
-        if (end_addr == LLDB_INVALID_ADDRESS)
-            end_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
-
-        if (end_addr == LLDB_INVALID_ADDRESS)
-            error.SetErrorStringWithFormat ("invalid end address string '%s'", option_arg);
+        {
+            ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+            end_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
+            if (end_addr != LLDB_INVALID_ADDRESS)
+                some_location_specified = true;
+        }
         break;
-        some_location_specified = true;
     case 'n':
         func_name.assign (option_arg);
         some_location_specified = true;
@@ -124,20 +128,43 @@ CommandObjectDisassemble::CommandOptions
         plugin_name.assign (option_arg);
         break;
 
+    case 'F':
+        {
+            Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
+            if (target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86
+                || target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86_64)
+            {
+                flavor_string.assign (option_arg);
+            }
+            else
+                error.SetErrorStringWithFormat("Disassembler flavors are currently only supported for x86 and x86_64 targets.");
+            break;
+        }
     case 'r':
         raw = true;
         break;
 
     case 'f':
-        cur_function = true;
+        current_function = true;
         some_location_specified = true;
         break;
 
-    case 'a':
+    case 'A':
         if (!arch.SetTriple (option_arg, m_interpreter.GetPlatform (true).get()))
             arch.SetTriple (option_arg);
         break;
 
+    case 'a':
+        {
+            ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+            symbol_containing_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
+            if (symbol_containing_addr != LLDB_INVALID_ADDRESS)
+            {
+                some_location_specified = true;
+            }
+        }
+        break;
+
     default:
         error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option);
         break;
@@ -154,13 +181,34 @@ CommandObjectDisassemble::CommandOptions
     num_lines_context = 0;
     num_instructions = 0;
     func_name.clear();
-    cur_function = false;
+    current_function = false;
     at_pc = false;
     frame_line = false;
     start_addr = LLDB_INVALID_ADDRESS;
     end_addr = LLDB_INVALID_ADDRESS;
+    symbol_containing_addr = LLDB_INVALID_ADDRESS;
     raw = false;
     plugin_name.clear();
+    
+    Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
+    
+    // This is a hack till we get the ability to specify features based on architecture.  For now GetDisassemblyFlavor
+    // is really only valid for x86 (and for the llvm assembler plugin, but I'm papering over that since that is the
+    // only disassembler plugin we have...
+    if (target)
+    {
+        if (target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86
+            || target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86_64)
+        {
+            flavor_string.assign(target->GetDisassemblyFlavor());
+        }
+        else
+            flavor_string.assign ("default");
+        
+    }
+    else
+        flavor_string.assign("default");
+    
     arch.Clear();
     some_location_specified = false;
 }
@@ -169,7 +217,7 @@ Error
 CommandObjectDisassemble::CommandOptions::OptionParsingFinished ()
 {
     if (!some_location_specified)
-        at_pc = true;
+        current_function = true;
     return Error();
     
 }
@@ -183,24 +231,29 @@ CommandObjectDisassemble::CommandOptions
 OptionDefinition
 CommandObjectDisassemble::CommandOptions::g_option_table[] =
 {
-{ LLDB_OPT_SET_ALL  , false , "bytes",          'b', no_argument        , NULL, 0, eArgTypeNone,        "Show opcode bytes when disassembling."},
-{ LLDB_OPT_SET_ALL  , false , "context",        'C', required_argument  , NULL, 0, eArgTypeNumLines,    "Number of context lines of source to show."},
-{ LLDB_OPT_SET_ALL  , false , "mixed",          'm', no_argument        , NULL, 0, eArgTypeNone,        "Enable mixed source and assembly display."},
-{ LLDB_OPT_SET_ALL  , false , "raw",            'r', no_argument        , NULL, 0, eArgTypeNone,        "Print raw disassembly with no symbol information."},
-{ LLDB_OPT_SET_ALL  , false , "plugin",         'P', required_argument  , NULL, 0, eArgTypePlugin,      "Name of the disassembler plugin you want to use."},
-{ LLDB_OPT_SET_ALL  , false , "arch",           'a', required_argument  , NULL, 0, eArgTypeArchitecture,"Specify the architecture to use from cross disassembly."},
-{ LLDB_OPT_SET_1 |
-  LLDB_OPT_SET_2    , true  , "start-address" , 's', required_argument  , NULL, 0, eArgTypeStartAddress,"Address at which to start disassembling."},
-{ LLDB_OPT_SET_1    , false , "end-address"  ,  'e', required_argument  , NULL, 0, eArgTypeEndAddress,  "Address at which to end disassembling."},
-{ LLDB_OPT_SET_2 |
-  LLDB_OPT_SET_3 |
-  LLDB_OPT_SET_4 |
-  LLDB_OPT_SET_5    , false , "count",          'c', required_argument  , NULL, 0, eArgTypeNumLines,    "Number of instructions to display."},
-{ LLDB_OPT_SET_3    , false  , "name",           'n', required_argument  , NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,             "Disassemble entire contents of the given function name."},
-{ LLDB_OPT_SET_4    , false  , "frame",          'f', no_argument        , NULL, 0, eArgTypeNone,        "Disassemble from the start of the current frame's function."},
-{ LLDB_OPT_SET_5    , false  , "pc",             'p', no_argument        , NULL, 0, eArgTypeNone,        "Disassemble around the current pc."},
-{ LLDB_OPT_SET_6    , false  , "line",           'l', no_argument        , NULL, 0, eArgTypeNone,        "Disassemble the current frame's current source line instructions if there debug line table information, else disasemble around the pc."},
-{ 0                 , false , NULL,             0,   0                  , NULL, 0, eArgTypeNone,        NULL }
+{ LLDB_OPT_SET_ALL, false, "bytes"        , 'b', no_argument        , NULL, 0, eArgTypeNone,        "Show opcode bytes when disassembling."},
+{ LLDB_OPT_SET_ALL, false, "context"      , 'C', required_argument  , NULL, 0, eArgTypeNumLines,    "Number of context lines of source to show."},
+{ LLDB_OPT_SET_ALL, false, "mixed"        , 'm', no_argument        , NULL, 0, eArgTypeNone,        "Enable mixed source and assembly display."},
+{ LLDB_OPT_SET_ALL, false, "raw"          , 'r', no_argument        , NULL, 0, eArgTypeNone,        "Print raw disassembly with no symbol information."},
+{ LLDB_OPT_SET_ALL, false, "plugin"       , 'P', required_argument  , NULL, 0, eArgTypePlugin,      "Name of the disassembler plugin you want to use."},
+{ LLDB_OPT_SET_ALL, false, "flavor"       , 'F', required_argument  , NULL, 0, eArgTypeDisassemblyFlavor,        "Name of the disassembly flavor you want to use.  "
+                                                                                                    "Currently the only valid options are default, and for Intel"
+                                                                                                    " architectures, att and intel."},
+{ LLDB_OPT_SET_ALL, false, "arch"         , 'A', required_argument  , NULL, 0, eArgTypeArchitecture,"Specify the architecture to use from cross disassembly."},
+{ LLDB_OPT_SET_1  |
+  LLDB_OPT_SET_2  , true , "start-address", 's', required_argument  , NULL, 0, eArgTypeAddressOrExpression,"Address at which to start disassembling."},
+{ LLDB_OPT_SET_1  , false, "end-address"  , 'e', required_argument  , NULL, 0, eArgTypeAddressOrExpression,  "Address at which to end disassembling."},
+{ LLDB_OPT_SET_2  |
+  LLDB_OPT_SET_3  |
+  LLDB_OPT_SET_4  |
+  LLDB_OPT_SET_5  , false, "count"        , 'c', required_argument  , NULL, 0, eArgTypeNumLines,    "Number of instructions to display."},
+{ LLDB_OPT_SET_3  , false, "name"         , 'n', required_argument  , NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
+                                                                                                    "Disassemble entire contents of the given function name."},
+{ LLDB_OPT_SET_4  , false, "frame"        , 'f', no_argument        , NULL, 0, eArgTypeNone,        "Disassemble from the start of the current frame's function."},
+{ LLDB_OPT_SET_5  , false, "pc"           , 'p', no_argument        , NULL, 0, eArgTypeNone,        "Disassemble around the current pc."},
+{ LLDB_OPT_SET_6  , false, "line"         , 'l', no_argument        , NULL, 0, eArgTypeNone,        "Disassemble the current frame's current source line instructions if there debug line table information, else disasemble around the pc."},
+{ LLDB_OPT_SET_7  , false, "address"      , 'a', required_argument  , NULL, 0, eArgTypeAddressOrExpression, "Disassemble function containing this address."},
+{ 0               , false, NULL           ,   0, 0                  , NULL, 0, eArgTypeNone,        NULL }
 };
 
 
@@ -243,20 +296,26 @@ CommandObjectDisassemble::DoExecute (Arg
     }
 
     const char *plugin_name = m_options.GetPluginName ();
-    DisassemblerSP disassembler = Disassembler::FindPlugin(m_options.arch, plugin_name);
+    const char *flavor_string = m_options.GetFlavorString();
+
+    DisassemblerSP disassembler = Disassembler::FindPlugin(m_options.arch, flavor_string, plugin_name);
 
     if (!disassembler)
     {
         if (plugin_name)
-            result.AppendErrorWithFormat ("Unable to find Disassembler plug-in named '%s' that supports the '%s' architecture.\n", 
+        {
+            result.AppendErrorWithFormat ("Unable to find Disassembler plug-in named '%s' that supports the '%s' architecture.\n",
                                           plugin_name,
                                           m_options.arch.GetArchitectureName());
+        }
         else
             result.AppendErrorWithFormat ("Unable to find Disassembler plug-in for the '%s' architecture.\n", 
                                           m_options.arch.GetArchitectureName());
         result.SetStatus (eReturnStatusFailed);
         return false;
     }
+    else if (flavor_string != NULL && !disassembler->FlavorValidForArchSpec(m_options.arch, flavor_string))
+        result.AppendWarningWithFormat("invalid disassembler flavor \"%s\", using default.\n", flavor_string);
 
     result.SetStatus (eReturnStatusSuccessFinishResult);
 
@@ -271,7 +330,6 @@ CommandObjectDisassemble::DoExecute (Arg
     if (m_options.show_mixed && m_options.num_lines_context == 0)
         m_options.num_lines_context = 1;
 
-    ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
     // Always show the PC in the disassembly
     uint32_t options = Disassembler::eOptionMarkPCAddress;
 
@@ -292,7 +350,8 @@ CommandObjectDisassemble::DoExecute (Arg
         if (Disassembler::Disassemble (m_interpreter.GetDebugger(), 
                                        m_options.arch,
                                        plugin_name,
-                                       exe_ctx,
+                                       flavor_string,
+                                       m_exe_ctx,
                                        name,
                                        NULL,    // Module *
                                        m_options.num_instructions,
@@ -311,7 +370,7 @@ CommandObjectDisassemble::DoExecute (Arg
     else
     {
         AddressRange range;
-        StackFrame *frame = exe_ctx.GetFramePtr();
+        StackFrame *frame = m_exe_ctx.GetFramePtr();
         if (m_options.frame_line)
         {
             if (frame == NULL)
@@ -331,7 +390,7 @@ CommandObjectDisassemble::DoExecute (Arg
                 m_options.show_mixed = false;
             }
         }
-        else if (m_options.cur_function)
+        else if (m_options.current_function)
         {
             if (frame == NULL)
             {
@@ -382,9 +441,43 @@ CommandObjectDisassemble::DoExecute (Arg
                         range.SetByteSize (m_options.end_addr - m_options.start_addr);
                     }
                 }
+                else
+                {
+                    if (m_options.symbol_containing_addr != LLDB_INVALID_ADDRESS 
+                        && target 
+                        && !target->GetSectionLoadList().IsEmpty())
+                    {
+                        bool failed = false;
+                        Address symbol_containing_address;
+                        if (target->GetSectionLoadList().ResolveLoadAddress (m_options.symbol_containing_addr, symbol_containing_address))
+                        {
+                            ModuleSP module_sp (symbol_containing_address.GetModule());
+                            SymbolContext sc;
+                            module_sp->ResolveSymbolContextForAddress (symbol_containing_address, eSymbolContextEverything, sc);
+                            if (sc.function || sc.symbol)
+                            {
+                                sc.GetAddressRange (eSymbolContextFunction | eSymbolContextSymbol, 0, false, range);
+                            }
+                            else
+                            {
+                                failed = true;
+                            }
+                        }
+                        else
+                        {
+                            failed = true;
+                        }
+                        if (failed)
+                        {
+                            result.AppendErrorWithFormat ("Could not find function bounds for address 0x%" PRIx64 "\n", m_options.symbol_containing_addr);
+                            result.SetStatus (eReturnStatusFailed);
+                            return false;
+                        }
+                    }
+                }
             }
         }
-        
+
         if (m_options.num_instructions != 0)
         {
             if (!range.GetBaseAddress().IsValid())
@@ -412,7 +505,8 @@ CommandObjectDisassemble::DoExecute (Arg
             if (Disassembler::Disassemble (m_interpreter.GetDebugger(), 
                                            m_options.arch,
                                            plugin_name,
-                                           exe_ctx,
+                                           flavor_string,
+                                           m_exe_ctx,
                                            range.GetBaseAddress(),
                                            m_options.num_instructions,
                                            m_options.show_mixed ? m_options.num_lines_context : 0,
@@ -423,7 +517,7 @@ CommandObjectDisassemble::DoExecute (Arg
             }
             else
             {
-                result.AppendErrorWithFormat ("Failed to disassemble memory at 0x%8.8llx.\n", m_options.start_addr);
+                result.AppendErrorWithFormat ("Failed to disassemble memory at 0x%8.8" PRIx64 ".\n", m_options.start_addr);
                 result.SetStatus (eReturnStatusFailed);            
             }
         }
@@ -458,7 +552,8 @@ CommandObjectDisassemble::DoExecute (Arg
             if (Disassembler::Disassemble (m_interpreter.GetDebugger(), 
                                            m_options.arch,
                                            plugin_name,
-                                           exe_ctx,
+                                           flavor_string,
+                                           m_exe_ctx,
                                            range,
                                            m_options.num_instructions,
                                            m_options.show_mixed ? m_options.num_lines_context : 0,
@@ -469,7 +564,7 @@ CommandObjectDisassemble::DoExecute (Arg
             }
             else
             {
-                result.AppendErrorWithFormat ("Failed to disassemble memory at 0x%8.8llx.\n", m_options.start_addr);
+                result.AppendErrorWithFormat ("Failed to disassemble memory at 0x%8.8" PRIx64 ".\n", m_options.start_addr);
                 result.SetStatus (eReturnStatusFailed);            
             }
         }

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectDisassemble.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectDisassemble.h?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectDisassemble.h (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectDisassemble.h Thu Jun  6 19:06:43 2013
@@ -14,6 +14,7 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/Core/ArchSpec.h"
 #include "lldb/Interpreter/CommandObject.h"
 #include "lldb/Interpreter/Options.h"
 
@@ -52,6 +53,14 @@ public:
             return plugin_name.c_str();
         }
         
+        const char *
+        GetFlavorString ()
+        {
+            if (flavor_string.empty() || flavor_string == "default")
+                return NULL;
+            return flavor_string.c_str();
+        }
+        
         virtual Error
         OptionParsingFinished ();
 
@@ -61,15 +70,17 @@ public:
         uint32_t num_instructions;
         bool raw;
         std::string func_name;
-        bool cur_function;
+        bool current_function;
         lldb::addr_t start_addr;
         lldb::addr_t end_addr;
         bool at_pc;
         bool frame_line;
         std::string plugin_name;
+        std::string flavor_string;
         ArchSpec arch;
         bool some_location_specified; // If no location was specified, we'll select "at_pc".  This should be set
                                       // in SetOptionValue if anything the selects a location is set.
+        lldb::addr_t symbol_containing_addr;
         static OptionDefinition g_option_table[];
     };
 

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectExpression.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectExpression.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectExpression.h"
 
 // C Includes
@@ -50,9 +52,10 @@ CommandObjectExpression::CommandOptions:
 OptionDefinition
 CommandObjectExpression::CommandOptions::g_option_table[] =
 {
-    { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "dynamic-value",      'd', required_argument, NULL, 0, eArgTypeBoolean,    "Upcast the value resulting from the expression to its dynamic type if available."},
-    { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error",    'u', required_argument, NULL, 0, eArgTypeBoolean,    "Clean up program state if the expression causes a crash, breakpoint hit or signal."},
-    { LLDB_OPT_SET_2                 , false, "object-description", 'o', no_argument,       NULL, 0, eArgTypeNone,       "Print the object description of the value resulting from the expression."},
+    { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "all-threads",        'a', required_argument, NULL, 0, eArgTypeBoolean,    "Should we run all threads if the execution doesn't complete on one thread."},
+    { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "ignore-breakpoints", 'i', required_argument, NULL, 0, eArgTypeBoolean,    "Ignore breakpoint hits while running expressions"},
+    { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "timeout",            't', required_argument, NULL, 0, eArgTypeUnsignedInteger,  "Timeout value (in microseconds) for running the expression."},
+    { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error",    'u', required_argument, NULL, 0, eArgTypeBoolean,    "Clean up program state if the expression causes a crash, or raises a signal.  Note, unlike gdb hitting a breakpoint is controlled by another option (-i)."},
 };
 
 
@@ -69,7 +72,7 @@ CommandObjectExpression::CommandOptions:
 {
     Error error;
 
-    const char short_option = (char) g_option_table[option_idx].short_option;
+    const int short_option = g_option_table[option_idx].short_option;
 
     switch (short_option)
     {
@@ -80,32 +83,47 @@ CommandObjectExpression::CommandOptions:
       //}
       //break;
 
-    case 'o':
-        print_object = true;
-        break;
-        
-    case 'd':
+    case 'a':
         {
             bool success;
             bool result;
             result = Args::StringToBoolean(option_arg, true, &success);
             if (!success)
-                error.SetErrorStringWithFormat("invalid dynamic value setting: \"%s\"", option_arg);
+                error.SetErrorStringWithFormat("invalid all-threads value setting: \"%s\"", option_arg);
             else
-            {
-                if (result)
-                    use_dynamic = eLazyBoolYes;  
-                else
-                    use_dynamic = eLazyBoolNo;
-            }
+                try_all_threads = result;
+        }
+        break;
+        
+    case 'i':
+        {
+            bool success;
+            bool tmp_value = Args::StringToBoolean(option_arg, true, &success);
+            if (success)
+                ignore_breakpoints = tmp_value;
+            else
+                error.SetErrorStringWithFormat("could not convert \"%s\" to a boolean value.", option_arg);
+            break;
+        }
+    case 't':
+        {
+            bool success;
+            uint32_t result;
+            result = Args::StringToUInt32(option_arg, 0, 0, &success);
+            if (success)
+                timeout = result;
+            else
+                error.SetErrorStringWithFormat ("invalid timeout setting \"%s\"", option_arg);
         }
         break;
         
     case 'u':
         {
             bool success;
-            unwind_on_error = Args::StringToBoolean(option_arg, true, &success);
-            if (!success)
+            bool tmp_value = Args::StringToBoolean(option_arg, true, &success);
+            if (success)
+                unwind_on_error = tmp_value;
+            else
                 error.SetErrorStringWithFormat("could not convert \"%s\" to a boolean value.", option_arg);
             break;
         }
@@ -120,11 +138,21 @@ CommandObjectExpression::CommandOptions:
 void
 CommandObjectExpression::CommandOptions::OptionParsingStarting (CommandInterpreter &interpreter)
 {
-    use_dynamic = eLazyBoolCalculate;
-    print_object = false;
-    unwind_on_error = true;
-    show_types = true;
+    Process *process = interpreter.GetExecutionContext().GetProcessPtr();
+    if (process != NULL)
+    {
+        ignore_breakpoints = process->GetIgnoreBreakpointsInExpressions();
+        unwind_on_error    = process->GetUnwindOnErrorInExpressions();
+    }
+    else
+    {
+        ignore_breakpoints = false;
+        unwind_on_error = true;
+    }
+    
     show_summary = true;
+    try_all_threads = true;
+    timeout = 0;
 }
 
 const OptionDefinition*
@@ -136,9 +164,9 @@ CommandObjectExpression::CommandOptions:
 CommandObjectExpression::CommandObjectExpression (CommandInterpreter &interpreter) :
     CommandObjectRaw (interpreter,
                       "expression",
-                      "Evaluate a C/ObjC/C++ expression in the current program context, using variables currently in scope.",
+                      "Evaluate a C/ObjC/C++ expression in the current program context, using user defined variables and variables currently in scope.",
                       NULL,
-                      eFlagProcessMustBePaused),
+                      eFlagProcessMustBePaused | eFlagTryTargetAPILock),
     m_option_group (interpreter),
     m_format_options (eFormatDefault),
     m_command_options (),
@@ -146,10 +174,24 @@ CommandObjectExpression::CommandObjectEx
     m_expr_lines ()
 {
   SetHelpLong(
-"Examples: \n\
+"Timeouts:\n\
+    If the expression can be evaluated statically (without runnning code) then it will be.\n\
+    Otherwise, by default the expression will run on the current thread with a short timeout:\n\
+    currently .25 seconds.  If it doesn't return in that time, the evaluation will be interrupted\n\
+    and resumed with all threads running.  You can use the -a option to disable retrying on all\n\
+    threads.  You can use the -t option to set a shorter timeout.\n\
+\n\
+User defined variables:\n\
+    You can define your own variables for convenience or to be used in subsequent expressions.\n\
+    You define them the same way you would define variables in C.  If the first character of \n\
+    your user defined variable is a $, then the variable's value will be available in future\n\
+    expressions, otherwise it will just be available in the current expression.\n\
+\n\
+Examples: \n\
 \n\
    expr my_struct->a = my_array[3] \n\
    expr -f bin -- (index * 8) + 5 \n\
+   expr unsigned int $foo = 5\n\
    expr char c[] = \"foo\"; c[0]\n");
 
     CommandArgumentEntry arg;
@@ -168,6 +210,7 @@ CommandObjectExpression::CommandObjectEx
     // Add the "--format" and "--gdb-format"
     m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT | OptionGroupFormat::OPTION_GROUP_GDB_FMT, LLDB_OPT_SET_1);
     m_option_group.Append (&m_command_options);
+    m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1 | LLDB_OPT_SET_2);
     m_option_group.Finalize();
 }
 
@@ -271,7 +314,12 @@ CommandObjectExpression::EvaluateExpress
     CommandReturnObject *result
 )
 {
-    Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
+    // Don't use m_exe_ctx as this might be called asynchronously
+    // after the command object DoExecute has finished when doing
+    // multi-line expression that use an input reader...
+    ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+
+    Target *target = exe_ctx.GetTargetPtr();
     
     if (!target)
         target = Host::GetDummyTarget(m_interpreter.GetDebugger()).get();
@@ -283,37 +331,28 @@ CommandObjectExpression::EvaluateExpress
         ExecutionResults exe_results;
         
         bool keep_in_memory = true;
-        lldb::DynamicValueType use_dynamic;
-        // If use dynamic is not set, get it from the target:
-        switch (m_command_options.use_dynamic)
-        {
-        case eLazyBoolCalculate:
-            use_dynamic = target->GetPreferDynamicValue();
-            break;
-        case eLazyBoolYes:
-            use_dynamic = lldb::eDynamicCanRunTarget;
-            break;
-        case eLazyBoolNo:
-            use_dynamic = lldb::eNoDynamicValues;
-            break;
-        }
+
+        EvaluateExpressionOptions options;
+        options.SetCoerceToId(m_varobj_options.use_objc)
+        .SetUnwindOnError(m_command_options.unwind_on_error)
+        .SetIgnoreBreakpoints (m_command_options.ignore_breakpoints)
+        .SetKeepInMemory(keep_in_memory)
+        .SetUseDynamic(m_varobj_options.use_dynamic)
+        .SetRunOthers(m_command_options.try_all_threads)
+        .SetTimeoutUsec(m_command_options.timeout);
         
         exe_results = target->EvaluateExpression (expr, 
-                                                  m_interpreter.GetExecutionContext().GetFramePtr(),
-                                                  eExecutionPolicyOnlyWhenNeeded,
-                                                  m_command_options.print_object,
-                                                  m_command_options.unwind_on_error,
-                                                  keep_in_memory, 
-                                                  use_dynamic, 
+                                                  exe_ctx.GetFramePtr(),
                                                   result_valobj_sp,
-                                                  0 /* no timeout */);
+                                                  options);
         
-        if (exe_results == eExecutionInterrupted && !m_command_options.unwind_on_error)
+        if ((exe_results == eExecutionInterrupted && !m_command_options.unwind_on_error)
+            ||(exe_results == eExecutionHitBreakpoint && !m_command_options.ignore_breakpoints))
         {
             uint32_t start_frame = 0;
             uint32_t num_frames = 1;
             uint32_t num_frames_with_source = 0;
-            Thread *thread = m_interpreter.GetExecutionContext().GetThreadPtr();
+            Thread *thread = exe_ctx.GetThreadPtr();
             if (thread)
             {
                 thread->GetStatus (result->GetOutputStream(), 
@@ -323,7 +362,7 @@ CommandObjectExpression::EvaluateExpress
             }
             else 
             {
-                Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+                Process *process = exe_ctx.GetProcessPtr();
                 if (process)
                 {
                     bool only_threads_with_stop_reason = true;
@@ -347,22 +386,8 @@ CommandObjectExpression::EvaluateExpress
                     if (format != eFormatDefault)
                         result_valobj_sp->SetFormat (format);
 
-                    ValueObject::DumpValueObjectOptions options;
-                    options.SetMaximumPointerDepth(0)
-                    .SetMaximumDepth(UINT32_MAX)
-                    .SetShowLocation(false)
-                    .SetShowTypes(m_command_options.show_types)
-                    .SetUseObjectiveC(m_command_options.print_object)
-                    .SetUseDynamicType(use_dynamic)
-                    .SetScopeChecked(true)
-                    .SetFlatOutput(false)
-                    .SetUseSyntheticValue(true)
-                    .SetIgnoreCap(false)
-                    .SetFormat(format)
-                    .SetSummary()
-                    .SetShowSummary(!m_command_options.print_object)
-                    .SetHideRootType(m_command_options.print_object);
-                    
+                    ValueObject::DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(true,format));
+
                     ValueObject::DumpValueObject (*(output_stream),
                                                   result_valobj_sp.get(),   // Variable object to dump
                                                   options);
@@ -387,7 +412,7 @@ CommandObjectExpression::EvaluateExpress
                     const char *error_cstr = result_valobj_sp->GetError().AsCString();
                     if (error_cstr && error_cstr[0])
                     {
-                        int error_cstr_len = strlen (error_cstr);
+                        const size_t error_cstr_len = strlen (error_cstr);
                         const bool ends_with_newline = error_cstr[error_cstr_len - 1] == '\n';
                         if (strstr(error_cstr, "error:") != error_cstr)
                             error_stream->PutCString ("error: ");

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectExpression.h?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectExpression.h (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectExpression.h Thu Jun  6 19:06:43 2013
@@ -16,6 +16,7 @@
 // Project includes
 #include "lldb/Interpreter/CommandObject.h"
 #include "lldb/Interpreter/OptionGroupFormat.h"
+#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
 #include "lldb/Target/ExecutionContext.h"
 
 namespace lldb_private {
@@ -50,11 +51,12 @@ public:
         // Options table: Required for subclasses of Options.
 
         static OptionDefinition g_option_table[];
-        bool        print_object;
-        LazyBool    use_dynamic;
         bool        unwind_on_error;
+        bool        ignore_breakpoints;
         bool        show_types;
         bool        show_summary;
+        uint32_t    timeout;
+        bool        try_all_threads;
     };
 
     CommandObjectExpression (CommandInterpreter &interpreter);
@@ -86,6 +88,7 @@ protected:
 
     OptionGroupOptions m_option_group;
     OptionGroupFormat m_format_options;
+    OptionGroupValueObjectDisplay m_varobj_options;
     CommandOptions m_command_options;
     uint32_t m_expr_line_count;
     std::string m_expr_lines; // Multi-line expression support

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectFrame.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectFrame.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectFrame.h"
 
 // C Includes
@@ -14,7 +16,6 @@
 #include <string>
 // Other libraries and framework includes
 // Project includes
-#include "lldb/Core/DataVisualization.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/StreamFile.h"
@@ -23,6 +24,7 @@
 #include "lldb/Core/Value.h"
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
@@ -61,7 +63,10 @@ public:
                              "frame info",
                              "List information about the currently selected frame in the current thread.",
                              "frame info",
-                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+                             eFlagRequiresFrame         |
+                             eFlagTryTargetAPILock      |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused   )
     {
     }
 
@@ -71,21 +76,10 @@ public:
 
 protected:
     bool
-    DoExecute (Args& command,
-             CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-        StackFrame *frame = exe_ctx.GetFramePtr();
-        if (frame)
-        {
-            frame->DumpUsingSettingsFormat (&result.GetOutputStream());
-            result.SetStatus (eReturnStatusSuccessFinishResult);
-        }
-        else
-        {
-            result.AppendError ("no current frame");
-            result.SetStatus (eReturnStatusFailed);
-        }
+        m_exe_ctx.GetFrameRef().DumpUsingSettingsFormat (&result.GetOutputStream());
+        result.SetStatus (eReturnStatusSuccessFinishResult);
         return result.Succeeded();
     }
 };
@@ -120,7 +114,7 @@ public:
         {
             Error error;
             bool success = false;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             switch (short_option)
             {
             case 'r':   
@@ -160,7 +154,10 @@ public:
                              "frame select",
                              "Select a frame by index from within the current thread and make it the current frame.",
                              NULL,
-                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+                             eFlagRequiresThread        |
+                             eFlagTryTargetAPILock      |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused   ),
         m_options (interpreter)
     {
         CommandArgumentEntry arg;
@@ -191,112 +188,92 @@ public:
 
 protected:
     bool
-    DoExecute (Args& command,
-             CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
-        Thread *thread = exe_ctx.GetThreadPtr();
-        if (thread)
+        // No need to check "thread" for validity as eFlagRequiresThread ensures it is valid
+        Thread *thread = m_exe_ctx.GetThreadPtr();
+
+        uint32_t frame_idx = UINT32_MAX;
+        if (m_options.relative_frame_offset != INT32_MIN)
         {
-            uint32_t frame_idx = UINT32_MAX;
-            if (m_options.relative_frame_offset != INT32_MIN)
+            // The one and only argument is a signed relative frame index
+            frame_idx = thread->GetSelectedFrameIndex ();
+            if (frame_idx == UINT32_MAX)
+                frame_idx = 0;
+            
+            if (m_options.relative_frame_offset < 0)
             {
-                // The one and only argument is a signed relative frame index
-                frame_idx = thread->GetSelectedFrameIndex ();
-                if (frame_idx == UINT32_MAX)
-                    frame_idx = 0;
-                
-                if (m_options.relative_frame_offset < 0)
+                if (frame_idx >= -m_options.relative_frame_offset)
+                    frame_idx += m_options.relative_frame_offset;
+                else
                 {
-                    if (frame_idx >= -m_options.relative_frame_offset)
-                        frame_idx += m_options.relative_frame_offset;
-                    else
+                    if (frame_idx == 0)
                     {
-                        if (frame_idx == 0)
-                        {
-                            //If you are already at the bottom of the stack, then just warn and don't reset the frame.
-                            result.AppendError("Already at the bottom of the stack");
-                            result.SetStatus(eReturnStatusFailed);
-                            return false;
-                        }
-                        else
-                            frame_idx = 0;
+                        //If you are already at the bottom of the stack, then just warn and don't reset the frame.
+                        result.AppendError("Already at the bottom of the stack");
+                        result.SetStatus(eReturnStatusFailed);
+                        return false;
                     }
-                }
-                else if (m_options.relative_frame_offset > 0)
-                {
-                    // I don't want "up 20" where "20" takes you past the top of the stack to produce
-                    // an error, but rather to just go to the top.  So I have to count the stack here...
-                    const uint32_t num_frames = thread->GetStackFrameCount();
-                    if (num_frames - frame_idx > m_options.relative_frame_offset)
-                        frame_idx += m_options.relative_frame_offset;
                     else
-                    {
-                        if (frame_idx == num_frames - 1)
-                        {
-                            //If we are already at the top of the stack, just warn and don't reset the frame.
-                            result.AppendError("Already at the top of the stack");
-                            result.SetStatus(eReturnStatusFailed);
-                            return false;
-                        }
-                        else
-                            frame_idx = num_frames - 1;
-                    }
+                        frame_idx = 0;
                 }
             }
-            else 
+            else if (m_options.relative_frame_offset > 0)
             {
-                if (command.GetArgumentCount() == 1)
-                {
-                    const char *frame_idx_cstr = command.GetArgumentAtIndex(0);
-                    frame_idx = Args::StringToUInt32 (frame_idx_cstr, UINT32_MAX, 0);
-                }
-                else if (command.GetArgumentCount() == 0)
+                // I don't want "up 20" where "20" takes you past the top of the stack to produce
+                // an error, but rather to just go to the top.  So I have to count the stack here...
+                const uint32_t num_frames = thread->GetStackFrameCount();
+                if (num_frames - frame_idx > m_options.relative_frame_offset)
+                    frame_idx += m_options.relative_frame_offset;
+                else
                 {
-                    frame_idx = thread->GetSelectedFrameIndex ();
-                    if (frame_idx == UINT32_MAX)
+                    if (frame_idx == num_frames - 1)
                     {
-                        frame_idx = 0;
+                        //If we are already at the top of the stack, just warn and don't reset the frame.
+                        result.AppendError("Already at the top of the stack");
+                        result.SetStatus(eReturnStatusFailed);
+                        return false;
                     }
+                    else
+                        frame_idx = num_frames - 1;
                 }
-                else
-                {
-                    result.AppendError ("invalid arguments.\n");
-                    m_options.GenerateOptionUsage (result.GetErrorStream(), this);
-                }
             }
-                
-            bool success = thread->SetSelectedFrameByIndex (frame_idx);
-            if (success)
+        }
+        else 
+        {
+            if (command.GetArgumentCount() == 1)
+            {
+                const char *frame_idx_cstr = command.GetArgumentAtIndex(0);
+                frame_idx = Args::StringToUInt32 (frame_idx_cstr, UINT32_MAX, 0);
+            }
+            else if (command.GetArgumentCount() == 0)
             {
-                exe_ctx.SetFrameSP(thread->GetSelectedFrame ());
-                StackFrame *frame = exe_ctx.GetFramePtr();
-                if (frame)
+                frame_idx = thread->GetSelectedFrameIndex ();
+                if (frame_idx == UINT32_MAX)
                 {
-                    bool already_shown = false;
-                    SymbolContext frame_sc(frame->GetSymbolContext(eSymbolContextLineEntry));
-                    if (m_interpreter.GetDebugger().GetUseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0)
-                    {
-                        already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line);
-                    }
-
-                    bool show_frame_info = true;
-                    bool show_source = !already_shown;
-                    if (frame->GetStatus (result.GetOutputStream(), show_frame_info, show_source))
-                    {
-                        result.SetStatus (eReturnStatusSuccessFinishResult);
-                        return result.Succeeded();
-                    }
+                    frame_idx = 0;
                 }
             }
-            result.AppendErrorWithFormat ("Frame index (%u) out of range.\n", frame_idx);
+            else
+            {
+                result.AppendError ("invalid arguments.\n");
+                m_options.GenerateOptionUsage (result.GetErrorStream(), this);
+            }
+        }
+
+        bool success = thread->SetSelectedFrameByIndexNoisily (frame_idx, result.GetOutputStream());
+        if (success)
+        {
+            m_exe_ctx.SetFrameSP(thread->GetSelectedFrame ());
+            result.SetStatus (eReturnStatusSuccessFinishResult);
         }
         else
         {
-            result.AppendError ("no current thread");
+            result.AppendErrorWithFormat ("Frame index (%u) out of range.\n", frame_idx);
+            result.SetStatus (eReturnStatusFailed);
         }
-        result.SetStatus (eReturnStatusFailed);
-        return false;
+        
+        return result.Succeeded();
     }
 protected:
 
@@ -307,7 +284,7 @@ OptionDefinition
 CommandObjectFrameSelect::CommandOptions::g_option_table[] =
 {
 { LLDB_OPT_SET_1, false, "relative", 'r', required_argument, NULL, 0, eArgTypeOffset, "A relative frame index offset from the current frame index."},
-{ 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL }
+{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 
 #pragma mark CommandObjectFrameVariable
@@ -328,7 +305,11 @@ public:
                              "Children of aggregate variables can be specified such as "
                              "'var->child.x'.",
                              NULL,
-                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+                             eFlagRequiresFrame |
+                             eFlagTryTargetAPILock |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused |
+                             eFlagRequiresProcess),
         m_option_group (interpreter),
         m_option_variable(true), // Include the frame specific options by passing "true"
         m_option_format (eFormatDefault),
@@ -364,19 +345,39 @@ public:
     {
         return &m_option_group;
     }
+    
+    
+    virtual int
+    HandleArgumentCompletion (Args &input,
+                              int &cursor_index,
+                              int &cursor_char_position,
+                              OptionElementVector &opt_element_vector,
+                              int match_start_point,
+                              int max_return_elements,
+                              bool &word_complete,
+                              StringList &matches)
+    {
+        // Arguments are the standard source file completer.
+        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
+        completion_str.erase (cursor_char_position);
+        
+        CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
+                                                             CommandCompletions::eVariablePathCompletion,
+                                                             completion_str.c_str(),
+                                                             match_start_point,
+                                                             max_return_elements,
+                                                             NULL,
+                                                             word_complete,
+                                                             matches);
+        return matches.GetSize();
+    }
 
 protected:
     virtual bool
     DoExecute (Args& command, CommandReturnObject &result)
     {
-        ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-        StackFrame *frame = exe_ctx.GetFramePtr();
-        if (frame == NULL)
-        {
-            result.AppendError ("you must be stopped in a valid stack frame to view frame variables.");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
+        // No need to check "frame" for validity as eFlagRequiresFrame ensures it is valid
+        StackFrame *frame = m_exe_ctx.GetFramePtr();
 
         Stream &s = result.GetOutputStream();
 
@@ -399,22 +400,7 @@ protected:
         else if (!m_option_variable.summary_string.IsCurrentValueEmpty())
             summary_format_sp.reset(new StringSummaryFormat(TypeSummaryImpl::Flags(),m_option_variable.summary_string.GetCurrentValue()));
         
-        ValueObject::DumpValueObjectOptions options;
-        
-        options.SetMaximumPointerDepth(m_varobj_options.ptr_depth)
-            .SetMaximumDepth(m_varobj_options.max_depth)
-            .SetShowTypes(m_varobj_options.show_types)
-            .SetShowLocation(m_varobj_options.show_location)
-            .SetUseObjectiveC(m_varobj_options.use_objc)
-            .SetUseDynamicType(m_varobj_options.use_dynamic)
-            .SetUseSyntheticValue(m_varobj_options.use_synth)
-            .SetFlatOutput(m_varobj_options.flat_output)
-            .SetOmitSummaryDepth(m_varobj_options.no_summary_depth)
-            .SetIgnoreCap(m_varobj_options.ignore_cap)
-            .SetSummary(summary_format_sp);
-
-        if (m_varobj_options.be_raw)
-            options.SetRawDisplay(true);
+        ValueObject::DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(false,eFormatDefault,summary_format_sp));
         
         if (variable_list)
         {
@@ -431,7 +417,7 @@ protected:
                 {
                     if (m_option_variable.use_regex)
                     {
-                        const uint32_t regex_start_index = regex_var_list.GetSize();
+                        const size_t regex_start_index = regex_var_list.GetSize();
                         RegularExpression regex (name_cstr);
                         if (regex.Compile(name_cstr))
                         {
@@ -441,7 +427,7 @@ protected:
                                                                                                      num_matches);
                             if (num_new_regex_vars > 0)
                             {
-                                for (uint32_t regex_idx = regex_start_index, end_index = regex_var_list.GetSize(); 
+                                for (size_t regex_idx = regex_start_index, end_index = regex_var_list.GetSize();
                                      regex_idx < end_index;
                                      ++regex_idx)
                                 {
@@ -524,10 +510,10 @@ protected:
             }
             else // No command arg specified.  Use variable_list, instead.
             {
-                const uint32_t num_variables = variable_list->GetSize();
+                const size_t num_variables = variable_list->GetSize();
                 if (num_variables > 0)
                 {
-                    for (uint32_t i=0; i<num_variables; i++)
+                    for (size_t i=0; i<num_variables; i++)
                     {
                         var_sp = variable_list->GetVariableAtIndex(i);
                         bool dump_variable = true;

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectHelp.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectHelp.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectHelp.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectHelp.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectHelp.h"
 
 // C Includes
@@ -62,7 +64,7 @@ CommandObjectHelp::DoExecute (Args& comm
 {
     CommandObject::CommandMap::iterator pos;
     CommandObject *cmd_obj;
-    const int argc = command.GetArgumentCount ();
+    const size_t argc = command.GetArgumentCount ();
     
     // 'help' doesn't take any arguments, other than command names.  If argc is 0, we show the user
     // all commands (aliases and user commands if asked for).  Otherwise every argument must be the name of a command or a sub-command.
@@ -103,8 +105,7 @@ CommandObjectHelp::DoExecute (Args& comm
                 else
                 {
                     CommandObject *found_cmd;
-                    found_cmd = ((CommandObjectMultiword *) sub_cmd_obj)->GetSubcommandObject(sub_command.c_str(), 
-                                                                                              &matches);
+                    found_cmd = sub_cmd_obj->GetSubcommandObject(sub_command.c_str(), &matches);
                     if (found_cmd == NULL)
                         all_okay = false;
                     else if (matches.GetSize() > 1)
@@ -172,8 +173,9 @@ CommandObjectHelp::DoExecute (Args& comm
                     {
                             // Also emit a warning about using "--" in case you are using a command that takes options and arguments.
                             m_interpreter.OutputFormattedHelpText (output_strm, "", "",
-                                                                   "\nThis command takes options and arguments, if your arguments look like option specifiers"
-                                                                   " you must use '--' to terminate the options before starting to give the arguments.", 1);
+                                                                   "\nThis command takes options and free-form arguments.  If your arguments resemble"
+                                                                   " option specifiers (i.e., they start with a - or --), you must use ' -- ' between"
+                                                                   " the end of the command options and the beginning of the arguments.", 1);
                     }
 
                     // Mark this help command with a success status.
@@ -189,7 +191,7 @@ CommandObjectHelp::DoExecute (Args& comm
                     }
                     else
                         m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
-                    ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (result);
+                    sub_cmd_obj->GenerateHelpText (result);
                 }
                 else
                 {
@@ -222,8 +224,8 @@ CommandObjectHelp::DoExecute (Args& comm
         {
             Stream &output_strm = result.GetOutputStream();
             output_strm.Printf("Help requested with ambiguous command name, possible completions:\n");
-            const uint32_t match_count = matches.GetSize();
-            for (uint32_t i = 0; i < match_count; i++)
+            const size_t match_count = matches.GetSize();
+            for (size_t i = 0; i < match_count; i++)
             {
                 output_strm.Printf("\t%s\n", matches.GetStringAtIndex(i));
             }

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectHelp.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectHelp.h?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectHelp.h (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectHelp.h Thu Jun  6 19:06:43 2013
@@ -57,7 +57,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectLog.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectLog.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectLog.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectLog.h"
 
 // C Includes
@@ -132,11 +134,11 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
-            case 'f':  log_file = option_arg;                                 break;
+            case 'f':  log_file.SetFile(option_arg, true);                    break;
             case 't':  log_options |= LLDB_LOG_OPTION_THREADSAFE;             break;
             case 'v':  log_options |= LLDB_LOG_OPTION_VERBOSE;                break;
             case 'g':  log_options |= LLDB_LOG_OPTION_DEBUG;                  break;
@@ -144,6 +146,7 @@ public:
             case 'T':  log_options |= LLDB_LOG_OPTION_PREPEND_TIMESTAMP;      break;
             case 'p':  log_options |= LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD;break;
             case 'n':  log_options |= LLDB_LOG_OPTION_PREPEND_THREAD_NAME;    break;
+            case 'S':  log_options |= LLDB_LOG_OPTION_BACKTRACE;              break;
             default:
                 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
                 break;
@@ -155,7 +158,7 @@ public:
         void
         OptionParsingStarting ()
         {
-            log_file.clear();
+            log_file.Clear();
             log_options = 0;
         }
 
@@ -171,7 +174,7 @@ public:
 
         // Instance variables to hold the values for command options.
 
-        std::string log_file;
+        FileSpec log_file;
         uint32_t log_options;
     };
 
@@ -188,9 +191,14 @@ protected:
         {
             std::string channel(args.GetArgumentAtIndex(0));
             args.Shift ();  // Shift off the channel
+            char log_file[PATH_MAX];
+            if (m_options.log_file)
+                m_options.log_file.GetPath(log_file, sizeof(log_file));
+            else
+                log_file[0] = '\0';
             bool success = m_interpreter.GetDebugger().EnableLog (channel.c_str(), 
                                                                   args.GetConstArgumentVector(), 
-                                                                  m_options.log_file.c_str(), 
+                                                                  log_file, 
                                                                   m_options.log_options, 
                                                                   result.GetErrorStream());
             if (success)
@@ -215,6 +223,7 @@ CommandObjectLogEnable::CommandOptions::
 { LLDB_OPT_SET_1, false, "timestamp",  'T', no_argument,       NULL, 0, eArgTypeNone,       "Prepend all log lines with a timestamp." },
 { LLDB_OPT_SET_1, false, "pid-tid",    'p', no_argument,       NULL, 0, eArgTypeNone,       "Prepend all log lines with the process and thread ID that generates the log line." },
 { LLDB_OPT_SET_1, false, "thread-name",'n', no_argument,       NULL, 0, eArgTypeNone,       "Prepend all log lines with the thread name for the thread that generates the log line." },
+{ LLDB_OPT_SET_1, false, "stack",      'S', no_argument,       NULL, 0, eArgTypeNone,       "Append a stack backtrace to each log line." },
 { 0, false, NULL,                       0,  0,                 NULL, 0, eArgTypeNone,       NULL }
 };
 
@@ -273,7 +282,7 @@ protected:
 
             std::string channel(args.GetArgumentAtIndex(0));
             args.Shift ();  // Shift off the channel
-            if (Log::GetLogChannelCallbacks (channel.c_str(), log_callbacks))
+            if (Log::GetLogChannelCallbacks (ConstString(channel.c_str()), log_callbacks))
             {
                 log_callbacks.disable (args.GetConstArgumentVector(), &result.GetErrorStream());
                 result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -347,7 +356,7 @@ protected:
                 Log::Callbacks log_callbacks;
 
                 std::string channel(args.GetArgumentAtIndex(i));
-                if (Log::GetLogChannelCallbacks (channel.c_str(), log_callbacks))
+                if (Log::GetLogChannelCallbacks (ConstString(channel.c_str()), log_callbacks))
                 {
                     log_callbacks.list_categories (&result.GetOutputStream());
                     result.SetStatus(eReturnStatusSuccessFinishResult);

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectMemory.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectMemory.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectMemory.h"
 
 // C Includes
@@ -16,6 +18,7 @@
 #include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/StreamString.h"
 #include "lldb/Core/ValueObjectMemory.h"
 #include "lldb/Interpreter/Args.h"
@@ -25,7 +28,8 @@
 #include "lldb/Interpreter/OptionGroupFormat.h"
 #include "lldb/Interpreter/OptionGroupOutputFile.h"
 #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
-#include "lldb/Symbol/ClangNamespaceDecl.h"
+#include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Symbol/TypeList.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/StackFrame.h"
 
@@ -37,8 +41,10 @@ g_option_table[] =
 {
     { LLDB_OPT_SET_1, false, "num-per-line" ,'l', required_argument, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."},
     { LLDB_OPT_SET_2, false, "binary"       ,'b', no_argument      , NULL, 0, eArgTypeNone          ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."},
-    { LLDB_OPT_SET_3, true , "view-as"      ,'t', required_argument, NULL, 0, eArgTypeNone          ,"The name of a type to view memory as."}, 
-    { LLDB_OPT_SET_4, false, "force"        ,'r', no_argument,       NULL, 0, eArgTypeNone          ,"Necessary if reading over 1024 bytes of memory."},
+    { LLDB_OPT_SET_3, true , "type"         ,'t', required_argument, NULL, 0, eArgTypeNone          ,"The name of a type to view memory as."}, 
+    { LLDB_OPT_SET_1|
+      LLDB_OPT_SET_2|
+      LLDB_OPT_SET_3, false, "force"        ,'r', no_argument,       NULL, 0, eArgTypeNone          ,"Necessary if reading over target.max-memory-read-size bytes."},
 };
 
 
@@ -78,7 +84,7 @@ public:
                     const char *option_arg)
     {
         Error error;
-        char short_option = (char) g_option_table[option_idx].short_option;
+        const int short_option = g_option_table[option_idx].short_option;
         
         switch (short_option)
         {
@@ -113,6 +119,7 @@ public:
         m_num_per_line.Clear();
         m_output_as_binary = false;
         m_view_as_type.Clear();
+        m_force = false;
     }
     
     Error
@@ -144,7 +151,7 @@ public:
 
             case eFormatInstruction:
                 if (count_option_set)
-                    byte_size_value = target->GetArchitecture().GetMaximumOpcodeByteSize() * format_options.GetCountValue().GetCurrentValue();
+                    byte_size_value = target->GetArchitecture().GetMaximumOpcodeByteSize();
                 m_num_per_line = 1;
                 break;
 
@@ -186,7 +193,7 @@ public:
                 if (byte_size_option_set)
                 {
                     if (byte_size_value > 1)
-                        error.SetErrorStringWithFormat ("display format (bytes/bytes with ascii) conflicts with the specified byte size %llu\n"
+                        error.SetErrorStringWithFormat ("display format (bytes/bytes with ascii) conflicts with the specified byte size %" PRIu64 "\n"
                                                         "\tconsider using a different display format or don't specify the byte size",
                                                         byte_size_value.GetCurrentValue());
                 }
@@ -215,6 +222,14 @@ public:
                 if (!count_option_set)
                     format_options.GetCountValue() = 8;
                 break;
+            case eFormatComplexInteger:
+                if (!byte_size_option_set)
+                    byte_size_value = 8;
+                if (!num_per_line_option_set)
+                    m_num_per_line = 1;
+                if (!count_option_set)
+                    format_options.GetCountValue() = 8;
+                break;
             case eFormatHex:
                 if (!byte_size_option_set)
                     byte_size_value = 4;
@@ -292,7 +307,7 @@ public:
                              "memory read",
                              "Read from the memory of the process being debugged.",
                              NULL,
-                             eFlagProcessMustBePaused),
+                             eFlagRequiresTarget | eFlagProcessMustBePaused),
         m_option_group (interpreter),
         m_format_options (eFormatBytesWithASCII, 1, 8),
         m_memory_options (),
@@ -311,14 +326,14 @@ public:
         CommandArgumentData end_addr_arg;
         
         // Define the first (and only) variant of this arg.
-        start_addr_arg.arg_type = eArgTypeStartAddress;
+        start_addr_arg.arg_type = eArgTypeAddressOrExpression;
         start_addr_arg.arg_repetition = eArgRepeatPlain;
         
         // There is only one variant this argument could be; put it into the argument entry.
         arg1.push_back (start_addr_arg);
         
         // Define the first (and only) variant of this arg.
-        end_addr_arg.arg_type = eArgTypeEndAddress;
+        end_addr_arg.arg_type = eArgTypeAddressOrExpression;
         end_addr_arg.arg_repetition = eArgRepeatOptional;
         
         // There is only one variant this argument could be; put it into the argument entry.
@@ -363,23 +378,17 @@ public:
 
 protected:
     virtual bool
-    DoExecute (Args& command,
-             CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
-        Target *target = exe_ctx.GetTargetPtr();
-        if (target == NULL)
-        {
-            result.AppendError("need at least a target to read memory");
-            result.SetStatus(eReturnStatusFailed);
-            return false;
-        }
+        // No need to check "target" for validity as eFlagRequiresTarget ensures it is valid
+        Target *target = m_exe_ctx.GetTargetPtr();
+
         const size_t argc = command.GetArgumentCount();
 
-        
         if ((argc == 0 && m_next_addr == LLDB_INVALID_ADDRESS) || argc > 2)
         {
-            result.AppendErrorWithFormat ("%s takes 1 or two args.\n", m_cmd_name.c_str());
+            result.AppendErrorWithFormat ("%s takes a start address expression with an optional end address expression.\n", m_cmd_name.c_str());
+            result.AppendRawWarning("Expressions should be quoted if they contain spaces or other special characters.\n");
             result.SetStatus(eReturnStatusFailed);
             return false;
         }
@@ -387,11 +396,11 @@ protected:
         ClangASTType clang_ast_type;        
         Error error;
 
-        Format format = m_format_options.GetFormat();
         const char *view_as_type_cstr = m_memory_options.m_view_as_type.GetCurrentValue();
         if (view_as_type_cstr && view_as_type_cstr[0])
         {
             // We are viewing memory as a type
+            
             SymbolContext sc;
             const bool exact_match = false;
             TypeList type_list;
@@ -490,7 +499,7 @@ protected:
             }
                     
             ConstString lookup_type_name(type_str.c_str());
-            StackFrame *frame = exe_ctx.GetFramePtr();
+            StackFrame *frame = m_exe_ctx.GetFramePtr();
             if (frame)
             {
                 sc = frame->GetSymbolContext (eSymbolContextModule);
@@ -538,7 +547,7 @@ protected:
                 --pointer_count;
             }
 
-            m_format_options.GetByteSizeValue() = (clang_ast_type.GetClangTypeBitWidth () + 7) / 8;
+            m_format_options.GetByteSizeValue() = clang_ast_type.GetClangTypeByteSize();
             
             if (m_format_options.GetByteSizeValue() == 0)
             {
@@ -559,7 +568,7 @@ protected:
         // Look for invalid combinations of settings
         if (error.Fail())
         {
-            result.AppendErrorWithFormat("%s", error.AsCString());
+            result.AppendError(error.AsCString());
             result.SetStatus(eReturnStatusFailed);
             return false;
         }
@@ -572,7 +581,8 @@ protected:
             // if no options have been set
             addr = m_next_addr;
             total_byte_size = m_prev_byte_size;
-            if (!m_format_options.AnyOptionWasSet() && 
+            clang_ast_type = m_prev_clang_ast_type;
+            if (!m_format_options.AnyOptionWasSet() &&
                 !m_memory_options.AnyOptionWasSet() &&
                 !m_outfile_options.AnyOptionWasSet() &&
                 !m_varobj_options.AnyOptionWasSet())
@@ -585,7 +595,7 @@ protected:
         }
 
         size_t item_count = m_format_options.GetCountValue().GetCurrentValue();
-        const size_t item_byte_size = m_format_options.GetByteSizeValue().GetCurrentValue();
+        size_t item_byte_size = m_format_options.GetByteSizeValue().GetCurrentValue();
         const size_t num_per_line = m_memory_options.m_num_per_line.GetCurrentValue();
 
         if (total_byte_size == 0)
@@ -596,33 +606,35 @@ protected:
         }
 
         if (argc > 0)
-            addr = Args::StringToUInt64(command.GetArgumentAtIndex(0), LLDB_INVALID_ADDRESS, 0);
+            addr = Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(0), LLDB_INVALID_ADDRESS, &error);
 
         if (addr == LLDB_INVALID_ADDRESS)
         {
-            result.AppendErrorWithFormat("invalid start address string '%s'.\n", command.GetArgumentAtIndex(0));
+            result.AppendError("invalid start address expression.");
+            result.AppendError(error.AsCString());
             result.SetStatus(eReturnStatusFailed);
             return false;
         }
 
         if (argc == 2)
         {
-            lldb::addr_t end_addr = Args::StringToUInt64(command.GetArgumentAtIndex(1), LLDB_INVALID_ADDRESS, 0);
+            lldb::addr_t end_addr = Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(1), LLDB_INVALID_ADDRESS, 0);
             if (end_addr == LLDB_INVALID_ADDRESS)
             {
-                result.AppendErrorWithFormat("invalid end address string '%s'.\n", command.GetArgumentAtIndex(1));
+                result.AppendError("invalid end address expression.");
+                result.AppendError(error.AsCString());
                 result.SetStatus(eReturnStatusFailed);
                 return false;
             }
             else if (end_addr <= addr)
             {
-                result.AppendErrorWithFormat("end address (0x%llx) must be greater that the start address (0x%llx).\n", end_addr, addr);
+                result.AppendErrorWithFormat("end address (0x%" PRIx64 ") must be greater that the start address (0x%" PRIx64 ").\n", end_addr, addr);
                 result.SetStatus(eReturnStatusFailed);
                 return false;
             }
             else if (m_format_options.GetCountValue().OptionWasSet())
             {
-                result.AppendErrorWithFormat("specify either the end address (0x%llx) or the count (--count %lu), not both.\n", end_addr, item_count);
+                result.AppendErrorWithFormat("specify either the end address (0x%" PRIx64 ") or the count (--count %lu), not both.\n", end_addr, item_count);
                 result.SetStatus(eReturnStatusFailed);
                 return false;
             }
@@ -631,16 +643,27 @@ protected:
             item_count = total_byte_size / item_byte_size;
         }
         
-        if (total_byte_size > 1024 && !m_memory_options.m_force)
+        uint32_t max_unforced_size = target->GetMaximumMemReadSize();
+        
+        if (total_byte_size > max_unforced_size && !m_memory_options.m_force)
         {
-            result.AppendErrorWithFormat("Normally, \'memory read\' will not read over 1Kbyte of data.\n");
-            result.AppendErrorWithFormat("Please use --force to override this restriction.\n");
+            result.AppendErrorWithFormat("Normally, \'memory read\' will not read over %" PRIu32 " bytes of data.\n",max_unforced_size);
+            result.AppendErrorWithFormat("Please use --force to override this restriction just once.\n");
+            result.AppendErrorWithFormat("or set target.max-memory-read-size if you will often need a larger limit.\n");
             return false;
         }
         
         DataBufferSP data_sp;
         size_t bytes_read = 0;
-        if (!clang_ast_type.GetOpaqueQualType())
+        if (clang_ast_type.GetOpaqueQualType())
+        {
+            // Make sure we don't display our type as ASCII bytes like the default memory read
+            if (m_format_options.GetFormatValue().OptionWasSet() == false)
+                m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault);
+
+            bytes_read = clang_ast_type.GetTypeByteSize() * m_format_options.GetCountValue().GetCurrentValue();
+        }
+        else if (m_format_options.GetFormatValue().GetCurrentValue() != eFormatCString)
         {
             data_sp.reset (new DataBufferHeap (total_byte_size, '\0'));
             Address address(addr, NULL);
@@ -654,24 +677,63 @@ protected:
                 }
                 else
                 {
-                    result.AppendErrorWithFormat("failed to read memory from 0x%llx.\n", addr);
+                    result.AppendErrorWithFormat("failed to read memory from 0x%" PRIx64 ".\n", addr);
                 }
                 result.SetStatus(eReturnStatusFailed);
                 return false;
             }
             
             if (bytes_read < total_byte_size)
-                result.AppendWarningWithFormat("Not all bytes (%lu/%lu) were able to be read from 0x%llx.\n", bytes_read, total_byte_size, addr);
-            else
-            {
-                m_next_addr = addr + bytes_read;
-                m_prev_byte_size = bytes_read; 
-                m_prev_format_options = m_format_options;
-                m_prev_memory_options = m_memory_options;
-                m_prev_outfile_options = m_outfile_options;
-                m_prev_varobj_options = m_varobj_options;
-            }
+                result.AppendWarningWithFormat("Not all bytes (%lu/%lu) were able to be read from 0x%" PRIx64 ".\n", bytes_read, total_byte_size, addr);
         }
+        else
+        {
+            // we treat c-strings as a special case because they do not have a fixed size
+            if (m_format_options.GetByteSizeValue().OptionWasSet() && !m_format_options.HasGDBFormat())
+                item_byte_size = m_format_options.GetByteSizeValue().GetCurrentValue();
+            else
+                item_byte_size = target->GetMaximumSizeOfStringSummary();
+            if (!m_format_options.GetCountValue().OptionWasSet())
+                item_count = 1;
+            data_sp.reset (new DataBufferHeap ((item_byte_size+1) * item_count, '\0')); // account for NULLs as necessary
+            uint8_t *data_ptr = data_sp->GetBytes();
+            auto data_addr = addr;
+            auto count = item_count;
+            item_count = 0;
+            while (item_count < count)
+            {
+                std::string buffer;
+                buffer.resize(item_byte_size+1,0);
+                Error error;
+                size_t read = target->ReadCStringFromMemory(data_addr, &buffer[0], item_byte_size+1, error);
+                if (error.Fail())
+                {
+                    result.AppendErrorWithFormat("failed to read memory from 0x%" PRIx64 ".\n", addr);
+                    result.SetStatus(eReturnStatusFailed);
+                    return false;
+                }
+                if (item_byte_size == read)
+                {
+                    result.AppendWarningWithFormat("unable to find a NULL terminated string at 0x%" PRIx64 ".Consider increasing the maximum read length.\n", data_addr);
+                    break;
+                }
+                read+=1; // account for final NULL byte
+                memcpy(data_ptr, &buffer[0], read);
+                data_ptr += read;
+                data_addr += read;
+                bytes_read += read;
+                item_count++; // if we break early we know we only read item_count strings
+            }
+            data_sp.reset(new DataBufferHeap(data_sp->GetBytes(),bytes_read+1));
+        }
+
+        m_next_addr = addr + bytes_read;
+        m_prev_byte_size = bytes_read;
+        m_prev_format_options = m_format_options;
+        m_prev_memory_options = m_memory_options;
+        m_prev_outfile_options = m_outfile_options;
+        m_prev_varobj_options = m_varobj_options;
+        m_prev_clang_ast_type = clang_ast_type;
 
         StreamFile outfile_stream;
         Stream *output_stream = NULL;
@@ -690,10 +752,10 @@ protected:
             {
                 if (m_memory_options.m_output_as_binary)
                 {
-                    int bytes_written = outfile_stream.Write (data_sp->GetBytes(), bytes_read);
+                    const size_t bytes_written = outfile_stream.Write (data_sp->GetBytes(), bytes_read);
                     if (bytes_written > 0)
                     {
-                        result.GetOutputStream().Printf ("%i bytes %s to '%s'\n", 
+                        result.GetOutputStream().Printf ("%zi bytes %s to '%s'\n", 
                                                          bytes_written, 
                                                          append ? "appended" : "written", 
                                                          path);
@@ -701,7 +763,7 @@ protected:
                     }
                     else 
                     {
-                        result.AppendErrorWithFormat("Failed to write %zu bytes to '%s'.\n", bytes_read, path);
+                        result.AppendErrorWithFormat("Failed to write %" PRIu64 " bytes to '%s'.\n", (uint64_t)bytes_read, path);
                         result.SetStatus(eReturnStatusFailed);
                         return false;
                     }
@@ -726,7 +788,7 @@ protected:
         }
 
 
-        ExecutionContextScope *exe_scope = exe_ctx.GetBestExecutionContextScope();
+        ExecutionContextScope *exe_scope = m_exe_ctx.GetBestExecutionContextScope();
         if (clang_ast_type.GetOpaqueQualType())
         {
             for (uint32_t i = 0; i<item_count; ++i)
@@ -734,31 +796,19 @@ protected:
                 addr_t item_addr = addr + (i * item_byte_size);
                 Address address (item_addr);
                 StreamString name_strm;
-                name_strm.Printf ("0x%llx", item_addr);
+                name_strm.Printf ("0x%" PRIx64, item_addr);
                 ValueObjectSP valobj_sp (ValueObjectMemory::Create (exe_scope, 
                                                                     name_strm.GetString().c_str(), 
                                                                     address, 
                                                                     clang_ast_type));
                 if (valobj_sp)
                 {
+                    Format format = m_format_options.GetFormat();
                     if (format != eFormatDefault)
                         valobj_sp->SetFormat (format);
 
-                    bool scope_already_checked = true;
+                    ValueObject::DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(false,format));
                     
-                    ValueObject::DumpValueObjectOptions options;
-                    options.SetMaximumPointerDepth(m_varobj_options.ptr_depth)
-                    .SetMaximumDepth(m_varobj_options.max_depth)
-                    .SetShowLocation(m_varobj_options.show_location)
-                    .SetShowTypes(m_varobj_options.show_types)
-                    .SetUseObjectiveC(m_varobj_options.use_objc)
-                    .SetScopeChecked(scope_already_checked)
-                    .SetFlatOutput(m_varobj_options.flat_output)
-                    .SetUseSyntheticValue(m_varobj_options.be_raw ? false : m_varobj_options.use_synth)
-                    .SetOmitSummaryDepth(m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth)
-                    .SetIgnoreCap(m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap)
-                    .SetFormat(format)
-                    .SetSummary();
                     ValueObject::DumpValueObject (*output_stream,
                                                   valobj_sp.get(),
                                                   options);
@@ -779,19 +829,32 @@ protected:
         DataExtractor data (data_sp, 
                             target->GetArchitecture().GetByteOrder(), 
                             target->GetArchitecture().GetAddressByteSize());
-
+        
+        Format format = m_format_options.GetFormat();
+        if ( ( (format == eFormatChar) || (format == eFormatCharPrintable) )
+            && (item_byte_size != 1)
+            && (item_count == 1))
+        {
+            // this turns requests such as
+            // memory read -fc -s10 -c1 *charPtrPtr
+            // which make no sense (what is a char of size 10?)
+            // into a request for fetching 10 chars of size 1 from the same memory location
+            format = eFormatCharArray;
+            item_count = item_byte_size;
+            item_byte_size = 1;
+        }
 
         assert (output_stream);
-        uint32_t bytes_dumped = data.Dump (output_stream,
-                                           0,
-                                           m_format_options.GetFormat(),
-                                           item_byte_size,
-                                           item_count,
-                                           num_per_line,
-                                           addr,
-                                           0,
-                                           0,
-                                           exe_scope);
+        size_t bytes_dumped = data.Dump (output_stream,
+                                         0,
+                                         format,
+                                         item_byte_size,
+                                         item_count,
+                                         num_per_line,
+                                         addr,
+                                         0,
+                                         0,
+                                         exe_scope);
         m_next_addr = addr + bytes_dumped;
         output_stream->EOL();
         return true;
@@ -808,6 +871,7 @@ protected:
     OptionGroupReadMemory m_prev_memory_options;
     OptionGroupOutputFile m_prev_outfile_options;
     OptionGroupValueObjectDisplay m_prev_varobj_options;
+    ClangASTType m_prev_clang_ast_type;
 };
 
 
@@ -857,7 +921,7 @@ public:
                         const char *option_arg)
         {
             Error error;
-            char short_option = (char) g_memory_write_option_table[option_idx].short_option;
+            const int short_option = g_memory_write_option_table[option_idx].short_option;
             
             switch (short_option)
             {
@@ -904,7 +968,7 @@ public:
                              "memory write",
                              "Write to the memory of the process being debugged.",
                              NULL,
-                             eFlagProcessMustBeLaunched),
+                             eFlagRequiresProcess | eFlagProcessMustBeLaunched),
         m_option_group (interpreter),
         m_format_options (eFormatBytes, 1, UINT64_MAX),
         m_memory_options ()
@@ -981,13 +1045,8 @@ protected:
     virtual bool
     DoExecute (Args& command, CommandReturnObject &result)
     {
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
-        if (process == NULL)
-        {
-            result.AppendError("need a process to read memory");
-            result.SetStatus(eReturnStatusFailed);
-            return false;
-        }
+        // No need to check "process" for validity as eFlagRequiresProcess ensures it is valid
+        Process *process = m_exe_ctx.GetProcessPtr();
 
         const size_t argc = command.GetArgumentCount();
 
@@ -1014,11 +1073,16 @@ protected:
         OptionValueUInt64 &byte_size_value = m_format_options.GetByteSizeValue();
         size_t item_byte_size = byte_size_value.GetCurrentValue();
 
-        lldb::addr_t addr = Args::StringToUInt64(command.GetArgumentAtIndex(0), LLDB_INVALID_ADDRESS, 0);
+        Error error;
+        lldb::addr_t addr = Args::StringToAddress (&m_exe_ctx,
+                                                   command.GetArgumentAtIndex(0),
+                                                   LLDB_INVALID_ADDRESS,
+                                                   &error);
 
         if (addr == LLDB_INVALID_ADDRESS)
         {
-            result.AppendErrorWithFormat("Invalid address string '%s'.\n", command.GetArgumentAtIndex(0));
+            result.AppendError("invalid address expression\n");
+            result.AppendError(error.AsCString());
             result.SetStatus(eReturnStatusFailed);
             return false;
         }
@@ -1040,18 +1104,18 @@ protected:
                     if (bytes_written == length)
                     {
                         // All bytes written
-                        result.GetOutputStream().Printf("%zu bytes were written to 0x%llx\n", bytes_written, addr);
+                        result.GetOutputStream().Printf("%" PRIu64 " bytes were written to 0x%" PRIx64 "\n", (uint64_t)bytes_written, addr);
                         result.SetStatus(eReturnStatusSuccessFinishResult);
                     }
                     else if (bytes_written > 0)
                     {
                         // Some byte written
-                        result.GetOutputStream().Printf("%zu bytes of %zu requested were written to 0x%llx\n", bytes_written, length, addr);
+                        result.GetOutputStream().Printf("%" PRIu64 " bytes of %" PRIu64 " requested were written to 0x%" PRIx64 "\n", (uint64_t)bytes_written, (uint64_t)length, addr);
                         result.SetStatus(eReturnStatusSuccessFinishResult);
                     }
                     else 
                     {
-                        result.AppendErrorWithFormat ("Memory write to 0x%llx failed: %s.\n", addr, error.AsCString());
+                        result.AppendErrorWithFormat ("Memory write to 0x%" PRIx64 " failed: %s.\n", addr, error.AsCString());
                         result.SetStatus(eReturnStatusFailed);
                     }
                 }
@@ -1075,9 +1139,8 @@ protected:
         uint64_t uval64;
         int64_t sval64;
         bool success = false;
-        const uint32_t num_value_args = command.GetArgumentCount();
-        uint32_t i;
-        for (i=0; i<num_value_args; ++i)
+        const size_t num_value_args = command.GetArgumentCount();
+        for (size_t i=0; i<num_value_args; ++i)
         {
             const char *value_str = command.GetArgumentAtIndex(i);
 
@@ -1129,7 +1192,7 @@ protected:
                 }
                 else if (!UIntValueIsValidForSize (uval64, item_byte_size))
                 {
-                    result.AppendErrorWithFormat ("Value 0x%llx is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size);
+                    result.AppendErrorWithFormat ("Value 0x%" PRIx64 " is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size);
                     result.SetStatus(eReturnStatusFailed);
                     return false;
                 }
@@ -1157,7 +1220,7 @@ protected:
                 }
                 else if (!UIntValueIsValidForSize (uval64, item_byte_size))
                 {
-                    result.AppendErrorWithFormat ("Value 0x%llx is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size);
+                    result.AppendErrorWithFormat ("Value 0x%" PRIx64 " is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size);
                     result.SetStatus(eReturnStatusFailed);
                     return false;
                 }
@@ -1180,7 +1243,7 @@ protected:
                     }
                     else
                     {
-                        result.AppendErrorWithFormat ("Memory write to 0x%llx failed: %s.\n", addr, error.AsCString());
+                        result.AppendErrorWithFormat ("Memory write to 0x%" PRIx64 " failed: %s.\n", addr, error.AsCString());
                         result.SetStatus(eReturnStatusFailed);
                         return false;
                     }
@@ -1197,7 +1260,7 @@ protected:
                 }
                 else if (!SIntValueIsValidForSize (sval64, item_byte_size))
                 {
-                    result.AppendErrorWithFormat ("Value %lli is too large or small to fit in a %lu byte signed integer value.\n", sval64, item_byte_size);
+                    result.AppendErrorWithFormat ("Value %" PRIi64 " is too large or small to fit in a %lu byte signed integer value.\n", sval64, item_byte_size);
                     result.SetStatus(eReturnStatusFailed);
                     return false;
                 }
@@ -1214,7 +1277,7 @@ protected:
                 }
                 else if (!UIntValueIsValidForSize (uval64, item_byte_size))
                 {
-                    result.AppendErrorWithFormat ("Value %llu is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size);
+                    result.AppendErrorWithFormat ("Value %" PRIu64 " is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size);
                     result.SetStatus(eReturnStatusFailed);
                     return false;
                 }
@@ -1231,7 +1294,7 @@ protected:
                 }
                 else if (!UIntValueIsValidForSize (uval64, item_byte_size))
                 {
-                    result.AppendErrorWithFormat ("Value %llo is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size);
+                    result.AppendErrorWithFormat ("Value %" PRIo64 " is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size);
                     result.SetStatus(eReturnStatusFailed);
                     return false;
                 }
@@ -1247,7 +1310,7 @@ protected:
                 return true;
             else
             {
-                result.AppendErrorWithFormat ("Memory write to 0x%llx failed: %s.\n", addr, error.AsCString());
+                result.AppendErrorWithFormat ("Memory write to 0x%" PRIx64 " failed: %s.\n", addr, error.AsCString());
                 result.SetStatus(eReturnStatusFailed);
                 return false;
             }

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectMultiword.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectMultiword.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectMultiword.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectMultiword.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "lldb/Interpreter/CommandObjectMultiword.h"
 // C Includes
 // C++ Includes
@@ -32,7 +34,8 @@ CommandObjectMultiword::CommandObjectMul
     const char *syntax,
     uint32_t flags
 ) :
-    CommandObject (interpreter, name, help, syntax, flags)
+    CommandObject (interpreter, name, help, syntax, flags),
+    m_can_be_removed(false)
 {
 }
 
@@ -98,7 +101,6 @@ CommandObjectMultiword::LoadSubCommand
     if (pos == m_subcommand_dict.end())
     {
         m_subcommand_dict[name] = cmd_obj;
-        m_interpreter.CrossRegisterCommand (name, GetCommandName());
     }
     else
         success = false;
@@ -141,7 +143,7 @@ CommandObjectMultiword::Execute(const ch
                 else
                 {
                     std::string error_msg;
-                    int num_subcmd_matches = matches.GetSize();
+                    const size_t num_subcmd_matches = matches.GetSize();
                     if (num_subcmd_matches > 0)
                         error_msg.assign ("ambiguous command ");
                     else
@@ -156,14 +158,14 @@ CommandObjectMultiword::Execute(const ch
                     if (num_subcmd_matches > 0)
                     {
                         error_msg.append (" Possible completions:");
-                        for (int i = 0; i < num_subcmd_matches; i++)
+                        for (size_t i = 0; i < num_subcmd_matches; i++)
                         {
                             error_msg.append ("\n\t");
                             error_msg.append (matches.GetStringAtIndex (i));
                         }
                     }
                     error_msg.append ("\n");
-                    result.AppendRawError (error_msg.c_str(), error_msg.size());
+                    result.AppendRawError (error_msg.c_str());
                     result.SetStatus (eReturnStatusFailed);
                 }
             }
@@ -307,3 +309,215 @@ CommandObjectMultiword::GetRepeatCommand
     return sub_command_object->GetRepeatCommand(current_command_args, index);
 }
 
+
+void
+CommandObjectMultiword::AproposAllSubCommands (const char *prefix,
+                                               const char *search_word,
+                                               StringList &commands_found,
+                                               StringList &commands_help)
+{
+    CommandObject::CommandMap::const_iterator pos;
+
+    for (pos = m_subcommand_dict.begin(); pos != m_subcommand_dict.end(); ++pos)
+    {
+        const char * command_name = pos->first.c_str();
+        CommandObject *sub_cmd_obj = pos->second.get();
+        StreamString complete_command_name;
+        
+        complete_command_name.Printf ("%s %s", prefix, command_name);
+        
+        if (sub_cmd_obj->HelpTextContainsWord (search_word))
+        {
+            commands_found.AppendString (complete_command_name.GetData());
+            commands_help.AppendString (sub_cmd_obj->GetHelp());
+        }
+        
+        if (sub_cmd_obj->IsMultiwordObject())
+            sub_cmd_obj->AproposAllSubCommands (complete_command_name.GetData(),
+                                                search_word,
+                                                commands_found,
+                                                commands_help);
+    }
+}
+
+
+
+CommandObjectProxy::CommandObjectProxy (CommandInterpreter &interpreter,
+                                        const char *name,
+                                        const char *help,
+                                        const char *syntax,
+                                        uint32_t flags) :
+    CommandObject (interpreter, name, help, syntax, flags)
+{
+}
+
+CommandObjectProxy::~CommandObjectProxy ()
+{
+}
+
+const char *
+CommandObjectProxy::GetHelpLong ()
+{
+    CommandObject *proxy_command = GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->GetHelpLong();
+    return NULL;
+}
+
+bool
+CommandObjectProxy::IsRemovable() const
+{
+    const CommandObject *proxy_command = const_cast<CommandObjectProxy *>(this)->GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->IsRemovable();
+    return false;
+}
+
+bool
+CommandObjectProxy::IsMultiwordObject ()
+{
+    CommandObject *proxy_command = GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->IsMultiwordObject();
+    return false;
+}
+
+lldb::CommandObjectSP
+CommandObjectProxy::GetSubcommandSP (const char *sub_cmd, StringList *matches)
+{
+    CommandObject *proxy_command = GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->GetSubcommandSP(sub_cmd, matches);
+    return lldb::CommandObjectSP();
+}
+
+CommandObject *
+CommandObjectProxy::GetSubcommandObject (const char *sub_cmd, StringList *matches)
+{
+    CommandObject *proxy_command = GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->GetSubcommandObject(sub_cmd, matches);
+    return NULL;
+}
+
+void
+CommandObjectProxy::AproposAllSubCommands (const char *prefix,
+                                           const char *search_word,
+                                           StringList &commands_found,
+                                           StringList &commands_help)
+{
+    CommandObject *proxy_command = GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->AproposAllSubCommands (prefix,
+                                                     search_word,
+                                                     commands_found,
+                                                     commands_help);
+}
+
+bool
+CommandObjectProxy::LoadSubCommand (const char *cmd_name,
+                                    const lldb::CommandObjectSP& command_sp)
+{
+    CommandObject *proxy_command = GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->LoadSubCommand (cmd_name, command_sp);
+    return false;
+}
+
+bool
+CommandObjectProxy::WantsRawCommandString()
+{
+    CommandObject *proxy_command = GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->WantsRawCommandString();
+    return false;
+}
+
+bool
+CommandObjectProxy::WantsCompletion()
+{
+    CommandObject *proxy_command = GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->WantsCompletion();
+    return false;
+}
+
+
+Options *
+CommandObjectProxy::GetOptions ()
+{
+    CommandObject *proxy_command = GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->GetOptions ();
+    return NULL;
+}
+
+
+int
+CommandObjectProxy::HandleCompletion (Args &input,
+                                      int &cursor_index,
+                                      int &cursor_char_position,
+                                      int match_start_point,
+                                      int max_return_elements,
+                                      bool &word_complete,
+                                      StringList &matches)
+{
+    CommandObject *proxy_command = GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->HandleCompletion (input,
+                                                cursor_index,
+                                                cursor_char_position,
+                                                match_start_point,
+                                                max_return_elements,
+                                                word_complete,
+                                                matches);
+    matches.Clear();
+    return 0;
+}
+int
+CommandObjectProxy::HandleArgumentCompletion (Args &input,
+                                              int &cursor_index,
+                                              int &cursor_char_position,
+                                              OptionElementVector &opt_element_vector,
+                                              int match_start_point,
+                                              int max_return_elements,
+                                              bool &word_complete,
+                                              StringList &matches)
+{
+    CommandObject *proxy_command = GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->HandleArgumentCompletion (input,
+                                                        cursor_index,
+                                                        cursor_char_position,
+                                                        opt_element_vector,
+                                                        match_start_point,
+                                                        max_return_elements,
+                                                        word_complete,
+                                                        matches);
+    matches.Clear();
+    return 0;
+}
+
+const char *
+CommandObjectProxy::GetRepeatCommand (Args &current_command_args,
+                                      uint32_t index)
+{
+    CommandObject *proxy_command = GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->GetRepeatCommand (current_command_args, index);
+    return NULL;
+}
+
+bool
+CommandObjectProxy::Execute (const char *args_string,
+                             CommandReturnObject &result)
+{
+    CommandObject *proxy_command = GetProxyCommandObject();
+    if (proxy_command)
+        return proxy_command->Execute (args_string, result);
+    result.AppendError ("command is not implemented");
+    result.SetStatus (eReturnStatusFailed);
+    return false;
+}
+
+

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectPlatform.h"
 
 // C Includes
@@ -15,6 +17,7 @@
 // Project includes
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
@@ -300,7 +303,7 @@ protected:
         
         PlatformSP host_platform_sp (Platform::GetDefaultPlatform());
         ostrm.Printf ("%s: %s\n", 
-                      host_platform_sp->GetShortPluginName(), 
+                      host_platform_sp->GetPluginName().GetCString(),
                       host_platform_sp->GetDescription());
 
         uint32_t idx;
@@ -352,7 +355,16 @@ protected:
     {
         Stream &ostrm = result.GetOutputStream();      
         
-        PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        PlatformSP platform_sp;
+        if (target)
+        {
+            platform_sp = target->GetPlatform();
+        }
+        if (!platform_sp)
+        {
+            platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+        }
         if (platform_sp)
         {
             platform_sp->GetStatus (ostrm);
@@ -477,7 +489,7 @@ protected:
                     {
                         Stream &ostrm = result.GetOutputStream();      
                         if (hostname.empty())
-                            ostrm.Printf ("Disconnected from \"%s\"\n", platform_sp->GetShortPluginName());
+                            ostrm.Printf ("Disconnected from \"%s\"\n", platform_sp->GetPluginName().GetCString());
                         else
                             ostrm.Printf ("Disconnected from \"%s\"\n", hostname.c_str());
                         result.SetStatus (eReturnStatusSuccessFinishResult);            
@@ -491,7 +503,7 @@ protected:
                 else
                 {
                     // Not connected...
-                    result.AppendErrorWithFormat ("not connected to '%s'", platform_sp->GetShortPluginName());
+                    result.AppendErrorWithFormat ("not connected to '%s'", platform_sp->GetPluginName().GetCString());
                     result.SetStatus (eReturnStatusFailed);            
                 }
             }
@@ -599,6 +611,7 @@ public:
         PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
         if (platform_sp)
         {
+            Error error;
             std::string cmd_line;
             args.GetCommandString(cmd_line);
             mode_t perms;
@@ -607,12 +620,21 @@ public:
                 perms = options_permissions->m_permissions;
             else
                 perms = 0000700 | 0000070 | 0000007;
-            uint32_t retcode = platform_sp->OpenFile(FileSpec(cmd_line.c_str(),false),
-                                                     File::eOpenOptionRead | File::eOpenOptionWrite |
-                                                     File::eOpenOptionAppend | File::eOpenOptionCanCreate,
-                                                     perms);
-            result.AppendMessageWithFormat("Status = %d\n",retcode);
-            result.SetStatus (eReturnStatusSuccessFinishResult);
+            lldb::user_id_t fd = platform_sp->OpenFile(FileSpec(cmd_line.c_str(),false),
+                                                       File::eOpenOptionRead | File::eOpenOptionWrite |
+                                                       File::eOpenOptionAppend | File::eOpenOptionCanCreate,
+                                                       perms,
+                                                       error);
+            if (error.Success())
+            {
+                result.AppendMessageWithFormat("File Descriptor = %lld\n",fd);
+                result.SetStatus (eReturnStatusSuccessFinishResult);
+            }
+            else
+            {
+                result.AppendError(error.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+            }
         }
         else
         {
@@ -662,10 +684,19 @@ public:
         {
             std::string cmd_line;
             args.GetCommandString(cmd_line);
-            uint32_t fd = ::atoi(cmd_line.c_str());
-            uint32_t retcode = platform_sp->CloseFile(fd);
-            result.AppendMessageWithFormat("Status = %d\n",retcode);
-            result.SetStatus (eReturnStatusSuccessFinishResult);
+            const lldb::user_id_t fd = Args::StringToUInt64(cmd_line.c_str(), UINT64_MAX);
+            Error error;
+            bool success = platform_sp->CloseFile(fd, error);
+            if (success)
+            {
+                result.AppendMessageWithFormat("file %lld closed.\n", fd);
+                result.SetStatus (eReturnStatusSuccessFinishResult);
+            }
+            else
+            {
+                result.AppendError(error.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+            }
         }
         else
         {
@@ -705,9 +736,10 @@ public:
         {
             std::string cmd_line;
             args.GetCommandString(cmd_line);
-            uint32_t fd = ::atoi(cmd_line.c_str());
+            const lldb::user_id_t fd = Args::StringToUInt64(cmd_line.c_str(), UINT64_MAX);
             std::string buffer(m_options.m_count,0);
-            uint32_t retcode = platform_sp->ReadFile(fd, m_options.m_offset, &buffer[0], m_options.m_count);
+            Error error;
+            uint32_t retcode = platform_sp->ReadFile(fd, m_options.m_offset, &buffer[0], m_options.m_count, error);
             result.AppendMessageWithFormat("Return = %d\n",retcode);
             result.AppendMessageWithFormat("Data = \"%s\"\n",buffer.c_str());
             result.SetStatus (eReturnStatusSuccessFinishResult);
@@ -830,8 +862,13 @@ public:
         {
             std::string cmd_line;
             args.GetCommandString(cmd_line);
-            uint32_t fd = ::atoi(cmd_line.c_str());
-            uint32_t retcode = platform_sp->WriteFile(fd, m_options.m_offset, &m_options.m_data[0], m_options.m_data.size());
+            Error error;
+            const lldb::user_id_t fd = Args::StringToUInt64(cmd_line.c_str(), UINT64_MAX);
+            uint32_t retcode = platform_sp->WriteFile (fd,
+                                                       m_options.m_offset,
+                                                       &m_options.m_data[0],
+                                                       m_options.m_data.size(),
+                                                       error);
             result.AppendMessageWithFormat("Return = %d\n",retcode);
             result.SetStatus (eReturnStatusSuccessFinishResult);
         }
@@ -1009,14 +1046,14 @@ public:
         PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
         if (platform_sp)
         {
-            std::string remote_file_path(args.GetArgumentAtIndex(0));
-            std::string host_file_path(args.GetArgumentAtIndex(1));
-            Error error = platform_sp->GetFile(FileSpec(remote_file_path.c_str(), false),
-                                               FileSpec(host_file_path.c_str(), false));
+            const char *remote_file_path = args.GetArgumentAtIndex(0);
+            const char *local_file_path = args.GetArgumentAtIndex(1);
+            Error error = platform_sp->GetFile(FileSpec(remote_file_path, false),
+                                               FileSpec(local_file_path, false));
             if (error.Success())
             {
                 result.AppendMessageWithFormat("successfully get-file from %s (remote) to %s (host)\n",
-                                               remote_file_path.c_str(), host_file_path.c_str());
+                                               remote_file_path, local_file_path);
                 result.SetStatus (eReturnStatusSuccessFinishResult);
             }
             else
@@ -1139,7 +1176,16 @@ public:
         PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
         if (platform_sp)
         {
-            platform_sp->PutFile(src_fs, dst_fs);
+            Error error (platform_sp->PutFile(src_fs, dst_fs));
+            if (error.Success())
+            {
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            }
+            else
+            {
+                result.AppendError (error.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+            }
         }
         else
         {
@@ -1157,11 +1203,11 @@ class CommandObjectPlatformProcessLaunch
 {
 public:
     CommandObjectPlatformProcessLaunch (CommandInterpreter &interpreter) :
-        CommandObjectParsed (interpreter, 
+        CommandObjectParsed (interpreter,
                              "platform process launch",
                              "Launch a new process on a remote platform.",
                              "platform process launch program",
-                             0),
+                             eFlagRequiresTarget | eFlagTryTargetAPILock),
         m_options (interpreter)
     {
     }
@@ -1181,20 +1227,22 @@ protected:
     virtual bool
     DoExecute (Args& args, CommandReturnObject &result)
     {
-        PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
-        
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        PlatformSP platform_sp;
+        if (target)
+        {   
+            platform_sp = target->GetPlatform();
+        }   
+        if (!platform_sp)
+        {
+            platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+        }   
+
         if (platform_sp)
         {
             Error error;
-            const uint32_t argc = args.GetArgumentCount();
-            Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
-            if (target == NULL)
-            {
-                result.AppendError ("invalid target, create a debug target using the 'target create' command");
-                result.SetStatus (eReturnStatusFailed);
-                return false;
-            }
-
+            const size_t argc = args.GetArgumentCount();
+            Target *target = m_exe_ctx.GetTargetPtr();
             Module *exe_module = target->GetExecutableModulePointer();
             if (exe_module)
             {
@@ -1218,9 +1266,7 @@ protected:
                     // We don't have any file yet, so the first argument is our
                     // executable, and the rest are program arguments
                     const bool first_arg_is_executable = true;
-                    m_options.launch_info.SetArguments (args, 
-                                                        first_arg_is_executable, 
-                                                        first_arg_is_executable);
+                    m_options.launch_info.SetArguments (args, first_arg_is_executable);
                 }
             }
             
@@ -1229,11 +1275,7 @@ protected:
                 Debugger &debugger = m_interpreter.GetDebugger();
 
                 if (argc == 0)
-                {
-                    const Args &target_settings_args = target->GetRunArguments();
-                    if (target_settings_args.GetArgumentCount())
-                        m_options.launch_info.GetArguments() = target_settings_args;
-                }
+                    target->GetRunArguments(m_options.launch_info.GetArguments());
 
                 ProcessSP process_sp (platform_sp->DebugProcess (m_options.launch_info, 
                                                                  debugger,
@@ -1303,7 +1345,16 @@ protected:
     virtual bool
     DoExecute (Args& args, CommandReturnObject &result)
     {
-        PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        PlatformSP platform_sp;
+        if (target)
+        {   
+            platform_sp = target->GetPlatform();
+        }   
+        if (!platform_sp)
+        {
+            platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+        }   
         
         if (platform_sp)
         {
@@ -1327,7 +1378,7 @@ protected:
                         }
                         else
                         {
-                            result.AppendErrorWithFormat ("no process found with pid = %llu\n", pid);
+                            result.AppendErrorWithFormat ("no process found with pid = %" PRIu64 "\n", pid);
                             result.SetStatus (eReturnStatusFailed);
                         }
                     }
@@ -1356,9 +1407,9 @@ protected:
                                 result.AppendErrorWithFormat ("no processes were found that %s \"%s\" on the \"%s\" platform\n", 
                                                               match_desc,
                                                               match_name,
-                                                              platform_sp->GetShortPluginName());
+                                                              platform_sp->GetPluginName().GetCString());
                             else
-                                result.AppendErrorWithFormat ("no processes were found on the \"%s\" platform\n", platform_sp->GetShortPluginName());
+                                result.AppendErrorWithFormat ("no processes were found on the \"%s\" platform\n", platform_sp->GetPluginName().GetCString());
                             result.SetStatus (eReturnStatusFailed);
                         }
                         else
@@ -1366,7 +1417,7 @@ protected:
                             result.AppendMessageWithFormat ("%u matching process%s found on \"%s\"", 
                                                             matches,
                                                             matches > 1 ? "es were" : " was",
-                                                            platform_sp->GetName());
+                                                            platform_sp->GetName().GetCString());
                             if (match_desc)
                                 result.AppendMessageWithFormat (" whose name %s \"%s\"", 
                                                                 match_desc,
@@ -1414,7 +1465,7 @@ protected:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             bool success = false;
 
             switch (short_option)
@@ -1530,21 +1581,21 @@ protected:
 OptionDefinition
 CommandObjectPlatformProcessList::CommandOptions::g_option_table[] =
 {
-{   LLDB_OPT_SET_1, false, "pid"              , 'p', required_argument, NULL, 0, eArgTypePid          , "List the process info for a specific process ID." },
-{   LLDB_OPT_SET_2, true , "name"             , 'n', required_argument, NULL, 0, eArgTypeProcessName  , "Find processes with executable basenames that match a string." },
-{   LLDB_OPT_SET_3, true , "ends-with"        , 'e', required_argument, NULL, 0, eArgTypeNone         , "Find processes with executable basenames that end with a string." },
-{   LLDB_OPT_SET_4, true , "starts-with"      , 's', required_argument, NULL, 0, eArgTypeNone         , "Find processes with executable basenames that start with a string." },
-{   LLDB_OPT_SET_5, true , "contains"         , 'c', required_argument, NULL, 0, eArgTypeNone         , "Find processes with executable basenames that contain a string." },
-{   LLDB_OPT_SET_6, true , "regex"            , 'r', required_argument, NULL, 0, eArgTypeNone         , "Find processes with executable basenames that match a regular expression." },
-{  ~LLDB_OPT_SET_1, false, "parent"           , 'P', required_argument, NULL, 0, eArgTypePid          , "Find processes that have a matching parent process ID." },
-{  ~LLDB_OPT_SET_1, false, "uid"              , 'u', required_argument, NULL, 0, eArgTypeNone         , "Find processes that have a matching user ID." },
-{  ~LLDB_OPT_SET_1, false, "euid"             , 'U', required_argument, NULL, 0, eArgTypeNone         , "Find processes that have a matching effective user ID." },
-{  ~LLDB_OPT_SET_1, false, "gid"              , 'g', required_argument, NULL, 0, eArgTypeNone         , "Find processes that have a matching group ID." },
-{  ~LLDB_OPT_SET_1, false, "egid"             , 'G', required_argument, NULL, 0, eArgTypeNone         , "Find processes that have a matching effective group ID." },
-{  ~LLDB_OPT_SET_1, false, "arch"             , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Find processes that have a matching architecture." },
-{ LLDB_OPT_SET_ALL, false, "show-args"        , 'A', no_argument      , NULL, 0, eArgTypeNone         , "Show process arguments instead of the process executable basename." },
-{ LLDB_OPT_SET_ALL, false, "verbose"          , 'v', no_argument      , NULL, 0, eArgTypeNone         , "Enable verbose output." },
-{  0              , false, NULL               ,  0 , 0                , NULL, 0, eArgTypeNone         , NULL }
+{ LLDB_OPT_SET_1            , false, "pid"        , 'p', required_argument, NULL, 0, eArgTypePid              , "List the process info for a specific process ID." },
+{ LLDB_OPT_SET_2            , true , "name"       , 'n', required_argument, NULL, 0, eArgTypeProcessName      , "Find processes with executable basenames that match a string." },
+{ LLDB_OPT_SET_3            , true , "ends-with"  , 'e', required_argument, NULL, 0, eArgTypeProcessName      , "Find processes with executable basenames that end with a string." },
+{ LLDB_OPT_SET_4            , true , "starts-with", 's', required_argument, NULL, 0, eArgTypeProcessName      , "Find processes with executable basenames that start with a string." },
+{ LLDB_OPT_SET_5            , true , "contains"   , 'c', required_argument, NULL, 0, eArgTypeProcessName      , "Find processes with executable basenames that contain a string." },
+{ LLDB_OPT_SET_6            , true , "regex"      , 'r', required_argument, NULL, 0, eArgTypeRegularExpression, "Find processes with executable basenames that match a regular expression." },
+{ LLDB_OPT_SET_FROM_TO(2, 6), false, "parent"     , 'P', required_argument, NULL, 0, eArgTypePid              , "Find processes that have a matching parent process ID." },
+{ LLDB_OPT_SET_FROM_TO(2, 6), false, "uid"        , 'u', required_argument, NULL, 0, eArgTypeUnsignedInteger  , "Find processes that have a matching user ID." },
+{ LLDB_OPT_SET_FROM_TO(2, 6), false, "euid"       , 'U', required_argument, NULL, 0, eArgTypeUnsignedInteger  , "Find processes that have a matching effective user ID." },
+{ LLDB_OPT_SET_FROM_TO(2, 6), false, "gid"        , 'g', required_argument, NULL, 0, eArgTypeUnsignedInteger  , "Find processes that have a matching group ID." },
+{ LLDB_OPT_SET_FROM_TO(2, 6), false, "egid"       , 'G', required_argument, NULL, 0, eArgTypeUnsignedInteger  , "Find processes that have a matching effective group ID." },
+{ LLDB_OPT_SET_FROM_TO(2, 6), false, "arch"       , 'a', required_argument, NULL, 0, eArgTypeArchitecture     , "Find processes that have a matching architecture." },
+{ LLDB_OPT_SET_FROM_TO(1, 6), false, "show-args"  , 'A', no_argument      , NULL, 0, eArgTypeNone             , "Show process arguments instead of the process executable basename." },
+{ LLDB_OPT_SET_FROM_TO(1, 6), false, "verbose"    , 'v', no_argument      , NULL, 0, eArgTypeNone             , "Enable verbose output." },
+{ 0                         , false, NULL         ,  0 , 0                , NULL, 0, eArgTypeNone             , NULL }
 };
 
 //----------------------------------------------------------------------
@@ -1583,7 +1634,17 @@ protected:
     virtual bool
     DoExecute (Args& args, CommandReturnObject &result)
     {
-        PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+        PlatformSP platform_sp;
+        if (target)
+        {   
+            platform_sp = target->GetPlatform();
+        }   
+        if (!platform_sp)
+        {
+            platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+        }   
+
         if (platform_sp)
         {
             const size_t argc = args.GetArgumentCount();
@@ -1604,12 +1665,12 @@ protected:
                             ProcessInstanceInfo proc_info;
                             if (platform_sp->GetProcessInfo (pid, proc_info))
                             {
-                                ostrm.Printf ("Process information for process %llu:\n", pid);
+                                ostrm.Printf ("Process information for process %" PRIu64 ":\n", pid);
                                 proc_info.Dump (ostrm, platform_sp.get());
                             }
                             else
                             {
-                                ostrm.Printf ("error: no process information is available for process %llu\n", pid);
+                                ostrm.Printf ("error: no process information is available for process %" PRIu64 "\n", pid);
                             }
                             ostrm.EOL();
                         }
@@ -1624,7 +1685,7 @@ protected:
                 else
                 {
                     // Not connected...
-                    result.AppendErrorWithFormat ("not connected to '%s'", platform_sp->GetShortPluginName());
+                    result.AppendErrorWithFormat ("not connected to '%s'", platform_sp->GetPluginName().GetCString());
                     result.SetStatus (eReturnStatusFailed);            
                 }
             }
@@ -2091,8 +2152,7 @@ RecurseCopy_Callback (void *baton,
             FileSpec new_directory(rc_baton->destination.c_str(),false);
             new_directory.AppendPathComponent(spec.GetLastPathComponent());
             uint32_t errcode = rc_baton->platform_sp->MakeDirectory(new_directory, 0777);
-            std::string new_directory_path;
-            new_directory.GetPath(new_directory_path);
+            std::string new_directory_path (new_directory.GetPath());
             if (errcode != 0)
             {
                 rc_baton->error.SetErrorStringWithFormat("unable to setup directory %s on remote end",new_directory_path.c_str());
@@ -2100,8 +2160,7 @@ RecurseCopy_Callback (void *baton,
             }
             
             // now recurse
-            std::string local_path;
-            spec.GetPath(local_path);
+            std::string local_path (spec.GetPath());
             RecurseCopyBaton rc_baton2 = { new_directory_path, rc_baton->platform_sp, Error() };
             FileSpec::EnumerateDirectory(local_path.c_str(), true, true, true, RecurseCopy_Callback, &rc_baton2);
             if (rc_baton2.error.Fail())
@@ -2208,8 +2267,7 @@ public:
                 return result.Succeeded();
             }
             // now recurse
-            std::string remote_folder_path;
-            remote_folder.GetPath(remote_folder_path);
+            std::string remote_folder_path (remote_folder.GetPath());
             Error err = RecurseCopy(source,remote_folder_path,platform_sp);
             if (err.Fail())
             {
@@ -2249,8 +2307,7 @@ private:
                  const std::string& destination,
                  const PlatformSP& platform_sp)
     {
-        std::string source_path;
-        source.GetPath(source_path);
+        std::string source_path (source.GetPath());
         RecurseCopyBaton baton = { destination, platform_sp, Error() };
         FileSpec::EnumerateDirectory(source_path.c_str(), true, true, true, RecurseCopy_Callback, &baton);
         return baton.error;

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectProcess.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectProcess.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectProcess.h"
 
 // C Includes
@@ -17,6 +19,7 @@
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Breakpoint/BreakpointSite.h"
 #include "lldb/Core/State.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Interpreter/Options.h"
@@ -31,19 +34,96 @@
 using namespace lldb;
 using namespace lldb_private;
 
+class CommandObjectProcessLaunchOrAttach : public CommandObjectParsed
+{
+public:
+    CommandObjectProcessLaunchOrAttach (CommandInterpreter &interpreter,
+                                       const char *name,
+                                       const char *help,
+                                       const char *syntax,
+                                       uint32_t flags,
+                                       const char *new_process_action) :
+        CommandObjectParsed (interpreter, name, help, syntax, flags),
+        m_new_process_action (new_process_action) {}
+    
+    virtual ~CommandObjectProcessLaunchOrAttach () {}
+protected:
+    bool
+    StopProcessIfNecessary (Process *&process, StateType &state, CommandReturnObject &result)
+    {
+        state = eStateInvalid;
+        if (process)
+        {
+            state = process->GetState();
+            
+            if (process->IsAlive() && state != eStateConnected)
+            {       
+                char message[1024];
+                if (process->GetState() == eStateAttaching)
+                    ::snprintf (message, sizeof(message), "There is a pending attach, abort it and %s?", m_new_process_action.c_str());
+                else if (process->GetShouldDetach())
+                    ::snprintf (message, sizeof(message), "There is a running process, detach from it and %s?", m_new_process_action.c_str());
+                else
+                    ::snprintf (message, sizeof(message), "There is a running process, kill it and %s?", m_new_process_action.c_str());
+        
+                if (!m_interpreter.Confirm (message, true))
+                {
+                    result.SetStatus (eReturnStatusFailed);
+                    return false;
+                }
+                else
+                {
+                    if (process->GetShouldDetach())
+                    {
+                        bool keep_stopped = false;
+                        Error detach_error (process->Detach(keep_stopped));
+                        if (detach_error.Success())
+                        {
+                            result.SetStatus (eReturnStatusSuccessFinishResult);
+                            process = NULL;
+                        }
+                        else
+                        {
+                            result.AppendErrorWithFormat ("Failed to detach from process: %s\n", detach_error.AsCString());
+                            result.SetStatus (eReturnStatusFailed);
+                        }
+                    }
+                    else
+                    {
+                        Error destroy_error (process->Destroy());
+                        if (destroy_error.Success())
+                        {
+                            result.SetStatus (eReturnStatusSuccessFinishResult);
+                            process = NULL;
+                        }
+                        else
+                        {
+                            result.AppendErrorWithFormat ("Failed to kill process: %s\n", destroy_error.AsCString());
+                            result.SetStatus (eReturnStatusFailed);
+                        }
+                    }
+                }
+            }
+        }
+        return result.Succeeded();
+    }
+    std::string m_new_process_action;
+};
 //-------------------------------------------------------------------------
 // CommandObjectProcessLaunch
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessLaunch
-class CommandObjectProcessLaunch : public CommandObjectParsed
+class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach
 {
 public:
 
     CommandObjectProcessLaunch (CommandInterpreter &interpreter) :
-        CommandObjectParsed (interpreter,
-                             "process launch",
-                             "Launch the executable in the debugger.",
-                             NULL),
+        CommandObjectProcessLaunchOrAttach (interpreter,
+                                            "process launch",
+                                            "Launch the executable in the debugger.",
+                                            NULL,
+                                            eFlagRequiresTarget,
+                                            "restart"),
         m_options (interpreter)
     {
         CommandArgumentEntry arg;
@@ -65,7 +145,7 @@ public:
     {
     }
 
-    int
+    virtual int
     HandleArgumentCompletion (Args &input,
                               int &cursor_index,
                               int &cursor_char_position,
@@ -108,13 +188,6 @@ protected:
         Debugger &debugger = m_interpreter.GetDebugger();
         Target *target = debugger.GetSelectedTarget().get();
         Error error;
-
-        if (target == NULL)
-        {
-            result.AppendError ("invalid target, create a debug target using the 'target create' command");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
         // If our listener is NULL, users aren't allows to launch
         char filename[PATH_MAX];
         const Module *exe_module = target->GetExecutableModulePointer();
@@ -126,58 +199,38 @@ protected:
             return false;
         }
         
+        StateType state = eStateInvalid;
+        Process *process = m_exe_ctx.GetProcessPtr();
+        
+        if (!StopProcessIfNecessary(process, state, result))
+            return false;
+        
+        const char *target_settings_argv0 = target->GetArg0();
+        
         exe_module->GetFileSpec().GetPath (filename, sizeof(filename));
-
-        const bool add_exe_file_as_first_arg = true;
-        m_options.launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), add_exe_file_as_first_arg);
         
-        StateType state = eStateInvalid;
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
-        if (process)
+        if (target_settings_argv0)
         {
-            state = process->GetState();
-            
-            if (process->IsAlive() && state != eStateConnected)
-            {       
-                char message[1024];
-                if (process->GetState() == eStateAttaching)
-                    ::strncpy (message, "There is a pending attach, abort it and launch a new process?", sizeof(message));
-                else
-                    ::strncpy (message, "There is a running process, kill it and restart?", sizeof(message));
-        
-                if (!m_interpreter.Confirm (message, true))
-                {
-                    result.SetStatus (eReturnStatusFailed);
-                    return false;
-                }
-                else
-                {
-                    Error destroy_error (process->Destroy());
-                    if (destroy_error.Success())
-                    {
-                        result.SetStatus (eReturnStatusSuccessFinishResult);
-                    }
-                    else
-                    {
-                        result.AppendErrorWithFormat ("Failed to kill process: %s\n", destroy_error.AsCString());
-                        result.SetStatus (eReturnStatusFailed);
-                    }
-                }
-            }
+            m_options.launch_info.GetArguments().AppendArgument (target_settings_argv0);
+            m_options.launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), false);
         }
-        
+        else
+        {
+            m_options.launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
+        }
+
         if (launch_args.GetArgumentCount() == 0)
         {
-            const Args &process_args = target->GetRunArguments();
-            if (process_args.GetArgumentCount() > 0)
-                m_options.launch_info.GetArguments().AppendArguments (process_args);
+            Args target_setting_args;
+            if (target->GetRunArguments(target_setting_args))
+                m_options.launch_info.GetArguments().AppendArguments (target_setting_args);
         }
         else
         {
+            m_options.launch_info.GetArguments().AppendArguments (launch_args);
+
             // Save the arguments for subsequent runs in the current target.
             target->SetRunArguments (launch_args);
-
-            m_options.launch_info.GetArguments().AppendArguments (launch_args);
         }
         
         if (target->GetDisableASLR())
@@ -193,6 +246,11 @@ protected:
         if (environment.GetArgumentCount() > 0)
             m_options.launch_info.GetEnvironmentEntries ().AppendArguments (environment);
 
+        // Get the value of synchronous execution here.  If you wait till after you have started to
+        // run, then you could have hit a breakpoint, whose command might switch the value, and
+        // then you'll pick up that incorrect value.
+        bool synchronous_execution = m_interpreter.GetSynchronous ();
+
         // Finalize the file actions, and if none were given, default to opening
         // up a pseudo terminal
         const bool default_to_use_pty = true;
@@ -206,41 +264,40 @@ protected:
                 m_options.launch_info.GetFlags().Clear (eLaunchFlagLaunchInTTY);
             }
         }
+        
+        if (!m_options.launch_info.GetArchitecture().IsValid())
+            m_options.launch_info.GetArchitecture() = target->GetArchitecture();
+
+        PlatformSP platform_sp (target->GetPlatform());
+        
+        if (platform_sp && platform_sp->CanDebugProcess ())
+        {
+            process = target->GetPlatform()->DebugProcess (m_options.launch_info, 
+                                                           debugger,
+                                                           target,
+                                                           debugger.GetListener(),
+                                                           error).get();
+        }
         else
         {
-            if (!m_options.launch_info.GetArchitecture().IsValid())
-                m_options.launch_info.GetArchitecture() = target->GetArchitecture();
-
-            PlatformSP platform_sp (target->GetPlatform());
-            
-            if (platform_sp && platform_sp->CanDebugProcess ())
-            {
-                process = target->GetPlatform()->DebugProcess (m_options.launch_info, 
-                                                               debugger,
-                                                               target,
-                                                               debugger.GetListener(),
-                                                               error).get();
-            }
-            else
-            {
-                const char *plugin_name = m_options.launch_info.GetProcessPluginName();
-                process = target->CreateProcess (debugger.GetListener(), plugin_name, NULL).get();
-                if (process)
-                    error = process->Launch (m_options.launch_info);
-            }
+            const char *plugin_name = m_options.launch_info.GetProcessPluginName();
+            process = target->CreateProcess (debugger.GetListener(), plugin_name, NULL).get();
+            if (process)
+                error = process->Launch (m_options.launch_info);
+        }
 
-            if (process == NULL)
-            {
-                result.SetError (error, "failed to launch or debug process");
-                return false;
-            }
+        if (process == NULL)
+        {
+            result.SetError (error, "failed to launch or debug process");
+            return false;
         }
+
              
         if (error.Success())
         {
             const char *archname = exe_module->GetArchitecture().GetArchitectureName();
 
-            result.AppendMessageWithFormat ("Process %llu launched: '%s' (%s)\n", process->GetID(), filename, archname);
+            result.AppendMessageWithFormat ("Process %" PRIu64 " launched: '%s' (%s)\n", process->GetID(), filename, archname);
             result.SetDidChangeProcessState (true);
             if (m_options.launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == false)
             {
@@ -252,7 +309,6 @@ protected:
                     error = process->Resume();
                     if (error.Success())
                     {
-                        bool synchronous_execution = m_interpreter.GetSynchronous ();
                         if (synchronous_execution)
                         {
                             state = process->WaitForProcessToStop (NULL);
@@ -304,13 +360,13 @@ protected:
 //CommandObjectProcessLaunch::CommandOptions::g_option_table[] =
 //{
 //{ SET1 | SET2 | SET3, false, "stop-at-entry", 's', no_argument,       NULL, 0, eArgTypeNone,    "Stop at the entry point of the program when launching a process."},
-//{ SET1              , false, "stdin",         'i', required_argument, NULL, 0, eArgTypePath,    "Redirect stdin for the process to <path>."},
-//{ SET1              , false, "stdout",        'o', required_argument, NULL, 0, eArgTypePath,    "Redirect stdout for the process to <path>."},
-//{ SET1              , false, "stderr",        'e', required_argument, NULL, 0, eArgTypePath,    "Redirect stderr for the process to <path>."},
+//{ SET1              , false, "stdin",         'i', required_argument, NULL, 0, eArgTypeDirectoryName,    "Redirect stdin for the process to <path>."},
+//{ SET1              , false, "stdout",        'o', required_argument, NULL, 0, eArgTypeDirectoryName,    "Redirect stdout for the process to <path>."},
+//{ SET1              , false, "stderr",        'e', required_argument, NULL, 0, eArgTypeDirectoryName,    "Redirect stderr for the process to <path>."},
 //{ SET1 | SET2 | SET3, false, "plugin",        'p', required_argument, NULL, 0, eArgTypePlugin,  "Name of the process plugin you want to use."},
-//{        SET2       , false, "tty",           't', optional_argument, NULL, 0, eArgTypePath,    "Start the process in a terminal. If <path> is specified, look for a terminal whose name contains <path>, else start the process in a new terminal."},
+//{        SET2       , false, "tty",           't', optional_argument, NULL, 0, eArgTypeDirectoryName,    "Start the process in a terminal. If <path> is specified, look for a terminal whose name contains <path>, else start the process in a new terminal."},
 //{               SET3, false, "no-stdio",      'n', no_argument,       NULL, 0, eArgTypeNone,    "Do not set up for terminal I/O to go to running process."},
-//{ SET1 | SET2 | SET3, false, "working-dir",   'w', required_argument, NULL, 0, eArgTypePath,    "Set the current working directory to <path> when running the inferior."},
+//{ SET1 | SET2 | SET3, false, "working-dir",   'w', required_argument, NULL, 0, eArgTypeDirectoryName,    "Set the current working directory to <path> when running the inferior."},
 //{ 0,                  false, NULL,             0,  0,                 NULL, 0, eArgTypeNone,    NULL }
 //};
 //
@@ -322,7 +378,7 @@ protected:
 // CommandObjectProcessAttach
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessAttach
-class CommandObjectProcessAttach : public CommandObjectParsed
+class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach
 {
 public:
 
@@ -345,7 +401,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             bool success = false;
             switch (short_option)
             {
@@ -440,10 +496,10 @@ public:
                         match_info.SetNameMatchType(eNameMatchStartsWith);
                     }
                     platform_sp->FindProcesses (match_info, process_infos);
-                    const uint32_t num_matches = process_infos.GetSize();
+                    const size_t num_matches = process_infos.GetSize();
                     if (num_matches > 0)
                     {
-                        for (uint32_t i=0; i<num_matches; ++i)
+                        for (size_t i=0; i<num_matches; ++i)
                         {
                             matches.AppendString (process_infos.GetProcessNameAtIndex(i), 
                                                   process_infos.GetProcessNameLengthAtIndex(i));
@@ -465,10 +521,12 @@ public:
     };
 
     CommandObjectProcessAttach (CommandInterpreter &interpreter) :
-        CommandObjectParsed (interpreter,
-                             "process attach",
-                             "Attach to a process.",
-                             "process attach <cmd-options>"),
+        CommandObjectProcessLaunchOrAttach (interpreter,
+                                            "process attach",
+                                            "Attach to a process.",
+                                            "process attach <cmd-options>",
+                                            0,
+                                            "attach"),
         m_options (interpreter)
     {
     }
@@ -493,29 +551,20 @@ protected:
         // and the target actually stopping.  So even if the interpreter is set to be asynchronous, we wait for the stop
         // ourselves here.
         
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
         StateType state = eStateInvalid;
-        if (process)
-        {
-            state = process->GetState();
-            if (process->IsAlive() && state != eStateConnected)
-            {
-                result.AppendErrorWithFormat ("Process %llu is currently being debugged, kill the process before attaching.\n", 
-                                              process->GetID());
-                result.SetStatus (eReturnStatusFailed);
-                return false;
-            }
-        }
-
+        Process *process = m_exe_ctx.GetProcessPtr();
+        
+        if (!StopProcessIfNecessary (process, state, result))
+            return false;
+        
         if (target == NULL)
         {
             // If there isn't a current target create one.
             TargetSP new_target_sp;
-            FileSpec emptyFileSpec;
             Error error;
             
             error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(), 
-                                                                              emptyFileSpec,
+                                                                              NULL,
                                                                               NULL, 
                                                                               false,
                                                                               NULL, // No platform options
@@ -588,7 +637,7 @@ protected:
 
                     if (state == eStateStopped)
                     {
-                        result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state));
+                        result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
                         result.SetStatus (eReturnStatusSuccessFinishNoResult);
                     }
                     else
@@ -629,12 +678,13 @@ protected:
             
             if (!old_arch_spec.IsValid())
             {
-                result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetArchitectureName());
+                result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetTriple().getTriple().c_str());
             }
-            else if (old_arch_spec != target->GetArchitecture())
+            else if (!old_arch_spec.IsExactMatch(target->GetArchitecture()))
             {
                 result.AppendWarningWithFormat("Architecture changed from %s to %s.\n", 
-                                                old_arch_spec.GetArchitectureName(), target->GetArchitecture().GetArchitectureName());
+                                               old_arch_spec.GetTriple().getTriple().c_str(),
+                                               target->GetArchitecture().GetTriple().getTriple().c_str());
             }
 
             // This supports the use-case scenario of immediately continuing the process once attached.
@@ -674,7 +724,10 @@ public:
                              "process continue",
                              "Continue execution of all threads in the current process.",
                              "process continue",
-                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+                             eFlagRequiresProcess       |
+                             eFlagTryTargetAPILock      |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused   ),
         m_options(interpreter)
     {
     }
@@ -705,7 +758,7 @@ protected:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             bool success = false;
             switch (short_option)
             {
@@ -742,19 +795,10 @@ protected:
     };
     
     bool
-    DoExecute (Args& command,
-             CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+        Process *process = m_exe_ctx.GetProcessPtr();
         bool synchronous_execution = m_interpreter.GetSynchronous ();
-
-        if (process == NULL)
-        {
-            result.AppendError ("no process to continue");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-         }
-
         StateType state = process->GetState();
         if (state == eStateStopped)
         {
@@ -773,12 +817,12 @@ protected:
                     StopInfoSP stop_info_sp = sel_thread_sp->GetStopInfo();
                     if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint)
                     {
-                        uint64_t bp_site_id = stop_info_sp->GetValue();
+                        lldb::break_id_t bp_site_id = (lldb::break_id_t)stop_info_sp->GetValue();
                         BreakpointSiteSP bp_site_sp(process->GetBreakpointSiteList().FindByID(bp_site_id));
                         if (bp_site_sp)
                         {
-                            uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
-                            for (uint32_t i = 0; i < num_owners; i++)
+                            const size_t num_owners = bp_site_sp->GetNumberOfOwners();
+                            for (size_t i = 0; i < num_owners; i++)
                             {
                                 Breakpoint &bp_ref = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
                                 if (!bp_ref.IsInternal())
@@ -791,24 +835,27 @@ protected:
                 }
             }
             
-            const uint32_t num_threads = process->GetThreadList().GetSize();
+            {  // Scope for thread list mutex:
+                Mutex::Locker locker (process->GetThreadList().GetMutex());
+                const uint32_t num_threads = process->GetThreadList().GetSize();
 
-            // Set the actions that the threads should each take when resuming
-            for (uint32_t idx=0; idx<num_threads; ++idx)
-            {
-                process->GetThreadList().GetThreadAtIndex(idx)->SetResumeState (eStateRunning);
+                // Set the actions that the threads should each take when resuming
+                for (uint32_t idx=0; idx<num_threads; ++idx)
+                {
+                    process->GetThreadList().GetThreadAtIndex(idx)->SetResumeState (eStateRunning);
+                }
             }
-
+            
             Error error(process->Resume());
             if (error.Success())
             {
-                result.AppendMessageWithFormat ("Process %llu resuming\n", process->GetID());
+                result.AppendMessageWithFormat ("Process %" PRIu64 " resuming\n", process->GetID());
                 if (synchronous_execution)
                 {
                     state = process->WaitForProcessToStop (NULL);
 
                     result.SetDidChangeProcessState (true);
-                    result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state));
+                    result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
                     result.SetStatus (eReturnStatusSuccessFinishNoResult);
                 }
                 else
@@ -857,13 +904,78 @@ CommandObjectProcessContinue::CommandOpt
 class CommandObjectProcessDetach : public CommandObjectParsed
 {
 public:
+    class CommandOptions : public Options
+    {
+    public:
+        
+        CommandOptions (CommandInterpreter &interpreter) :
+            Options (interpreter)
+        {
+            OptionParsingStarting ();
+        }
+
+        ~CommandOptions ()
+        {
+        }
+
+        Error
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
+        {
+            Error error;
+            const int short_option = m_getopt_table[option_idx].val;
+            
+            switch (short_option)
+            {
+                case 's':
+                    bool tmp_result;
+                    bool success;
+                    tmp_result = Args::StringToBoolean(option_arg, false, &success);
+                    if (!success)
+                        error.SetErrorStringWithFormat("invalid boolean option: \"%s\"", option_arg);
+                    else
+                    {
+                        if (tmp_result)
+                            m_keep_stopped = eLazyBoolYes;
+                        else
+                            m_keep_stopped = eLazyBoolNo;
+                    }
+                    break;
+                default:
+                    error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
+                    break;
+            }
+            return error;
+        }
+
+        void
+        OptionParsingStarting ()
+        {
+            m_keep_stopped = eLazyBoolCalculate;
+        }
+
+        const OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
+
+        // Options table: Required for subclasses of Options.
+
+        static OptionDefinition g_option_table[];
+
+        // Instance variables to hold the values for command options.
+        LazyBool m_keep_stopped;
+    };
 
     CommandObjectProcessDetach (CommandInterpreter &interpreter) :
         CommandObjectParsed (interpreter,
                              "process detach",
                              "Detach from the current process being debugged.",
                              "process detach",
-                             eFlagProcessMustBeLaunched)
+                             eFlagRequiresProcess      |
+                             eFlagTryTargetAPILock     |
+                             eFlagProcessMustBeLaunched),
+        m_options(interpreter)
     {
     }
 
@@ -871,21 +983,35 @@ public:
     {
     }
 
+    Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+
+
 protected:
     bool
-    DoExecute (Args& command,
-             CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
-        if (process == NULL)
-        {
-            result.AppendError ("must have a valid process in order to detach");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
+        Process *process = m_exe_ctx.GetProcessPtr();
+        result.AppendMessageWithFormat ("Detaching from process %" PRIu64 "\n", process->GetID());
+        // FIXME: This will be a Command Option:
+        bool keep_stopped;
+        if (m_options.m_keep_stopped == eLazyBoolCalculate)
+        {
+            // Check the process default:
+            if (process->GetDetachKeepsStopped())
+                keep_stopped = true;
+            else
+                keep_stopped = false;
         }
-
-        result.AppendMessageWithFormat ("Detaching from process %llu\n", process->GetID());
-        Error error (process->Detach());
+        else if (m_options.m_keep_stopped == eLazyBoolYes)
+            keep_stopped = true;
+        else
+            keep_stopped = false;
+        
+        Error error (process->Detach(keep_stopped));
         if (error.Success())
         {
             result.SetStatus (eReturnStatusSuccessFinishResult);
@@ -898,6 +1024,15 @@ protected:
         }
         return result.Succeeded();
     }
+
+    CommandOptions m_options;
+};
+
+OptionDefinition
+CommandObjectProcessDetach::CommandOptions::g_option_table[] =
+{
+{ LLDB_OPT_SET_1, false, "keep-stopped",   's', required_argument, NULL, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." },
+{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 
 //-------------------------------------------------------------------------
@@ -928,7 +1063,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
@@ -993,12 +1128,12 @@ protected:
         
         TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget());
         Error error;        
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+        Process *process = m_exe_ctx.GetProcessPtr();
         if (process)
         {
             if (process->IsAlive())
             {
-                result.AppendErrorWithFormat ("Process %llu is currently being debugged, kill the process before connecting.\n", 
+                result.AppendErrorWithFormat ("Process %" PRIu64 " is currently being debugged, kill the process before connecting.\n",
                                               process->GetID());
                 result.SetStatus (eReturnStatusFailed);
                 return false;
@@ -1008,10 +1143,9 @@ protected:
         if (!target_sp)
         {
             // If there isn't a current target create one.
-            FileSpec emptyFileSpec;
             
             error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(), 
-                                                                              emptyFileSpec,
+                                                                              NULL,
                                                                               NULL, 
                                                                               false,
                                                                               NULL, // No platform options
@@ -1036,7 +1170,7 @@ protected:
             
             if (process)
             {
-                error = process->ConnectRemote (remote_url);
+                error = process->ConnectRemote (&process->GetTarget().GetDebugger().GetOutputStream(), remote_url);
 
                 if (error.Fail())
                 {
@@ -1049,7 +1183,7 @@ protected:
             else
             {
                 result.AppendErrorWithFormat ("Unable to find process plug-in for remote URL '%s'.\nPlease specify a process plug-in name with the --plugin option, or specify an object file using the \"file\" command.\n", 
-                                              m_cmd_name.c_str());
+                                              remote_url);
                 result.SetStatus (eReturnStatusFailed);
             }
         }
@@ -1066,7 +1200,6 @@ protected:
     CommandOptions m_options;
 };
 
-
 OptionDefinition
 CommandObjectProcessConnect::CommandOptions::g_option_table[] =
 {
@@ -1075,6 +1208,39 @@ CommandObjectProcessConnect::CommandOpti
 };
 
 //-------------------------------------------------------------------------
+// CommandObjectProcessPlugin
+//-------------------------------------------------------------------------
+#pragma mark CommandObjectProcessPlugin
+
+class CommandObjectProcessPlugin : public CommandObjectProxy
+{
+public:
+    
+    CommandObjectProcessPlugin (CommandInterpreter &interpreter) :
+        CommandObjectProxy (interpreter,
+                            "process plugin",
+                            "Send a custom command to the current process plug-in.",
+                            "process plugin <args>",
+                            0)
+    {
+    }
+    
+    ~CommandObjectProcessPlugin ()
+    {
+    }
+
+    virtual CommandObject *
+    GetProxyCommandObject()
+    {
+        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+        if (process)
+            return process->GetPluginCommandObject();
+        return NULL;
+    }
+};
+
+
+//-------------------------------------------------------------------------
 // CommandObjectProcessLoad
 //-------------------------------------------------------------------------
 #pragma mark CommandObjectProcessLoad
@@ -1088,7 +1254,10 @@ public:
                              "process load",
                              "Load a shared library into the current process.",
                              "process load <filename> [<filename> ...]",
-                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+                             eFlagRequiresProcess       |
+                             eFlagTryTargetAPILock      |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused   )
     {
     }
 
@@ -1101,15 +1270,9 @@ protected:
     DoExecute (Args& command,
              CommandReturnObject &result)
     {
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
-        if (process == NULL)
-        {
-            result.AppendError ("must have a valid process in order to load a shared library");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
+        Process *process = m_exe_ctx.GetProcessPtr();
 
-        const uint32_t argc = command.GetArgumentCount();
+        const size_t argc = command.GetArgumentCount();
         
         for (uint32_t i=0; i<argc; ++i)
         {
@@ -1148,7 +1311,10 @@ public:
                              "process unload",
                              "Unload a shared library from the current process using the index returned by a previous call to \"process load\".",
                              "process unload <index>",
-                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+                             eFlagRequiresProcess       |
+                             eFlagTryTargetAPILock      |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused   )
     {
     }
 
@@ -1161,15 +1327,9 @@ protected:
     DoExecute (Args& command,
              CommandReturnObject &result)
     {
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
-        if (process == NULL)
-        {
-            result.AppendError ("must have a valid process in order to load a shared library");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
+        Process *process = m_exe_ctx.GetProcessPtr();
 
-        const uint32_t argc = command.GetArgumentCount();
+        const size_t argc = command.GetArgumentCount();
         
         for (uint32_t i=0; i<argc; ++i)
         {
@@ -1214,7 +1374,8 @@ public:
         CommandObjectParsed (interpreter,
                              "process signal",
                              "Send a UNIX signal to the current process being debugged.",
-                             NULL)
+                             NULL,
+                             eFlagRequiresProcess | eFlagTryTargetAPILock)
     {
         CommandArgumentEntry arg;
         CommandArgumentData signal_arg;
@@ -1239,13 +1400,7 @@ protected:
     DoExecute (Args& command,
              CommandReturnObject &result)
     {
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
-        if (process == NULL)
-        {
-            result.AppendError ("no process to signal");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
+        Process *process = m_exe_ctx.GetProcessPtr();
 
         if (command.GetArgumentCount() == 1)
         {
@@ -1302,6 +1457,8 @@ public:
                              "process interrupt",
                              "Interrupt the current process being debugged.",
                              "process interrupt",
+                             eFlagRequiresProcess      |
+                             eFlagTryTargetAPILock     |
                              eFlagProcessMustBeLaunched)
     {
     }
@@ -1313,9 +1470,9 @@ public:
 protected:
     bool
     DoExecute (Args& command,
-             CommandReturnObject &result)
+               CommandReturnObject &result)
     {
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+        Process *process = m_exe_ctx.GetProcessPtr();
         if (process == NULL)
         {
             result.AppendError ("no process to halt");
@@ -1325,14 +1482,11 @@ protected:
 
         if (command.GetArgumentCount() == 0)
         {
-            Error error(process->Halt ());
+            bool clear_thread_plans = true;
+            Error error(process->Halt (clear_thread_plans));
             if (error.Success())
             {
                 result.SetStatus (eReturnStatusSuccessFinishResult);
-                
-                // Maybe we should add a "SuspendThreadPlans so we
-                // can halt, and keep in place all the current thread plans.
-                process->GetThreadList().DiscardThreadPlans();
             }
             else
             {
@@ -1365,6 +1519,8 @@ public:
                              "process kill",
                              "Terminate the current process being debugged.",
                              "process kill",
+                             eFlagRequiresProcess      |
+                             eFlagTryTargetAPILock     |
                              eFlagProcessMustBeLaunched)
     {
     }
@@ -1378,7 +1534,7 @@ protected:
     DoExecute (Args& command,
              CommandReturnObject &result)
     {
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+        Process *process = m_exe_ctx.GetProcessPtr();
         if (process == NULL)
         {
             result.AppendError ("no process to kill");
@@ -1423,7 +1579,7 @@ public:
                              "process status",
                              "Show the current status and location of executing process.",
                              "process status",
-                             0)
+                             eFlagRequiresProcess | eFlagTryTargetAPILock)
     {
     }
 
@@ -1437,27 +1593,18 @@ public:
     {
         Stream &strm = result.GetOutputStream();
         result.SetStatus (eReturnStatusSuccessFinishNoResult);
-        ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-        Process *process = exe_ctx.GetProcessPtr();
-        if (process)
-        {
-            const bool only_threads_with_stop_reason = true;
-            const uint32_t start_frame = 0;
-            const uint32_t num_frames = 1;
-            const uint32_t num_frames_with_source = 1;
-            process->GetStatus(strm);
-            process->GetThreadStatus (strm, 
-                                      only_threads_with_stop_reason, 
-                                      start_frame,
-                                      num_frames,
-                                      num_frames_with_source);
-            
-        }
-        else
-        {
-            result.AppendError ("No process.");
-            result.SetStatus (eReturnStatusFailed);
-        }
+        // No need to check "process" for validity as eFlagRequiresProcess ensures it is valid        
+        Process *process = m_exe_ctx.GetProcessPtr();
+        const bool only_threads_with_stop_reason = true;
+        const uint32_t start_frame = 0;
+        const uint32_t num_frames = 1;
+        const uint32_t num_frames_with_source = 1;
+        process->GetStatus(strm);
+        process->GetThreadStatus (strm, 
+                                  only_threads_with_stop_reason, 
+                                  start_frame,
+                                  num_frames,
+                                  num_frames_with_source);
         return result.Succeeded();
     }
 };
@@ -1489,7 +1636,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
@@ -1789,6 +1936,7 @@ CommandObjectMultiwordProcess::CommandOb
     LoadSubCommand ("status",      CommandObjectSP (new CommandObjectProcessStatus    (interpreter)));
     LoadSubCommand ("interrupt",   CommandObjectSP (new CommandObjectProcessInterrupt (interpreter)));
     LoadSubCommand ("kill",        CommandObjectSP (new CommandObjectProcessKill      (interpreter)));
+    LoadSubCommand ("plugin",      CommandObjectSP (new CommandObjectProcessPlugin    (interpreter)));
 }
 
 CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess ()

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectQuit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectQuit.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectQuit.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectQuit.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectQuit.h"
 
 // C Includes
@@ -32,9 +34,64 @@ CommandObjectQuit::~CommandObjectQuit ()
 {
 }
 
+// returns true if there is at least one alive process
+// is_a_detach will be true if all alive processes will be detached when you quit
+// and false if at least one process will be killed instead
+bool
+CommandObjectQuit::ShouldAskForConfirmation (bool& is_a_detach)
+{
+    if (m_interpreter.GetPromptOnQuit() == false)
+        return false;
+    bool should_prompt = false;
+    is_a_detach = true;
+    for (uint32_t debugger_idx = 0;
+         debugger_idx < Debugger::GetNumDebuggers();
+         debugger_idx++)
+    {
+        DebuggerSP debugger_sp(Debugger::GetDebuggerAtIndex(debugger_idx));
+        if (!debugger_sp)
+            continue;
+        const TargetList& target_list(debugger_sp->GetTargetList());
+        for (uint32_t target_idx = 0;
+             target_idx < target_list.GetNumTargets();
+             target_idx++)
+        {
+            TargetSP target_sp(target_list.GetTargetAtIndex(target_idx));
+            if (!target_sp)
+                continue;
+            ProcessSP process_sp(target_sp->GetProcessSP());
+            if (process_sp
+                && process_sp->IsValid()
+                && process_sp->IsAlive()
+                && process_sp->WarnBeforeDetach())
+            {
+                should_prompt = true;
+                if (process_sp->GetShouldDetach() == false)
+                {
+                    // if we need to kill at least one process, just say so and return
+                    is_a_detach = false;
+                    return should_prompt;
+                }
+            }
+        }
+    }
+    return should_prompt;
+}
+
 bool
 CommandObjectQuit::DoExecute (Args& command, CommandReturnObject &result)
 {
+    bool is_a_detach = true;
+    if (ShouldAskForConfirmation (is_a_detach))
+    {
+        StreamString message;
+        message.Printf("Quitting LLDB will %s one or more processes. Do you really want to proceed", (is_a_detach ? "detach from" : "kill"));
+        if (!m_interpreter.Confirm(message.GetData(), true))
+        {
+            result.SetStatus(eReturnStatusFailed);
+            return false;
+        }
+    }
     m_interpreter.BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived);
     result.SetStatus (eReturnStatusQuit);
     return true;

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectQuit.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectQuit.h?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectQuit.h (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectQuit.h Thu Jun  6 19:06:43 2013
@@ -35,6 +35,9 @@ protected:
     virtual bool
     DoExecute (Args& args,
              CommandReturnObject &result);
+    
+    bool
+    ShouldAskForConfirmation (bool& is_a_detach);
 
 };
 

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectRegister.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectRegister.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectRegister.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectRegister.h"
 
 // C Includes
@@ -20,9 +22,10 @@
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Interpreter/NamedOptionValue.h"
 #include "lldb/Interpreter/Options.h"
 #include "lldb/Interpreter/OptionGroupFormat.h"
+#include "lldb/Interpreter/OptionValueArray.h"
+#include "lldb/Interpreter/OptionValueUInt64.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
@@ -42,7 +45,10 @@ public:
                              "register read",
                              "Dump the contents of one or more register values from the current frame.  If no register is specified, dumps them all.",
                              NULL,
-                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+                             eFlagRequiresFrame         |
+                             eFlagRequiresRegContext    |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused   ),
         m_option_group (interpreter),
         m_format_options (eFormatDefault),
         m_command_options ()
@@ -123,24 +129,29 @@ public:
     DumpRegisterSet (const ExecutionContext &exe_ctx,
                      Stream &strm,
                      RegisterContext *reg_ctx,
-                     uint32_t set_idx,
+                     size_t set_idx,
                      bool primitive_only=false)
     {
         uint32_t unavailable_count = 0;
         uint32_t available_count = 0;
+
+        if (!reg_ctx)
+            return false; // thread has no registers (i.e. core files are corrupt, incomplete crash logs...)
+
         const RegisterSet * const reg_set = reg_ctx->GetRegisterSet(set_idx);
         if (reg_set)
         {
             strm.Printf ("%s:\n", reg_set->name);
             strm.IndentMore ();
-            const uint32_t num_registers = reg_set->num_registers;
-            for (uint32_t reg_idx = 0; reg_idx < num_registers; ++reg_idx)
+            const size_t num_registers = reg_set->num_registers;
+            for (size_t reg_idx = 0; reg_idx < num_registers; ++reg_idx)
             {
                 const uint32_t reg = reg_set->registers[reg_idx];
                 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg);
                 // Skip the dumping of derived register if primitive_only is true.
                 if (primitive_only && reg_info && reg_info->value_regs)
                     continue;
+
                 if (DumpRegister (exe_ctx, strm, reg_ctx, reg_info))
                     ++available_count;
                 else
@@ -162,89 +173,89 @@ protected:
     DoExecute (Args& command, CommandReturnObject &result)
     {
         Stream &strm = result.GetOutputStream();
-        ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-        RegisterContext *reg_ctx = exe_ctx.GetRegisterContext ();
+        RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext ();
 
-        if (reg_ctx)
+        const RegisterInfo *reg_info = NULL;
+        if (command.GetArgumentCount() == 0)
         {
-            const RegisterInfo *reg_info = NULL;
-            if (command.GetArgumentCount() == 0)
+            size_t set_idx;
+            
+            size_t num_register_sets = 1;
+            const size_t set_array_size = m_command_options.set_indexes.GetSize();
+            if (set_array_size > 0)
             {
-                uint32_t set_idx;
-                
-                uint32_t num_register_sets = 1;
-                const uint32_t set_array_size = m_command_options.set_indexes.GetSize();
-                if (set_array_size > 0)
+                for (size_t i=0; i<set_array_size; ++i)
                 {
-                    for (uint32_t i=0; i<set_array_size; ++i)
+                    set_idx = m_command_options.set_indexes[i]->GetUInt64Value (UINT32_MAX, NULL);
+                    if (set_idx < reg_ctx->GetRegisterSetCount())
                     {
-                        set_idx = m_command_options.set_indexes[i]->GetUInt64Value (UINT32_MAX, NULL);
-                        if (set_idx != UINT32_MAX)
+                        if (!DumpRegisterSet (m_exe_ctx, strm, reg_ctx, set_idx))
                         {
-                            if (!DumpRegisterSet (exe_ctx, strm, reg_ctx, set_idx))
-                            {
-                                result.AppendErrorWithFormat ("invalid register set index: %u\n", set_idx);
-                                result.SetStatus (eReturnStatusFailed);
-                                break;
-                            }
-                        }
-                        else
-                        {
-                            result.AppendError ("invalid register set index\n");
+                            if (errno)
+                                result.AppendErrorWithFormat ("register read failed with errno: %d\n", errno);
+                            else
+                                result.AppendError ("unknown error while reading registers.\n");
                             result.SetStatus (eReturnStatusFailed);
                             break;
                         }
                     }
-                }
-                else
-                {
-                    if (m_command_options.dump_all_sets)
-                        num_register_sets = reg_ctx->GetRegisterSetCount();
-
-                    for (set_idx = 0; set_idx < num_register_sets; ++set_idx)
+                    else
                     {
-                        // When dump_all_sets option is set, dump primitive as well as derived registers.
-                        DumpRegisterSet (exe_ctx, strm, reg_ctx, set_idx, !m_command_options.dump_all_sets.GetCurrentValue());
+                        result.AppendErrorWithFormat ("invalid register set index: %zu\n", set_idx);
+                        result.SetStatus (eReturnStatusFailed);
+                        break;
                     }
                 }
             }
             else
             {
                 if (m_command_options.dump_all_sets)
+                    num_register_sets = reg_ctx->GetRegisterSetCount();
+
+                for (set_idx = 0; set_idx < num_register_sets; ++set_idx)
                 {
-                    result.AppendError ("the --all option can't be used when registers names are supplied as arguments\n");
-                    result.SetStatus (eReturnStatusFailed);
-                }
-                else if (m_command_options.set_indexes.GetSize() > 0)
-                {
-                    result.AppendError ("the --set <set> option can't be used when registers names are supplied as arguments\n");
-                    result.SetStatus (eReturnStatusFailed);
+                    // When dump_all_sets option is set, dump primitive as well as derived registers.
+                    DumpRegisterSet (m_exe_ctx, strm, reg_ctx, set_idx, !m_command_options.dump_all_sets.GetCurrentValue());
                 }
-                else
+            }
+        }
+        else
+        {
+            if (m_command_options.dump_all_sets)
+            {
+                result.AppendError ("the --all option can't be used when registers names are supplied as arguments\n");
+                result.SetStatus (eReturnStatusFailed);
+            }
+            else if (m_command_options.set_indexes.GetSize() > 0)
+            {
+                result.AppendError ("the --set <set> option can't be used when registers names are supplied as arguments\n");
+                result.SetStatus (eReturnStatusFailed);
+            }
+            else
+            {
+                const char *arg_cstr;
+                for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx)
                 {
-                    const char *arg_cstr;
-                    for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx)
-                    {
-                        reg_info = reg_ctx->GetRegisterInfoByName(arg_cstr);
+                    // in most LLDB commands we accept $rbx as the name for register RBX - and here we would
+                    // reject it and non-existant. we should be more consistent towards the user and allow them
+                    // to say reg read $rbx - internally, however, we should be strict and not allow ourselves
+                    // to call our registers $rbx in our own API
+                    if (*arg_cstr == '$')
+                        arg_cstr = arg_cstr+1;
+                    reg_info = reg_ctx->GetRegisterInfoByName(arg_cstr);
 
-                        if (reg_info)
-                        {
-                            if (!DumpRegister (exe_ctx, strm, reg_ctx, reg_info))
-                                strm.Printf("%-12s = error: unavailable\n", reg_info->name);
-                        }
-                        else
-                        {
-                            result.AppendErrorWithFormat ("Invalid register name '%s'.\n", arg_cstr);
-                        }
+                    if (reg_info)
+                    {
+                        if (!DumpRegister (m_exe_ctx, strm, reg_ctx, reg_info))
+                            strm.Printf("%-12s = error: unavailable\n", reg_info->name);
+                    }
+                    else
+                    {
+                        result.AppendErrorWithFormat ("Invalid register name '%s'.\n", arg_cstr);
                     }
                 }
             }
         }
-        else
-        {
-            result.AppendError ("no current frame");
-            result.SetStatus (eReturnStatusFailed);
-        }
         return result.Succeeded();
     }
 
@@ -288,7 +299,7 @@ protected:
                         const char *option_value)
         {
             Error error;
-            const char short_option = (char) g_option_table[option_idx].short_option;
+            const int short_option = g_option_table[option_idx].short_option;
             switch (short_option)
             {
                 case 's':
@@ -363,7 +374,10 @@ public:
                              "register write",
                              "Modify a single register value.",
                              NULL,
-                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+                             eFlagRequiresFrame         |
+                             eFlagRequiresRegContext    |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused)
     {
         CommandArgumentEntry arg1;
         CommandArgumentEntry arg2;
@@ -399,64 +413,64 @@ protected:
     DoExecute(Args& command, CommandReturnObject &result)
     {
         DataExtractor reg_data;
-        ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-        RegisterContext *reg_ctx = exe_ctx.GetRegisterContext ();
+        RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext ();
 
-        if (reg_ctx)
+        if (command.GetArgumentCount() != 2)
         {
-            if (command.GetArgumentCount() != 2)
-            {
-                result.AppendError ("register write takes exactly 2 arguments: <reg-name> <value>");
-                result.SetStatus (eReturnStatusFailed);
-            }
-            else
-            {
-                const char *reg_name = command.GetArgumentAtIndex(0);
-                const char *value_str = command.GetArgumentAtIndex(1);
-                const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
+            result.AppendError ("register write takes exactly 2 arguments: <reg-name> <value>");
+            result.SetStatus (eReturnStatusFailed);
+        }
+        else
+        {
+            const char *reg_name = command.GetArgumentAtIndex(0);
+            const char *value_str = command.GetArgumentAtIndex(1);
+            
+            
+            // in most LLDB commands we accept $rbx as the name for register RBX - and here we would
+            // reject it and non-existant. we should be more consistent towards the user and allow them
+            // to say reg write $rbx - internally, however, we should be strict and not allow ourselves
+            // to call our registers $rbx in our own API
+            if (reg_name && *reg_name == '$')
+                reg_name = reg_name+1;
+            
+            const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
 
-                if (reg_info)
+            if (reg_info)
+            {
+                RegisterValue reg_value;
+                
+                Error error (reg_value.SetValueFromCString (reg_info, value_str));
+                if (error.Success())
                 {
-                    RegisterValue reg_value;
-                    
-                    Error error (reg_value.SetValueFromCString (reg_info, value_str));
-                    if (error.Success())
+                    if (reg_ctx->WriteRegister (reg_info, reg_value))
                     {
-                        if (reg_ctx->WriteRegister (reg_info, reg_value))
-                        {
-                            // Toss all frames and anything else in the thread
-                            // after a register has been written.
-                            exe_ctx.GetThreadRef().Flush();
-                            result.SetStatus (eReturnStatusSuccessFinishNoResult);
-                            return true;
-                        }
+                        // Toss all frames and anything else in the thread
+                        // after a register has been written.
+                        m_exe_ctx.GetThreadRef().Flush();
+                        result.SetStatus (eReturnStatusSuccessFinishNoResult);
+                        return true;
                     }
-                    if (error.AsCString())
-                    {
-                        result.AppendErrorWithFormat ("Failed to write register '%s' with value '%s': %s\n",
-                                                     reg_name,
-                                                     value_str,
-                                                     error.AsCString());
-                    }
-                    else
-                    {
-                        result.AppendErrorWithFormat ("Failed to write register '%s' with value '%s'",
-                                                     reg_name,
-                                                     value_str);
-                    }
-                    result.SetStatus (eReturnStatusFailed);
+                }
+                if (error.AsCString())
+                {
+                    result.AppendErrorWithFormat ("Failed to write register '%s' with value '%s': %s\n",
+                                                 reg_name,
+                                                 value_str,
+                                                 error.AsCString());
                 }
                 else
                 {
-                    result.AppendErrorWithFormat ("Register not found for '%s'.\n", reg_name);
-                    result.SetStatus (eReturnStatusFailed);
+                    result.AppendErrorWithFormat ("Failed to write register '%s' with value '%s'",
+                                                 reg_name,
+                                                 value_str);
                 }
+                result.SetStatus (eReturnStatusFailed);
+            }
+            else
+            {
+                result.AppendErrorWithFormat ("Register not found for '%s'.\n", reg_name);
+                result.SetStatus (eReturnStatusFailed);
             }
-        }
-        else
-        {
-            result.AppendError ("no current frame");
-            result.SetStatus (eReturnStatusFailed);
         }
         return result.Succeeded();
     }

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectSettings.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectSettings.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectSettings.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectSettings.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectSettings.h"
 
 // C Includes
@@ -21,12 +23,6 @@ using namespace lldb;
 using namespace lldb_private;
 #include "llvm/ADT/StringRef.h"
 
-static inline void StripLeadingSpaces(llvm::StringRef &Str)
-{
-    while (!Str.empty() && isspace(Str[0]))
-        Str = Str.substr(1);
-}
-
 //-------------------------------------------------------------------------
 // CommandObjectSettingsSet
 //-------------------------------------------------------------------------
@@ -68,8 +64,8 @@ public:
 "When setting a dictionary or array variable, you can set multiple entries \n\
 at once by giving the values to the set command.  For example: \n\
 \n\
-(lldb) settings set target.run-args value1  value2 value3 \n\
-(lldb) settings set target.env-vars [\"MYPATH\"]=~/.:/usr/bin  [\"SOME_ENV_VAR\"]=12345 \n\
+(lldb) settings set target.run-args value1 value2 value3 \n\
+(lldb) settings set target.env-vars MYPATH=~/.:/usr/bin  SOME_ENV_VAR=12345 \n\
 \n\
 (lldb) settings show target.run-args \n\
   [0]: 'value1' \n\
@@ -79,8 +75,6 @@ at once by giving the values to the set
   'MYPATH=~/.:/usr/bin'\n\
   'SOME_ENV_VAR=12345' \n\
 \n\
-Note the special syntax for setting a dictionary element: [\"<key>\"]=<value> \n\
-\n\
 Warning:  The 'set' command re-sets the entire array or dictionary.  If you \n\
 just want to add, remove or update individual values (or add something to \n\
 the end), use one of the other settings sub-commands: append, replace, \n\
@@ -108,8 +102,7 @@ insert-before or insert-after.\n");
 
         CommandOptions (CommandInterpreter &interpreter) :
             Options (interpreter),
-            m_override (true),
-            m_reset (false)
+            m_global (false)
         {
         }
 
@@ -120,15 +113,12 @@ insert-before or insert-after.\n");
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
-                case 'n':
-                    m_override = false;
-                    break;
-                case 'r':
-                    m_reset = true;
+                case 'g':
+                    m_global = true;
                     break;
                 default:
                     error.SetErrorStringWithFormat ("unrecognized options '%c'", short_option);
@@ -141,8 +131,7 @@ insert-before or insert-after.\n");
         void
         OptionParsingStarting ()
         {
-            m_override = true;
-            m_reset = false;
+            m_global = false;
         }
         
         const OptionDefinition*
@@ -157,9 +146,7 @@ insert-before or insert-after.\n");
 
         // Instance variables to hold the values for command options.
 
-        bool m_override;
-        bool m_reset;
-
+        bool m_global;
     };
 
     virtual int
@@ -172,15 +159,20 @@ insert-before or insert-after.\n");
                               bool &word_complete,
                               StringList &matches)
     {
-        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-        completion_str.erase (cursor_char_position);
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
 
-        // Attempting to complete variable name
-        llvm::StringRef prev_str(cursor_index == 2 ? input.GetArgumentAtIndex(1) : "");
-        if (cursor_index == 1 ||
-            (cursor_index == 2 && prev_str.startswith("-")) // "settings set -r th", followed by Tab.
-            )
+        const size_t argc = input.GetArgumentCount();
+        const char *arg = NULL;
+        int setting_var_idx;
+        for (setting_var_idx = 1; setting_var_idx < argc; ++setting_var_idx)
+        {
+            arg = input.GetArgumentAtIndex(setting_var_idx);
+            if (arg && arg[0] != '-')
+                break; // We found our setting variable name index
+        }
+        if (cursor_index == setting_var_idx)
         {
+            // Attempting to complete setting variable name
             CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
                                                                  CommandCompletions::eSettingsNameCompletion,
                                                                  completion_str.c_str(),
@@ -189,39 +181,35 @@ insert-before or insert-after.\n");
                                                                  NULL,
                                                                  word_complete,
                                                                  matches);
-            // If there is only 1 match which fulfills the completion request, do an early return.
-            if (matches.GetSize() == 1 && completion_str.compare(matches.GetStringAtIndex(0)) != 0)
-                return 1;
         }
-
-        // Attempting to complete value
-        if ((cursor_index == 2)   // Partly into the variable's value
-            || (cursor_index == 1  // Or at the end of a completed valid variable name
-                && matches.GetSize() == 1
-                && completion_str.compare (matches.GetStringAtIndex(0)) == 0))
-        {
-            matches.Clear();
-            UserSettingsControllerSP usc_sp = Debugger::GetSettingsController();
-            if (cursor_index == 1)
-            {
-                // The user is at the end of the variable name, which is complete and valid.
-                UserSettingsController::CompleteSettingsValue (usc_sp,
-                                                               input.GetArgumentAtIndex (1), // variable name
-                                                               NULL,                         // empty value string
-                                                               word_complete,
-                                                               matches);
-            }
-            else
+        else
+        {
+            arg = input.GetArgumentAtIndex(cursor_index);
+            
+            if (arg)
             {
-                // The user is partly into the variable value.
-                UserSettingsController::CompleteSettingsValue (usc_sp,
-                                                               input.GetArgumentAtIndex (1),  // variable name
-                                                               completion_str.c_str(),        // partial value string
-                                                               word_complete,
-                                                               matches);
+                if (arg[0] == '-')
+                {
+                    // Complete option name
+                }
+                else
+                {
+                    // Complete setting value
+                    const char *setting_var_name = input.GetArgumentAtIndex(setting_var_idx);
+                    Error error;
+                    lldb::OptionValueSP value_sp (m_interpreter.GetDebugger().GetPropertyValue(&m_exe_ctx, setting_var_name, false, error));
+                    if (value_sp)
+                    {
+                        value_sp->AutoComplete (m_interpreter,
+                                                completion_str.c_str(),
+                                                match_start_point,
+                                                max_return_elements,
+                                                word_complete,
+                                                matches);
+                    }
+                }
             }
         }
-
         return matches.GetSize();
     }
     
@@ -229,16 +217,14 @@ protected:
     virtual bool
     DoExecute (const char *command, CommandReturnObject &result)
     {
-        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
-
         Args cmd_args(command);
 
         // Process possible options.
         if (!ParseOptions (cmd_args, result))
             return false;
 
-        const int argc = cmd_args.GetArgumentCount ();
-        if ((argc < 2) && (!m_options.m_reset))
+        const size_t argc = cmd_args.GetArgumentCount ();
+        if ((argc < 2) && (!m_options.m_global))
         {
             result.AppendError ("'settings set' takes more arguments");
             result.SetStatus (eReturnStatusFailed);
@@ -248,39 +234,49 @@ protected:
         const char *var_name = cmd_args.GetArgumentAtIndex (0);
         if ((var_name == NULL) || (var_name[0] == '\0'))
         {
-            result.AppendError ("'settings set' command requires a valid variable name; No value supplied");
+            result.AppendError ("'settings set' command requires a valid variable name");
             result.SetStatus (eReturnStatusFailed);
             return false;
         }
 
         // Split the raw command into var_name and value pair.
-        std::string var_name_string = var_name;
         llvm::StringRef raw_str(command);
-        llvm::StringRef var_value_str = raw_str.split(var_name).second;
-        StripLeadingSpaces(var_value_str);
-        std::string var_value_string = var_value_str.str();
+        std::string var_value_string = raw_str.split(var_name).second.str();
+        const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false);
 
-        if (!m_options.m_reset
-            && var_value_string.empty())
+        Error error;
+        if (m_options.m_global)
         {
-            result.AppendError ("'settings set' command requires a valid variable value unless using '--reset' option;"
-                                " No value supplied");
+            error = m_interpreter.GetDebugger().SetPropertyValue (NULL,
+                                                                  eVarSetOperationAssign,
+                                                                  var_name,
+                                                                  var_value_cstr);
+        }
+        
+        if (error.Success())
+        {
+            // FIXME this is the same issue as the one in commands script import
+            // we could be setting target.load-script-from-symbol-file which would cause
+            // Python scripts to be loaded, which could run LLDB commands
+            // (e.g. settings set target.process.python-os-plugin-path) and cause a crash
+            // if we did not clear the command's exe_ctx first
+            ExecutionContext exe_ctx(m_exe_ctx);
+            m_exe_ctx.Clear();
+            error = m_interpreter.GetDebugger().SetPropertyValue (&exe_ctx,
+                                                                  eVarSetOperationAssign,
+                                                                  var_name,
+                                                                  var_value_cstr);
+        }
+
+        if (error.Fail())
+        {
+            result.AppendError (error.AsCString());
             result.SetStatus (eReturnStatusFailed);
+            return false;
         }
         else
         {
-          Error err = usc_sp->SetVariable (var_name_string.c_str(), 
-                                           var_value_string.c_str(), 
-                                           eVarSetOperationAssign, 
-                                           m_options.m_override, 
-                                           m_interpreter.GetDebugger().GetInstanceName().AsCString());
-            if (err.Fail ())
-            {
-                result.AppendError (err.AsCString());
-                result.SetStatus (eReturnStatusFailed);
-            }
-            else
-                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            result.SetStatus (eReturnStatusSuccessFinishResult);
         }
 
         return result.Succeeded();
@@ -292,8 +288,7 @@ private:
 OptionDefinition
 CommandObjectSettingsSet::CommandOptions::g_option_table[] =
 {
-    { LLDB_OPT_SET_1, false, "no-override", 'n', no_argument, NULL, NULL, eArgTypeNone, "Prevents already existing instances and pending settings from being assigned this new value.  Using this option means that only the default or specified instance setting values will be updated." },
-    { LLDB_OPT_SET_2, false, "reset", 'r', no_argument,   NULL, NULL, eArgTypeNone, "Causes value to be reset to the original default for this variable.  No value needs to be specified when this option is used." },
+    { LLDB_OPT_SET_2, false, "global", 'g', no_argument,   NULL, 0, eArgTypeNone, "Apply the new value to the global default value." },
     { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 
@@ -339,8 +334,7 @@ public:
                               bool &word_complete,
                               StringList &matches)
     {
-        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-        completion_str.erase (cursor_char_position);
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
 
         CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
                                                              CommandCompletions::eSettingsNameCompletion,
@@ -355,51 +349,32 @@ public:
 
 protected:
     virtual bool
-    DoExecute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
-        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
-        const char *current_prefix = usc_sp->GetLevelName().GetCString();
+        result.SetStatus (eReturnStatusSuccessFinishResult);
 
-        Error err;
-
-        if (command.GetArgumentCount())
+        const size_t argc = args.GetArgumentCount ();
+        if (argc > 0)
         {
-            // The user requested to see the value of a particular variable.
-            SettableVariableType var_type;
-            const char *variable_name = command.GetArgumentAtIndex (0);
-            StringList value = usc_sp->GetVariable (variable_name, 
-                                                    var_type,
-                                                    m_interpreter.GetDebugger().GetInstanceName().AsCString(),
-                                                    err);
-            
-            if (err.Fail ())
-            {
-                result.AppendError (err.AsCString());
-                result.SetStatus (eReturnStatusFailed);
-                  
-            }
-            else
+            for (size_t i=0; i<argc; ++i)
             {
-                UserSettingsController::DumpValue(m_interpreter, usc_sp, variable_name, result.GetOutputStream());
-                result.SetStatus (eReturnStatusSuccessFinishResult);
+                const char *property_path = args.GetArgumentAtIndex (i);
+
+                Error error(m_interpreter.GetDebugger().DumpPropertyValue (&m_exe_ctx, result.GetOutputStream(), property_path, OptionValue::eDumpGroupValue));
+                if (error.Success())
+                {
+                    result.GetOutputStream().EOL();
+                }
+                else
+                {
+                    result.AppendError (error.AsCString());
+                    result.SetStatus (eReturnStatusFailed);
+                }
             }
         }
         else
         {
-            UserSettingsController::GetAllVariableValues (m_interpreter, 
-                                                          usc_sp, 
-                                                          current_prefix, 
-                                                          result.GetOutputStream(), 
-                                                          err);
-            if (err.Fail ())
-            {
-                result.AppendError (err.AsCString());
-                result.SetStatus (eReturnStatusFailed);
-            }
-            else
-            {
-                result.SetStatus (eReturnStatusSuccessFinishNoResult);
-            }
+            m_interpreter.GetDebugger().DumpAllPropertyValues (&m_exe_ctx, result.GetOutputStream(), OptionValue::eDumpGroupValue);
         }
 
         return result.Succeeded();
@@ -451,8 +426,7 @@ public:
                               bool &word_complete,
                               StringList &matches)
     {
-        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-        completion_str.erase (cursor_char_position);
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
 
         CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
                                                              CommandCompletions::eSettingsNameCompletion,
@@ -467,46 +441,36 @@ public:
 
 protected:
     virtual bool
-    DoExecute (Args& command, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
-        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
-        const char *current_prefix = usc_sp->GetLevelName().GetCString();
-
-        Error err;
+        result.SetStatus (eReturnStatusSuccessFinishResult);
 
-        if (command.GetArgumentCount() == 0)
+        const bool will_modify = false;
+        const size_t argc = args.GetArgumentCount ();
+        if (argc > 0)
         {
-            UserSettingsController::FindAllSettingsDescriptions (m_interpreter, 
-                                                                 usc_sp, 
-                                                                 current_prefix, 
-                                                                 result.GetOutputStream(), 
-                                                                 err);
-        }
-        else if (command.GetArgumentCount() == 1)
-        {
-            const char *search_name = command.GetArgumentAtIndex (0);
-            UserSettingsController::FindSettingsDescriptions (m_interpreter, 
-                                                              usc_sp, 
-                                                              current_prefix,
-                                                              search_name, 
-                                                              result.GetOutputStream(), 
-                                                              err);
-        }
-        else
-        {
-            result.AppendError ("Too many aguments for 'settings list' command.\n");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
+            const bool dump_qualified_name = true;
 
-        if (err.Fail ())
-        {
-            result.AppendError (err.AsCString());
-            result.SetStatus (eReturnStatusFailed);
+            for (size_t i=0; i<argc; ++i)
+            {
+                const char *property_path = args.GetArgumentAtIndex (i);
+                
+                const Property *property = m_interpreter.GetDebugger().GetValueProperties()->GetPropertyAtPath (&m_exe_ctx, will_modify, property_path);
+
+                if (property)
+                {
+                    property->DumpDescription (m_interpreter, result.GetOutputStream(), 0, dump_qualified_name);
+                }
+                else
+                {
+                    result.AppendErrorWithFormat ("invalid property path '%s'", property_path);
+                    result.SetStatus (eReturnStatusFailed);
+                }
+            }
         }
         else
         {
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            m_interpreter.GetDebugger().DumpAllDescriptions (m_interpreter, result.GetOutputStream());
         }
 
         return result.Succeeded();
@@ -517,14 +481,14 @@ protected:
 // CommandObjectSettingsRemove
 //-------------------------------------------------------------------------
 
-class CommandObjectSettingsRemove : public CommandObjectParsed
+class CommandObjectSettingsRemove : public CommandObjectRaw
 {
 public:
     CommandObjectSettingsRemove (CommandInterpreter &interpreter) :
-        CommandObjectParsed (interpreter,
-                             "settings remove",
-                             "Remove the specified element from an internal debugger settings array or dictionary variable.",
-                             NULL)
+        CommandObjectRaw (interpreter,
+                          "settings remove",
+                          "Remove the specified element from an array or dictionary settings variable.",
+                          NULL)
     {
         CommandArgumentEntry arg1;
         CommandArgumentEntry arg2;
@@ -569,8 +533,7 @@ public:
                               bool &word_complete,
                               StringList &matches)
     {
-        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-        completion_str.erase (cursor_char_position);
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
 
         // Attempting to complete variable name
         if (cursor_index < 2)
@@ -588,56 +551,48 @@ public:
 
 protected:
     virtual bool
-    DoExecute (Args& command, CommandReturnObject &result)
+    DoExecute (const char *command, CommandReturnObject &result)
     {
-        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
-
-        const int argc = command.GetArgumentCount ();
-
-        if (argc != 2)
+        result.SetStatus (eReturnStatusSuccessFinishNoResult);
+     
+        Args cmd_args(command);
+        
+        // Process possible options.
+        if (!ParseOptions (cmd_args, result))
+            return false;
+        
+        const size_t argc = cmd_args.GetArgumentCount ();
+        if (argc == 0)
         {
-            result.AppendError ("'settings remove' takes two arguments");
+            result.AppendError ("'settings set' takes an array or dictionary item, or an array followed by one or more indexes, or a dictionary followed by one or more key names to remove");
             result.SetStatus (eReturnStatusFailed);
             return false;
         }
-
-        const char *var_name = command.GetArgumentAtIndex (0);
-        std::string var_name_string;
+        
+        const char *var_name = cmd_args.GetArgumentAtIndex (0);
         if ((var_name == NULL) || (var_name[0] == '\0'))
         {
-            result.AppendError ("'settings remove' command requires a valid variable name; No value supplied");
+            result.AppendError ("'settings set' command requires a valid variable name");
             result.SetStatus (eReturnStatusFailed);
             return false;
         }
-
-        var_name_string = var_name;
-        command.Shift();
-
-        const char *index_value = command.GetArgumentAtIndex (0);
-        std::string index_value_string;
-        if ((index_value == NULL) || (index_value[0] == '\0'))
+        
+        // Split the raw command into var_name and value pair.
+        llvm::StringRef raw_str(command);
+        std::string var_value_string = raw_str.split(var_name).second.str();
+        const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false);
+        
+        Error error (m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
+                                                                   eVarSetOperationRemove,
+                                                                   var_name,
+                                                                   var_value_cstr));
+        if (error.Fail())
         {
-            result.AppendError ("'settings remove' command requires an index or key value; no value supplied");
+            result.AppendError (error.AsCString());
             result.SetStatus (eReturnStatusFailed);
             return false;
         }
-
-        index_value_string = index_value;
-
-        Error err = usc_sp->SetVariable (var_name_string.c_str(), 
-                                         NULL, 
-                                         eVarSetOperationRemove,  
-                                         true, 
-                                         m_interpreter.GetDebugger().GetInstanceName().AsCString(),
-                                         index_value_string.c_str());
-        if (err.Fail ())
-        {
-            result.AppendError (err.AsCString());
-            result.SetStatus (eReturnStatusFailed);
-        }
-        else
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
-
+        
         return result.Succeeded();
     }
 };
@@ -713,8 +668,7 @@ public:
                               bool &word_complete,
                               StringList &matches)
     {
-        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-        completion_str.erase (cursor_char_position);
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
 
         // Attempting to complete variable name
         if (cursor_index < 2)
@@ -734,20 +688,10 @@ protected:
     virtual bool
     DoExecute (const char *command, CommandReturnObject &result)
     {
-        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
+        result.SetStatus (eReturnStatusSuccessFinishNoResult);
 
         Args cmd_args(command);
-        const int argc = cmd_args.GetArgumentCount ();
-
-        if (argc < 3)
-        {
-            result.AppendError ("'settings replace' takes more arguments");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
-
         const char *var_name = cmd_args.GetArgumentAtIndex (0);
-        std::string var_name_string;
         if ((var_name == NULL) || (var_name[0] == '\0'))
         {
             result.AppendError ("'settings replace' command requires a valid variable name; No value supplied");
@@ -755,47 +699,26 @@ protected:
             return false;
         }
 
-        var_name_string = var_name;
-        cmd_args.Shift();
-
-        const char *index_value = cmd_args.GetArgumentAtIndex (0);
-        std::string index_value_string;
-        if ((index_value == NULL) || (index_value[0] == '\0'))
-        {
-            result.AppendError ("'settings insert-before' command requires an index value; no value supplied");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
-
-        index_value_string = index_value;
-        cmd_args.Shift();
 
         // Split the raw command into var_name, index_value, and value triple.
         llvm::StringRef raw_str(command);
-        llvm::StringRef var_value_str = raw_str.split(var_name).second.split(index_value).second;
-        StripLeadingSpaces(var_value_str);
-        std::string var_value_string = var_value_str.str();
+        std::string var_value_string = raw_str.split(var_name).second.str();
+        const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false);
 
-        if (var_value_string.empty())
+        Error error(m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
+                                                                  eVarSetOperationReplace,
+                                                                  var_name,
+                                                                  var_value_cstr));
+        if (error.Fail())
         {
-            result.AppendError ("'settings replace' command requires a valid variable value; no value supplied");
+            result.AppendError (error.AsCString());
             result.SetStatus (eReturnStatusFailed);
+            return false;
         }
         else
         {
-            Error err = usc_sp->SetVariable (var_name_string.c_str(), 
-                                             var_value_string.c_str(), 
-                                             eVarSetOperationReplace, 
-                                             true, 
-                                             m_interpreter.GetDebugger().GetInstanceName().AsCString(),
-                                             index_value_string.c_str());
-            if (err.Fail ())
-            {
-                result.AppendError (err.AsCString());
-                result.SetStatus (eReturnStatusFailed);
-            }
-            else
-                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            result.SetStatus (eReturnStatusSuccessFinishNoResult);
+
         }
 
         return result.Succeeded();
@@ -866,8 +789,7 @@ public:
                               bool &word_complete,
                               StringList &matches)
     {
-        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-        completion_str.erase (cursor_char_position);
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
 
         // Attempting to complete variable name
         if (cursor_index < 2)
@@ -887,10 +809,10 @@ protected:
     virtual bool
     DoExecute (const char *command, CommandReturnObject &result)
     {
-        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
+        result.SetStatus (eReturnStatusSuccessFinishNoResult);
 
         Args cmd_args(command);
-        const int argc = cmd_args.GetArgumentCount ();
+        const size_t argc = cmd_args.GetArgumentCount ();
 
         if (argc < 3)
         {
@@ -900,7 +822,6 @@ protected:
         }
 
         const char *var_name = cmd_args.GetArgumentAtIndex (0);
-        std::string var_name_string;
         if ((var_name == NULL) || (var_name[0] == '\0'))
         {
             result.AppendError ("'settings insert-before' command requires a valid variable name; No value supplied");
@@ -908,48 +829,20 @@ protected:
             return false;
         }
 
-        var_name_string = var_name;
-        cmd_args.Shift();
-
-        const char *index_value = cmd_args.GetArgumentAtIndex (0);
-        std::string index_value_string;
-        if ((index_value == NULL) || (index_value[0] == '\0'))
-        {
-            result.AppendError ("'settings insert-before' command requires an index value; no value supplied");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
-
-        index_value_string = index_value;
-        cmd_args.Shift();
-
         // Split the raw command into var_name, index_value, and value triple.
         llvm::StringRef raw_str(command);
-        llvm::StringRef var_value_str = raw_str.split(var_name).second.split(index_value).second;
-        StripLeadingSpaces(var_value_str);
-        std::string var_value_string = var_value_str.str();
+        std::string var_value_string = raw_str.split(var_name).second.str();
+        const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false);
 
-        if (var_value_string.empty())
+        Error error(m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
+                                                                  eVarSetOperationInsertBefore,
+                                                                  var_name,
+                                                                  var_value_cstr));
+        if (error.Fail())
         {
-            result.AppendError ("'settings insert-before' command requires a valid variable value;"
-                                " No value supplied");
+            result.AppendError (error.AsCString());
             result.SetStatus (eReturnStatusFailed);
-        }
-        else
-        {
-            Error err = usc_sp->SetVariable (var_name_string.c_str(), 
-                                             var_value_string.c_str(), 
-                                             eVarSetOperationInsertBefore,
-                                             true, 
-                                             m_interpreter.GetDebugger().GetInstanceName().AsCString(),
-                                             index_value_string.c_str());
-            if (err.Fail ())
-            {
-                result.AppendError (err.AsCString());
-                result.SetStatus (eReturnStatusFailed);
-            }
-            else
-                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            return false;
         }
 
         return result.Succeeded();
@@ -1020,8 +913,7 @@ public:
                               bool &word_complete,
                               StringList &matches)
     {
-        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-        completion_str.erase (cursor_char_position);
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
 
         // Attempting to complete variable name
         if (cursor_index < 2)
@@ -1041,10 +933,10 @@ protected:
     virtual bool
     DoExecute (const char *command, CommandReturnObject &result)
     {
-        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
+        result.SetStatus (eReturnStatusSuccessFinishNoResult);
 
         Args cmd_args(command);
-        const int argc = cmd_args.GetArgumentCount ();
+        const size_t argc = cmd_args.GetArgumentCount ();
 
         if (argc < 3)
         {
@@ -1054,7 +946,6 @@ protected:
         }
 
         const char *var_name = cmd_args.GetArgumentAtIndex (0);
-        std::string var_name_string;
         if ((var_name == NULL) || (var_name[0] == '\0'))
         {
             result.AppendError ("'settings insert-after' command requires a valid variable name; No value supplied");
@@ -1062,48 +953,20 @@ protected:
             return false;
         }
 
-        var_name_string = var_name;
-        cmd_args.Shift();
-
-        const char *index_value = cmd_args.GetArgumentAtIndex (0);
-        std::string index_value_string;
-        if ((index_value == NULL) || (index_value[0] == '\0'))
-        {
-            result.AppendError ("'settings insert-after' command requires an index value; no value supplied");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
-
-        index_value_string = index_value;
-        cmd_args.Shift();
-
         // Split the raw command into var_name, index_value, and value triple.
         llvm::StringRef raw_str(command);
-        llvm::StringRef var_value_str = raw_str.split(var_name).second.split(index_value).second;
-        StripLeadingSpaces(var_value_str);
-        std::string var_value_string = var_value_str.str();
+        std::string var_value_string = raw_str.split(var_name).second.str();
+        const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false);
 
-        if (var_value_string.empty())
+        Error error(m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
+                                                                  eVarSetOperationInsertAfter,
+                                                                  var_name,
+                                                                  var_value_cstr));
+        if (error.Fail())
         {
-            result.AppendError ("'settings insert-after' command requires a valid variable value;"
-                                " No value supplied");
+            result.AppendError (error.AsCString());
             result.SetStatus (eReturnStatusFailed);
-        }
-        else
-        {
-            Error err = usc_sp->SetVariable (var_name_string.c_str(), 
-                                             var_value_string.c_str(), 
-                                             eVarSetOperationInsertAfter,
-                                             true, 
-                                             m_interpreter.GetDebugger().GetInstanceName().AsCString(), 
-                                             index_value_string.c_str());
-            if (err.Fail ())
-            {
-                result.AppendError (err.AsCString());
-                result.SetStatus (eReturnStatusFailed);
-            }
-            else
-                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            return false;
         }
 
         return result.Succeeded();
@@ -1164,8 +1027,7 @@ public:
                               bool &word_complete,
                               StringList &matches)
     {
-        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-        completion_str.erase (cursor_char_position);
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
 
         // Attempting to complete variable name
         if (cursor_index < 2)
@@ -1185,10 +1047,9 @@ protected:
     virtual bool
     DoExecute (const char *command, CommandReturnObject &result)
     {
-        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
-
+        result.SetStatus (eReturnStatusSuccessFinishNoResult);
         Args cmd_args(command);
-        const int argc = cmd_args.GetArgumentCount ();
+        const size_t argc = cmd_args.GetArgumentCount ();
 
         if (argc < 2)
         {
@@ -1198,7 +1059,6 @@ protected:
         }
 
         const char *var_name = cmd_args.GetArgumentAtIndex (0);
-        std::string var_name_string;
         if ((var_name == NULL) || (var_name[0] == '\0'))
         {
             result.AppendError ("'settings append' command requires a valid variable name; No value supplied");
@@ -1206,36 +1066,23 @@ protected:
             return false;
         }
 
-        var_name_string = var_name;
         // Do not perform cmd_args.Shift() since StringRef is manipulating the
         // raw character string later on.
 
         // Split the raw command into var_name and value pair.
         llvm::StringRef raw_str(command);
-        llvm::StringRef var_value_str = raw_str.split(var_name).second;
-        StripLeadingSpaces(var_value_str);
-        std::string var_value_string = var_value_str.str();
+        std::string var_value_string = raw_str.split(var_name).second.str();
+        const char *var_value_cstr = Args::StripSpaces(var_value_string, true, true, false);
 
-        if (var_value_string.empty())
+        Error error(m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
+                                                                  eVarSetOperationAppend,
+                                                                  var_name,
+                                                                  var_value_cstr));
+        if (error.Fail())
         {
-            result.AppendError ("'settings append' command requires a valid variable value;"
-                                " No value supplied");
+            result.AppendError (error.AsCString());
             result.SetStatus (eReturnStatusFailed);
-        }
-        else
-        {
-            Error err = usc_sp->SetVariable (var_name_string.c_str(), 
-                                             var_value_string.c_str(), 
-                                             eVarSetOperationAppend, 
-                                             true, 
-                                             m_interpreter.GetDebugger().GetInstanceName().AsCString());
-            if (err.Fail ())
-            {
-                result.AppendError (err.AsCString());
-                result.SetStatus (eReturnStatusFailed);
-            }
-            else
-                result.SetStatus (eReturnStatusSuccessFinishNoResult);
+            return false;
         }
 
         return result.Succeeded();
@@ -1282,8 +1129,7 @@ public:
                               bool &word_complete,
                               StringList &matches)
     {
-        std::string completion_str (input.GetArgumentAtIndex (cursor_index));
-        completion_str.erase (cursor_char_position);
+        std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position);
 
         // Attempting to complete variable name
         if (cursor_index < 2)
@@ -1303,9 +1149,8 @@ protected:
     virtual bool
     DoExecute (Args& command, CommandReturnObject &result)
     {
-        UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
-
-        const int argc = command.GetArgumentCount ();
+        result.SetStatus (eReturnStatusSuccessFinishNoResult);
+        const size_t argc = command.GetArgumentCount ();
 
         if (argc != 1)
         {
@@ -1321,20 +1166,17 @@ protected:
             result.SetStatus (eReturnStatusFailed);
             return false;
         }
-
-        Error err = usc_sp->SetVariable (var_name, 
-                                         NULL, 
-                                         eVarSetOperationClear, 
-                                         false, 
-                                         m_interpreter.GetDebugger().GetInstanceName().AsCString());
-
-        if (err.Fail ())
+        
+        Error error (m_interpreter.GetDebugger().SetPropertyValue (&m_exe_ctx,
+                                                                   eVarSetOperationClear,
+                                                                   var_name,
+                                                                   NULL));
+        if (error.Fail())
         {
-            result.AppendError (err.AsCString());
+            result.AppendError (error.AsCString());
             result.SetStatus (eReturnStatusFailed);
+            return false;
         }
-        else
-            result.SetStatus (eReturnStatusSuccessFinishNoResult);
 
         return result.Succeeded();
     }

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectSource.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectSource.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectSource.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectSource.h"
 
 // C Includes
@@ -16,10 +18,14 @@
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/FileLineResolver.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/SourceManager.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Host/FileSpec.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/Function.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/TargetList.h"
 #include "lldb/Interpreter/CommandCompletions.h"
@@ -51,7 +57,7 @@ class CommandObjectSourceInfo : public C
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            const char short_option = g_option_table[option_idx].short_option;
+            const int short_option = g_option_table[option_idx].short_option;
             switch (short_option)
             {
             case 'l':
@@ -159,7 +165,7 @@ class CommandObjectSourceList : public C
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            const char short_option = g_option_table[option_idx].short_option;
+            const int short_option = g_option_table[option_idx].short_option;
             switch (short_option)
             {
             case 'l':
@@ -182,6 +188,12 @@ class CommandObjectSourceList : public C
                 symbol_name = option_arg;
                 break;
 
+            case 'a':
+                {
+                    ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+                    address = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
+                }
+                break;
             case 's':
                 modules.push_back (std::string (option_arg));
                 break;
@@ -189,6 +201,9 @@ class CommandObjectSourceList : public C
             case 'b':
                 show_bp_locs = true;
                 break;
+            case 'r':
+                reverse = true;
+                break;
            default:
                 error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option);
                 break;
@@ -203,9 +218,11 @@ class CommandObjectSourceList : public C
             file_spec.Clear();
             file_name.clear();
             symbol_name.clear();
+            address = LLDB_INVALID_ADDRESS;
             start_line = 0;
-            num_lines = 10;
+            num_lines = 0;
             show_bp_locs = false;
+            reverse = false;
             modules.clear();
         }
 
@@ -220,10 +237,12 @@ class CommandObjectSourceList : public C
         FileSpec file_spec;
         std::string file_name;
         std::string symbol_name;
+        lldb::addr_t address;
         uint32_t start_line;
         uint32_t num_lines;
         STLStringArray modules;        
         bool show_bp_locs;
+        bool reverse;
     };
  
 public:   
@@ -231,21 +250,10 @@ public:
         CommandObjectParsed (interpreter,
                              "source list",
                              "Display source code (as specified) based on the current executable's debug info.",
-                             NULL),
+                             NULL,
+                             eFlagRequiresTarget), 
         m_options (interpreter)
     {
-        CommandArgumentEntry arg;
-        CommandArgumentData file_arg;
-        
-        // Define the first (and only) variant of this arg.
-        file_arg.arg_type = eArgTypeFilename;
-        file_arg.arg_repetition = eArgRepeatOptional;
-        
-        // There is only one variant this argument could be; put it into the argument entry.
-        arg.push_back (file_arg);
-        
-        // Push the data for the first argument into the m_arguments vector.
-        m_arguments.push_back (arg);
     }
 
     ~CommandObjectSourceList ()
@@ -262,49 +270,207 @@ public:
     virtual const char *
     GetRepeatCommand (Args &current_command_args, uint32_t index)
     {
-        return m_cmd_name.c_str();
+        // This is kind of gross, but the command hasn't been parsed yet so we can't look at the option
+        // values for this invocation...  I have to scan the arguments directly.
+        size_t num_args = current_command_args.GetArgumentCount();
+        bool is_reverse = false;
+        for (size_t i = 0 ; i < num_args; i++)
+        {
+            const char *arg = current_command_args.GetArgumentAtIndex(i);
+            if (arg && (strcmp(arg, "-r") == 0 || strcmp(arg, "--reverse") == 0))
+            {
+                is_reverse = true;
+            }
+        }
+        if (is_reverse)
+        {
+            if (m_reverse_name.empty())
+            {
+                m_reverse_name = m_cmd_name;
+                m_reverse_name.append (" -r");
+            }
+            return m_reverse_name.c_str();
+        }
+        else
+            return m_cmd_name.c_str();
     }
 
 protected:
-    bool
-    DoExecute (Args& command, CommandReturnObject &result)
-    {
-        const int argc = command.GetArgumentCount();
 
-        if (argc != 0)
+    struct SourceInfo
+    {
+        ConstString function;
+        LineEntry line_entry;
+        
+        SourceInfo (const ConstString &name, const LineEntry &line_entry) :
+            function(name),
+            line_entry(line_entry)
         {
-            result.AppendErrorWithFormat("'%s' takes no arguments, only flags.\n", GetCommandName());
-            result.SetStatus (eReturnStatusFailed);
+        }
+        
+        SourceInfo () :
+            function(),
+            line_entry()
+        {
+        }
+        
+        bool
+        IsValid () const
+        {
+            return (bool)function && line_entry.IsValid();
+        }
+        
+        bool
+        operator == (const SourceInfo &rhs) const
+        {
+            return function == rhs.function &&
+            line_entry.file == rhs.line_entry.file &&
+            line_entry.line == rhs.line_entry.line;
+        }
+        
+        bool
+        operator != (const SourceInfo &rhs) const
+        {
+            return function != rhs.function ||
+            line_entry.file != rhs.line_entry.file ||
+            line_entry.line != rhs.line_entry.line;
+        }
+        
+        bool
+        operator < (const SourceInfo &rhs) const
+        {
+            if (function.GetCString() < rhs.function.GetCString())
+                return true;
+            if (line_entry.file.GetDirectory().GetCString() < rhs.line_entry.file.GetDirectory().GetCString())
+                return true;
+            if (line_entry.file.GetFilename().GetCString() < rhs.line_entry.file.GetFilename().GetCString())
+                return true;
+            if (line_entry.line < rhs.line_entry.line)
+                return true;
             return false;
         }
+    };
+
+    size_t
+    DisplayFunctionSource (const SymbolContext &sc,
+                           SourceInfo &source_info,
+                           CommandReturnObject &result)
+    {
+        if (!source_info.IsValid())
+        {
+            source_info.function = sc.GetFunctionName();
+            source_info.line_entry = sc.GetFunctionStartLineEntry();
+        }
+    
+        if (sc.function)
+        {
+            Target *target = m_exe_ctx.GetTargetPtr();
+
+            FileSpec start_file;
+            uint32_t start_line;
+            uint32_t end_line;
+            FileSpec end_file;
+            
+            if (sc.block == NULL)
+            {
+                // Not an inlined function
+                sc.function->GetStartLineSourceInfo (start_file, start_line);
+                if (start_line == 0)
+                {
+                    result.AppendErrorWithFormat("Could not find line information for start of function: \"%s\".\n", source_info.function.GetCString());
+                    result.SetStatus (eReturnStatusFailed);
+                    return 0;
+                }
+                sc.function->GetEndLineSourceInfo (end_file, end_line);
+            }
+            else
+            {
+                // We have an inlined function
+                start_file = source_info.line_entry.file;
+                start_line = source_info.line_entry.line;
+                end_line = start_line + m_options.num_lines;
+            }
 
-        ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-        Target *target = exe_ctx.GetTargetPtr();
+            // This is a little hacky, but the first line table entry for a function points to the "{" that
+            // starts the function block.  It would be nice to actually get the function
+            // declaration in there too.  So back up a bit, but not further than what you're going to display.
+            uint32_t extra_lines;
+            if (m_options.num_lines >= 10)
+                extra_lines = 5;
+            else
+                extra_lines = m_options.num_lines/2;
+            uint32_t line_no;
+            if (start_line <= extra_lines)
+                line_no = 1;
+            else
+                line_no = start_line - extra_lines;
+            
+            // For fun, if the function is shorter than the number of lines we're supposed to display,
+            // only display the function...
+            if (end_line != 0)
+            {
+                if (m_options.num_lines > end_line - line_no)
+                    m_options.num_lines = end_line - line_no + extra_lines;
+            }
+            
+            m_breakpoint_locations.Clear();
 
-        if (target == NULL)
-            target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+            if (m_options.show_bp_locs)
+            {
+                const bool show_inlines = true;
+                m_breakpoint_locations.Reset (start_file, 0, show_inlines);
+                SearchFilter target_search_filter (m_exe_ctx.GetTargetSP());
+                target_search_filter.Search (m_breakpoint_locations);
+            }
             
-        if (target == NULL)
+            result.AppendMessageWithFormat("File: %s\n", start_file.GetPath().c_str());
+            return target->GetSourceManager().DisplaySourceLinesWithLineNumbers (start_file,
+                                                                                 line_no,
+                                                                                 0,
+                                                                                 m_options.num_lines,
+                                                                                 "",
+                                                                                 &result.GetOutputStream(),
+                                                                                 GetBreakpointLocations ());
+        }
+        else
+        {
+            result.AppendErrorWithFormat("Could not find function info for: \"%s\".\n", m_options.symbol_name.c_str());
+        }
+        return 0;
+    }
+
+    bool
+    DoExecute (Args& command, CommandReturnObject &result)
+    {
+        const size_t argc = command.GetArgumentCount();
+
+        if (argc != 0)
         {
-            result.AppendError ("invalid target, create a debug target using the 'target create' command");
+            result.AppendErrorWithFormat("'%s' takes no arguments, only flags.\n", GetCommandName());
             result.SetStatus (eReturnStatusFailed);
             return false;
         }
 
+        Target *target = m_exe_ctx.GetTargetPtr();
+
+        SymbolContextList sc_list;
         if (!m_options.symbol_name.empty())
         {
             // Displaying the source for a symbol:
-            SymbolContextList sc_list;
             ConstString name(m_options.symbol_name.c_str());
             bool include_symbols = false;
             bool include_inlines = true;
             bool append = true;
             size_t num_matches = 0;
             
-            if (m_options.modules.size() > 0)
+            if (m_options.num_lines == 0)
+                m_options.num_lines = 10;
+
+            const size_t num_modules = m_options.modules.size();
+            if (num_modules > 0)
             {
                 ModuleList matching_modules;
-                for (unsigned i = 0, e = m_options.modules.size(); i != e; i++)
+                for (size_t i = 0; i < num_modules; ++i)
                 {
                     FileSpec module_file_spec(m_options.modules[i].c_str(), false);
                     if (module_file_spec)
@@ -330,120 +496,153 @@ protected:
                 return false;
             }
             
-            sc_list.GetContextAtIndex (0, sc);
-            FileSpec start_file;
-            uint32_t start_line;
-            uint32_t end_line;
-            FileSpec end_file;
-            if (sc.function != NULL)
+            if (num_matches > 1)
             {
-                sc.function->GetStartLineSourceInfo (start_file, start_line);
-                if (start_line == 0)
+                std::set<SourceInfo> source_match_set;
+                
+                bool displayed_something = false;
+                for (size_t i = 0; i < num_matches; i++)
                 {
-                    result.AppendErrorWithFormat("Could not find line information for start of function: \"%s\".\n", m_options.symbol_name.c_str());
-                    result.SetStatus (eReturnStatusFailed);
-                    return false;
+                    sc_list.GetContextAtIndex (i, sc);
+                    SourceInfo source_info (sc.GetFunctionName(),
+                                            sc.GetFunctionStartLineEntry());
+                    
+                    if (source_info.IsValid())
+                    {
+                        if (source_match_set.find(source_info) == source_match_set.end())
+                        {
+                            source_match_set.insert(source_info);
+                            if (DisplayFunctionSource (sc, source_info, result))
+                                displayed_something = true;
+                        }
+                    }
                 }
-                sc.function->GetEndLineSourceInfo (end_file, end_line);
+                
+                if (displayed_something)
+                    result.SetStatus (eReturnStatusSuccessFinishResult);
+                else
+                    result.SetStatus (eReturnStatusFailed);
             }
             else
             {
-                result.AppendErrorWithFormat("Could not find function info for: \"%s\".\n", m_options.symbol_name.c_str());
-                result.SetStatus (eReturnStatusFailed);
-                return false;
+                sc_list.GetContextAtIndex (0, sc);
+                SourceInfo source_info;
+                
+                if (DisplayFunctionSource (sc, source_info, result))
+                {
+                    result.SetStatus (eReturnStatusSuccessFinishResult);
+                }
+                else
+                {
+                    result.SetStatus (eReturnStatusFailed);
+                }
             }
+            return result.Succeeded();
+        }
+        else if (m_options.address != LLDB_INVALID_ADDRESS)
+        {
+            SymbolContext sc;
+            Address so_addr;
+            StreamString error_strm;
 
-            if (num_matches > 1)
+            if (target->GetSectionLoadList().IsEmpty())
             {
-                // This could either be because there are multiple functions of this name, in which case
-                // we'll have to specify this further...  Or it could be because there are multiple inlined instances
-                // of one function.  So run through the matches and if they all have the same file & line then we can just
-                // list one.
-                
-                bool found_multiple = false;
-                
-                for (size_t i = 1; i < num_matches; i++)
+                // The target isn't loaded yet, we need to lookup the file address
+                // in all modules
+                const ModuleList &module_list = target->GetImages();
+                const size_t num_modules = module_list.GetSize();
+                for (size_t i=0; i<num_modules; ++i)
                 {
-                    SymbolContext scratch_sc;
-                    sc_list.GetContextAtIndex (i, scratch_sc);
-                    if (scratch_sc.function != NULL)
+                    ModuleSP module_sp (module_list.GetModuleAtIndex(i));
+                    if (module_sp && module_sp->ResolveFileAddress(m_options.address, so_addr))
                     {
-                        FileSpec scratch_file;
-                        uint32_t scratch_line;
-                        scratch_sc.function->GetStartLineSourceInfo (scratch_file, scratch_line);
-                        if (scratch_file != start_file 
-                            || scratch_line != start_line)
-                        {
-                            found_multiple = true;
-                            break;
-                        }
+                        sc.Clear(true);
+                        if (module_sp->ResolveSymbolContextForAddress (so_addr, eSymbolContextEverything, sc) & eSymbolContextLineEntry)
+                            sc_list.Append(sc);
                     }
                 }
-                if (found_multiple)
+                
+                if (sc_list.GetSize() == 0)
+                {
+                    result.AppendErrorWithFormat("no modules have source information for file address 0x%" PRIx64 ".\n",
+                                                 m_options.address);
+                    result.SetStatus (eReturnStatusFailed);
+                    return false;
+                }
+            }
+            else
+            {
+                // The target has some things loaded, resolve this address to a
+                // compile unit + file + line and display
+                if (target->GetSectionLoadList().ResolveLoadAddress (m_options.address, so_addr))
                 {
-                    StreamString s;
-                    for (size_t i = 0; i < num_matches; i++)
+                    ModuleSP module_sp (so_addr.GetModule());
+                    if (module_sp)
                     {
-                        SymbolContext scratch_sc;
-                        sc_list.GetContextAtIndex (i, scratch_sc);
-                        if (scratch_sc.function != NULL)
+                        sc.Clear(true);
+                        if (module_sp->ResolveSymbolContextForAddress (so_addr, eSymbolContextEverything, sc) & eSymbolContextLineEntry)
                         {
-                            s.Printf("\n%lu: ", i); 
-                            scratch_sc.function->Dump (&s, true);
+                            sc_list.Append(sc);
+                        }
+                        else
+                        {
+                            so_addr.Dump(&error_strm, NULL, Address::DumpStyleModuleWithFileAddress);
+                            result.AppendErrorWithFormat("address resolves to %s, but there is no line table information available for this address.\n",
+                                                         error_strm.GetData());
+                            result.SetStatus (eReturnStatusFailed);
+                            return false;
                         }
                     }
-                    result.AppendErrorWithFormat("Multiple functions found matching: %s: \n%s\n", 
-                                                 m_options.symbol_name.c_str(),
-                                                 s.GetData());
+                }
+
+                if (sc_list.GetSize() == 0)
+                {
+                    result.AppendErrorWithFormat("no modules contain load address 0x%" PRIx64 ".\n", m_options.address);
                     result.SetStatus (eReturnStatusFailed);
                     return false;
                 }
             }
-            
-                
-            // This is a little hacky, but the first line table entry for a function points to the "{" that 
-            // starts the function block.  It would be nice to actually get the function
-            // declaration in there too.  So back up a bit, but not further than what you're going to display.
-            size_t lines_to_back_up = m_options.num_lines >= 10 ? 5 : m_options.num_lines/2;
-            uint32_t line_no;
-            if (start_line <= lines_to_back_up)
-                line_no = 1;
-            else
-                line_no = start_line - lines_to_back_up;
-                
-            // For fun, if the function is shorter than the number of lines we're supposed to display, 
-            // only display the function...
-            if (end_line != 0)
-            {
-                if (m_options.num_lines > end_line - line_no)
-                    m_options.num_lines = end_line - line_no;
-            }
-            
-            char path_buf[PATH_MAX];
-            start_file.GetPath(path_buf, sizeof(path_buf));
-            
-            if (m_options.show_bp_locs)
+            uint32_t num_matches = sc_list.GetSize();
+            for (uint32_t i=0; i<num_matches; ++i)
             {
-                const bool show_inlines = true;
-                m_breakpoint_locations.Reset (start_file, 0, show_inlines);
-                SearchFilter target_search_filter (exe_ctx.GetTargetSP());
-                target_search_filter.Search (m_breakpoint_locations);
-            }
-            else
-                m_breakpoint_locations.Clear();
-
-            result.AppendMessageWithFormat("File: %s.\n", path_buf);
-            target->GetSourceManager().DisplaySourceLinesWithLineNumbers (start_file,
-                                                                          line_no,
-                                                                          0,
-                                                                          m_options.num_lines,
-                                                                          "",
-                                                                          &result.GetOutputStream(),
-                                                                          GetBreakpointLocations ());
-            
-            result.SetStatus (eReturnStatusSuccessFinishResult);
-            return true;
+                sc_list.GetContextAtIndex(i, sc);
+                if (sc.comp_unit)
+                {
+                    if (m_options.show_bp_locs)
+                    {
+                        m_breakpoint_locations.Clear();
+                        const bool show_inlines = true;
+                        m_breakpoint_locations.Reset (*sc.comp_unit, 0, show_inlines);
+                        SearchFilter target_search_filter (target->shared_from_this());
+                        target_search_filter.Search (m_breakpoint_locations);
+                    }
+                    
+                    bool show_fullpaths = true;
+                    bool show_module = true;
+                    bool show_inlined_frames = true;
+                    sc.DumpStopContext(&result.GetOutputStream(),
+                                       m_exe_ctx.GetBestExecutionContextScope(),
+                                       sc.line_entry.range.GetBaseAddress(),
+                                       show_fullpaths,
+                                       show_module,
+                                       show_inlined_frames);
+                    result.GetOutputStream().EOL();
+
+                    if (m_options.num_lines == 0)
+                        m_options.num_lines = 10;
+                    
+                    size_t lines_to_back_up = m_options.num_lines >= 10 ? 5 : m_options.num_lines/2;
 
+                    target->GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.comp_unit,
+                                                                                  sc.line_entry.line,
+                                                                                  lines_to_back_up,
+                                                                                  m_options.num_lines - lines_to_back_up,
+                                                                                  "->",
+                                                                                  &result.GetOutputStream(),
+                                                                                  GetBreakpointLocations ());
+                    result.SetStatus (eReturnStatusSuccessFinishResult);
+                }
+            }
         }
         else if (m_options.file_name.empty())
         {
@@ -454,13 +653,18 @@ protected:
             if (m_options.start_line == 0)
             {
                 if (target->GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream(),
-                                                                                               GetBreakpointLocations ()))
+                                                                           m_options.num_lines,
+                                                                           m_options.reverse,
+                                                                           GetBreakpointLocations ()))
                 {
                     result.SetStatus (eReturnStatusSuccessFinishResult);
                 }
             }
             else
             {
+                if (m_options.num_lines == 0)
+                    m_options.num_lines = 10;
+
                 if (m_options.show_bp_locs)
                 {
                     SourceManager::FileSP last_file_sp (target->GetSourceManager().GetLastFile ());
@@ -477,8 +681,8 @@ protected:
 
                 if (target->GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile(
                             m_options.start_line,   // Line to display
-                            0,                      // Lines before line to display
-                            m_options.num_lines,    // Lines after line to display
+                            m_options.num_lines,    // Lines after line to
+                            UINT32_MAX,             // Don't mark "line"
                             "",                     // Don't mark "line"
                             &result.GetOutputStream(),
                             GetBreakpointLocations ()))
@@ -499,7 +703,7 @@ protected:
             if (m_options.modules.size() > 0)
             {
                 ModuleList matching_modules;
-                for (unsigned i = 0, e = m_options.modules.size(); i != e; i++)
+                for (size_t i = 0, e = m_options.modules.size(); i < e; ++i)
                 {
                     FileSpec module_file_spec(m_options.modules[i].c_str(), false);
                     if (module_file_spec)
@@ -577,6 +781,9 @@ protected:
                     else
                         m_breakpoint_locations.Clear();
 
+                    if (m_options.num_lines == 0)
+                        m_options.num_lines = 10;
+                    
                     target->GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.comp_unit,
                                                                                   m_options.start_line,
                                                                                   0,
@@ -608,18 +815,22 @@ protected:
     }
     CommandOptions m_options;
     FileLineResolver m_breakpoint_locations;
+    std::string    m_reverse_name;
 
 };
 
 OptionDefinition
 CommandObjectSourceList::CommandOptions::g_option_table[] =
 {
-{ LLDB_OPT_SET_ALL, false, "count",    'c', required_argument, NULL, 0, eArgTypeCount,   "The number of source lines to display."},
-{ LLDB_OPT_SET_ALL, false, "shlib",    's', required_argument, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Look up the source file in the given shared library."},
+{ LLDB_OPT_SET_ALL, false, "count",  'c', required_argument, NULL, 0, eArgTypeCount,   "The number of source lines to display."},
+{ LLDB_OPT_SET_1  |
+  LLDB_OPT_SET_2  , false, "shlib",  's', required_argument, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Look up the source file in the given shared library."},
 { LLDB_OPT_SET_ALL, false, "show-breakpoints", 'b', no_argument, NULL, 0, eArgTypeNone, "Show the line table locations from the debug information that indicate valid places to set source level breakpoints."},
-{ LLDB_OPT_SET_1, false, "file",       'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,    "The file from which to display source."},
-{ LLDB_OPT_SET_1, false, "line",       'l', required_argument, NULL, 0, eArgTypeLineNum,    "The line number at which to start the display source."},
-{ LLDB_OPT_SET_2, false, "name",       'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeSymbol,    "The name of a function whose source to display."},
+{ LLDB_OPT_SET_1  , false, "file",   'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,    "The file from which to display source."},
+{ LLDB_OPT_SET_1  , false, "line",   'l', required_argument, NULL, 0, eArgTypeLineNum,    "The line number at which to start the display source."},
+{ LLDB_OPT_SET_2  , false, "name",   'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeSymbol,    "The name of a function whose source to display."},
+{ LLDB_OPT_SET_3  , false, "address",'a', required_argument, NULL, 0, eArgTypeAddressOrExpression, "Lookup the address and display the source information for the corresponding file and line."},
+{ LLDB_OPT_SET_4, false, "reverse", 'r', no_argument, NULL, 0, eArgTypeNone, "Reverse the listing to look backwards from the last displayed block of source."},
 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 
@@ -635,7 +846,8 @@ CommandObjectMultiwordSource::CommandObj
                             "A set of commands for accessing source file information",
                             "source <subcommand> [<subcommand-options>]")
 {
-    LoadSubCommand ("info",   CommandObjectSP (new CommandObjectSourceInfo (interpreter)));
+    // "source info" isn't implemented yet...
+    //LoadSubCommand ("info",   CommandObjectSP (new CommandObjectSourceInfo (interpreter)));
     LoadSubCommand ("list",   CommandObjectSP (new CommandObjectSourceList (interpreter)));
 }
 

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectSyntax.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectSyntax.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectSyntax.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectSyntax.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectSyntax.h"
 
 // C Includes
@@ -57,7 +59,7 @@ CommandObjectSyntax::DoExecute (Args& co
 {
     CommandObject::CommandMap::iterator pos;
     CommandObject *cmd_obj;
-    const int argc = command.GetArgumentCount();
+    const size_t argc = command.GetArgumentCount();
 
     if (argc > 0)
     {
@@ -66,14 +68,12 @@ CommandObjectSyntax::DoExecute (Args& co
         for (int i = 1; i < argc; ++i)
         {
             std::string sub_command = command.GetArgumentAtIndex (i);
-            if (! cmd_obj->IsMultiwordObject())
+            if (!cmd_obj->IsMultiwordObject())
                 all_okay = false;
             else
             {
-                pos = ((CommandObjectMultiword *) cmd_obj)->m_subcommand_dict.find (sub_command);
-                if (pos != ((CommandObjectMultiword *) cmd_obj)->m_subcommand_dict.end())
-                    cmd_obj = pos->second.get();
-                else
+                cmd_obj = cmd_obj->GetSubcommandObject(sub_command.c_str());
+                if (!cmd_obj)
                     all_okay = false;
             }
         }

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectTarget.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectTarget.h"
 
 // C Includes
@@ -18,10 +20,13 @@
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/InputReader.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Core/State.h"
 #include "lldb/Core/Timer.h"
 #include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/Host/Symbols.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/Options.h"
@@ -34,6 +39,7 @@
 #include "lldb/Interpreter/OptionGroupUInt64.h"
 #include "lldb/Interpreter/OptionGroupUUID.h"
 #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
+#include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/FuncUnwinders.h"
 #include "lldb/Symbol/LineTable.h"
 #include "lldb/Symbol/ObjectFile.h"
@@ -75,7 +81,7 @@ DumpTargetInfo (uint32_t target_idx, Tar
     }
     PlatformSP platform_sp (target->GetPlatform());
     if (platform_sp)
-        strm.Printf ("%splatform=%s", properties++ > 0 ? ", " : " ( ", platform_sp->GetName());
+        strm.Printf ("%splatform=%s", properties++ > 0 ? ", " : " ( ", platform_sp->GetName().GetCString());
     
     ProcessSP process_sp (target->GetProcessSP());
     bool show_process_status = false;
@@ -87,7 +93,7 @@ DumpTargetInfo (uint32_t target_idx, Tar
             show_process_status = StateIsStoppedState(state, true);
         const char *state_cstr = StateAsCString (state);
         if (pid != LLDB_INVALID_PROCESS_ID)
-            strm.Printf ("%spid=%llu", properties++ > 0 ? ", " : " ( ", pid);
+            strm.Printf ("%spid=%" PRIu64, properties++ > 0 ? ", " : " ( ", pid);
         strm.Printf ("%sstate=%s", properties++ > 0 ? ", " : " ( ", state_cstr);
     }
     if (properties > 0)
@@ -151,8 +157,10 @@ public:
         m_option_group (interpreter),
         m_arch_option (),
         m_platform_options(true), // Do include the "--platform" option in the platform settings by passing true
-        m_core_file (LLDB_OPT_SET_1, false, "core-file", 'c', 0, eArgTypePath, "Fullpath to a core file to use for this target."),
-        m_platform_path (LLDB_OPT_SET_1, false, "platform-path", 'P', 0, eArgTypePath, "Path to the remote file to use for this target.")
+        m_core_file (LLDB_OPT_SET_1, false, "core", 'c', 0, eArgTypeFilename, "Fullpath to a core file to use for this target."),
+        m_platform_path (LLDB_OPT_SET_1, false, "platform-path", 'P', 0, eArgTypePath, "Path to the remote file to use for this target."),
+        m_symbol_file (LLDB_OPT_SET_1, false, "symfile", 's', 0, eArgTypeFilename, "Fullpath to a stand alone debug symbols file for when debug symbols are not in the executable."),
+        m_add_dependents (LLDB_OPT_SET_1, false, "no-dependents", 'd', "Don't load dependent files when creating the target, just add the specified executable.", true, true)
     {
         CommandArgumentEntry arg;
         CommandArgumentData file_arg;
@@ -171,6 +179,8 @@ public:
         m_option_group.Append (&m_platform_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
         m_option_group.Append (&m_core_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
         m_option_group.Append (&m_platform_path, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+        m_option_group.Append (&m_symbol_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+        m_option_group.Append (&m_add_dependents, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
         m_option_group.Finalize();
     }
 
@@ -184,7 +194,7 @@ public:
         return &m_option_group;
     }
 
-    int
+    virtual int
     HandleArgumentCompletion (Args &input,
                               int &cursor_index,
                               int &cursor_char_position,
@@ -212,12 +222,25 @@ protected:
     bool
     DoExecute (Args& command, CommandReturnObject &result)
     {
-        const int argc = command.GetArgumentCount();
+        const size_t argc = command.GetArgumentCount();
         FileSpec core_file (m_core_file.GetOptionValue().GetCurrentValue());
         FileSpec remote_file (m_platform_path.GetOptionValue().GetCurrentValue());
 
         if (argc == 1 || core_file || remote_file)
         {
+            FileSpec symfile (m_symbol_file.GetOptionValue().GetCurrentValue());
+            if (symfile)
+            {
+                if (!symfile.Exists())
+                {
+                    char symfile_path[PATH_MAX];
+                    symfile.GetPath(symfile_path, sizeof(symfile_path));
+                    result.AppendErrorWithFormat("invalid symbol file path '%s'", symfile_path);
+                    result.SetStatus (eReturnStatusFailed);
+                    return false;
+                }
+            }
+
             const char *file_path = command.GetArgumentAtIndex(0);
             Timer scoped_timer(__PRETTY_FUNCTION__, "(lldb) target create '%s'", file_path);
             FileSpec file_spec;
@@ -281,9 +304,10 @@ protected:
 
             TargetSP target_sp;
             const char *arch_cstr = m_arch_option.GetArchitectureName();
-            const bool get_dependent_files = true;
+            const bool get_dependent_files = m_add_dependents.GetOptionValue().GetCurrentValue();
             Error error (debugger.GetTargetList().CreateTarget (debugger,
-                                                                remote_file ? remote_file : file_spec,
+//                                                                remote_file ? remote_file : file_spec,
+                                                                file_path,
                                                                 arch_cstr,
                                                                 get_dependent_files,
                                                                 &m_platform_options,
@@ -291,6 +315,13 @@ protected:
 
             if (target_sp)
             {
+                if (symfile)
+                {
+                    ModuleSP module_sp (target_sp->GetExecutableModule());
+                    if (module_sp)
+                        module_sp->SetSymbolFileFileSpec(symfile);
+                }
+                
                 debugger.GetTargetList().SetSelectedTarget(target_sp.get());
                 if (must_set_platform_path)
                 {
@@ -368,7 +399,8 @@ private:
     OptionGroupPlatform m_platform_options;
     OptionGroupFile m_core_file;
     OptionGroupFile m_platform_path;
-
+    OptionGroupFile m_symbol_file;
+    OptionGroupBoolean m_add_dependents;
 };
 
 #pragma mark CommandObjectTargetList
@@ -511,7 +543,7 @@ public:
                              NULL,
                              0),
         m_option_group (interpreter),
-        m_cleanup_option (LLDB_OPT_SET_1, false, "clean", 'c', 0, eArgTypeNone, "Perform extra cleanup to minimize memory consumption after deleting the target.", false)
+        m_cleanup_option (LLDB_OPT_SET_1, false, "clean", 'c', "Perform extra cleanup to minimize memory consumption after deleting the target.", false, false)
     {
         m_option_group.Append (&m_cleanup_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
         m_option_group.Finalize();
@@ -636,14 +668,14 @@ public:
     CommandObjectTargetVariable (CommandInterpreter &interpreter) :
         CommandObjectParsed (interpreter,
                              "target variable",
-                             "Read global variable(s) prior to running your binary.",
+                             "Read global variable(s) prior to, or while running your binary.",
                              NULL,
-                             0),
+                             eFlagRequiresTarget),
         m_option_group (interpreter),
         m_option_variable (false), // Don't include frame options
         m_option_format (eFormatDefault),
-        m_option_compile_units    (LLDB_OPT_SET_1, false, "file", 'f', 0, eArgTypePath, "A basename or fullpath to a file that contains global variables. This option can be specified multiple times."),
-        m_option_shared_libraries (LLDB_OPT_SET_1, false, "shlib",'s', 0, eArgTypePath, "A basename or fullpath to a shared library to use in the search for global variables. This option can be specified multiple times."),
+        m_option_compile_units    (LLDB_OPT_SET_1, false, "file", 'file', 0, eArgTypeFilename, "A basename or fullpath to a file that contains global variables. This option can be specified multiple times."),
+        m_option_shared_libraries (LLDB_OPT_SET_1, false, "shlib",'shlb', 0, eArgTypeFilename, "A basename or fullpath to a shared library to use in the search for global variables. This option can be specified multiple times."),
         m_varobj_options()
     {
         CommandArgumentEntry arg;
@@ -675,19 +707,8 @@ public:
     void
     DumpValueObject (Stream &s, VariableSP &var_sp, ValueObjectSP &valobj_sp, const char *root_name)
     {
-        ValueObject::DumpValueObjectOptions options;
+        ValueObject::DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions());
         
-        options.SetMaximumPointerDepth(m_varobj_options.ptr_depth)
-               .SetMaximumDepth(m_varobj_options.max_depth)
-               .SetShowTypes(m_varobj_options.show_types)
-               .SetShowLocation(m_varobj_options.show_location)
-               .SetUseObjectiveC(m_varobj_options.use_objc)
-               .SetUseDynamicType(m_varobj_options.use_dynamic)
-               .SetUseSyntheticValue(m_varobj_options.use_synth)
-               .SetFlatOutput(m_varobj_options.flat_output)
-               .SetOmitSummaryDepth(m_varobj_options.no_summary_depth)
-               .SetIgnoreCap(m_varobj_options.ignore_cap);
-                
         switch (var_sp->GetScope())
         {
             case eValueTypeVariableGlobal:
@@ -735,9 +756,9 @@ public:
     }
     
     
-    static uint32_t GetVariableCallback (void *baton, 
-                                         const char *name,
-                                         VariableList &variable_list)
+    static size_t GetVariableCallback (void *baton,
+                                       const char *name,
+                                       VariableList &variable_list)
     {
         Target *target = static_cast<Target *>(baton);
         if (target)
@@ -759,109 +780,141 @@ public:
     }
     
 protected:
+    
+    void
+    DumpGlobalVariableList(const ExecutionContext &exe_ctx, const SymbolContext &sc, const VariableList &variable_list, Stream &s)
+    {
+        size_t count = variable_list.GetSize();
+        if (count > 0)
+        {
+            if (sc.module_sp)
+            {
+                if (sc.comp_unit)
+                {
+                    s.Printf ("Global variables for %s in %s:\n",
+                              sc.comp_unit->GetPath().c_str(),
+                              sc.module_sp->GetFileSpec().GetPath().c_str());
+                }
+                else
+                {
+                    s.Printf ("Global variables for %s\n",
+                              sc.module_sp->GetFileSpec().GetPath().c_str());
+                }
+            }
+            else if (sc.comp_unit)
+            {
+                s.Printf ("Global variables for %s\n",
+                          sc.comp_unit->GetPath().c_str());
+            }
+            
+            for (uint32_t i=0; i<count; ++i)
+            {
+                VariableSP var_sp (variable_list.GetVariableAtIndex(i));
+                if (var_sp)
+                {
+                    ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_ctx.GetBestExecutionContextScope(), var_sp));
+                    
+                    if (valobj_sp)
+                        DumpValueObject (s, var_sp, valobj_sp, var_sp->GetName().GetCString());
+                }
+            }
+        }
+
+    }
     virtual bool
     DoExecute (Args& args, CommandReturnObject &result)
     {
-        ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
-        Target *target = exe_ctx.GetTargetPtr();
-        if (target)
+        Target *target = m_exe_ctx.GetTargetPtr();
+        const size_t argc = args.GetArgumentCount();
+        Stream &s = result.GetOutputStream();
+        
+        if (argc > 0)
         {
-            const size_t argc = args.GetArgumentCount();
-            Stream &s = result.GetOutputStream();
-            if (argc > 0)
+
+            for (size_t idx = 0; idx < argc; ++idx)
             {
+                VariableList variable_list;
+                ValueObjectList valobj_list;
 
-                for (size_t idx = 0; idx < argc; ++idx)
+                const char *arg = args.GetArgumentAtIndex(idx);
+                size_t matches = 0;
+                bool use_var_name = false;
+                if (m_option_variable.use_regex)
                 {
-                    VariableList variable_list;
-                    ValueObjectList valobj_list;
-
-                    const char *arg = args.GetArgumentAtIndex(idx);
-                    uint32_t matches = 0;
-                    bool use_var_name = false;
-                    if (m_option_variable.use_regex)
+                    RegularExpression regex(arg);
+                    if (!regex.IsValid ())
                     {
-                        RegularExpression regex(arg);
-                        if (!regex.IsValid ())
-                        {
-                            result.GetErrorStream().Printf ("error: invalid regular expression: '%s'\n", arg);
-                            result.SetStatus (eReturnStatusFailed);
-                            return false;
-                        }
-                        use_var_name = true;
-                        matches = target->GetImages().FindGlobalVariables (regex,
-                                                                           true, 
-                                                                           UINT32_MAX, 
-                                                                           variable_list);
-                    }
-                    else
-                    {
-                        Error error (Variable::GetValuesForVariableExpressionPath (arg,
-                                                                                   exe_ctx.GetBestExecutionContextScope(),
-                                                                                   GetVariableCallback,
-                                                                                   target,
-                                                                                   variable_list,
-                                                                                   valobj_list));
-                        matches = variable_list.GetSize();
-                    }
-                    
-                    if (matches == 0)
-                    {
-                        result.GetErrorStream().Printf ("error: can't find global variable '%s'\n", arg);
+                        result.GetErrorStream().Printf ("error: invalid regular expression: '%s'\n", arg);
                         result.SetStatus (eReturnStatusFailed);
                         return false;
                     }
-                    else
+                    use_var_name = true;
+                    matches = target->GetImages().FindGlobalVariables (regex,
+                                                                       true, 
+                                                                       UINT32_MAX, 
+                                                                       variable_list);
+                }
+                else
+                {
+                    Error error (Variable::GetValuesForVariableExpressionPath (arg,
+                                                                               m_exe_ctx.GetBestExecutionContextScope(),
+                                                                               GetVariableCallback,
+                                                                               target,
+                                                                               variable_list,
+                                                                               valobj_list));
+                    matches = variable_list.GetSize();
+                }
+                
+                if (matches == 0)
+                {
+                    result.GetErrorStream().Printf ("error: can't find global variable '%s'\n", arg);
+                    result.SetStatus (eReturnStatusFailed);
+                    return false;
+                }
+                else
+                {
+                    for (uint32_t global_idx=0; global_idx<matches; ++global_idx)
                     {
-                        for (uint32_t global_idx=0; global_idx<matches; ++global_idx)
+                        VariableSP var_sp (variable_list.GetVariableAtIndex(global_idx));
+                        if (var_sp)
                         {
-                            VariableSP var_sp (variable_list.GetVariableAtIndex(global_idx));
-                            if (var_sp)
-                            {
-                                ValueObjectSP valobj_sp (valobj_list.GetValueObjectAtIndex(global_idx));
-                                if (!valobj_sp)
-                                    valobj_sp = ValueObjectVariable::Create (exe_ctx.GetBestExecutionContextScope(), var_sp);
-                                
-                                if (valobj_sp)
-                                    DumpValueObject (s, var_sp, valobj_sp, use_var_name ? var_sp->GetName().GetCString() : arg);
-                            }
+                            ValueObjectSP valobj_sp (valobj_list.GetValueObjectAtIndex(global_idx));
+                            if (!valobj_sp)
+                                valobj_sp = ValueObjectVariable::Create (m_exe_ctx.GetBestExecutionContextScope(), var_sp);
+                            
+                            if (valobj_sp)
+                                DumpValueObject (s, var_sp, valobj_sp, use_var_name ? var_sp->GetName().GetCString() : arg);
                         }
                     }
                 }
             }
-            else
+        }
+        else
+        {
+            const FileSpecList &compile_units = m_option_compile_units.GetOptionValue().GetCurrentValue();
+            const FileSpecList &shlibs = m_option_shared_libraries.GetOptionValue().GetCurrentValue();
+            SymbolContextList sc_list;
+            const size_t num_compile_units = compile_units.GetSize();
+            const size_t num_shlibs = shlibs.GetSize();
+            if (num_compile_units == 0 && num_shlibs == 0)
             {
                 bool success = false;
-                StackFrame *frame = exe_ctx.GetFramePtr();
+                StackFrame *frame = m_exe_ctx.GetFramePtr();
                 CompileUnit *comp_unit = NULL;
                 if (frame)
                 {
-                    comp_unit = frame->GetSymbolContext (eSymbolContextCompUnit).comp_unit;
-                    if (comp_unit)
+                    SymbolContext sc = frame->GetSymbolContext (eSymbolContextCompUnit);
+                    if (sc.comp_unit)
                     {
                         const bool can_create = true;
-                        VariableListSP comp_unit_varlist_sp (comp_unit->GetVariableList(can_create));
+                        VariableListSP comp_unit_varlist_sp (sc.comp_unit->GetVariableList(can_create));
                         if (comp_unit_varlist_sp)
                         {
                             size_t count = comp_unit_varlist_sp->GetSize();
                             if (count > 0)
                             {
-                                s.Printf ("Global variables for %s/%s:\n", 
-                                          comp_unit->GetDirectory().GetCString(),
-                                          comp_unit->GetFilename().GetCString());
-
+                                DumpGlobalVariableList(m_exe_ctx, sc, *comp_unit_varlist_sp, s);
                                 success = true;
-                                for (uint32_t i=0; i<count; ++i)
-                                {
-                                    VariableSP var_sp (comp_unit_varlist_sp->GetVariableAtIndex(i));
-                                    if (var_sp)
-                                    {
-                                        ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_ctx.GetBestExecutionContextScope(), var_sp));
-                                        
-                                        if (valobj_sp)
-                                            DumpValueObject (s, var_sp, valobj_sp, var_sp->GetName().GetCString());
-                                    }
-                                }
                             }
                         }
                     }
@@ -871,25 +924,87 @@ protected:
                     if (frame)
                     {
                         if (comp_unit)
-                            result.AppendErrorWithFormat ("no global variables in current compile unit: %s/%s\n", 
-                                                          comp_unit->GetDirectory().GetCString(), 
-                                                          comp_unit->GetFilename().GetCString());
+                            result.AppendErrorWithFormat ("no global variables in current compile unit: %s\n",
+                                                          comp_unit->GetPath().c_str());
                         else
-                            result.AppendError ("no debug information for frame %u\n", frame->GetFrameIndex());
+                            result.AppendErrorWithFormat ("no debug information for frame %u\n", frame->GetFrameIndex());
                     }                        
                     else
                         result.AppendError ("'target variable' takes one or more global variable names as arguments\n");
                     result.SetStatus (eReturnStatusFailed);
                 }
             }
+            else
+            {
+                SymbolContextList sc_list;
+                const bool append = true;
+                // We have one or more compile unit or shlib
+                if (num_shlibs > 0)
+                {
+                    for (size_t shlib_idx=0; shlib_idx<num_shlibs; ++shlib_idx)
+                    {
+                        const FileSpec module_file(shlibs.GetFileSpecAtIndex(shlib_idx));
+                        ModuleSpec module_spec (module_file);
+                        
+                        ModuleSP module_sp (target->GetImages().FindFirstModule(module_spec));
+                        if (module_sp)
+                        {
+                            if (num_compile_units > 0)
+                            {
+                                for (size_t cu_idx=0; cu_idx<num_compile_units; ++cu_idx)
+                                    module_sp->FindCompileUnits(compile_units.GetFileSpecAtIndex(cu_idx), append, sc_list);
+                            }
+                            else
+                            {
+                                SymbolContext sc;
+                                sc.module_sp = module_sp;
+                                sc_list.Append(sc);
+                            }
+                        }
+                        else
+                        {
+                            // Didn't find matching shlib/module in target...
+                            result.AppendErrorWithFormat ("target doesn't contain the specified shared library: %s\n",
+                                                          module_file.GetPath().c_str());
+                        }
+                    }
+                }
+                else
+                {
+                    // No shared libraries, we just want to find globals for the compile units files that were specified
+                    for (size_t cu_idx=0; cu_idx<num_compile_units; ++cu_idx)
+                        target->GetImages().FindCompileUnits(compile_units.GetFileSpecAtIndex(cu_idx), append, sc_list);
+                }
+                
+                const uint32_t num_scs = sc_list.GetSize();
+                if (num_scs > 0)
+                {
+                    SymbolContext sc;
+                    for (uint32_t sc_idx=0; sc_idx<num_scs; ++sc_idx)
+                    {
+                        if (sc_list.GetContextAtIndex(sc_idx, sc))
+                        {
+                            if (sc.comp_unit)
+                            {
+                                const bool can_create = true;
+                                VariableListSP comp_unit_varlist_sp (sc.comp_unit->GetVariableList(can_create));
+                                if (comp_unit_varlist_sp)
+                                    DumpGlobalVariableList(m_exe_ctx, sc, *comp_unit_varlist_sp, s);
+                            }
+                            else if (sc.module_sp)
+                            {
+                                // Get all global variables for this module
+                                lldb_private::RegularExpression all_globals_regex("."); // Any global with at least one character
+                                VariableList variable_list;
+                                sc.module_sp->FindGlobalVariables(all_globals_regex, append, UINT32_MAX, variable_list);
+                                DumpGlobalVariableList(m_exe_ctx, sc, variable_list, s);
+                            }
+                        }
+                    }
+                }
+            }
         }
-        else
-        {
-            result.AppendError ("invalid target, create a debug target using the 'target create' command");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
-        
+
         if (m_interpreter.TruncationWarningNecessary())
         {
             result.GetOutputStream().Printf(m_interpreter.TruncationWarningText(),
@@ -956,7 +1071,7 @@ protected:
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
         if (target)
         {
-            uint32_t argc = command.GetArgumentCount();
+            const size_t argc = command.GetArgumentCount();
             if (argc & 1)
             {
                 result.AppendError ("add requires an even number of arguments\n");
@@ -964,7 +1079,7 @@ protected:
             }
             else
             {
-                for (uint32_t i=0; i<argc; i+=2)
+                for (size_t i=0; i<argc; i+=2)
                 {
                     const char *from = command.GetArgumentAtIndex(i);
                     const char *to = command.GetArgumentAtIndex(i+1);
@@ -1093,7 +1208,7 @@ protected:
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
         if (target)
         {
-            uint32_t argc = command.GetArgumentCount();
+            size_t argc = command.GetArgumentCount();
             // check for at least 3 arguments and an odd nubmer of parameters
             if (argc >= 3 && argc & 1)
             {
@@ -1217,7 +1332,7 @@ public:
         CommandArgumentData path_arg;
         
         // Define the first (and only) variant of this arg.
-        path_arg.arg_type = eArgTypePath;
+        path_arg.arg_type = eArgTypeDirectoryName;
         path_arg.arg_repetition = eArgRepeatPlain;
         
         // There is only one variant this argument could be; put it into the argument entry.
@@ -1287,21 +1402,18 @@ DumpModuleArchitecture (Stream &strm, Mo
 static void
 DumpModuleUUID (Stream &strm, Module *module)
 {
-    if (module->GetUUID().IsValid())
+    if (module && module->GetUUID().IsValid())
         module->GetUUID().Dump (&strm);
     else
         strm.PutCString("                                    ");
 }
 
 static uint32_t
-DumpCompileUnitLineTable
-(
- CommandInterpreter &interpreter,
- Stream &strm,
- Module *module,
- const FileSpec &file_spec,
- bool load_addresses
- )
+DumpCompileUnitLineTable (CommandInterpreter &interpreter,
+                          Stream &strm,
+                          Module *module,
+                          const FileSpec &file_spec,
+                          bool load_addresses)
 {
     uint32_t num_matches = 0;
     if (module)
@@ -1343,12 +1455,9 @@ DumpFullpath (Stream &strm, const FileSp
     {
         if (width > 0)
         {
-            char fullpath[PATH_MAX];
-            if (file_spec_ptr->GetPath(fullpath, sizeof(fullpath)))
-            {
-                strm.Printf("%-*s", width, fullpath);
-                return;
-            }
+            std::string fullpath = file_spec_ptr->GetPath();
+            strm.Printf("%-*s", width, fullpath.c_str());
+            return;
         }
         else
         {
@@ -1420,11 +1529,9 @@ DumpModuleSections (CommandInterpreter &
             SectionList *section_list = objfile->GetSectionList();
             if (section_list)
             {
-                strm.PutCString ("Sections for '");
-                strm << module->GetFileSpec();
-                if (module->GetObjectName())
-                    strm << '(' << module->GetObjectName() << ')';
-                strm.Printf ("' (%s):\n", module->GetArchitecture().GetArchitectureName());
+                strm.Printf ("Sections for '%s' (%s):\n",
+                             module->GetSpecificationDescription().c_str(),
+                             module->GetArchitecture().GetArchitectureName());
                 strm.IndentMore();
                 section_list->Dump(&strm, interpreter.GetExecutionContext().GetTargetPtr(), true, UINT32_MAX);
                 strm.IndentLess();
@@ -1610,7 +1717,7 @@ DumpSymbolContextList (ExecutionContextS
     strm.IndentLess ();
 }
 
-static uint32_t
+static size_t
 LookupFunctionInModule (CommandInterpreter &interpreter,
                         Stream &strm,
                         Module *module,
@@ -1624,7 +1731,7 @@ LookupFunctionInModule (CommandInterpret
     {
         SymbolContextList sc_list;
         const bool append = true;
-        uint32_t num_matches = 0;
+        size_t num_matches = 0;
         if (name_is_regex)
         {
             RegularExpression function_name_regex (name);
@@ -1639,7 +1746,7 @@ LookupFunctionInModule (CommandInterpret
             ConstString function_name (name);
             num_matches = module->FindFunctions (function_name,
                                                  NULL,
-                                                 eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeMethod | eFunctionNameTypeSelector, 
+                                                 eFunctionNameTypeAuto,
                                                  include_symbols,
                                                  include_inlines, 
                                                  append, 
@@ -1649,7 +1756,7 @@ LookupFunctionInModule (CommandInterpret
         if (num_matches)
         {
             strm.Indent ();
-            strm.Printf("%u match%s found in ", num_matches, num_matches > 1 ? "es" : "");
+            strm.Printf("%zu match%s found in ", num_matches, num_matches > 1 ? "es" : "");
             DumpFullpath (strm, &module->GetFileSpec(), 0);
             strm.PutCString(":\n");
             DumpSymbolContextList (interpreter.GetExecutionContext().GetBestExecutionContextScope(), strm, sc_list, verbose);
@@ -1659,7 +1766,7 @@ LookupFunctionInModule (CommandInterpret
     return 0;
 }
 
-static uint32_t
+static size_t
 LookupTypeInModule (CommandInterpreter &interpreter,
                     Stream &strm, 
                     Module *module, 
@@ -1670,7 +1777,7 @@ LookupTypeInModule (CommandInterpreter &
     {
         TypeList type_list;
         const uint32_t max_num_matches = UINT32_MAX;
-        uint32_t num_matches = 0;
+        size_t num_matches = 0;
         bool name_is_fully_qualified = false;
         SymbolContext sc;
 
@@ -1680,7 +1787,7 @@ LookupTypeInModule (CommandInterpreter &
         if (num_matches)
         {
             strm.Indent ();
-            strm.Printf("%u match%s found in ", num_matches, num_matches > 1 ? "es" : "");
+            strm.Printf("%zu match%s found in ", num_matches, num_matches > 1 ? "es" : "");
             DumpFullpath (strm, &module->GetFileSpec(), 0);
             strm.PutCString(":\n");
             const uint32_t num_types = type_list.GetSize();
@@ -1714,7 +1821,7 @@ LookupTypeInModule (CommandInterpreter &
     return 0;
 }
 
-static uint32_t
+static size_t
 LookupTypeHere (CommandInterpreter &interpreter,
                 Stream &strm,
                 const SymbolContext &sym_ctx,
@@ -1726,7 +1833,7 @@ LookupTypeHere (CommandInterpreter &inte
     
     TypeList type_list;
     const uint32_t max_num_matches = UINT32_MAX;
-    uint32_t num_matches = 1;
+    size_t num_matches = 1;
     bool name_is_fully_qualified = false;
     
     ConstString name(name_cstr);
@@ -1813,9 +1920,9 @@ FindModulesByName (Target *target,
     {
         // Check the global list
         Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex());
-        const uint32_t num_modules = Module::GetNumberAllocatedModules();
+        const size_t num_modules = Module::GetNumberAllocatedModules();
         ModuleSP module_sp;
-        for (uint32_t image_idx = 0; image_idx<num_modules; ++image_idx)
+        for (size_t image_idx = 0; image_idx<num_modules; ++image_idx)
         {
             Module *module = Module::GetAllocatedModuleAtIndex(image_idx);
             
@@ -1927,10 +2034,11 @@ class CommandObjectTargetModulesSourceFi
 public:
     
     CommandObjectTargetModulesSourceFileAutoComplete (CommandInterpreter &interpreter,
-                                          const char *name,
-                                          const char *help,
-                                          const char *syntax) :
-        CommandObjectParsed (interpreter, name, help, syntax)
+                                                      const char *name,
+                                                      const char *help,
+                                                      const char *syntax,
+                                                      uint32_t flags) :
+        CommandObjectParsed (interpreter, name, help, syntax, flags)
     {
         CommandArgumentEntry arg;
         CommandArgumentData source_file_arg;
@@ -2023,7 +2131,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
@@ -2084,11 +2192,11 @@ protected:
             {
                 // Dump all sections for all modules images
                 Mutex::Locker modules_locker(target->GetImages().GetMutex());
-                const uint32_t num_modules = target->GetImages().GetSize();
+                const size_t num_modules = target->GetImages().GetSize();
                 if (num_modules > 0)
                 {
-                    result.GetOutputStream().Printf("Dumping symbol table for %u modules.\n", num_modules);
-                    for (uint32_t image_idx = 0;  image_idx<num_modules; ++image_idx)
+                    result.GetOutputStream().Printf("Dumping symbol table for %zu modules.\n", num_modules);
+                    for (size_t image_idx = 0; image_idx<num_modules; ++image_idx)
                     {
                         if (num_dumped > 0)
                         {
@@ -2217,11 +2325,11 @@ protected:
             if (command.GetArgumentCount() == 0)
             {
                 // Dump all sections for all modules images
-                const uint32_t num_modules = target->GetImages().GetSize();
+                const size_t num_modules = target->GetImages().GetSize();
                 if (num_modules > 0)
                 {
-                    result.GetOutputStream().Printf("Dumping sections for %u modules.\n", num_modules);
-                    for (uint32_t image_idx = 0;  image_idx<num_modules; ++image_idx)
+                    result.GetOutputStream().Printf("Dumping sections for %zu modules.\n", num_modules);
+                    for (size_t image_idx = 0;  image_idx<num_modules; ++image_idx)
                     {
                         num_dumped++;
                         DumpModuleSections (m_interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx));
@@ -2323,12 +2431,12 @@ protected:
             if (command.GetArgumentCount() == 0)
             {
                 // Dump all sections for all modules images
-                ModuleList &target_modules = target->GetImages();
+                const ModuleList &target_modules = target->GetImages();
                 Mutex::Locker modules_locker (target_modules.GetMutex());
-                const uint32_t num_modules = target_modules.GetSize();
+                const size_t num_modules = target_modules.GetSize();
                 if (num_modules > 0)
                 {
-                    result.GetOutputStream().Printf("Dumping debug symbols for %u modules.\n", num_modules);
+                    result.GetOutputStream().Printf("Dumping debug symbols for %zu modules.\n", num_modules);
                     for (uint32_t image_idx = 0;  image_idx<num_modules; ++image_idx)
                     {
                         if (DumpModuleSymbolVendor (result.GetOutputStream(), target_modules.GetModulePointerAtIndexUnlocked(image_idx)))
@@ -2391,9 +2499,10 @@ class CommandObjectTargetModulesDumpLine
 public:
     CommandObjectTargetModulesDumpLineTable (CommandInterpreter &interpreter) :
     CommandObjectTargetModulesSourceFileAutoComplete (interpreter,
-                                          "target modules dump line-table",
-                                          "Dump the debug symbol file for one or more target modules.",
-                                          NULL)
+                                                      "target modules dump line-table",
+                                                      "Dump the debug symbol file for one or more target modules.",
+                                                      NULL,
+                                                      eFlagRequiresTarget)
     {
     }
     
@@ -2407,65 +2516,55 @@ protected:
     DoExecute (Args& command,
              CommandReturnObject &result)
     {
-        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-        if (target == NULL)
+        Target *target = m_exe_ctx.GetTargetPtr();
+        uint32_t total_num_dumped = 0;
+        
+        uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize();
+        result.GetOutputStream().SetAddressByteSize(addr_byte_size);
+        result.GetErrorStream().SetAddressByteSize(addr_byte_size);
+        
+        if (command.GetArgumentCount() == 0)
         {
-            result.AppendError ("invalid target, create a debug target using the 'target create' command");
+            result.AppendErrorWithFormat ("\nSyntax: %s\n", m_cmd_syntax.c_str());
             result.SetStatus (eReturnStatusFailed);
-            return false;
         }
         else
         {
-            ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-            uint32_t total_num_dumped = 0;
-            
-            uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize();
-            result.GetOutputStream().SetAddressByteSize(addr_byte_size);
-            result.GetErrorStream().SetAddressByteSize(addr_byte_size);
-            
-            if (command.GetArgumentCount() == 0)
+            // Dump specified images (by basename or fullpath)
+            const char *arg_cstr;
+            for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx)
             {
-                result.AppendErrorWithFormat ("\nSyntax: %s\n", m_cmd_syntax.c_str());
-                result.SetStatus (eReturnStatusFailed);
-            }
-            else
-            {
-                // Dump specified images (by basename or fullpath)
-                const char *arg_cstr;
-                for (int arg_idx = 0; (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != NULL; ++arg_idx)
+                FileSpec file_spec(arg_cstr, false);
+                
+                const ModuleList &target_modules = target->GetImages();
+                Mutex::Locker modules_locker(target_modules.GetMutex());
+                const size_t num_modules = target_modules.GetSize();
+                if (num_modules > 0)
                 {
-                    FileSpec file_spec(arg_cstr, false);
-                    
-                    ModuleList &target_modules = target->GetImages();
-                    Mutex::Locker modules_locker(target_modules.GetMutex());
-                    const uint32_t num_modules = target_modules.GetSize();
-                    if (num_modules > 0)
+                    uint32_t num_dumped = 0;
+                    for (uint32_t i = 0; i<num_modules; ++i)
                     {
-                        uint32_t num_dumped = 0;
-                        for (uint32_t i = 0; i<num_modules; ++i)
-                        {
-                            if (DumpCompileUnitLineTable (m_interpreter,
-                                                          result.GetOutputStream(),
-                                                          target_modules.GetModulePointerAtIndexUnlocked(i),
-                                                          file_spec,
-                                                          exe_ctx.GetProcessPtr() && exe_ctx.GetProcessRef().IsAlive()))
-                                num_dumped++;
-                        }
-                        if (num_dumped == 0)
-                            result.AppendWarningWithFormat ("No source filenames matched '%s'.\n", arg_cstr);
-                        else
-                            total_num_dumped += num_dumped;
+                        if (DumpCompileUnitLineTable (m_interpreter,
+                                                      result.GetOutputStream(),
+                                                      target_modules.GetModulePointerAtIndexUnlocked(i),
+                                                      file_spec,
+                                                      m_exe_ctx.GetProcessPtr() && m_exe_ctx.GetProcessRef().IsAlive()))
+                            num_dumped++;
                     }
+                    if (num_dumped == 0)
+                        result.AppendWarningWithFormat ("No source filenames matched '%s'.\n", arg_cstr);
+                    else
+                        total_num_dumped += num_dumped;
                 }
             }
-            
-            if (total_num_dumped > 0)
-                result.SetStatus (eReturnStatusSuccessFinishResult);
-            else
-            {
-                result.AppendError ("no source filenames matched any command arguments");
-                result.SetStatus (eReturnStatusFailed);
-            }
+        }
+        
+        if (total_num_dumped > 0)
+            result.SetStatus (eReturnStatusSuccessFinishResult);
+        else
+        {
+            result.AppendError ("no source filenames matched any command arguments");
+            result.SetStatus (eReturnStatusFailed);
         }
         return result.Succeeded();
     }
@@ -2510,16 +2609,27 @@ public:
         CommandObjectParsed (interpreter,
                              "target modules add",
                              "Add a new module to the current target's modules.",
-                             "target modules add [<module>]")
+                             "target modules add [<module>]"),
+        m_option_group (interpreter),
+        m_symbol_file (LLDB_OPT_SET_1, false, "symfile", 's', 0, eArgTypeFilename, "Fullpath to a stand alone debug symbols file for when debug symbols are not in the executable.")
     {
+        m_option_group.Append (&m_uuid_option_group, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+        m_option_group.Append (&m_symbol_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+        m_option_group.Finalize();
     }
     
     virtual
     ~CommandObjectTargetModulesAdd ()
     {
     }
+        
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_option_group;
+    }
     
-    int
+    virtual int
     HandleArgumentCompletion (Args &input,
                               int &cursor_index,
                               int &cursor_char_position,
@@ -2544,6 +2654,12 @@ public:
     }
 
 protected:
+    
+    OptionGroupOptions m_option_group;
+    OptionGroupUUID m_uuid_option_group;
+    OptionGroupFile m_symbol_file;
+    
+
     virtual bool
     DoExecute (Args& args,
              CommandReturnObject &result)
@@ -2557,12 +2673,72 @@ protected:
         }
         else
         {
+            bool flush = false;
+            
             const size_t argc = args.GetArgumentCount();
             if (argc == 0)
             {
-                result.AppendError ("one or more executable image paths must be specified");
-                result.SetStatus (eReturnStatusFailed);
-                return false;
+                if (m_uuid_option_group.GetOptionValue ().OptionWasSet())
+                {
+                    // We are given a UUID only, go locate the file
+                    ModuleSpec module_spec;
+                    module_spec.GetUUID() = m_uuid_option_group.GetOptionValue ().GetCurrentValue();
+                    if (m_symbol_file.GetOptionValue().OptionWasSet())
+                        module_spec.GetSymbolFileSpec() = m_symbol_file.GetOptionValue().GetCurrentValue();
+                    if (Symbols::DownloadObjectAndSymbolFile (module_spec))
+                    {
+                        ModuleSP module_sp (target->GetSharedModule (module_spec));
+                        if (module_sp)
+                        {
+                            result.SetStatus (eReturnStatusSuccessFinishResult);
+                            return true;
+                        }
+                        else
+                        {
+                            flush = true;
+                            
+                            StreamString strm;
+                            module_spec.GetUUID().Dump (&strm);
+                            if (module_spec.GetFileSpec())
+                            {
+                                if (module_spec.GetSymbolFileSpec())
+                                {
+                                    result.AppendErrorWithFormat ("Unable to create the executable or symbol file with UUID %s with path %s and symbol file %s",
+                                                                  strm.GetString().c_str(),
+                                                                  module_spec.GetFileSpec().GetPath().c_str(),
+                                                                  module_spec.GetSymbolFileSpec().GetPath().c_str());
+                                }
+                                else
+                                {
+                                    result.AppendErrorWithFormat ("Unable to create the executable or symbol file with UUID %s with path %s",
+                                                                  strm.GetString().c_str(),
+                                                                  module_spec.GetFileSpec().GetPath().c_str());
+                                }
+                            }
+                            else
+                            {
+                                result.AppendErrorWithFormat ("Unable to create the executable or symbol file with UUID %s",
+                                                              strm.GetString().c_str());
+                            }
+                            result.SetStatus (eReturnStatusFailed);
+                            return false;
+                        }
+                    }
+                    else
+                    {
+                        StreamString strm;
+                        module_spec.GetUUID().Dump (&strm);
+                        result.AppendErrorWithFormat ("Unable to locate the executable or symbol file with UUID %s", strm.GetString().c_str());
+                        result.SetStatus (eReturnStatusFailed);
+                        return false;
+                    }
+                }
+                else
+                {
+                    result.AppendError ("one or more executable image paths must be specified");
+                    result.SetStatus (eReturnStatusFailed);
+                    return false;
+                }
             }
             else
             {
@@ -2575,13 +2751,26 @@ protected:
                         if (file_spec.Exists())
                         {
                             ModuleSpec module_spec (file_spec);
-                            ModuleSP module_sp (target->GetSharedModule (module_spec));
+                            if (m_uuid_option_group.GetOptionValue ().OptionWasSet())
+                                module_spec.GetUUID() = m_uuid_option_group.GetOptionValue ().GetCurrentValue();
+                            if (m_symbol_file.GetOptionValue().OptionWasSet())
+                                module_spec.GetSymbolFileSpec() = m_symbol_file.GetOptionValue().GetCurrentValue();
+                            Error error;
+                            ModuleSP module_sp (target->GetSharedModule (module_spec, &error));
                             if (!module_sp)
                             {
-                                result.AppendError ("one or more executable image paths must be specified");
+                                const char *error_cstr = error.AsCString();
+                                if (error_cstr)
+                                    result.AppendError (error_cstr);
+                                else
+                                    result.AppendErrorWithFormat ("unsupported module: %s", path);
                                 result.SetStatus (eReturnStatusFailed);
                                 return false;
                             }
+                            else
+                            {
+                                flush = true;
+                            }
                             result.SetStatus (eReturnStatusSuccessFinishResult);
                         }
                         else
@@ -2602,7 +2791,15 @@ protected:
                     }
                 }
             }
+            
+            if (flush)
+            {
+                ProcessSP process = target->GetProcessSP();
+                if (process)
+                    process->Flush();
+            }
         }
+        
         return result.Succeeded();
     }
 
@@ -2617,7 +2814,7 @@ public:
                                                       "Set the load addresses for one or more sections in a target module.",
                                                       "target modules load [--file <module> --uuid <uuid>] <sect-name> <address> [<sect-name> <address> ....]"),
         m_option_group (interpreter),
-        m_file_option (LLDB_OPT_SET_1, false, "file", 'f', 0, eArgTypePath, "Fullpath or basename for module to load."),
+        m_file_option (LLDB_OPT_SET_1, false, "file", 'f', 0, eArgTypeFilename, "Fullpath or basename for module to load."),
         m_slide_option(LLDB_OPT_SET_1, false, "slide", 's', 0, eArgTypeOffset, "Set the load address for all sections to be the virtual address in the file plus the offset.", 0)
     {
         m_option_group.Append (&m_uuid_option_group, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
@@ -2732,7 +2929,7 @@ protected:
                                                     {
                                                         if (target->GetSectionLoadList().SetSectionLoadAddress (section_sp, load_addr))
                                                             changed = true;
-                                                        result.AppendMessageWithFormat("section '%s' loaded at 0x%llx\n", sect_name, load_addr);
+                                                        result.AppendMessageWithFormat("section '%s' loaded at 0x%" PRIx64 "\n", sect_name, load_addr);
                                                     }
                                                 }
                                                 else
@@ -2762,7 +2959,12 @@ protected:
                                 }
                                 
                                 if (changed)
+                                {
                                     target->ModulesDidLoad (matching_modules);
+                                    Process *process = m_exe_ctx.GetProcessPtr();
+                                    if (process)
+                                        process->Flush();
+                                }
                             }
                             else
                             {
@@ -2780,14 +2982,20 @@ protected:
                     }
                     else
                     {
-                        module->GetFileSpec().GetPath (path, sizeof(path));
-                        result.AppendErrorWithFormat ("invalid module '%s'.\n", path);
+                        FileSpec *module_spec_file = module_spec.GetFileSpecPtr();
+                        if (module_spec_file)
+                        {
+                            module_spec_file->GetPath (path, sizeof(path));
+                            result.AppendErrorWithFormat ("invalid module '%s'.\n", path);
+                        }
+                        else
+                            result.AppendError ("no module spec");
                         result.SetStatus (eReturnStatusFailed);
                     }
                 }
                 else
                 {
-                    char uuid_cstr[64];
+                    std::string uuid_str;
                     
                     if (module_spec.GetFileSpec())
                         module_spec.GetFileSpec().GetPath (path, sizeof(path));
@@ -2795,16 +3003,14 @@ protected:
                         path[0] = '\0';
 
                     if (module_spec.GetUUIDPtr())
-                        module_spec.GetUUID().GetAsCString(uuid_cstr, sizeof(uuid_cstr));
-                    else
-                        uuid_cstr[0] = '\0';
+                        uuid_str = module_spec.GetUUID().GetAsString();
                     if (num_matches > 1)
                     {
                         result.AppendErrorWithFormat ("multiple modules match%s%s%s%s:\n", 
                                                       path[0] ? " file=" : "", 
                                                       path,
-                                                      uuid_cstr[0] ? " uuid=" : "", 
-                                                      uuid_cstr);
+                                                      !uuid_str.empty() ? " uuid=" : "", 
+                                                      uuid_str.c_str());
                         for (size_t i=0; i<num_matches; ++i)
                         {
                             if (matching_modules.GetModulePointerAtIndex(i)->GetFileSpec().GetPath (path, sizeof(path)))
@@ -2816,8 +3022,8 @@ protected:
                         result.AppendErrorWithFormat ("no modules were found  that match%s%s%s%s.\n", 
                                                       path[0] ? " file=" : "", 
                                                       path,
-                                                      uuid_cstr[0] ? " uuid=" : "", 
-                                                      uuid_cstr);
+                                                      !uuid_str.empty() ? " uuid=" : "", 
+                                                      uuid_str.c_str());
                     }
                     result.SetStatus (eReturnStatusFailed);
                 }
@@ -2865,29 +3071,25 @@ public:
         virtual Error
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
-            char short_option = (char) m_getopt_table[option_idx].val;
+            Error error;
+
+            const int short_option = m_getopt_table[option_idx].val;
             if (short_option == 'g')
             {
                 m_use_global_module_list = true;
             }
             else if (short_option == 'a')
             {
-                bool success;
-                m_module_addr = Args::StringToAddress(option_arg, LLDB_INVALID_ADDRESS, &success);
-                if (!success)
-                {
-                    Error error;
-                    error.SetErrorStringWithFormat("invalid address: \"%s\"", option_arg);
-                }
+                ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+                m_module_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
             }
             else
             {
-                uint32_t width = 0;
+                unsigned long width = 0;
                 if (option_arg)
                     width = strtoul (option_arg, NULL, 0);
                 m_format_array.push_back(std::make_pair(short_option, width));
             }
-            Error error;
             return error;
         }
         
@@ -2975,18 +3177,18 @@ protected:
                         ModuleSP module_sp (module_address.GetModule());
                         if (module_sp)
                         {
-                            PrintModule (target, module_sp.get(), UINT32_MAX, 0, strm);
+                            PrintModule (target, module_sp.get(), 0, strm);
                             result.SetStatus (eReturnStatusSuccessFinishResult);
                         }
                         else
                         {
-                            result.AppendError ("Couldn't find module matching address: 0x%llx.", m_options.m_module_addr);
+                            result.AppendErrorWithFormat ("Couldn't find module matching address: 0x%" PRIx64 ".", m_options.m_module_addr);
                             result.SetStatus (eReturnStatusFailed);
                         }
                     }
                     else
                     {
-                        result.AppendError ("Couldn't find module containing address: 0x%llx.", m_options.m_module_addr);
+                        result.AppendErrorWithFormat ("Couldn't find module containing address: 0x%" PRIx64 ".", m_options.m_module_addr);
                         result.SetStatus (eReturnStatusFailed);
                     }
                 }
@@ -2998,11 +3200,11 @@ protected:
                 return result.Succeeded();
             }
             
-            uint32_t num_modules = 0;
+            size_t num_modules = 0;
             Mutex::Locker locker;      // This locker will be locked on the mutex in module_list_ptr if it is non-NULL.
                                        // Otherwise it will lock the AllocationModuleCollectionMutex when accessing
                                        // the global module list directly.
-            ModuleList *module_list_ptr = NULL;
+            const ModuleList *module_list_ptr = NULL;
             const size_t argc = command.GetArgumentCount();
             if (argc == 0)
             {
@@ -3060,8 +3262,8 @@ protected:
                         module_sp = module->shared_from_this();
                     }
                     
-                    int indent = strm.Printf("[%3u] ", image_idx);
-                    PrintModule (target, module, image_idx, indent, strm);
+                    const size_t indent = strm.Printf("[%3u] ", image_idx);
+                    PrintModule (target, module, indent, strm);
 
                 }
                 result.SetStatus (eReturnStatusSuccessFinishResult);
@@ -3090,9 +3292,15 @@ protected:
     }
 
     void
-    PrintModule (Target *target, Module *module, uint32_t idx, int indent, Stream &strm)
+    PrintModule (Target *target, Module *module, int indent, Stream &strm)
     {
 
+        if (module == NULL)
+        {
+            strm.PutCString("Null module");
+            return;
+        }
+        
         bool dump_object_name = false;
         if (m_options.m_format_array.empty())
         {
@@ -3158,12 +3366,12 @@ protected:
                                         if (format_char == 'o')
                                         {
                                             // Show the offset of slide for the image
-                                            strm.Printf ("0x%*.*llx", addr_nibble_width, addr_nibble_width, header_load_addr - header_addr.GetFileAddress());
+                                            strm.Printf ("0x%*.*" PRIx64, addr_nibble_width, addr_nibble_width, header_load_addr - header_addr.GetFileAddress());
                                         }
                                         else
                                         {
                                             // Show the load address of the image
-                                            strm.Printf ("0x%*.*llx", addr_nibble_width, addr_nibble_width, header_load_addr);
+                                            strm.Printf ("0x%*.*" PRIx64, addr_nibble_width, addr_nibble_width, header_load_addr);
                                         }
                                     }
                                     break;
@@ -3178,7 +3386,7 @@ protected:
                     break;
                 case 'r':
                     {
-                        uint32_t ref_count = 0;
+                        size_t ref_count = 0;
                         ModuleSP module_sp (module->shared_from_this());
                         if (module_sp)
                         {
@@ -3186,9 +3394,9 @@ protected:
                             ref_count = module_sp.use_count() - 1;
                         }
                         if (width)
-                            strm.Printf("{%*u}", width, ref_count);
+                            strm.Printf("{%*zu}", width, ref_count);
                         else
-                            strm.Printf("{%u}", ref_count);
+                            strm.Printf("{%zu}", ref_count);
                     }
                     break;
 
@@ -3254,7 +3462,7 @@ protected:
 OptionDefinition
 CommandObjectTargetModulesList::CommandOptions::g_option_table[] =
 {
-    { LLDB_OPT_SET_1, false, "address",    'a', required_argument, NULL, 0, eArgTypeAddress, "Display the image at this address."},
+    { LLDB_OPT_SET_1, false, "address",    'a', required_argument, NULL, 0, eArgTypeAddressOrExpression, "Display the image at this address."},
     { LLDB_OPT_SET_1, false, "arch",       'A', optional_argument, NULL, 0, eArgTypeWidth,   "Display the architecture when listing images."},
     { LLDB_OPT_SET_1, false, "triple",     't', optional_argument, NULL, 0, eArgTypeWidth,   "Display the triple when listing images."},
     { LLDB_OPT_SET_1, false, "header",     'h', no_argument,       NULL, 0, eArgTypeNone,    "Display the image header address as a load address if debugging, a file address otherwise."},
@@ -3297,10 +3505,10 @@ public:
     public:
 
         CommandOptions (CommandInterpreter &interpreter) :
-        Options(interpreter),
-        m_type(eLookupTypeInvalid),
-        m_str(),
-        m_addr(LLDB_INVALID_ADDRESS)
+            Options(interpreter),
+            m_type(eLookupTypeInvalid),
+            m_str(),
+            m_addr(LLDB_INVALID_ADDRESS)
         {
         }
 
@@ -3314,21 +3522,26 @@ public:
         {
             Error error;
 
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
                 case 'a':
+                {
+                    ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
                     m_type = eLookupTypeAddress;
-                    m_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS);
+                    m_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
                     if (m_addr == LLDB_INVALID_ADDRESS)
                         error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg);
                     break;
+                }
 
                 case 'n':
+                {
                     m_str = option_arg;
                     m_type = eLookupTypeFunctionOrSymbol;
                     break;
+                }
             }
 
             return error;
@@ -3363,7 +3576,11 @@ public:
         CommandObjectParsed (interpreter,
                              "target modules show-unwind",
                              "Show synthesized unwind instructions for a function.",
-                             NULL),
+                             NULL,
+                             eFlagRequiresTarget        |
+                             eFlagRequiresProcess       |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused   ),
         m_options (interpreter)
     {
     }
@@ -3385,16 +3602,8 @@ protected:
     DoExecute (Args& command,
              CommandReturnObject &result)
     {
-        Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-        if (!target)
-        {
-            result.AppendError ("invalid target, create a debug target using the 'target create' command");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
-
-        ExecutionContext exe_ctx = m_interpreter.GetDebugger().GetSelectedExecutionContext();
-        Process *process = exe_ctx.GetProcessPtr();
+        Target *target = m_exe_ctx.GetTargetPtr();
+        Process *process = m_exe_ctx.GetProcessPtr();
         ABI *abi = NULL;
         if (process)
           abi = process->GetABI().get();
@@ -3422,78 +3631,94 @@ protected:
             return false;
         }
 
+        SymbolContextList sc_list;
+        
         if (m_options.m_type == eLookupTypeFunctionOrSymbol)
         {
-            SymbolContextList sc_list;
-            uint32_t num_matches;
             ConstString function_name (m_options.m_str.c_str());
-            num_matches = target->GetImages().FindFunctions (function_name, eFunctionNameTypeAuto, true, false, true, sc_list);
-            for (uint32_t idx = 0; idx < num_matches; idx++)
+            target->GetImages().FindFunctions (function_name, eFunctionNameTypeAuto, true, false, true, sc_list);
+        }
+        else if (m_options.m_type == eLookupTypeAddress && target)
+        {
+            Address addr;
+            if (target->GetSectionLoadList().ResolveLoadAddress (m_options.m_addr, addr))
             {
                 SymbolContext sc;
-                sc_list.GetContextAtIndex(idx, sc);
-                if (sc.symbol == NULL && sc.function == NULL)
-                    continue;
-                if (sc.module_sp.get() == NULL || sc.module_sp->GetObjectFile() == NULL)
-                    continue;
-                AddressRange range;
-                if (!sc.GetAddressRange (eSymbolContextFunction | eSymbolContextSymbol, 0, false, range))
-                    continue;
-                if (!range.GetBaseAddress().IsValid())
-                    continue;
-                ConstString funcname(sc.GetFunctionName());
-                if (funcname.IsEmpty())
-                    continue;
-                addr_t start_addr = range.GetBaseAddress().GetLoadAddress(target);
-                if (abi)
-                    start_addr = abi->FixCodeAddress(start_addr);
-
-                FuncUnwindersSP func_unwinders_sp (sc.module_sp->GetObjectFile()->GetUnwindTable().GetUncachedFuncUnwindersContainingAddress(start_addr, sc));
-                if (func_unwinders_sp.get() == NULL)
-                    continue;
-
-                Address first_non_prologue_insn (func_unwinders_sp->GetFirstNonPrologueInsn(*target));
-                if (first_non_prologue_insn.IsValid())
+                ModuleSP module_sp (addr.GetModule());
+                module_sp->ResolveSymbolContextForAddress (addr, eSymbolContextEverything, sc);
+                if (sc.function || sc.symbol)
                 {
-                    result.GetOutputStream().Printf("First non-prologue instruction is at address 0x%llx or offset %lld into the function.\n", first_non_prologue_insn.GetLoadAddress(target), first_non_prologue_insn.GetLoadAddress(target) - start_addr);
-                    result.GetOutputStream().Printf ("\n");
+                    sc_list.Append(sc);
                 }
+            }
+        }
 
-                UnwindPlanSP non_callsite_unwind_plan = func_unwinders_sp->GetUnwindPlanAtNonCallSite(*thread.get());
-                if (non_callsite_unwind_plan.get())
-                {
-                    result.GetOutputStream().Printf("Asynchronous (not restricted to call-sites) UnwindPlan for %s`%s (start addr 0x%llx):\n", sc.module_sp->GetPlatformFileSpec().GetFilename().AsCString(), funcname.AsCString(), start_addr);
-                    non_callsite_unwind_plan->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS);
-                    result.GetOutputStream().Printf ("\n");
-                }
+        size_t num_matches = sc_list.GetSize();
+        for (uint32_t idx = 0; idx < num_matches; idx++)
+        {
+            SymbolContext sc;
+            sc_list.GetContextAtIndex(idx, sc);
+            if (sc.symbol == NULL && sc.function == NULL)
+                continue;
+            if (sc.module_sp.get() == NULL || sc.module_sp->GetObjectFile() == NULL)
+                continue;
+            AddressRange range;
+            if (!sc.GetAddressRange (eSymbolContextFunction | eSymbolContextSymbol, 0, false, range))
+                continue;
+            if (!range.GetBaseAddress().IsValid())
+                continue;
+            ConstString funcname(sc.GetFunctionName());
+            if (funcname.IsEmpty())
+                continue;
+            addr_t start_addr = range.GetBaseAddress().GetLoadAddress(target);
+            if (abi)
+                start_addr = abi->FixCodeAddress(start_addr);
+
+            FuncUnwindersSP func_unwinders_sp (sc.module_sp->GetObjectFile()->GetUnwindTable().GetUncachedFuncUnwindersContainingAddress(start_addr, sc));
+            if (func_unwinders_sp.get() == NULL)
+                continue;
 
-                UnwindPlanSP callsite_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(-1);
-                if (callsite_unwind_plan.get())
-                {
-                    result.GetOutputStream().Printf("Synchronous (restricted to call-sites) UnwindPlan for %s`%s (start addr 0x%llx):\n", sc.module_sp->GetPlatformFileSpec().GetFilename().AsCString(), funcname.AsCString(), start_addr);
-                    callsite_unwind_plan->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS);
-                    result.GetOutputStream().Printf ("\n");
-                }
+            Address first_non_prologue_insn (func_unwinders_sp->GetFirstNonPrologueInsn(*target));
+            if (first_non_prologue_insn.IsValid())
+            {
+                result.GetOutputStream().Printf("First non-prologue instruction is at address 0x%" PRIx64 " or offset %" PRId64 " into the function.\n", first_non_prologue_insn.GetLoadAddress(target), first_non_prologue_insn.GetLoadAddress(target) - start_addr);
+                result.GetOutputStream().Printf ("\n");
+            }
 
-                UnwindPlanSP arch_default_unwind_plan = func_unwinders_sp->GetUnwindPlanArchitectureDefault(*thread.get());
-                if (arch_default_unwind_plan.get())
-                {
-                    result.GetOutputStream().Printf("Architecture default UnwindPlan for %s`%s (start addr 0x%llx):\n", sc.module_sp->GetPlatformFileSpec().GetFilename().AsCString(), funcname.AsCString(), start_addr);
-                    arch_default_unwind_plan->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS);
-                    result.GetOutputStream().Printf ("\n");
-                }
+            UnwindPlanSP non_callsite_unwind_plan = func_unwinders_sp->GetUnwindPlanAtNonCallSite(*thread.get());
+            if (non_callsite_unwind_plan.get())
+            {
+                result.GetOutputStream().Printf("Asynchronous (not restricted to call-sites) UnwindPlan for %s`%s (start addr 0x%" PRIx64 "):\n", sc.module_sp->GetPlatformFileSpec().GetFilename().AsCString(), funcname.AsCString(), start_addr);
+                non_callsite_unwind_plan->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS);
+                result.GetOutputStream().Printf ("\n");
+            }
 
-                UnwindPlanSP fast_unwind_plan = func_unwinders_sp->GetUnwindPlanFastUnwind(*thread.get());
-                if (fast_unwind_plan.get())
-                {
-                    result.GetOutputStream().Printf("Fast UnwindPlan for %s`%s (start addr 0x%llx):\n", sc.module_sp->GetPlatformFileSpec().GetFilename().AsCString(), funcname.AsCString(), start_addr);
-                    fast_unwind_plan->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS);
-                    result.GetOutputStream().Printf ("\n");
-                }
+            UnwindPlanSP callsite_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(-1);
+            if (callsite_unwind_plan.get())
+            {
+                result.GetOutputStream().Printf("Synchronous (restricted to call-sites) UnwindPlan for %s`%s (start addr 0x%" PRIx64 "):\n", sc.module_sp->GetPlatformFileSpec().GetFilename().AsCString(), funcname.AsCString(), start_addr);
+                callsite_unwind_plan->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS);
+                result.GetOutputStream().Printf ("\n");
+            }
 
+            UnwindPlanSP arch_default_unwind_plan = func_unwinders_sp->GetUnwindPlanArchitectureDefault(*thread.get());
+            if (arch_default_unwind_plan.get())
+            {
+                result.GetOutputStream().Printf("Architecture default UnwindPlan for %s`%s (start addr 0x%" PRIx64 "):\n", sc.module_sp->GetPlatformFileSpec().GetFilename().AsCString(), funcname.AsCString(), start_addr);
+                arch_default_unwind_plan->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS);
+                result.GetOutputStream().Printf ("\n");
+            }
 
+            UnwindPlanSP fast_unwind_plan = func_unwinders_sp->GetUnwindPlanFastUnwind(*thread.get());
+            if (fast_unwind_plan.get())
+            {
+                result.GetOutputStream().Printf("Fast UnwindPlan for %s`%s (start addr 0x%" PRIx64 "):\n", sc.module_sp->GetPlatformFileSpec().GetFilename().AsCString(), funcname.AsCString(), start_addr);
+                fast_unwind_plan->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS);
                 result.GetOutputStream().Printf ("\n");
             }
+
+
+            result.GetOutputStream().Printf ("\n");
         }
         return result.Succeeded();
     }
@@ -3504,7 +3729,8 @@ protected:
 OptionDefinition
 CommandObjectTargetModulesShowUnwind::CommandOptions::g_option_table[] =
 {
-    { LLDB_OPT_SET_1,   true,  "name",       'n', required_argument, NULL, 0, eArgTypeFunctionName, "Lookup a function or symbol by name in one or more target modules."},
+    { LLDB_OPT_SET_1,   false,  "name",       'n', required_argument, NULL, 0, eArgTypeFunctionName, "Show unwind instructions for a function or symbol name."},
+    { LLDB_OPT_SET_2,   false,  "address",    'a', required_argument, NULL, 0, eArgTypeAddressOrExpression, "Show unwind instructions for a function or symbol containing an address"},
     { 0,                false, NULL,           0, 0,                 NULL, 0, eArgTypeNone, NULL }
 };
 
@@ -3547,15 +3773,16 @@ public:
         {
             Error error;
             
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
                 case 'a':
-                    m_type = eLookupTypeAddress;
-                    m_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS);
-                    if (m_addr == LLDB_INVALID_ADDRESS)
-                        error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg);
+                    {
+                        m_type = eLookupTypeAddress;
+                        ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+                        m_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
+                    }
                     break;
                     
                 case 'o':
@@ -3659,7 +3886,8 @@ public:
         CommandObjectParsed (interpreter,
                              "target modules lookup",
                              "Look up information within executable and dependent shared library images.",
-                             NULL),
+                             NULL,
+                             eFlagRequiresTarget),
         m_options (interpreter)
     {
         CommandArgumentEntry arg;
@@ -3703,9 +3931,7 @@ public:
                 break;
         }
         
-        ExecutionContext exe_ctx = interpreter.GetDebugger().GetSelectedExecutionContext();
-        
-        StackFrameSP frame = exe_ctx.GetFrameSP();
+        StackFrameSP frame = m_exe_ctx.GetFrameSP();
         
         if (!frame)
             return false;
@@ -3881,9 +4107,9 @@ protected:
                 
                 // Dump all sections for all other modules
                 
-                ModuleList &target_modules = target->GetImages();
+                const ModuleList &target_modules = target->GetImages();
                 Mutex::Locker modules_locker(target_modules.GetMutex());
-                const uint32_t num_modules = target_modules.GetSize();
+                const size_t num_modules = target_modules.GetSize();
                 if (num_modules > 0)
                 {
                     for (i = 0; i<num_modules && syntax_error == false; ++i)
@@ -3915,9 +4141,9 @@ protected:
                     const size_t num_matches = FindModulesByName (target, arg_cstr, module_list, false);
                     if (num_matches > 0)
                     {
-                        for (size_t i=0; i<num_matches; ++i)
+                        for (size_t j=0; j<num_matches; ++j)
                         {
-                            Module *module = module_list.GetModulePointerAtIndex(i);
+                            Module *module = module_list.GetModulePointerAtIndex(j);
                             if (module)
                             {
                                 if (LookupInModule (m_interpreter, module, result, syntax_error))
@@ -3947,22 +4173,22 @@ protected:
 OptionDefinition
 CommandObjectTargetModulesLookup::CommandOptions::g_option_table[] =
 {
-    { LLDB_OPT_SET_1,   true,  "address",    'a', required_argument, NULL, 0, eArgTypeAddress,      "Lookup an address in one or more target modules."},
-    { LLDB_OPT_SET_1,   false, "offset",     'o', required_argument, NULL, 0, eArgTypeOffset,       "When looking up an address subtract <offset> from any addresses before doing the lookup."},
+    { LLDB_OPT_SET_1,   true,  "address",    'a', required_argument, NULL, 0, eArgTypeAddressOrExpression, "Lookup an address in one or more target modules."},
+    { LLDB_OPT_SET_1,   false, "offset",     'o', required_argument, NULL, 0, eArgTypeOffset,           "When looking up an address subtract <offset> from any addresses before doing the lookup."},
     { LLDB_OPT_SET_2| LLDB_OPT_SET_4 | LLDB_OPT_SET_5
       /* FIXME: re-enable this for types when the LookupTypeInModule actually uses the regex option: | LLDB_OPT_SET_6 */ ,
-                        false, "regex",      'r', no_argument,       NULL, 0, eArgTypeNone,         "The <name> argument for name lookups are regular expressions."},
-    { LLDB_OPT_SET_2,   true,  "symbol",     's', required_argument, NULL, 0, eArgTypeSymbol,       "Lookup a symbol by name in the symbol tables in one or more target modules."},
-    { LLDB_OPT_SET_3,   true,  "file",       'f', required_argument, NULL, 0, eArgTypeFilename,     "Lookup a file by fullpath or basename in one or more target modules."},
-    { LLDB_OPT_SET_3,   false, "line",       'l', required_argument, NULL, 0, eArgTypeLineNum,      "Lookup a line number in a file (must be used in conjunction with --file)."},
+                        false, "regex",      'r', no_argument,       NULL, 0, eArgTypeNone,             "The <name> argument for name lookups are regular expressions."},
+    { LLDB_OPT_SET_2,   true,  "symbol",     's', required_argument, NULL, 0, eArgTypeSymbol,           "Lookup a symbol by name in the symbol tables in one or more target modules."},
+    { LLDB_OPT_SET_3,   true,  "file",       'f', required_argument, NULL, 0, eArgTypeFilename,         "Lookup a file by fullpath or basename in one or more target modules."},
+    { LLDB_OPT_SET_3,   false, "line",       'l', required_argument, NULL, 0, eArgTypeLineNum,          "Lookup a line number in a file (must be used in conjunction with --file)."},
     { LLDB_OPT_SET_FROM_TO(3,5),
-                        false, "no-inlines", 'i', no_argument,       NULL, 0, eArgTypeNone,         "Ignore inline entries (must be used in conjunction with --file or --function)."},
-    { LLDB_OPT_SET_4,   true,  "function",   'F', required_argument, NULL, 0, eArgTypeFunctionName, "Lookup a function by name in the debug symbols in one or more target modules."},
-    { LLDB_OPT_SET_5,   true,  "name",       'n', required_argument, NULL, 0, eArgTypeFunctionName, "Lookup a function or symbol by name in one or more target modules."},
-    { LLDB_OPT_SET_6,   true,  "type",       't', required_argument, NULL, 0, eArgTypeName,         "Lookup a type by name in the debug symbols in one or more target modules."},
-    { LLDB_OPT_SET_ALL, false, "verbose",    'v', no_argument,       NULL, 0, eArgTypeNone,         "Enable verbose lookup information."},
-    { LLDB_OPT_SET_ALL, false, "all",        'A', no_argument,       NULL, 0, eArgTypeNone,         "Print all matches, not just the best match, if a best match is available."},
-    { 0,                false, NULL,           0, 0,                 NULL, 0, eArgTypeNone, NULL }
+                        false, "no-inlines", 'i', no_argument,       NULL, 0, eArgTypeNone,             "Ignore inline entries (must be used in conjunction with --file or --function)."},
+    { LLDB_OPT_SET_4,   true,  "function",   'F', required_argument, NULL, 0, eArgTypeFunctionName,     "Lookup a function by name in the debug symbols in one or more target modules."},
+    { LLDB_OPT_SET_5,   true,  "name",       'n', required_argument, NULL, 0, eArgTypeFunctionOrSymbol, "Lookup a function or symbol by name in one or more target modules."},
+    { LLDB_OPT_SET_6,   true,  "type",       't', required_argument, NULL, 0, eArgTypeName,             "Lookup a type by name in the debug symbols in one or more target modules."},
+    { LLDB_OPT_SET_ALL, false, "verbose",    'v', no_argument,       NULL, 0, eArgTypeNone,             "Enable verbose lookup information."},
+    { LLDB_OPT_SET_ALL, false, "all",        'A', no_argument,       NULL, 0, eArgTypeNone,             "Print all matches, not just the best match, if a best match is available."},
+    { 0,                false, NULL,           0, 0,                 NULL, 0, eArgTypeNone,             NULL }
 };
 
 
@@ -4016,7 +4242,6 @@ public:
     {
         LoadSubCommand ("add",          CommandObjectSP (new CommandObjectTargetModulesAdd (interpreter)));
         LoadSubCommand ("load",         CommandObjectSP (new CommandObjectTargetModulesLoad (interpreter)));
-        //LoadSubCommand ("unload",       CommandObjectSP (new CommandObjectTargetModulesUnload (interpreter)));
         LoadSubCommand ("dump",         CommandObjectSP (new CommandObjectTargetModulesDump (interpreter)));
         LoadSubCommand ("list",         CommandObjectSP (new CommandObjectTargetModulesList (interpreter)));
         LoadSubCommand ("lookup",       CommandObjectSP (new CommandObjectTargetModulesLookup (interpreter)));
@@ -4044,9 +4269,17 @@ public:
     CommandObjectTargetSymbolsAdd (CommandInterpreter &interpreter) :
         CommandObjectParsed (interpreter,
                              "target symbols add",
-                             "Add a debug symbol file to one of the target's current modules.",
-                             "target symbols add [<symfile>]")
+                             "Add a debug symbol file to one of the target's current modules by specifying a path to a debug symbols file, or using the options to specify a module to download symbols for.",
+                             "target symbols add [<symfile>]", eFlagRequiresTarget),
+        m_option_group (interpreter),
+        m_file_option (LLDB_OPT_SET_1, false, "shlib", 's', CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Fullpath or basename for module to find debug symbols for."),
+        m_current_frame_option (LLDB_OPT_SET_2, false, "frame", 'F', "Locate the debug symbols the currently selected frame.", false, true)
+
     {
+        m_option_group.Append (&m_uuid_option_group, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+        m_option_group.Append (&m_file_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+        m_option_group.Append (&m_current_frame_option, LLDB_OPT_SET_2, LLDB_OPT_SET_2);
+        m_option_group.Finalize();
     }
     
     virtual
@@ -4054,7 +4287,7 @@ public:
     {
     }
     
-    int
+    virtual int
     HandleArgumentCompletion (Args &input,
                               int &cursor_index,
                               int &cursor_char_position,
@@ -4078,75 +4311,356 @@ public:
         return matches.GetSize();
     }
     
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_option_group;
+    }
+    
+
 protected:
+    
+    bool
+    AddModuleSymbols (Target *target,
+                      ModuleSpec &module_spec,
+                      bool &flush,
+                      CommandReturnObject &result)
+    {
+        const FileSpec &symbol_fspec = module_spec.GetSymbolFileSpec();
+        if (symbol_fspec)
+        {
+            char symfile_path[PATH_MAX];
+            symbol_fspec.GetPath (symfile_path, sizeof(symfile_path));
+            
+            if (!module_spec.GetUUID().IsValid())
+            {
+                if (!module_spec.GetFileSpec() && !module_spec.GetPlatformFileSpec())
+                    module_spec.GetFileSpec().GetFilename() = symbol_fspec.GetFilename();
+            }
+            // We now have a module that represents a symbol file
+            // that can be used for a module that might exist in the
+            // current target, so we need to find that module in the
+            // target
+            ModuleList matching_module_list;
+            
+            size_t num_matches = 0;
+            // First extract all module specs from the symbol file
+            lldb_private::ModuleSpecList symfile_module_specs;
+            if (ObjectFile::GetModuleSpecifications(module_spec.GetSymbolFileSpec(), 0, symfile_module_specs))
+            {
+                // Now extract the module spec that matches the target architecture
+                ModuleSpec target_arch_module_spec;
+                ModuleSpec symfile_module_spec;
+                target_arch_module_spec.GetArchitecture() = target->GetArchitecture();
+                if (symfile_module_specs.FindMatchingModuleSpec(target_arch_module_spec, symfile_module_spec))
+                {
+                    // See if it has a UUID?
+                    if (symfile_module_spec.GetUUID().IsValid())
+                    {
+                        // It has a UUID, look for this UUID in the target modules
+                        ModuleSpec symfile_uuid_module_spec;
+                        symfile_uuid_module_spec.GetUUID() = symfile_module_spec.GetUUID();
+                        num_matches = target->GetImages().FindModules (symfile_uuid_module_spec, matching_module_list);
+                    }
+                }
+                
+                if (num_matches == 0)
+                {
+                    // No matches yet, iterate through the module specs to find a UUID value that
+                    // we can match up to an image in our target
+                    const size_t num_symfile_module_specs = symfile_module_specs.GetSize();
+                    for (size_t i=0; i<num_symfile_module_specs && num_matches == 0; ++i)
+                    {
+                        if (symfile_module_specs.GetModuleSpecAtIndex(i, symfile_module_spec))
+                        {
+                            if (symfile_module_spec.GetUUID().IsValid())
+                            {
+                                // It has a UUID, look for this UUID in the target modules
+                                ModuleSpec symfile_uuid_module_spec;
+                                symfile_uuid_module_spec.GetUUID() = symfile_module_spec.GetUUID();
+                                num_matches = target->GetImages().FindModules (symfile_uuid_module_spec, matching_module_list);
+                            }                            
+                        }
+                    }
+                }
+            }
+
+            // Just try to match up the file by basename if we have no matches at this point
+            if (num_matches == 0)
+                num_matches = target->GetImages().FindModules (module_spec, matching_module_list);
+    
+            while (num_matches == 0)
+            {
+                ConstString filename_no_extension(module_spec.GetFileSpec().GetFileNameStrippingExtension());
+                // Empty string returned, lets bail
+                if (!filename_no_extension)
+                    break;
+                
+                // Check if there was no extension to strip and the basename is the same
+                if (filename_no_extension == module_spec.GetFileSpec().GetFilename())
+                    break;
+                
+                // Replace basename with one less extension
+                module_spec.GetFileSpec().GetFilename() = filename_no_extension;
+                
+                num_matches = target->GetImages().FindModules (module_spec, matching_module_list);
+                
+            }
+
+            if (num_matches > 1)
+            {
+                result.AppendErrorWithFormat ("multiple modules match symbol file '%s', use the --uuid option to resolve the ambiguity.\n", symfile_path);
+            }
+            else if (num_matches == 1)
+            {
+                ModuleSP module_sp (matching_module_list.GetModuleAtIndex(0));
+                
+                // The module has not yet created its symbol vendor, we can just
+                // give the existing target module the symfile path to use for
+                // when it decides to create it!
+                module_sp->SetSymbolFileFileSpec (symbol_fspec);
+                
+                SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor(true, &result.GetErrorStream());
+                if (symbol_vendor)
+                {
+                    SymbolFile *symbol_file = symbol_vendor->GetSymbolFile();
+                    
+                    if (symbol_file)
+                    {
+                        ObjectFile *object_file = symbol_file->GetObjectFile();
+                        
+                        if (object_file && object_file->GetFileSpec() == symbol_fspec)
+                        {
+                            // Provide feedback that the symfile has been successfully added.
+                            const FileSpec &module_fs = module_sp->GetFileSpec();
+                            result.AppendMessageWithFormat("symbol file '%s' has been added to '%s'\n",
+                                                           symfile_path,
+                                                           module_fs.GetPath().c_str());
+                            
+                            // Let clients know something changed in the module
+                            // if it is currently loaded
+                            ModuleList module_list;
+                            module_list.Append (module_sp);
+                            target->SymbolsDidLoad (module_list);
+                            
+                            // Make sure we load any scripting resources that may be embedded
+                            // in the debug info files in case the platform supports that.
+                            Error error;
+                            StreamString feedback_stream;
+                            module_sp->LoadScriptingResourceInTarget (target, error,&feedback_stream);
+                            if (error.Fail() && error.AsCString())
+                                result.AppendWarningWithFormat("unable to load scripting data for module %s - error reported was %s",
+                                                               module_sp->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
+                                                               error.AsCString());
+                            else if (feedback_stream.GetSize())
+                                result.AppendWarningWithFormat("%s",feedback_stream.GetData());
+
+                            flush = true;
+                            result.SetStatus (eReturnStatusSuccessFinishResult);
+                            return true;
+                        }
+                    }
+                }
+                // Clear the symbol file spec if anything went wrong
+                module_sp->SetSymbolFileFileSpec (FileSpec());
+            }
+
+            if (module_spec.GetUUID().IsValid())
+            {
+                StreamString ss_symfile_uuid;
+                module_spec.GetUUID().Dump(&ss_symfile_uuid);
+                result.AppendErrorWithFormat ("symbol file '%s' (%s) does not match any existing module%s\n",
+                                              symfile_path,
+                                              ss_symfile_uuid.GetData(),
+                                              (symbol_fspec.GetFileType() != FileSpec::eFileTypeRegular)
+                                                ? "\n       please specify the full path to the symbol file"
+                                                : "");
+            }
+            else
+            {
+                result.AppendErrorWithFormat ("symbol file '%s' does not match any existing module%s\n",
+                                              symfile_path,
+                                              (symbol_fspec.GetFileType() != FileSpec::eFileTypeRegular)
+                                                ? "\n       please specify the full path to the symbol file"
+                                                : "");
+            }
+        }
+        else
+        {
+            result.AppendError ("one or more executable image paths must be specified");
+        }
+        result.SetStatus (eReturnStatusFailed);
+        return false;
+    }
+
     virtual bool
     DoExecute (Args& args,
              CommandReturnObject &result)
     {
-        ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
-        Target *target = exe_ctx.GetTargetPtr();
-        if (target == NULL)
+        Target *target = m_exe_ctx.GetTargetPtr();
+        result.SetStatus (eReturnStatusFailed);
+        bool flush = false;
+        ModuleSpec module_spec;
+        const bool uuid_option_set = m_uuid_option_group.GetOptionValue().OptionWasSet();
+        const bool file_option_set = m_file_option.GetOptionValue().OptionWasSet();
+        const bool frame_option_set = m_current_frame_option.GetOptionValue().OptionWasSet();
+
+        const size_t argc = args.GetArgumentCount();
+        if (argc == 0)
         {
-            result.AppendError ("invalid target, create a debug target using the 'target create' command");
-            result.SetStatus (eReturnStatusFailed);
+            if (uuid_option_set || file_option_set || frame_option_set)
+            {
+                bool success = false;
+                bool error_set = false;
+                if (frame_option_set)
+                {
+                    Process *process = m_exe_ctx.GetProcessPtr();
+                    if (process)
+                    {
+                        const StateType process_state = process->GetState();
+                        if (StateIsStoppedState (process_state, true))
+                        {
+                            StackFrame *frame = m_exe_ctx.GetFramePtr();
+                            if (frame)
+                            {
+                                ModuleSP frame_module_sp (frame->GetSymbolContext(eSymbolContextModule).module_sp);
+                                if (frame_module_sp)
+                                {
+                                    if (frame_module_sp->GetPlatformFileSpec().Exists())
+                                    {
+                                        module_spec.GetArchitecture() = frame_module_sp->GetArchitecture();
+                                        module_spec.GetFileSpec() = frame_module_sp->GetPlatformFileSpec();
+                                    }
+                                    module_spec.GetUUID() = frame_module_sp->GetUUID();
+                                    success = module_spec.GetUUID().IsValid() || module_spec.GetFileSpec();
+                                }
+                                else
+                                {
+                                    result.AppendError ("frame has no module");
+                                    error_set = true;
+                                }
+                            }
+                            else
+                            {
+                                result.AppendError ("invalid current frame");
+                                error_set = true;
+                            }
+                        }
+                        else
+                        {
+                            result.AppendErrorWithFormat ("process is not stopped: %s", StateAsCString(process_state));
+                            error_set = true;
+                        }
+                    }
+                    else
+                    {
+                        result.AppendError ("a process must exist in order to use the --frame option");
+                        error_set = true;
+                    }
+                }
+                else
+                {
+                    if (uuid_option_set)
+                    {
+                        module_spec.GetUUID() = m_uuid_option_group.GetOptionValue().GetCurrentValue();
+                        success |= module_spec.GetUUID().IsValid();
+                    }
+                    else if (file_option_set)
+                    {
+                        module_spec.GetFileSpec() = m_file_option.GetOptionValue().GetCurrentValue();
+                        ModuleSP module_sp (target->GetImages().FindFirstModule(module_spec));
+                        if (module_sp)
+                        {
+                            module_spec.GetFileSpec() = module_sp->GetFileSpec();
+                            module_spec.GetPlatformFileSpec() = module_sp->GetPlatformFileSpec();
+                            module_spec.GetUUID() = module_sp->GetUUID();
+                            module_spec.GetArchitecture() = module_sp->GetArchitecture();
+                        }
+                        else
+                        {
+                            module_spec.GetArchitecture() = target->GetArchitecture();
+                        }
+                        success |= module_spec.GetFileSpec().Exists();
+                    }
+                }
+
+                if (success)
+                {
+                    if (Symbols::DownloadObjectAndSymbolFile (module_spec))
+                    {
+                        if (module_spec.GetSymbolFileSpec())
+                            success = AddModuleSymbols (target, module_spec, flush, result);
+                    }
+                }
+
+                if (!success && !error_set)
+                {
+                    StreamString error_strm;
+                    if (uuid_option_set)
+                    {
+                        error_strm.PutCString("unable to find debug symbols for UUID ");
+                        module_spec.GetUUID().Dump (&error_strm);
+                    }
+                    else if (file_option_set)
+                    {
+                        error_strm.PutCString("unable to find debug symbols for the executable file ");
+                        error_strm << module_spec.GetFileSpec();
+                    }
+                    else if (frame_option_set)
+                    {
+                        error_strm.PutCString("unable to find debug symbols for the current frame");                            
+                    }
+                    result.AppendError (error_strm.GetData());
+                }
+            }
+            else
+            {
+                result.AppendError ("one or more symbol file paths must be specified, or options must be specified");
+            }
         }
         else
         {
-            bool flush = false;
-            const size_t argc = args.GetArgumentCount();
-            if (argc == 0)
+            if (uuid_option_set)
             {
-                result.AppendError ("one or more symbol file paths must be specified");
-                result.SetStatus (eReturnStatusFailed);
+                result.AppendError ("specify either one or more paths to symbol files or use the --uuid option without arguments");
+            }
+            else if (file_option_set)
+            {
+                result.AppendError ("specify either one or more paths to symbol files or use the --file option without arguments");
+            }
+            else if (frame_option_set)
+            {
+                result.AppendError ("specify either one or more paths to symbol files or use the --frame option without arguments");
             }
             else
             {
+                PlatformSP platform_sp (target->GetPlatform());
+
                 for (size_t i=0; i<argc; ++i)
                 {
                     const char *symfile_path = args.GetArgumentAtIndex(i);
                     if (symfile_path)
                     {
-                        FileSpec symfile_spec(symfile_path, true);
+                        module_spec.GetSymbolFileSpec().SetFile(symfile_path, true);
+                        if (platform_sp)
+                        {
+                            FileSpec symfile_spec;
+                            if (platform_sp->ResolveSymbolFile(*target, module_spec, symfile_spec).Success())
+                                module_spec.GetSymbolFileSpec() = symfile_spec;
+                        }
+                        
                         ArchSpec arch;
-                        if (symfile_spec.Exists())
+                        bool symfile_exists = module_spec.GetSymbolFileSpec().Exists();
+
+                        if (symfile_exists)
                         {
-                            ModuleSP symfile_module_sp (new Module (symfile_spec, target->GetArchitecture()));
-                            if (symfile_module_sp)
-                            {
-                                // We now have a module that represents a symbol file
-                                // that can be used for a module that might exist in the
-                                // current target, so we need to find that module in the
-                                // target
-                                
-                                ModuleSP old_module_sp (target->GetImages().FindModule (symfile_module_sp->GetUUID()));
-                                if (old_module_sp)
-                                {
-                                    // The module has not yet created its symbol vendor, we can just
-                                    // give the existing target module the symfile path to use for
-                                    // when it decides to create it!
-                                    old_module_sp->SetSymbolFileFileSpec (symfile_module_sp->GetFileSpec());
-
-                                    // Let clients know something changed in the module
-                                    // if it is currently loaded
-                                    ModuleList module_list;
-                                    module_list.Append (old_module_sp);
-                                    target->ModulesDidLoad (module_list);
-                                    flush = true;
-                                }
-                            }
-                            else
-                            {
-                                result.AppendError ("one or more executable image paths must be specified");
-                                result.SetStatus (eReturnStatusFailed);
+                            if (!AddModuleSymbols (target, module_spec, flush, result))
                                 break;
-                            }
-                            result.SetStatus (eReturnStatusSuccessFinishResult);
                         }
                         else
                         {
                             char resolved_symfile_path[PATH_MAX];
-                            result.SetStatus (eReturnStatusFailed);
-                            if (symfile_spec.GetPath (resolved_symfile_path, sizeof(resolved_symfile_path)))
+                            if (module_spec.GetSymbolFileSpec().GetPath (resolved_symfile_path, sizeof(resolved_symfile_path)))
                             {
                                 if (strcmp (resolved_symfile_path, symfile_path) != 0)
                                 {
@@ -4160,17 +4674,23 @@ protected:
                     }
                 }
             }
+        }
 
-            if (flush)
-            {
-                Process *process = exe_ctx.GetProcessPtr();
-                if (process)
-                    process->Flush();
-            }
+        if (flush)
+        {
+            Process *process = m_exe_ctx.GetProcessPtr();
+            if (process)
+                process->Flush();
         }
         return result.Succeeded();
     }
     
+    OptionGroupOptions m_option_group;
+    OptionGroupUUID m_uuid_option_group;
+    OptionGroupFile m_file_option;
+    OptionGroupBoolean m_current_frame_option;
+
+    
 };
 
 
@@ -4245,7 +4765,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             bool success;
 
             switch (short_option)
@@ -4470,7 +4990,7 @@ public:
         case eInputReaderDone:
             if (!got_interrupted && !batch_mode)
             {
-                out_stream->Printf ("Stop hook #%llu added.\n", new_stop_hook->GetID());
+                out_stream->Printf ("Stop hook #%" PRIu64 " added.\n", new_stop_hook->GetID());
                 out_stream->Flush();
             }
             break;
@@ -4490,7 +5010,7 @@ protected:
             target->AddStopHook (new_hook_sp);
 
             //  First step, make the specifier.
-            std::auto_ptr<SymbolContextSpecifier> specifier_ap;
+            std::unique_ptr<SymbolContextSpecifier> specifier_ap;
             if (m_options.m_sym_ctx_specified)
             {
                 specifier_ap.reset(new SymbolContextSpecifier(m_interpreter.GetDebugger().GetSelectedTarget()));
@@ -4556,7 +5076,7 @@ protected:
             {
                 // Use one-liner.
                 new_hook_sp->GetCommandPointer()->AppendString (m_options.m_one_liner.c_str());
-                result.AppendMessageWithFormat("Stop hook #%llu added.\n", new_hook_sp->GetID());
+                result.AppendMessageWithFormat("Stop hook #%" PRIu64 " added.\n", new_hook_sp->GetID());
             }
             else
             {
@@ -4603,17 +5123,17 @@ private:
 OptionDefinition
 CommandObjectTargetStopHookAdd::CommandOptions::g_option_table[] =
 {
-    { LLDB_OPT_SET_ALL, false, "one-liner", 'o', required_argument, NULL, NULL, eArgTypeOneLiner,
+    { LLDB_OPT_SET_ALL, false, "one-liner", 'o', required_argument, NULL, 0, eArgTypeOneLiner,
         "Specify a one-line breakpoint command inline. Be sure to surround it with quotes." },
     { LLDB_OPT_SET_ALL, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName,
         "Set the module within which the stop-hook is to be run."},
-    { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, NULL, eArgTypeThreadIndex,
+    { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex,
         "The stop hook is run only for the thread whose index matches this argument."},
-    { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, NULL, eArgTypeThreadID,
+    { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, 0, eArgTypeThreadID,
         "The stop hook is run only for the thread whose TID matches this argument."},
-    { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, NULL, eArgTypeThreadName,
+    { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, 0, eArgTypeThreadName,
         "The stop hook is run only for the thread whose thread name matches this argument."},
-    { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, eArgTypeQueueName,
+    { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, 0, eArgTypeQueueName,
         "The stop hook is run only for threads in the queue whose name is given by this argument."},
     { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
         "Specify the source file within which the stop-hook is to be run." },
@@ -4621,7 +5141,7 @@ CommandObjectTargetStopHookAdd::CommandO
         "Set the start of the line range for which the stop-hook is to be run."},
     { LLDB_OPT_SET_1, false, "end-line", 'e', required_argument, NULL, 0, eArgTypeLineNum,
         "Set the end of the line range for which the stop-hook is to be run."},
-    { LLDB_OPT_SET_2, false, "classname", 'c', required_argument, NULL, NULL, eArgTypeClassName,
+    { LLDB_OPT_SET_2, false, "classname", 'c', required_argument, NULL, 0, eArgTypeClassName,
         "Specify the class within which the stop-hook is to be run." },
     { LLDB_OPT_SET_3, false, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
         "Set the function name within which the stop hook will be run." },

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectThread.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectThread.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectThread.cpp Thu Jun  6 19:06:43 2013
@@ -7,21 +7,25 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectThread.h"
 
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
-#include "lldb/Interpreter/Options.h"
+#include "lldb/lldb-private.h"
 #include "lldb/Core/State.h"
 #include "lldb/Core/SourceManager.h"
-
 #include "lldb/Host/Host.h"
-
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
-
+#include "lldb/Interpreter/Options.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/LineTable.h"
+#include "lldb/Symbol/LineEntry.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Target.h"
@@ -31,8 +35,7 @@
 #include "lldb/Target/ThreadPlanStepOut.h"
 #include "lldb/Target/ThreadPlanStepRange.h"
 #include "lldb/Target/ThreadPlanStepInRange.h"
-#include "lldb/Symbol/LineTable.h"
-#include "lldb/Symbol/LineEntry.h"
+
 
 using namespace lldb;
 using namespace lldb_private;
@@ -66,7 +69,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
@@ -122,10 +125,14 @@ public:
 
     CommandObjectThreadBacktrace (CommandInterpreter &interpreter) :
         CommandObjectParsed (interpreter,
-                           "thread backtrace",
-                           "Show the stack for one or more threads.  If no threads are specified, show the currently selected thread.  Use the thread-index \"all\" to see all threads.",
-                           NULL,
-                           eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+                             "thread backtrace",
+                             "Show the stack for one or more threads.  If no threads are specified, show the currently selected thread.  Use the thread-index \"all\" to see all threads.",
+                             NULL,
+                             eFlagRequiresProcess       |
+                             eFlagRequiresThread        |
+                             eFlagTryTargetAPILock      |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused   ),
         m_options(interpreter)
     {
         CommandArgumentEntry arg;
@@ -163,28 +170,20 @@ protected:
         const uint32_t num_frames_with_source = 0;
         if (command.GetArgumentCount() == 0)
         {
-            ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-            Thread *thread = exe_ctx.GetThreadPtr();
-            if (thread)
-            {
-                // Thread::GetStatus() returns the number of frames shown.
-                if (thread->GetStatus (strm,
-                                       m_options.m_start,
-                                       m_options.m_count,
-                                       num_frames_with_source))
-                {
-                    result.SetStatus (eReturnStatusSuccessFinishResult);
-                }
-            }
-            else
+            Thread *thread = m_exe_ctx.GetThreadPtr();
+            // Thread::GetStatus() returns the number of frames shown.
+            if (thread->GetStatus (strm,
+                                   m_options.m_start,
+                                   m_options.m_count,
+                                   num_frames_with_source))
             {
-                result.AppendError ("invalid thread");
-                result.SetStatus (eReturnStatusFailed);
+                result.SetStatus (eReturnStatusSuccessFinishResult);
             }
         }
         else if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0)
         {
-            Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+            Process *process = m_exe_ctx.GetProcessPtr();
+            Mutex::Locker locker (process->GetThreadList().GetMutex());
             uint32_t num_threads = process->GetThreadList().GetSize();
             for (uint32_t i = 0; i < num_threads; i++)
             {
@@ -206,11 +205,12 @@ protected:
         }
         else
         {
-            uint32_t num_args = command.GetArgumentCount();
-            Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+            const size_t num_args = command.GetArgumentCount();
+            Process *process = m_exe_ctx.GetProcessPtr();
+            Mutex::Locker locker (process->GetThreadList().GetMutex());
             std::vector<ThreadSP> thread_sps;
 
-            for (uint32_t i = 0; i < num_args; i++)
+            for (size_t i = 0; i < num_args; i++)
             {
                 bool success;
                 
@@ -293,7 +293,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
@@ -320,6 +320,13 @@ public:
                 }
                 break;
 
+            case 't':
+                {
+                    m_step_in_target.clear();
+                    m_step_in_target.assign(option_arg);
+
+                }
+                break;
             default:
                 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
                 break;
@@ -334,6 +341,7 @@ public:
             m_avoid_no_debug = true;
             m_run_mode = eOnlyDuringStepping;
             m_avoid_regexp.clear();
+            m_step_in_target.clear();
         }
 
         const OptionDefinition*
@@ -350,16 +358,21 @@ public:
         bool m_avoid_no_debug;
         RunMode m_run_mode;
         std::string m_avoid_regexp;
+        std::string m_step_in_target;
     };
 
     CommandObjectThreadStepWithTypeAndScope (CommandInterpreter &interpreter,
                                              const char *name,
                                              const char *help,
                                              const char *syntax,
-                                             uint32_t flags,
                                              StepType step_type,
                                              StepScope step_scope) :
-        CommandObjectParsed (interpreter, name, help, syntax, flags),
+        CommandObjectParsed (interpreter, name, help, syntax,
+                             eFlagRequiresProcess       |
+                             eFlagRequiresThread        |
+                             eFlagTryTargetAPILock      |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused   ),
         m_step_type (step_type),
         m_step_scope (step_scope),
         m_options (interpreter)
@@ -394,164 +407,161 @@ protected:
     virtual bool
     DoExecute (Args& command, CommandReturnObject &result)
     {
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+        Process *process = m_exe_ctx.GetProcessPtr();
         bool synchronous_execution = m_interpreter.GetSynchronous();
 
-        if (process == NULL)
-        {
-            result.AppendError ("need a valid process to step");
-            result.SetStatus (eReturnStatusFailed);
+        const uint32_t num_threads = process->GetThreadList().GetSize();
+        Thread *thread = NULL;
 
+        if (command.GetArgumentCount() == 0)
+        {
+            thread = process->GetThreadList().GetSelectedThread().get();
+            if (thread == NULL)
+            {
+                result.AppendError ("no selected thread in process");
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            }
         }
         else
         {
-            const uint32_t num_threads = process->GetThreadList().GetSize();
-            Thread *thread = NULL;
-
-            if (command.GetArgumentCount() == 0)
+            const char *thread_idx_cstr = command.GetArgumentAtIndex(0);
+            uint32_t step_thread_idx = Args::StringToUInt32 (thread_idx_cstr, LLDB_INVALID_INDEX32);
+            if (step_thread_idx == LLDB_INVALID_INDEX32)
             {
-                thread = process->GetThreadList().GetSelectedThread().get();
-                if (thread == NULL)
-                {
-                    result.AppendError ("no selected thread in process");
-                    result.SetStatus (eReturnStatusFailed);
-                    return false;
-                }
+                result.AppendErrorWithFormat ("invalid thread index '%s'.\n", thread_idx_cstr);
+                result.SetStatus (eReturnStatusFailed);
+                return false;
             }
-            else
+            thread = process->GetThreadList().FindThreadByIndexID(step_thread_idx).get();
+            if (thread == NULL)
             {
-                const char *thread_idx_cstr = command.GetArgumentAtIndex(0);
-                uint32_t step_thread_idx = Args::StringToUInt32 (thread_idx_cstr, LLDB_INVALID_INDEX32);
-                if (step_thread_idx == LLDB_INVALID_INDEX32)
-                {
-                    result.AppendErrorWithFormat ("invalid thread index '%s'.\n", thread_idx_cstr);
-                    result.SetStatus (eReturnStatusFailed);
-                    return false;
-                }
-                thread = process->GetThreadList().FindThreadByIndexID(step_thread_idx).get();
-                if (thread == NULL)
-                {
-                    result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n", 
-                                                  step_thread_idx, num_threads);
-                    result.SetStatus (eReturnStatusFailed);
-                    return false;
-                }
+                result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n", 
+                                              step_thread_idx, num_threads);
+                result.SetStatus (eReturnStatusFailed);
+                return false;
             }
+        }
 
-            const bool abort_other_plans = false;
-            const lldb::RunMode stop_other_threads = m_options.m_run_mode;
-            
-            // This is a bit unfortunate, but not all the commands in this command object support
-            // only while stepping, so I use the bool for them.
-            bool bool_stop_other_threads;
-            if (m_options.m_run_mode == eAllThreads)
+        const bool abort_other_plans = false;
+        const lldb::RunMode stop_other_threads = m_options.m_run_mode;
+        
+        // This is a bit unfortunate, but not all the commands in this command object support
+        // only while stepping, so I use the bool for them.
+        bool bool_stop_other_threads;
+        if (m_options.m_run_mode == eAllThreads)
+            bool_stop_other_threads = false;
+        else if (m_options.m_run_mode == eOnlyDuringStepping)
+        {
+            if (m_step_type == eStepTypeOut)
                 bool_stop_other_threads = false;
             else
                 bool_stop_other_threads = true;
+        }
+        else
+            bool_stop_other_threads = true;
 
-            ThreadPlan *new_plan = NULL;
-            
-            if (m_step_type == eStepTypeInto)
-            {
-                StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
+        ThreadPlan *new_plan = NULL;
+        
+        if (m_step_type == eStepTypeInto)
+        {
+            StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
 
-                if (frame->HasDebugInformation ())
+            if (frame->HasDebugInformation ())
+            {
+                new_plan = thread->QueueThreadPlanForStepInRange (abort_other_plans,
+                                                                frame->GetSymbolContext(eSymbolContextEverything).line_entry.range, 
+                                                                frame->GetSymbolContext(eSymbolContextEverything),
+                                                                m_options.m_step_in_target.c_str(),
+                                                                stop_other_threads,
+                                                                m_options.m_avoid_no_debug);
+                if (new_plan && !m_options.m_avoid_regexp.empty())
                 {
-                    new_plan = thread->QueueThreadPlanForStepRange (abort_other_plans, m_step_type, 
-                                                                    frame->GetSymbolContext(eSymbolContextEverything).line_entry.range, 
-                                                                    frame->GetSymbolContext(eSymbolContextEverything), 
-                                                                    stop_other_threads,
-                                                                    m_options.m_avoid_no_debug);
-                    if (new_plan && !m_options.m_avoid_regexp.empty())
-                    {
-                        ThreadPlanStepInRange *step_in_range_plan = static_cast<ThreadPlanStepInRange *> (new_plan);
-                        step_in_range_plan->SetAvoidRegexp(m_options.m_avoid_regexp.c_str());
-                    }
+                    ThreadPlanStepInRange *step_in_range_plan = static_cast<ThreadPlanStepInRange *> (new_plan);
+                    step_in_range_plan->SetAvoidRegexp(m_options.m_avoid_regexp.c_str());
                 }
-                else
-                    new_plan = thread->QueueThreadPlanForStepSingleInstruction (false, abort_other_plans, bool_stop_other_threads);
-                    
             }
-            else if (m_step_type == eStepTypeOver)
-            {
-                StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
+            else
+                new_plan = thread->QueueThreadPlanForStepSingleInstruction (false, abort_other_plans, bool_stop_other_threads);
+                
+        }
+        else if (m_step_type == eStepTypeOver)
+        {
+            StackFrame *frame = thread->GetStackFrameAtIndex(0).get();
 
-                if (frame->HasDebugInformation())
-                    new_plan = thread->QueueThreadPlanForStepRange (abort_other_plans, 
-                                                                    m_step_type, 
+            if (frame->HasDebugInformation())
+                new_plan = thread->QueueThreadPlanForStepOverRange (abort_other_plans,
                                                                     frame->GetSymbolContext(eSymbolContextEverything).line_entry.range, 
                                                                     frame->GetSymbolContext(eSymbolContextEverything), 
-                                                                    stop_other_threads,
-                                                                    false);
-                else
-                    new_plan = thread->QueueThreadPlanForStepSingleInstruction (true, 
-                                                                                abort_other_plans, 
-                                                                                bool_stop_other_threads);
-
-            }
-            else if (m_step_type == eStepTypeTrace)
-            {
-                new_plan = thread->QueueThreadPlanForStepSingleInstruction (false, abort_other_plans, bool_stop_other_threads);
-            }
-            else if (m_step_type == eStepTypeTraceOver)
-            {
-                new_plan = thread->QueueThreadPlanForStepSingleInstruction (true, abort_other_plans, bool_stop_other_threads);
-            }
-            else if (m_step_type == eStepTypeOut)
-            {
-                new_plan = thread->QueueThreadPlanForStepOut (abort_other_plans, 
-                                                              NULL, 
-                                                              false, 
-                                                              bool_stop_other_threads, 
-                                                              eVoteYes, 
-                                                              eVoteNoOpinion, 
-                                                              thread->GetSelectedFrameIndex());
-            }
+                                                                    stop_other_threads);
             else
-            {
-                result.AppendError ("step type is not supported");
-                result.SetStatus (eReturnStatusFailed);
-                return false;
-            }
-            
-            // If we got a new plan, then set it to be a master plan (User level Plans should be master plans
-            // so that they can be interruptible).  Then resume the process.
-            
-            if (new_plan != NULL)
-            {
-                new_plan->SetIsMasterPlan (true);
-                new_plan->SetOkayToDiscard (false);
+                new_plan = thread->QueueThreadPlanForStepSingleInstruction (true, 
+                                                                            abort_other_plans, 
+                                                                            bool_stop_other_threads);
 
-                process->GetThreadList().SetSelectedThreadByID (thread->GetID());
-                process->Resume ();
-            
+        }
+        else if (m_step_type == eStepTypeTrace)
+        {
+            new_plan = thread->QueueThreadPlanForStepSingleInstruction (false, abort_other_plans, bool_stop_other_threads);
+        }
+        else if (m_step_type == eStepTypeTraceOver)
+        {
+            new_plan = thread->QueueThreadPlanForStepSingleInstruction (true, abort_other_plans, bool_stop_other_threads);
+        }
+        else if (m_step_type == eStepTypeOut)
+        {
+            new_plan = thread->QueueThreadPlanForStepOut (abort_other_plans, 
+                                                          NULL, 
+                                                          false, 
+                                                          bool_stop_other_threads, 
+                                                          eVoteYes, 
+                                                          eVoteNoOpinion, 
+                                                          thread->GetSelectedFrameIndex());
+        }
+        else
+        {
+            result.AppendError ("step type is not supported");
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
+        
+        // If we got a new plan, then set it to be a master plan (User level Plans should be master plans
+        // so that they can be interruptible).  Then resume the process.
+        
+        if (new_plan != NULL)
+        {
+            new_plan->SetIsMasterPlan (true);
+            new_plan->SetOkayToDiscard (false);
 
-                if (synchronous_execution)
-                {
-                    StateType state = process->WaitForProcessToStop (NULL);
-                    
-                    //EventSP event_sp;
-                    //StateType state = process->WaitForStateChangedEvents (NULL, event_sp);
-                    //while (! StateIsStoppedState (state))
-                    //  {
-                    //    state = process->WaitForStateChangedEvents (NULL, event_sp);
-                    //  }
-                    process->GetThreadList().SetSelectedThreadByID (thread->GetID());
-                    result.SetDidChangeProcessState (true);
-                    result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state));
-                    result.SetStatus (eReturnStatusSuccessFinishNoResult);
-                }
-                else
-                {
-                    result.SetStatus (eReturnStatusSuccessContinuingNoResult);
-                }
+            process->GetThreadList().SetSelectedThreadByID (thread->GetID());
+            process->Resume ();
+        
+
+            if (synchronous_execution)
+            {
+                StateType state = process->WaitForProcessToStop (NULL);
+                
+                //EventSP event_sp;
+                //StateType state = process->WaitForStateChangedEvents (NULL, event_sp);
+                //while (! StateIsStoppedState (state))
+                //  {
+                //    state = process->WaitForStateChangedEvents (NULL, event_sp);
+                //  }
+                process->GetThreadList().SetSelectedThreadByID (thread->GetID());
+                result.SetDidChangeProcessState (true);
+                result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
+                result.SetStatus (eReturnStatusSuccessFinishNoResult);
             }
             else
             {
-                result.AppendError ("Couldn't find thread plan to implement step type.");
-                result.SetStatus (eReturnStatusFailed);
+                result.SetStatus (eReturnStatusSuccessContinuingNoResult);
             }
         }
+        else
+        {
+            result.AppendError ("Couldn't find thread plan to implement step type.");
+            result.SetStatus (eReturnStatusFailed);
+        }
         return result.Succeeded();
     }
 
@@ -583,7 +593,8 @@ CommandObjectThreadStepWithTypeAndScope:
 {
 { LLDB_OPT_SET_1, false, "avoid-no-debug",  'a', required_argument, NULL,               0, eArgTypeBoolean,     "A boolean value that sets whether step-in will step over functions with no debug information."},
 { LLDB_OPT_SET_1, false, "run-mode",        'm', required_argument, g_tri_running_mode, 0, eArgTypeRunMode, "Determine how to run other threads while stepping the current thread."},
-{ LLDB_OPT_SET_1, false, "step-over-regexp",'r', required_argument, NULL,               0, eArgTypeRegularExpression,   "A regular expression that defines function names to step over."},
+{ LLDB_OPT_SET_1, false, "step-over-regexp",'r', required_argument, NULL,               0, eArgTypeRegularExpression,   "A regular expression that defines function names to not to stop at when stepping in."},
+{ LLDB_OPT_SET_1, false, "step-in-target",  't', required_argument, NULL,               0, eArgTypeFunctionName,   "The name of the directly called function step in should stop at when stepping into."},
 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 
@@ -601,7 +612,10 @@ public:
                              "thread continue",
                              "Continue execution of one or more threads in an active process.",
                              NULL,
-                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+                             eFlagRequiresThread        |
+                             eFlagTryTargetAPILock      |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused)
     {
         CommandArgumentEntry arg;
         CommandArgumentData thread_idx_arg;
@@ -635,7 +649,7 @@ public:
             return false;
         }
 
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+        Process *process = m_exe_ctx.GetProcessPtr();
         if (process == NULL)
         {
             result.AppendError ("no process exists. Cannot continue");
@@ -713,7 +727,7 @@ public:
                             thread->SetResumeState (eStateSuspended);
                         }
                     }
-                    result.AppendMessageWithFormat ("in process %llu\n", process->GetID());
+                    result.AppendMessageWithFormat ("in process %" PRIu64 "\n", process->GetID());
                 }
             }
             else
@@ -731,7 +745,7 @@ public:
                     Thread *thread = process->GetThreadList().GetThreadAtIndex(idx).get();
                     if (thread == current_thread)
                     {
-                        result.AppendMessageWithFormat ("Resuming thread 0x%4.4llx in process %llu\n", thread->GetID(), process->GetID());
+                        result.AppendMessageWithFormat ("Resuming thread 0x%4.4" PRIx64 " in process %" PRIu64 "\n", thread->GetID(), process->GetID());
                         thread->SetResumeState (eStateRunning);
                     }
                     else
@@ -744,13 +758,13 @@ public:
             Error error (process->Resume());
             if (error.Success())
             {
-                result.AppendMessageWithFormat ("Process %llu resuming\n", process->GetID());
+                result.AppendMessageWithFormat ("Process %" PRIu64 " resuming\n", process->GetID());
                 if (synchronous_execution)
                 {
                     state = process->WaitForProcessToStop (NULL);
                     
                     result.SetDidChangeProcessState (true);
-                    result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state));
+                    result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
                     result.SetStatus (eReturnStatusSuccessFinishNoResult);
                 }
                 else
@@ -808,7 +822,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
@@ -881,7 +895,10 @@ public:
                              "thread until",
                              "Run the current or specified thread until it reaches a given line number or leaves the current function.",
                              NULL,
-                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+                             eFlagRequiresThread        |
+                             eFlagTryTargetAPILock      |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused   ),
         m_options (interpreter)
     {
         CommandArgumentEntry arg;
@@ -925,7 +942,7 @@ protected:
             return false;
         }
 
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+        Process *process = m_exe_ctx.GetProcessPtr();
         if (process == NULL)
         {
             result.AppendError ("need a valid process to step");
@@ -1051,7 +1068,7 @@ protected:
                                                                 &address_list.front(), 
                                                                 address_list.size(), 
                                                                 m_options.m_stop_others, 
-                                                                thread->GetSelectedFrameIndex ());
+                                                                m_options.m_frame_idx);
                 // User level plans should be master plans so they can be interrupted (e.g. by hitting a breakpoint)
                 // and other plans executed by the user (stepping around the breakpoint) and then a "continue"
                 // will resume the original plan.
@@ -1072,13 +1089,13 @@ protected:
             Error error (process->Resume ());
             if (error.Success())
             {
-                result.AppendMessageWithFormat ("Process %llu resuming\n", process->GetID());
+                result.AppendMessageWithFormat ("Process %" PRIu64 " resuming\n", process->GetID());
                 if (synchronous_execution)
                 {
                     StateType state = process->WaitForProcessToStop (NULL);
 
                     result.SetDidChangeProcessState (true);
-                    result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state));
+                    result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
                     result.SetStatus (eReturnStatusSuccessFinishNoResult);
                 }
                 else
@@ -1123,7 +1140,10 @@ public:
                              "thread select",
                              "Select a thread as the currently active thread.",
                              NULL,
-                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+                             eFlagRequiresProcess       |
+                             eFlagTryTargetAPILock      |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused   )
     {
         CommandArgumentEntry arg;
         CommandArgumentData thread_idx_arg;
@@ -1149,7 +1169,7 @@ protected:
     virtual bool
     DoExecute (Args& command, CommandReturnObject &result)
     {
-        Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
+        Process *process = m_exe_ctx.GetProcessPtr();
         if (process == NULL)
         {
             result.AppendError ("no process");
@@ -1173,17 +1193,9 @@ protected:
             return false;
         }
 
-        process->GetThreadList().SetSelectedThreadByID(new_thread->GetID());
+        process->GetThreadList().SetSelectedThreadByID(new_thread->GetID(), true);
         result.SetStatus (eReturnStatusSuccessFinishNoResult);
         
-        const uint32_t start_frame = 0;
-        const uint32_t num_frames = 1;
-        const uint32_t num_frames_with_source = 1;
-        new_thread->GetStatus (result.GetOutputStream(), 
-                               start_frame,
-                               num_frames,
-                               num_frames_with_source);
-
         return result.Succeeded();
     }
 
@@ -1204,7 +1216,10 @@ public:
                              "thread list",
                              "Show a summary of all current threads in a process.",
                              "thread list",
-                             eFlagProcessMustBeLaunched | eFlagProcessMustBePaused)
+                             eFlagRequiresProcess       |
+                             eFlagTryTargetAPILock      |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused   )
     {
     }
 
@@ -1218,28 +1233,233 @@ protected:
     {
         Stream &strm = result.GetOutputStream();
         result.SetStatus (eReturnStatusSuccessFinishNoResult);
-        ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-        Process *process = exe_ctx.GetProcessPtr();
-        if (process)
-        {
-            const bool only_threads_with_stop_reason = false;
-            const uint32_t start_frame = 0;
-            const uint32_t num_frames = 0;
-            const uint32_t num_frames_with_source = 0;
-            process->GetStatus(strm);
-            process->GetThreadStatus (strm, 
-                                      only_threads_with_stop_reason, 
-                                      start_frame,
-                                      num_frames,
-                                      num_frames_with_source);            
+        Process *process = m_exe_ctx.GetProcessPtr();
+        const bool only_threads_with_stop_reason = false;
+        const uint32_t start_frame = 0;
+        const uint32_t num_frames = 0;
+        const uint32_t num_frames_with_source = 0;
+        process->GetStatus(strm);
+        process->GetThreadStatus (strm, 
+                                  only_threads_with_stop_reason, 
+                                  start_frame,
+                                  num_frames,
+                                  num_frames_with_source);            
+        return result.Succeeded();
+    }
+};
+
+//-------------------------------------------------------------------------
+// CommandObjectThreadReturn
+//-------------------------------------------------------------------------
+
+class CommandObjectThreadReturn : public CommandObjectRaw
+{
+public:
+    class CommandOptions : public Options
+    {
+    public:
+
+        CommandOptions (CommandInterpreter &interpreter) :
+            Options (interpreter),
+            m_from_expression (false)
+        {
+            // Keep default values of all options in one place: OptionParsingStarting ()
+            OptionParsingStarting ();
         }
-        else
+
+        virtual
+        ~CommandOptions ()
+        {
+        }
+
+        virtual Error
+        SetOptionValue (uint32_t option_idx, const char *option_arg)
+        {
+            Error error;
+            const int short_option = m_getopt_table[option_idx].val;
+
+            switch (short_option)
+            {
+                case 'x':
+                {
+                    bool success;
+                    bool tmp_value = Args::StringToBoolean (option_arg, false, &success);
+                    if (success)
+                        m_from_expression = tmp_value;
+                    else
+                    {
+                        error.SetErrorStringWithFormat ("invalid boolean value '%s' for 'x' option", option_arg);
+                    }
+                }
+                break;
+                default:
+                    error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
+                    break;
+
+            }
+            return error;
+        }
+
+        void
+        OptionParsingStarting ()
+        {
+            m_from_expression = false;
+        }
+
+        const OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
+
+        bool m_from_expression;
+
+        // Options table: Required for subclasses of Options.
+
+        static OptionDefinition g_option_table[];
+
+        // Instance variables to hold the values for command options.
+    };
+
+    virtual
+    Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+
+    CommandObjectThreadReturn (CommandInterpreter &interpreter) :
+        CommandObjectRaw (interpreter,
+                          "thread return",
+                          "Return from the currently selected frame, short-circuiting execution of the frames below it, with an optional return value,"
+                          " or with the -x option from the innermost function evaluation.",
+                          "thread return",
+                          eFlagRequiresFrame         |
+                          eFlagTryTargetAPILock      |
+                          eFlagProcessMustBeLaunched |
+                          eFlagProcessMustBePaused   ),
+        m_options (interpreter)
+    {
+        CommandArgumentEntry arg;
+        CommandArgumentData expression_arg;
+
+        // Define the first (and only) variant of this arg.
+        expression_arg.arg_type = eArgTypeExpression;
+        expression_arg.arg_repetition = eArgRepeatOptional;
+
+        // There is only one variant this argument could be; put it into the argument entry.
+        arg.push_back (expression_arg);
+
+        // Push the data for the first argument into the m_arguments vector.
+        m_arguments.push_back (arg);
+        
+        
+    }
+    
+    ~CommandObjectThreadReturn()
+    {
+    }
+    
+protected:
+
+    bool DoExecute
+    (
+        const char *command,
+        CommandReturnObject &result
+    )
+    {
+        // I am going to handle this by hand, because I don't want you to have to say:
+        // "thread return -- -5".
+        if (command[0] == '-' && command[1] == 'x')
         {
-            result.AppendError ("no current location or status available");
+            if (command && command[2] != '\0')
+                result.AppendWarning("Return values ignored when returning from user called expressions");
+            
+            Thread *thread = m_exe_ctx.GetThreadPtr();
+            Error error;
+            error = thread->UnwindInnermostExpression();
+            if (!error.Success())
+            {
+                result.AppendErrorWithFormat ("Unwinding expression failed - %s.", error.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+            }
+            else
+            {
+                bool success = thread->SetSelectedFrameByIndexNoisily (0, result.GetOutputStream());
+                if (success)
+                {
+                    m_exe_ctx.SetFrameSP(thread->GetSelectedFrame ());
+                    result.SetStatus (eReturnStatusSuccessFinishResult);
+                }
+                else
+                {
+                    result.AppendErrorWithFormat ("Could not select 0th frame after unwinding expression.");
+                    result.SetStatus (eReturnStatusFailed);
+                }
+            }
+            return result.Succeeded();
+        }
+        
+        ValueObjectSP return_valobj_sp;
+        
+        StackFrameSP frame_sp = m_exe_ctx.GetFrameSP();
+        uint32_t frame_idx = frame_sp->GetFrameIndex();
+        
+        if (frame_sp->IsInlined())
+        {
+            result.AppendError("Don't know how to return from inlined frames.");
             result.SetStatus (eReturnStatusFailed);
+            return false;
         }
-        return result.Succeeded();
+        
+        if (command && command[0] != '\0')
+        {
+            Target *target = m_exe_ctx.GetTargetPtr();
+            EvaluateExpressionOptions options;
+
+            options.SetUnwindOnError(true);
+            options.SetUseDynamic(eNoDynamicValues);
+            
+            ExecutionResults exe_results = eExecutionSetupError;
+            exe_results = target->EvaluateExpression (command,
+                                                      frame_sp.get(),
+                                                      return_valobj_sp,
+                                                      options);
+            if (exe_results != eExecutionCompleted)
+            {
+                if (return_valobj_sp)
+                    result.AppendErrorWithFormat("Error evaluating result expression: %s", return_valobj_sp->GetError().AsCString());
+                else
+                    result.AppendErrorWithFormat("Unknown error evaluating result expression.");
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            
+            }
+        }
+                
+        Error error;
+        ThreadSP thread_sp = m_exe_ctx.GetThreadSP();
+        const bool broadcast = true;
+        error = thread_sp->ReturnFromFrame (frame_sp, return_valobj_sp, broadcast);
+        if (!error.Success())
+        {
+            result.AppendErrorWithFormat("Error returning from frame %d of thread %d: %s.", frame_idx, thread_sp->GetIndexID(), error.AsCString());
+            result.SetStatus (eReturnStatusFailed);
+            return false;
+        }
+
+        result.SetStatus (eReturnStatusSuccessFinishResult);
+        return true;
     }
+    
+    CommandOptions m_options;
+
+};
+OptionDefinition
+CommandObjectThreadReturn::CommandOptions::g_option_table[] =
+{
+{ LLDB_OPT_SET_ALL, false, "from-expression",  'x', no_argument, NULL,               0, eArgTypeNone,     "Return from the innermost expression evaluation."},
+{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 
 //-------------------------------------------------------------------------
@@ -1255,6 +1475,7 @@ CommandObjectMultiwordThread::CommandObj
     LoadSubCommand ("backtrace",  CommandObjectSP (new CommandObjectThreadBacktrace (interpreter)));
     LoadSubCommand ("continue",   CommandObjectSP (new CommandObjectThreadContinue (interpreter)));
     LoadSubCommand ("list",       CommandObjectSP (new CommandObjectThreadList (interpreter)));
+    LoadSubCommand ("return",     CommandObjectSP (new CommandObjectThreadReturn (interpreter)));
     LoadSubCommand ("select",     CommandObjectSP (new CommandObjectThreadSelect (interpreter)));
     LoadSubCommand ("until",      CommandObjectSP (new CommandObjectThreadUntil (interpreter)));
     LoadSubCommand ("step-in",    CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope (
@@ -1262,7 +1483,6 @@ CommandObjectMultiwordThread::CommandObj
                                                     "thread step-in",
                                                     "Source level single step in specified thread (current thread, if none specified).",
                                                     NULL,
-                                                    eFlagProcessMustBeLaunched | eFlagProcessMustBePaused,
                                                     eStepTypeInto,
                                                     eStepScopeSource)));
     
@@ -1271,7 +1491,6 @@ CommandObjectMultiwordThread::CommandObj
                                                     "thread step-out",
                                                     "Finish executing the function of the currently selected frame and return to its call site in specified thread (current thread, if none specified).",
                                                     NULL,
-                                                    eFlagProcessMustBeLaunched | eFlagProcessMustBePaused,
                                                     eStepTypeOut,
                                                     eStepScopeSource)));
 
@@ -1280,7 +1499,6 @@ CommandObjectMultiwordThread::CommandObj
                                                     "thread step-over",
                                                     "Source level single step in specified thread (current thread, if none specified), stepping over calls.",
                                                     NULL,
-                                                    eFlagProcessMustBeLaunched | eFlagProcessMustBePaused,
                                                     eStepTypeOver,
                                                     eStepScopeSource)));
 
@@ -1289,7 +1507,6 @@ CommandObjectMultiwordThread::CommandObj
                                                     "thread step-inst",
                                                     "Single step one instruction in specified thread (current thread, if none specified).",
                                                     NULL,
-                                                    eFlagProcessMustBeLaunched | eFlagProcessMustBePaused,
                                                     eStepTypeTrace,
                                                     eStepScopeInstruction)));
 
@@ -1298,7 +1515,6 @@ CommandObjectMultiwordThread::CommandObj
                                                     "thread step-inst-over",
                                                     "Single step one instruction in specified thread (current thread, if none specified), stepping over calls.",
                                                     NULL,
-                                                    eFlagProcessMustBeLaunched | eFlagProcessMustBePaused,
                                                     eStepTypeTraceOver,
                                                     eStepScopeInstruction)));
 }

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectType.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectType.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectType.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectType.h"
 
 // C Includes
@@ -15,13 +17,13 @@
 
 // C++ Includes
 
-#include "lldb/Core/DataVisualization.h"
 #include "lldb/Core/ConstString.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/InputReaderEZ.h"
 #include "lldb/Core/RegularExpression.h"
 #include "lldb/Core/State.h"
 #include "lldb/Core/StringList.h"
+#include "lldb/DataFormatters/DataVisualization.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandObject.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
@@ -59,7 +61,7 @@ public:
     {
     }
     
-    typedef STD_SHARED_PTR(ScriptAddOptions) SharedPointer;
+    typedef std::shared_ptr<ScriptAddOptions> SharedPointer;
     
 };
 
@@ -92,7 +94,7 @@ public:
     {
     }
     
-    typedef STD_SHARED_PTR(SynthAddOptions) SharedPointer;
+    typedef std::shared_ptr<SynthAddOptions> SharedPointer;
     
 };
 
@@ -177,7 +179,7 @@ public:
     }
     
     static bool
-    AddSummary(const ConstString& type_name,
+    AddSummary(ConstString type_name,
                lldb::TypeSummaryImplSP entry,
                SummaryFormatType type,
                std::string category,
@@ -209,7 +211,7 @@ private:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             bool success;
             
             switch (short_option)
@@ -322,7 +324,7 @@ public:
     }
     
     static bool
-    AddSynth(const ConstString& type_name,
+    AddSynth(ConstString type_name,
              lldb::SyntheticChildrenSP entry,
              SynthFormatType type,
              std::string category_name,
@@ -374,7 +376,7 @@ private:
                         const char *option_value)
         {
             Error error;
-            const char short_option = (char) g_option_table[option_idx].short_option;
+            const int short_option = g_option_table[option_idx].short_option;
             bool success;
             
             switch (short_option)
@@ -742,7 +744,9 @@ CommandObjectTypeFormatList_LoopCallback
 //-------------------------------------------------------------------------
 
 static const char *g_summary_addreader_instructions = "Enter your Python command(s). Type 'DONE' to end.\n"
-                                                       "def function (valobj,internal_dict):";
+                                                       "def function (valobj,internal_dict):\n"
+                                                       "     \"\"\"valobj: an SBValue which you want to provide a summary for\n"
+                                                       "        internal_dict: an LLDB support object not to be used\"\"\"";
 
 class TypeScriptAddInputReader : public InputReaderEZ
 {
@@ -816,7 +820,7 @@ public:
         ScriptAddOptions *options_ptr = ((ScriptAddOptions*)data.baton);
         if (!options_ptr)
         {
-            out_stream->Printf ("Internal error #1: no script attached.\n");
+            out_stream->Printf ("internal synchronization information missing or invalid.\n");
             out_stream->Flush();
             return;
         }
@@ -826,7 +830,7 @@ public:
         ScriptInterpreter *interpreter = data.reader.GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
         if (!interpreter)
         {
-            out_stream->Printf ("Internal error #2: no script attached.\n");
+            out_stream->Printf ("no script interpreter.\n");
             out_stream->Flush();
             return;
         }
@@ -834,13 +838,13 @@ public:
         if (!interpreter->GenerateTypeScriptFunction (options->m_user_source, 
                                                       funct_name_str))
         {
-            out_stream->Printf ("Internal error #3: no script attached.\n");
+            out_stream->Printf ("unable to generate a function.\n");
             out_stream->Flush();
             return;
         }
         if (funct_name_str.empty())
         {
-            out_stream->Printf ("Internal error #4: no script attached.\n");
+            out_stream->Printf ("unable to obtain a valid function name from the script interpreter.\n");
             out_stream->Flush();
             return;
         }
@@ -915,7 +919,7 @@ Error
 CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
 {
     Error error;
-    char short_option = (char) m_getopt_table[option_idx].val;
+    const int short_option = m_getopt_table[option_idx].val;
     bool success;
     
     switch (short_option)
@@ -1035,17 +1039,10 @@ CommandObjectTypeSummaryAdd::Execute_Scr
     
     if (!m_options.m_python_function.empty()) // we have a Python function ready to use
     {
-        ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
-        if (!interpreter)
-        {
-            result.AppendError ("Internal error #1N: no script attached.\n");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
         const char *funct_name = m_options.m_python_function.c_str();
         if (!funct_name || !funct_name[0])
         {
-            result.AppendError ("Internal error #2N: no script attached.\n");
+            result.AppendError ("function name empty.\n");
             result.SetStatus (eReturnStatusFailed);
             return false;
         }
@@ -1055,13 +1052,20 @@ CommandObjectTypeSummaryAdd::Execute_Scr
         script_format.reset(new ScriptSummaryFormat(m_options.m_flags,
                                                     funct_name,
                                                     code.c_str()));
+        
+        ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+        
+        if (interpreter && interpreter->CheckObjectExists(funct_name) == false)
+            result.AppendWarningWithFormat("The provided function \"%s\" does not exist - "
+                                           "please define it before attempting to use this summary.\n",
+                                           funct_name);
     }
     else if (!m_options.m_python_script.empty()) // we have a quick 1-line script, just use it
     {
         ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
         if (!interpreter)
         {
-            result.AppendError ("Internal error #1Q: no script attached.\n");
+            result.AppendError ("script interpreter missing - unable to generate function wrapper.\n");
             result.SetStatus (eReturnStatusFailed);
             return false;
         }
@@ -1071,13 +1075,13 @@ CommandObjectTypeSummaryAdd::Execute_Scr
         if (!interpreter->GenerateTypeScriptFunction (funct_sl, 
                                                       funct_name_str))
         {
-            result.AppendError ("Internal error #2Q: no script attached.\n");
+            result.AppendError ("unable to generate function wrapper.\n");
             result.SetStatus (eReturnStatusFailed);
             return false;
         }
         if (funct_name_str.empty())
         {
-            result.AppendError ("Internal error #3Q: no script attached.\n");
+            result.AppendError ("script interpreter failed to generate a valid function name.\n");
             result.SetStatus (eReturnStatusFailed);
             return false;
         }
@@ -1336,7 +1340,7 @@ CommandObjectTypeSummaryAdd::DoExecute (
 }
 
 bool
-CommandObjectTypeSummaryAdd::AddSummary(const ConstString& type_name,
+CommandObjectTypeSummaryAdd::AddSummary(ConstString type_name,
                                         TypeSummaryImplSP entry,
                                         SummaryFormatType type,
                                         std::string category_name,
@@ -1345,6 +1349,21 @@ CommandObjectTypeSummaryAdd::AddSummary(
     lldb::TypeCategoryImplSP category;
     DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()), category);
     
+    if (type == eRegularSummary)
+    {
+        std::string type_name_str(type_name.GetCString());
+        if (type_name_str.compare(type_name_str.length() - 2, 2, "[]") == 0)
+        {
+            type_name_str.resize(type_name_str.length()-2);
+            if (type_name_str.back() != ' ')
+                type_name_str.append(" \\[[0-9]+\\]");
+            else
+                type_name_str.append("\\[[0-9]+\\]");
+            type_name.SetCString(type_name_str.c_str());
+            type = eRegexSummary;
+        }
+    }
+    
     if (type == eRegexSummary)
     {
         RegularExpressionSP typeRX(new RegularExpression());
@@ -1417,7 +1436,7 @@ private:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
@@ -1580,7 +1599,7 @@ private:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
@@ -1724,7 +1743,7 @@ class CommandObjectTypeSummaryList : pub
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
@@ -1956,24 +1975,46 @@ protected:
             return false;
         }
         
-        for (int i = argc - 1; i >= 0; i--)
+        if (argc == 1 && strcmp(command.GetArgumentAtIndex(0),"*") == 0)
         {
-            const char* typeA = command.GetArgumentAtIndex(i);
-            ConstString typeCS(typeA);
-            
-            if (!typeCS)
+            // we want to make sure to enable "system" last and "default" first
+            DataVisualization::Categories::Enable(ConstString("default"), TypeCategoryMap::First);
+            uint32_t num_categories = DataVisualization::Categories::GetCount();
+            for (uint32_t i = 0; i < num_categories; i++)
             {
-                result.AppendError("empty category name not allowed");
-                result.SetStatus(eReturnStatusFailed);
-                return false;
+                lldb::TypeCategoryImplSP category_sp = DataVisualization::Categories::GetCategoryAtIndex(i);
+                if (category_sp)
+                {
+                    if ( ::strcmp(category_sp->GetName(), "system") == 0 ||
+                         ::strcmp(category_sp->GetName(), "default") == 0 )
+                        continue;
+                    else
+                        DataVisualization::Categories::Enable(category_sp, TypeCategoryMap::Default);
+                }
             }
-            DataVisualization::Categories::Enable(typeCS);
-            lldb::TypeCategoryImplSP cate;
-            if (DataVisualization::Categories::GetCategory(typeCS, cate) && cate.get())
+            DataVisualization::Categories::Enable(ConstString("system"), TypeCategoryMap::Last);
+        }
+        else
+        {
+            for (int i = argc - 1; i >= 0; i--)
             {
-                if (cate->GetCount() == 0)
+                const char* typeA = command.GetArgumentAtIndex(i);
+                ConstString typeCS(typeA);
+                
+                if (!typeCS)
+                {
+                    result.AppendError("empty category name not allowed");
+                    result.SetStatus(eReturnStatusFailed);
+                    return false;
+                }
+                DataVisualization::Categories::Enable(typeCS);
+                lldb::TypeCategoryImplSP cate;
+                if (DataVisualization::Categories::GetCategory(typeCS, cate) && cate.get())
                 {
-                    result.AppendWarning("empty category enabled (typo?)");
+                    if (cate->GetCount() == 0)
+                    {
+                        result.AppendWarning("empty category enabled (typo?)");
+                    }
                 }
             }
         }
@@ -2265,7 +2306,7 @@ class CommandObjectTypeFilterList : publ
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
@@ -2479,7 +2520,7 @@ class CommandObjectTypeSynthList : publi
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
@@ -2677,7 +2718,7 @@ private:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
@@ -2843,7 +2884,7 @@ private:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
@@ -3010,7 +3051,7 @@ private:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
@@ -3139,7 +3180,7 @@ private:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             
             switch (short_option)
             {
@@ -3329,7 +3370,7 @@ public:
         SynthAddOptions *options_ptr = ((SynthAddOptions*)data.baton);
         if (!options_ptr)
         {
-            out_stream->Printf ("Internal error #1: no script attached.\n");
+            out_stream->Printf ("internal synchronization data missing.\n");
             out_stream->Flush();
             return;
         }
@@ -3339,7 +3380,7 @@ public:
         ScriptInterpreter *interpreter = data.reader.GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
         if (!interpreter)
         {
-            out_stream->Printf ("Internal error #2: no script attached.\n");
+            out_stream->Printf ("no script interpreter.\n");
             out_stream->Flush();
             return;
         }
@@ -3347,13 +3388,13 @@ public:
         if (!interpreter->GenerateTypeSynthClass (options->m_user_source, 
                                                   class_name_str))
         {
-            out_stream->Printf ("Internal error #3: no script attached.\n");
+            out_stream->Printf ("unable to generate a class.\n");
             out_stream->Flush();
             return;
         }
         if (class_name_str.empty())
         {
-            out_stream->Printf ("Internal error #4: no script attached.\n");
+            out_stream->Printf ("unable to obtain a proper name for the class.\n");
             out_stream->Flush();
             return;
         }
@@ -3361,10 +3402,10 @@ public:
         // everything should be fine now, let's add the synth provider class
         
         SyntheticChildrenSP synth_provider;
-        synth_provider.reset(new TypeSyntheticImpl(SyntheticChildren::Flags().SetCascades(options->m_cascade).
-                                                         SetSkipPointers(options->m_skip_pointers).
-                                                         SetSkipReferences(options->m_skip_references),
-                                                         class_name_str.c_str()));
+        synth_provider.reset(new ScriptedSyntheticChildren(SyntheticChildren::Flags().SetCascades(options->m_cascade).
+                                                           SetSkipPointers(options->m_skip_pointers).
+                                                           SetSkipReferences(options->m_skip_references),
+                                                           class_name_str.c_str()));
         
         
         lldb::TypeCategoryImplSP category;
@@ -3391,7 +3432,7 @@ public:
             }
             else
             {
-                out_stream->Printf ("Internal error #6: no script attached.\n");
+                out_stream->Printf ("invalid type name.\n");
                 out_stream->Flush();
                 return;
             }
@@ -3480,14 +3521,19 @@ CommandObjectTypeSynthAdd::Execute_Pytho
     
     SyntheticChildrenSP entry;
     
-    TypeSyntheticImpl* impl = new TypeSyntheticImpl(SyntheticChildren::Flags().
-                                                    SetCascades(m_options.m_cascade).
-                                                    SetSkipPointers(m_options.m_skip_pointers).
-                                                    SetSkipReferences(m_options.m_skip_references),
-                                                    m_options.m_class_name.c_str());
+    ScriptedSyntheticChildren* impl = new ScriptedSyntheticChildren(SyntheticChildren::Flags().
+                                                                    SetCascades(m_options.m_cascade).
+                                                                    SetSkipPointers(m_options.m_skip_pointers).
+                                                                    SetSkipReferences(m_options.m_skip_references),
+                                                                    m_options.m_class_name.c_str());
     
     entry.reset(impl);
     
+    ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+    
+    if (interpreter && interpreter->CheckObjectExists(impl->GetPythonClassName()) == false)
+        result.AppendWarning("The provided class does not exist - please define it before attempting to use this synthetic provider");
+    
     // now I have a valid provider, let's add it to every type
     
     lldb::TypeCategoryImplSP category;
@@ -3544,15 +3590,30 @@ CommandObjectTypeSynthAdd::CommandObject
 }
 
 bool
-CommandObjectTypeSynthAdd::AddSynth(const ConstString& type_name,
-         SyntheticChildrenSP entry,
-         SynthFormatType type,
-         std::string category_name,
-         Error* error)
+CommandObjectTypeSynthAdd::AddSynth(ConstString type_name,
+                                    SyntheticChildrenSP entry,
+                                    SynthFormatType type,
+                                    std::string category_name,
+                                    Error* error)
 {
     lldb::TypeCategoryImplSP category;
     DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()), category);
     
+    if (type == eRegularSynth)
+    {
+        std::string type_name_str(type_name.GetCString());
+        if (type_name_str.compare(type_name_str.length() - 2, 2, "[]") == 0)
+        {
+            type_name_str.resize(type_name_str.length()-2);
+            if (type_name_str.back() != ' ')
+                type_name_str.append(" \\[[0-9]+\\]");
+            else
+                type_name_str.append("\\[[0-9]+\\]");
+            type_name.SetCString(type_name_str.c_str());
+            type = eRegularSynth;
+        }
+    }
+    
     if (category->AnyMatches(type_name,
                              eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter,
                              false))
@@ -3636,7 +3697,7 @@ private:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
             bool success;
             
             switch (short_option)
@@ -3723,7 +3784,7 @@ private:
     };
     
     bool
-    AddFilter(const ConstString& type_name,
+    AddFilter(ConstString type_name,
               SyntheticChildrenSP entry,
               FilterFormatType type,
               std::string category_name,
@@ -3732,6 +3793,21 @@ private:
         lldb::TypeCategoryImplSP category;
         DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()), category);
         
+        if (type == eRegularFilter)
+        {
+            std::string type_name_str(type_name.GetCString());
+            if (type_name_str.compare(type_name_str.length() - 2, 2, "[]") == 0)
+            {
+                type_name_str.resize(type_name_str.length()-2);
+                if (type_name_str.back() != ' ')
+                    type_name_str.append(" \\[[0-9]+\\]");
+                else
+                    type_name_str.append("\\[[0-9]+\\]");
+                type_name.SetCString(type_name_str.c_str());
+                type = eRegexFilter;
+            }
+        }
+        
         if (category->AnyMatches(type_name,
                                  eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth,
                                  false))
@@ -3799,9 +3875,9 @@ public:
                     "    int i;\n"
                     "} \n"
                     "Typing:\n"
-                    "type filter add --child a -- child g Foo\n"
+                    "type filter add --child a --child g Foo\n"
                     "frame variable a_foo\n"
-                    "will produce an output where only a and b are displayed\n"
+                    "will produce an output where only a and g are displayed\n"
                     "Other children of a_foo (b,c,d,e,f,h and i) are available by asking for them, as in:\n"
                     "frame variable a_foo.b a_foo.c ... a_foo.i\n"
                     "\n"

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectVersion.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectVersion.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectVersion.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectVersion.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectVersion.h"
 
 // C Includes

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectWatchpoint.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectWatchpoint.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectWatchpoint.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 #include "CommandObjectWatchpoint.h"
 #include "CommandObjectWatchpointCommand.h"
 
@@ -67,23 +69,6 @@ static inline void StripLeadingSpaces(ll
     while (!Str.empty() && isspace(Str[0]))
         Str = Str.substr(1);
 }
-static inline llvm::StringRef StripOptionTerminator(llvm::StringRef &Str, bool with_dash_w, bool with_dash_x)
-{
-    llvm::StringRef ExprStr = Str;
-
-    // Get rid of the leading spaces first.
-    StripLeadingSpaces(ExprStr);
-
-    // If there's no '-w' and no '-x', we can just return.
-    if (!with_dash_w && !with_dash_x)
-        return ExprStr;
-
-    // Otherwise, split on the "--" option terminator string, and return the rest of the string.
-    ExprStr = ExprStr.split("--").second;
-    StripLeadingSpaces(ExprStr);
-    return ExprStr;
-}
-
 
 // Equivalent class: {"-", "to", "To", "TO"} of range specifier array.
 static const char* RSA[4] = { "-", "to", "To", "TO" };
@@ -213,7 +198,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
@@ -642,7 +627,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
@@ -743,7 +728,7 @@ private:
 OptionDefinition
 CommandObjectWatchpointIgnore::CommandOptions::g_option_table[] =
 {
-    { LLDB_OPT_SET_ALL, true, "ignore-count", 'i', required_argument, NULL, NULL, eArgTypeCount, "Set the number of times this watchpoint is skipped before stopping." },
+    { LLDB_OPT_SET_ALL, true, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, "Set the number of times this watchpoint is skipped before stopping." },
     { 0,                false, NULL,            0 , 0,                 NULL, 0,    eArgTypeNone, NULL }
 };
 
@@ -799,7 +784,7 @@ public:
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
@@ -906,7 +891,7 @@ private:
 OptionDefinition
 CommandObjectWatchpointModify::CommandOptions::g_option_table[] =
 {
-{ LLDB_OPT_SET_ALL, false, "condition",    'c', required_argument, NULL, NULL, eArgTypeExpression, "The watchpoint stops only if this condition expression evaluates to true."},
+{ LLDB_OPT_SET_ALL, false, "condition",    'c', required_argument, NULL, 0, eArgTypeExpression, "The watchpoint stops only if this condition expression evaluates to true."},
 { 0,                false, NULL,            0 , 0,                 NULL, 0,    eArgTypeNone, NULL }
 };
 
@@ -932,7 +917,10 @@ public:
                              "If watchpoint setting fails, consider disable/delete existing ones "
                              "to free up resources.",
                              NULL,
-                            eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+                             eFlagRequiresFrame         |
+                             eFlagTryTargetAPILock      |
+                             eFlagProcessMustBeLaunched |
+                             eFlagProcessMustBePaused   ),
         m_option_group (interpreter),
         m_option_watchpoint ()
     {
@@ -970,19 +958,26 @@ public:
     }
 
 protected:
+    static size_t GetVariableCallback (void *baton,
+                                       const char *name,
+                                       VariableList &variable_list)
+    {
+        Target *target = static_cast<Target *>(baton);
+        if (target)
+        {
+            return target->GetImages().FindGlobalVariables (ConstString(name),
+                                                            true,
+                                                            UINT32_MAX,
+                                                            variable_list);
+        }
+        return 0;
+    }
+    
     virtual bool
-    DoExecute (Args& command,
-             CommandReturnObject &result)
+    DoExecute (Args& command, CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-        ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-        StackFrame *frame = exe_ctx.GetFramePtr();
-        if (frame == NULL)
-        {
-            result.AppendError ("you must be stopped in a valid stack frame to set a watchpoint.");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
+        StackFrame *frame = m_exe_ctx.GetFramePtr();
 
         // If no argument is present, issue an error message.  There's no way to set a watchpoint.
         if (command.GetArgumentCount() <= 0)
@@ -1008,7 +1003,8 @@ protected:
         Stream &output_stream = result.GetOutputStream();
 
         // A simple watch variable gesture allows only one argument.
-        if (command.GetArgumentCount() != 1) {
+        if (command.GetArgumentCount() != 1)
+        {
             result.GetErrorStream().Printf("error: specify exactly one variable to watch for\n");
             result.SetStatus(eReturnStatusFailed);
             return false;
@@ -1023,16 +1019,42 @@ protected:
                                                               expr_path_options,
                                                               var_sp,
                                                               error);
-        if (valobj_sp) {
+        
+        if (!valobj_sp)
+        {
+            // Not in the frame; let's check the globals.
+            
+            VariableList variable_list;
+            ValueObjectList valobj_list;
+            
+            Error error (Variable::GetValuesForVariableExpressionPath (command.GetArgumentAtIndex(0),
+                                                                       m_exe_ctx.GetBestExecutionContextScope(),
+                                                                       GetVariableCallback,
+                                                                       target,
+                                                                       variable_list,
+                                                                       valobj_list));
+            
+            if (valobj_list.GetSize())
+                valobj_sp = valobj_list.GetValueObjectAtIndex(0);
+        }
+        
+        ClangASTType type;
+        
+        if (valobj_sp)
+        {
             AddressType addr_type;
             addr = valobj_sp->GetAddressOf(false, &addr_type);
-            if (addr_type == eAddressTypeLoad) {
+            if (addr_type == eAddressTypeLoad)
+            {
                 // We're in business.
                 // Find out the size of this variable.
                 size = m_option_watchpoint.watch_size == 0 ? valobj_sp->GetByteSize()
                                                            : m_option_watchpoint.watch_size;
             }
-        } else {
+            type.SetClangType(valobj_sp->GetClangAST(), valobj_sp->GetClangType());
+        }
+        else
+        {
             const char *error_cstr = error.AsCString(NULL);
             if (error_cstr)
                 result.GetErrorStream().Printf("error: %s\n", error_cstr);
@@ -1045,25 +1067,26 @@ protected:
         // Now it's time to create the watchpoint.
         uint32_t watch_type = m_option_watchpoint.watch_type;
         error.Clear();
-        Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type, error).get();
-        if (wp) {
+        Watchpoint *wp = target->CreateWatchpoint(addr, size, &type, watch_type, error).get();
+        if (wp)
+        {
             wp->SetWatchSpec(command.GetArgumentAtIndex(0));
             wp->SetWatchVariable(true);
-            if (var_sp && var_sp->GetDeclaration().GetFile()) {
+            if (var_sp && var_sp->GetDeclaration().GetFile())
+            {
                 StreamString ss;
                 // True to show fullpath for declaration file.
                 var_sp->GetDeclaration().DumpStopContext(&ss, true);
                 wp->SetDeclInfo(ss.GetString());
             }
-            StreamString ss;
-            ValueObject::DumpValueObject(ss, valobj_sp.get());
-            wp->SetNewSnapshot(ss.GetString());
             output_stream.Printf("Watchpoint created: ");
             wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
             output_stream.EOL();
             result.SetStatus(eReturnStatusSuccessFinishResult);
-        } else {
-            result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%llx, size=%lu, variable expression='%s').\n",
+        }
+        else
+        {
+            result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%" PRIx64 ", size=%lu, variable expression='%s').\n",
                                          addr, size, command.GetArgumentAtIndex(0));
             if (error.AsCString(NULL))
                 result.AppendError(error.AsCString());
@@ -1100,7 +1123,10 @@ public:
                           "If watchpoint setting fails, consider disable/delete existing ones "
                           "to free up resources.",
                           NULL,
-                          eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
+                          eFlagRequiresFrame         |
+                          eFlagTryTargetAPILock      |
+                          eFlagProcessMustBeLaunched |
+                          eFlagProcessMustBePaused   ),
         m_option_group (interpreter),
         m_option_watchpoint ()
     {
@@ -1147,23 +1173,53 @@ protected:
     DoExecute (const char *raw_command, CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-        ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-        StackFrame *frame = exe_ctx.GetFramePtr();
-        if (frame == NULL)
-        {
-            result.AppendError ("you must be stopped in a valid stack frame to set a watchpoint.");
-            result.SetStatus (eReturnStatusFailed);
-            return false;
-        }
+        StackFrame *frame = m_exe_ctx.GetFramePtr();
 
         Args command(raw_command);
+        const char *expr = NULL;
+        if (raw_command[0] == '-')
+        {
+            // We have some options and these options MUST end with --.
+            const char *end_options = NULL;
+            const char *s = raw_command;
+            while (s && s[0])
+            {
+                end_options = ::strstr (s, "--");
+                if (end_options)
+                {
+                    end_options += 2; // Get past the "--"
+                    if (::isspace (end_options[0]))
+                    {
+                        expr = end_options;
+                        while (::isspace (*expr))
+                            ++expr;
+                        break;
+                    }
+                }
+                s = end_options;
+            }
+            
+            if (end_options)
+            {
+                Args args (raw_command, end_options - raw_command);
+                if (!ParseOptions (args, result))
+                    return false;
+                
+                Error error (m_option_group.NotifyOptionParsingFinished());
+                if (error.Fail())
+                {
+                    result.AppendError (error.AsCString());
+                    result.SetStatus (eReturnStatusFailed);
+                    return false;
+                }
+            }
+        }
 
-        // Process possible options.
-        if (!ParseOptions (command, result))
-            return false;
+        if (expr == NULL)
+            expr = raw_command;
 
         // If no argument is present, issue an error message.  There's no way to set a watchpoint.
-        if (command.GetArgumentCount() <= 0)
+        if (command.GetArgumentCount() == 0)
         {
             result.GetErrorStream().Printf("error: required argument missing; specify an expression to evaulate into the addres to watch for\n");
             result.SetStatus(eReturnStatusFailed);
@@ -1184,38 +1240,24 @@ protected:
         lldb::addr_t addr = 0;
         size_t size = 0;
 
-        VariableSP var_sp;
         ValueObjectSP valobj_sp;
-        Stream &output_stream = result.GetOutputStream();
-
-        // We will process the raw command string to rid of the '-w', '-x', or '--'
-        llvm::StringRef raw_expr_str(raw_command);
-        std::string expr_str = StripOptionTerminator(raw_expr_str, with_dash_w, with_dash_x).str();
-
-        // Sanity check for when the user forgets to terminate the option strings with a '--'.
-        if ((with_dash_w || with_dash_w) && expr_str.empty())
-        {
-            result.GetErrorStream().Printf("error: did you forget to enter the option terminator string \"--\"?\n");
-            result.SetStatus(eReturnStatusFailed);
-            return false;
-        }
 
         // Use expression evaluation to arrive at the address to watch.
-        const bool coerce_to_id = true;
-        const bool unwind_on_error = true;
-        const bool keep_in_memory = false;
-        ExecutionResults expr_result = target->EvaluateExpression (expr_str.c_str(), 
+        EvaluateExpressionOptions options;
+        options.SetCoerceToId(false)
+        .SetUnwindOnError(true)
+        .SetKeepInMemory(false)
+        .SetRunOthers(true)
+        .SetTimeoutUsec(0);
+        
+        ExecutionResults expr_result = target->EvaluateExpression (expr, 
                                                                    frame, 
-                                                                   eExecutionPolicyOnlyWhenNeeded,
-                                                                   coerce_to_id,
-                                                                   unwind_on_error, 
-                                                                   keep_in_memory, 
-                                                                   eNoDynamicValues, 
                                                                    valobj_sp,
-                                                                   0 /* no timeout */);
-        if (expr_result != eExecutionCompleted) {
+                                                                   options);
+        if (expr_result != eExecutionCompleted)
+        {
             result.GetErrorStream().Printf("error: expression evaluation of address to watch failed\n");
-            result.GetErrorStream().Printf("expression evaluated: %s\n", expr_str.c_str());
+            result.GetErrorStream().Printf("expression evaluated: %s\n", expr);
             result.SetStatus(eReturnStatusFailed);
             return false;
         }
@@ -1223,7 +1265,8 @@ protected:
         // Get the address to watch.
         bool success = false;
         addr = valobj_sp->GetValueAsUnsigned(0, &success);
-        if (!success) {
+        if (!success)
+        {
             result.GetErrorStream().Printf("error: expression did not evaluate to an address\n");
             result.SetStatus(eReturnStatusFailed);
             return false;
@@ -1233,26 +1276,26 @@ protected:
 
         // Now it's time to create the watchpoint.
         uint32_t watch_type = m_option_watchpoint.watch_type;
+        
+        // Fetch the type from the value object, the type of the watched object is the pointee type
+        /// of the expression, so convert to that if we  found a valid type.
+        ClangASTType type(valobj_sp->GetClangAST(), valobj_sp->GetClangType());
+        if (type.IsValid())
+            type.SetClangType(type.GetASTContext(), type.GetPointeeType());
+        
         Error error;
-        Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type, error).get();
-        if (wp) {
-            if (var_sp && var_sp->GetDeclaration().GetFile()) {
-                StreamString ss;
-                // True to show fullpath for declaration file.
-                var_sp->GetDeclaration().DumpStopContext(&ss, true);
-                wp->SetDeclInfo(ss.GetString());
-            }
+        Watchpoint *wp = target->CreateWatchpoint(addr, size, &type, watch_type, error).get();
+        if (wp)
+        {
+            Stream &output_stream = result.GetOutputStream();
             output_stream.Printf("Watchpoint created: ");
-            uint64_t val = target->GetProcessSP()->ReadUnsignedIntegerFromMemory(addr, size, 0, error);
-            if (error.Success())
-                wp->SetNewSnapshotVal(val);
-            else
-                output_stream.Printf("watchpoint snapshot failed: %s", error.AsCString());
             wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
             output_stream.EOL();
             result.SetStatus(eReturnStatusSuccessFinishResult);
-        } else {
-            result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%llx, size=%lu).\n",
+        }
+        else
+        {
+            result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%" PRIx64 ", size=%lu).\n",
                                          addr, size);
             if (error.AsCString(NULL))
                 result.AppendError(error.AsCString());

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectWatchpointCommand.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectWatchpointCommand.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectWatchpointCommand.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectWatchpointCommand.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-python.h"
+
 // C Includes
 // C++ Includes
 
@@ -188,7 +190,7 @@ but do NOT enter more than one command p
                                              CommandReturnObject &result)
     {
         InputReaderSP reader_sp (new InputReader(m_interpreter.GetDebugger()));
-        std::auto_ptr<WatchpointOptions::CommandData> data_ap(new WatchpointOptions::CommandData());
+        std::unique_ptr<WatchpointOptions::CommandData> data_ap(new WatchpointOptions::CommandData());
         if (reader_sp && data_ap.get())
         {
             BatonSP baton_sp (new WatchpointOptions::CommandBaton (data_ap.release()));
@@ -224,7 +226,7 @@ but do NOT enter more than one command p
     SetWatchpointCommandCallback (WatchpointOptions *wp_options,
                                   const char *oneliner)
     {
-        std::auto_ptr<WatchpointOptions::CommandData> data_ap(new WatchpointOptions::CommandData());
+        std::unique_ptr<WatchpointOptions::CommandData> data_ap(new WatchpointOptions::CommandData());
 
         // It's necessary to set both user_source and script_source to the oneliner.
         // The former is used to generate callback description (as in watchpoint command list)
@@ -396,7 +398,7 @@ but do NOT enter more than one command p
         SetOptionValue (uint32_t option_idx, const char *option_arg)
         {
             Error error;
-            char short_option = (char) m_getopt_table[option_idx].val;
+            const int short_option = m_getopt_table[option_idx].val;
 
             switch (short_option)
             {
@@ -599,16 +601,16 @@ g_script_option_enumeration[4] =
 OptionDefinition
 CommandObjectWatchpointCommandAdd::CommandOptions::g_option_table[] =
 {
-    { LLDB_OPT_SET_1,   false, "one-liner",       'o', required_argument, NULL, NULL, eArgTypeOneLiner,
+    { LLDB_OPT_SET_1,   false, "one-liner",       'o', required_argument, NULL, 0, eArgTypeOneLiner,
         "Specify a one-line watchpoint command inline. Be sure to surround it with quotes." },
 
-    { LLDB_OPT_SET_ALL, false, "stop-on-error",   'e', required_argument, NULL, NULL, eArgTypeBoolean,
+    { LLDB_OPT_SET_ALL, false, "stop-on-error",   'e', required_argument, NULL, 0, eArgTypeBoolean,
         "Specify whether watchpoint command execution should terminate on error." },
 
-    { LLDB_OPT_SET_ALL, false, "script-type",     's', required_argument, g_script_option_enumeration, NULL, eArgTypeNone,
+    { LLDB_OPT_SET_ALL, false, "script-type",     's', required_argument, g_script_option_enumeration, 0, eArgTypeNone,
         "Specify the language for the commands - if none is specified, the lldb command interpreter will be used."},
 
-    { LLDB_OPT_SET_2,   false, "python-function", 'F', required_argument, NULL, NULL, eArgTypePythonFunction,
+    { LLDB_OPT_SET_2,   false, "python-function", 'F', required_argument, NULL, 0, eArgTypePythonFunction,
         "Give the name of a Python function to run as command for this watchpoint. Be sure to give a module name if appropriate."},
     
     { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
@@ -828,7 +830,6 @@ CommandObjectWatchpointCommand::CommandO
                             "A set of commands for adding, removing and examining bits of code to be executed when the watchpoint is hit (watchpoint 'commmands').",
                             "command <sub-command> [<sub-command-options>] <watchpoint-id>")
 {
-    bool status;
     CommandObjectSP add_command_object (new CommandObjectWatchpointCommandAdd (interpreter));
     CommandObjectSP delete_command_object (new CommandObjectWatchpointCommandDelete (interpreter));
     CommandObjectSP list_command_object (new CommandObjectWatchpointCommandList (interpreter));
@@ -837,9 +838,9 @@ CommandObjectWatchpointCommand::CommandO
     delete_command_object->SetCommandName ("watchpoint command delete");
     list_command_object->SetCommandName ("watchpoint command list");
 
-    status = LoadSubCommand ("add",    add_command_object);
-    status = LoadSubCommand ("delete", delete_command_object);
-    status = LoadSubCommand ("list",   list_command_object);
+    LoadSubCommand ("add",    add_command_object);
+    LoadSubCommand ("delete", delete_command_object);
+    LoadSubCommand ("list",   list_command_object);
 }
 
 CommandObjectWatchpointCommand::~CommandObjectWatchpointCommand ()

Modified: lldb/branches/lldb-platform-work/source/Commands/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/Makefile?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/Makefile (original)
+++ lldb/branches/lldb-platform-work/source/Commands/Makefile Thu Jun  6 19:06:43 2013
@@ -12,3 +12,5 @@ LIBRARYNAME := lldbCommands
 BUILD_ARCHIVE = 1
 
 include $(LLDB_LEVEL)/Makefile
+
+EXTRA_OPTIONS += -Wno-four-char-constants
\ No newline at end of file

Modified: lldb/branches/lldb-platform-work/source/Core/Address.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Address.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Address.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Address.cpp Thu Jun  6 19:06:43 2013
@@ -10,7 +10,9 @@
 #include "lldb/Core/Address.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/Section.h"
+#include "lldb/Symbol/Block.h"
 #include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/Type.h"
 #include "lldb/Symbol/Variable.h"
 #include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/ExecutionContext.h"
@@ -84,7 +86,7 @@ ReadUIntMax64 (ExecutionContextScope *ex
         if (GetByteOrderAndAddressSize (exe_scope, address, byte_order, addr_size))
         {
             DataExtractor data (&buf, sizeof(buf), byte_order, addr_size);
-            uint32_t offset = 0;
+            lldb::offset_t offset = 0;
             uval64 = data.GetU64(&offset);
         }
         else
@@ -229,7 +231,7 @@ Address::operator= (const Address& rhs)
     if (this != &rhs)
     {
         m_section_wp = rhs.m_section_wp;
-        m_offset = rhs.m_offset;
+        m_offset = rhs.m_offset.load();
     }
     return *this;
 }
@@ -309,8 +311,15 @@ Address::GetLoadAddress (Target *target)
 }
 
 addr_t
-Address::GetCallableLoadAddress (Target *target) const
+Address::GetCallableLoadAddress (Target *target, bool is_indirect) const
 {
+    if (is_indirect && target) {
+        ProcessSP processSP = target->GetProcessSP();
+        Error error;
+        if (processSP.get())
+            return processSP->ResolveIndirectFunction(this, error);
+    }
+
     addr_t code_addr = GetLoadAddress (target);
 
     if (target)
@@ -382,7 +391,7 @@ Address::Dump (Stream *s, ExecutionConte
         if (section_sp)
         {
             section_sp->DumpName(s);
-            s->Printf (" + %llu", m_offset);
+            s->Printf (" + %" PRIu64, m_offset.load());
         }
         else
         {
@@ -463,7 +472,7 @@ Address::Dump (Stream *s, ExecutionConte
                                         s->PutCString(symbol_name);
                                         addr_t delta = file_Addr - symbol->GetAddress().GetFileAddress();
                                         if (delta)
-                                            s->Printf(" + %llu", delta);
+                                            s->Printf(" + %" PRIu64, delta);
                                         showed_info = true;
                                     }
                                 }
@@ -694,14 +703,14 @@ Address::Dump (Stream *s, ExecutionConte
                                                stop_if_block_is_inlined_function, 
                                                &variable_list);
                     
-                    uint32_t num_variables = variable_list.GetSize();
-                    for (uint32_t var_idx = 0; var_idx < num_variables; ++var_idx)
+                    const size_t num_variables = variable_list.GetSize();
+                    for (size_t var_idx = 0; var_idx < num_variables; ++var_idx)
                     {
                         Variable *var = variable_list.GetVariableAtIndex (var_idx).get();
                         if (var && var->LocationIsValidForAddress (*this))
                         {
                             s->Indent();
-                            s->Printf ("   Variable: id = {0x%8.8llx}, name = \"%s\", type= \"%s\", location =",
+                            s->Printf ("   Variable: id = {0x%8.8" PRIx64 "}, name = \"%s\", type= \"%s\", location =",
                                        var->GetID(),
                                        var->GetName().GetCString(),
                                        var->GetType()->GetName().GetCString());
@@ -760,7 +769,7 @@ Address::Dump (Stream *s, ExecutionConte
 uint32_t
 Address::CalculateSymbolContext (SymbolContext *sc, uint32_t resolve_scope) const
 {
-    sc->Clear();
+    sc->Clear(false);
     // Absolute addresses don't have enough information to reconstruct even their target.
 
     SectionSP section_sp (GetSection());
@@ -994,39 +1003,16 @@ lldb_private::operator> (const Address&
 bool
 lldb_private::operator== (const Address& a, const Address& rhs)
 {
-    return  a.GetSection() == rhs.GetSection() &&
-            a.GetOffset()  == rhs.GetOffset();
+    return  a.GetOffset()  == rhs.GetOffset() &&
+            a.GetSection() == rhs.GetSection();
 }
 // The operator != checks for exact inequality only (differing section, or
 // different offset)
 bool
 lldb_private::operator!= (const Address& a, const Address& rhs)
 {
-    return  a.GetSection() != rhs.GetSection() ||
-            a.GetOffset()  != rhs.GetOffset();
-}
-
-bool
-Address::IsLinkedAddress () const
-{
-    SectionSP section_sp (GetSection());
-    return section_sp && section_sp->GetLinkedSection();
-}
-
-
-void
-Address::ResolveLinkedAddress ()
-{
-    SectionSP section_sp (GetSection());
-    if (section_sp)
-    {
-        SectionSP linked_section_sp (section_sp->GetLinkedSection());
-        if (linked_section_sp)
-        {
-            m_offset += section_sp->GetLinkedOffset();
-            m_section_wp = linked_section_sp;
-        }
-    }
+    return  a.GetOffset()  != rhs.GetOffset() ||
+            a.GetSection() != rhs.GetSection();
 }
 
 AddressClass

Modified: lldb/branches/lldb-platform-work/source/Core/AddressRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/AddressRange.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/AddressRange.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/AddressRange.cpp Thu Jun  6 19:06:43 2013
@@ -196,7 +196,7 @@ AddressRange::Dump(Stream *s, Target *ta
 void
 AddressRange::DumpDebug (Stream *s) const
 {
-    s->Printf("%p: AddressRange section = %p, offset = 0x%16.16llx, byte_size = 0x%16.16llx\n", this, m_base_addr.GetSection().get(), m_base_addr.GetOffset(), GetByteSize());
+    s->Printf("%p: AddressRange section = %p, offset = 0x%16.16" PRIx64 ", byte_size = 0x%16.16" PRIx64 "\n", this, m_base_addr.GetSection().get(), m_base_addr.GetOffset(), GetByteSize());
 }
 //
 //bool

Modified: lldb/branches/lldb-platform-work/source/Core/AddressResolverFileLine.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/AddressResolverFileLine.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/AddressResolverFileLine.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/AddressResolverFileLine.cpp Thu Jun  6 19:06:43 2013
@@ -12,6 +12,8 @@
 // Project includes
 #include "lldb/Core/Log.h"
 #include "lldb/Core/StreamString.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/SymbolContext.h"
 #include "lldb/lldb-private-log.h"
 
 using namespace lldb;
@@ -50,7 +52,7 @@ AddressResolverFileLine::SearchCallback
     uint32_t sc_list_size;
     CompileUnit *cu = context.comp_unit;
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
 
     sc_list_size = cu->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything,
                                              sc_list);
@@ -75,7 +77,7 @@ AddressResolverFileLine::SearchCallback
             else
             {
                 if (log)
-                  log->Printf ("error: Unable to resolve address at file address 0x%llx for %s:%d\n",
+                  log->Printf ("error: Unable to resolve address at file address 0x%" PRIx64 " for %s:%d\n",
                                line_start.GetFileAddress(),
                                m_file_spec.GetFilename().AsCString("<Unknown>"),
                                m_line_number);

Modified: lldb/branches/lldb-platform-work/source/Core/AddressResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/AddressResolverName.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/AddressResolverName.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/AddressResolverName.cpp Thu Jun  6 19:06:43 2013
@@ -11,8 +11,12 @@
 
 // Project includes
 #include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/StreamString.h"
 #include "lldb/Symbol/ClangNamespaceDecl.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/lldb-private-log.h"
 
 using namespace lldb;
@@ -33,7 +37,7 @@ AddressResolverName::AddressResolverName
     {
         if (!m_regex.Compile (m_func_name.AsCString()))
         {
-            LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+            Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
 
             if (log)
                 log->Warning ("function name regexp: \"%s\" did not compile.", m_func_name.AsCString());
@@ -94,7 +98,7 @@ AddressResolverName::SearchCallback
     SymbolContext sc;
     Address func_addr;
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
 
     if (m_class_name)
     {
@@ -116,7 +120,7 @@ AddressResolverName::SearchCallback
                                                            sym_list);
             context.module_sp->FindFunctions (m_func_name,
                                               NULL,
-                                              eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeMethod | eFunctionNameTypeSelector,
+                                              eFunctionNameTypeAuto,
                                               include_symbols,
                                               include_inlines,
                                               append, 

Modified: lldb/branches/lldb-platform-work/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ArchSpec.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ArchSpec.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ArchSpec.cpp Thu Jun  6 19:06:43 2013
@@ -10,6 +10,7 @@
 #include "lldb/Core/ArchSpec.h"
 
 #include <stdio.h>
+#include <errno.h>
 
 #include <string>
 
@@ -26,6 +27,9 @@ using namespace lldb_private;
 
 #define ARCH_SPEC_SEPARATOR_CHAR '-'
 
+
+static bool cores_match (const ArchSpec::Core core1, const ArchSpec::Core core2, bool try_inverse, bool enforce_exact_match);
+
 namespace lldb_private {
 
     struct CoreDefinition
@@ -53,8 +57,10 @@ static const CoreDefinition g_core_defin
     { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv6       , "armv6"     },
     { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv7       , "armv7"     },
     { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv7f      , "armv7f"    },
-    { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv7k      , "armv7k"    },
     { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv7s      , "armv7s"    },
+    { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv7k      , "armv7k"    },
+    { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv7m      , "armv7m"    },
+    { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv7em     , "armv7em"   },
     { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_xscale      , "xscale"    },
     { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb  , ArchSpec::eCore_thumb           , "thumb"     },
     { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb  , ArchSpec::eCore_thumbv4t        , "thumbv4t"  },
@@ -63,8 +69,10 @@ static const CoreDefinition g_core_defin
     { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb  , ArchSpec::eCore_thumbv6         , "thumbv6"   },
     { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb  , ArchSpec::eCore_thumbv7         , "thumbv7"   },
     { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb  , ArchSpec::eCore_thumbv7f        , "thumbv7f"  },
-    { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb  , ArchSpec::eCore_thumbv7k        , "thumbv7k"  },
     { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb  , ArchSpec::eCore_thumbv7s        , "thumbv7s"  },
+    { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb  , ArchSpec::eCore_thumbv7k        , "thumbv7k"  },
+    { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb  , ArchSpec::eCore_thumbv7m        , "thumbv7m"  },
+    { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb  , ArchSpec::eCore_thumbv7em       , "thumbv7em" },
     
     
     { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc    , ArchSpec::eCore_ppc_generic     , "ppc"       },
@@ -91,7 +99,9 @@ static const CoreDefinition g_core_defin
     { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86    , ArchSpec::eCore_x86_32_i486    , "i486"      },
     { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86    , ArchSpec::eCore_x86_32_i486sx  , "i486sx"    },
 
-    { eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64  , "x86_64"    }
+    { eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64  , "x86_64"    },
+    { eByteOrderLittle, 4, 4, 4 , llvm::Triple::UnknownArch , ArchSpec::eCore_uknownMach32  , "unknown-mach-32" },
+    { eByteOrderLittle, 8, 4, 4 , llvm::Triple::UnknownArch , ArchSpec::eCore_uknownMach64  , "unknown-mach-64" }
 };
 
 struct ArchDefinitionEntry
@@ -99,6 +109,8 @@ struct ArchDefinitionEntry
     ArchSpec::Core core;
     uint32_t cpu;
     uint32_t sub;
+    uint32_t cpu_mask;
+    uint32_t sub_mask;
 };
 
 struct ArchDefinition
@@ -106,13 +118,11 @@ struct ArchDefinition
     ArchitectureType type;
     size_t num_entries;
     const ArchDefinitionEntry *entries;
-    uint32_t cpu_mask;
-    uint32_t sub_mask;
     const char *name;
 };
 
 
-uint32_t
+size_t
 ArchSpec::AutoComplete (const char *name, StringList &matches)
 {
     uint32_t i;
@@ -141,60 +151,66 @@ ArchSpec::AutoComplete (const char *name
 // convert cpu type and subtypes to architecture names, and to convert
 // architecture names to cpu types and subtypes. The ordering is important and
 // allows the precedence to be set when the table is built.
+#define SUBTYPE_MASK 0x00FFFFFFu
 static const ArchDefinitionEntry g_macho_arch_entries[] =
 {
-    { ArchSpec::eCore_arm_generic     , llvm::MachO::CPUTypeARM       , CPU_ANY },
-    { ArchSpec::eCore_arm_generic     , llvm::MachO::CPUTypeARM       , 0       },
-    { ArchSpec::eCore_arm_armv4       , llvm::MachO::CPUTypeARM       , 5       },
-    { ArchSpec::eCore_arm_armv4t      , llvm::MachO::CPUTypeARM       , 5       },
-    { ArchSpec::eCore_arm_armv6       , llvm::MachO::CPUTypeARM       , 6       },
-    { ArchSpec::eCore_arm_armv5       , llvm::MachO::CPUTypeARM       , 7       },
-    { ArchSpec::eCore_arm_armv5e      , llvm::MachO::CPUTypeARM       , 7       },
-    { ArchSpec::eCore_arm_armv5t      , llvm::MachO::CPUTypeARM       , 7       },
-    { ArchSpec::eCore_arm_xscale      , llvm::MachO::CPUTypeARM       , 8       },
-    { ArchSpec::eCore_arm_armv7       , llvm::MachO::CPUTypeARM       , 9       },
-    { ArchSpec::eCore_arm_armv7f      , llvm::MachO::CPUTypeARM       , 10      },
-    { ArchSpec::eCore_arm_armv7k      , llvm::MachO::CPUTypeARM       , 12      },
-    { ArchSpec::eCore_arm_armv7s      , llvm::MachO::CPUTypeARM       , 11      },
-    { ArchSpec::eCore_thumb           , llvm::MachO::CPUTypeARM       , 0       },
-    { ArchSpec::eCore_thumbv4t        , llvm::MachO::CPUTypeARM       , 5       },
-    { ArchSpec::eCore_thumbv5         , llvm::MachO::CPUTypeARM       , 7       },
-    { ArchSpec::eCore_thumbv5e        , llvm::MachO::CPUTypeARM       , 7       },
-    { ArchSpec::eCore_thumbv6         , llvm::MachO::CPUTypeARM       , 6       },
-    { ArchSpec::eCore_thumbv7         , llvm::MachO::CPUTypeARM       , 9       },
-    { ArchSpec::eCore_thumbv7f        , llvm::MachO::CPUTypeARM       , 10      },
-    { ArchSpec::eCore_thumbv7k        , llvm::MachO::CPUTypeARM       , 12      },
-    { ArchSpec::eCore_thumbv7s        , llvm::MachO::CPUTypeARM       , 11      },
-    { ArchSpec::eCore_ppc_generic     , llvm::MachO::CPUTypePowerPC   , CPU_ANY },
-    { ArchSpec::eCore_ppc_generic     , llvm::MachO::CPUTypePowerPC   , 0       },
-    { ArchSpec::eCore_ppc_ppc601      , llvm::MachO::CPUTypePowerPC   , 1       },
-    { ArchSpec::eCore_ppc_ppc602      , llvm::MachO::CPUTypePowerPC   , 2       },
-    { ArchSpec::eCore_ppc_ppc603      , llvm::MachO::CPUTypePowerPC   , 3       },
-    { ArchSpec::eCore_ppc_ppc603e     , llvm::MachO::CPUTypePowerPC   , 4       },
-    { ArchSpec::eCore_ppc_ppc603ev    , llvm::MachO::CPUTypePowerPC   , 5       },
-    { ArchSpec::eCore_ppc_ppc604      , llvm::MachO::CPUTypePowerPC   , 6       },
-    { ArchSpec::eCore_ppc_ppc604e     , llvm::MachO::CPUTypePowerPC   , 7       },
-    { ArchSpec::eCore_ppc_ppc620      , llvm::MachO::CPUTypePowerPC   , 8       },
-    { ArchSpec::eCore_ppc_ppc750      , llvm::MachO::CPUTypePowerPC   , 9       },
-    { ArchSpec::eCore_ppc_ppc7400     , llvm::MachO::CPUTypePowerPC   , 10      },
-    { ArchSpec::eCore_ppc_ppc7450     , llvm::MachO::CPUTypePowerPC   , 11      },
-    { ArchSpec::eCore_ppc_ppc970      , llvm::MachO::CPUTypePowerPC   , 100     },
-    { ArchSpec::eCore_ppc64_generic   , llvm::MachO::CPUTypePowerPC64 , 0       },
-    { ArchSpec::eCore_ppc64_ppc970_64 , llvm::MachO::CPUTypePowerPC64 , 100     },
-    { ArchSpec::eCore_x86_32_i386     , llvm::MachO::CPUTypeI386      , 3       },
-    { ArchSpec::eCore_x86_32_i486     , llvm::MachO::CPUTypeI386      , 4       },
-    { ArchSpec::eCore_x86_32_i486sx   , llvm::MachO::CPUTypeI386      , 0x84    },
-    { ArchSpec::eCore_x86_32_i386     , llvm::MachO::CPUTypeI386      , CPU_ANY },
-    { ArchSpec::eCore_x86_64_x86_64   , llvm::MachO::CPUTypeX86_64    , 3       },
-    { ArchSpec::eCore_x86_64_x86_64   , llvm::MachO::CPUTypeX86_64    , 4       },
-    { ArchSpec::eCore_x86_64_x86_64   , llvm::MachO::CPUTypeX86_64    , CPU_ANY }
+    { ArchSpec::eCore_arm_generic     , llvm::MachO::CPUTypeARM       , CPU_ANY, UINT32_MAX , UINT32_MAX  },
+    { ArchSpec::eCore_arm_generic     , llvm::MachO::CPUTypeARM       , 0      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_arm_armv4       , llvm::MachO::CPUTypeARM       , 5      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_arm_armv4t      , llvm::MachO::CPUTypeARM       , 5      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_arm_armv6       , llvm::MachO::CPUTypeARM       , 6      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_arm_armv5       , llvm::MachO::CPUTypeARM       , 7      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_arm_armv5e      , llvm::MachO::CPUTypeARM       , 7      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_arm_armv5t      , llvm::MachO::CPUTypeARM       , 7      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_arm_xscale      , llvm::MachO::CPUTypeARM       , 8      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_arm_armv7       , llvm::MachO::CPUTypeARM       , 9      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_arm_armv7f      , llvm::MachO::CPUTypeARM       , 10     , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_arm_armv7s      , llvm::MachO::CPUTypeARM       , 11     , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_arm_armv7k      , llvm::MachO::CPUTypeARM       , 12     , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_arm_armv7m      , llvm::MachO::CPUTypeARM       , 15     , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_arm_armv7em     , llvm::MachO::CPUTypeARM       , 16     , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_thumb           , llvm::MachO::CPUTypeARM       , 0      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_thumbv4t        , llvm::MachO::CPUTypeARM       , 5      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_thumbv5         , llvm::MachO::CPUTypeARM       , 7      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_thumbv5e        , llvm::MachO::CPUTypeARM       , 7      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_thumbv6         , llvm::MachO::CPUTypeARM       , 6      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_thumbv7         , llvm::MachO::CPUTypeARM       , 9      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_thumbv7f        , llvm::MachO::CPUTypeARM       , 10     , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_thumbv7s        , llvm::MachO::CPUTypeARM       , 11     , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_thumbv7k        , llvm::MachO::CPUTypeARM       , 12     , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_thumbv7m        , llvm::MachO::CPUTypeARM       , 15     , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_thumbv7em       , llvm::MachO::CPUTypeARM       , 16     , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc_generic     , llvm::MachO::CPUTypePowerPC   , CPU_ANY, UINT32_MAX , UINT32_MAX  },
+    { ArchSpec::eCore_ppc_generic     , llvm::MachO::CPUTypePowerPC   , 0      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc_ppc601      , llvm::MachO::CPUTypePowerPC   , 1      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc_ppc602      , llvm::MachO::CPUTypePowerPC   , 2      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc_ppc603      , llvm::MachO::CPUTypePowerPC   , 3      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc_ppc603e     , llvm::MachO::CPUTypePowerPC   , 4      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc_ppc603ev    , llvm::MachO::CPUTypePowerPC   , 5      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc_ppc604      , llvm::MachO::CPUTypePowerPC   , 6      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc_ppc604e     , llvm::MachO::CPUTypePowerPC   , 7      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc_ppc620      , llvm::MachO::CPUTypePowerPC   , 8      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc_ppc750      , llvm::MachO::CPUTypePowerPC   , 9      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc_ppc7400     , llvm::MachO::CPUTypePowerPC   , 10     , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc_ppc7450     , llvm::MachO::CPUTypePowerPC   , 11     , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc_ppc970      , llvm::MachO::CPUTypePowerPC   , 100    , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc64_generic   , llvm::MachO::CPUTypePowerPC64 , 0      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_ppc64_ppc970_64 , llvm::MachO::CPUTypePowerPC64 , 100    , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_x86_32_i386     , llvm::MachO::CPUTypeI386      , 3      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_x86_32_i486     , llvm::MachO::CPUTypeI386      , 4      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_x86_32_i486sx   , llvm::MachO::CPUTypeI386      , 0x84   , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_x86_32_i386     , llvm::MachO::CPUTypeI386      , CPU_ANY, UINT32_MAX , UINT32_MAX  },
+    { ArchSpec::eCore_x86_64_x86_64   , llvm::MachO::CPUTypeX86_64    , 3      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_x86_64_x86_64   , llvm::MachO::CPUTypeX86_64    , 4      , UINT32_MAX , SUBTYPE_MASK },
+    { ArchSpec::eCore_x86_64_x86_64   , llvm::MachO::CPUTypeX86_64    , CPU_ANY, UINT32_MAX , UINT32_MAX  },
+    // Catch any unknown mach architectures so we can always use the object and symbol mach-o files
+    { ArchSpec::eCore_uknownMach32    , 0                             , 0      , 0xFF000000u, 0x00000000u },
+    { ArchSpec::eCore_uknownMach64    , llvm::MachO::CPUArchABI64     , 0      , 0xFF000000u, 0x00000000u }
 };
 static const ArchDefinition g_macho_arch_def = {
     eArchTypeMachO,
     sizeof(g_macho_arch_entries)/sizeof(g_macho_arch_entries[0]),
     g_macho_arch_entries,
-    UINT32_MAX,     // CPU type mask
-    0x00FFFFFFu,    // CPU subtype mask
     "mach-o"
 };
 
@@ -205,22 +221,20 @@ static const ArchDefinition g_macho_arch
 // allows the precedence to be set when the table is built.
 static const ArchDefinitionEntry g_elf_arch_entries[] =
 {
-    { ArchSpec::eCore_sparc_generic   , llvm::ELF::EM_SPARC  , LLDB_INVALID_CPUTYPE }, // Sparc
-    { ArchSpec::eCore_x86_32_i386     , llvm::ELF::EM_386    , LLDB_INVALID_CPUTYPE }, // Intel 80386
-    { ArchSpec::eCore_x86_32_i486     , llvm::ELF::EM_486    , LLDB_INVALID_CPUTYPE }, // Intel 486 (deprecated)
-    { ArchSpec::eCore_ppc_generic     , llvm::ELF::EM_PPC    , LLDB_INVALID_CPUTYPE }, // PowerPC
-    { ArchSpec::eCore_ppc64_generic   , llvm::ELF::EM_PPC64  , LLDB_INVALID_CPUTYPE }, // PowerPC64
-    { ArchSpec::eCore_arm_generic     , llvm::ELF::EM_ARM    , LLDB_INVALID_CPUTYPE }, // ARM
-    { ArchSpec::eCore_sparc9_generic  , llvm::ELF::EM_SPARCV9, LLDB_INVALID_CPUTYPE }, // SPARC V9
-    { ArchSpec::eCore_x86_64_x86_64   , llvm::ELF::EM_X86_64 , LLDB_INVALID_CPUTYPE }, // AMD64
+    { ArchSpec::eCore_sparc_generic   , llvm::ELF::EM_SPARC  , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // Sparc
+    { ArchSpec::eCore_x86_32_i386     , llvm::ELF::EM_386    , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // Intel 80386
+    { ArchSpec::eCore_x86_32_i486     , llvm::ELF::EM_486    , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // Intel 486 (deprecated)
+    { ArchSpec::eCore_ppc_generic     , llvm::ELF::EM_PPC    , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // PowerPC
+    { ArchSpec::eCore_ppc64_generic   , llvm::ELF::EM_PPC64  , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // PowerPC64
+    { ArchSpec::eCore_arm_generic     , llvm::ELF::EM_ARM    , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // ARM
+    { ArchSpec::eCore_sparc9_generic  , llvm::ELF::EM_SPARCV9, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // SPARC V9
+    { ArchSpec::eCore_x86_64_x86_64   , llvm::ELF::EM_X86_64 , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }  // AMD64
 };
 
 static const ArchDefinition g_elf_arch_def = {
     eArchTypeELF,
     sizeof(g_elf_arch_entries)/sizeof(g_elf_arch_entries[0]),
     g_elf_arch_entries,
-    UINT32_MAX,     // CPU type mask
-    UINT32_MAX,     // CPU subtype mask
     "elf",
 };
 
@@ -228,7 +242,7 @@ static const ArchDefinition g_elf_arch_d
 // Table of all ArchDefinitions
 static const ArchDefinition *g_arch_definitions[] = {
     &g_macho_arch_def,
-    &g_elf_arch_def,
+    &g_elf_arch_def
 };
 
 static const size_t k_num_arch_definitions =
@@ -278,14 +292,12 @@ FindArchDefinitionEntry (const ArchDefin
     if (def == NULL)
         return NULL;
 
-    const uint32_t cpu_mask = def->cpu_mask;
-    const uint32_t sub_mask = def->sub_mask;
     const ArchDefinitionEntry *entries = def->entries;
     for (size_t i = 0; i < def->num_entries; ++i)
     {
-        if ((entries[i].cpu == (cpu_mask & cpu)) &&
-            (entries[i].sub == (sub_mask & sub)))
-            return &entries[i];
+        if (entries[i].cpu == (cpu & entries[i].cpu_mask))
+            if (entries[i].sub == (sub & entries[i].sub_mask))
+                return &entries[i];
     }
     return NULL;
 }
@@ -483,49 +495,59 @@ ArchSpec::SetTriple (const llvm::Triple
     return IsValid();
 }
 
-bool
-ArchSpec::SetTriple (const char *triple_cstr)
+static bool
+ParseMachCPUDashSubtypeTriple (const char *triple_cstr, ArchSpec &arch)
 {
-    if (triple_cstr && triple_cstr[0])
+    // Accept "12-10" or "12.10" as cpu type/subtype
+    if (isdigit(triple_cstr[0]))
     {
-        if (isdigit(triple_cstr[0]))
-        {
-            // Accept "12-10" or "12.10" as cpu type/subtype
-            char *end = NULL;
-            uint32_t cpu = ::strtoul (triple_cstr, &end, 0);
-            if (cpu != 0 && end && ((*end == '-') || (*end == '.')))
+        char *end = NULL;
+        errno = 0;
+        uint32_t cpu = (uint32_t)::strtoul (triple_cstr, &end, 0);
+        if (errno == 0 && cpu != 0 && end && ((*end == '-') || (*end == '.')))
+        {
+            errno = 0;
+            uint32_t sub = (uint32_t)::strtoul (end + 1, &end, 0);
+            if (errno == 0 && end && ((*end == '-') || (*end == '.') || (*end == '\0')))
             {
-                uint32_t sub = ::strtoul (end + 1, &end, 0);
-                if (sub != 0 && end && ((*end == '-') || (*end == '.') || (*end == '\0')))
+                if (arch.SetArchitecture (eArchTypeMachO, cpu, sub))
                 {
-                    if (SetArchitecture (eArchTypeMachO, cpu, sub))
+                    if (*end == '-')
                     {
-                        if (*end == '-')
+                        llvm::StringRef vendor_os (end + 1);
+                        size_t dash_pos = vendor_os.find('-');
+                        if (dash_pos != llvm::StringRef::npos)
                         {
-                            llvm::StringRef vendor_os (end + 1);
-                            size_t dash_pos = vendor_os.find('-');
-                            if (dash_pos != llvm::StringRef::npos)
+                            llvm::StringRef vendor_str(vendor_os.substr(0, dash_pos));
+                            arch.GetTriple().setVendorName(vendor_str);
+                            const size_t vendor_start_pos = dash_pos+1;
+                            dash_pos = vendor_os.find('-', vendor_start_pos);
+                            if (dash_pos == llvm::StringRef::npos)
+                            {
+                                if (vendor_start_pos < vendor_os.size())
+                                    arch.GetTriple().setOSName(vendor_os.substr(vendor_start_pos));
+                            }
+                            else
                             {
-                                llvm::StringRef vendor_str(vendor_os.substr(0, dash_pos));
-                                m_triple.setVendorName(vendor_str);
-                                const size_t vendor_start_pos = dash_pos+1;
-                                dash_pos = vendor_os.find(vendor_start_pos, '-');
-                                if (dash_pos == llvm::StringRef::npos)
-                                {
-                                    if (vendor_start_pos < vendor_os.size())
-                                        m_triple.setOSName(vendor_os.substr(vendor_start_pos));
-                                }
-                                else
-                                {
-                                    m_triple.setOSName(vendor_os.substr(vendor_start_pos, dash_pos - vendor_start_pos));
-                                }
+                                arch.GetTriple().setOSName(vendor_os.substr(vendor_start_pos, dash_pos - vendor_start_pos));
                             }
                         }
-                        return true;
                     }
+                    return true;
                 }
             }
         }
+    }
+    return false;
+}
+bool
+ArchSpec::SetTriple (const char *triple_cstr)
+{
+    if (triple_cstr && triple_cstr[0])
+    {
+        if (ParseMachCPUDashSubtypeTriple (triple_cstr, *this))
+            return true;
+        
         llvm::StringRef triple_stref (triple_cstr);
         if (triple_stref.startswith (LLDB_ARCH_DEFAULT))
         {
@@ -554,6 +576,9 @@ ArchSpec::SetTriple (const char *triple_
 {
     if (triple_cstr && triple_cstr[0])
     {
+        if (ParseMachCPUDashSubtypeTriple (triple_cstr, *this))
+            return true;
+        
         llvm::StringRef triple_stref (triple_cstr);
         if (triple_stref.startswith (LLDB_ARCH_DEFAULT))
         {
@@ -587,7 +612,7 @@ ArchSpec::SetTriple (const char *triple_
                     // architecture. If this is not available (might not be
                     // connected) use the first supported architecture.
                     ArchSpec compatible_arch;
-                    if (platform->IsCompatibleArchitecture (raw_arch, &compatible_arch))
+                    if (platform->IsCompatibleArchitecture (raw_arch, false, &compatible_arch))
                     {
                         if (compatible_arch.IsValid())
                         {
@@ -697,6 +722,88 @@ ArchSpec::GetMaximumOpcodeByteSize() con
     return 0;
 }
 
+bool
+ArchSpec::IsExactMatch (const ArchSpec& rhs) const
+{
+    return IsEqualTo (rhs, true);
+}
+
+bool
+ArchSpec::IsCompatibleMatch (const ArchSpec& rhs) const
+{
+    return IsEqualTo (rhs, false);
+}
+
+bool
+ArchSpec::IsEqualTo (const ArchSpec& rhs, bool exact_match) const
+{
+    if (GetByteOrder() != rhs.GetByteOrder())
+        return false;
+        
+    const ArchSpec::Core lhs_core = GetCore ();
+    const ArchSpec::Core rhs_core = rhs.GetCore ();
+
+    const bool core_match = cores_match (lhs_core, rhs_core, true, exact_match);
+
+    if (core_match)
+    {
+        const llvm::Triple &lhs_triple = GetTriple();
+        const llvm::Triple &rhs_triple = rhs.GetTriple();
+
+        const llvm::Triple::VendorType lhs_triple_vendor = lhs_triple.getVendor();
+        const llvm::Triple::VendorType rhs_triple_vendor = rhs_triple.getVendor();
+        if (lhs_triple_vendor != rhs_triple_vendor)
+        {
+            if (exact_match)
+            {
+                const bool rhs_vendor_specified = rhs.TripleVendorWasSpecified();
+                const bool lhs_vendor_specified = TripleVendorWasSpecified();
+                // Both architectures had the vendor specified, so if they aren't
+                // equal then we return false
+                if (rhs_vendor_specified && lhs_vendor_specified)
+                    return false;
+            }
+            
+            // Only fail if both vendor types are not unknown
+            if (lhs_triple_vendor != llvm::Triple::UnknownVendor &&
+                rhs_triple_vendor != llvm::Triple::UnknownVendor)
+                return false;
+        }
+        
+        const llvm::Triple::OSType lhs_triple_os = lhs_triple.getOS();
+        const llvm::Triple::OSType rhs_triple_os = rhs_triple.getOS();
+        if (lhs_triple_os != rhs_triple_os)
+        {
+            if (exact_match)
+            {
+                const bool rhs_os_specified = rhs.TripleOSWasSpecified();
+                const bool lhs_os_specified = TripleOSWasSpecified();
+                // Both architectures had the OS specified, so if they aren't
+                // equal then we return false
+                if (rhs_os_specified && lhs_os_specified)
+                    return false;
+            }
+            // Only fail if both os types are not unknown
+            if (lhs_triple_os != llvm::Triple::UnknownOS &&
+                rhs_triple_os != llvm::Triple::UnknownOS)
+                return false;
+        }
+
+        const llvm::Triple::EnvironmentType lhs_triple_env = lhs_triple.getEnvironment();
+        const llvm::Triple::EnvironmentType rhs_triple_env = rhs_triple.getEnvironment();
+            
+        if (lhs_triple_env != rhs_triple_env)
+        {
+            // Only fail if both environment types are not unknown
+            if (lhs_triple_env != llvm::Triple::UnknownEnvironment &&
+                rhs_triple_env != llvm::Triple::UnknownEnvironment)
+                return false;
+        }
+        return true;
+    }
+    return false;
+}
+
 //===----------------------------------------------------------------------===//
 // Helper methods.
 
@@ -722,119 +829,13 @@ ArchSpec::CoreUpdated (bool update_tripl
 // Operators.
 
 static bool
-cores_match (const ArchSpec::Core core1, const ArchSpec::Core core2, bool try_inverse)
+cores_match (const ArchSpec::Core core1, const ArchSpec::Core core2, bool try_inverse, bool enforce_exact_match)
 {
+    if (core1 == core2)
+        return true;
+
     switch (core1)
     {
-//    case ArchSpec::eCore_arm_armv4:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_thumb)
-//            return true;
-//        break;
-//        
-//    case ArchSpec::eCore_arm_armv4t:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_thumbv4t)
-//            return true;
-//        break;
-//        
-//    case ArchSpec::eCore_arm_armv5:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_thumbv5)
-//            return true;
-//        break;
-//        
-//    case ArchSpec::eCore_arm_armv5t:
-//    case ArchSpec::eCore_arm_armv5e:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_thumbv5e)
-//            return true;
-//        break;
-//        
-//    case ArchSpec::eCore_arm_armv6:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_thumbv6)
-//            return true;
-//        break;
-//        
-//    case ArchSpec::eCore_arm_armv7:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_thumbv7)
-//            return true;
-//        break;
-//        
-//    case ArchSpec::eCore_arm_armv7f:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_thumbv7f)
-//            return true;
-//        break;
-//        
-//    case ArchSpec::eCore_arm_armv7k:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_thumbv7k)
-//            return true;
-//        break;
-//        
-//    case ArchSpec::eCore_arm_armv7s:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_thumbv7s)
-//            return true;
-//        break;
-//
-//    case ArchSpec::eCore_thumb:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_arm_armv4)
-//            return true;
-//        break;
-//
-//    case ArchSpec::eCore_thumbv4t:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_arm_armv4t)
-//            return true;
-//        break;
-//    
-//    case ArchSpec::eCore_thumbv5:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_arm_armv5)
-//            return true;
-//        break;
-//
-//    case ArchSpec::eCore_thumbv5e:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_arm_armv5t || core2 == ArchSpec::eCore_arm_armv5e)
-//            return true;
-//        break;
-//
-//    case ArchSpec::eCore_thumbv6:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_arm_armv6)
-//            return true;
-//        break;
-//
-//    case ArchSpec::eCore_thumbv7:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_arm_armv7)
-//            return true;
-//        break;
-//
-//    case ArchSpec::eCore_thumbv7f:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_arm_armv7f)
-//            return true;
-//        break;
-//
-//    case ArchSpec::eCore_thumbv7k:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_arm_armv7k)
-//            return true;
-//        break;
-//
-//    case ArchSpec::eCore_thumbv7s:
-//        try_inverse = false;
-//        if (core2 == ArchSpec::eCore_arm_armv7s)
-//            return true;
-//        break;
-    
     case ArchSpec::kCore_any:
         return true;
 
@@ -862,87 +863,28 @@ cores_match (const ArchSpec::Core core1,
             return true;
         break;
 
+    case ArchSpec::eCore_arm_armv7m:
+    case ArchSpec::eCore_arm_armv7em:
+    case ArchSpec::eCore_arm_armv7f:
+    case ArchSpec::eCore_arm_armv7k:
+    case ArchSpec::eCore_arm_armv7s:
+        if (!enforce_exact_match)
+        {
+            try_inverse = false;
+            if (core2 == ArchSpec::eCore_arm_armv7)
+                return true;
+        }
+        break;
+
     default:
         break;
     }
     if (try_inverse)
-        return cores_match (core2, core1, false);
-    return false;
-}
-
-bool
-lldb_private::operator== (const ArchSpec& lhs, const ArchSpec& rhs)
-{
-    if (lhs.GetByteOrder() != rhs.GetByteOrder())
-        return false;
-        
-    const ArchSpec::Core lhs_core = lhs.GetCore ();
-    const ArchSpec::Core rhs_core = rhs.GetCore ();
-
-    // Check if the cores match, or check a little closer watching for wildcard
-    // and equivalent cores
-    const bool core_match = (lhs_core == rhs_core) || cores_match (lhs_core, rhs_core, true);
-
-    if (core_match)
-    {
-        const llvm::Triple &lhs_triple = lhs.GetTriple();
-        const llvm::Triple &rhs_triple = rhs.GetTriple();
-
-        const llvm::Triple::VendorType lhs_triple_vendor = lhs_triple.getVendor();
-        const llvm::Triple::VendorType rhs_triple_vendor = rhs_triple.getVendor();
-        if (lhs_triple_vendor != rhs_triple_vendor)
-        {
-            const bool rhs_vendor_specified = rhs.TripleVendorWasSpecified();
-            const bool lhs_vendor_specified = lhs.TripleVendorWasSpecified();
-            // Both architectures had the vendor specified, so if they aren't
-            // equal then we return false
-            if (rhs_vendor_specified && lhs_vendor_specified)
-                return false;
-            
-            // Only fail if both vendor types are not unknown
-            if (lhs_triple_vendor != llvm::Triple::UnknownVendor &&
-                rhs_triple_vendor != llvm::Triple::UnknownVendor)
-                return false;
-        }
-        
-        const llvm::Triple::OSType lhs_triple_os = lhs_triple.getOS();
-        const llvm::Triple::OSType rhs_triple_os = rhs_triple.getOS();
-        if (lhs_triple_os != rhs_triple_os)
-        {
-            const bool rhs_os_specified = rhs.TripleOSWasSpecified();
-            const bool lhs_os_specified = lhs.TripleOSWasSpecified();
-            // Both architectures had the OS specified, so if they aren't
-            // equal then we return false
-            if (rhs_os_specified && lhs_os_specified)
-                return false;
-            // Only fail if both os types are not unknown
-            if (lhs_triple_os != llvm::Triple::UnknownOS &&
-                rhs_triple_os != llvm::Triple::UnknownOS)
-                return false;
-        }
-
-        const llvm::Triple::EnvironmentType lhs_triple_env = lhs_triple.getEnvironment();
-        const llvm::Triple::EnvironmentType rhs_triple_env = rhs_triple.getEnvironment();
-            
-        if (lhs_triple_env != rhs_triple_env)
-        {
-            // Only fail if both environment types are not unknown
-            if (lhs_triple_env != llvm::Triple::UnknownEnvironment &&
-                rhs_triple_env != llvm::Triple::UnknownEnvironment)
-                return false;
-        }
-        return true;
-    }
+        return cores_match (core2, core1, false, enforce_exact_match);
     return false;
 }
 
 bool
-lldb_private::operator!= (const ArchSpec& lhs, const ArchSpec& rhs)
-{
-    return !(lhs == rhs);
-}
-
-bool
 lldb_private::operator<(const ArchSpec& lhs, const ArchSpec& rhs)
 {
     const ArchSpec::Core lhs_core = lhs.GetCore ();

Modified: lldb/branches/lldb-platform-work/source/Core/Broadcaster.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Broadcaster.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Broadcaster.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Broadcaster.cpp Thu Jun  6 19:06:43 2013
@@ -29,7 +29,7 @@ Broadcaster::Broadcaster (BroadcasterMan
     m_hijacking_masks(),
     m_manager (manager)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
     if (log)
         log->Printf ("%p Broadcaster::Broadcaster(\"%s\")", this, m_broadcaster_name.AsCString());
 
@@ -37,7 +37,7 @@ Broadcaster::Broadcaster (BroadcasterMan
 
 Broadcaster::~Broadcaster()
 {
-    LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+    Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
     if (log)
         log->Printf ("%p Broadcaster::~Broadcaster(\"%s\")", this, m_broadcaster_name.AsCString());
 
@@ -236,7 +236,7 @@ Broadcaster::PrivateBroadcastEvent (Even
             hijacking_listener = NULL;
     }
 
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
     if (log)
     {
         StreamString event_description;
@@ -294,7 +294,7 @@ Broadcaster::HijackBroadcaster (Listener
 {
     Mutex::Locker event_types_locker(m_listeners_mutex);
     
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
     if (log)
     {
         log->Printf ("%p Broadcaster(\"%s\")::HijackBroadcaster (listener(\"%s\")=%p)",
@@ -313,7 +313,7 @@ Broadcaster::RestoreBroadcaster ()
 {
     Mutex::Locker event_types_locker(m_listeners_mutex);
 
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
     if (log)
     {
         Listener *listener = m_hijacking_listeners.back();

Modified: lldb/branches/lldb-platform-work/source/Core/Communication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/Communication.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/Communication.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/Communication.cpp Thu Jun  6 19:06:43 2013
@@ -108,7 +108,7 @@ Communication::Disconnect (Error *error_
         // don't want to pay for the overhead it might cause if every time we
         // access the connection we have to take a lock.
         //
-        // This auto_ptr will cleanup after itself when this object goes away,
+        // This unique pointer will cleanup after itself when this object goes away,
         // so there is no need to currently have it destroy itself immediately
         // upon disconnnect.
         //connection_sp.reset();
@@ -136,10 +136,10 @@ size_t
 Communication::Read (void *dst, size_t dst_len, uint32_t timeout_usec, ConnectionStatus &status, Error *error_ptr)
 {
     lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
-                                         "%p Communication::Read (dst = %p, dst_len = %zu, timeout = %u usec) connection = %p",
+                                         "%p Communication::Read (dst = %p, dst_len = %" PRIu64 ", timeout = %u usec) connection = %p",
                                          this, 
                                          dst, 
-                                         dst_len, 
+                                         (uint64_t)dst_len,
                                          timeout_usec, 
                                          m_connection_sp.get());
 
@@ -208,12 +208,12 @@ Communication::Write (const void *src, s
 {
     lldb::ConnectionSP connection_sp (m_connection_sp);
 
-    Mutex::Locker (m_write_mutex);
+    Mutex::Locker locker(m_write_mutex);
     lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
-                                         "%p Communication::Write (src = %p, src_len = %zu) connection = %p",
+                                         "%p Communication::Write (src = %p, src_len = %" PRIu64 ") connection = %p",
                                          this, 
                                          src, 
-                                         src_len, 
+                                         (uint64_t)src_len,
                                          connection_sp.get());
 
     if (connection_sp.get())
@@ -295,8 +295,8 @@ void
 Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast, ConnectionStatus status)
 {
     lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
-                                 "%p Communication::AppendBytesToCache (src = %p, src_len = %zu, broadcast = %i)",
-                                 this, bytes, len, broadcast);
+                                 "%p Communication::AppendBytesToCache (src = %p, src_len = %" PRIu64 ", broadcast = %i)",
+                                 this, bytes, (uint64_t)len, broadcast);
     if ((bytes == NULL || len == 0)
         && (status != lldb::eConnectionStatusEndOfFile))
         return;
@@ -338,7 +338,7 @@ Communication::ReadThread (void *p)
 {
     Communication *comm = (Communication *)p;
 
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_COMMUNICATION));
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_COMMUNICATION));
 
     if (log)
         log->Printf ("%p Communication::ReadThread () thread starting...", p);
@@ -374,14 +374,13 @@ Communication::ReadThread (void *p)
         case eConnectionStatusLostConnection:   // Lost connection while connected to a valid connection
             done = true;
             // Fall through...
-        default:
         case eConnectionStatusError:            // Check GetError() for details
         case eConnectionStatusTimedOut:         // Request timed out
             if (log)
-                error.LogIfError(log.get(), 
-                                 "%p Communication::ReadFromConnection () => status = %s", 
-                                 p, 
-                                 Communication::ConnectionStatusAsCString (status));
+                error.LogIfError (log,
+                                  "%p Communication::ReadFromConnection () => status = %s",
+                                  p,
+                                  Communication::ConnectionStatusAsCString (status));
             break;
         }
     }

Modified: lldb/branches/lldb-platform-work/source/Core/ConnectionFileDescriptor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ConnectionFileDescriptor.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ConnectionFileDescriptor.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ConnectionFileDescriptor.cpp Thu Jun  6 19:06:43 2013
@@ -7,6 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
+#if defined(__APPLE__)
+// Enable this special support for Apple builds where we can have unlimited
+// select bounds. We tried switching to poll() and kqueue and we were panicing
+// the kernel, so we have to stick with select for now.
+#define _DARWIN_UNLIMITED_SELECT
+#endif
+
 #include "lldb/Core/ConnectionFileDescriptor.h"
 
 // C Includes
@@ -18,6 +25,7 @@
 #include <netinet/tcp.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <sys/termios.h>
 #include <sys/types.h>
 #include <string.h>
 #include <stdlib.h>
@@ -25,6 +33,9 @@
 
 // C++ Includes
 // Other libraries and framework includes
+#if defined(__APPLE__)
+#include "llvm/ADT/SmallVector.h"
+#endif
 // Project includes
 #include "lldb/lldb-private-log.h"
 #include "lldb/Interpreter/Args.h"
@@ -43,11 +54,12 @@ DecodeHostAndPort (const char *host_and_
                    int32_t& port,
                    Error *error_ptr)
 {
-    RegularExpression regex ("([^:]+):([0-9]+)");
-    if (regex.Execute (host_and_port, 2))
+    static RegularExpression g_regex ("([^:]+):([0-9]+)");
+    RegularExpression::Match regex_match(2);
+    if (g_regex.Execute (host_and_port, &regex_match))
     {
-        if (regex.GetMatchAtIndex (host_and_port, 1, host_str) &&
-            regex.GetMatchAtIndex (host_and_port, 2, port_str))
+        if (regex_match.GetMatchAtIndex (host_and_port, 1, host_str) &&
+            regex_match.GetMatchAtIndex (host_and_port, 2, port_str))
         {
             port = Args::StringToSInt32 (port_str.c_str(), INT32_MIN);
             if (port != INT32_MIN)
@@ -80,7 +92,7 @@ ConnectionFileDescriptor::ConnectionFile
     m_mutex (Mutex::eMutexTypeRecursive),
     m_shutting_down (false)
 {
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION |  LIBLLDB_LOG_OBJECT));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION |  LIBLLDB_LOG_OBJECT));
     if (log)
         log->Printf ("%p ConnectionFileDescriptor::ConnectionFileDescriptor ()", this);
 }
@@ -99,7 +111,7 @@ ConnectionFileDescriptor::ConnectionFile
     m_mutex (Mutex::eMutexTypeRecursive),
     m_shutting_down (false)
 {
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION |  LIBLLDB_LOG_OBJECT));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION |  LIBLLDB_LOG_OBJECT));
     if (log)
         log->Printf ("%p ConnectionFileDescriptor::ConnectionFileDescriptor (fd = %i, owns_fd = %i)", this, fd, owns_fd);
     OpenCommandPipe ();
@@ -108,7 +120,7 @@ ConnectionFileDescriptor::ConnectionFile
 
 ConnectionFileDescriptor::~ConnectionFileDescriptor ()
 {
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION |  LIBLLDB_LOG_OBJECT));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION |  LIBLLDB_LOG_OBJECT));
     if (log)
         log->Printf ("%p ConnectionFileDescriptor::~ConnectionFileDescriptor ()", this);
     Disconnect (NULL);
@@ -120,7 +132,7 @@ ConnectionFileDescriptor::OpenCommandPip
 {
     CloseCommandPipe();
     
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION |  LIBLLDB_LOG_OBJECT));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
     // Make the command file descriptor here:
     int filedes[2];
     int result = pipe (filedes);
@@ -164,7 +176,7 @@ ConnectionStatus
 ConnectionFileDescriptor::Connect (const char *s, Error *error_ptr)
 {
     Mutex::Locker locker (m_mutex);
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
     if (log)
         log->Printf ("%p ConnectionFileDescriptor::Connect (url = '%s')", this, s);
 
@@ -261,6 +273,26 @@ ConnectionFileDescriptor::Connect (const
                 return eConnectionStatusError;
             }
 
+            if (::isatty(m_fd_send))
+            {
+                // Set up serial terminal emulation
+                struct termios options;
+                ::tcgetattr (m_fd_send, &options);
+
+                // Set port speed to maximum
+                ::cfsetospeed (&options, B115200);
+                ::cfsetispeed (&options, B115200);
+
+                // Raw input, disable echo and signals
+                options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
+
+                // Make sure only one character is needed to return from a read
+                options.c_cc[VMIN]  = 1;
+                options.c_cc[VTIME] = 0;
+
+                ::tcsetattr (m_fd_send, TCSANOW, &options);
+            }
+
             int flags = ::fcntl (m_fd_send, F_GETFL, 0);
             if (flags >= 0)
             {
@@ -285,7 +317,7 @@ ConnectionFileDescriptor::Connect (const
 ConnectionStatus
 ConnectionFileDescriptor::Disconnect (Error *error_ptr)
 {
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
     if (log)
         log->Printf ("%p ConnectionFileDescriptor::Disconnect ()", this);
 
@@ -360,10 +392,10 @@ ConnectionFileDescriptor::Read (void *ds
                                 ConnectionStatus &status, 
                                 Error *error_ptr)
 {
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
     if (log)
-        log->Printf ("%p ConnectionFileDescriptor::Read () ::read (fd = %i, dst = %p, dst_len = %zu)...",
-                     this, m_fd_recv, dst, dst_len);
+        log->Printf ("%p ConnectionFileDescriptor::Read () ::read (fd = %i, dst = %p, dst_len = %" PRIu64 ")...",
+                     this, m_fd_recv, dst, (uint64_t)dst_len);
 
     Mutex::Locker locker;
     bool got_lock = locker.TryLock (m_mutex);
@@ -411,12 +443,12 @@ ConnectionFileDescriptor::Read (void *ds
     }
 
     if (log)
-        log->Printf ("%p ConnectionFileDescriptor::Read () ::read (fd = %i, dst = %p, dst_len = %zu) => %zi, error = %s",
+        log->Printf ("%p ConnectionFileDescriptor::Read () ::read (fd = %i, dst = %p, dst_len = %" PRIu64 ") => %" PRIi64 ", error = %s",
                      this, 
                      m_fd_recv, 
                      dst, 
-                     dst_len, 
-                     bytes_read, 
+                     (uint64_t)dst_len,
+                     (int64_t)bytes_read,
                      error.AsCString());
 
     if (error_ptr)
@@ -464,7 +496,6 @@ ConnectionFileDescriptor::Read (void *ds
             return 0;
         }
 
-        //Disconnect (NULL);
         return 0;
     }
     return bytes_read;
@@ -473,9 +504,9 @@ ConnectionFileDescriptor::Read (void *ds
 size_t
 ConnectionFileDescriptor::Write (const void *src, size_t src_len, ConnectionStatus &status, Error *error_ptr)
 {
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
     if (log)
-        log->Printf ("%p ConnectionFileDescriptor::Write (src = %p, src_len = %zu)", this, src, src_len);
+        log->Printf ("%p ConnectionFileDescriptor::Write (src = %p, src_len = %" PRIu64 ")", this, src, (uint64_t)src_len);
 
     if (!IsConnected ())
     {
@@ -530,32 +561,32 @@ ConnectionFileDescriptor::Write (const v
         switch (m_fd_send_type)
         {
             case eFDTypeFile:       // Other FD requireing read/write
-                log->Printf ("%p ConnectionFileDescriptor::Write()  ::write (fd = %i, src = %p, src_len = %zu) => %zi (error = %s)",
+                log->Printf ("%p ConnectionFileDescriptor::Write()  ::write (fd = %i, src = %p, src_len = %" PRIu64 ") => %" PRIi64 " (error = %s)",
                              this, 
                              m_fd_send, 
                              src, 
-                             src_len, 
-                             bytes_sent, 
+                             (uint64_t)src_len,
+                             (int64_t)bytes_sent,
                              error.AsCString());
                 break;
                 
             case eFDTypeSocket:     // Socket requiring send/recv
-                log->Printf ("%p ConnectionFileDescriptor::Write()  ::send (socket = %i, src = %p, src_len = %zu, flags = 0) => %zi (error = %s)",
+                log->Printf ("%p ConnectionFileDescriptor::Write()  ::send (socket = %i, src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64 " (error = %s)",
                              this, 
                              m_fd_send, 
                              src, 
-                             src_len, 
-                             bytes_sent, 
+                             (uint64_t)src_len,
+                             (int64_t)bytes_sent,
                              error.AsCString());
                 break;
                 
             case eFDTypeSocketUDP:  // Unconnected UDP socket requiring sendto/recvfrom
-                log->Printf ("%p ConnectionFileDescriptor::Write()  ::sendto (socket = %i, src = %p, src_len = %zu, flags = 0) => %zi (error = %s)",
+                log->Printf ("%p ConnectionFileDescriptor::Write()  ::sendto (socket = %i, src = %p, src_len = %" PRIu64 ", flags = 0) => %" PRIi64 " (error = %s)",
                              this, 
                              m_fd_send, 
                              src, 
-                             src_len, 
-                             bytes_sent, 
+                             (uint64_t)src_len,
+                             (int64_t)bytes_sent, 
                              error.AsCString());
                 break;
         }
@@ -590,13 +621,28 @@ ConnectionFileDescriptor::Write (const v
     return bytes_sent;
 }
 
+
+
+#if defined(__APPLE__)
+
+// This ConnectionFileDescriptor::BytesAvailable() uses select().
+//
+// PROS:
+//  - select is consistent across most unix platforms
+//  - this Apple specific version allows for unlimited fds in the fd_sets by
+//    setting the _DARWIN_UNLIMITED_SELECT define prior to including the
+//    required header files.
+
+// CONS:
+//  - Darwin only
+
 ConnectionStatus
 ConnectionFileDescriptor::BytesAvailable (uint32_t timeout_usec, Error *error_ptr)
 {
     // Don't need to take the mutex here separately since we are only called from Read.  If we
     // ever get used more generally we will need to lock here as well.
     
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
     if (log)
         log->Printf("%p ConnectionFileDescriptor::BytesAvailable (timeout_usec = %u)", this, timeout_usec);
     struct timeval *tv_ptr;
@@ -613,90 +659,423 @@ ConnectionFileDescriptor::BytesAvailable
         tv = time_value.GetAsTimeVal();
         tv_ptr = &tv;
     }
-
-    while (m_fd_recv >= 0)
+    
+    // Make a copy of the file descriptors to make sure we don't
+    // have another thread change these values out from under us
+    // and cause problems in the loop below where like in FS_SET()
+    const int data_fd = m_fd_recv;
+    const int pipe_fd = m_pipe_read;
+    
+    if (data_fd >= 0)
     {
-        fd_set read_fds;
-        FD_ZERO (&read_fds);
-        FD_SET (m_fd_recv, &read_fds);
-        if (m_pipe_read != -1)
-            FD_SET (m_pipe_read, &read_fds);
-        int nfds = std::max<int>(m_fd_recv, m_pipe_read) + 1;
+        const bool have_pipe_fd = pipe_fd >= 0;
         
-        Error error;
+        while (data_fd == m_fd_recv)
+        {
+            const int nfds = std::max<int>(data_fd, pipe_fd) + 1;
+            llvm::SmallVector<fd_set, 1> read_fds;
+            read_fds.resize((nfds/FD_SETSIZE) + 1);
+            for (size_t i=0; i<read_fds.size(); ++i)
+                FD_ZERO (&read_fds[i]);
+            // FD_SET doesn't bounds check, it just happily walks off the end
+            // but we have taken care of making the extra storage with our
+            // SmallVector of fd_set objects
+            FD_SET (data_fd, read_fds.data());
+            if (have_pipe_fd)
+                FD_SET (pipe_fd, read_fds.data());
+            
+            Error error;
+            
+            if (log)
+            {
+                if (have_pipe_fd)
+                    log->Printf("%p ConnectionFileDescriptor::BytesAvailable()  ::select (nfds=%i, fds={%i, %i}, NULL, NULL, timeout=%p)...",
+                                this, nfds, data_fd, pipe_fd, tv_ptr);
+                else
+                    log->Printf("%p ConnectionFileDescriptor::BytesAvailable()  ::select (nfds=%i, fds={%i}, NULL, NULL, timeout=%p)...",
+                                this, nfds, data_fd, tv_ptr);
+            }
+            
+            const int num_set_fds = ::select (nfds, read_fds.data(), NULL, NULL, tv_ptr);
+            if (num_set_fds < 0)
+                error.SetErrorToErrno();
+            else
+                error.Clear();
+            
+            if (log)
+            {
+                if (have_pipe_fd)
+                    log->Printf("%p ConnectionFileDescriptor::BytesAvailable()  ::select (nfds=%i, fds={%i, %i}, NULL, NULL, timeout=%p) => %d, error = %s",
+                                this, nfds, data_fd, pipe_fd, tv_ptr, num_set_fds, error.AsCString());
+                else
+                    log->Printf("%p ConnectionFileDescriptor::BytesAvailable()  ::select (nfds=%i, fds={%i}, NULL, NULL, timeout=%p) => %d, error = %s",
+                                this, nfds, data_fd, tv_ptr, num_set_fds, error.AsCString());
+            }
+            
+            if (error_ptr)
+                *error_ptr = error;
+            
+            if (error.Fail())
+            {
+                switch (error.GetError())
+                {
+                    case EBADF:     // One of the descriptor sets specified an invalid descriptor.
+                        return eConnectionStatusLostConnection;
+                        
+                    case EINVAL:    // The specified time limit is invalid. One of its components is negative or too large.
+                    default:        // Other unknown error
+                        return eConnectionStatusError;
+                        
+                    case EAGAIN:    // The kernel was (perhaps temporarily) unable to
+                        // allocate the requested number of file descriptors,
+                        // or we have non-blocking IO
+                    case EINTR:     // A signal was delivered before the time limit
+                        // expired and before any of the selected events
+                        // occurred.
+                        break;      // Lets keep reading to until we timeout
+                }
+            }
+            else if (num_set_fds == 0)
+            {
+                return eConnectionStatusTimedOut;
+            }
+            else if (num_set_fds > 0)
+            {
+                // FD_ISSET is happy to deal with a something larger than
+                // a single fd_set.
+                if (FD_ISSET(data_fd, read_fds.data()))
+                    return eConnectionStatusSuccess;
+                if (have_pipe_fd && FD_ISSET(pipe_fd, read_fds.data()))
+                {
+                    // We got a command to exit.  Read the data from that pipe:
+                    char buffer[16];
+                    ssize_t bytes_read;
+                    
+                    do
+                    {
+                        bytes_read = ::read (pipe_fd, buffer, sizeof(buffer));
+                    } while (bytes_read < 0 && errno == EINTR);
+                    assert (bytes_read == 1 && buffer[0] == 'q');
+                    
+                    if (log)
+                        log->Printf("%p ConnectionFileDescriptor::BytesAvailable() got data: %*s from the command channel.",
+                                    this, (int) bytes_read, buffer);
+                    
+                    return eConnectionStatusEndOfFile;
+                }
+            }
+        }
+    }
+    
+    if (error_ptr)
+        error_ptr->SetErrorString("not connected");
+    return eConnectionStatusLostConnection;
+}
 
+#else
 
-        if (log)
-            log->Printf("%p ConnectionFileDescriptor::BytesAvailable()  ::select (nfds = %i, fd = %i, NULL, NULL, timeout = %p)...",
-                        this, nfds, m_fd_recv, tv_ptr);
+// This ConnectionFileDescriptor::BytesAvailable() uses select().
+//
+// PROS:
+//  - select is consistent across most unix platforms
+// CONS:
+//  - only supports file descriptors up to FD_SETSIZE. This implementation
+//    will assert if it runs into that hard limit to let users know that
+//    another ConnectionFileDescriptor::BytesAvailable() should be used
+//    or a new version of ConnectionFileDescriptor::BytesAvailable() should
+//    be written for the system that is running into the limitations. MacOSX
+//    uses kqueues, and there is a poll() based implementation below.
 
-        const int num_set_fds = ::select (nfds, &read_fds, NULL, NULL, tv_ptr);
-        if (num_set_fds < 0)
-            error.SetErrorToErrno();
-        else
-            error.Clear();
+ConnectionStatus
+ConnectionFileDescriptor::BytesAvailable (uint32_t timeout_usec, Error *error_ptr)
+{
+    // Don't need to take the mutex here separately since we are only called from Read.  If we
+    // ever get used more generally we will need to lock here as well.
+    
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+    if (log)
+        log->Printf("%p ConnectionFileDescriptor::BytesAvailable (timeout_usec = %u)", this, timeout_usec);
+    struct timeval *tv_ptr;
+    struct timeval tv;
+    if (timeout_usec == UINT32_MAX)
+    {
+        // Infinite wait...
+        tv_ptr = NULL;
+    }
+    else
+    {
+        TimeValue time_value;
+        time_value.OffsetWithMicroSeconds (timeout_usec);
+        tv = time_value.GetAsTimeVal();
+        tv_ptr = &tv;
+    }
+    
+    // Make a copy of the file descriptors to make sure we don't
+    // have another thread change these values out from under us
+    // and cause problems in the loop below where like in FS_SET()
+    const int data_fd = m_fd_recv;
+    const int pipe_fd = m_pipe_read;
+
+    if (data_fd >= 0)
+    {
+        // If this assert fires off on MacOSX, we will need to switch to using
+        // libdispatch to read from file descriptors because poll() is causing
+        // kernel panics and if we exceed FD_SETSIZE we will have no choice...
+        assert (data_fd < FD_SETSIZE);
+        
+        const bool have_pipe_fd = pipe_fd >= 0;
+        
+        if (have_pipe_fd)
+        {
+            assert (pipe_fd < FD_SETSIZE);            
+        }
 
-        if (log)
-            log->Printf("%p ConnectionFileDescriptor::BytesAvailable()  ::select (nfds = %i, fd = %i, NULL, NULL, timeout = %p) => %d, error = %s",
-                        this, nfds, m_fd_recv, tv_ptr, num_set_fds, error.AsCString());
+        while (data_fd == m_fd_recv)
+        {
+            fd_set read_fds;
+            FD_ZERO (&read_fds);
+            FD_SET (data_fd, &read_fds);
+            if (have_pipe_fd)
+                FD_SET (pipe_fd, &read_fds);
 
-        if (error_ptr)
-            *error_ptr = error;
+            const int nfds = std::max<int>(data_fd, pipe_fd) + 1;
 
-        if (error.Fail())
-        {
-            switch (error.GetError())
+            Error error;
+            
+            if (log)
             {
-            case EBADF:     // One of the descriptor sets specified an invalid descriptor.
-                return eConnectionStatusLostConnection;
-
-            case EINVAL:    // The specified time limit is invalid. One of its components is negative or too large.
-            default:        // Other unknown error
-                return eConnectionStatusError;
+                if (have_pipe_fd)
+                    log->Printf("%p ConnectionFileDescriptor::BytesAvailable()  ::select (nfds=%i, fds={%i, %i}, NULL, NULL, timeout=%p)...",
+                                this, nfds, data_fd, pipe_fd, tv_ptr);
+                else
+                    log->Printf("%p ConnectionFileDescriptor::BytesAvailable()  ::select (nfds=%i, fds={%i}, NULL, NULL, timeout=%p)...",
+                                this, nfds, data_fd, tv_ptr);
+            }
+            
+            const int num_set_fds = ::select (nfds, &read_fds, NULL, NULL, tv_ptr);
+            if (num_set_fds < 0)
+                error.SetErrorToErrno();
+            else
+                error.Clear();
+            
+            if (log)
+            {
+                if (have_pipe_fd)
+                    log->Printf("%p ConnectionFileDescriptor::BytesAvailable()  ::select (nfds=%i, fds={%i, %i}, NULL, NULL, timeout=%p) => %d, error = %s",
+                                this, nfds, data_fd, pipe_fd, tv_ptr, num_set_fds, error.AsCString());
+                else
+                    log->Printf("%p ConnectionFileDescriptor::BytesAvailable()  ::select (nfds=%i, fds={%i}, NULL, NULL, timeout=%p) => %d, error = %s",
+                                this, nfds, data_fd, tv_ptr, num_set_fds, error.AsCString());
+            }
 
-            case EAGAIN:    // The kernel was (perhaps temporarily) unable to
-                            // allocate the requested number of file descriptors,
-                            // or we have non-blocking IO
-            case EINTR:     // A signal was delivered before the time limit
-                            // expired and before any of the selected events
-                            // occurred.
-                break;      // Lets keep reading to until we timeout
+            if (error_ptr)
+                *error_ptr = error;
+            
+            if (error.Fail())
+            {
+                switch (error.GetError())
+                {
+                    case EBADF:     // One of the descriptor sets specified an invalid descriptor.
+                        return eConnectionStatusLostConnection;
+                        
+                    case EINVAL:    // The specified time limit is invalid. One of its components is negative or too large.
+                    default:        // Other unknown error
+                        return eConnectionStatusError;
+                        
+                    case EAGAIN:    // The kernel was (perhaps temporarily) unable to
+                        // allocate the requested number of file descriptors,
+                        // or we have non-blocking IO
+                    case EINTR:     // A signal was delivered before the time limit
+                        // expired and before any of the selected events
+                        // occurred.
+                        break;      // Lets keep reading to until we timeout
+                }
+            }
+            else if (num_set_fds == 0)
+            {
+                return eConnectionStatusTimedOut;
+            }
+            else if (num_set_fds > 0)
+            {
+                if (FD_ISSET(data_fd, &read_fds))
+                    return eConnectionStatusSuccess;                
+                if (have_pipe_fd && FD_ISSET(pipe_fd, &read_fds))
+                {
+                    // We got a command to exit.  Read the data from that pipe:
+                    char buffer[16];
+                    ssize_t bytes_read;
+                    
+                    do
+                    {
+                        bytes_read = ::read (pipe_fd, buffer, sizeof(buffer));
+                    } while (bytes_read < 0 && errno == EINTR);
+                    assert (bytes_read == 1 && buffer[0] == 'q');
+                    
+                    if (log)
+                        log->Printf("%p ConnectionFileDescriptor::BytesAvailable() got data: %*s from the command channel.",
+                                    this, (int) bytes_read, buffer);
+                    
+                    return eConnectionStatusEndOfFile;
+                }
             }
         }
-        else if (num_set_fds == 0)
-        {
-            return eConnectionStatusTimedOut;
-        }
-        else if (num_set_fds > 0)
+    }
+    
+    if (error_ptr)
+        error_ptr->SetErrorString("not connected");
+    return eConnectionStatusLostConnection;
+}
+
+#endif
+
+#if 0
+#include <poll.h>
+
+// This ConnectionFileDescriptor::BytesAvailable() uses poll(). poll() should NOT
+// be used on MacOSX as it has all sorts of restrictions on the types of file descriptors
+// that it doesn't support.
+//
+// There may be some systems that properly support poll() that could use this
+// implementation. I will let each system opt into this on their own.
+//
+// PROS:
+//  - no restrictions on the fd value that is used
+// CONS:
+//  - varies wildly from platform to platform in its implementation restrictions
+
+ConnectionStatus
+ConnectionFileDescriptor::BytesAvailable (uint32_t timeout_usec, Error *error_ptr)
+{
+    // Don't need to take the mutex here separately since we are only called from Read.  If we
+    // ever get used more generally we will need to lock here as well.
+    
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+    if (log)
+        log->Printf("%p ConnectionFileDescriptor::BytesAvailable (timeout_usec = %u)", this, timeout_usec);
+    int timeout_msec = 0;
+    if (timeout_usec == UINT32_MAX)
+    {
+        // Infinite wait...
+        timeout_msec = -1;
+    }
+    else if (timeout_usec == 0)
+    {
+        // Return immediately, don't wait
+        timeout_msec = 0;
+    }
+    else
+    {
+        // Convert usec to msec
+        timeout_msec = (timeout_usec + 999) / 1000;
+    }
+    
+    // Make a copy of the file descriptors to make sure we don't
+    // have another thread change these values out from under us
+    // and cause problems in the loop below where like in FS_SET()
+    const int data_fd = m_fd_recv;
+    const int pipe_fd = m_pipe_read;
+    
+    // Make sure the file descriptor can be used with select as it
+    // must be in range
+    if (data_fd >= 0)
+    {
+        const bool have_pipe_fd = pipe_fd >= 0;
+        struct pollfd fds[2] =
+        {
+            { data_fd, POLLIN, 0 },
+            { pipe_fd, POLLIN, 0 }
+        };
+        const int nfds = have_pipe_fd ? 2 : 1;
+        Error error;
+        while (data_fd == m_fd_recv)
         {
-            if (m_pipe_read != -1 && FD_ISSET(m_pipe_read, &read_fds))
+            const int num_set_fds = ::poll (fds, nfds, timeout_msec);
+            
+            if (num_set_fds < 0)
+                error.SetErrorToErrno();
+            else
+                error.Clear();
+            
+            if (error_ptr)
+                *error_ptr = error;
+            
+            if (log)
             {
-                // We got a command to exit.  Read the data from that pipe:
-                char buffer[16];
-                ssize_t bytes_read;
-                
-                do
+                if (have_pipe_fd)
+                    log->Printf("%p ConnectionFileDescriptor::BytesAvailable()  ::poll (fds={{%i,POLLIN},{%i,POLLIN}}, nfds=%i, timeout_ms=%i) => %d, error = %s\n",
+                                this,
+                                data_fd,
+                                pipe_fd,
+                                nfds,
+                                timeout_msec,
+                                num_set_fds,
+                                error.AsCString());
+                else
+                    log->Printf("%p ConnectionFileDescriptor::BytesAvailable()  ::poll (fds={{%i,POLLIN}}, nfds=%i, timeout_ms=%i) => %d, error = %s\n",
+                                this,
+                                data_fd,
+                                nfds,
+                                timeout_msec,
+                                num_set_fds,
+                                error.AsCString());
+            }
+            
+            if (error.Fail())
+            {
+                switch (error.GetError())
                 {
-                    bytes_read = ::read (m_pipe_read, buffer, sizeof(buffer));
-                } while (bytes_read < 0 && errno == EINTR);
-                assert (bytes_read == 1 && buffer[0] == 'q');
-                
-                if (log)
-                    log->Printf("%p ConnectionFileDescriptor::BytesAvailable() got data: %*s from the command channel.",
-                                this, (int) bytes_read, buffer);
-
-                return eConnectionStatusEndOfFile;
+                    case EBADF:     // One of the descriptor sets specified an invalid descriptor.
+                        return eConnectionStatusLostConnection;
+                        
+                    case EINVAL:    // The specified time limit is invalid. One of its components is negative or too large.
+                    default:        // Other unknown error
+                        return eConnectionStatusError;
+                        
+                    case EAGAIN:    // The kernel was (perhaps temporarily) unable to
+                        // allocate the requested number of file descriptors,
+                        // or we have non-blocking IO
+                    case EINTR:     // A signal was delivered before the time limit
+                        // expired and before any of the selected events
+                        // occurred.
+                        break;      // Lets keep reading to until we timeout
+                }
+            }
+            else if (num_set_fds == 0)
+            {
+                return eConnectionStatusTimedOut;
+            }
+            else if (num_set_fds > 0)
+            {
+                if (fds[0].revents & POLLIN)
+                    return eConnectionStatusSuccess;
+                if (fds[1].revents & POLLIN)
+                {
+                    // We got a command to exit.  Read the data from that pipe:
+                    char buffer[16];
+                    ssize_t bytes_read;
+                    
+                    do
+                    {
+                        bytes_read = ::read (pipe_fd, buffer, sizeof(buffer));
+                    } while (bytes_read < 0 && errno == EINTR);
+                    assert (bytes_read == 1 && buffer[0] == 'q');
+                    
+                    if (log)
+                        log->Printf("%p ConnectionFileDescriptor::BytesAvailable() got data: %*s from the command channel.",
+                                    this, (int) bytes_read, buffer);
+                    
+                    return eConnectionStatusEndOfFile;
+                }
             }
-            else
-                return eConnectionStatusSuccess;
         }
     }
-
     if (error_ptr)
         error_ptr->SetErrorString("not connected");
     return eConnectionStatusLostConnection;
 }
 
+#endif
+
 ConnectionStatus
 ConnectionFileDescriptor::Close (int& fd, Error *error_ptr)
 {
@@ -711,7 +1090,7 @@ ConnectionFileDescriptor::Close (int& fd
         // can get into the close scope below
         if (fd >= 0)
         {
-            LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+            Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
             if (log)
                 log->Printf ("%p ConnectionFileDescriptor::Close (fd = %i)", this,fd);
 
@@ -820,7 +1199,7 @@ ConnectionFileDescriptor::NamedSocketCon
 ConnectionStatus
 ConnectionFileDescriptor::SocketListen (uint16_t listen_port_num, Error *error_ptr)
 {
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
     if (log)
         log->Printf ("%p ConnectionFileDescriptor::SocketListen (port = %i)", this, listen_port_num);
 
@@ -883,7 +1262,7 @@ ConnectionFileDescriptor::SocketListen (
 ConnectionStatus
 ConnectionFileDescriptor::ConnectTCP (const char *host_and_port, Error *error_ptr)
 {
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
     if (log)
         log->Printf ("%p ConnectionFileDescriptor::ConnectTCP (host/port = %s)", this, host_and_port);
     Disconnect (NULL);
@@ -957,7 +1336,7 @@ ConnectionFileDescriptor::ConnectTCP (co
 ConnectionStatus
 ConnectionFileDescriptor::ConnectUDP (const char *host_and_port, Error *error_ptr)
 {
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
+    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
     if (log)
         log->Printf ("%p ConnectionFileDescriptor::ConnectUDP (host/port = %s)", this, host_and_port);
     Disconnect (NULL);

Modified: lldb/branches/lldb-platform-work/source/Core/ConstString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/ConstString.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/ConstString.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/ConstString.cpp Thu Jun  6 19:06:43 2013
@@ -87,7 +87,7 @@ public:
     }
 
     const char *
-    GetConstCStringWithLength (const char *cstr, int cstr_len)
+    GetConstCStringWithLength (const char *cstr, size_t cstr_len)
     {
         if (cstr)
         {
@@ -100,6 +100,18 @@ public:
     }
 
     const char *
+    GetConstCStringWithStringRef (const llvm::StringRef &string_ref)
+    {
+        if (string_ref.data())
+        {
+            Mutex::Locker locker (m_mutex);
+            StringPoolEntryType& entry = m_string_map.GetOrCreateValue (string_ref, (StringPoolValueType)NULL);
+            return entry.getKeyData();
+        }
+        return NULL;
+    }
+
+    const char *
     GetConstCStringAndSetMangledCounterPart (const char *demangled_cstr, const char *mangled_ccstr)
     {
         if (demangled_cstr)
@@ -120,11 +132,11 @@ public:
     }
 
     const char *
-    GetConstTrimmedCStringWithLength (const char *cstr, int cstr_len)
+    GetConstTrimmedCStringWithLength (const char *cstr, size_t cstr_len)
     {
         if (cstr)
         {
-            int trimmed_len = std::min<int> (strlen (cstr), cstr_len);
+            const size_t trimmed_len = std::min<size_t> (strlen (cstr), cstr_len);
             return GetConstCStringWithLength (cstr, trimmed_len);
         }
         return NULL;
@@ -205,6 +217,11 @@ ConstString::ConstString (const char *cs
 {
 }
 
+ConstString::ConstString (const llvm::StringRef &s) :
+    m_string (StringPool().GetConstCStringWithLength (s.data(), s.size()))
+{
+}
+
 bool
 ConstString::operator < (const ConstString& rhs) const
 {
@@ -262,9 +279,12 @@ ConstString::Compare (const ConstString&
 void
 ConstString::Dump(Stream *s, const char *fail_value) const
 {
-    const char *cstr = AsCString (fail_value);
-    if (cstr)
-        s->PutCString (cstr);
+    if (s)
+    {
+        const char *cstr = AsCString (fail_value);
+        if (cstr)
+            s->PutCString (cstr);
+    }
 }
 
 void
@@ -274,7 +294,7 @@ ConstString::DumpDebug(Stream *s) const
     size_t cstr_len = GetLength();
     // Only print the parens if we have a non-NULL string
     const char *parens = cstr ? "\"" : "";
-    s->Printf("%*p: ConstString, string = %s%s%s, length = %zu", (int)sizeof(void*) * 2, this, parens, cstr, parens, cstr_len);
+    s->Printf("%*p: ConstString, string = %s%s%s, length = %" PRIu64, (int)sizeof(void*) * 2, this, parens, cstr, parens, (uint64_t)cstr_len);
 }
 
 void
@@ -284,6 +304,12 @@ ConstString::SetCString (const char *cst
 }
 
 void
+ConstString::SetString (const llvm::StringRef &s)
+{
+    m_string = StringPool().GetConstCStringWithLength (s.data(), s.size());
+}
+
+void
 ConstString::SetCStringWithMangledCounterpart (const char *demangled, const ConstString &mangled)
 {
     m_string = StringPool().GetConstCStringAndSetMangledCounterPart (demangled, mangled.m_string);

Modified: lldb/branches/lldb-platform-work/source/Core/DataBufferHeap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/DataBufferHeap.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/DataBufferHeap.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/DataBufferHeap.cpp Thu Jun  6 19:06:43 2013
@@ -23,7 +23,7 @@ DataBufferHeap::DataBufferHeap () :
 // Initialize this class with "n" characters and fill the buffer
 // with "ch".
 //----------------------------------------------------------------------
-DataBufferHeap::DataBufferHeap (size_t n, uint8_t ch) :
+DataBufferHeap::DataBufferHeap (lldb::offset_t n, uint8_t ch) :
     m_data(n, ch)
 {
 }
@@ -32,7 +32,7 @@ DataBufferHeap::DataBufferHeap (size_t n
 // Initialize this class with a copy of the "n" bytes from the "bytes"
 // buffer.
 //----------------------------------------------------------------------
-DataBufferHeap::DataBufferHeap (const void *src, size_t src_len) :
+DataBufferHeap::DataBufferHeap (const void *src, lldb::offset_t src_len) :
     m_data()
 {
     CopyData (src, src_len);
@@ -73,7 +73,7 @@ DataBufferHeap::GetBytes () const
 //----------------------------------------------------------------------
 // Return the number of bytes this object currently contains.
 //----------------------------------------------------------------------
-size_t
+uint64_t
 DataBufferHeap::GetByteSize () const
 {
     return m_data.size();
@@ -84,15 +84,15 @@ DataBufferHeap::GetByteSize () const
 // Sets the number of bytes that this object should be able to
 // contain. This can be used prior to copying data into the buffer.
 //----------------------------------------------------------------------
-size_t
-DataBufferHeap::SetByteSize (size_t new_size)
+uint64_t
+DataBufferHeap::SetByteSize (uint64_t new_size)
 {
     m_data.resize(new_size);
     return m_data.size();
 }
 
 void
-DataBufferHeap::CopyData (const void *src, size_t src_len)
+DataBufferHeap::CopyData (const void *src, uint64_t src_len)
 {
     const uint8_t *src_u8 = (const uint8_t *)src;
     if (src && src_len > 0)

Modified: lldb/branches/lldb-platform-work/source/Core/DataBufferMemoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/DataBufferMemoryMap.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/DataBufferMemoryMap.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/DataBufferMemoryMap.cpp Thu Jun  6 19:06:43 2013
@@ -19,7 +19,10 @@
 #include "lldb/Host/File.h"
 #include "lldb/Host/FileSpec.h"
 #include "lldb/Host/Host.h"
+#include "lldb/Core/Log.h"
+#include "lldb/lldb-private-log.h"
 
+using namespace lldb;
 using namespace lldb_private;
 
 //----------------------------------------------------------------------
@@ -65,7 +68,7 @@ DataBufferMemoryMap::GetBytes() const
 //----------------------------------------------------------------------
 // Return the number of bytes this object currently contains.
 //----------------------------------------------------------------------
-size_t
+uint64_t
 DataBufferMemoryMap::GetByteSize() const
 {
     return m_size;
@@ -80,6 +83,9 @@ DataBufferMemoryMap::Clear()
 {
     if (m_mmap_addr != NULL)
     {
+        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP));
+        if (log)
+            log->Printf("DataBufferMemoryMap::Clear() m_mmap_addr = %p, m_mmap_size = %zu", m_mmap_addr, m_mmap_size);
         ::munmap((void *)m_mmap_addr, m_mmap_size);
         m_mmap_addr = NULL;
         m_mmap_size = 0;
@@ -97,15 +103,24 @@ DataBufferMemoryMap::Clear()
 // offset.
 //----------------------------------------------------------------------
 size_t
-DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* file, 
-                                            off_t offset, 
-                                            size_t length,
+DataBufferMemoryMap::MemoryMapFromFileSpec (const FileSpec* filespec,
+                                            lldb::offset_t offset,
+                                            lldb::offset_t length,
                                             bool writeable)
 {
-    if (file != NULL)
+    if (filespec != NULL)
     {
+        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP));
+        if (log)
+        {
+            log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(file=\"%s\", offset=0x%" PRIx64 ", length=0x%" PRIx64 ", writeable=%i",
+                        filespec->GetPath().c_str(),
+                        offset,
+                        length,
+                        writeable);
+        }
         char path[PATH_MAX];
-        if (file->GetPath(path, sizeof(path)))
+        if (filespec->GetPath(path, sizeof(path)))
         {
             uint32_t options = File::eOpenOptionRead;
             if (writeable)
@@ -116,8 +131,7 @@ DataBufferMemoryMap::MemoryMapFromFileSp
             if (error.Success())
             {
                 const bool fd_is_file = true;
-                MemoryMapFromFileDescriptor (file.GetDescriptor(), offset, length, writeable, fd_is_file);
-                return GetByteSize();
+                return MemoryMapFromFileDescriptor (file.GetDescriptor(), offset, length, writeable, fd_is_file);
             }
         }
     }
@@ -141,14 +155,24 @@ DataBufferMemoryMap::MemoryMapFromFileSp
 //----------------------------------------------------------------------
 size_t
 DataBufferMemoryMap::MemoryMapFromFileDescriptor (int fd, 
-                                                  off_t offset, 
-                                                  size_t length,
+                                                  lldb::offset_t offset, 
+                                                  lldb::offset_t length,
                                                   bool writeable,
                                                   bool fd_is_file)
 {
     Clear();
     if (fd >= 0)
     {
+        Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_MMAP|LIBLLDB_LOG_VERBOSE));
+        if (log)
+        {
+            log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec(fd=%i, offset=0x%" PRIx64 ", length=0x%" PRIx64 ", writeable=%i, fd_is_file=%i)",
+                        fd,
+                        offset,
+                        length,
+                        writeable,
+                        fd_is_file);
+        }
         struct stat stat;
         if (::fstat(fd, &stat) == 0)
         {
@@ -176,10 +200,10 @@ DataBufferMemoryMap::MemoryMapFromFileDe
                         flags |= MAP_FILE;
 
                     m_mmap_addr = (uint8_t *)::mmap(NULL, length, prot, flags, fd, offset);
+                    Error error;
 
                     if (m_mmap_addr == (void*)-1)
                     {
-                        Error error;
                         error.SetErrorToErrno ();
                         if (error.GetError() == EINVAL)
                         {
@@ -209,7 +233,7 @@ DataBufferMemoryMap::MemoryMapFromFileDe
                         }
                         if (error.GetError() == ENOMEM)
                         {
-                           error.SetErrorStringWithFormat("could not allocate %lld bytes of memory to mmap in file", (uint64_t) length);
+                           error.SetErrorStringWithFormat("could not allocate %" PRId64 " bytes of memory to mmap in file", (uint64_t) length);
                         }
                     }
                     else
@@ -220,6 +244,12 @@ DataBufferMemoryMap::MemoryMapFromFileDe
                         m_data = m_mmap_addr;
                         m_size = length;
                     }
+                    
+                    if (log)
+                    {
+                        log->Printf("DataBufferMemoryMap::MemoryMapFromFileSpec() m_mmap_addr = %p, m_mmap_size = %zu, error = %s",
+                                    m_mmap_addr, m_mmap_size, error.AsCString());
+                    }
                 }
             }
         }

Modified: lldb/branches/lldb-platform-work/source/Core/DataEncoder.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/DataEncoder.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/DataEncoder.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/DataEncoder.cpp Thu Jun  6 19:06:43 2013
@@ -142,32 +142,6 @@ DataEncoder::GetSharedDataOffset () cons
     return 0;
 }
 
-//------------------------------------------------------------------
-// Returns true if there are LENGTH bytes availabe starting OFFSET
-// into the data that is in this object.
-//------------------------------------------------------------------
-bool
-DataEncoder::ValidOffsetForDataOfSize (uint32_t offset, uint32_t length) const
-{
-    size_t size = GetByteSize();
-    if (offset >= size)
-        return false;   // offset isn't valid
-
-    if (length == 0)
-        return true;    // No bytes requested at this offset, return true
-
-    // If we flip the bits in offset we can figure out how
-    // many bytes we have left before "offset + length"
-    // could overflow when doing unsigned arithmetic.
-    if (length > ~offset)
-        return false;   // unsigned overflow
-
-    // Make sure "offset + length" is a valid offset as well.
-    // length must be greater than zero for this to be a
-    // valid expression, and we have already checked for this.
-    return ((offset + length) <= size);
-}
-
 //----------------------------------------------------------------------
 // Set the data with which this object will extract from to data
 // starting at BYTES and set the length of the data to LENGTH bytes

Modified: lldb/branches/lldb-platform-work/source/Core/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/DataExtractor.cpp?rev=183468&r1=183467&r2=183468&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/DataExtractor.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/DataExtractor.cpp Thu Jun  6 19:06:43 2013
@@ -11,6 +11,8 @@
 #include <stddef.h>
 
 #include <bitset>
+#include <limits>
+#include <sstream>
 #include <string>
 
 #include "llvm/ADT/APFloat.h"
@@ -36,39 +38,73 @@ using namespace lldb;
 using namespace lldb_private;
 
 static inline uint16_t 
-ReadInt16(const unsigned char* ptr, unsigned offset) 
+ReadInt16(const unsigned char* ptr, offset_t offset)
 {
     return *(uint16_t *)(ptr + offset);
 }
 static inline uint32_t
-ReadInt32 (const unsigned char* ptr, unsigned offset) 
+ReadInt32 (const unsigned char* ptr, offset_t offset)
 {
     return *(uint32_t *)(ptr + offset);
 }
 
 static inline uint64_t 
-ReadInt64(const unsigned char* ptr, unsigned offset) 
+ReadInt64(const unsigned char* ptr, offset_t offset)
 {
     return *(uint64_t *)(ptr + offset);
 }
 
 static inline uint16_t
-ReadSwapInt16(const unsigned char* ptr, unsigned offset) 
+ReadInt16(const void* ptr)
+{
+    return *(uint16_t *)(ptr);
+}
+static inline uint32_t
+ReadInt32 (const void* ptr)
+{
+    return *(uint32_t *)(ptr);
+}
+
+static inline uint64_t
+ReadInt64(const void* ptr)
+{
+    return *(uint64_t *)(ptr);
+}
+
+static inline uint16_t
+ReadSwapInt16(const unsigned char* ptr, offset_t offset)
 {
     return llvm::ByteSwap_16(*(uint16_t *)(ptr + offset));
 }
 
 static inline uint32_t
-ReadSwapInt32 (const unsigned char* ptr, unsigned offset) 
+ReadSwapInt32 (const unsigned char* ptr, offset_t offset)
 {
     return llvm::ByteSwap_32(*(uint32_t *)(ptr + offset));
 }
 static inline uint64_t 
-ReadSwapInt64(const unsigned char* ptr, unsigned offset) 
+ReadSwapInt64(const unsigned char* ptr, offset_t offset) 
 {
   return llvm::ByteSwap_64(*(uint64_t *)(ptr + offset));
 }
 
+static inline uint16_t
+ReadSwapInt16(const void* ptr)
+{
+    return llvm::ByteSwap_16(*(uint16_t *)(ptr));
+}
+
+static inline uint32_t
+ReadSwapInt32 (const void* ptr)
+{
+    return llvm::ByteSwap_32(*(uint32_t *)(ptr));
+}
+static inline uint64_t
+ReadSwapInt64(const void* ptr)
+{
+    return llvm::ByteSwap_64(*(uint64_t *)(ptr));
+}
+
 #define NON_PRINTABLE_CHAR '.'
 //----------------------------------------------------------------------
 // Default constructor.
@@ -86,7 +122,7 @@ DataExtractor::DataExtractor () :
 // This constructor allows us to use data that is owned by someone else.
 // The data must stay around as long as this object is valid.
 //----------------------------------------------------------------------
-DataExtractor::DataExtractor (const void* data, uint32_t length, ByteOrder endian, uint8_t addr_size) :
+DataExtractor::DataExtractor (const void* data, offset_t length, ByteOrder endian, uint32_t addr_size) :
     m_start     ((uint8_t*)data),
     m_end       ((uint8_t*)data + length),
     m_byte_order(endian),
@@ -102,7 +138,7 @@ DataExtractor::DataExtractor (const void
 // as long as any DataExtractor objects exist that have a reference to
 // this data.
 //----------------------------------------------------------------------
-DataExtractor::DataExtractor (const DataBufferSP& data_sp, ByteOrder endian, uint8_t addr_size) :
+DataExtractor::DataExtractor (const DataBufferSP& data_sp, ByteOrder endian, uint32_t addr_size) :
     m_start     (NULL),
     m_end       (NULL),
     m_byte_order(endian),
@@ -119,7 +155,7 @@ DataExtractor::DataExtractor (const Data
 // as any object contains a reference to that data. The endian
 // swap and address size settings are copied from "data".
 //----------------------------------------------------------------------
-DataExtractor::DataExtractor (const DataExtractor& data, uint32_t offset, uint32_t length) :
+DataExtractor::DataExtractor (const DataExtractor& data, offset_t offset, offset_t length) :
     m_start(NULL),
     m_end(NULL),
     m_byte_order(data.m_byte_order),
@@ -128,7 +164,7 @@ DataExtractor::DataExtractor (const Data
 {
     if (data.ValidOffset(offset))
     {
-        uint32_t bytes_available = data.GetByteSize() - offset;
+        offset_t bytes_available = data.GetByteSize() - offset;
         if (length > bytes_available)
             length = bytes_available;
         SetData(data, offset, length);
@@ -206,32 +242,6 @@ DataExtractor::GetSharedDataOffset () co
     return 0;
 }
 
-//------------------------------------------------------------------
-// Returns true if there are LENGTH bytes availabe starting OFFSET
-// into the data that is in this object.
-//------------------------------------------------------------------
-bool
-DataExtractor::ValidOffsetForDataOfSize (uint32_t offset, uint32_t length) const
-{
-    size_t size = GetByteSize();
-    if (offset >= size)
-        return false;   // offset isn't valid
-
-    if (length == 0)
-        return true;    // No bytes requested at this offset, return true
-
-    // If we flip the bits in offset we can figure out how
-    // many bytes we have left before "offset + length"
-    // could overflow when doing unsigned arithmetic.
-    if (length > ~offset)
-        return false;   // unsigned overflow
-
-    // Make sure "offset + length" is a valid offset as well.
-    // length must be greater than zero for this to be a
-    // valid expression, and we have already checked for this.
-    return ((offset + length) <= size);
-}
-
 //----------------------------------------------------------------------
 // Set the data with which this object will extract from to data
 // starting at BYTES and set the length of the data to LENGTH bytes
@@ -242,8 +252,8 @@ DataExtractor::ValidOffsetForDataOfSize
 // reference to that data will be released. Is SWAP is set to true,
 // any data extracted will be endian swapped.
 //----------------------------------------------------------------------
-uint32_t
-DataExtractor::SetData (const void *bytes, uint32_t length, ByteOrder endian)
+lldb::offset_t
+DataExtractor::SetData (const void *bytes, offset_t length, ByteOrder endian)
 {
     m_byte_order = endian;
     m_data_sp.reset();
@@ -274,8 +284,8 @@ DataExtractor::SetData (const void *byte
 // refers to those bytes. The address size and endian swap settings
 // are copied from the current values in "data".
 //----------------------------------------------------------------------
-uint32_t
-DataExtractor::SetData (const DataExtractor& data, uint32_t data_offset, uint32_t data_length)
+lldb::offset_t
+DataExtractor::SetData (const DataExtractor& data, offset_t data_offset, offset_t data_length)
 {
     m_addr_size = data.m_addr_size;
     // If "data" contains shared pointer to data, then we can use that
@@ -309,8 +319,8 @@ DataExtractor::SetData (const DataExtrac
 // around as long as it is needed. The address size and endian swap
 // settings will remain unchanged from their current settings.
 //----------------------------------------------------------------------
-uint32_t
-DataExtractor::SetData (const DataBufferSP& data_sp, uint32_t data_offset, uint32_t data_length)
+lldb::offset_t
+DataExtractor::SetData (const DataBufferSP& data_sp, offset_t data_offset, offset_t data_length)
 {
     m_start = m_end = NULL;
 
@@ -333,7 +343,7 @@ DataExtractor::SetData (const DataBuffer
         }
     }
 
-    uint32_t new_size = GetByteSize();
+    size_t new_size = GetByteSize();
 
     // Don't hold a shared pointer to the data buffer if we don't share
     // any valid bytes in the shared buffer.
@@ -350,15 +360,12 @@ DataExtractor::SetData (const DataBuffer
 // RETURNS the byte that was extracted, or zero on failure.
 //----------------------------------------------------------------------
 uint8_t
-DataExtractor::GetU8 (uint32_t *offset_ptr) const
+DataExtractor::GetU8 (offset_t *offset_ptr) const
 {
-    uint8_t val = 0;
-    if ( m_start < m_end )
-    {
-        val = m_start[*offset_ptr];
-        *offset_ptr += sizeof(val);
-    }
-    return val;
+    const uint8_t *data = (const uint8_t *)GetData (offset_ptr, 1);
+    if (data)
+        return *data;
+    return 0;
 }
 
 //----------------------------------------------------------------------
@@ -371,16 +378,13 @@ DataExtractor::GetU8 (uint32_t *offset_p
 // the buffer due to being out of bounds, or unsufficient data.
 //----------------------------------------------------------------------
 void *
-DataExtractor::GetU8 (uint32_t *offset_ptr, void *dst, uint32_t count) const
+DataExtractor::GetU8 (offset_t *offset_ptr, void *dst, uint32_t count) const
 {
-    register uint32_t offset = *offset_ptr;
-
-    if ((count > 0) && ValidOffsetForDataOfSize(offset, count) )
+    const uint8_t *data = (const uint8_t *)GetData (offset_ptr, count);
+    if (data)
     {
         // Copy the data into the buffer
-        memcpy (dst, m_start + offset, count);
-        // Advance the offset
-        *offset_ptr += count;
+        memcpy (dst, data, count);
         // Return a non-NULL pointer to the converted data as an indicator of success
         return dst;
     }
@@ -394,49 +398,52 @@ DataExtractor::GetU8 (uint32_t *offset_p
 // RETURNS the uint16_t that was extracted, or zero on failure.
 //----------------------------------------------------------------------
 uint16_t
-DataExtractor::GetU16 (uint32_t *offset_ptr) const
+DataExtractor::GetU16 (offset_t *offset_ptr) const
 {
     uint16_t val = 0;
-    register uint32_t offset = *offset_ptr;
-    if ( ValidOffsetForDataOfSize(offset, sizeof(val)) )
+    const uint8_t *data = (const uint8_t *)GetData (offset_ptr, sizeof(val));
+    if (data)
     {
         if (m_byte_order != lldb::endian::InlHostByteOrder())
-            val = ReadSwapInt16(m_start, offset);
+            val = ReadSwapInt16(data);
         else
-            val = ReadInt16 (m_start, offset);
-
-        // Advance the offset
-        *offset_ptr += sizeof(val);
+            val = ReadInt16 (data);
     }
     return val;
 }
 
 uint16_t
-DataExtractor::GetU16_unchecked (uint32_t *offset_ptr) const
+DataExtractor::GetU16_unchecked (offset_t *offset_ptr) const
 {
-    uint16_t val = (m_byte_order == lldb::endian::InlHostByteOrder()) ? 
-                        ReadInt16 (m_start, *offset_ptr) :
-                        ReadSwapInt16(m_start, *offset_ptr);
+    uint16_t val;
+    if (m_byte_order == lldb::endian::InlHostByteOrder())
+        val = ReadInt16 (m_start, *offset_ptr);
+    else
+        val = ReadSwapInt16(m_start, *offset_ptr);
     *offset_ptr += sizeof(val);
     return val;
 }
 
 uint32_t
-DataExtractor::GetU32_unchecked (uint32_t *offset_ptr) const
+DataExtractor::GetU32_unchecked (offset_t *offset_ptr) const
 {
-    uint32_t val = (m_byte_order == lldb::endian::InlHostByteOrder()) ? 
-                        ReadInt32 (m_start, *offset_ptr) :
-                        ReadSwapInt32 (m_start, *offset_ptr);
+    uint32_t val;
+    if (m_byte_order == lldb::endian::InlHostByteOrder())
+        val = ReadInt32 (m_start, *offset_ptr);
+    else
+        val =  ReadSwapInt32 (m_start, *offset_ptr);
     *offset_ptr += sizeof(val);
     return val;
 }
 
 uint64_t
-DataExtractor::GetU64_unchecked (uint32_t *offset_ptr) const
+DataExtractor::GetU64_unchecked (offset_t *offset_ptr) const
 {
-    uint64_t val = (m_byte_order == lldb::endian::InlHostByteOrder()) ? 
-                        ReadInt64 (m_start, *offset_ptr) :
-                        ReadSwapInt64 (m_start, *offset_ptr);
+    uint64_t val;
+    if (m_byte_order == lldb::endian::InlHostByteOrder())
+        val = ReadInt64 (m_start, *offset_ptr);
+    else
+        val = ReadSwapInt64 (m_start, *offset_ptr);
     *offset_ptr += sizeof(val);
     return val;
 }
@@ -452,31 +459,30 @@ DataExtractor::GetU64_unchecked (uint32_
 // in the buffer due to being out of bounds, or unsufficient data.
 //----------------------------------------------------------------------
 void *
-DataExtractor::GetU16 (uint32_t *offset_ptr, void *void_dst, uint32_t count) const
+DataExtractor::GetU16 (offset_t *offset_ptr, void *void_dst, uint32_t count) const
 {
-    uint16_t *dst = (uint16_t *)void_dst;
-    const size_t value_size = sizeof(*dst);
-    register uint32_t offset = *offset_ptr;
-
-    if ((count > 0) && ValidOffsetForDataOfSize(offset, value_size * count) )
+    const size_t src_size = sizeof(uint16_t) * count;
+    const uint16_t *src = (const uint16_t *)GetData (offset_ptr, src_size);
+    if (src)
     {
-        uint16_t *value_ptr;
-        uint16_t *end = dst + count;
         if (m_byte_order != lldb::endian::InlHostByteOrder())
         {
-            for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
-                *value_ptr = ReadSwapInt16 (m_start, offset);
+            uint16_t *dst_pos = (uint16_t *)void_dst;
+            uint16_t *dst_end = dst_pos + count;
+            const uint16_t *src_pos = src;
+            while (dst_pos < dst_end)
+            {
+                *dst_pos = ReadSwapInt16 (src_pos);
+                ++dst_pos;
+                ++src_pos;
+            }
         }
         else
         {
-            for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
-                *value_ptr = ReadInt16 (m_start, offset);
+            memcpy (void_dst, src, src_size);
         }
-
-        // Advance the offset
-        *offset_ptr = offset;
         // Return a non-NULL pointer to the converted data as an indicator of success
-        return dst;
+        return void_dst;
     }
     return NULL;
 }
@@ -488,20 +494,16 @@ DataExtractor::GetU16 (uint32_t *offset_
 // RETURNS the uint32_t that was extracted, or zero on failure.
 //----------------------------------------------------------------------
 uint32_t
-DataExtractor::GetU32 (uint32_t *offset_ptr) const
+DataExtractor::GetU32 (offset_t *offset_ptr) const
 {
     uint32_t val = 0;
-    register uint32_t offset = *offset_ptr;
-
-    if ( ValidOffsetForDataOfSize(offset, sizeof(val)) )
+    const uint32_t *data = (const uint32_t *)GetData (offset_ptr, sizeof(val));
+    if (data)
     {
         if (m_byte_order != lldb::endian::InlHostByteOrder())
-            val = ReadSwapInt32 (m_start, offset);
+            val = ReadSwapInt32 (data);
         else
-            val = ReadInt32 (m_start, offset);
-
-        // Advance the offset
-        *offset_ptr += sizeof(val);
+            val = *data;
     }
     return val;
 }
@@ -516,32 +518,30 @@ DataExtractor::GetU32 (uint32_t *offset_
 // in the buffer due to being out of bounds, or unsufficient data.
 //----------------------------------------------------------------------
 void *
-DataExtractor::GetU32 (uint32_t *offset_ptr, void *void_dst, uint32_t count) const
+DataExtractor::GetU32 (offset_t *offset_ptr, void *void_dst, uint32_t count) const
 {
-    uint32_t *dst = (uint32_t *)void_dst;
-    const size_t value_size = sizeof(*dst);
-    register uint32_t offset = *offset_ptr;
-
-    if ((count > 0) && ValidOffsetForDataOfSize(offset, value_size * count))
+    const size_t src_size = sizeof(uint32_t) * count;
+    const uint32_t *src = (const uint32_t *)GetData (offset_ptr, src_size);
+    if (src)
     {
-        uint32_t *value_ptr;
-        uint32_t *end = dst + count;
         if (m_byte_order != lldb::endian::InlHostByteOrder())
         {
-            for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
-                *value_ptr = ReadSwapInt32 (m_start, offset);
-
+            uint32_t *dst_pos = (uint32_t *)void_dst;
+            uint32_t *dst_end = dst_pos + count;
+            const uint32_t *src_pos = src;
+            while (dst_pos < dst_end)
+            {
+                *dst_pos = ReadSwapInt32 (src_pos);
+                ++dst_pos;
+                ++src_pos;
+            }
         }
         else
         {
-            for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
-                *value_ptr = ReadInt32 (m_start, offset);
+            memcpy (void_dst, src, src_size);
         }
-
-        // Advance the offset
-        *offset_ptr = offset;
         // Return a non-NULL pointer to the converted data as an indicator of success
-        return dst;
+        return void_dst;
     }
     return NULL;
 }
@@ -553,19 +553,16 @@ DataExtractor::GetU32 (uint32_t *offset_
 // RETURNS the uint64_t that was extracted, or zero on failure.
 //----------------------------------------------------------------------
 uint64_t
-DataExtractor::GetU64 (uint32_t *offset_ptr) const
+DataExtractor::GetU64 (offset_t *offset_ptr) const
 {
     uint64_t val = 0;
-    register uint32_t offset = *offset_ptr;
-    if ( ValidOffsetForDataOfSize(offset, sizeof(val)) )
+    const uint64_t *data = (const uint64_t *)GetData (offset_ptr, sizeof(val));
+    if (data)
     {
         if (m_byte_order != lldb::endian::InlHostByteOrder())
-            val = ReadSwapInt64 (m_start, offset);
+            val = ReadSwapInt64 (data);
         else
-            val = ReadInt64 (m_start, offset);
-
-        // Advance the offset
-        *offset_ptr += sizeof(val);
+            val = *data;
     }
     return val;
 }
@@ -578,32 +575,30 @@ DataExtractor::GetU64 (uint32_t *offset_
 // return false and leave the offset pointed to by offset_ptr unchanged.
 //----------------------------------------------------------------------
 void *
-DataExtractor::GetU64 (uint32_t *offset_ptr, void *void_dst, uint32_t count) const
+DataExtractor::GetU64 (offset_t *offset_ptr, void *void_dst, uint32_t count) const
 {
-    uint64_t *dst = (uint64_t *)void_dst;
-    const size_t value_size = sizeof(uint64_t);
-    register uint32_t offset = *offset_ptr;
-
-    if ((count > 0) && ValidOffsetForDataOfSize(offset, value_size * count))
+    const size_t src_size = sizeof(uint64_t) * count;
+    const uint64_t *src = (const uint64_t *)GetData (offset_ptr, src_size);
+    if (src)
     {
-        uint64_t *value_ptr;
-        uint64_t *end = dst + count;
         if (m_byte_order != lldb::endian::InlHostByteOrder())
         {
-            for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
-                *value_ptr = ReadSwapInt64 (m_start, offset);
-
+            uint64_t *dst_pos = (uint64_t *)void_dst;
+            uint64_t *dst_end = dst_pos + count;
+            const uint64_t *src_pos = src;
+            while (dst_pos < dst_end)
+            {
+                *dst_pos = ReadSwapInt64 (src_pos);
+                ++dst_pos;
+                ++src_pos;
+            }
         }
         else
         {
-            for (value_ptr = dst; value_ptr < end; ++value_ptr, offset += value_size)
-                *value_ptr = ReadInt64 (m_start, offset);
+            memcpy (void_dst, src, src_size);
         }
-
-        // Advance the offset
-        *offset_ptr = offset;
         // Return a non-NULL pointer to the converted data as an indicator of success
-        return dst;
+        return void_dst;
     }
     return NULL;
 }
@@ -619,7 +614,7 @@ DataExtractor::GetU64 (uint32_t *offset_
 // RETURNS the integer value that was extracted, or zero on failure.
 //----------------------------------------------------------------------
 uint32_t
-DataExtractor::GetMaxU32 (uint32_t *offset_ptr, uint32_t byte_size) const
+DataExtractor::GetMaxU32 (offset_t *offset_ptr, size_t byte_size) const
 {
     switch (byte_size)
     {
@@ -627,7 +622,7 @@ DataExtractor::GetMaxU32 (uint32_t *offs
     case 2: return GetU16(offset_ptr); break;
     case 4: return GetU32(offset_ptr); break;
     default:
-        assert(!"GetMaxU32 unhandled case!");
+        assert("GetMaxU32 unhandled case!" == NULL);
         break;
     }
     return 0;
@@ -644,7 +639,7 @@ DataExtractor::GetMaxU32 (uint32_t *offs
 // RETURNS the integer value that was extracted, or zero on failure.
 //----------------------------------------------------------------------
 uint64_t
-DataExtractor::GetMaxU64 (uint32_t *offset_ptr, uint32_t size) const
+DataExtractor::GetMaxU64 (offset_t *offset_ptr, size_t size) const
 {
     switch (size)
     {
@@ -653,14 +648,14 @@ DataExtractor::GetMaxU64 (uint32_t *offs
     case 4: return GetU32(offset_ptr); break;
     case 8: return GetU64(offset_ptr); break;
     default:
-        assert(!"GetMax64 unhandled case!");
+        assert("GetMax64 unhandled case!" == NULL);
         break;
     }
     return 0;
 }
 
 uint64_t
-DataExtractor::GetMaxU64_unchecked (uint32_t *offset_ptr, uint32_t size) const
+DataExtractor::GetMaxU64_unchecked (offset_t *offset_ptr, size_t size) const
 {
     switch (size)
     {
@@ -669,14 +664,14 @@ DataExtractor::GetMaxU64_unchecked (uint
         case 4: return GetU32_unchecked (offset_ptr); break;
         case 8: return GetU64_unchecked (offset_ptr); break;
         default:
-            assert(!"GetMax64 unhandled case!");
+            assert("GetMax64 unhandled case!" == NULL);
             break;
     }
     return 0;
 }
 
 int64_t
-DataExtractor::GetMaxS64 (uint32_t *offset_ptr, uint32_t size) const
+DataExtractor::GetMaxS64 (offset_t *offset_ptr, size_t size) const
 {
     switch (size)
     {
@@ -685,14 +680,14 @@ DataExtractor::GetMaxS64 (uint32_t *offs
     case 4: return (int32_t)GetU32(offset_ptr); break;
     case 8: return (int64_t)GetU64(offset_ptr); break;
     default:
-        assert(!"GetMax64 unhandled case!");
+        assert("GetMax64 unhandled case!" == NULL);
         break;
     }
     return 0;
 }
 
 uint64_t
-DataExtractor::GetMaxU64Bitfield (uint32_t *offset_ptr, uint32_t size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const
+DataExtractor::GetMaxU64Bitfield (offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const
 {
     uint64_t uval64 = GetMaxU64 (offset_ptr, size);
     if (bitfield_bit_size > 0)
@@ -708,17 +703,17 @@ DataExtractor::GetMaxU64Bitfield (uint32
 }
 
 int64_t
-DataExtractor::GetMaxS64Bitfield (uint32_t *offset_ptr, uint32_t size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const
+DataExtractor::GetMaxS64Bitfield (offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const
 {
     int64_t sval64 = GetMaxS64 (offset_ptr, size);
     if (bitfield_bit_size > 0)
     {
         if (bitfield_bit_offset > 0)
             sval64 >>= bitfield_bit_offset;
-        uint64_t bitfield_mask = ((1 << bitfield_bit_size) - 1);
+        uint64_t bitfield_mask = (((uint64_t)1) << bitfield_bit_size) - 1;
         sval64 &= bitfield_mask;
         // sign extend if needed
-        if (sval64 & (1 << (bitfield_bit_size - 1)))
+        if (sval64 & (((uint64_t)1) << (bitfield_bit_size - 1)))
             sval64 |= ~bitfield_mask;
     }
     return sval64;
@@ -726,80 +721,74 @@ DataExtractor::GetMaxS64Bitfield (uint32
 
 
 float
-DataExtractor::GetFloat (uint32_t *offset_ptr) const
+DataExtractor::GetFloat (offset_t *offset_ptr) const
 {
     typedef float float_type;
     float_type val = 0.0;
-    const uint8_t *src_data = PeekData (*offset_ptr, sizeof(float_type));
-    
-    if (src_data)
+    const size_t src_size = sizeof(float_type);
+    const float_type *src = (const float_type *)GetData (offset_ptr, src_size);
+    if (src)
     {
         if (m_byte_order != lldb::endian::InlHostByteOrder())
         {
+            const uint8_t *src_data = (const uint8_t *)src;
             uint8_t *dst_data = (uint8_t *)&val;
             for (int i=0; i<sizeof(float_type); ++i)
                 dst_data[sizeof(float_type) - 1 - i] = src_data[i];
         }
         else
         {
-            ::memcpy (&val, src_data, sizeof (float_type));
+            val = *src;
         }
-
-        // Advance the offset
-        *offset_ptr += sizeof(val);
     }
     return val;
 }
 
 double
-DataExtractor::GetDouble (uint32_t *offset_ptr) const
+DataExtractor::GetDouble (offset_t *offset_ptr) const
 {
     typedef double float_type;
     float_type val = 0.0;
-    const uint8_t *src_data = PeekData (*offset_ptr, sizeof(float_type));
-    
-    if (src_data)
+    const size_t src_size = sizeof(float_type);
+    const float_type *src = (const float_type *)GetData (offset_ptr, src_size);
+    if (src)
     {
         if (m_byte_order != lldb::endian::InlHostByteOrder())
         {
+            const uint8_t *src_data = (const uint8_t *)src;
             uint8_t *dst_data = (uint8_t *)&val;
             for (int i=0; i<sizeof(float_type); ++i)
                 dst_data[sizeof(float_type) - 1 - i] = src_data[i];
         }
         else
         {
-            ::memcpy (&val, src_data, sizeof (float_type));
+            val = *src;
         }
-
-        // Advance the offset
-        *offset_ptr += sizeof(val);
     }
     return val;
 }
 
 
 long double
-DataExtractor::GetLongDouble (uint32_t *offset_ptr) const
+DataExtractor::GetLongDouble (offset_t *offset_ptr) const
 {
     typedef long double float_type;
     float_type val = 0.0;
-    const uint8_t *src_data = PeekData (*offset_ptr, sizeof(float_type));
-    
-    if (src_data)
+    const size_t src_size = sizeof(float_type);
+    const float_type *src = (const float_type *)GetData (offset_ptr, src_size);
+    if (src)
     {
         if (m_byte_order != lldb::endian::InlHostByteOrder())
         {
+            const uint8_t *src_data = (const uint8_t *)src;
             uint8_t *dst_data = (uint8_t *)&val;
             for (int i=0; i<sizeof(float_type); ++i)
                 dst_data[sizeof(float_type) - 1 - i] = src_data[i];
         }
         else
         {
-            ::memcpy (&val, src_data, sizeof (float_type));
+            val = *src;
         }
-
-        // Advance the offset
-        *offset_ptr += sizeof(val);
     }
     return val;
 }
@@ -814,13 +803,13 @@ DataExtractor::GetLongDouble (uint32_t *
 // RETURNS the address that was extracted, or zero on failure.
 //------------------------------------------------------------------
 uint64_t
-DataExtractor::GetAddress (uint32_t *offset_ptr) const
+DataExtractor::GetAddress (offset_t *offset_ptr) const
 {
     return GetMaxU64 (offset_ptr, m_addr_size);
 }
 
 uint64_t
-DataExtractor::GetAddress_unchecked (uint32_t *offset_ptr) const
+DataExtractor::GetAddress_unchecked (offset_t *offset_ptr) const
 {
     return GetMaxU64_unchecked (offset_ptr, m_addr_size);
 }
@@ -834,7 +823,7 @@ DataExtractor::GetAddress_unchecked (uin
 // RETURNS the pointer that was extracted, or zero on failure.
 //------------------------------------------------------------------
 uint64_t
-DataExtractor::GetPointer (uint32_t *offset_ptr) const
+DataExtractor::GetPointer (offset_t *offset_ptr) const
 {
     return GetMaxU64 (offset_ptr, m_addr_size);
 }
@@ -847,7 +836,7 @@ DataExtractor::GetPointer (uint32_t *off
 //----------------------------------------------------------------------
 
 uint64_t
-DataExtractor::GetGNUEHPointer (uint32_t *offset_ptr, uint32_t eh_ptr_enc, lldb::addr_t pc_rel_addr, lldb::addr_t text_addr, lldb::addr_t data_addr)//, BSDRelocs *data_relocs) const
+DataExtractor::GetGNUEHPointer (offset_t *offset_ptr, uint32_t eh_ptr_enc, lldb::addr_t pc_rel_addr, lldb::addr_t text_addr, lldb::addr_t data_addr)//, BSDRelocs *data_relocs) const
 {
     if (eh_ptr_enc == DW_EH_PE_omit)
         return ULLONG_MAX;  // Value isn't in the buffer...
@@ -946,7 +935,7 @@ DataExtractor::GetGNUEHPointer (uint32_t
 }
 
 size_t
-DataExtractor::ExtractBytes (uint32_t offset, uint32_t length, ByteOrder dst_byte_order, void *dst) const
+DataExtractor::ExtractBytes (offset_t offset, offset_t length, ByteOrder dst_byte_order, void *dst) const
 {
     const uint8_t *src = PeekData (offset, length);
     if (src)
@@ -962,52 +951,18 @@ DataExtractor::ExtractBytes (uint32_t of
     }
     return 0;
 }
-//----------------------------------------------------------------------
-// Peeks at bytes in the contained data.
-//
-// Returns a valid pointer to bytes if "offset" is a valid offset in
-// and there are "length" bytes available, else NULL is returned.
-//----------------------------------------------------------------------
-const uint8_t*
-DataExtractor::PeekData (uint32_t offset, uint32_t length) const
-{
-    if ( length > 0 && ValidOffsetForDataOfSize(offset, length) )
-        return m_start + offset;
-    return NULL;
-}
-
-//----------------------------------------------------------------------
-// Returns a pointer to a bytes in this object's data at the offset
-// pointed to by "offset_ptr". If "length" is zero or too large,
-// then the offset pointed to by "offset_ptr" will not be updated
-// and NULL will be returned.
-//
-// Returns a pointer to the data if the offset and length are valid,
-// or NULL otherwise.
-//----------------------------------------------------------------------
-const void*
-DataExtractor::GetData (uint32_t *offset_ptr, uint32_t length) const
-{
-    const uint8_t* bytes = NULL;
-    register uint32_t offset = *offset_ptr;
-    if ( length > 0 && ValidOffsetForDataOfSize(offset, length) )
-    {
-        bytes = m_start + offset;
-        *offset_ptr = offset + length;
-    }
-    return bytes;
-}
 
 // Extract data and swap if needed when doing the copy
-uint32_t
-DataExtractor::CopyByteOrderedData (uint32_t src_offset, 
-                                    uint32_t src_len,
+lldb::offset_t
+DataExtractor::CopyByteOrderedData (offset_t src_offset,
+                                    offset_t src_len,
                                     void *dst_void_ptr, 
-                                    uint32_t dst_len, 
+                                    offset_t dst_len, 
                                     ByteOrder dst_byte_order) const
 {
     // Validate the source info
-    assert (ValidOffsetForDataOfSize(src_offset, src_len));
+    if (!ValidOffsetForDataOfSize(src_offset, src_len))
+        assert (ValidOffsetForDataOfSize(src_offset, src_len));
     assert (src_len > 0);
     assert (m_byte_order == eByteOrderBig || m_byte_order == eByteOrderLittle);
 
@@ -1031,7 +986,7 @@ DataExtractor::CopyByteOrderedData (uint
             // We are copying the entire value from src into dst.
             // Calculate how many, if any, zeroes we need for the most 
             // significant bytes if "dst_len" is greater than "src_len"...
-            const uint32_t num_zeroes = dst_len - src_len;
+            const size_t num_zeroes = dst_len - src_len;
             if (dst_byte_order == eByteOrderBig)
             {
                 // Big endian, so we lead with zeroes...
@@ -1124,22 +1079,31 @@ DataExtractor::CopyByteOrderedData (uint
 // updated.
 //----------------------------------------------------------------------
 const char*
-DataExtractor::GetCStr (uint32_t *offset_ptr) const
+DataExtractor::GetCStr (offset_t *offset_ptr) const
 {
-    const char *s = NULL;
-    if ( m_start < m_end )
+    const char *cstr = (const char *)PeekData (*offset_ptr, 1);
+    if (cstr)
     {
-        s = (char*)m_start + *offset_ptr;
-
-        size_t length = strlen(s) + 1;
-
-        if (!ValidOffsetForDataOfSize(*offset_ptr, length))
-            return NULL;
-
-        // Advance the offset
-        *offset_ptr += length;
+        const char *cstr_end = cstr;
+        const char *end = (const char *)m_end;
+        while (cstr_end < end && *cstr_end)
+            ++cstr_end;
+
+        // Now we are either at the end of the data or we point to the
+        // NULL C string terminator with cstr_end...
+        if (*cstr_end == '\0')
+        {
+            // Advance the offset with one extra byte for the NULL terminator
+            *offset_ptr += (cstr_end - cstr + 1);
+            return cstr;
+        }
+        
+        // We reached the end of the data without finding a NULL C string
+        // terminator. Fall through and return NULL otherwise anyone that
+        // would have used the result as a C string can wonder into
+        // unknown memory...
     }
-    return s;
+    return NULL;
 }
 
 //------------------------------------------------------------------
@@ -1151,11 +1115,9 @@ DataExtractor::GetCStr (uint32_t *offset
 // this object's data, else NULL is returned.
 //------------------------------------------------------------------
 const char *
-DataExtractor::PeekCStr (uint32_t offset) const
+DataExtractor::PeekCStr (offset_t offset) const
 {
-    if (ValidOffset (offset))
-        return (const char*)m_start + offset;
-    return NULL;
+    return (const char *)PeekData (offset, 1);
 }
 
 //----------------------------------------------------------------------
@@ -1167,9 +1129,12 @@ DataExtractor::PeekCStr (uint32_t offset
 // Returned the extracted integer value.
 //----------------------------------------------------------------------
 uint64_t
-DataExtractor::GetULEB128 (uint32_t *offset_ptr) const
+DataExtractor::GetULEB128 (offset_t *offset_ptr) const
 {
-    const uint8_t *src = m_start + *offset_ptr;
+    const uint8_t *src = (const uint8_t *)PeekData (*offset_ptr, 1);
+    if (src == NULL)
+        return 0;
+    
     const uint8_t *end = m_end;
     
     if (src < end)
@@ -1188,7 +1153,7 @@ DataExtractor::GetULEB128 (uint32_t *off
                 shift += 7;
             }
         }
-        *offset_ptr = (uint32_t)(src - m_start);
+        *offset_ptr = src - m_start;
         return result;
     }
     
@@ -1204,20 +1169,24 @@ DataExtractor::GetULEB128 (uint32_t *off
 // Returned the extracted integer value.
 //----------------------------------------------------------------------
 int64_t
-DataExtractor::GetSLEB128 (uint32_t *offset_ptr) const
+DataExtractor::GetSLEB128 (offset_t *offset_ptr) const
 {
-    int64_t result = 0;
-
-    if ( m_start < m_end )
+    const uint8_t *src = (const uint8_t *)PeekData (*offset_ptr, 1);
+    if (src == NULL)
+        return 0;
+    
+    const uint8_t *end = m_end;
+    
+    if (src < end)
     {
+        int64_t result = 0;
         int shift = 0;
-        int size = sizeof (uint32_t) * 8;
-        const uint8_t *src = m_start + *offset_ptr;
+        int size = sizeof (int64_t) * 8;
 
         uint8_t byte = 0;
         int bytecount = 0;
 
-        while (src < m_end)
+        while (src < end)
         {
             bytecount++;
             byte = *src++;
@@ -1232,8 +1201,9 @@ DataExtractor::GetSLEB128 (uint32_t *off
             result |= - (1 << shift);
 
         *offset_ptr += bytecount;
+        return result;
     }
-    return result;
+    return 0;
 }
 
 //----------------------------------------------------------------------
@@ -1245,27 +1215,30 @@ DataExtractor::GetSLEB128 (uint32_t *off
 // Returns the number of bytes consumed during the extraction.
 //----------------------------------------------------------------------
 uint32_t
-DataExtractor::Skip_LEB128 (uint32_t *offset_ptr) const
+DataExtractor::Skip_LEB128 (offset_t *offset_ptr) const
 {
     uint32_t bytes_consumed = 0;
-    if ( m_start < m_end )
+    const uint8_t *src = (const uint8_t *)PeekData (*offset_ptr, 1);
+    if (src == NULL)
+        return 0;
+        
+    const uint8_t *end = m_end;
+    
+    if (src < end)
     {
-        const uint8_t *start = m_start + *offset_ptr;
-        const uint8_t *src = start;
-
-        while ((src < m_end) && (*src++ & 0x80))
+        const uint8_t *src_pos = src;
+        while ((src_pos < end) && (*src_pos++ & 0x80))
             ++bytes_consumed;
-
-        *offset_ptr += src - start;
+        *offset_ptr += src_pos - src;
     }
     return bytes_consumed;
 }
 
-static uint32_t
-DumpAPInt (Stream *s, const DataExtractor &data, uint32_t offset, uint32_t byte_size, bool is_signed, unsigned radix)
+static lldb::offset_t
+DumpAPInt (Stream *s, const DataExtractor &data, lldb::offset_t offset, lldb::offset_t byte_size, bool is_signed, unsigned radix)
 {
     llvm::SmallVector<uint64_t, 2> uint64_array;
-    uint32_t bytes_left = byte_size;
+    lldb::offset_t bytes_left = byte_size;
     uint64_t u64;
     const lldb::ByteOrder byte_order = data.GetByteOrder();
     if (byte_order == lldb::eByteOrderLittle)
@@ -1279,7 +1252,7 @@ DumpAPInt (Stream *s, const DataExtracto
             }
             else
             {
-                u64 = data.GetMaxU64(&offset, bytes_left);
+                u64 = data.GetMaxU64(&offset, (uint32_t)bytes_left);
                 bytes_left = 0;
             }                        
             uint64_array.push_back(u64);
@@ -1287,8 +1260,8 @@ DumpAPInt (Stream *s, const DataExtracto
     }
     else if (byte_order == lldb::eByteOrderBig)
     {
-        uint32_t be_offset = offset + byte_size;
-        uint32_t temp_offset;
+        lldb::offset_t be_offset = offset + byte_size;
+        lldb::offset_t temp_offset;
         while (bytes_left > 0)
         {
             if (bytes_left >= 8)
@@ -1302,7 +1275,7 @@ DumpAPInt (Stream *s, const DataExtracto
             {
                 be_offset -= bytes_left;
                 temp_offset = be_offset;
-                u64 = data.GetMaxU64(&temp_offset, bytes_left);
+                u64 = data.GetMaxU64(&temp_offset, (uint32_t)bytes_left);
                 bytes_left = 0;
             }                        
             uint64_array.push_back(u64);
@@ -1329,13 +1302,13 @@ DumpAPInt (Stream *s, const DataExtracto
     return offset;
 }
 
-uint32_t
+lldb::offset_t
 DataExtractor::Dump (Stream *s,
-                     uint32_t start_offset,
+                     offset_t start_offset,
                      lldb::Format item_format,
-                     uint32_t item_byte_size,
-                     uint32_t item_count,
-                     uint32_t num_per_line,
+                     size_t item_byte_size,
+                     size_t item_count,
+                     size_t num_per_line,
                      uint64_t base_addr,
                      uint32_t item_bit_size,     // If zero, this is not a bitfield value, if non-zero, the value is a bitfield
                      uint32_t item_bit_offset,    // If "item_bit_size" is non-zero, this is the shift amount to apply to a bitfield
@@ -1350,7 +1323,7 @@ DataExtractor::Dump (Stream *s,
             item_byte_size = s->GetAddressByteSize();
     }
     
-    uint32_t offset = start_offset;
+    offset_t offset = start_offset;
 
     if (item_format == eFormatInstruction)
     {
@@ -1359,17 +1332,23 @@ DataExtractor::Dump (Stream *s,
             target_sp = exe_scope->CalculateTarget();
         if (target_sp)
         {
-            DisassemblerSP disassembler_sp (Disassembler::FindPlugin(target_sp->GetArchitecture(), NULL));
+            DisassemblerSP disassembler_sp (Disassembler::FindPlugin(target_sp->GetArchitecture(), NULL,  NULL));
             if (disassembler_sp)
             {
                 lldb::addr_t addr = base_addr + start_offset;
                 lldb_private::Address so_addr;
-                if (!target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
+				bool data_from_file = true;
+                if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
                 {
-                    so_addr.SetRawAddress(addr);
+                    data_from_file = false;
+                }
+                else
+                {
+                    if (target_sp->GetSectionLoadList().IsEmpty() || !target_sp->GetImages().ResolveFileAddress(addr, so_addr))
+                        so_addr.SetRawAddress(addr);
                 }
 
-                size_t bytes_consumed = disassembler_sp->DecodeInstructions (so_addr, *this, start_offset, item_count, false);
+                size_t bytes_consumed = disassembler_sp->DecodeInstructions (so_addr, *this, start_offset, item_count, false, data_from_file);
                 
                 if (bytes_consumed)
                 {
@@ -1391,7 +1370,7 @@ DataExtractor::Dump (Stream *s,
     if ((item_format == eFormatOSType || item_format == eFormatAddressInfo) && item_byte_size > 8)
         item_format = eFormatHex;
 
-    uint32_t line_start_offset = start_offset;
+    lldb::offset_t line_start_offset = start_offset;
     for (uint32_t count = 0; ValidOffset(offset) && count < item_count; ++count)
     {
         if ((count % num_per_line) == 0)
@@ -1400,13 +1379,13 @@ DataExtractor::Dump (Stream *s,
             {
                 if (item_format == eFormatBytesWithASCII && offset > line_start_offset)
                 {
-                    s->Printf("%*s", (num_per_line - (offset - line_start_offset)) * 3 + 2, "");
-                    Dump(s, line_start_offset, eFormatCharPrintable, 1, offset - line_start_offset, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
+                    s->Printf("%*s", static_cast<int>((num_per_line - (offset - line_start_offset)) * 3 + 2), "");
+                    Dump(s, line_start_offset, eFormatCharPrintable, 1, offset - line_start_offset, LLDB_INVALID_OFFSET, LLDB_INVALID_ADDRESS, 0, 0);
                 }
                 s->EOL();
             }
             if (base_addr != LLDB_INVALID_ADDRESS)
-                s->Printf ("0x%8.8llx: ", (uint64_t)(base_addr + (offset - start_offset)));
+                s->Printf ("0x%8.8" PRIx64 ": ", (uint64_t)(base_addr + (offset - start_offset)));
             line_start_offset = offset;
         }
         else
@@ -1426,7 +1405,7 @@ DataExtractor::Dump (Stream *s,
                 s->Printf ("%s", GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset) ? "true" : "false");
             else
             {
-                s->Printf("error: unsupported byte size (%u) for boolean format", item_byte_size);
+                s->Printf("error: unsupported byte size (%zu) for boolean format", item_byte_size);
                 return offset;
             }
             break;
@@ -1496,7 +1475,7 @@ DataExtractor::Dump (Stream *s,
                         if (item_byte_size == 1)
                             s->Printf ("\\x%2.2x", (uint8_t)ch); 
                         else
-                            s->Printf ("%llu", ch); 
+                            s->Printf ("%" PRIu64, ch);
                         break;
                     }
                 }
@@ -1514,7 +1493,7 @@ DataExtractor::Dump (Stream *s,
         case eFormatEnum:       // Print enum value as a signed integer when we don't get the enum type
         case eFormatDecimal:
             if (item_byte_size <= 8)
-                s->Printf ("%lld", GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
+                s->Printf ("%" PRId64, GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
             else
             {
                 const bool is_signed = true;
@@ -1525,7 +1504,7 @@ DataExtractor::Dump (Stream *s,
 
         case eFormatUnsigned:
             if (item_byte_size <= 8)
-                s->Printf ("%llu", GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
+                s->Printf ("%" PRIu64, GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
             else
             {
                 const bool is_signed = false;
@@ -1536,7 +1515,7 @@ DataExtractor::Dump (Stream *s,
 
         case eFormatOctal:
             if (item_byte_size <= 8)
-                s->Printf ("0%llo", GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
+                s->Printf ("0%" PRIo64, GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
             else
             {
                 const bool is_signed = false;
@@ -1582,7 +1561,7 @@ DataExtractor::Dump (Stream *s,
                 if (!cstr)
                 {
                     s->Printf("NULL");
-                    offset = UINT32_MAX;
+                    offset = LLDB_INVALID_OFFSET;
                 }
                 else
                 {
@@ -1626,16 +1605,16 @@ DataExtractor::Dump (Stream *s,
 
         case eFormatComplexInteger:
             {
-                uint32_t complex_int_byte_size = item_byte_size / 2;
+                size_t complex_int_byte_size = item_byte_size / 2;
                 
                 if (complex_int_byte_size <= 8)
                 {
-                    s->Printf("%llu", GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
-                    s->Printf(" + %llui", GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
+                    s->Printf("%" PRIu64, GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
+                    s->Printf(" + %" PRIu64 "i", GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0));
                 }
                 else
                 {
-                    s->Printf("error: unsupported byte size (%u) for complex integer format", item_byte_size);
+                    s->Printf("error: unsupported byte size (%zu) for complex integer format", item_byte_size);
                     return offset;
                 }
             }
@@ -1667,7 +1646,7 @@ DataExtractor::Dump (Stream *s,
             }
             else
             {
-                s->Printf("error: unsupported byte size (%u) for complex float format", item_byte_size);
+                s->Printf("error: unsupported byte size (%zu) for complex float format", item_byte_size);
                 return offset;
             }
             break;
@@ -1680,7 +1659,7 @@ DataExtractor::Dump (Stream *s,
                 bool wantsuppercase  = (item_format == eFormatHexUppercase);
                 if (item_byte_size <= 8)
                 {
-                    s->Printf(wantsuppercase ? "0x%*.*llX" : "0x%*.*llx", 2 * item_byte_size, 2 * item_byte_size, GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
+                    s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64, (int)(2 * item_byte_size), (int)(2 * item_byte_size), GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset));
                 }
                 else
                 {
@@ -1706,22 +1685,30 @@ DataExtractor::Dump (Stream *s,
             break;
 
         case eFormatFloat:
-            if (sizeof(float) == item_byte_size)
-            {
-                s->Printf ("%g", GetFloat (&offset));
-            }
-            else if (sizeof(double) == item_byte_size)
-            {
-                s->Printf ("%lg", GetDouble(&offset));
-            }
-            else if (sizeof(long double) == item_byte_size)
-            {
-                s->Printf ("%Lg", GetLongDouble(&offset));
-            }
-            else
             {
-                s->Printf("error: unsupported byte size (%u) for float format", item_byte_size);
-                return offset;
+                std::ostringstream ss;
+                if (item_byte_size == sizeof(float))
+                {
+                    ss.precision(std::numeric_limits<float>::digits10);
+                    ss << GetFloat(&offset);
+                } 
+                else if (item_byte_size == sizeof(double))
+                {
+                    ss.precision(std::numeric_limits<double>::digits10);
+                    ss << GetDouble(&offset);
+                }
+                else if (item_byte_size == sizeof(long double))
+                {
+                    ss.precision(std::numeric_limits<long double>::digits10);
+                    ss << GetLongDouble(&offset);
+                }
+                else
+                {
+                    s->Printf("error: unsupported byte size (%zu) for float format", item_byte_size);
+                    return offset;
+                }
+                ss.flush();
+                s->Printf("%s", ss.str().c_str());
             }
             break;
 
@@ -1736,7 +1723,7 @@ DataExtractor::Dump (Stream *s,
         case eFormatAddressInfo:
             {
                 addr_t addr = GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset);
-                s->Printf("0x%*.*llx", 2 * item_byte_size, 2 * item_byte_size, addr);
+                s->Printf("0x%*.*" PRIx64, (int)(2 * item_byte_size), (int)(2 * item_byte_size), addr);
                 if (exe_scope)
                 {
                     TargetSP target_sp (exe_scope->CalculateTarget());
@@ -1780,7 +1767,7 @@ DataExtractor::Dump (Stream *s,
             }
             else
             {
-                s->Printf("error: unsupported byte size (%u) for hex float format", item_byte_size);
+                s->Printf("error: unsupported byte size (%zu) for hex float format", item_byte_size);
                 return offset;
             }
             break;
@@ -1838,7 +1825,7 @@ DataExtractor::Dump (Stream *s,
 
         case eFormatVectorOfUInt64:
             s->PutChar('{');
-            offset = Dump (s, offset, eFormatHex,     sizeof(uint32_t), item_byte_size / sizeof(uint32_t), item_byte_size / sizeof(uint32_t), LLDB_INVALID_ADDRESS, 0, 0);
+            offset = Dump (s, offset, eFormatHex,     sizeof(uint64_t), item_byte_size / sizeof(uint64_t), item_byte_size / sizeof(uint64_t), LLDB_INVALID_ADDRESS, 0, 0);
             s->PutChar('}');
             break;
 
@@ -1864,8 +1851,8 @@ DataExtractor::Dump (Stream *s,
 
     if (item_format == eFormatBytesWithASCII && offset > line_start_offset)
     {
-        s->Printf("%*s", (num_per_line - (offset - line_start_offset)) * 3 + 2, "");
-        Dump(s, line_start_offset, eFormatCharPrintable, 1, offset - line_start_offset, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
+        s->Printf("%*s", static_cast<int>((num_per_line - (offset - line_start_offset)) * 3 + 2), "");
+        Dump(s, line_start_offset, eFormatCharPrintable, 1, offset - line_start_offset, LLDB_INVALID_OFFSET, LLDB_INVALID_ADDRESS, 0, 0);
     }
     return offset;  // Return the offset at which we ended up
 }
@@ -1882,12 +1869,12 @@ DataExtractor::Dump (Stream *s,
 // string will be used for the supplied "type". If the stream "s"
 // is NULL, then the output will be send to Log().
 //----------------------------------------------------------------------
-uint32_t
+lldb::offset_t
 DataExtractor::PutToLog
 (
     Log *log,
-    uint32_t start_offset,
-    uint32_t length,
+    offset_t start_offset,
+    offset_t length,
     uint64_t base_addr,
     uint32_t num_per_line,
     DataExtractor::Type type,
@@ -1897,8 +1884,8 @@ DataExtractor::PutToLog
     if (log == NULL)
         return start_offset;
 
-    uint32_t offset;
-    uint32_t end_offset;
+    offset_t offset;
+    offset_t end_offset;
     uint32_t count;
     StreamString sstr;
     for (offset = start_offset, end_offset = offset + length, count = 0; ValidOffset(offset) && offset < end_offset; ++count)
@@ -1913,12 +1900,11 @@ DataExtractor::PutToLog
             }
             // Reset string offset and fill the current line string with address:
             if (base_addr != LLDB_INVALID_ADDRESS)
-                sstr.Printf("0x%8.8llx:", (uint64_t)(base_addr + (offset - start_offset)));
+                sstr.Printf("0x%8.8" PRIx64 ":", (uint64_t)(base_addr + (offset - start_offset)));
         }
 
         switch (type)
         {
-            default:
             case TypeUInt8:   sstr.Printf (format ? format : " %2.2x", GetU8(&offset)); break;
             case TypeChar:
                 {
@@ -1928,10 +1914,10 @@ DataExtractor::PutToLog
                 break;
             case TypeUInt16:  sstr.Printf (format ? format : " %4.4x",       GetU16(&offset)); break;
             case TypeUInt32:  sstr.Printf (format ? format : " %8.8x",       GetU32(&offset)); break;
-            case TypeUInt64:  sstr.Printf (format ? format : " %16.16llx",   GetU64(&offset)); break;
-            case TypePointer: sstr.Printf (format ? format : " 0x%llx",      GetAddress(&offset)); break;
-            case TypeULEB128: sstr.Printf (format ? format : " 0x%llx",      GetULEB128(&offset)); break;
-            case TypeSLEB128: sstr.Printf (format ? format : " %lld",        GetSLEB128(&offset)); break;
+            case TypeUInt64:  sstr.Printf (format ? format : " %16.16" PRIx64,   GetU64(&offset)); break;
+            case TypePointer: sstr.Printf (format ? format : " 0x%" PRIx64,      GetAddress(&offset)); break;
+            case TypeULEB128: sstr.Printf (format ? format : " 0x%" PRIx64,      GetULEB128(&offset)); break;
+            case TypeSLEB128: sstr.Printf (format ? format : " %" PRId64,        GetSLEB128(&offset)); break;
         }
     }
 
@@ -1947,7 +1933,7 @@ DataExtractor::PutToLog
 // Dump out a UUID starting at 'offset' bytes into the buffer
 //----------------------------------------------------------------------
 void
-DataExtractor::DumpUUID (Stream *s, uint32_t offset) const
+DataExtractor::DumpUUID (Stream *s, offset_t offset) const
 {
     if (s)
     {
@@ -1959,7 +1945,7 @@ DataExtractor::DumpUUID (Stream *s, uint
         }
         else
         {
-            s->Printf("<not enough data for UUID at offset 0x%8.8x>", offset);
+            s->Printf("<not enough data for UUID at offset 0x%8.8" PRIx64 ">", offset);
         }
     }
 }
@@ -2030,7 +2016,7 @@ DataExtractor::Append(DataExtractor& rhs
 }
 
 bool
-DataExtractor::Append(void* buf, uint32_t length)
+DataExtractor::Append(void* buf, offset_t length)
 {
     if (buf == NULL)
         return false;

Removed: lldb/branches/lldb-platform-work/source/Core/DataVisualization.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Core/DataVisualization.cpp?rev=183467&view=auto
==============================================================================
--- lldb/branches/lldb-platform-work/source/Core/DataVisualization.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Core/DataVisualization.cpp (removed)
@@ -1,277 +0,0 @@
-//===-- DataVisualization.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/Core/DataVisualization.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-
-#include "lldb/Core/Debugger.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-static FormatManager&
-GetFormatManager()
-{
-    static FormatManager g_format_manager;
-    return g_format_manager;
-}
-
-void
-DataVisualization::ForceUpdate ()
-{
-    GetFormatManager().Changed();
-}
-
-uint32_t
-DataVisualization::GetCurrentRevision ()
-{
-    return GetFormatManager().GetCurrentRevision();
-}
-
-lldb::TypeFormatImplSP
-DataVisualization::ValueFormats::GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
-{
-    lldb::TypeFormatImplSP entry;
-    GetFormatManager().GetValueNavigator().Get(valobj, entry, use_dynamic);
-    return entry;
-}
-
-lldb::TypeFormatImplSP
-DataVisualization::ValueFormats::GetFormat (const ConstString &type)
-{
-    lldb::TypeFormatImplSP entry;
-    GetFormatManager().GetValueNavigator().Get(type, entry);
-    return entry;
-}
-
-void
-DataVisualization::ValueFormats::Add (const ConstString &type, const lldb::TypeFormatImplSP &entry)
-{
-    GetFormatManager().GetValueNavigator().Add(FormatManager::GetValidTypeName(type),entry);
-}
-
-bool
-DataVisualization::ValueFormats::Delete (const ConstString &type)
-{
-    return GetFormatManager().GetValueNavigator().Delete(type);
-}
-
-void
-DataVisualization::ValueFormats::Clear ()
-{
-    GetFormatManager().GetValueNavigator().Clear();
-}
-
-void
-DataVisualization::ValueFormats::LoopThrough (TypeFormatImpl::ValueCallback callback, void* callback_baton)
-{
-    GetFormatManager().GetValueNavigator().LoopThrough(callback, callback_baton);
-}
-
-uint32_t
-DataVisualization::ValueFormats::GetCount ()
-{
-    return GetFormatManager().GetValueNavigator().GetCount();
-}
-
-lldb::TypeNameSpecifierImplSP
-DataVisualization::ValueFormats::GetTypeNameSpecifierForFormatAtIndex (uint32_t index)
-{
-    return GetFormatManager().GetValueNavigator().GetTypeNameSpecifierAtIndex(index);
-}
-
-lldb::TypeFormatImplSP
-DataVisualization::ValueFormats::GetFormatAtIndex (uint32_t index)
-{
-    return GetFormatManager().GetValueNavigator().GetAtIndex(index);
-}
-
-lldb::TypeSummaryImplSP
-DataVisualization::GetSummaryFormat (ValueObject& valobj,
-                                     lldb::DynamicValueType use_dynamic)
-{
-    return GetFormatManager().GetSummaryFormat(valobj, use_dynamic);
-}
-
-lldb::TypeSummaryImplSP
-DataVisualization::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
-    return GetFormatManager().GetSummaryForType(type_sp);
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP
-DataVisualization::GetSyntheticChildren (ValueObject& valobj,
-                                         lldb::DynamicValueType use_dynamic)
-{
-    return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic);
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP
-DataVisualization::GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
-    return GetFormatManager().GetSyntheticChildrenForType(type_sp);
-}
-#endif
-
-lldb::TypeFilterImplSP
-DataVisualization::GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
-    return GetFormatManager().GetFilterForType(type_sp);
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::TypeSyntheticImplSP
-DataVisualization::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
-    return GetFormatManager().GetSyntheticForType(type_sp);
-}
-#endif
-
-bool
-DataVisualization::AnyMatches (ConstString type_name,
-                               TypeCategoryImpl::FormatCategoryItems items,
-                               bool only_enabled,
-                               const char** matching_category,
-                               TypeCategoryImpl::FormatCategoryItems* matching_type)
-{
-    return GetFormatManager().AnyMatches(type_name,
-                                         items,
-                                         only_enabled,
-                                         matching_category,
-                                         matching_type);
-}
-
-bool
-DataVisualization::Categories::GetCategory (const ConstString &category, lldb::TypeCategoryImplSP &entry,
-                                            bool allow_create)
-{
-    entry = GetFormatManager().GetCategory(category, allow_create);
-    return (entry.get() != NULL);
-}
-
-void
-DataVisualization::Categories::Add (const ConstString &category)
-{
-    GetFormatManager().GetCategory(category);
-}
-
-bool
-DataVisualization::Categories::Delete (const ConstString &category)
-{
-    GetFormatManager().DisableCategory(category);
-    return GetFormatManager().DeleteCategory(category);
-}
-
-void
-DataVisualization::Categories::Clear ()
-{
-    GetFormatManager().ClearCategories();
-}
-
-void
-DataVisualization::Categories::Clear (const ConstString &category)
-{
-    GetFormatManager().GetCategory(category)->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
-}
-
-void
-DataVisualization::Categories::Enable (const ConstString& category,
-                                       CategoryMap::Position pos)
-{
-    if (GetFormatManager().GetCategory(category)->IsEnabled())
-        GetFormatManager().DisableCategory(category);
-    GetFormatManager().EnableCategory(category, pos);
-}
-
-void
-DataVisualization::Categories::Disable (const ConstString& category)
-{
-    if (GetFormatManager().GetCategory(category)->IsEnabled() == true)
-        GetFormatManager().DisableCategory(category);
-}
-
-void
-DataVisualization::Categories::Enable (const lldb::TypeCategoryImplSP& category,
-                                       CategoryMap::Position pos)
-{
-    if (category.get())
-    {
-        if (category->IsEnabled())
-            GetFormatManager().DisableCategory(category);
-        GetFormatManager().EnableCategory(category, pos);
-    }
-}
-
-void
-DataVisualization::Categories::Disable (const lldb::TypeCategoryImplSP& category)
-{
-    if (category.get() && category->IsEnabled() == true)
-        GetFormatManager().DisableCategory(category);
-}
-
-void
-DataVisualization::Categories::LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton)
-{
-    GetFormatManager().LoopThroughCategories(callback, callback_baton);
-}
-
-uint32_t
-DataVisualization::Categories::GetCount ()
-{
-    return GetFormatManager().GetCategoriesCount();
-}
-
-lldb::TypeCategoryImplSP
-DataVisualization::Categories::GetCategoryAtIndex (uint32_t index)
-{
-    return GetFormatManager().GetCategoryAtIndex(index);
-}
-
-bool
-DataVisualization::NamedSummaryFormats::GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry)
-{
-    return GetFormatManager().GetNamedSummaryNavigator().Get(type,entry);
-}
-
-void
-DataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry)
-{
-    GetFormatManager().GetNamedSummaryNavigator().Add(FormatManager::GetValidTypeName(type),entry);
-}
-
-bool
-DataVisualization::NamedSummaryFormats::Delete (const ConstString &type)
-{
-    return GetFormatManager().GetNamedSummaryNavigator().Delete(type);
-}
-
-void
-DataVisualization::NamedSummaryFormats::Clear ()
-{
-    GetFormatManager().GetNamedSummaryNavigator().Clear();
-}
-
-void
-DataVisualization::NamedSummaryFormats::LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton)
-{
-    GetFormatManager().GetNamedSummaryNavigator().LoopThrough(callback, callback_baton);
-}
-
-uint32_t
-DataVisualization::NamedSummaryFormats::GetCount ()
-{
-    return GetFormatManager().GetNamedSummaryNavigator().GetCount();
-}





More information about the llvm-branch-commits mailing list