<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-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/Process/gdb-remote/GDBRemoteCommunicationClient.cpp<br>
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp<br>
<br>
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.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-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=313442&r1=313441&r2=313442&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)<br>
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Fri Sep 15 20:53:13 2017<br>
@@ -2624,8 +2624,7 @@ size_t GDBRemoteCommunicationClient::Get<br>
* tid.<br>
* Assume pid=tid=1 in such cases.<br>
*/<br>
- if (response.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/Process/gdb-remote/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-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=313442&r1=313441&r2=313442&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)<br>
+++ lldb/trunk/source/Plugins/Process/gdb-remote/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::GetGDBServerRegis<br>
<br>
XMLNode target_node = xml_document.GetRootElement("target");<br>
if (target_node) {<br>
- XMLNode feature_node;<br>
- target_node.ForEachChildElement([&target_info, &feature_node](<br>
+ std::vector<XMLNode> feature_nodes;<br>
+ target_node.ForEachChildElement([&target_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::GetGDBServerRegis<br>
if (!href.empty())<br>
target_info.includes.push_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.ForEachChildElementWithName(<br>
"group", [&target_info](const XMLNode &node) -> bool {<br>
@@ -4423,7 +4422,7 @@ bool ProcessGDBRemote::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_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>
_______________________________________________<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/mailman/listinfo/lldb-commits</a><br>
</blockquote></div></div>