[Lldb-commits] [PATCH] D106467: [LLDB][GUI] Add Process Plugin Field
Omar Emara via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 21 11:02:03 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 a new Process Plugin Field. It is a choices field that
lists all the available process plugins and can retrieve the name of the
selected plugin or an empty string if the default is selected.
The Attach form now uses that field instead of manually creating a
choices field.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106467
Files:
lldb/source/Core/IOHandlerCursesGUI.cpp
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===================================================================
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -1504,6 +1504,29 @@
int m_first_visibile_choice;
};
+class ProcessPluginFieldDelegate : public ChoicesFieldDelegate {
+public:
+ ProcessPluginFieldDelegate()
+ : ChoicesFieldDelegate("Process Plugin", 3, GetPossiblePluginNames()) {}
+
+ std::vector<std::string> GetPossiblePluginNames() {
+ std::vector<std::string> names;
+ names.push_back("<default>");
+
+ size_t i = 0;
+ while (auto name = PluginManager::GetProcessPluginNameAtIndex(i++))
+ names.push_back(name);
+ return names;
+ }
+
+ std::string GetPluginName() {
+ std::string plugin_name = GetChoiceContent();
+ if (plugin_name == "<default>")
+ return "";
+ return plugin_name;
+ }
+};
+
template <class T> class ListFieldDelegate : public FieldDelegate {
public:
ListFieldDelegate(const char *label, T default_field)
@@ -1899,6 +1922,12 @@
return delegate;
}
+ ProcessPluginFieldDelegate *AddProcessPluginField() {
+ ProcessPluginFieldDelegate *delegate = new ProcessPluginFieldDelegate();
+ m_fields.push_back(FieldDelegateUP(delegate));
+ return delegate;
+ }
+
template <class T>
ListFieldDelegate<T> *AddListField(const char *label, T default_field) {
ListFieldDelegate<T> *delegate =
@@ -2347,8 +2376,7 @@
m_include_existing_field =
AddBooleanField("Include existing processes.", false);
m_show_advanced_field = AddBooleanField("Show advanced settings.", false);
- m_plugin_field =
- AddChoicesField("Plugin Name", 3, GetPossiblePluginNames());
+ m_plugin_field = AddProcessPluginField();
AddAction("Attach", [this](Window &window) { Attach(window); });
}
@@ -2390,16 +2418,6 @@
return module_sp->GetFileSpec().GetFilename().AsCString();
}
- std::vector<std::string> GetPossiblePluginNames() {
- std::vector<std::string> names;
- names.push_back("<default>");
-
- size_t i = 0;
- while (auto name = PluginManager::GetProcessPluginNameAtIndex(i++))
- names.push_back(name);
- return names;
- }
-
bool StopRunningProcess() {
ExecutionContext exe_ctx =
m_debugger.GetCommandInterpreter().GetExecutionContext();
@@ -2455,8 +2473,7 @@
} else {
attach_info.SetProcessID(m_pid_field->GetInteger());
}
- if (m_plugin_field->GetChoiceContent() != "<default>")
- attach_info.SetProcessPluginName(m_plugin_field->GetChoiceContent());
+ attach_info.SetProcessPluginName(m_plugin_field->GetPluginName());
return attach_info;
}
@@ -2504,7 +2521,7 @@
BooleanFieldDelegate *m_wait_for_field;
BooleanFieldDelegate *m_include_existing_field;
BooleanFieldDelegate *m_show_advanced_field;
- ChoicesFieldDelegate *m_plugin_field;
+ ProcessPluginFieldDelegate *m_plugin_field;
};
class MenuDelegate {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106467.360528.patch
Type: text/x-patch
Size: 2983 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210721/a5520c13/attachment.bin>
More information about the lldb-commits
mailing list