<div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:rgb(0,0,0)">It seems that the process plugin uses the Process::SetPrivateState at the right time. If you look at the log, you will see that the process is already in the '<b>private</b> <b>stopped'</b> state when the OS plugin is invoked.<br><br><div class="gmail_default">(lldb) c</div><div class="gmail_default">lldb Process::Resume -- locking run lock</div><div class="gmail_default">lldb Process::PrivateResume() m_stop_id = 1, public state: stopped private state: stopped</div><div class="gmail_default">lldb Process::SetPrivateState (running)</div><div class="gmail_default">intern-state Process::ShouldBroadcastEvent (0x1abea90) => new state: running, last broadcast state: running - YES</div><div class="gmail_default">intern-state Process::HandlePrivateEvent (pid = 1) broadcasting new state running (old state stopped) to public</div><div class="gmail_default">intern-state Process::PushProcessIOHandler pushing IO handler</div><div class="gmail_default">intern-state Process::HandlePrivateEvent updated m_iohandler_sync to 1</div><div class="gmail_default">lldb Process thinks the process has resumed.</div><div class="gmail_default">intern-state timeout = <infinite>, event_sp)...</div><div class="gmail_default">lldb waited from m_iohandler_sync to change from 0. New value is 1.</div><div class="gmail_default">dbg.evt-handler Process::SetPublicState (state = running, restarted = 0)</div><div class="gmail_default">Process 1 resuming</div><div class="gmail_default">lldb Process::SetPrivateState (stopped)</div><div class="gmail_default">lldb Process::SetPrivateState (stopped) stop_id = 2</div><div class="gmail_default">error: error: process must be stopped.</div><div class="gmail_default">intern-state Process::ShouldBroadcastEvent (0x7f3e9c007450) => new state: stopped, last broadcast state: stopped - YES</div><div class="gmail_default">intern-state Process::HandlePrivateEvent (pid = 1) broadcasting new state stopped (old state running) to public</div><div class="gmail_default">intern-state timeout = <infinite>, event_sp)...</div><div class="gmail_default">dbg.evt-handler Process::SetPublicState (state = stopped, restarted = 0)</div><div class="gmail_default">dbg.evt-handler Process::SetPublicState (stopped) -- unlocking run lock<br><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 15, 2019 at 1:38 AM Jim Ingham <<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Your plugin should have set the private state to stopped when it figures out however it does that the process has stopped. The API is Process::SetPrivateState. Is that happening at the right time?<div><br></div><div>Jim</div><div><br><div><br><blockquote type="cite"><div>On Feb 14, 2019, at 1:50 PM, Alexander Polyakov <<a href="mailto:polyakov.alx@gmail.com" target="_blank">polyakov.alx@gmail.com</a>> wrote:</div><br class="m_-1694066553590274530gmail-m_-7065674772318133911Apple-interchange-newline"><div><div dir="ltr"><div dir="ltr"><div style="font-family:arial,helvetica,sans-serif;font-size:small">I found out that the plugin works well with an x86 application, so I think that the problem is in my process plugin. Maybe you know a place where to start looking for an issue?</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 14, 2019 at 10:56 PM Jim Ingham <<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>The simplest thing possible to reproduce the failure. So some OS_Plugin implementation which tries to look up a global like this and fails, and some program source I can run it under that provides said global. That way I can easily watch it fails as you describe when the plugin gets activated, and see why it isn’t allowing this call on private stop.<div><br></div><div>Jim</div><div><br><div><br><blockquote type="cite"><div>On Feb 14, 2019, at 11:50 AM, Alexander Polyakov <<a href="mailto:polyakov.alx@gmail.com" target="_blank">polyakov.alx@gmail.com</a>> wrote:</div><br class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504Apple-interchange-newline"><div><div style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto">Sure, could you describe in more detail which example may help you?</div></div><div style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">чт, 14 февр. 2019 г. в 22:36, Jim Ingham <<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>That’s a little complicated… <div><br></div><div>lldb has two levels of stop state - private stops and public stops. When the process gets notification from the underlying process plugin that the process stopped, it raises a private stop event. That gets handled by the ShouldStop mechanism on the private state thread in lldb, and then if the stop is judged interesting to the user, it gets rebroadcast as a public stop.<div><br></div><div>For instance, when you issue a “step” command, lldb will stop and start the process multiple times as it walks through the source line. But only the last of those stops are relevant to the user of LLDB, so all the other ones exist only as private stops.</div><div><br></div><div>The SB API’s for the most part should only consider a “publicly stopped” process accessible. After all, you wouldn’t want some API to succeed sometimes if you happen to catch it in the middle of a private stop.</div><div><br></div><div>But the OperatingSystem plugin needs to get called right after a private stop, so it can provide threads for the ShouldStop mechanism. We should really have some formal mechanism whereby things like the OS plugin can request elevated rights in the SB API’s, so that they can run at private stop time. IIRC, we instead have a hack where SB API calls that run on the private state thread are blanket allowed to run at private stop. The xnu Operating System plugin successfully gets global values to look up its threads. So I’m not sure why that isn’t working for you.</div><div><br></div><div>Can you cook up a simple example showing the failure and I’ll have a look?</div></div></div><div><div><div><br></div><div>Jim</div><div><br><div><br><blockquote type="cite"><div>On Feb 14, 2019, at 11:10 AM, Alexander Polyakov <<a href="mailto:polyakov.alx@gmail.com" target="_blank">polyakov.alx@gmail.com</a>> wrote:</div><br class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504m_8996099617066268273Apple-interchange-newline"><div><div dir="ltr"><div dir="ltr"><div style="font-family:arial,helvetica,sans-serif;font-size:small">It is, the error is: <b>error: error: process must be stopped.</b><br><br>I thought that the plugin (get_thread_info in my case) is invoked when the process is already stopped, but it's not. Is it ok?</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 14, 2019 at 9:53 PM Jim Ingham <<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>All SBValues have an error in them (SBValue.GetError). Does that say anything interesting?<div><br></div><div>Jim</div><div> <div><br></div><div><br><div><br><blockquote type="cite"><div>On Feb 14, 2019, at 10:08 AM, Alexander Polyakov via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" target="_blank">lldb-dev@lists.llvm.org</a>> wrote:</div><br class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504m_8996099617066268273gmail-m_-306735485749780307gmail-m_-1096846428411375768Apple-interchange-newline"><div><div dir="ltr"><div style="font-family:arial,helvetica,sans-serif;font-size:small"><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">Hi lldb-dev,<br><br>I work on a custom implementation of OperatingSystem plugin using Python and SB API. I’m trying to fetch information about some variables from the target into the plugin, to do that I’m using the following Python code:</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">ready_tasks = self._target.FindGlobalVariables(‘pxReadyTasksLists’, 1).GetValueAtIndex(0)</div><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> </p><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">When I do `print(ready_tasks)` I get:</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">No value</div><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> </p><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">At the same time, doing the same actions inside lldb embedded interpreter follows to:</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">` print(lldb.target.FindGlobalVariables('pxReadyTasksLists',1).GetValueAtIndex(0))`</div><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> </p><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">(List_t [5]) pxReadyTasksLists = {</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> <span class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504Apple-converted-space"> </span>[0] = {</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> <span class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504Apple-converted-space"> </span>uxNumberOfItems = 0</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> <span class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504Apple-converted-space"> </span>pxIndex = 0x00000000</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> <span class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504Apple-converted-space"> </span>xListEnd = {</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> <span class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504Apple-converted-space"> </span>xItemValue = 0</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> <span class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504Apple-converted-space"> </span>pxNext = 0x00000000</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> <span class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504Apple-converted-space"> </span>pxPrevious = 0x00000000</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> <span class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504Apple-converted-space"> </span>}</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> <span class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504Apple-converted-space"> </span>}</div><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">…</div><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"> </p><div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">Does anybody know what may cause such a behavior?</div></div><div><br></div>--<span class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504Apple-converted-space"> </span><br><div dir="ltr" class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504m_8996099617066268273gmail-m_-306735485749780307gmail-m_-1096846428411375768gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="font-family:arial,helvetica,sans-serif;font-size:12.8px">Alexander</span><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></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="https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br></div></blockquote></div><br></div></div></div></blockquote></div><br clear="all"><div><br></div>--<span class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504Apple-converted-space"> </span><br><div dir="ltr" class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504m_8996099617066268273gmail-m_-306735485749780307gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="font-family:arial,helvetica,sans-serif;font-size:12.8px">Alexander</span><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></blockquote></div><br></div></div></div></blockquote></div></div><span style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">--<span class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504Apple-converted-space"> </span></span><br style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="ltr" class="m_-1694066553590274530gmail-m_-7065674772318133911gmail-m_-3246543174561134504gmail_signature" style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="font-family:arial,helvetica,sans-serif;font-size:12.8px">Alexander</span></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></blockquote></div><br></div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-1694066553590274530gmail-m_-7065674772318133911gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="font-family:arial,helvetica,sans-serif;font-size:12.8px">Alexander</span><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div></blockquote></div><br></div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-1694066553590274530gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;font-size:12.8px">Alexander</span><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>