Index: include/lldb/Interpreter/Args.h =================================================================== --- include/lldb/Interpreter/Args.h +++ include/lldb/Interpreter/Args.h @@ -394,7 +394,9 @@ static bool StringToBoolean (const char *s, bool fail_value, bool *success_ptr); - + + static char StringToChar(const char *s, char fail_value, bool *success_ptr); + static int64_t StringToOptionEnum (const char *s, OptionEnumValueElement *enum_values, int32_t fail_value, Error &error); Index: include/lldb/Interpreter/OptionValue.h =================================================================== --- include/lldb/Interpreter/OptionValue.h +++ include/lldb/Interpreter/OptionValue.h @@ -26,12 +26,14 @@ class OptionValue { public: - typedef enum { + typedef enum + { eTypeInvalid = 0, eTypeArch, eTypeArgs, eTypeArray, eTypeBoolean, + eTypeChar, eTypeDictionary, eTypeEnum, eTypeFileSpec, @@ -41,11 +43,11 @@ eTypeProperties, eTypeRegex, eTypeSInt64, - eTypeString, + eTypeString, eTypeUInt64, eTypeUUID } Type; - + enum { eDumpOptionName = (1u << 0), eDumpOptionType = (1u << 1), @@ -173,6 +175,7 @@ case 1u << eTypeArgs: return eTypeArgs; case 1u << eTypeArray: return eTypeArray; case 1u << eTypeBoolean: return eTypeBoolean; + case 1u << eTypeChar: return eTypeChar; case 1u << eTypeDictionary: return eTypeDictionary; case 1u << eTypeEnum: return eTypeEnum; case 1u << eTypeFileSpec: return eTypeFileSpec; @@ -221,10 +224,16 @@ OptionValueBoolean * GetAsBoolean (); - + + OptionValueChar * + GetAsChar (); + const OptionValueBoolean * GetAsBoolean () const; - + + const OptionValueChar * + GetAsChar () const; + OptionValueDictionary * GetAsDictionary (); @@ -302,7 +311,11 @@ bool SetBooleanValue (bool new_value); - + + char GetCharValue(char fail_value) const; + + char SetCharValue(char new_value); + int64_t GetEnumerationValue (int64_t fail_value = -1) const; Index: include/lldb/Interpreter/OptionValues.h =================================================================== --- include/lldb/Interpreter/OptionValues.h +++ include/lldb/Interpreter/OptionValues.h @@ -15,6 +15,7 @@ #include "lldb/Interpreter/OptionValueArgs.h" #include "lldb/Interpreter/OptionValueArray.h" #include "lldb/Interpreter/OptionValueBoolean.h" +#include "lldb/Interpreter/OptionValueChar.h" #include "lldb/Interpreter/OptionValueDictionary.h" #include "lldb/Interpreter/OptionValueEnumeration.h" #include "lldb/Interpreter/OptionValueFileSpec.h" Index: include/lldb/lldb-forward.h =================================================================== --- include/lldb/lldb-forward.h +++ include/lldb/lldb-forward.h @@ -140,6 +140,7 @@ class OptionValueArgs; class OptionValueArray; class OptionValueBoolean; +class OptionValueChar; class OptionValueDictionary; class OptionValueEnumeration; class OptionValueFileSpec; Index: source/Interpreter/Args.cpp =================================================================== --- source/Interpreter/Args.cpp +++ source/Interpreter/Args.cpp @@ -969,6 +969,26 @@ return fail_value; } +char +Args::StringToChar(const char *s, char fail_value, bool *success_ptr) +{ + bool success = false; + char result = fail_value; + + if (s) + { + size_t length = strlen(s); + if (length == 1) + { + success = true; + result = s[0]; + } + } + if (success_ptr) + *success_ptr = success; + return result; +} + const char * Args::StringToVersion (const char *s, uint32_t &major, uint32_t &minor, uint32_t &update) { Index: source/Interpreter/CMakeLists.txt =================================================================== --- source/Interpreter/CMakeLists.txt +++ source/Interpreter/CMakeLists.txt @@ -24,6 +24,7 @@ OptionValueArgs.cpp OptionValueArray.cpp OptionValueBoolean.cpp + OptionValueChar.cpp OptionValueDictionary.cpp OptionValueEnumeration.cpp OptionValueFileSpec.cpp Index: source/Interpreter/OptionValue.cpp =================================================================== --- source/Interpreter/OptionValue.cpp +++ source/Interpreter/OptionValue.cpp @@ -71,6 +71,21 @@ return nullptr; } +const OptionValueChar * +OptionValue::GetAsChar () const +{ + if (GetType () == OptionValue::eTypeChar) + return static_cast(this); + return nullptr; +} + +OptionValueChar * +OptionValue::GetAsChar () +{ + if (GetType () == OptionValue::eTypeChar) + return static_cast(this); + return nullptr; +} OptionValueFileSpec * OptionValue::GetAsFileSpec () @@ -342,6 +357,27 @@ return false; } +char +OptionValue::GetCharValue(char fail_value) const +{ + const OptionValueChar *option_value = GetAsChar(); + if (option_value) + return option_value->GetCurrentValue(); + return fail_value; +} + +char +OptionValue::SetCharValue(char new_value) +{ + OptionValueChar *option_value = GetAsChar(); + if (option_value) + { + option_value->SetCurrentValue(new_value); + return true; + } + return false; +} + int64_t OptionValue::GetEnumerationValue (int64_t fail_value) const { @@ -520,6 +556,8 @@ case eTypeArgs: return "arguments"; case eTypeArray: return "array"; case eTypeBoolean: return "boolean"; + case eTypeChar: + return "char"; case eTypeDictionary: return "dictionary"; case eTypeEnum: return "enum"; case eTypeFileSpec: return "file"; @@ -547,6 +585,7 @@ { case 1u << eTypeArch: value_sp.reset(new OptionValueArch()); break; case 1u << eTypeBoolean: value_sp.reset(new OptionValueBoolean(false)); break; + case 1u << eTypeChar: value_sp.reset(new OptionValueChar('\0')); break; case 1u << eTypeFileSpec: value_sp.reset(new OptionValueFileSpec()); break; case 1u << eTypeFormat: value_sp.reset(new OptionValueFormat(eFormatInvalid)); break; case 1u << eTypeSInt64: value_sp.reset(new OptionValueSInt64()); break; Index: source/Interpreter/OptionValueArray.cpp =================================================================== --- source/Interpreter/OptionValueArray.cpp +++ source/Interpreter/OptionValueArray.cpp @@ -53,6 +53,7 @@ break; case eTypeBoolean: + case eTypeChar: case eTypeEnum: case eTypeFileSpec: case eTypeFormat: Index: source/Interpreter/OptionValueDictionary.cpp =================================================================== --- source/Interpreter/OptionValueDictionary.cpp +++ source/Interpreter/OptionValueDictionary.cpp @@ -64,6 +64,7 @@ break; case eTypeBoolean: + case eTypeChar: case eTypeEnum: case eTypeFileSpec: case eTypeFormat: Index: source/Interpreter/Property.cpp =================================================================== --- source/Interpreter/Property.cpp +++ source/Interpreter/Property.cpp @@ -60,7 +60,11 @@ else m_value_sp.reset (new OptionValueBoolean(definition.default_uint_value != 0)); break; - + + case OptionValue::eTypeChar: + m_value_sp.reset(new OptionValueChar(Args::StringToChar(definition.default_cstr_value, '\0', nullptr))); + break; + case OptionValue::eTypeDictionary: // "definition.default_uint_value" is always a OptionValue::Type m_value_sp.reset (new OptionValueDictionary(OptionValue::ConvertTypeToMask((OptionValue::Type)definition.default_uint_value)));