[Lldb-commits] [PATCH] D106564: [LLDB][GUI] Add Arch Field

Omar Emara via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 22 08:29:09 PDT 2021


OmarEmaraDev created this revision.
OmarEmaraDev added a reviewer: clayborg.
Herald added a reviewer: teemperor.
OmarEmaraDev requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This patch adds an Arch field that inputs and validates an arch spec.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106564

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===================================================================
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -1345,6 +1345,25 @@
   bool m_need_to_exist;
 };
 
+class ArchFieldDelegate : public TextFieldDelegate {
+public:
+  ArchFieldDelegate(const char *label, const char *content, bool required)
+      : TextFieldDelegate(label, content, required) {}
+
+  void FieldDelegateExitCallback() override {
+    TextFieldDelegate::FieldDelegateExitCallback();
+    if (!IsSpecified())
+      return;
+
+    if (!GetArchSpec().IsValid())
+      SetError("Not a valid arch!");
+  }
+
+  const std::string &GetArchString() { return m_content; }
+
+  ArchSpec GetArchSpec() { return ArchSpec(GetArchString()); }
+};
+
 class BooleanFieldDelegate : public FieldDelegate {
 public:
   BooleanFieldDelegate(const char *label, bool content)
@@ -1919,6 +1938,14 @@
     return delegate;
   }
 
+  ArchFieldDelegate *AddArchField(const char *label, const char *content,
+                                  bool required) {
+    ArchFieldDelegate *delegate =
+        new ArchFieldDelegate(label, content, required);
+    m_fields.push_back(FieldDelegateUP(delegate));
+    return delegate;
+  }
+
   IntegerFieldDelegate *AddIntegerField(const char *label, int content,
                                         bool required) {
     IntegerFieldDelegate *delegate =


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106564.360836.patch
Type: text/x-patch
Size: 1449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210722/3c7133ea/attachment.bin>


More information about the lldb-commits mailing list