diff options
| author | Greg Clayton <gclayton@apple.com> | 2010-10-06 22:10:17 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2010-10-06 22:10:17 +0000 |
| commit | 524e60b4e4a20bd674e5401c866fc56106369226 (patch) | |
| tree | d8a9015d00ebc4a8a5b2bdd26f2aefcd0092b2a6 /lldb | |
| parent | 24ab1ce8c2d8e3429f54b6c2ede5c5ed8fe79192 (diff) | |
| download | bcm5719-llvm-524e60b4e4a20bd674e5401c866fc56106369226.tar.gz bcm5719-llvm-524e60b4e4a20bd674e5401c866fc56106369226.zip | |
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.
llvm-svn: 115854
Diffstat (limited to 'lldb')
| -rw-r--r-- | lldb/include/lldb/API/SBError.h | 2 | ||||
| -rw-r--r-- | lldb/include/lldb/API/SBProcess.h | 2 | ||||
| -rw-r--r-- | lldb/include/lldb/API/SBTarget.h | 19 | ||||
| -rw-r--r-- | lldb/include/lldb/API/SBValue.h | 3 | ||||
| -rw-r--r-- | lldb/source/API/SBTarget.cpp | 108 | ||||
| -rw-r--r-- | lldb/source/API/SBValue.cpp | 11 |
6 files changed, 143 insertions, 2 deletions
diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h index cbea6910ffa..7d695bbbc51 100644 --- a/lldb/include/lldb/API/SBError.h +++ b/lldb/include/lldb/API/SBError.h @@ -75,6 +75,8 @@ protected: friend class SBHostOS; friend class SBInputReader; friend class SBProcess; + friend class SBTarget; + friend class SBValue; #ifndef SWIG diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 440622b3526..78c41ba00b6 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -112,9 +112,11 @@ public: 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); diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 8a47f4428d4..3bd2f079d0c 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -55,6 +55,8 @@ public: 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 @@ public: 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 (); diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index c247339ef5b..e632bb61036 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -25,6 +25,9 @@ public: bool IsValid() const; + + SBError + GetError(); const char * GetName(); diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 27da3aa9186..087b7dfafb1 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -129,6 +129,22 @@ SBTarget::LaunchProcess 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 @@ SBTarget::LaunchProcess 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 @@ SBTarget::LaunchProcess 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 @@ SBTarget::LaunchProcess } } } + 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/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 6f63f53d745..6fbd5fd1777 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -53,6 +53,17 @@ SBValue::IsValid () const 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() { |

