diff options
| author | Greg Clayton <gclayton@apple.com> | 2015-10-05 22:58:37 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2015-10-05 22:58:37 +0000 |
| commit | b3788eaf9976ce0323f886fda0bd510cfe8a2dea (patch) | |
| tree | 9c1c1a9f01e19d5ad5786c348da62f2bd5058b67 /lldb/source | |
| parent | 41127ad7af1ff9b9573e402f599024bd24d18110 (diff) | |
| download | bcm5719-llvm-b3788eaf9976ce0323f886fda0bd510cfe8a2dea.tar.gz bcm5719-llvm-b3788eaf9976ce0323f886fda0bd510cfe8a2dea.zip | |
SBTarget::Attach(SBAttachInfo &) was changed to not be asynchronous back in February and this affected Xcode's abililty to cancel an attach to process by name.
Added the ability to specify if an attach by name should be synchronous or not in SBAttachInfo and ProcessAttachInfo.
<rdar://problem/22821480>
llvm-svn: 249361
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/API/SBAttachInfo.cpp | 16 | ||||
| -rw-r--r-- | lldb/source/Target/Target.cpp | 19 |
2 files changed, 28 insertions, 7 deletions
diff --git a/lldb/source/API/SBAttachInfo.cpp b/lldb/source/API/SBAttachInfo.cpp index 07446df27df..0f2ab7afc9c 100644 --- a/lldb/source/API/SBAttachInfo.cpp +++ b/lldb/source/API/SBAttachInfo.cpp @@ -36,6 +36,15 @@ SBAttachInfo::SBAttachInfo (const char *path, bool wait_for) : m_opaque_sp->SetWaitForLaunch (wait_for); } +SBAttachInfo::SBAttachInfo (const char *path, bool wait_for, bool async) : + m_opaque_sp (new ProcessAttachInfo()) +{ + if (path && path[0]) + m_opaque_sp->GetExecutableFile().SetFile(path, false); + m_opaque_sp->SetWaitForLaunch (wait_for); + m_opaque_sp->SetAsync(async); +} + SBAttachInfo::SBAttachInfo (const SBAttachInfo &rhs) : m_opaque_sp (new ProcessAttachInfo()) { @@ -127,6 +136,13 @@ SBAttachInfo::SetWaitForLaunch (bool b) m_opaque_sp->SetWaitForLaunch (b); } +void +SBAttachInfo::SetWaitForLaunch (bool b, bool async) +{ + m_opaque_sp->SetWaitForLaunch (b); + m_opaque_sp->SetAsync(async); +} + bool SBAttachInfo::GetIgnoreExisting () { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 5ab219a1b78..b02f2f5cd6f 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -3124,9 +3124,6 @@ Target::Attach (ProcessAttachInfo &attach_info, Stream *stream) } } - ListenerSP hijack_listener_sp (new Listener ("lldb.Target.Attach.attach.hijack")); - attach_info.SetHijackListener (hijack_listener_sp); - const ModuleSP old_exec_module_sp = GetExecutableModule (); // If no process info was specified, then use the target executable @@ -3143,6 +3140,13 @@ Target::Attach (ProcessAttachInfo &attach_info, Stream *stream) } const auto platform_sp = GetDebugger ().GetPlatformList ().GetSelectedPlatform (); + ListenerSP hijack_listener_sp; + const bool async = attach_info.GetAsync(); + if (async == false) + { + hijack_listener_sp.reset (new Listener ("lldb.Target.Attach.attach.hijack")); + attach_info.SetHijackListener (hijack_listener_sp); + } Error error; if (state != eStateConnected && platform_sp != nullptr && platform_sp->CanDebugProcess ()) @@ -3162,11 +3166,12 @@ Target::Attach (ProcessAttachInfo &attach_info, Stream *stream) return error; } } - process_sp->HijackProcessEvents (hijack_listener_sp.get ()); + if (hijack_listener_sp) + process_sp->HijackProcessEvents (hijack_listener_sp.get ()); error = process_sp->Attach (attach_info); } - if (error.Success () && process_sp) + if (error.Success () && process_sp && async == false) { state = process_sp->WaitForProcessToStop (nullptr, nullptr, false, attach_info.GetHijackListener ().get (), stream); process_sp->RestoreProcessEvents (); @@ -3175,9 +3180,9 @@ Target::Attach (ProcessAttachInfo &attach_info, Stream *stream) { const char *exit_desc = process_sp->GetExitDescription (); if (exit_desc) - error.SetErrorStringWithFormat ("attach failed: %s", exit_desc); + error.SetErrorStringWithFormat ("%s", exit_desc); else - error.SetErrorString ("attach failed: process did not stop (no such process or permission problem?)"); + error.SetErrorString ("process did not stop (no such process or permission problem?)"); process_sp->Destroy (false); } } |

