[Lldb-commits] [lldb] r115854 - in /lldb/trunk: include/lldb/API/SBError.h include/lldb/API/SBProcess.h include/lldb/API/SBTarget.h include/lldb/API/SBValue.h source/API/SBTarget.cpp source/API/SBValue.cpp

Greg Clayton gclayton at apple.com
Wed Oct 6 15:10:18 PDT 2010


Author: gclayton
Date: Wed Oct  6 17:10:17 2010
New Revision: 115854

URL: http://llvm.org/viewvc/llvm-project?rev=115854&view=rev
Log:
Expose the error contained within an SBValue.

Move anything that creates a new process into SBTarget. Marked some functions
as deprecated. I will remove them after our new API changes make it through
a build cycle.


Modified:
    lldb/trunk/include/lldb/API/SBError.h
    lldb/trunk/include/lldb/API/SBProcess.h
    lldb/trunk/include/lldb/API/SBTarget.h
    lldb/trunk/include/lldb/API/SBValue.h
    lldb/trunk/source/API/SBTarget.cpp
    lldb/trunk/source/API/SBValue.cpp

Modified: lldb/trunk/include/lldb/API/SBError.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBError.h?rev=115854&r1=115853&r2=115854&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBError.h (original)
+++ lldb/trunk/include/lldb/API/SBError.h Wed Oct  6 17:10:17 2010
@@ -75,6 +75,8 @@
     friend class SBHostOS;
     friend class SBInputReader;
     friend class SBProcess;
+    friend class SBTarget;
+    friend class SBValue;
 
 #ifndef SWIG
 

Modified: lldb/trunk/include/lldb/API/SBProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=115854&r1=115853&r2=115854&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBProcess.h (original)
+++ lldb/trunk/include/lldb/API/SBProcess.h Wed Oct  6 17:10:17 2010
@@ -112,9 +112,11 @@
     lldb::pid_t
     AttachByPID (lldb::pid_t pid);  // DEPRECATED: will be removed in a few builds in favor of SBError AttachByPID(pid_t)
 
+    // DEPRECATED: relocated to "SBProcess SBTarget::AttachToProcess (lldb::pid_t pid, SBError& error)"
     SBError
     Attach (lldb::pid_t pid);
 
+    // DEPRECATED: relocated to "SBProcess SBTarget::AttachToProcess (const char *name, bool wait_for_launch, SBError& error)"
     SBError
     AttachByName (const char *name, bool wait_for_launch);
 

Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=115854&r1=115853&r2=115854&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Wed Oct  6 17:10:17 2010
@@ -55,6 +55,8 @@
     lldb::SBProcess
     GetProcess ();
 
+    // DEPRECATED in favor of the function below that contains an SBError as the
+    // last parameter.
     lldb::SBProcess
     LaunchProcess (char const **argv,
                    char const **envp,
@@ -62,6 +64,23 @@
                    uint32_t launch_flags,   // See lldb::LaunchFlags
                    bool stop_at_entry);
 
+    lldb::SBProcess
+    LaunchProcess (char const **argv,
+                   char const **envp,
+                   const char *tty,
+                   uint32_t launch_flags,   // See lldb::LaunchFlags
+                   bool stop_at_entry,
+                   SBError& error);
+
+    lldb::SBProcess
+    AttachToProcess (lldb::pid_t pid, // The process ID to attach to
+                     SBError& error); // An error explaining what went wrong if attach fails
+
+    lldb::SBProcess
+    AttachToProcess (const char *name,  // basename of process to attach to
+                     bool wait_for,     // if true wait for a new instance of "name" to be launched
+                     SBError& error);   // An error explaining what went wrong if attach fails
+
     lldb::SBFileSpec
     GetExecutable ();
 

Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=115854&r1=115853&r2=115854&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Wed Oct  6 17:10:17 2010
@@ -25,6 +25,9 @@
 
     bool
     IsValid() const;
