[Lldb-commits] [lldb] ba822e2 - [LLDB] Format lldb-server's target XML
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 20 02:02:25 PDT 2022
Author: David Spickett
Date: 2022-09-20T09:02:17Z
New Revision: ba822e248d3a41aa334eb1b79396364ee251c10c
URL: https://github.com/llvm/llvm-project/commit/ba822e248d3a41aa334eb1b79396364ee251c10c
DIFF: https://github.com/llvm/llvm-project/commit/ba822e248d3a41aa334eb1b79396364ee251c10c.diff
LOG: [LLDB] Format lldb-server's target XML
So that the XML isn't one giant line. Which wasn't
a problem for lldb but was for me trying to troubleshoot
it using the logs.
It now looks like:
```
<?xml version="1.0"?>
<target version="1.0">
<architecture>aarch64</architecture>
<feature>
<...>
<reg name="fpcr" .../>
</feature>
</target>
```
Reviewed By: labath
Differential Revision: https://reviews.llvm.org/D134035
Added:
Modified:
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/test/API/tools/lldb-server/TestPtyServer.py
lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 072151e73f933..4ea8472c008ca 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -3066,19 +3066,24 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
StreamString response;
- response.Printf("<?xml version=\"1.0\"?>");
- response.Printf("<target version=\"1.0\">");
+ response.Printf("<?xml version=\"1.0\"?>\n");
+ response.Printf("<target version=\"1.0\">\n");
+ response.IndentMore();
- response.Printf("<architecture>%s</architecture>",
+ response.Indent();
+ response.Printf("<architecture>%s</architecture>\n",
m_current_process->GetArchitecture()
.GetTriple()
.getArchName()
.str()
.c_str());
- response.Printf("<feature>");
+ response.Indent("<feature>\n");
const int registers_count = reg_context.GetUserRegisterCount();
+ if (registers_count)
+ response.IndentMore();
+
for (int reg_index = 0; reg_index < registers_count; reg_index++) {
const RegisterInfo *reg_info =
reg_context.GetRegisterInfoAtIndex(reg_index);
@@ -3090,7 +3095,9 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
continue;
}
- response.Printf("<reg name=\"%s\" bitsize=\"%" PRIu32 "\" regnum=\"%d\" ",
+ response.Indent();
+ response.Printf("<reg name=\"%s\" bitsize=\"%" PRIu32
+ "\" regnum=\"%d\" ",
reg_info->name, reg_info->byte_size * 8, reg_index);
if (!reg_context.RegisterOffsetIsDynamic())
@@ -3139,11 +3146,15 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
response.Printf("\" ");
}
- response.Printf("/>");
+ response.Printf("/>\n");
}
- response.Printf("</feature>");
- response.Printf("</target>");
+ if (registers_count)
+ response.IndentLess();
+
+ response.Indent("</feature>\n");
+ response.IndentLess();
+ response.Indent("</target>\n");
return MemoryBuffer::getMemBufferCopy(response.GetString(), "target.xml");
}
diff --git a/lldb/test/API/tools/lldb-server/TestPtyServer.py b/lldb/test/API/tools/lldb-server/TestPtyServer.py
index f5aa0ad74751d..52b7cf47423e7 100644
--- a/lldb/test/API/tools/lldb-server/TestPtyServer.py
+++ b/lldb/test/API/tools/lldb-server/TestPtyServer.py
@@ -63,7 +63,7 @@ def test_pty_server(self):
"read packet: $qXfer:features:read:target.xml:0,200000#00",
{
"direction": "send",
- "regex": re.compile("^\$l(.+)#[0-9a-fA-F]{2}$"),
+ "regex": re.compile("^\$l(.+)#[0-9a-fA-F]{2}$", flags=re.DOTALL),
"capture": {1: "target_xml"},
}],
True)
diff --git a/lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py b/lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
index 96eddf6ceae14..9a863673ef23c 100644
--- a/lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
+++ b/lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
@@ -25,7 +25,7 @@ def test_g_target_xml_returns_correct_data(self):
LENGTH),
{
"direction": "send",
- "regex": re.compile("^\$l(.+)#[0-9a-fA-F]{2}$"),
+ "regex": re.compile("^\$l(.+)#[0-9a-fA-F]{2}$", flags=re.DOTALL),
"capture": {1: "target_xml"}
}],
True)
More information about the lldb-commits
mailing list