[Lldb-commits] [lldb] r178201 - Return a useful error message from ValidatePlan if the expression can't be made for some reason.

Jim Ingham jingham at apple.com
Wed Mar 27 17:04:05 PDT 2013


Author: jingham
Date: Wed Mar 27 19:04:05 2013
New Revision: 178201

URL: http://llvm.org/viewvc/llvm-project?rev=178201&view=rev
Log:
Return a useful error message from ValidatePlan if the expression can't be made for some reason.

Modified:
    lldb/trunk/source/Target/ThreadPlanCallFunction.cpp

Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=178201&r1=178200&r2=178201&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Wed Mar 27 19:04:05 2013
@@ -68,8 +68,9 @@ ThreadPlanCallFunction::ConstructorSetup
     process_sp->ReadUnsignedIntegerFromMemory(m_function_sp, 4, 0, error);
     if (!error.Success())
     {
+        m_constructor_errors.Printf ("Trying to put the stack in unreadable memory at: 0x%" PRIx64 ".", m_function_sp);
         if (log)
-            log->Printf ("ThreadPlanCallFunction(%p): Trying to put the stack in unreadable memory at: 0x%" PRIx64 ".", this, m_function_sp);
+            log->Printf ("ThreadPlanCallFunction(%p): %s.", this, m_constructor_errors.GetData());
         return false;
     }
     
@@ -77,8 +78,9 @@ ThreadPlanCallFunction::ConstructorSetup
 
     if (exe_module == NULL)
     {
+        m_constructor_errors.Printf ("Can't execute code without an executable module.");
         if (log)
-            log->Printf ("ThreadPlanCallFunction(%p): Can't execute code without an executable module.", this);
+            log->Printf ("ThreadPlanCallFunction(%p): %s.", this, m_constructor_errors.GetData());
         return false;
     }
     else
@@ -86,17 +88,21 @@ ThreadPlanCallFunction::ConstructorSetup
         ObjectFile *objectFile = exe_module->GetObjectFile();
         if (!objectFile)
         {
+            m_constructor_errors.Printf ("Could not find object file for module \"%s\".", 
+                                         exe_module->GetFileSpec().GetFilename().AsCString());
+
             if (log)
-                log->Printf ("ThreadPlanCallFunction(%p): Could not find object file for module \"%s\".", 
-                             this, exe_module->GetFileSpec().GetFilename().AsCString());
+                log->Printf ("ThreadPlanCallFunction(%p): %s.", this, m_constructor_errors.GetData());
             return false;
         }
+        
         m_start_addr = objectFile->GetEntryPointAddress();
         if (!m_start_addr.IsValid())
         {
+            m_constructor_errors.Printf ("Could not find entry point address for executable module \"%s\".", 
+                                         exe_module->GetFileSpec().GetFilename().AsCString());
             if (log)
-                log->Printf ("ThreadPlanCallFunction(%p): Could not find entry point address for executable module \"%s\".", 
-                             this, exe_module->GetFileSpec().GetFilename().AsCString());
+                log->Printf ("ThreadPlanCallFunction(%p): %s.", this, m_constructor_errors.GetData());
             return false;
         }
     }
@@ -109,8 +115,9 @@ ThreadPlanCallFunction::ConstructorSetup
 
     if (!thread.CheckpointThreadState (m_stored_thread_state))
     {
+        m_constructor_errors.Printf ("Setting up ThreadPlanCallFunction, failed to checkpoint thread state.");
         if (log)
-            log->Printf ("ThreadPlanCallFunction(%p): Setting up ThreadPlanCallFunction, failed to checkpoint thread state.", this);
+            log->Printf ("ThreadPlanCallFunction(%p): %s.", this, m_constructor_errors.GetData());
         return false;
     }
     function_load_addr = m_function_addr.GetLoadAddress (target_sp.get());
@@ -330,7 +337,16 @@ bool
 ThreadPlanCallFunction::ValidatePlan (Stream *error)
 {
     if (!m_valid)
+    {
+        if (error)
+        {
+            if (m_constructor_errors.GetSize() > 0)
+                error->PutCString (m_constructor_errors.GetData());
+            else
+                error->PutCString ("Unknown error");
+        }
         return false;
+    }
 
     return true;
 }





More information about the lldb-commits mailing list