diff options
| author | Greg Clayton <gclayton@apple.com> | 2011-06-24 03:21:43 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2011-06-24 03:21:43 +0000 |
| commit | 0c74e78d633181698f22b95871e141af39111260 (patch) | |
| tree | 13598833410064b6972a8fcf019a0f9d76a4d46f /lldb/source/API/SBTarget.cpp | |
| parent | 1da39282ec9f2399a53e8092c7862e58699a39c9 (diff) | |
| download | bcm5719-llvm-0c74e78d633181698f22b95871e141af39111260.tar.gz bcm5719-llvm-0c74e78d633181698f22b95871e141af39111260.zip | |
Fixed SBTarget attach calls to properly deal with being connected to a remotely
connected process connection.
Also added support for more kinds of continue packet when multiple threads
need to continue where some want to continue with signals.
llvm-svn: 133785
Diffstat (limited to 'lldb/source/API/SBTarget.cpp')
| -rw-r--r-- | lldb/source/API/SBTarget.cpp | 78 |
1 files changed, 71 insertions, 7 deletions
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 8ed525e3d4d..c1278e023a5 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -282,11 +282,43 @@ SBTarget::AttachToProcessWithID if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - if (listener.IsValid()) - sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref())); + + StateType state = eStateInvalid; + sb_process.SetProcess (m_opaque_sp->GetProcessSP()); + if (sb_process.IsValid()) + { + state = sb_process->GetState(); + + if (sb_process->IsAlive() && state != eStateConnected) + { + if (state == eStateAttaching) + error.SetErrorString ("process attach is in progress"); + else + error.SetErrorString ("a process is already being debugged"); + sb_process.Clear(); + return sb_process; + } + } + + if (state == eStateConnected) + { + // If we are already connected, then we have already specified the + // listener, so if a valid listener is supplied, we need to error out + // to let the client know. + if (listener.IsValid()) + { + error.SetErrorString ("process is connected and already has a listener, pass empty listener"); + sb_process.Clear(); + return sb_process; + } + } else - sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); - + { + if (listener.IsValid()) + sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref())); + else + sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + } if (sb_process.IsValid()) { @@ -323,10 +355,42 @@ SBTarget::AttachToProcessWithName { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); - if (listener.IsValid()) - sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref())); + StateType state = eStateInvalid; + sb_process.SetProcess (m_opaque_sp->GetProcessSP()); + if (sb_process.IsValid()) + { + state = sb_process->GetState(); + + if (sb_process->IsAlive() && state != eStateConnected) + { + if (state == eStateAttaching) + error.SetErrorString ("process attach is in progress"); + else + error.SetErrorString ("a process is already being debugged"); + sb_process.Clear(); + return sb_process; + } + } + + if (state == eStateConnected) + { + // If we are already connected, then we have already specified the + // listener, so if a valid listener is supplied, we need to error out + // to let the client know. + if (listener.IsValid()) + { + error.SetErrorString ("process is connected and already has a listener, pass empty listener"); + sb_process.Clear(); + return sb_process; + } + } else - sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + { + if (listener.IsValid()) + sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref())); + else + sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + } if (sb_process.IsValid()) { |

