From bcae3cdbd029210e9ecf42f07d38cc4ed4a95230 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 14 Jul 2022 20:23:07 -0700 Subject: [lldb] Print the enum values and their description in the help output Print the enum values and their description in the help output for argument values. Until now, there was no way to get these values and their description. Example output: (lldb) help -- How verbose the output of 'po' should be. compact : Only show the description string full : Show the full output, including persistent variable's name and type Differential revision: https://reviews.llvm.org/D129707 --- lldb/source/Interpreter/CommandObject.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'lldb/source/Interpreter/CommandObject.cpp') diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index 609ac57..719cfbc 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -16,6 +16,7 @@ #include #include "lldb/Core/Address.h" +#include "lldb/Interpreter/CommandOptionArgumentTable.h" #include "lldb/Interpreter/Options.h" #include "lldb/Utility/ArchSpec.h" #include "llvm/ADT/ScopeExit.h" @@ -398,9 +399,28 @@ void CommandObject::GetArgumentHelp(Stream &str, CommandArgumentType arg_type, interpreter.OutputHelpText(str, name_str.GetString(), "--", help_text, name_str.GetSize()); } - } else + } else { interpreter.OutputFormattedHelpText(str, name_str.GetString(), "--", entry->help_text, name_str.GetSize()); + + // Print enum values and their description if any. + OptionEnumValues enum_values = g_argument_table[arg_type].enum_values; + if (!enum_values.empty()) { + str.EOL(); + size_t longest = 0; + for (const OptionEnumValueElement &element : enum_values) + longest = + std::max(longest, llvm::StringRef(element.string_value).size()); + str.IndentMore(5); + for (const OptionEnumValueElement &element : enum_values) { + str.Indent(); + interpreter.OutputHelpText(str, element.string_value, ":", + element.usage, longest); + } + str.IndentLess(5); + str.EOL(); + } + } } const char *CommandObject::GetArgumentName(CommandArgumentType arg_type) { -- cgit v1.1