aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectPlatform.cpp
diff options
context:
space:
mode:
authorMed Ismail Bennani <medismail.bennani@gmail.com>2023-01-09 20:26:19 -0800
committerMed Ismail Bennani <medismail.bennani@gmail.com>2023-01-12 12:49:05 -0800
commit2d53527e9c64c70c24e1abba74fa0a8c8b3392b1 (patch)
tree9d629efec95e7633675765fa301768d60603e4cb /lldb/source/Commands/CommandObjectPlatform.cpp
parent3fbc89048517e7152cce763db3b1e5738d558113 (diff)
downloadllvm-2d53527e9c64c70c24e1abba74fa0a8c8b3392b1.zip
llvm-2d53527e9c64c70c24e1abba74fa0a8c8b3392b1.tar.gz
llvm-2d53527e9c64c70c24e1abba74fa0a8c8b3392b1.tar.bz2
[lldb] Add Debugger & ScriptedMetadata reference to Platform::CreateInstance
This patch is preparatory work for Scripted Platform support and does multiple things: First, it introduces new options for the `platform select` command and `SBPlatform::Create` API, to hold a reference to the debugger object, the name of the python script managing the Scripted Platform and a structured data dictionary that the user can use to pass arbitrary data. Then, it updates the various `Create` and `GetOrCreate` methods for the `Platform` and `PlatformList` classes to pass down the new parameter to the `Platform::CreateInstance` callbacks. Finally, it updates every callback to reflect these changes. Differential Revision: https://reviews.llvm.org/D139249 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Diffstat (limited to 'lldb/source/Commands/CommandObjectPlatform.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp91
1 files changed, 43 insertions, 48 deletions
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 69c44fe..610eb24 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -139,63 +139,58 @@ private:
};
// "platform select <platform-name>"
-class CommandObjectPlatformSelect : public CommandObjectParsed {
-public:
- CommandObjectPlatformSelect(CommandInterpreter &interpreter)
- : CommandObjectParsed(interpreter, "platform select",
- "Create a platform if needed and select it as the "
- "current platform.",
- "platform select <platform-name>", 0),
- m_platform_options(
- false) // Don't include the "--platform" option by passing false
- {
- m_option_group.Append(&m_platform_options, LLDB_OPT_SET_ALL, 1);
- m_option_group.Finalize();
- CommandArgumentData platform_arg{eArgTypePlatform, eArgRepeatPlain};
- m_arguments.push_back({platform_arg});
- }
+CommandObjectPlatformSelect::CommandObjectPlatformSelect(
+ CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "platform select",
+ "Create a platform if needed and select it as the "
+ "current platform.",
+ "platform select <platform-name>", 0),
+ m_platform_options(
+ false) // Don't include the "--platform" option by passing false
+{
+ m_option_group.Append(&m_platform_options, LLDB_OPT_SET_ALL, 1);
+ m_option_group.Append(&m_platform_options.m_class_options,
+ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, LLDB_OPT_SET_ALL);
+ m_option_group.Finalize();
+ CommandArgumentData platform_arg{eArgTypePlatform, eArgRepeatPlain};
+ m_arguments.push_back({platform_arg});
+}
- ~CommandObjectPlatformSelect() override = default;
+void CommandObjectPlatformSelect::HandleCompletion(CompletionRequest &request) {
+ CommandCompletions::PlatformPluginNames(GetCommandInterpreter(), request,
+ nullptr);
+}
- void HandleCompletion(CompletionRequest &request) override {
- CommandCompletions::PlatformPluginNames(GetCommandInterpreter(), request,
- nullptr);
- }
+Options *CommandObjectPlatformSelect::GetOptions() { return &m_option_group; }
- Options *GetOptions() override { return &m_option_group; }
+bool CommandObjectPlatformSelect::DoExecute(Args &args,
+ CommandReturnObject &result) {
+ if (args.GetArgumentCount() == 1) {
+ const char *platform_name = args.GetArgumentAtIndex(0);
+ if (platform_name && platform_name[0]) {
+ const bool select = true;
+ m_platform_options.SetPlatformName(platform_name);
+ Status error;
+ ArchSpec platform_arch;
+ PlatformSP platform_sp(m_platform_options.CreatePlatformWithOptions(
+ m_interpreter, ArchSpec(), select, error, platform_arch));
+ if (platform_sp) {
+ GetDebugger().GetPlatformList().SetSelectedPlatform(platform_sp);
-protected:
- bool DoExecute(Args &args, CommandReturnObject &result) override {
- if (args.GetArgumentCount() == 1) {
- const char *platform_name = args.GetArgumentAtIndex(0);
- if (platform_name && platform_name[0]) {
- const bool select = true;
- m_platform_options.SetPlatformName(platform_name);
- Status error;
- ArchSpec platform_arch;
- PlatformSP platform_sp(m_platform_options.CreatePlatformWithOptions(
- m_interpreter, ArchSpec(), select, error, platform_arch));
- if (platform_sp) {
- GetDebugger().GetPlatformList().SetSelectedPlatform(platform_sp);
-
- platform_sp->GetStatus(result.GetOutputStream());
- result.SetStatus(eReturnStatusSuccessFinishResult);
- } else {
- result.AppendError(error.AsCString());
- }
+ platform_sp->GetStatus(result.GetOutputStream());
+ result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
- result.AppendError("invalid platform name");
+ result.AppendError(error.AsCString());
}
} else {
- result.AppendError(
- "platform create takes a platform name as an argument\n");
+ result.AppendError("invalid platform name");
}
- return result.Succeeded();
+ } else {
+ result.AppendError(
+ "platform create takes a platform name as an argument\n");
}
-
- OptionGroupOptions m_option_group;
- OptionGroupPlatform m_platform_options;
-};
+ return result.Succeeded();
+}
// "platform list"
class CommandObjectPlatformList : public CommandObjectParsed {