diff options
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r-- | lldb/source/Commands/CommandCompletions.cpp | 24 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectAppend.cpp | 94 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectAppend.h | 42 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectHelp.cpp | 8 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 52 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectSet.cpp | 152 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectSet.h | 43 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectSettings.cpp | 983 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectSettings.h | 308 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectShow.cpp | 73 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectShow.h | 43 |
11 files changed, 1337 insertions, 485 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 77e9ac8c8f2..42275cb982d 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -38,6 +38,7 @@ CommandCompletions::g_common_completions[] = {eDiskDirectoryCompletion, CommandCompletions::DiskDirectories}, {eSymbolCompletion, CommandCompletions::Symbols}, {eModuleCompletion, CommandCompletions::Modules}, + {eSettingsNameCompletion, CommandCompletions::SettingsNames}, {eNoCompletion, NULL} // This one has to be last in the list. }; @@ -410,6 +411,26 @@ CommandCompletions::Symbols return matches.GetSize(); } +int +CommandCompletions::SettingsNames (CommandInterpreter &interpreter, + const char *partial_setting_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + bool &word_complete, + StringList &matches) +{ + lldb::UserSettingsControllerSP root_settings = Debugger::GetSettingsController(); + Args partial_setting_name_pieces = UserSettingsController::BreakNameIntoPieces (partial_setting_name); + + return UserSettingsController::CompleteSettingsNames (root_settings, + partial_setting_name_pieces, + word_complete, + matches); + + //return matches.GetSize(); +} + CommandCompletions::Completer::Completer ( CommandInterpreter &interpreter, @@ -687,6 +708,3 @@ CommandCompletions::ModuleCompleter::DoCompletion (SearchFilter *filter) filter->Search (*this); return m_matches.GetSize(); } - - - diff --git a/lldb/source/Commands/CommandObjectAppend.cpp b/lldb/source/Commands/CommandObjectAppend.cpp deleted file mode 100644 index 89d5cee71e4..00000000000 --- a/lldb/source/Commands/CommandObjectAppend.cpp +++ /dev/null @@ -1,94 +0,0 @@ -//===-- CommandObjectAppend.cpp ---------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectAppend.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -using namespace lldb; -using namespace lldb_private; - -//----------------------------------------------------------------------------- -// CommandObjectAppend -//----------------------------------------------------------------------------- - -CommandObjectAppend::CommandObjectAppend () : - CommandObject ("append", - "Allows the user to append a value to a single debugger setting variable, for settings that are of list types. Type 'settings' to see a list of debugger setting variables", - "append <var-name> <value-string>") -{ -} - -CommandObjectAppend::~CommandObjectAppend () -{ -} - -bool -CommandObjectAppend::Execute -( - CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result -) -{ - CommandInterpreter::VariableMap::iterator pos; - - const int argc = command.GetArgumentCount(); - if (argc < 2) - { - result.AppendError ("'append' requires at least two arguments"); - result.SetStatus (eReturnStatusFailed); - return false; - } - - const char *var_name = command.GetArgumentAtIndex(0); - command.Shift(); - - - if (var_name == NULL || var_name[0] == '\0') - { - result.AppendError ("'set' command requires a valid variable name. No value supplied"); - result.SetStatus (eReturnStatusFailed); - } - else - { - StateVariable *var = interpreter.GetStateVariable(var_name); - if (var == NULL) - { - result.AppendErrorWithFormat ("'%s' is not a settable internal variable.\n", var_name); - result.SetStatus (eReturnStatusFailed); - } - else - { - if (var->GetType() == StateVariable::eTypeString) - { - for (size_t i = 0; i < command.GetArgumentCount(); ++i) - var->AppendStringValue (command.GetArgumentAtIndex(i)); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else if (var->GetType() == StateVariable::eTypeStringArray) - { - var->GetArgs().AppendArguments (command); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - result.AppendErrorWithFormat ("Values cannot be appended to variable '%s'. Try 'set' instead.\n", var_name); - result.SetStatus (eReturnStatusFailed); - } - } - } - return result.Succeeded(); -} - diff --git a/lldb/source/Commands/CommandObjectAppend.h b/lldb/source/Commands/CommandObjectAppend.h deleted file mode 100644 index 6b2ab9d3888..00000000000 --- a/lldb/source/Commands/CommandObjectAppend.h +++ /dev/null @@ -1,42 +0,0 @@ -//===-- CommandObjectAppend.h -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_CommandObjectAppend_h_ -#define liblldb_CommandObjectAppend_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { -//----------------------------------------------------------------------------- -// CommandObjectAppend -//----------------------------------------------------------------------------- - -class CommandObjectAppend : public CommandObject -{ -public: - CommandObjectAppend (); - - virtual - ~CommandObjectAppend (); - - virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result); - - -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectAppend_h_ diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp index 4bf8a30edba..cf80cd484f1 100644 --- a/lldb/source/Commands/CommandObjectHelp.cpp +++ b/lldb/source/Commands/CommandObjectHelp.cpp @@ -94,7 +94,7 @@ CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, Comm Stream &output_strm = result.GetOutputStream(); if (sub_cmd_obj->GetOptions() != NULL) { - output_strm.Printf ("%s\n", sub_cmd_obj->GetHelp()); + 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); const char *long_help = sub_cmd_obj->GetHelpLong(); @@ -104,7 +104,7 @@ CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, Comm } else if (sub_cmd_obj->IsMultiwordObject()) { - output_strm.Printf ("%s\n", sub_cmd_obj->GetHelp()); + interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (interpreter, result); } else @@ -112,9 +112,9 @@ CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, Comm const char *long_help = sub_cmd_obj->GetHelpLong(); if ((long_help != NULL) && (strlen (long_help) > 0)) - output_strm.Printf ("%s", long_help); + interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelpLong(), 1); else - output_strm.Printf ("%s\n", sub_cmd_obj->GetHelp()); + interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); } } diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 73386b4fe17..3ca9e80a7e7 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -161,11 +161,44 @@ public: process = target->CreateProcess (interpreter.GetDebugger().GetListener(), plugin_name).get(); - const Args *environment = interpreter.GetEnvironmentVariables(); - const Args *run_args = interpreter.GetProgramArguments(); - uint32_t launch_flags = eLaunchFlagNone; - if (interpreter.GetDisableASLR()) - launch_flags |= eLaunchFlagDisableASLR; + const char *process_name = process->GetInstanceName().AsCString(); + StreamString run_args_var_name; + StreamString env_vars_var_name; + StreamString disable_aslr_var_name; + lldb::SettableVariableType var_type; + + Args *run_args = NULL; + run_args_var_name.Printf ("process.[%s].run-args", process_name); + StringList run_args_value = Debugger::GetSettingsController()->GetVariable (run_args_var_name.GetData(), + var_type); + if (run_args_value.GetSize() > 0) + { + run_args = new Args; + for (int i = 0; i < run_args_value.GetSize(); ++i) + run_args->AppendArgument (run_args_value.GetStringAtIndex (i)); + } + + Args *environment = NULL; + env_vars_var_name.Printf ("process.[%s].env-vars", process_name); + StringList env_vars_value = Debugger::GetSettingsController()->GetVariable (env_vars_var_name.GetData(), + var_type); + if (env_vars_value.GetSize() > 0) + { + environment = new Args; + for (int i = 0; i < env_vars_value.GetSize(); ++i) + environment->AppendArgument (env_vars_value.GetStringAtIndex (i)); + } + + uint32_t launch_flags = eLaunchFlagNone; + disable_aslr_var_name.Printf ("process.[%s].disable-aslr", process_name); + StringList disable_aslr_value = Debugger::GetSettingsController()->GetVariable(disable_aslr_var_name.GetData(), + var_type); + if (disable_aslr_value.GetSize() > 0) + { + if (strcmp (disable_aslr_value.GetStringAtIndex(0), "true") == 0) + launch_flags |= eLaunchFlagDisableASLR; + + } // There are two possible sources of args to be passed to the process upon launching: Those the user // typed at the run command (launch_args); or those the user pre-set in the run-args variable (run_args). @@ -179,12 +212,9 @@ public: else { // launch-args was not empty; use that, AND re-set run-args to contains launch-args values. - StateVariable *run_args_var = interpreter.GetStateVariable ("run-args"); - if (run_args_var != NULL) - { - run_args_var->ArrayClearValues(); - run_args_var->GetArgs().AppendArguments (launch_args); - } + std::string new_run_args; + launch_args.GetCommandString (new_run_args); + Debugger::GetSettingsController()->SetVariable (run_args_var_name.GetData(), new_run_args.c_str(), lldb::eVarSetOperationAssign, false); } diff --git a/lldb/source/Commands/CommandObjectSet.cpp b/lldb/source/Commands/CommandObjectSet.cpp deleted file mode 100644 index 89f154a083e..00000000000 --- a/lldb/source/Commands/CommandObjectSet.cpp +++ /dev/null @@ -1,152 +0,0 @@ -//===-- CommandObjectSet.cpp ------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectSet.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -using namespace lldb; -using namespace lldb_private; - -//------------------------------------------------------------------------- -// CommandObjectSet -//------------------------------------------------------------------------- - -CommandObjectSet::CommandObjectSet () : - CommandObject ("set", - "Allows the user to set or change the value of a single debugger setting variable.", - "set <setting_name> <value>") -{ -} - -CommandObjectSet::~CommandObjectSet() -{ -} - - -bool -CommandObjectSet::Execute -( - CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result -) -{ - CommandInterpreter::VariableMap::iterator pos; - - const int argc = command.GetArgumentCount(); - - if (argc < 1) - { - result.AppendError ("'set' takes at least two arguments"); - result.SetStatus (eReturnStatusFailed); - return false; - } - - const char *var_name = command.GetArgumentAtIndex(0); - const char *var_value = command.GetArgumentAtIndex(1); - - if (var_name == NULL || var_name[0] == '\0') - { - result.AppendError ("'set' command requires a valid variable name; No value supplied"); - result.SetStatus (eReturnStatusFailed); - } - else if (var_value == NULL || var_value[0] == '\0') - { - // No value given: Check to see if we're trying to clear an array. - StateVariable *var = interpreter.GetStateVariable (var_name); - if (var != NULL - && var->GetType() == StateVariable::eTypeStringArray) - { - var->ArrayClearValues(); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - result.AppendError ("'set' command requires a valid variable value; No value supplied"); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - StateVariable *var = interpreter.GetStateVariable(var_name); - if (var == NULL) - { - result.AppendErrorWithFormat ("'%s' is not a settable internal variable.\n", var_name); - result.SetStatus (eReturnStatusFailed); - } - else - { - result.SetStatus (eReturnStatusSuccessFinishNoResult); - if (var->GetType() == StateVariable::eTypeBoolean) - { - bool success = false; - bool new_value = Args::StringToBoolean (var_value, false, &success); - - if (success) - { - result.SetStatus(eReturnStatusSuccessFinishResult); - if (!var->HasVerifyFunction() || var->VerifyValue (&interpreter, (void *) &new_value, result)) - var->SetBoolValue (new_value); - } - else - { - result.AppendErrorWithFormat ("Invalid boolean string '%s'.\n", var_value); - result.SetStatus (eReturnStatusFailed); - } - } - else if (var->GetType() == StateVariable::eTypeInteger) - { - bool success = false; - int new_value = Args::StringToSInt32(var_value, -1, 0, &success); - - if (success) - { - result.SetStatus(eReturnStatusSuccessFinishResult); - if (!var->HasVerifyFunction() || var->VerifyValue (&interpreter, (void *) &new_value, result)) - var->SetIntValue (new_value); - } - else - { - result.AppendErrorWithFormat ("Invalid boolean string '%s'.\n", var_value); - result.SetStatus (eReturnStatusFailed); - } - } - else if (var->GetType() == StateVariable::eTypeString) - { - if (!var->HasVerifyFunction() || var->VerifyValue (&interpreter, (void *) var_value, result)) - var->SetStringValue (var_value); - } - else if (var->GetType() == StateVariable::eTypeStringArray) - { - if (var_value == NULL || var_value[0] == '\0') - var->ArrayClearValues (); - else - { - command.Shift(); // shift off variable name - var->ArrayClearValues(); // clear the old values - var->GetArgs().AppendArguments (command); // set the new values. - } - } - else - { - result.AppendErrorWithFormat ("Variable '%s' has unrecognized type.\n", - var->GetName()); - result.SetStatus (eReturnStatusFailed); - } - } - } - return result.Succeeded(); -} - diff --git a/lldb/source/Commands/CommandObjectSet.h b/lldb/source/Commands/CommandObjectSet.h deleted file mode 100644 index 8e4d81f8d42..00000000000 --- a/lldb/source/Commands/CommandObjectSet.h +++ /dev/null @@ -1,43 +0,0 @@ -//===-- CommandObjectSet.h --------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_CommandObjectSet_h_ -#define liblldb_CommandObjectSet_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { - -//------------------------------------------------------------------------- -// CommandObjectSet -//------------------------------------------------------------------------- - -class CommandObjectSet : public CommandObject -{ -public: - - CommandObjectSet (); - - virtual - ~CommandObjectSet (); - - virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result); - -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectSet_h_ diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index 3b75c870a34..a4a3643d7bf 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -15,47 +15,998 @@ // Project includes #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Interpreter/CommandCompletions.h" using namespace lldb; using namespace lldb_private; //------------------------------------------------------------------------- -// CommandObjectSettings +// CommandObjectMultiwordSettings //------------------------------------------------------------------------- -CommandObjectSettings::CommandObjectSettings () : - CommandObject ("settings", - "Lists the debugger settings variables available to the user to 'set' or 'show'.", - "settings") +CommandObjectMultiwordSettings::CommandObjectMultiwordSettings (CommandInterpreter &interpreter) : + CommandObjectMultiword ("settings", + "A set of commands for manipulating internal settable debugger variables.", + "settings <command> [<command-options>]") { + bool status; + + CommandObjectSP set_command_object (new CommandObjectSettingsSet ()); + CommandObjectSP show_command_object (new CommandObjectSettingsShow ()); + CommandObjectSP list_command_object (new CommandObjectSettingsList ()); + CommandObjectSP remove_command_object (new CommandObjectSettingsRemove ()); + CommandObjectSP replace_command_object (new CommandObjectSettingsReplace ()); + CommandObjectSP insert_before_command_object (new CommandObjectSettingsInsertBefore ()); + CommandObjectSP insert_after_command_object (new CommandObjectSettingsInsertAfter()); + CommandObjectSP append_command_object (new CommandObjectSettingsAppend()); + CommandObjectSP clear_command_object (new CommandObjectSettingsClear()); + + status = LoadSubCommand (interpreter, "set", set_command_object); + status = LoadSubCommand (interpreter, "show", show_command_object); + status = LoadSubCommand (interpreter, "list", list_command_object); + status = LoadSubCommand (interpreter, "remove", remove_command_object); + status = LoadSubCommand (interpreter, "replace", replace_command_object); + status = LoadSubCommand (interpreter, "insert-before", insert_before_command_object); + status = LoadSubCommand (interpreter, "insert-after", insert_after_command_object); + status = LoadSubCommand (interpreter, "append", append_command_object); + status = LoadSubCommand (interpreter, "clear", clear_command_object); +} + +CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings () +{ +} + +//------------------------------------------------------------------------- +// CommandObjectSettingsSet +//------------------------------------------------------------------------- + +CommandObjectSettingsSet::CommandObjectSettingsSet () : + CommandObject ("settings set", + "Allows the user to set or change the value of a single debugger setting variable.", + "settings set [<cmd-options>] <setting-variable-name> <value>"), + m_options () +{ +} + +CommandObjectSettingsSet::~CommandObjectSettingsSet() +{ +} + + +bool +CommandObjectSettingsSet::Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result) +{ + UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); + + const int argc = command.GetArgumentCount (); + + if (argc < 2) + { + result.AppendError ("'settings set' takes more arguments"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + const char *var_name = command.GetArgumentAtIndex (0); + std::string var_name_string; + if ((var_name == NULL) || (var_name[0] == '\0')) + { + result.AppendError ("'settings set' command requires a valid variable name; No value supplied"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + var_name_string = var_name; + command.Shift(); + + const char *var_value; + std::string value_string; + + command.GetCommandString (value_string); + var_value = value_string.c_str(); + + if (!m_options.m_reset + && var_value == NULL) + { + result.AppendError ("'settings set' command requires a valid variable value unless using '--reset' option;" + " No value supplied"); + result.SetStatus (eReturnStatusFailed); + } + else + { + Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationAssign, + m_options.m_override); + if (err.Fail ()) + { + result.AppendError (err.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + else + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + + return result.Succeeded(); +} + +int +CommandObjectSettingsSet::HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) +{ + std::string completion_str (input.GetArgumentAtIndex (cursor_index)); + completion_str.erase (cursor_char_position); + + // Attempting to complete variable name + if (cursor_index == 1) + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + + // Attempting to complete value + if ((cursor_index == 2) // Partly into the variable's value + || (cursor_index == 1 // Or at the end of a completed valid variable name + && matches.GetSize() == 1 + && completion_str.compare (matches.GetStringAtIndex(0)) == 0)) + { + matches.Clear(); + lldb::UserSettingsControllerSP root_settings = Debugger::GetSettingsController(); + if (cursor_index == 1) + { + // The user is at the end of the variable name, which is complete and valid. + UserSettingsController::CompleteSettingsValue (root_settings, + input.GetArgumentAtIndex (1), // variable name + NULL, // empty value string + word_complete, + matches); + } + else + { + // The user is partly into the variable value. + UserSettingsController::CompleteSettingsValue (root_settings, + input.GetArgumentAtIndex (1), // variable name + completion_str.c_str(), // partial value string + word_complete, + matches); + } + } + + return matches.GetSize(); +} + +//------------------------------------------------------------------------- +// CommandObjectSettingsSet::CommandOptions +//------------------------------------------------------------------------- + +CommandObjectSettingsSet::CommandOptions::CommandOptions () : + Options (), + m_override (false), + m_reset (false) +{ +} + +CommandObjectSettingsSet::CommandOptions::~CommandOptions () +{ +} + +lldb::OptionDefinition +CommandObjectSettingsSet::CommandOptions::g_option_table[] = +{ + { LLDB_OPT_SET_1, false, "override", 'o', no_argument, NULL, NULL, NULL, "Causes already existing instances and pending settings to use this new value. This option only makes sense when setting default values." }, + + { LLDB_OPT_SET_2, false, "reset", 'r', no_argument, NULL, NULL, NULL, "Causes value to be reset to the original default for this variable. No value needs to be specified when this option is used." }, +}; + +const lldb::OptionDefinition* +CommandObjectSettingsSet::CommandOptions::GetDefinitions () +{ + return g_option_table; +} + +Error +CommandObjectSettingsSet::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) +{ + Error error; + char short_option = (char) m_getopt_table[option_idx].val; + + switch (short_option) + { + case 'o': + m_override = true; + break; + case 'r': + m_reset = true; + break; + default: + error.SetErrorStringWithFormat ("Unrecognized options '%c'.\n", short_option); + break; + } + + return error; +} + +void +CommandObjectSettingsSet::CommandOptions::ResetOptionValues () +{ + Options::ResetOptionValues (); + + m_override = false; + m_reset = false; +} + +Options * +CommandObjectSettingsSet::GetOptions () +{ + return &m_options; +} + + +//------------------------------------------------------------------------- +// CommandObjectSettingsShow -- Show current values +//------------------------------------------------------------------------- + +CommandObjectSettingsShow::CommandObjectSettingsShow () : + CommandObject ("settings show", + "Allows the user to see a single internal debugger setting variable and its value, or lists them all.", + "settings show [<setting-variable-name>]") +{ +} + +CommandObjectSettingsShow::~CommandObjectSettingsShow() +{ +} + + +bool +CommandObjectSettingsShow::Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result) +{ + UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); + std::string current_prefix = root_settings->GetLevelName().AsCString(); + + Error err; + + if (command.GetArgumentCount()) + { + // The user requested to see the value of a particular variable. + lldb::SettableVariableType var_type; + const char *variable_name = command.GetArgumentAtIndex (0); + StringList value = root_settings->GetVariable (variable_name, var_type); + + if (value.GetSize() == 0) + { + result.AppendErrorWithFormat ("Unable to find variable named '%s'. " + "Try 'show' to see all variable values.\n", variable_name); + result.SetStatus (eReturnStatusFailed); + + } + else + { + char *type_name = (char *) ""; + if (var_type != eSetVarTypeNone) + { + StreamString tmp_str; + tmp_str.Printf (" (%s)", UserSettingsController::GetTypeString (var_type)); + type_name = (char *) tmp_str.GetData(); + } + + if (value.GetSize() == 1) + result.AppendMessageWithFormat ("%s%s = '%s'\n", variable_name, type_name, value.GetStringAtIndex (0)); + else + { + result.AppendMessageWithFormat ("%s%s:\n", variable_name, type_name); + for (int i = 0; i < value.GetSize(); ++i) + { + result.AppendMessageWithFormat (" [%d]: '%s'\n", i, value.GetStringAtIndex (i)); + } + } + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + } + else + { + UserSettingsController::GetAllVariableValues (interpreter, root_settings, current_prefix, + result.GetOutputStream(), err); + if (err.Fail ()) + { + result.AppendError (err.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + else + { + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + } + + return result.Succeeded(); } -CommandObjectSettings::~CommandObjectSettings() +int +CommandObjectSettingsShow::HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) +{ + std::string completion_str (input.GetArgumentAtIndex (cursor_index)); + completion_str.erase (cursor_char_position); + + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + return matches.GetSize(); +} + +//------------------------------------------------------------------------- +// CommandObjectSettingsList +//------------------------------------------------------------------------- + +CommandObjectSettingsList::CommandObjectSettingsList () : + CommandObject ("settings list", + "Lists the internal debugger settings variables available to the user to 'set' or 'show'.", + "settings list") +{ +} + +CommandObjectSettingsList::~CommandObjectSettingsList() { } bool -CommandObjectSettings::Execute -( - CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result -) +CommandObjectSettingsList::Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result) { - CommandInterpreter::VariableMap::iterator pos; + UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); + std::string current_prefix = root_settings->GetLevelName().AsCString(); + + Error err; + + UserSettingsController::FindAllSettingsDescriptions (interpreter, root_settings, current_prefix, + result.GetOutputStream(), err); - if (command.GetArgumentCount() != 0) + if (err.Fail ()) { - result.AppendError ("'settings' does not take any arguments"); + result.AppendError (err.AsCString()); result.SetStatus (eReturnStatusFailed); } else { - interpreter.ShowVariableHelp (result); result.SetStatus (eReturnStatusSuccessFinishNoResult); } return result.Succeeded(); } +//------------------------------------------------------------------------- +// CommandObjectSettingsRemove +//------------------------------------------------------------------------- + +CommandObjectSettingsRemove::CommandObjectSettingsRemove () : + CommandObject ("settings remove", + "Removes the specified element from an internal debugger settings array or dictionary variable.", + "settings remove <setting-variable-name> [<index>|\"key\"]") +{ +} + +CommandObjectSettingsRemove::~CommandObjectSettingsRemove () +{ +} + +bool +CommandObjectSettingsRemove::Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result) +{ + UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); + + const int argc = command.GetArgumentCount (); + + if (argc != 2) + { + result.AppendError ("'settings remove' takes two arguments"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + const char *var_name = command.GetArgumentAtIndex (0); + std::string var_name_string; + if ((var_name == NULL) || (var_name[0] == '\0')) + { + result.AppendError ("'settings remove' command requires a valid variable name; No value supplied"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + var_name_string = var_name; + command.Shift(); + + const char *index_value = command.GetArgumentAtIndex (0); + std::string index_value_string; + if ((index_value == NULL) || (index_value[0] == '\0')) + { + result.AppendError ("'settings remove' command requires an index or key value; no value supplied"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + index_value_string = index_value; + + Error err = root_settings->SetVariable (var_name_string.c_str(), NULL, lldb::eVarSetOperationRemove, + false, index_value_string.c_str()); + if (err.Fail ()) + { + result.AppendError (err.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + else + result.SetStatus (eReturnStatusSuccessFinishNoResult); + + return result.Succeeded(); +} + +int +CommandObjectSettingsRemove::HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) +{ + std::string completion_str (input.GetArgumentAtIndex (cursor_index)); + completion_str.erase (cursor_char_position); + + // Attempting to complete variable name + if (cursor_index < 2) + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + + return matches.GetSize(); +} + +//------------------------------------------------------------------------- +// CommandObjectSettingsReplace +//------------------------------------------------------------------------- + +CommandObjectSettingsReplace::CommandObjectSettingsReplace () : + CommandObject ("settings replace", + "Replaces the specified element from an internal debugger settings array or dictionary variable.", + "settings replace <setting-variable-name> [<index>|\"<key>\"] <new-value>") +{ +} + +CommandObjectSettingsReplace::~CommandObjectSettingsReplace () +{ +} + +bool +CommandObjectSettingsReplace::Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result) +{ + UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); + + const int argc = command.GetArgumentCount (); + + if (argc < 3) + { + result.AppendError ("'settings replace' takes more arguments"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + const char *var_name = command.GetArgumentAtIndex (0); + std::string var_name_string; + if ((var_name == NULL) || (var_name[0] == '\0')) + { + result.AppendError ("'settings replace' command requires a valid variable name; No value supplied"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + var_name_string = var_name; + command.Shift(); + + const char *index_value = command.GetArgumentAtIndex (0); + std::string index_value_string; + if ((index_value == NULL) || (index_value[0] == '\0')) + { + result.AppendError ("'settings insert-before' command requires an index value; no value supplied"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + index_value_string = index_value; + command.Shift(); + + const char *var_value; + std::string value_string; + + command.GetCommandString (value_string); + var_value = value_string.c_str(); + + if ((var_value == NULL) || (var_value[0] == '\0')) + { + result.AppendError ("'settings replace' command requires a valid variable value; no value supplied"); + result.SetStatus (eReturnStatusFailed); + } + else + { + Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationReplace, + false, index_value_string.c_str()); + if (err.Fail ()) + { + result.AppendError (err.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + else + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + + return result.Succeeded(); +} + +int +CommandObjectSettingsReplace::HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) +{ + std::string completion_str (input.GetArgumentAtIndex (cursor_index)); + completion_str.erase (cursor_char_position); + + // Attempting to complete variable name + if (cursor_index < 2) + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + + return matches.GetSize(); +} + +//------------------------------------------------------------------------- +// CommandObjectSettingsInsertBefore +//------------------------------------------------------------------------- + +CommandObjectSettingsInsertBefore::CommandObjectSettingsInsertBefore () : + CommandObject ("settings insert-before", + "Inserts value(s) into an internal debugger settings array variable, immediately before the specified element.", + "settings insert-before <setting-variable-name> [<index>] <new-value>") +{ +} + +CommandObjectSettingsInsertBefore::~CommandObjectSettingsInsertBefore () +{ +} + +bool +CommandObjectSettingsInsertBefore::Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result) +{ + UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); + + const int argc = command.GetArgumentCount (); + + if (argc < 3) + { + result.AppendError ("'settings insert-before' takes more arguments"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + const char *var_name = command.GetArgumentAtIndex (0); + std::string var_name_string; + if ((var_name == NULL) || (var_name[0] == '\0')) + { + result.AppendError ("'settings insert-before' command requires a valid variable name; No value supplied"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + var_name_string = var_name; + command.Shift(); + + const char *index_value = command.GetArgumentAtIndex (0); + std::string index_value_string; + if ((index_value == NULL) || (index_value[0] == '\0')) + { + result.AppendError ("'settings insert-before' command requires an index value; no value supplied"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + index_value_string = index_value; + command.Shift(); + + const char *var_value; + std::string value_string; + + command.GetCommandString (value_string); + var_value = value_string.c_str(); + + if ((var_value == NULL) || (var_value[0] == '\0')) + { + result.AppendError ("'settings insert-before' command requires a valid variable value;" + " No value supplied"); + result.SetStatus (eReturnStatusFailed); + } + else + { + Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationInsertBefore, + false, index_value_string.c_str()); + if (err.Fail ()) + { + result.AppendError (err.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + else + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + + return result.Succeeded(); +} + + +int +CommandObjectSettingsInsertBefore::HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) +{ + std::string completion_str (input.GetArgumentAtIndex (cursor_index)); + completion_str.erase (cursor_char_position); + + // Attempting to complete variable name + if (cursor_index < 2) + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + + return matches.GetSize(); +} + +//------------------------------------------------------------------------- +// CommandObjectSettingInsertAfter +//------------------------------------------------------------------------- + +CommandObjectSettingsInsertAfter::CommandObjectSettingsInsertAfter () : + CommandObject ("settings insert-after", + "Inserts value(s) into an internal debugger settings array variable, immediately after the specified element.", + "settings insert-after <setting-variable-name> [<index>] <new-value>") +{ +} + +CommandObjectSettingsInsertAfter::~CommandObjectSettingsInsertAfter () +{ +} + +bool +CommandObjectSettingsInsertAfter::Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result) +{ + UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); + + const int argc = command.GetArgumentCount (); + + if (argc < 3) + { + result.AppendError ("'settings insert-after' takes more arguments"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + const char *var_name = command.GetArgumentAtIndex (0); + std::string var_name_string; + if ((var_name == NULL) || (var_name[0] == '\0')) + { + result.AppendError ("'settings insert-after' command requires a valid variable name; No value supplied"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + var_name_string = var_name; + command.Shift(); + + const char *index_value = command.GetArgumentAtIndex (0); + std::string index_value_string; + if ((index_value == NULL) || (index_value[0] == '\0')) + { + result.AppendError ("'settings insert-after' command requires an index value; no value supplied"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + index_value_string = index_value; + command.Shift(); + + const char *var_value; + std::string value_string; + + command.GetCommandString (value_string); + var_value = value_string.c_str(); + + if ((var_value == NULL) || (var_value[0] == '\0')) + { + result.AppendError ("'settings insert-after' command requires a valid variable value;" + " No value supplied"); + result.SetStatus (eReturnStatusFailed); + } + else + { + Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationInsertAfter, + false, index_value_string.c_str()); + if (err.Fail ()) + { + result.AppendError (err.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + else + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + + return result.Succeeded(); +} + + +int +CommandObjectSettingsInsertAfter::HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) +{ + std::string completion_str (input.GetArgumentAtIndex (cursor_index)); + completion_str.erase (cursor_char_position); + + // Attempting to complete variable name + if (cursor_index < 2) + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + + return matches.GetSize(); +} + +//------------------------------------------------------------------------- +// CommandObjectSettingsAppend +//------------------------------------------------------------------------- + +CommandObjectSettingsAppend::CommandObjectSettingsAppend () : + CommandObject ("settings append", + "Appends new value to the end of an internal debugger settings array, dictionary or string variable.", + "settings append <setting-variable-name> <new-value>") +{ +} + +CommandObjectSettingsAppend::~CommandObjectSettingsAppend () +{ +} + +bool +CommandObjectSettingsAppend::Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result) +{ + UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); + + const int argc = command.GetArgumentCount (); + + if (argc < 2) + { + result.AppendError ("'settings append' takes more arguments"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + const char *var_name = command.GetArgumentAtIndex (0); + std::string var_name_string; + if ((var_name == NULL) || (var_name[0] == '\0')) + { + result.AppendError ("'settings append' command requires a valid variable name; No value supplied"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + var_name_string = var_name; + command.Shift(); + + const char *var_value; + std::string value_string; + + command.GetCommandString (value_string); + var_value = value_string.c_str(); + + if ((var_value == NULL) || (var_value[0] == '\0')) + { + result.AppendError ("'settings append' command requires a valid variable value;" + " No value supplied"); + result.SetStatus (eReturnStatusFailed); + } + else + { + Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationAppend, + false); + if (err.Fail ()) + { + result.AppendError (err.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + else + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + + return result.Succeeded(); +} + + +int +CommandObjectSettingsAppend::HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) +{ + std::string completion_str (input.GetArgumentAtIndex (cursor_index)); + completion_str.erase (cursor_char_position); + + // Attempting to complete variable name + if (cursor_index < 2) + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + + return matches.GetSize(); +} + +//------------------------------------------------------------------------- +// CommandObjectSettingsClear +//------------------------------------------------------------------------- + +CommandObjectSettingsClear::CommandObjectSettingsClear () : + CommandObject ("settings clear", + "Erases all the contents of an internal debugger settings variables; only valid for variables with clearable types, i.e. strings, arrays or dictionaries.", + "settings clear") +{ +} + +CommandObjectSettingsClear::~CommandObjectSettingsClear () +{ +} + +bool +CommandObjectSettingsClear::Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result) +{ + UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); + + const int argc = command.GetArgumentCount (); + + if (argc != 1) + { + result.AppendError ("'setttings clear' takes exactly one argument"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + const char *var_name = command.GetArgumentAtIndex (0); + if ((var_name == NULL) || (var_name[0] == '\0')) + { + result.AppendError ("'settings clear' command requires a valid variable name; No value supplied"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + Error err = root_settings->SetVariable (var_name, NULL, lldb::eVarSetOperationClear, false); + + if (err.Fail ()) + { + result.AppendError (err.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + else + result.SetStatus (eReturnStatusSuccessFinishNoResult); + + return result.Succeeded(); +} + + +int +CommandObjectSettingsClear::HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) +{ + std::string completion_str (input.GetArgumentAtIndex (cursor_index)); + completion_str.erase (cursor_char_position); + + // Attempting to complete variable name + if (cursor_index < 2) + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + + return matches.GetSize(); +} diff --git a/lldb/source/Commands/CommandObjectSettings.h b/lldb/source/Commands/CommandObjectSettings.h index 4159b8b03b6..0bfb3caff3c 100644 --- a/lldb/source/Commands/CommandObjectSettings.h +++ b/lldb/source/Commands/CommandObjectSettings.h @@ -15,27 +15,327 @@ // Other libraries and framework includes // Project includes #include "lldb/Interpreter/CommandObject.h" +#include "lldb/Interpreter/CommandObjectMultiword.h" +#include "lldb/Interpreter/Options.h" + namespace lldb_private { //------------------------------------------------------------------------- -// CommandObjectSettings +// CommandObjectMultiwordSettings +//------------------------------------------------------------------------- + +class CommandObjectMultiwordSettings : public CommandObjectMultiword +{ +public: + + CommandObjectMultiwordSettings (CommandInterpreter &interpreter); + + virtual + ~CommandObjectMultiwordSettings (); + +}; + +//------------------------------------------------------------------------- +// CommandObjectSettingsSet +//------------------------------------------------------------------------- + +class CommandObjectSettingsSet : public CommandObject +{ +public: + CommandObjectSettingsSet (); + + virtual + ~CommandObjectSettingsSet (); + + virtual bool + Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result); + + virtual Options * + GetOptions (); + + class CommandOptions : public Options + { + public: + + CommandOptions (); + + virtual + ~CommandOptions (); + + virtual Error + SetOptionValue (int option_idx, const char *option_arg); + + void + ResetOptionValues (); + + const lldb::OptionDefinition* + GetDefinitions (); + + // Options table: Required for subclasses of Options. + + static lldb::OptionDefinition g_option_table[]; + + // Instance variables to hold the values for command options. + + bool m_override; + bool m_reset; + + }; + + virtual int + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches); + +private: + CommandOptions m_options; +}; + +//------------------------------------------------------------------------- +// CommandObjectSettingsShow -- Show current values //------------------------------------------------------------------------- -class CommandObjectSettings : public CommandObject +class CommandObjectSettingsShow : public CommandObject { public: + CommandObjectSettingsShow (); + + virtual + ~CommandObjectSettingsShow (); + + virtual bool + Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result); + + + virtual int + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches); + +private: +}; + +//------------------------------------------------------------------------- +// CommandObjectSettingsList -- List settable variables +//------------------------------------------------------------------------- + +class CommandObjectSettingsList : public CommandObject +{ +public: + CommandObjectSettingsList (); + + virtual + ~CommandObjectSettingsList (); + + virtual bool + Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result); + +private: +}; - CommandObjectSettings (); +//------------------------------------------------------------------------- +// CommandObjectSettingsRemove +//------------------------------------------------------------------------- + +class CommandObjectSettingsRemove : public CommandObject +{ +public: + CommandObjectSettingsRemove (); virtual - ~CommandObjectSettings (); + ~CommandObjectSettingsRemove (); virtual bool Execute (CommandInterpreter &interpreter, Args& command, CommandReturnObject &result); + virtual int + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches); + +private: +}; + +//------------------------------------------------------------------------- +// CommandObjectSettingsReplace +//------------------------------------------------------------------------- + +class CommandObjectSettingsReplace : public CommandObject +{ +public: + CommandObjectSettingsReplace (); + + virtual + ~CommandObjectSettingsReplace (); + + virtual bool + Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result); + + virtual int + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches); + +private: +}; + +//------------------------------------------------------------------------- +// CommandObjectSettingsInsertBefore +//------------------------------------------------------------------------- + +class CommandObjectSettingsInsertBefore : public CommandObject +{ +public: + CommandObjectSettingsInsertBefore (); + + virtual + ~CommandObjectSettingsInsertBefore (); + + virtual bool + Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result); + + virtual int + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches); + +private: +}; + +//------------------------------------------------------------------------- +// CommandObjectSettingInsertAfter +//------------------------------------------------------------------------- + +class CommandObjectSettingsInsertAfter : public CommandObject +{ +public: + CommandObjectSettingsInsertAfter (); + + virtual + ~CommandObjectSettingsInsertAfter (); + + virtual bool + Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result); + + virtual int + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches); + +private: +}; + +//------------------------------------------------------------------------- +// CommandObjectSettingsAppend +//------------------------------------------------------------------------- + +class CommandObjectSettingsAppend : public CommandObject +{ +public: + CommandObjectSettingsAppend (); + + virtual + ~CommandObjectSettingsAppend (); + + virtual bool + Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result); + + virtual int + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches); + +private: +}; + +//------------------------------------------------------------------------- +// CommandObjectSettingsClear +//------------------------------------------------------------------------- + +class CommandObjectSettingsClear : public CommandObject +{ +public: + CommandObjectSettingsClear (); + + virtual + ~CommandObjectSettingsClear (); + + virtual bool + Execute (CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result); + + virtual int + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches); + +private: }; } // namespace lldb_private diff --git a/lldb/source/Commands/CommandObjectShow.cpp b/lldb/source/Commands/CommandObjectShow.cpp deleted file mode 100644 index 4acbf66d548..00000000000 --- a/lldb/source/Commands/CommandObjectShow.cpp +++ /dev/null @@ -1,73 +0,0 @@ -//===-- CommandObjectShow.cpp -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectShow.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -using namespace lldb; -using namespace lldb_private; - -//------------------------------------------------------------------------- -// CommandObjectShow -//------------------------------------------------------------------------- - -CommandObjectShow::CommandObjectShow () : - CommandObject ("show", - "Allows the user to see a single debugger setting variable and its value, or lists them all.", - "show [<setting-variable-name>]") -{ -} - -CommandObjectShow::~CommandObjectShow() -{ -} - - -bool -CommandObjectShow::Execute -( - CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result -) -{ - CommandInterpreter::VariableMap::iterator pos; - - if (command.GetArgumentCount()) - { - // The user requested to see the value of a particular variable. - - const char *var_name = command.GetArgumentAtIndex(0); - StateVariable *var = interpreter.GetStateVariable(var_name); - if (var) - { - var->AppendVariableInformation (result); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - result.AppendErrorWithFormat ("Unrecognized variable '%s'; cannot do 'show' command.\n", var_name); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - // The user didn't specify a particular variable, so show the values of all of them. - interpreter.ShowVariableValues(result); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - - return result.Succeeded(); -} diff --git a/lldb/source/Commands/CommandObjectShow.h b/lldb/source/Commands/CommandObjectShow.h deleted file mode 100644 index a51cd4d6516..00000000000 --- a/lldb/source/Commands/CommandObjectShow.h +++ /dev/null @@ -1,43 +0,0 @@ -//===-- CommandObjectShow.h -------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_CommandObjectShow_h_ -#define liblldb_CommandObjectShow_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { - -//------------------------------------------------------------------------- -// CommandObjectShow -//------------------------------------------------------------------------- - -class CommandObjectShow : public CommandObject -{ -public: - - CommandObjectShow (); - - virtual - ~CommandObjectShow (); - - virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result); - -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectShow_h_ |