[Lldb-commits] [PATCH] D129707: [lldb] Print the enum values and their description in the argument value help output
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 13 20:35:44 PDT 2022
JDevlieghere updated this revision to Diff 444511.
JDevlieghere added a comment.
Rebase on D129703 <https://reviews.llvm.org/D129703>
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129707/new/
https://reviews.llvm.org/D129707
Files:
lldb/source/Interpreter/CommandObject.cpp
lldb/test/API/commands/help/TestHelp.py
Index: lldb/test/API/commands/help/TestHelp.py
===================================================================
--- lldb/test/API/commands/help/TestHelp.py
+++ lldb/test/API/commands/help/TestHelp.py
@@ -318,3 +318,16 @@
"\(does not apply to binary output\)."])
self.expect("help memory find", patterns=[
"--show-tags\n\s+Include memory tags in output."])
+
+ @no_debug_info_test
+ def test_help_show_enum_values(self):
+ """ Check the help output for a argument type contains the enum values
+ and their descriptions. """
+ self.expect("help <log-handler>", substrs=[
+ 'The log handle that will be used to write out log messages.',
+ 'default' , 'Use the default (stream) log handler',
+ 'stream' , 'Write log messages to the debugger output stream',
+ 'circular' , 'Write log messages to a fixed size circular buffer',
+ 'os' , 'Write log messages to the operating system log',
+ ])
+
Index: lldb/source/Interpreter/CommandObject.cpp
===================================================================
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -16,6 +16,7 @@
#include <cstdlib>
#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 @@
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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129707.444511.patch
Type: text/x-patch
Size: 2589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220714/692ed0b8/attachment.bin>
More information about the lldb-commits
mailing list