From: David Spickett Date: Wed, 17 Aug 2022 13:58:28 +0000 (+0000) Subject: [LLDB] Format lldb-server's target XML X-Git-Tag: upstream/17.0.6~33052 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ba822e248d3a41aa334eb1b79396364ee251c10c;p=platform%2Fupstream%2Fllvm.git [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: ``` aarch64 <...> ``` Reviewed By: labath Differential Revision: https://reviews.llvm.org/D134035 --- diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 072151e..4ea8472 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(""); - response.Printf(""); + response.Printf("\n"); + response.Printf("\n"); + response.IndentMore(); - response.Printf("%s", + response.Indent(); + response.Printf("%s\n", m_current_process->GetArchitecture() .GetTriple() .getArchName() .str() .c_str()); - response.Printf(""); + response.Indent("\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("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(""); - response.Printf(""); + if (registers_count) + response.IndentLess(); + + response.Indent("\n"); + response.IndentLess(); + response.Indent("\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 f5aa0ad..52b7cf4 100644 --- a/lldb/test/API/tools/lldb-server/TestPtyServer.py +++ b/lldb/test/API/tools/lldb-server/TestPtyServer.py @@ -63,7 +63,7 @@ class PtyServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase): "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 96eddf6..9a86367 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 @@ class TestGdbRemoteTargetXmlPacket(gdbremote_testcase.GdbRemoteTestCaseBase): 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)