+    
+    SBError
+    GetError();
 
     const char *
     GetName();

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=115854&r1=115853&r2=115854&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Wed Oct  6 17:10:17 2010
@@ -129,6 +129,22 @@
     bool stop_at_entry
 )
 {
+    SBError sb_error;    
+    return LaunchProcess (argv, envp, tty, launch_flags, stop_at_entry, sb_error);
+}
+
+
+SBProcess
+SBTarget::LaunchProcess
+(
+    char const **argv,
+    char const **envp,
+    const char *tty,
+    uint32_t launch_flags,
+    bool stop_at_entry,
+    SBError &error
+)
+{
     SBProcess sb_process;
     if (m_opaque_sp)
     {
@@ -146,7 +162,7 @@
 
         if (sb_process.IsValid())
         {
-            Error error (sb_process->Launch (argv, envp, launch_flags, tty, tty, tty));
+            error.SetError (sb_process->Launch (argv, envp, launch_flags, tty, tty, tty));
             if (error.Success())
             {
                 // We we are stopping at the entry point, we can return now!
@@ -158,7 +174,7 @@
                 if (state == eStateStopped)
                 {
                     // resume the process to skip the entry point
-                    error = sb_process->Resume();
+                    error.SetError (sb_process->Resume());
                     if (error.Success())
                     {
                         // If we are doing synchronous mode, then wait for the
@@ -169,8 +185,96 @@
                 }
             }
         }
+        else
+        {
+            error.SetErrorString ("unable to create lldb_private::Process");
+        }
+    }
+    else
+    {
+        error.SetErrorString ("SBTarget is invalid");
+    }
+    return sb_process;
+}
+
+
+lldb::SBProcess
+SBTarget::AttachToProcess 
+(
+    lldb::pid_t pid,// The process ID to attach to
+    SBError& error  // An error explaining what went wrong if attach fails
+)
+{
+    SBProcess sb_process;
+    if (m_opaque_sp)
+    {
+        // DEPRECATED, this will change when CreateProcess is removed...
+        if (m_opaque_sp->GetProcessSP())
+        {
+            sb_process.SetProcess(m_opaque_sp->GetProcessSP());
+        }
+        else
+        {
+            // When launching, we always want to create a new process When
+            // SBTarget::CreateProcess is removed, this will always happen.
+            sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
+        }
+
+        if (sb_process.IsValid())
+        {
+            error.SetError (sb_process->Attach (pid));
+        }
+        else
+        {
+            error.SetErrorString ("unable to create lldb_private::Process");
+        }
+    }
+    else
+    {
+        error.SetErrorString ("SBTarget is invalid");
     }
     return sb_process;
+
+}
+
+lldb::SBProcess
+SBTarget::AttachToProcess 
+(
+    const char *name,   // basename of process to attach to
+    bool wait_for,      // if true wait for a new instance of "name" to be launched
+    SBError& error      // An error explaining what went wrong if attach fails
+)
+{
+    SBProcess sb_process;
+    if (m_opaque_sp)
+    {
+        // DEPRECATED, this will change when CreateProcess is removed...
+        if (m_opaque_sp->GetProcessSP())
+        {
+            sb_process.SetProcess(m_opaque_sp->GetProcessSP());
+        }
+        else
+        {
+            // When launching, we always want to create a new process When
+            // SBTarget::CreateProcess is removed, this will always happen.
+            sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
+        }
+
+        if (sb_process.IsValid())
+        {
+            error.SetError (sb_process->Attach (name, wait_for));
+        }
+        else
+        {
+            error.SetErrorString ("unable to create lldb_private::Process");
+        }
+    }
+    else
+    {
+        error.SetErrorString ("SBTarget is invalid");
+    }
+    return sb_process;
+
 }
 
 SBFileSpec

Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=115854&r1=115853&r2=115854&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Wed Oct  6 17:10:17 2010
@@ -53,6 +53,17 @@
     return  (m_opaque_sp.get() != NULL);
 }
 
+SBError
+SBValue::GetError()
+{
+    SBError sb_error;
+    
+    if (m_opaque_sp.get())
+        sb_error.SetError(m_opaque_sp->GetError());
+    
+    return sb_error;
+}
+
 const char *
 SBValue::GetName()
 {





More information about the lldb-commits mailing list