diff options
Diffstat (limited to 'lldb/source/Interpreter')
-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 |
3 files changed, 54 insertions, 37 deletions
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()) |