<div dir="ltr">I should rephrase since we need context here:<div><br></div><div>1. TOT lldb <=> current debugserver/llgs</div><div><br></div><div>Will use qProcessInfo and get the process id.</div><div><br></div><div>
2. TOT lldb <=> older debugserver</div><div><br></div><div>Will use qProcessINfo and get the process id.</div><div><br></div><div>3. TOT lldb <=> gdbserver</div><div><br></div><div>Will fail to get the process id from qProcessInfo, will not ask for qC because it's not Apple/iOS. That will trigger lldb to think its not attached properly.</div>
<div><br></div><div>-- two fixes here: </div><div>3.1 - fall back to qC as we would in the Apple/iOS case, and realize we wont' really have the real PID, which we don't really care about for the remote setup case,</div>
<div>3.2 - rework and add a "do I have a process on the remote end" predicate, and rework attach logic to just ask this new question which doesn't promise a process id.</div><div><br></div><div>4. old lldb <=> TOT debugserver</div>
<div><br></div><div>Asks for qC, gets same behavior as it did before - gets a thread id, treats it as a process id, connection works.</div><div><br></div><div><br></div><div>So we really only have case 3 that is an issue, which is what Matthew hit since he has a different gdbremote.</div>
<div><br></div><div>Since I believe that is the only case we're trying to fix here, I'd be in favor of doing the simple fix of allowing $qC for a fake process id not limited to Apple/iOS.</div><div><br></div><div>
That's my take. I'm happy to check that change in if this seems reasonable.</div><div><br></div><div>-Todd</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 13, 2014 at 4:25 PM, Todd Fiala <span dir="ltr"><<a href="mailto:tfiala@google.com" target="_blank">tfiala@google.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">You realize that qC's response is not stable as a pseudo pid, right? So anything that asks for it, thinks they have it, and then asks again for it can get a different result depending on what the gdb remote thinks is the current thread.<div>
<br></div><div>I'd offer we consider falling back to qC and not limiting it to iOS over reverting this entirely, unless you strongly object. *Or* we can simply do exactly what you said - which is check if we're attached to something - by grabbing the qC result and just not storing it as a process id (i.e. essentially create a GDBRemoteCommunicationClient::HasProcess (), which happens to be implemented in terms of checking qProcessInfo, then qC, for anything).</div>
<div><br></div><div>Just some thoughts.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Todd</div></font></span></div><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">On Tue, May 13, 2014 at 4:05 PM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@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><br>
> On May 13, 2014, at 7:56 AM, Todd Fiala <<a href="mailto:tfiala@google.com" target="_blank">tfiala@google.com</a>> wrote:<br>
><br>
> Hey Matthew,<br>
><br>
> > However is there any real need to restrict the fallback case to just Apple/iOS?<br>
><br>
> Keep in mind that qC in gdbserver does implement the protocol correctly and returns the thread id, not the proc id. On Linux the first thread happens to get a thread id that is identical to the proc id. So when launching an exe, the active thread id returned just happens to be the proc id as well out of happy coincidence. This is not true on other OSes and not guaranteed true when attaching to a Linux process if the active thread is not the first thread. Given that lldb was not caching the proc id until my change last week, it means that lldb using qC against a gdbserver (or gdb remote protocol implementing qC per spec) is definitely getting the buggy behavior I was fixing (i.e. different proc ids throughout the life of the process when running against a multi-threaded inferior, and entirely invalid results for proc id when run on OSes where the thread ids have no correlation to the proc id, as on MacOSX).<br>
><br>
> Thus, reverting to using qC when qProcessInfo isn't implemented is really just reverting to buggy and inconsistent behavior, although it may allow lldb to run where it can't now (and could before) and the proc id reported just happens to be right some of the time.<br>
<br>
</div>I would revert this. The pid isn't really all that important, we just need to know that we are talking to something valid or not. We assume zero is invalid.<br>
<div>><br>
> I think the real fix here may be if $qProcessInfo isn't present, then we probably need to settle for not assuming we can get the process id, and just make sure lldb can handle running without it in that case.<br>
><br>
> Greg, any thoughts on that?<br>
<br>
</div>I would revert to getting the pid from qC. Lame, but it would make us more backward compatible. Leave a note in the code saying we really prefer stubs to implement the qProcessInfo packet.<br>
<div><div><br>
><br>
> -Todd<br>
><br>
> On Tuesday, May 13, 2014, Matthew Gardiner <<a href="mailto:mg11@csr.com" target="_blank">mg11@csr.com</a>> wrote:e thread if returned<br>
> Todd Fiala wrote:<br>
> This is a change I made.<br>
><br>
> qC is supposed to return the thread id, not the process id.<br>
><br>
> qProcessInfo is being used now to collect the process id. We added a fallback so that if the process info request fails, on Apple/iOS we fall back to the older qC (which, as indicated before, used to return the process id erroneously, see the gdb remote documentation).<br>
><br>
> After doing a bit more analysis, I see that you added a fallback such that if the process info request fails, we fall back to traditional gdbserver qC. This is completely reasonable, and permits our custom stubs to support qProcessInfo.<br>
><br>
> However is there any real need to restrict the fallback case to just Apple/iOS? that is:<br>
><br>
> const llvm::Triple &triple = GetProcessArchitecture().GetTriple();<br>
> if ((triple.getVendor() == llvm::Triple::Apple) &&<br>
> (triple.getOS() == llvm::Triple::IOS))<br>
> {<br>
><br>
> Surely, all stubs which fail to implement qProcessInfo should be permitted to fallback to qC?<br>
><br>
> I've just commented out the above "if" in my working copy, and now the initial "gdb-remote host:port" works again - in so far as the current inferior process number is reported rather than 0. (Admittedly other things don't quite work as desired later on in the debug-session, e.g. "next". But presumably an Apple/iOS stub would either fail similarly, or work as expected due to some localised conditional treatment, (i.e. "if apple then...")).<br>
><br>
> So, to continue to interoperate with traditional gdbserver implementations can we let all older stubs continue to fallback to qC?<br>
><br>
> thanks<br>
> Matt<br>
><br>
><br>
><br>
><br>
><br>
> Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom<br>
> More information can be found at <a href="http://www.csr.com" target="_blank">www.csr.com</a>. Keep up to date with CSR on our technical blog, <a href="http://www.csr.com/blog" target="_blank">www.csr.com/blog</a>, CSR people blog, <a href="http://www.csr.com/people" target="_blank">www.csr.com/people</a>, YouTube, <a href="http://www.youtube.com/user/CSRplc" target="_blank">www.youtube.com/user/CSRplc</a>, Facebook, <a href="http://www.facebook.com/pages/CSR/191038434253534" target="_blank">www.facebook.com/pages/CSR/191038434253534</a>, or follow us on Twitter at <a href="http://www.twitter.com/CSR_plc" target="_blank">www.twitter.com/CSR_plc</a>.<br>
> New for 2014, you can now access the wide range of products powered by aptX at <a href="http://www.aptx.com" target="_blank">www.aptx.com</a>.<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><div class="">-- <br><div dir="ltr"><table cellspacing="0" cellpadding="0" style="color:rgb(136,136,136);font-family:'Times New Roman'">
<tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small">
<td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Todd Fiala |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tfiala@google.com" style="color:rgb(17,85,204)" target="_blank"><span style="background-color:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">tfiala@google.com</span></a> |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"><font color="#1155cc"> <a>650-943-3180</a></font></td></tr></tbody></table><br></div>
</div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><table cellspacing="0" cellpadding="0" style="color:rgb(136,136,136);font-family:'Times New Roman'"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small">
<td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Todd Fiala |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tfiala@google.com" style="color:rgb(17,85,204)" target="_blank"><span style="background-color:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">tfiala@google.com</span></a> |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"><font color="#1155cc"> <a>650-943-3180</a></font></td></tr></tbody></table><br></div>
</div>