[Lldb-commits] [lldb] r230046 - Add an OptionValueLanguage class
Enrico Granata
egranata at apple.com
Fri Feb 20 11:46:30 PST 2015
Author: enrico
Date: Fri Feb 20 13:46:30 2015
New Revision: 230046
URL: http://llvm.org/viewvc/llvm-project?rev=230046&view=rev
Log:
Add an OptionValueLanguage class
Added:
lldb/trunk/include/lldb/Interpreter/OptionValueLanguage.h
lldb/trunk/source/Interpreter/OptionValueLanguage.cpp
Modified:
lldb/trunk/include/lldb/Interpreter/OptionValue.h
lldb/trunk/include/lldb/Interpreter/OptionValues.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/Interpreter/OptionValue.cpp
lldb/trunk/source/Interpreter/Property.cpp
Modified: lldb/trunk/include/lldb/Interpreter/OptionValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionValue.h?rev=230046&r1=230045&r2=230046&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionValue.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionValue.h Fri Feb 20 13:46:30 2015
@@ -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;
Added: lldb/trunk/include/lldb/Interpreter/OptionValueLanguage.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionValueLanguage.h?rev=230046&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionValueLanguage.h (added)
+++ lldb/trunk/include/lldb/Interpreter/OptionValueLanguage.h Fri Feb 20 13:46:30 2015
@@ -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_
Modified: lldb/trunk/include/lldb/Interpreter/OptionValues.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionValues.h?rev=230046&r1=230045&r2=230046&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionValues.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionValues.h Fri Feb 20 13:46:30 2015
@@ -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"
Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=230046&r1=230045&r2=230046&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Fri Feb 20 13:46:30 2015
@@ -146,6 +146,7 @@ class OptionValueEnumeration;
class OptionValueFileSpec;
class OptionValueFileSpecList;
class OptionValueFormat;
+class OptionValueLanguage;
class OptionValueFormatEntity;
class OptionValuePathMappings;
class OptionValueProperties;
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=230046&r1=230045&r2=230046&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Feb 20 13:46:30 2015
@@ -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 */,
Modified: lldb/trunk/source/Interpreter/OptionValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValue.cpp?rev=230046&r1=230045&r2=230046&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValue.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValue.cpp Fri Feb 20 13:46:30 2015
@@ -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::Forma
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 (Ty
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::CreateValueFromCStringForTy
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;
Added: lldb/trunk/source/Interpreter/OptionValueLanguage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueLanguage.cpp?rev=230046&view=auto
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueLanguage.cpp (added)
+++ lldb/trunk/source/Interpreter/OptionValueLanguage.cpp Fri Feb 20 13:46:30 2015
@@ -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));
+}
+
Modified: lldb/trunk/source/Interpreter/Property.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Property.cpp?rev=230046&r1=230045&r2=230046&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Property.cpp (original)
+++ lldb/trunk/source/Interpreter/Property.cpp Fri Feb 20 13:46:30 2015
@@ -122,6 +122,21 @@ Property::Property (const PropertyDefini
}
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));
More information about the lldb-commits
mailing list