<div dir="ltr">Yes, this works for OpenOCD as well.  Thanks!</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 18, 2017 at 4:44 AM, Tamas Berghammer <span dir="ltr"><<a href="mailto:tberghammer@google.com" target="_blank">tberghammer@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">Hi Vadim,<div><br></div><div>This change broke remote debugging on Linux and Android as for some reason LLDB sends a qfThreadInfo on those platforms before starting a process (not sure why, will investigate when I have a bit more time) and lldb-server sends an OK response to it. After your change it will generate a valid thread ID what will cause LLDB to get confused and fail to lunch a process. I submitted a fix as r313525 what should work both for OpenOCD and for Linux/Android but can you verify the OpenOCD part?</div><div><br></div><div>Thanks,</div><div>Tamas</div><br><div class="gmail_quote"><div dir="ltr">On Sat, Sep 16, 2017 at 4:54 AM Vadim Chugunov via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: vadimcn<br>
Date: Fri Sep 15 20:53:13 2017<br>
New Revision: 313442<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=313442&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=313442&view=rev</a><br>
Log:<br>
Fix compatibility with OpenOCD debug stub.<br>
<br>
OpenOCD sends register classes as two separate <feature> nodes, fixed parser to process both of them.<br>
<br>
OpenOCD returns "l" in response to "qfThreadInfo", so IsUnsupportedResponse() was false and we were ending up without any threads in the process. I think it's reasonable to assume that there's always at least one thread.<br>
<br>
Modified:<br>
    lldb/trunk/source/Plugins/<wbr>Process/gdb-remote/<wbr>GDBRemoteCommunicationClient.<wbr>cpp<br>
    lldb/trunk/source/Plugins/<wbr>Process/gdb-remote/<wbr>ProcessGDBRemote.cpp<br>
<br>
Modified: lldb/trunk/source/Plugins/<wbr>Process/gdb-remote/<wbr>GDBRemoteCommunicationClient.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=313442&r1=313441&r2=313442&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lldb/trunk/source/<wbr>Plugins/Process/gdb-remote/<wbr>GDBRemoteCommunicationClient.<wbr>cpp?rev=313442&r1=313441&r2=<wbr>313442&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lldb/trunk/source/Plugins/<wbr>Process/gdb-remote/<wbr>GDBRemoteCommunicationClient.<wbr>cpp (original)<br>
+++ lldb/trunk/source/Plugins/<wbr>Process/gdb-remote/<wbr>GDBRemoteCommunicationClient.<wbr>cpp Fri Sep 15 20:53:13 2017<br>
@@ -2624,8 +2624,7 @@ size_t GDBRemoteCommunicationClient::<wbr>Get<br>
      * tid.<br>
      * Assume pid=tid=1 in such cases.<br>
     */<br>
-    if (response.<wbr>IsUnsupportedResponse() && thread_ids.size() == 0 &&<br>
-        IsConnected()) {<br>
+    if (thread_ids.size() == 0 && IsConnected()) {<br>
       thread_ids.push_back(1);<br>
     }<br>
   } else {<br>
<br>
Modified: lldb/trunk/source/Plugins/<wbr>Process/gdb-remote/<wbr>ProcessGDBRemote.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=313442&r1=313441&r2=313442&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lldb/trunk/source/<wbr>Plugins/Process/gdb-remote/<wbr>ProcessGDBRemote.cpp?rev=<wbr>313442&r1=313441&r2=313442&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lldb/trunk/source/Plugins/<wbr>Process/gdb-remote/<wbr>ProcessGDBRemote.cpp (original)<br>
+++ lldb/trunk/source/Plugins/<wbr>Process/gdb-remote/<wbr>ProcessGDBRemote.cpp Fri Sep 15 20:53:13 2017<br>
@@ -4168,7 +4168,6 @@ struct GdbServerTargetInfo {<br>
   std::string osabi;<br>
   stringVec includes;<br>
   RegisterSetMap reg_set_map;<br>
-  XMLNode feature_node;<br>
 };<br>
<br>
 bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,<br>
@@ -4374,8 +4373,8 @@ bool ProcessGDBRemote::<wbr>GetGDBServerRegis<br>
<br>
     XMLNode target_node = xml_document.GetRootElement("<wbr>target");<br>
     if (target_node) {<br>
-      XMLNode feature_node;<br>
-      target_node.<wbr>ForEachChildElement([&target_<wbr>info, &feature_node](<br>
+      std::vector<XMLNode> feature_nodes;<br>
+      target_node.<wbr>ForEachChildElement([&target_<wbr>info, &feature_nodes](<br>
                                           const XMLNode &node) -> bool {<br>
         llvm::StringRef name = node.GetName();<br>
         if (name == "architecture") {<br>
@@ -4387,7 +4386,7 @@ bool ProcessGDBRemote::<wbr>GetGDBServerRegis<br>
           if (!href.empty())<br>
             target_info.includes.push_<wbr>back(href.str());<br>
         } else if (name == "feature") {<br>
-          feature_node = node;<br>
+          feature_nodes.push_back(node);<br>
         } else if (name == "groups") {<br>
           node.<wbr>ForEachChildElementWithName(<br>
               "group", [&target_info](const XMLNode &node) -> bool {<br>
@@ -4423,7 +4422,7 @@ bool ProcessGDBRemote::<wbr>GetGDBServerRegis<br>
       // set the Target's architecture yet, so the ABI is also potentially<br>
       // incorrect.<br>
       ABISP abi_to_use_sp = ABI::FindPlugin(shared_from_<wbr>this(), arch_to_use);<br>
-      if (feature_node) {<br>
+      for (auto &feature_node : feature_nodes) {<br>
         ParseRegisters(feature_node, target_info, this->m_register_info,<br>
                        abi_to_use_sp, cur_reg_num, reg_offset);<br>
       }<br>
<br>
<br>
______________________________<wbr>_________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/lldb-commits</a><br>
</blockquote></div></div>
</blockquote></div><br></div>