diff options
-rw-r--r-- | lldb/include/lldb/Interpreter/CommandAlias.h | 8 | ||||
-rw-r--r-- | lldb/include/lldb/Interpreter/CommandObject.h | 10 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectCommands.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandAlias.cpp | 22 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 12 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandObject.cpp | 57 |
6 files changed, 67 insertions, 48 deletions
diff --git a/lldb/include/lldb/Interpreter/CommandAlias.h b/lldb/include/lldb/Interpreter/CommandAlias.h index 2f703513058..f14ac52e705 100644 --- a/lldb/include/lldb/Interpreter/CommandAlias.h +++ b/lldb/include/lldb/Interpreter/CommandAlias.h @@ -88,6 +88,12 @@ public: const char* GetHelpLong () override; + void + SetHelp (const char * str) override; + + void + SetHelpLong (const char * str) override; + bool Execute(const char *args_string, CommandReturnObject &result) override; @@ -105,6 +111,8 @@ private: std::string m_option_string; OptionArgVectorSP m_option_args_sp ; LazyBool m_is_dashdash_alias; + bool m_did_set_help : 1; + bool m_did_set_help_long : 1; }; } // namespace lldb_private diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h index b881f38976c..2f2a897523f 100644 --- a/lldb/include/lldb/Interpreter/CommandObject.h +++ b/lldb/include/lldb/Interpreter/CommandObject.h @@ -154,19 +154,13 @@ public: const char * GetCommandName (); - void + virtual void SetHelp (const char * str); - void - SetHelp (std::string str); - - void + virtual void SetHelpLong (const char * str); void - SetHelpLong (std::string str); - - void SetSyntax (const char *str); // override this to return true if you want to enable the user to delete diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 09008756cfe..f6b2144eae0 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -1345,7 +1345,7 @@ public: std::string docstring; m_fetched_help_long = scripter->GetDocumentationForItem(m_function_name.c_str(),docstring); if (!docstring.empty()) - SetHelpLong(docstring); + SetHelpLong(docstring.c_str()); } } return CommandObjectRaw::GetHelpLong(); @@ -1446,7 +1446,7 @@ public: std::string docstring; m_fetched_help_short = scripter->GetShortHelpForCommandObject(m_cmd_obj_sp,docstring); if (!docstring.empty()) - SetHelp(docstring); + SetHelp(docstring.c_str()); } } return CommandObjectRaw::GetHelp(); @@ -1463,7 +1463,7 @@ public: std::string docstring; m_fetched_help_long = scripter->GetLongHelpForCommandObject(m_cmd_obj_sp,docstring); if (!docstring.empty()) - SetHelpLong(docstring); + SetHelpLong(docstring.c_str()); } } return CommandObjectRaw::GetHelpLong(); diff --git a/lldb/source/Interpreter/CommandAlias.cpp b/lldb/source/Interpreter/CommandAlias.cpp index f9929b45ca3..f7d8e8e9f1b 100644 --- a/lldb/source/Interpreter/CommandAlias.cpp +++ b/lldb/source/Interpreter/CommandAlias.cpp @@ -87,7 +87,9 @@ CommandAlias::CommandAlias (CommandInterpreter &interpreter, m_underlying_command_sp(), m_option_string(options_args ? options_args : ""), m_option_args_sp(new OptionArgVector), -m_is_dashdash_alias(eLazyBoolCalculate) +m_is_dashdash_alias(eLazyBoolCalculate), +m_did_set_help(false), +m_did_set_help_long(false) { if (ProcessAliasOptionsArgs(cmd_sp, options_args, m_option_args_sp)) { @@ -259,10 +261,24 @@ CommandAlias::Desugar () // allow CommandAlias objects to provide their own help, but fallback to the info // for the underlying command if no customization has been provided +void +CommandAlias::SetHelp (const char * str) +{ + this->CommandObject::SetHelp(str); + m_did_set_help = true; +} + +void +CommandAlias::SetHelpLong (const char * str) +{ + this->CommandObject::SetHelpLong(str); + m_did_set_help_long = true; +} + const char* CommandAlias::GetHelp () { - if (!m_cmd_help_short.empty()) + if (!m_cmd_help_short.empty() || m_did_set_help) return m_cmd_help_short.c_str(); if (IsValid()) return m_underlying_command_sp->GetHelp(); @@ -272,7 +288,7 @@ CommandAlias::GetHelp () const char* CommandAlias::GetHelpLong () { - if (!m_cmd_help_long.empty()) + if (!m_cmd_help_long.empty() || m_did_set_help_long) return m_cmd_help_long.c_str(); if (IsValid()) return m_underlying_command_sp->GetHelpLong(); diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 78c37a6a27d..96602cd4cfc 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -344,10 +344,14 @@ CommandInterpreter::Initialize () cmd_obj_sp = GetCommandSPExact ("expression", false); if (cmd_obj_sp) { - AddAlias ("p", cmd_obj_sp, "--"); - AddAlias ("print", cmd_obj_sp, "--"); - AddAlias ("call", cmd_obj_sp, "--"); - AddAlias ("po", cmd_obj_sp, "-O --"); + AddAlias ("p", cmd_obj_sp, "--")->SetHelpLong(""); + AddAlias ("print", cmd_obj_sp, "--")->SetHelpLong(""); + AddAlias ("call", cmd_obj_sp, "--")->SetHelpLong(""); + if (auto po = AddAlias ("po", cmd_obj_sp, "-O --")) + { + po->SetHelp("Evaluate an expression in the current program context, using user defined variables and variables currently in scope, and display the result of evaluation in a language-specific manner."); + po->SetHelpLong(""); + } } cmd_obj_sp = GetCommandSPExact ("process kill", false); diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index ead292a3152..d8c10847fa1 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -118,25 +118,19 @@ CommandObject::SetCommandName (const char *name) void CommandObject::SetHelp (const char *cstr) { - m_cmd_help_short = cstr; -} - -void -CommandObject::SetHelp (std::string str) -{ - m_cmd_help_short = str; + if (cstr) + m_cmd_help_short = cstr; + else + m_cmd_help_short.assign(""); } void CommandObject::SetHelpLong (const char *cstr) { - m_cmd_help_long = cstr; -} - -void -CommandObject::SetHelpLong (std::string str) -{ - m_cmd_help_long = str; + if (cstr) + m_cmd_help_long = cstr; + else + m_cmd_help_long.assign(""); } void @@ -932,23 +926,26 @@ CommandObject::GenerateHelpText (Stream &output_strm) if ((long_help != nullptr) && (strlen (long_help) > 0)) FormatLongHelpText (output_strm, long_help); - if (WantsRawCommandString() && !WantsCompletion()) - { - // Emit the message about using ' -- ' between the end of the command options and the raw input - // conditionally, i.e., only if the command object does not want completion. - interpreter.OutputFormattedHelpText (output_strm, "", "", - "\nIMPORTANT NOTE: Because this command takes 'raw' input, if you use any command options" - " you must use ' -- ' between the end of the command options and the beginning of the raw input.", 1); - } - else if (GetNumArgumentEntries() > 0 - && GetOptions() - && GetOptions()->NumCommandOptions() > 0) + if (!IsDashDashCommand()) { - // Also emit a warning about using "--" in case you are using a command that takes options and arguments. - interpreter.OutputFormattedHelpText (output_strm, "", "", - "\nThis command takes options and free-form arguments. If your arguments resemble" - " option specifiers (i.e., they start with a - or --), you must use ' -- ' between" - " the end of the command options and the beginning of the arguments.", 1); + if (WantsRawCommandString() && !WantsCompletion()) + { + // Emit the message about using ' -- ' between the end of the command options and the raw input + // conditionally, i.e., only if the command object does not want completion. + interpreter.OutputFormattedHelpText (output_strm, "", "", + "\nIMPORTANT NOTE: Because this command takes 'raw' input, if you use any command options" + " you must use ' -- ' between the end of the command options and the beginning of the raw input.", 1); + } + else if (GetNumArgumentEntries() > 0 + && GetOptions() + && GetOptions()->NumCommandOptions() > 0) + { + // Also emit a warning about using "--" in case you are using a command that takes options and arguments. + interpreter.OutputFormattedHelpText (output_strm, "", "", + "\nThis command takes options and free-form arguments. If your arguments resemble" + " option specifiers (i.e., they start with a - or --), you must use ' -- ' between" + " the end of the command options and the beginning of the arguments.", 1); + } } } else if (IsMultiwordObject()) |