<div dir="ltr">I've overridden DebugProcess but for some reason LLDB thinks my process has exited even when it hasn't. Can you tell from looking at this log what might be going wrong?<div><br></div><div><div>1431622791.100000000 Processing command: process attach -p 9664</div><div>1431622791.100000000 HandleCommand, cmd_obj : 'process attach'</div><div>1431622791.100000000 HandleCommand, (revised) command_string: 'process attach -p 9664'</div><div>1431622791.100000000 HandleCommand, wants_raw_input:'False'</div><div>1431622791.101000000 HandleCommand, command line after removing command name(s): '-p 9664'</div><div>1431622791.101000000 039FD150 Listener::Listener('lldb.Target.Attach.attach.hijack')</div><div>1431622791.102000000 039FD5D8 Broadcaster::Broadcaster("lldb.process")</div><div>1431622791.102000000 039FD654 Broadcaster::Broadcaster("lldb.process.internal_state_broadcaster")</div><div>1431622791.102000000 039FD6A0 Broadcaster::Broadcaster("lldb.process.internal_state_control_broadcaster")</div><div>1431622791.103000000 039FD6EC Listener::Listener('lldb.process.internal_state_listener')</div><div>1431622791.103000000 039FD8AC Broadcaster::Broadcaster("process.stdio")</div><div>1431622791.103000000 039FD8AC Communication::Communication (name = process.stdio)</div><div>1431622791.103000000 032B82C0 Listener::StartListeningForEvents (broadcaster = 039FD5D8, mask = 0x0000000d) acquired_mask = 0x0000000d for lldb.Debugger</div><div>1431622791.103000000 039FD5C8 Process::Process()</div><div>1431622791.103000000 032B82C0 Listener::StartListeningForEvents (broadcaster = 039FD5D8, mask = 0x0000001f) acquired_mask = 0x0000001f for lldb.Debugger</div><div>1431622791.103000000 039FD6EC Listener::StartListeningForEvents (broadcaster = 039FD654, mask = 0x00000003) acquired_mask = 0x00000003 for lldb.process.internal_state_listener</div><div>1431622791.103000000 039FD6EC Listener::StartListeningForEvents (broadcaster = 039FD6A0, mask = 0x00000007) acquired_mask = 0x00000007 for lldb.process.internal_state_listener</div><div>1431622791.104000000 Process::SetPublicState (state = attaching, restarted = 0)</div><div>1431622791.104000000 Process::SetPrivateState (attaching)</div><div>1431622791.104000000 039FD654 Broadcaster("lldb.process.internal_state_broadcaster")::BroadcastEvent (event_sp = {03A03220 Event: broadcaster = 039FD654 (lldb.process.internal_state_broadcaster), type = 0x00000001, data = { process = 039FD5C8 (pid = 0), state = attaching}}, unique =0) hijack = 00000000</div><div>1431622791.104000000 039FD6EC Listener('lldb.process.internal_state_listener')::AddEvent (event_sp = {03A03220})</div><div>1431622791.104000000 DebuggerThread::DebugAttach attaching to '9664'</div><div>1431622791.104000000 WaitForDebuggerConnection Waiting for initial stop.</div><div>1431622791.105000000 thread created</div><div>1431622791.105000000 DebuggerThread preparing to attach to process '9664' on background thread.</div><div>1431622791.105000000 Entering WaitForDebugEvent loop</div><div>1431622791.105000000 HandleCreateProcessEvent process 9664 spawned</div><div>1431622791.106000000 Debugger established connected to process 9664. Image base = 0x1240000</div><div>1431622791.153000000 035EA020 Broadcaster("lldb.target")::BroadcastEvent (event_sp = {035E1AC8 Event: broadcaster = 035EA020 (lldb.target), type = 0x00000002 (modules-loaded), data = {}}, unique =0) hijack = 00000000</div><div>1431622791.168000000 035EA020 Broadcaster("lldb.target")::BroadcastEvent (event_sp = {04453CF8 Event: broadcaster = 035EA020 (lldb.target), type = 0x00000002 (modules-loaded), data = {}}, unique =0) hijack = 00000000</div><div>1431622791.169000000 035EA020 Broadcaster("lldb.target")::BroadcastEvent (event_sp = {04305458 Event: broadcaster = 035EA020 (lldb.target), type = 0x00000002 (modules-loaded), data = {}}, unique =0) hijack = 00000000</div><div>1431622791.180000000 035EA020 Broadcaster("lldb.target")::BroadcastEvent (event_sp = {035FE9E0 Event: broadcaster = 035EA020 (lldb.target), type = 0x00000002 (modules-loaded), data = {}}, unique =0) hijack = 00000000</div><div>1431622791.181000000 035EA020 Broadcaster("lldb.target")::BroadcastEvent (event_sp = {04308570 Event: broadcaster = 035EA020 (lldb.target), type = 0x00000002 (modules-loaded), data = {}}, unique =0) hijack = 00000000</div><div>1431622791.193000000 035EA020 Broadcaster("lldb.target")::BroadcastEvent (event_sp = {03605E60 Event: broadcaster = 035EA020 (lldb.target), type = 0x00000002 (modules-loaded), data = {}}, unique =0) hijack = 00000000</div><div>1431622791.194000000 035EA020 Broadcaster("lldb.target")::BroadcastEvent (event_sp = {044D69E8 Event: broadcaster = 035EA020 (lldb.target), type = 0x00000002 (modules-loaded), data = {}}, unique =0) hijack = 00000000</div><div>1431622791.194000000 HandleCreateThreadEvent Thread 9664 spawned in process 20100446945280</div><div>1431622791.194000000 HandleExceptionEvent encountered first chance exception 0x80000003 (breakpoint) on thread 4680</div><div>1431622791.194000000 Process::SetPrivateState (stopped)</div><div>1431622791.194000000 Process::SetPrivateState (stopped) stop_id = 1</div><div>1431622791.194000000 DoAttachToProcessWithID successfully attached to process with pid=9664</div><div>1431622791.194000000 039FD654 Broadcaster("lldb.process.internal_state_broadcaster")::BroadcastEvent (event_sp = {032C56C8 Event: broadcaster = 039FD654 (lldb.process.internal_state_broadcaster), type = 0x00000001, data = { process = 039FD5C8 (pid = 0), state = stopped}}, unique =0) hijack = 00000000</div><div>1431622791.194000000 Process::AttachCompletionHandler::lldb_private::Process::AttachCompletionHandler::AttachCompletionHandler process=039FD5C8, exec_count=0</div><div>1431622791.194000000 039FD6EC Listener('lldb.process.internal_state_listener')::AddEvent (event_sp = {032C56C8})</div><div>1431622791.194000000 Process::lldb_private::Process::StartPrivateStateThread() starting private state thread </div><div>1431622791.194000000 DebuggerThread::HandleExceptionEvent waiting for ExceptionPred != BreakInDebugger</div><div>1431622791.194000000 Process::lldb_private::Process::ControlPrivateStateThread (signal = 4)</div><div>1431622791.195000000 039FD6A0 Broadcaster("lldb.process.internal_state_control_broadcaster")::BroadcastEvent (event_sp = {032C1A58 Event: broadcaster = 039FD6A0 (lldb.process.internal_state_control_broadcaster), type = 0x00000004 (control-resume), data = <NULL>}, unique =0) hijack = 00000000</div><div>1431622791.195000000 039FD6EC Listener('lldb.process.internal_state_listener')::AddEvent (event_sp = {032C1A58})</div><div>1431622791.195000000 thread created</div><div>1431622791.195000000 Process::lldb_private::Process::RunPrivateStateThread (arg = 039FD5C8, pid = 9664) thread starting...</div><div>1431622791.195000000 Sending control event of type: 4.</div><div>1431622791.195000000 Process::lldb_private::Process::WaitForEventsPrivate (timeout = 00000000, event_sp)...</div><div>1431622791.195000000 039FD6EC Listener::WaitForEventsInternal (timeout = { 00000000 }) for lldb.process.internal_state_listener</div><div>1431622791.195000000 039FD6EC 'lldb.process.internal_state_listener' Listener::FindNextEventInternal(broadcaster=039FD6A0, broadcaster_names=00000000[0], event_type_mask=0x00000000, remove=1) event 032C1A58</div><div>1431622791.195000000 Process::lldb_private::Process::RunPrivateStateThread (arg = 039FD5C8, pid = 9664) got a control event: 4</div><div>1431622791.195000000 Process::lldb_private::Process::WaitForEventsPrivate (timeout = 00000000, event_sp)...</div><div>1431622791.195000000 039FD6EC Listener::WaitForEventsInternal (timeout = { 00000000 }) for lldb.process.internal_state_listener</div><div>1431622791.195000000 Process::lldb_private::Process::WaitForProcessToStop (timeout = 00000000)</div><div>1431622791.195000000 039FD6EC 'lldb.process.internal_state_listener' Listener::FindNextEventInternal(broadcaster=00000000, broadcaster_names=00000000[0], event_type_mask=0x00000000, remove=1) event 03A03220</div><div>1431622791.195000000 Process::lldb_private::Process::WaitForStateChangedEvents (timeout = 00000000, event_sp)...</div><div>1431622791.195000000 039FD150 Listener::WaitForEventsInternal (timeout = { 00000000 }) for lldb.Target.Attach.attach.hijack</div><div>1431622791.195000000 Process::AttachCompletionHandler::lldb_private::Process::AttachCompletionHandler::PerformAction called with state attaching (3)</div><div>1431622791.195000000 Ran next event action, result was 2.</div><div>1431622791.195000000 Process::SetExitStatus (status=0 (0x00000000), description="No valid Process")</div><div>1431622791.195000000 Process::SetPrivateState (exited)</div><div>1431622791.195000000 Process::SetPrivateState (exited) stop_id = 2</div><div><br></div><div>The key seems to be this AttachCompletionHandler::PerformHandler being called with state attaching. For some reason LLDB is turning that into "the process is exiting". </div><div><br></div><div>It's possible I'm misunderstanding the purpose of this AttachCompletionHandler, but on the surface it seems like "Attaching" is the expected state for the program to be in when this happens.</div><div><br></div><div>With Launch, the way it works is that I return from DoLaunch() with my private state set to eStateStopped (because the program is stopped at the initial breakpoint) and LLDB calls DoResume() on me eventually. With attach, I'm doing the same thing -- returning from DoAttachToProcessWithID when my private state is set to eStateStopped and public state set to eStateAttaching (m_continue_once_attached = false, so it actually is stopped when I return from DoAttach).</div><div><br></div><div>Do I have the states mixed up with regards to what LLDB is expecting?</div><div><br></div><div><br><br><div class="gmail_quote">On Wed, May 13, 2015 at 3:25 PM Greg Clayton <<a href="mailto:gclayton@apple.com">gclayton@apple.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The theory is to require platforms to implement the minimum number of functions.<br>
<br>
If you implement launch and attach, then you shouldn't need a third function to debug your process.<br>
<br>
This all hinges on your ability to stop your program at the entry point when the eLaunchFlagDebug launch flag is set. If you can do this, then you should be able to use launch followed by attach. If you can't do this, you will need to override the PlatformWindows::DebugProcess(...).<br>
<br>
Greg<br>
<br>
> On May 13, 2015, at 2:59 PM, Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br>
><br>
> In particular this code:<br>
><br>
> error = LaunchProcess (launch_info);<br>
> if (error.Success())<br>
> {<br>
> if (log)<br>
> log->Printf ("Platform::%s LaunchProcess() call succeeded (pid=%" PRIu64 ")", __FUNCTION__, launch_info.GetProcessID ());<br>
> if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID)<br>
> {<br>
> ProcessAttachInfo attach_info (launch_info);<br>
> process_sp = Attach (attach_info, debugger, target, error);<br>
><br>
> For Windows if you want to launch a program under the debugger the method you use launch to launch the process also does the attach at the same time. Until recently, PlatformWindows::CanDebugProcess() had been returning false, so it was falling back to calling Process::DoLaunch(), which has been working fine.<br>
><br>
> I'm adding support for attaching to processes though, and this requires changing that function to return true. So now both launches and attaches go through this path of launching first, and then attaching, which causes the launch codepath to break.<br>
><br>
> What is the correct way to handle this? Could I add a method to Platform called SupportsAtomicLaunchAndAttach() that if true will just call Process::DoLaunch() directly, and if false will continue down the existing codepath?<br>
> _______________________________________________<br>
> lldb-dev mailing list<br>
> <a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
<br>
</blockquote></div></div></div></div>