diff options
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/include/lldb/Interpreter/OptionValue.h | 14 | ||||
-rw-r--r-- | lldb/include/lldb/Interpreter/OptionValueLanguage.h | 107 | ||||
-rw-r--r-- | lldb/include/lldb/Interpreter/OptionValues.h | 1 | ||||
-rw-r--r-- | lldb/include/lldb/lldb-forward.h | 1 | ||||
-rw-r--r-- | lldb/lldb.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionValue.cpp | 39 | ||||
-rw-r--r-- | lldb/source/Interpreter/OptionValueLanguage.cpp | 73 | ||||
-rw-r--r-- | lldb/source/Interpreter/Property.cpp | 15 |
8 files changed, 256 insertions, 0 deletions
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h index 8ca7b94c320..fd751f744de 100644 --- a/lldb/include/lldb/Interpreter/OptionValue.h +++ b/lldb/include/lldb/Interpreter/OptionValue.h @@ -40,6 +40,7 @@ namespace lldb_private { eTypeFileSpec, eTypeFileSpecList, eTypeFormat, + eTypeLanguage, eTypePathMap, eTypeProperties, eTypeRegex, @@ -187,6 +188,7 @@ namespace lldb_private { case 1u << eTypeFileSpec: return eTypeFileSpec; case 1u << eTypeFileSpecList: return eTypeFileSpecList; case 1u << eTypeFormat: return eTypeFormat; + case 1u << eTypeLanguage: return eTypeLanguage; case 1u << eTypePathMap: return eTypePathMap; case 1u << eTypeProperties: return eTypeProperties; case 1u << eTypeRegex: return eTypeRegex; @@ -270,6 +272,12 @@ namespace lldb_private { const OptionValueFormat * GetAsFormat () const; + OptionValueLanguage * + GetAsLanguage (); + + const OptionValueLanguage * + GetAsLanguage () const; + OptionValuePathMappings * GetAsPathMappings (); @@ -348,6 +356,12 @@ namespace lldb_private { bool SetFormatValue (lldb::Format new_value); + + lldb::LanguageType + GetLanguageValue (lldb::LanguageType fail_value = lldb::eLanguageTypeUnknown) const; + + bool + SetLanguageValue (lldb::LanguageType new_language); const FormatEntity::Entry * GetFormatEntity () const; diff --git a/lldb/include/lldb/Interpreter/OptionValueLanguage.h b/lldb/include/lldb/Interpreter/OptionValueLanguage.h new file mode 100644 index 00000000000..fba5e22821e --- /dev/null +++ b/lldb/include/lldb/Interpreter/OptionValueLanguage.h @@ -0,0 +1,107 @@ +//===-- OptionValueLanguage.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_OptionValueLanguage_h_ +#define liblldb_OptionValueLanguage_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-enumerations.h" +#include "lldb/Interpreter/OptionValue.h" + +namespace lldb_private { + +class OptionValueLanguage : public OptionValue +{ +public: + OptionValueLanguage (lldb::LanguageType value) : + OptionValue(), + m_current_value (value), + m_default_value (value) + { + } + + OptionValueLanguage (lldb::LanguageType current_value, + lldb::LanguageType default_value) : + OptionValue(), + m_current_value (current_value), + m_default_value (default_value) + { + } + + virtual + ~OptionValueLanguage () + { + } + + //--------------------------------------------------------------------- + // Virtual subclass pure virtual overrides + //--------------------------------------------------------------------- + + OptionValue::Type + GetType () const override + { + return eTypeLanguage; + } + + void + DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override; + + Error + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign) override; + + bool + Clear () override + { + m_current_value = m_default_value; + m_value_was_set = false; + return true; + } + + lldb::OptionValueSP + DeepCopy () const override; + + //--------------------------------------------------------------------- + // Subclass specific functions + //--------------------------------------------------------------------- + + lldb::LanguageType + GetCurrentValue() const + { + return m_current_value; + } + + lldb::LanguageType + GetDefaultValue() const + { + return m_default_value; + } + + void + SetCurrentValue (lldb::LanguageType value) + { + m_current_value = value; + } + + void + SetDefaultValue (lldb::LanguageType value) + { + m_default_value = value; + } + +protected: + lldb::LanguageType m_current_value; + lldb::LanguageType m_default_value; +}; + +} // namespace lldb_private + +#endif // liblldb_OptionValueLanguage_h_ diff --git a/lldb/include/lldb/Interpreter/OptionValues.h b/lldb/include/lldb/Interpreter/OptionValues.h index 2ccab994674..44e1f097582 100644 --- a/lldb/include/lldb/Interpreter/OptionValues.h +++ b/lldb/include/lldb/Interpreter/OptionValues.h @@ -21,6 +21,7 @@ #include "lldb/Interpreter/OptionValueFileSpec.h" #include "lldb/Interpreter/OptionValueFileSpecList.h" #include "lldb/Interpreter/OptionValueFormat.h" +#include "lldb/Interpreter/OptionValueLanguage.h" #include "lldb/Interpreter/OptionValueFormatEntity.h" #include "lldb/Interpreter/OptionValuePathMappings.h" #include "lldb/Interpreter/OptionValueProperties.h" diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index 53f59dd6209..0cc6e1f05bb 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -146,6 +146,7 @@ class OptionValueEnumeration; class OptionValueFileSpec; class OptionValueFileSpecList; class OptionValueFormat; +class OptionValueLanguage; class OptionValueFormatEntity; class OptionValuePathMappings; class OptionValueProperties; diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 8b9ae792dab..547798618eb 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -783,6 +783,7 @@ 9461569B14E358A6003A195C /* SBTypeFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568B14E35621003A195C /* SBTypeFormat.cpp */; }; 9461569C14E358A6003A195C /* SBTypeSummary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568C14E35621003A195C /* SBTypeSummary.cpp */; }; 9461569D14E358A6003A195C /* SBTypeSynthetic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568D14E35621003A195C /* SBTypeSynthetic.cpp */; }; + 946216C21A97C080006E19CC /* OptionValueLanguage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 946216C11A97C080006E19CC /* OptionValueLanguage.cpp */; }; 9463D4CD13B1798800C230D4 /* CommandObjectType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9463D4CC13B1798800C230D4 /* CommandObjectType.cpp */; }; 9475C18814E5E9FA001BFC6D /* SBTypeCategory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9475C18714E5E9FA001BFC6D /* SBTypeCategory.cpp */; }; 9475C18914E5EA08001BFC6D /* SBTypeCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = 9475C18514E5E9C5001BFC6D /* SBTypeCategory.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -2424,6 +2425,8 @@ 9461569314E3567F003A195C /* SBTypeFormat.i */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBTypeFormat.i; sourceTree = "<group>"; }; 9461569414E3567F003A195C /* SBTypeSummary.i */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBTypeSummary.i; sourceTree = "<group>"; }; 9461569514E3567F003A195C /* SBTypeSynthetic.i */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBTypeSynthetic.i; sourceTree = "<group>"; }; + 946216BF1A97C055006E19CC /* OptionValueLanguage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OptionValueLanguage.h; path = include/lldb/Interpreter/OptionValueLanguage.h; sourceTree = "<group>"; }; + 946216C11A97C080006E19CC /* OptionValueLanguage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionValueLanguage.cpp; path = source/Interpreter/OptionValueLanguage.cpp; sourceTree = "<group>"; }; 9463D4CC13B1798800C230D4 /* CommandObjectType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = CommandObjectType.cpp; path = source/Commands/CommandObjectType.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 9463D4CE13B179A500C230D4 /* CommandObjectType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CommandObjectType.h; path = source/Commands/CommandObjectType.h; sourceTree = "<group>"; }; 9475C18514E5E9C5001BFC6D /* SBTypeCategory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeCategory.h; path = include/lldb/API/SBTypeCategory.h; sourceTree = "<group>"; }; @@ -4355,6 +4358,8 @@ 260CC64315D0440D002BF2E0 /* OptionValueFormat.cpp */, 264A58EB1A7DBC8C00A6B1B0 /* OptionValueFormatEntity.h */, 264A58ED1A7DBCAD00A6B1B0 /* OptionValueFormatEntity.cpp */, + 946216BF1A97C055006E19CC /* OptionValueLanguage.h */, + 946216C11A97C080006E19CC /* OptionValueLanguage.cpp */, 26DAED5F15D327A200E15819 /* OptionValuePathMappings.h */, 26DAED6215D327C200E15819 /* OptionValuePathMappings.cpp */, 260CC62415D04377002BF2E0 /* OptionValueProperties.h */, @@ -6145,6 +6150,7 @@ 2671A0D013482601003A87BB /* ConnectionMachPort.cpp in Sources */, 4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */, 4CD0BD0F134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp in Sources */, + 946216C21A97C080006E19CC /* OptionValueLanguage.cpp in Sources */, AF45FDE518A1F3AC0007051C /* AppleGetThreadItemInfoHandler.cpp in Sources */, 2377C2F819E613C100737875 /* PipePosix.cpp in Sources */, AF77E0931A033C7F0096C0EA /* ABISysV_ppc64.cpp in Sources */, diff --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp index d8b5e12cd82..8f136a5b1c5 100644 --- a/lldb/source/Interpreter/OptionValue.cpp +++ b/lldb/source/Interpreter/OptionValue.cpp @@ -222,6 +222,22 @@ OptionValue::GetAsFormat () const return nullptr; } +OptionValueLanguage * +OptionValue::GetAsLanguage () +{ + if (GetType () == OptionValue::eTypeLanguage) + return static_cast<OptionValueLanguage *>(this); + return NULL; +} + +const OptionValueLanguage * +OptionValue::GetAsLanguage () const +{ + if (GetType () == OptionValue::eTypeLanguage) + return static_cast<const OptionValueLanguage *>(this); + return NULL; +} + OptionValueFormatEntity * OptionValue::GetAsFormatEntity () { @@ -468,6 +484,27 @@ OptionValue::SetFormatValue (lldb::Format new_value) return false; } +lldb::LanguageType +OptionValue::GetLanguageValue (lldb::LanguageType fail_value) const +{ + const OptionValueLanguage *option_value = GetAsLanguage (); + if (option_value) + return option_value->GetCurrentValue(); + return fail_value; +} + +bool +OptionValue::SetLanguageValue (lldb::LanguageType new_language) +{ + OptionValueLanguage *option_value = GetAsLanguage (); + if (option_value) + { + option_value->SetCurrentValue(new_language); + return true; + } + return false; +} + const FormatEntity::Entry * OptionValue::GetFormatEntity () const { @@ -589,6 +626,7 @@ OptionValue::GetBuiltinTypeAsCString (Type t) case eTypeFileSpecList: return "file-list"; case eTypeFormat: return "format"; case eTypeFormatEntity: return "format-string"; + case eTypeLanguage: return "language"; case eTypePathMap: return "path-map"; case eTypeProperties: return "properties"; case eTypeRegex: return "regex"; @@ -615,6 +653,7 @@ OptionValue::CreateValueFromCStringForTypeMask (const char *value_cstr, uint32_t case 1u << eTypeFileSpec: value_sp.reset(new OptionValueFileSpec()); break; case 1u << eTypeFormat: value_sp.reset(new OptionValueFormat(eFormatInvalid)); break; case 1u << eTypeFormatEntity: value_sp.reset(new OptionValueFormatEntity(NULL)); break; + case 1u << eTypeLanguage: value_sp.reset(new OptionValueLanguage(eLanguageTypeUnknown)); break; case 1u << eTypeSInt64: value_sp.reset(new OptionValueSInt64()); break; case 1u << eTypeString: value_sp.reset(new OptionValueString()); break; case 1u << eTypeUInt64: value_sp.reset(new OptionValueUInt64()); break; diff --git a/lldb/source/Interpreter/OptionValueLanguage.cpp b/lldb/source/Interpreter/OptionValueLanguage.cpp new file mode 100644 index 00000000000..fd46553dabd --- /dev/null +++ b/lldb/source/Interpreter/OptionValueLanguage.cpp @@ -0,0 +1,73 @@ +//===-- OptionValueFormat.cpp -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Interpreter/OptionValueLanguage.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/Stream.h" +#include "lldb/DataFormatters/FormatManager.h" +#include "lldb/Interpreter/Args.h" +#include "lldb/Target/LanguageRuntime.h" + +using namespace lldb; +using namespace lldb_private; + +void +OptionValueLanguage::DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) +{ + if (dump_mask & eDumpOptionType) + strm.Printf ("(%s)", GetTypeAsCString ()); + if (dump_mask & eDumpOptionValue) + { + if (dump_mask & eDumpOptionType) + strm.PutCString (" = "); + strm.PutCString (LanguageRuntime::GetNameForLanguageType(m_current_value)); + } +} + +Error +OptionValueLanguage::SetValueFromString (llvm::StringRef value, VarSetOperationType op) +{ + Error error; + switch (op) + { + case eVarSetOperationClear: + Clear(); + break; + + case eVarSetOperationReplace: + case eVarSetOperationAssign: + { + LanguageType new_type = LanguageRuntime::GetLanguageTypeFromString(value.data()); + m_value_was_set = true; + m_current_value = new_type; + } + break; + + case eVarSetOperationInsertBefore: + case eVarSetOperationInsertAfter: + case eVarSetOperationRemove: + case eVarSetOperationAppend: + case eVarSetOperationInvalid: + error = OptionValue::SetValueFromString(value, op); + break; + } + return error; +} + + +lldb::OptionValueSP +OptionValueLanguage::DeepCopy () const +{ + return OptionValueSP(new OptionValueLanguage(*this)); +} + diff --git a/lldb/source/Interpreter/Property.cpp b/lldb/source/Interpreter/Property.cpp index cde255acef7..492a8017c60 100644 --- a/lldb/source/Interpreter/Property.cpp +++ b/lldb/source/Interpreter/Property.cpp @@ -122,6 +122,21 @@ Property::Property (const PropertyDefinition &definition) : } break; + case OptionValue::eTypeLanguage: + // "definition.default_uint_value" is the default language enumeration value if + // "definition.default_cstr_value" is NULL, otherwise interpret + // "definition.default_cstr_value" as a string value that represents the default + // value. + { + LanguageType new_lang = eLanguageTypeUnknown; + if (definition.default_cstr_value) + LanguageRuntime::GetLanguageTypeFromString(definition.default_cstr_value); + else + new_lang = (LanguageType)definition.default_uint_value; + m_value_sp.reset (new OptionValueLanguage(new_lang)); + } + break; + case OptionValue::eTypeFormatEntity: // "definition.default_cstr_value" as a string value that represents the default m_value_sp.reset (new OptionValueFormatEntity(definition.default_cstr_value)); |