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.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@115854 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp
index 27da3aa..087b7df 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -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,10 +185,98 @@
}
}
}
+ 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
SBTarget::GetExecutable ()
{
diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp
index 6f63f53..6fbd5fd 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -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()
{