diff options
author | Caroline Tice <ctice@apple.com> | 2010-09-04 00:03:46 +0000 |
---|---|---|
committer | Caroline Tice <ctice@apple.com> | 2010-09-04 00:03:46 +0000 |
commit | 3df9a8dfd7714dd6d03d5e1a93dbbfee736946bc (patch) | |
tree | 5855b97cff85c66d8e0236d43ed974c031a5bf3b /lldb/source/Commands/CommandObjectSet.cpp | |
parent | 070ebd93d2765e5f88e9739edb673a1fee5cbe9c (diff) | |
download | bcm5719-llvm-3df9a8dfd7714dd6d03d5e1a93dbbfee736946bc.tar.gz bcm5719-llvm-3df9a8dfd7714dd6d03d5e1a93dbbfee736946bc.zip |
This is a very large commit that completely re-does the way lldb
handles user settable internal variables (the equivalent of set/show
variables in gdb). In addition to the basic infrastructure (most of
which is defined in UserSettingsController.{h,cpp}, there are examples
of two classes that have been set up to contain user settable
variables (the Debugger and Process classes). The 'settings' command
has been modified to be a command-subcommand structure, and the 'set',
'show' and 'append' commands have been moved into this sub-commabnd
structure. The old StateVariable class has been completely replaced
by this, and the state variable dictionary has been removed from the
Command Interpreter. Places that formerly accessed the state variable
mechanism have been modified to access the variables in this new
structure instead (checking the term-width; getting/checking the
prompt; etc.)
Variables are attached to classes; there are two basic "flavors" of
variables that can be set: "global" variables (static/class-wide), and
"instance" variables (one per instance of the class). The whole thing
has been set up so that any global or instance variable can be set at
any time (e.g. on start up, in your .lldbinit file), whether or not
any instances actually exist (there's a whole pending and default
values mechanism to help deal with that).
llvm-svn: 113041
Diffstat (limited to 'lldb/source/Commands/CommandObjectSet.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectSet.cpp | 152 |
1 files changed, 0 insertions, 152 deletions
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(); -} - |