Improved API logging.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@117772 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBCommandInterpreter.cpp b/source/API/SBCommandInterpreter.cpp
index dff852d..0c30ac9 100644
--- a/source/API/SBCommandInterpreter.cpp
+++ b/source/API/SBCommandInterpreter.cpp
@@ -36,8 +36,8 @@
     Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
 
     if (log)
-        log->Printf ("SBCommandInterpreter::SBCommandInterpreter (interpreter = %p)"
-                     " => this.obj = %p", interpreter, m_opaque_ptr);
+        log->Printf ("SBCommandInterpreter::SBCommandInterpreter (interpreter=%p)"
+                     " => SBCommandInterpreter(%p)", interpreter, m_opaque_ptr);
 }
 
 SBCommandInterpreter::~SBCommandInterpreter ()
@@ -73,8 +73,8 @@
     Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
 
     if (log)
-        log->Printf("SBCommandInterpreter::HandleCommand (this.obj=%p, command_line='%s', result=%p, "
-                    "add_to_history='%s')", m_opaque_ptr, command_line, &result, (add_to_history ? "true" : "false"));
+        log->Printf ("SBCommandInterpreter(%p)::HandleCommand (command_line='%s', result=%p, add_to_history=%i)", 
+                     m_opaque_ptr, command_line, &result, add_to_history);
 
     result.Clear();
     if (m_opaque_ptr)
@@ -93,8 +93,8 @@
     {
         SBStream sstr;
         result.GetDescription (sstr);
-        log->Printf ("SBCommandInterpreter::HandleCommand ('%s') => SBCommandReturnObject: '%s'", 
-                     command_line, sstr.GetData());
+        log->Printf ("SBCommandInterpreter(%p)::HandleCommand (\"%s\") => SBCommandReturnObject(%p): '%s'", 
+                     m_opaque_ptr, command_line, result.get(), sstr.GetData());
     }
 
     return result.GetStatus();
@@ -156,27 +156,39 @@
         if (target)
             process.SetProcess(target->GetProcessSP());
     }
+    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+
+    if (log)
+        log->Printf ("SBCommandInterpreter(%p)::GetProcess () => SBProcess(%p)", 
+                     m_opaque_ptr, process.get());
+
+    
     return process;
 }
 
 ssize_t
 SBCommandInterpreter::WriteToScriptInterpreter (const char *src)
 {
-    if (m_opaque_ptr && src && src[0])
-        return WriteToScriptInterpreter (src, strlen(src));
-    return 0;
+    return WriteToScriptInterpreter (src, strlen(src));
 }
 
 ssize_t
 SBCommandInterpreter::WriteToScriptInterpreter (const char *src, size_t src_len)
 {
+    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+
+    ssize_t bytes_written = 0;
     if (m_opaque_ptr && src && src[0])
     {
         ScriptInterpreter *script_interpreter = m_opaque_ptr->GetScriptInterpreter();
         if (script_interpreter)
-            return ::write (script_interpreter->GetMasterFileDescriptor(), src, src_len);
+            bytes_written = ::write (script_interpreter->GetMasterFileDescriptor(), src, src_len);
     }
-    return 0;
+    if (log)
+        log->Printf ("SBCommandInterpreter(%p)::WriteToScriptInterpreter (src=\"%s\", src_len=%zu) => %zi", 
+                     m_opaque_ptr, src, src_len, bytes_written);
+
+    return bytes_written;
 }
 
 
@@ -212,6 +224,12 @@
         result->AppendError ("SBCommandInterpreter is not valid");
         result->SetStatus (eReturnStatusFailed);
     }
+    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+
+    if (log)
+        log->Printf ("SBCommandInterpreter(%p)::SourceInitFileInHomeDirectory (&SBCommandReturnObject(%p))", 
+                     m_opaque_ptr, result.get());
+
 }
 
 void
@@ -227,6 +245,11 @@
         result->AppendError ("SBCommandInterpreter is not valid");
         result->SetStatus (eReturnStatusFailed);
     }
+    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+
+    if (log)
+        log->Printf ("SBCommandInterpreter(%p)::SourceInitFileInCurrentWorkingDirectory (&SBCommandReturnObject(%p))", 
+                     m_opaque_ptr, result.get());
 }
 
 SBBroadcaster
@@ -234,13 +257,10 @@
 {
     Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
 
-    //if (log)
-    //    log->Printf ("SBCommandInterpreter::GetBroadcaster ()");
-
     SBBroadcaster broadcaster (m_opaque_ptr, false);
 
     if (log)
-        log->Printf ("SBCommandInterpreter::GetBroadcaster (this.obj=%p) => SBBroadcaster (this.m_opaque_ptr=%p)", 
+        log->Printf ("SBCommandInterpreter(%p)::GetBroadcaster() => SBBroadcaster(%p)", 
                      m_opaque_ptr, broadcaster.get());
 
     return broadcaster;