<div dir="ltr">Thanks for the info. I understand the multiple threads stopping at the same time issue. But I would think we should at least pick one stopped thread and set it as selected thread instead of some random thread with stop reason None. Also, in my repro case, there is only one thread that has stop reason, so the heuristics should be pretty trivial to set selected thread to that one.<div>I have workaround this issue with the suggestion but I think there is a bug(on Linux) here.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 18, 2016 at 4:40 PM, Jim Ingham <span dir="ltr"><<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">On many platforms (OS X for sure) there’s no guarantee that when you stop you will only have hit one breakpoint on one thread.  On OS X in multithreaded programs, it is not at all uncommon to have many threads hit breakpoint(s) by the the time the stop gets reported.  So you just have to iterate over all the threads and see what their stop reasons are.  Note that it isn’t just breakpoints, you might have been stepping on thread A, and when you stop, thread A will have stopped with “plan complete” for the step operation, and thread B for some other breakpoint.<div><br></div><div>So when you get a stop event you have to iterate over the threads and see why they have stopped.</div><div><br></div><div>LLDB will set one of the threads as the selected thread, using some heuristics (if you were stepping on thread A & threads A & B stopped with breakpoints, thread A will be the selected thread, etc…)  So you could just show the selected thread, but really you want to figure out what all the threads are doing.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Jim</div></font></span><div><div class="h5"><div><br><div><blockquote type="cite"><div>On Mar 18, 2016, at 4:25 PM, Jeffrey Tan <<a href="mailto:jeffrey.fudan@gmail.com" target="_blank">jeffrey.fudan@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div><br></div>Hmm, interesting, I got the stop reason from the lldb.SBProcess.GetProcessFromEvent(event).GetSelectedThread().GetStopReason(). Is that thread not the one that stopped? But you are right, the breakpoint hits in another thread:<div><div><br></div><div>thread #87: tid = 1006769, 0x000000000042eacd biggrep_master_server_async`facebook::biggrep::BigGrepMasterAsync::future_find(this=0x00007f3ea2d74fd0, corpus=error: summary string parsing error, needle=error: summary string parsing error, options=0x00007f3e899fc7e0) + 51 at <b>BigGrepMasterAsync.cpp:171</b>, name = 'BigGrep-pri3-32', <b>stop reason = breakpoint</b> 1.1<br></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">How do I know which thread hits the breakpoint?</div><div class="gmail_extra"><br></div><div class="gmail_extra">Jeffrey</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 18, 2016 at 4:12 PM, Jim Ingham <span dir="ltr"><<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">You only show one thread in your example.  Did another thread have a valid stop reason?  lldb shouldn’t be stopping for no reason anywhere…<div><br></div><div>Jim</div><div><br><div><blockquote type="cite"><div><div><div>On Mar 18, 2016, at 4:08 PM, Jeffrey Tan via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" target="_blank">lldb-dev@lists.llvm.org</a>> wrote:</div><br></div></div><div><div><div><div dir="ltr">Btw: the breakpoint I set is:<div>"b BigGrepMasterAsync.cpp:171" which is not in any of the stopped stack frames.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 18, 2016 at 3:47 PM, Jeffrey Tan <span dir="ltr"><<a href="mailto:jeffrey.fudan@gmail.com" target="_blank">jeffrey.fudan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>Our IDE(wrapping lldb using python) works fine on Linux for simple hello world cases. While trying a real world case, I found whenever we set a source line breakpoint, then trigger the code path, lldb will send a stopped state process event, with thread.GetStopReason() being None and with weird callstack. Any ideas why do I get this stop stack(code is listed at the end)? I have verified that if I do not set breakpoint and trigger the same code path does not cause this stop event to generate.</div><div><br></div><div><div>bt</div><div>* thread #1: tid = 952490, 0x00007fd7cb2daa83 libc.so.6`__GI_epoll_wait + 51, name = 'biggrep_master_'</div><div>  * frame #0: 0x00007fd7cb2daa83 libc.so.6`__GI_epoll_wait + 51</div><div>    frame #1: 0x000000000271189f biggrep_master_server_async`epoll_dispatch(base=0x00007fd7ca970800, arg=0x00007fd7ca62c1e0, tv=<unavailable>) + 127 at epoll.c:315</div><div>    frame #2: 0x000000000270f6d1 biggrep_master_server_async`event_base_loop(base=0x00007fd7ca970800, flags=<unavailable>) + 225 at event.c:524</div><div>    frame #3: 0x00000000025f9378 biggrep_master_server_async`folly::EventBase::loopBody(this=0x00007fd7ca945180, flags=0) + 834 at EventBase.cpp:335</div><div>    frame #4: 0x00000000025f900b biggrep_master_server_async`folly::EventBase::loop(this=0x00007fd7ca945180) + 29 at EventBase.cpp:287</div><div>    frame #5: 0x00000000025fa053 biggrep_master_server_async`folly::EventBase::loopForever(this=0x00007fd7ca945180) + 109 at EventBase.cpp:435</div><div>    frame #6: 0x0000000001e24b72 biggrep_master_server_async`apache::thrift::ThriftServer::serve(this=0x00007fd7ca96d710) + 110 at ThriftServer.cpp:365</div><div>    frame #7: 0x00000000004906bc biggrep_master_server_async`facebook::services::ServiceFramework::startFramework(this=0x00007ffc06776140, waitUntilStop=true) + 1942 at ServiceFramework.cpp:885</div><div>    frame #8: 0x000000000048fe6d biggrep_master_server_async`facebook::services::ServiceFramework::go(this=0x00007ffc06776140, waitUntilStop=true) + 35 at ServiceFramework.cpp:775</div><div>    frame #9: 0x00000000004219a7 biggrep_master_server_async`main(argc=1, argv=0x00007ffc067769d8) + 2306 at BigGrepMasterServerAsync.cpp:134</div><div>    frame #10: 0x00007fd7cb1ed0f6 libc.so.6`__libc_start_main + 246</div><div>    frame #11: 0x0000000000420bfc biggrep_master_server_async`_start + 41 at start.S:122</div></div><div><br></div><div>Here is the code snippet of handling code:</div><div><div>def _handle_process_event(self, event):</div><div>        # Ignore non-stopping events.</div><div>        if lldb.SBProcess.GetRestartedFromEvent(event):</div><div>            log_debug('Non stopping event: %s' % str(event))</div><div>            return</div><div><br></div><div>        process = lldb.SBProcess.GetProcessFromEvent(event)<br></div><div>        if process.state == lldb.eStateStopped:</div><div>            self._send_paused_notification(process)</div><div>        elif process.state == lldb.eStateExited:</div><div>            exit_message = 'Process(%d) exited with: %u' % (</div><div>                    process.GetProcessID(),</div><div>                    process.GetExitStatus())</div><div>            if process.GetExitDescription():</div><div>                exit_message += (', ' + process.GetExitDescription())</div><div>            self._send_user_output('log', exit_message)</div><div>            self.should_quit = True</div><div>        else:</div><div>            self._send_notification('Debugger.resumed', None)</div><div><br></div><div>        event_type = event.GetType()</div><div>        if event_type == lldb.SBProcess.eBroadcastBitSTDOUT:</div><div>            # Read stdout from inferior.</div><div>            process_output = ''</div><div>            while True:</div><div>                output_part = process.GetSTDOUT(1024)</div><div>                if not output_part or len(output_part) == 0:</div><div>                    break</div><div>                process_output += output_part</div><div>            self._send_user_output('log', process_output)</div></div></div>
</blockquote></div><br></div></div></div>
_______________________________________________<br>lldb-dev mailing list<br><a href="mailto:lldb-dev@lists.llvm.org" target="_blank">lldb-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br></div></blockquote></div><br></div></div></blockquote></div><br></div></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>