================
@@ -175,3 +175,35 @@ std::string RegisterFlags::AsTable(uint32_t max_width) 
const {
 
   return table;
 }
+
+void RegisterFlags::ToXML(StreamString &strm) const {
+  // Example XML:
+  // <flags id="cpsr_flags" size="4">
+  //   <field name="incorrect" start="0" end="0"/>
+  // </flags>
+  strm.Indent();
+  strm << "<flags id=\"" << GetID() << "\" ";
+  strm.Printf("size=\"%d\"", GetSize());
+  strm << ">";
+  for (const Field &field : m_fields) {
+    // Skip padding fields.
+    if (field.GetName().empty())
+      continue;
+
+    strm << "\n";
+    strm.IndentMore();
+    field.ToXML(strm);
+    strm.IndentLess();
+  }
+  strm.PutChar('\n');
+  strm.Indent("</flags>\n");
+}
+
+void RegisterFlags::Field::ToXML(StreamString &strm) const {
+  // Example XML:
+  // <field name="correct" start="0" end="0"/>
+  strm.Indent();
+  strm << "<field name=\"" << GetName() << "\" ";
----------------
DavidSpickett wrote:

Good point. Register names, unlikely. The ID of the flag set is an internal 
detail so that's ok as is.

For field names I have seen ones like `Foo[N]` so `Foo<N>` isn't that unlikely, 
especially if you've got a lot of system registers. Split fields like 
`Foo[3:1<stuff>Foo[0]` aren't that uncommon. I could imagine `'` being used to 
mean `prime` like `Foo` and `Foo'`.

So I've used printHTMLEscaped to replace the reserved chars (which are the same 
as for XML), and gone ahead and committed some tests to check that lldb itself 
will convert those back to the original characters 
(https://github.com/llvm/llvm-project/commit/2325b3cfdadf266651294ff469ce600a8ee402ce).

https://github.com/llvm/llvm-project/pull/69951
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to