aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectHelp.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-09-18 01:14:36 +0000
committerGreg Clayton <gclayton@apple.com>2010-09-18 01:14:36 +0000
commita701509229f658eac7c10bd6aa54cf6ed5b5011d (patch)
treeb38ff5cfb3fd466e5c7f89cea9bd9fa7d89eed16 /lldb/source/Commands/CommandObjectHelp.cpp
parent9a587aaaa9e7bed09477c3c8d51d8f44dfd99158 (diff)
downloadllvm-a701509229f658eac7c10bd6aa54cf6ed5b5011d.zip
llvm-a701509229f658eac7c10bd6aa54cf6ed5b5011d.tar.gz
llvm-a701509229f658eac7c10bd6aa54cf6ed5b5011d.tar.bz2
Fixed the way set/show variables were being accessed to being natively
accessed by the objects that own the settings. The previous approach wasn't very usable and made for a lot of unnecessary code just to access variables that were already owned by the objects. While I fixed those things, I saw that CommandObject objects should really have a reference to their command interpreter so they can access the terminal with if they want to output usaage. Fixed up all CommandObjects to take an interpreter and cleaned up the API to not need the interpreter to be passed in. Fixed the disassemble command to output the usage if no options are passed down and arguments are passed (all disassebmle variants take options, there are no "args only"). llvm-svn: 114252
Diffstat (limited to 'lldb/source/Commands/CommandObjectHelp.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectHelp.cpp43
1 files changed, 26 insertions, 17 deletions
diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp
index 9541d36..2d4b9f2 100644
--- a/lldb/source/Commands/CommandObjectHelp.cpp
+++ b/lldb/source/Commands/CommandObjectHelp.cpp
@@ -25,8 +25,9 @@ using namespace lldb_private;
// CommandObjectHelp
//-------------------------------------------------------------------------
-CommandObjectHelp::CommandObjectHelp () :
- CommandObject ("help",
+CommandObjectHelp::CommandObjectHelp (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "help",
"Show a list of all debugger commands, or give details about specific commands.",
"help [<cmd-name>]")
{
@@ -38,7 +39,7 @@ CommandObjectHelp::~CommandObjectHelp()
bool
-CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, CommandReturnObject &result)
+CommandObjectHelp::Execute (Args& command, CommandReturnObject &result)
{
CommandObject::CommandMap::iterator pos;
CommandObject *cmd_obj;
@@ -49,13 +50,13 @@ CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, Comm
if (argc == 0)
{
result.SetStatus (eReturnStatusSuccessFinishNoResult);
- interpreter.GetHelp (result); // General help, for ALL commands.
+ m_interpreter.GetHelp (result); // General help, for ALL commands.
}
else
{
// Get command object for the first command argument. Only search built-in command dictionary.
StringList matches;
- cmd_obj = interpreter.GetCommandObject (command.GetArgumentAtIndex (0), &matches);
+ cmd_obj = m_interpreter.GetCommandObject (command.GetArgumentAtIndex (0), &matches);
if (cmd_obj != NULL)
{
@@ -94,10 +95,9 @@ CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, Comm
Stream &output_strm = result.GetOutputStream();
if (sub_cmd_obj->GetOptions() != NULL)
{
- interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
+ m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax());
- sub_cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, sub_cmd_obj,
- interpreter.GetDebugger().GetInstanceName().AsCString());
+ sub_cmd_obj->GetOptions()->GenerateOptionUsage (m_interpreter, output_strm, sub_cmd_obj);
const char *long_help = sub_cmd_obj->GetHelpLong();
if ((long_help != NULL)
&& (strlen (long_help) > 0))
@@ -105,8 +105,8 @@ CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, Comm
}
else if (sub_cmd_obj->IsMultiwordObject())
{
- interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
- ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (interpreter, result);
+ m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
+ ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (result);
}
else
{
@@ -115,7 +115,7 @@ CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, Comm
&& (strlen (long_help) > 0))
output_strm.Printf ("\n%s", long_help);
else
- interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
+ m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax());
}
}
@@ -145,7 +145,6 @@ CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, Comm
int
CommandObjectHelp::HandleCompletion
(
- CommandInterpreter &interpreter,
Args &input,
int &cursor_index,
int &cursor_char_position,
@@ -158,15 +157,25 @@ CommandObjectHelp::HandleCompletion
// Return the completions of the commands in the help system:
if (cursor_index == 0)
{
- return interpreter.HandleCompletionMatches(input, cursor_index, cursor_char_position, match_start_point,
- max_return_elements, word_complete, matches);
+ return m_interpreter.HandleCompletionMatches (input,
+ cursor_index,
+ cursor_char_position,
+ match_start_point,
+ max_return_elements,
+ word_complete,
+ matches);
}
else
{
- CommandObject *cmd_obj = interpreter.GetCommandObject (input.GetArgumentAtIndex(0));
+ CommandObject *cmd_obj = m_interpreter.GetCommandObject (input.GetArgumentAtIndex(0));
input.Shift();
cursor_index--;
- return cmd_obj->HandleCompletion (interpreter, input, cursor_index, cursor_char_position, match_start_point,
- max_return_elements, word_complete, matches);
+ return cmd_obj->HandleCompletion (input,
+ cursor_index,
+ cursor_char_position,
+ match_start_point,
+ max_return_elements,
+ word_complete,
+ matches);
}
}