<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Greg,<BR> <BR>Thanks a lot!<BR>This seems helped.<BR> <BR>Eugene<br> <BR><div>> Subject: Re: [lldb-dev] C++ API get stray process stopped event<br>> From: gclayton@apple.com<br>> Date: Thu, 25 Jun 2015 16:14:17 -0700<br>> CC: lldb-dev@cs.uiuc.edu<br>> To: eugenebi@hotmail.com<br>> <br>> <br>> > On Jun 25, 2015, at 10:36 AM, Eugene Birukov <eugenebi@hotmail.com> wrote:<br>> > <br>> > Hi,<br>> >  <br>> > I am running on Linux Ubuntu 14.04 with lldb-4.7 I built from sources about a month ago.<br>> >  <br>> > My C++ debugger does pretty much the following:<br>> >  • Initializes LLDB, sets it to async mode<br>> >    • Gets listener from debugger, subscribes for process and target events <br>> >     • Sets a few breakpoints<br>> >     • Waits for event on the listener<br>> >    • If event is a process event <br>> >               • If event type is eBroadcastBitSTDOUT or eBroadcastBitSTERR<br>> >                         • call SBDebugger::HandleProcessEvent() to get it printed<br>> >            • else if process state is eStateStopped<br>> >                     • scan all the target threads and checks their stop reason, registers, etc.<br>> >                  • call SBProcess::Continue()<br>> >         • Loop to 4<br>> >  <br>> > Now, the program behavior varies - so it might be I am doing something wrong...<br>> >  <br>> > One version of the program always gets stray stopped event in the very beginning after reporting several module loads. In this case it has only one thread yet and the thread stop reason is eStopReasonNone. when it happens, I have to skip calling SBProcess::Continue() - i.e. just ignore this event as if the target state was eStateRunning and reissue wait for event. This is a bit annoying but detection and workaround are simple.<br>> <br>> You must check to see if a eStateStopped event was restarted:<br>> <br>> lldb::SBEvent event = ...; // Get event somehow<br>> <br>> <br>> lldb::StateType state = SBProcess::GetStateFromEvent(event);<br>> if (state == eStateStopped)<br>> {<br>>   if (SBProcess::GetRestartedFromEvent (event))<br>>   {<br>>     // Ignore this eStateStopped event, as the process already continued<br>>   }<br>>   else<br>>   {<br>>     // Process the stop event.   <br>>   }<br>> }<br>> <br>> >  <br>> > Another version of the program does not subscribe for target events. It often works smooth, but once in a while gets stray stopped event and the thread state is eStopReasonTrace. I should not call SBProcess::Continue() in this case too. Now the problem is that I do turn on tracing sometimes, and if it is genuine trace event I have to call continue.<br>> >  <br>> > Any advice - how to investigate this problem - if it is my bug or something in LLDB?<br>> <br>> Check for restarted events and let me know if you still see problems after you ignore restarts...<br>> <br>> Greg Clayton<br></div>                                         </div></body>
</html>