<div dir="ltr">I am not sure. From the output, it seems lldb does stop at the entry point(because you can issue "bt" command to dump the stack) in both platforms; the problem seems to be that it did not emit the stopped event for its stop on linux.  </div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 23, 2016 at 2:03 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">If the linux side is not obeying "stop_at_entry" then that is a bug.<br>
<br>
Jim<br>
<div><div class="h5"><br>
<br>
> On Feb 23, 2016, at 1:49 PM, Jeffrey Tan via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org">lldb-dev@lists.llvm.org</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I have got lldb launch working fine on my macbook for sometime. But when I try the same code on Linux, it failed to emit any stopping events during initial launch.<br>
><br>
> When I run the reproduce code(listed at the end), I got the following different results:<br>
><br>
> The key difference is that Macbook will emit a stopped event which caused our IDE UI to enter break mode, while Linux violates this assumption. Is this a bug?<br>
><br>
> ======================Mac======================<br>
> lldb_pythonpath: /Applications/Xcode.app/Contents/Developer/../SharedFrameworks/LLDB.framework/Resources/Python<br>
> Launch result: success<br>
> <Listener> Listening Thread ID: 4610625536<br>
> dbg> Target event: ModulesLoaded<br>
> Process event: StateChanged, Stopped<br>
> Stop reason: 5<br>
> dbg> bt<br>
> * thread #1: tid = 0x101f01d, 0x00007fff6401a000 dyld`_dyld_start, stop reason = signal SIGSTOP<br>
>   * frame #0: 0x00007fff6401a000 dyld`_dyld_start<br>
> ======================Mac======================<br>
><br>
> ======================Linux======================<br>
> python linux_launch.py<br>
> find_lldb: <module 'lldb' from '/home/jeffreytan/project/llvm-bin/Debug+Asserts/lib/python2.7/site-packages/lldb/__init__.pyc'><br>
> Launch result: success<br>
> <Listener> Listening Thread ID: 140316621375232<br>
> dbg> bt<br>
> * thread #1: tid = 2794520, 0x00007f6165b7bb00, name = 'foo', stop reason = signal SIGSTOP<br>
>   * frame #0: 0x00007f6165b7bb00<br>
> ======================Linux======================<br>
><br>
> ============================Repro main.py============================<br>
> # Should be first for LLDB package to be added to search path.<br>
> from find_lldb import lldb<br>
> import sys<br>
> import os<br>
> import time<br>
> from sys import stdin, stdout<br>
> from event_thread import LLDBListenerThread<br>
> import threading<br>
><br>
><br>
> def interctive_loop(debugger):<br>
>     while (True):<br>
>         stdout.write('dbg> ')<br>
>         command = stdin.readline().rstrip()<br>
>         if len(command) == 0:<br>
>             continue<br>
>         if command == 'q':<br>
>             return<br>
>         debugger.HandleCommand(command)<br>
><br>
> def do_test():<br>
>     debugger = lldb.SBDebugger.Create()<br>
>     debugger.SetAsync(True)<br>
>     executable_path = '~/Personal/compiler/CompilerConstruction/code/compiler'<br>
>     target = debugger.CreateTargetWithFileAndArch(executable_path, lldb.LLDB_ARCH_DEFAULT)<br>
><br>
>     listener = lldb.SBListener('Event Listener')<br>
>     error = lldb.SBError()<br>
>     process = target.Launch (listener,<br>
>                              None,      # argv<br>
>                              None,      # envp<br>
>                              None,      # stdin_path<br>
>                              None,      # stdout_path<br>
>                              None,      # stderr_path<br>
>                              None,      # working directory<br>
>                              0,         # launch flags<br>
>                              True,     # Stop at entry<br>
>                              error)     # error<br>
>     print 'Launch result: %s' % str(error)<br>
><br>
>     running_signal = threading.Event()<br>
>     stopped_signal = threading.Event()<br>
>     event_thread = LLDBListenerThread(debugger, running_signal, stopped_signal)<br>
>     event_thread.start()<br>
><br>
>     interctive_loop(debugger)<br>
><br>
>     event_thread.should_quit = True<br>
>     event_thread.join()<br>
><br>
>     lldb.SBDebugger.Destroy(debugger)<br>
>     return debugger<br>
><br>
> def main():<br>
>     debugger = do_test()<br>
><br>
> if __name__ == '__main__':<br>
>     main()<br>
><br>
> ============================Event_thread============================<br>
> class LLDBListenerThread(Thread):<br>
>     should_quit = False<br>
><br>
>     def __init__(self, debugger, running_signal=None, stopped_sigal=None):<br>
>       Thread.__init__(self)<br>
>       self._running_signal = running_signal<br>
>       self._stopped_sigal = stopped_sigal<br>
>       process = debugger.GetSelectedTarget().process<br>
>       self.listener = debugger.GetListener()<br>
>       self._add_listener_to_process(process)<br>
>       self._add_listener_to_target(process.target)<br>
><br>
><br>
>     def _add_listener_to_target(self, target):<br>
>         # Listen for breakpoint/watchpoint events (Added/Removed/Disabled/etc).<br>
>         broadcaster = target.GetBroadcaster()<br>
>         mask = lldb.SBTarget.eBroadcastBitBreakpointChanged | lldb.SBTarget.eBroadcastBitWatchpointChanged | lldb.SBTarget.eBroadcastBitModulesLoaded<br>
>         broadcaster.AddListener(self.listener, mask)<br>
><br>
>     def _add_listener_to_process(self, process):<br>
>         # Listen for process events (Start/Stop/Interrupt/etc).<br>
>         broadcaster = process.GetBroadcaster()<br>
>         mask = lldb.SBProcess.eBroadcastBitStateChanged | lldb.SBProcess.eBroadcastBitSTDOUT | lldb.SBProcess.eBroadcastBitSTDERR | lldb.SBProcess.eBroadcastBitInterrupt<br>
>         broadcaster.AddListener(self.listener, mask)<br>
><br>
>     def run(self):<br>
>         print '<Listener> Listening Thread ID: %d' % thread.get_ident()<br>
>         while not self.should_quit:<br>
>             event = lldb.SBEvent()<br>
>             if self.listener.WaitForEvent(1, event):<br>
>                 if lldb.SBTarget.EventIsTargetEvent(event):<br>
>                     self._handle_target_event(event)<br>
>                 elif lldb.SBProcess.EventIsProcessEvent(event):<br>
>                     self._handle_process_event(event)<br>
>                 elif lldb.SBBreakpoint.EventIsBreakpointEvent(event):<br>
>                     self._handle_breakpoint_event(event)<br>
>                 elif lldb.SBThread.EventIsThreadEvent(event):<br>
>                     self._handle_thread_event(event)<br>
>                 else:<br>
>                     self._handle_unknown_event(event)<br>
>         print '<Listener> Exiting listener thread'<br>
><br>
>     def _handle_target_event(self, event):<br>
>         event_type = event.GetType()<br>
>         print 'Target event: %s' % target_event_type_to_name_map[event_type]<br>
><br>
>     def _handle_process_event(self, event):<br>
>         if lldb.SBProcess.GetRestartedFromEvent(event):<br>
>             print 'Non stopping event: %s' % str(event)<br>
>             return<br>
>         process = lldb.SBProcess.GetProcessFromEvent(event)<br>
>         event_type = event.GetType()<br>
>         print 'Process event: %s, %s' % (process_event_type_to_name_map[event_type], process_state_name_map[process.state])<br>
>         if process.state == lldb.eStateExited:<br>
>             self.should_quit = True<br>
>         elif process.state == lldb.eStateStopped:<br>
>             if self._stopped_sigal:<br>
>                 self._stopped_sigal.set()<br>
>         else:<br>
>             if self._running_signal:<br>
>                 self._running_signal.set()<br>
><br>
>         thread = process.selected_thread<br>
>         print 'Stop reason: %d' % thread.GetStopReason()<br>
>         if event_type == lldb.SBProcess.eBroadcastBitSTDOUT:<br>
>             print 'Stdout:'<br>
>             while True:<br>
>                 output = process.GetSTDOUT(1024)<br>
>                 if len(output) == 0:<br>
>                     break<br>
>                 stdout.write(output)<br>
><br>
>     def _handle_breakpoint_event(self, event):<br>
>         breakpoint = lldb.SBBreakpoint.GetBreakpointFromEvent(event)<br>
>         event_type = lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent(event)<br>
>         print 'Breakpoint event: [%s] %s' % (breakpoint_event_type_to_name_map[event_type], str(breakpoint))<br>
><br>
>     def _handle_unknown_event(self, event):<br>
>         print 'Unknown event'<br>
><br>
</div></div>> _______________________________________________<br>
> lldb-dev mailing list<br>
> <a href="mailto:lldb-dev@lists.llvm.org">lldb-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br>
<br>
</blockquote></div><br></div>