[Lldb-commits] [lldb] r129843 - in /lldb/trunk: include/lldb/Interpreter/NamedOptionValue.h include/lldb/lldb-forward-rtti.h include/lldb/lldb-forward.h lldb.xcodeproj/project.pbxproj source/Interpreter/NamedOptionValue.cpp

Greg Clayton gclayton at apple.com
Tue Apr 19 18:33:38 PDT 2011


Author: gclayton
Date: Tue Apr 19 20:33:38 2011
New Revision: 129843

URL: http://llvm.org/viewvc/llvm-project?rev=129843&view=rev
Log:
Added the start of a new option value system that we can use for many things
around the debugger. The class isn't hooked into anything yet, but it will be
soon. 


Added:
    lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h
    lldb/trunk/source/Interpreter/NamedOptionValue.cpp
Modified:
    lldb/trunk/include/lldb/lldb-forward-rtti.h
    lldb/trunk/include/lldb/lldb-forward.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj

Added: lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h?rev=129843&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h (added)
+++ lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h Tue Apr 19 20:33:38 2011
@@ -0,0 +1,648 @@
+//===-- NamedOptionValue.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_NamedOptionValue_h_
+#define liblldb_NamedOptionValue_h_
+
+// C Includes
+// C++ Includes
+#include <vector>
+#include <map>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/ConstString.h"
+#include "lldb/Host/FileSpec.h"
+
+namespace lldb_private {
+
+
+    //---------------------------------------------------------------------
+    // OptionValue
+    //---------------------------------------------------------------------
+    class OptionValue
+    {
+    public:
+        typedef enum {
+            eTypeInvalid = 0,
+            eTypeArray,
+            eTypeBoolean,
+            eTypeDictionary,
+            eTypeEnum,
+            eTypeFileSpec,
+            eTypeSInt64,
+            eTypeUInt64,
+            eTypeString
+        } Type;
+        
+        virtual ~OptionValue ()
+        {
+        }
+        //-----------------------------------------------------------------
+        // Subclasses should override these functions
+        //-----------------------------------------------------------------
+        virtual Type
+        GetType () = 0;
+        
+        virtual void
+        DumpValue (Stream &strm) = 0;
+        
+        virtual bool
+        SetValueFromCString (const char *value) = 0;
+        
+        virtual bool
+        ResetValueToDefault () = 0;
+    };
+    
+    
+
+    //---------------------------------------------------------------------
+    // OptionValueBoolean
+    //---------------------------------------------------------------------
+    class OptionValueBoolean : public OptionValue
+    {
+        OptionValueBoolean (bool current_value, 
+                            bool default_value) :
+        m_current_value (current_value),
+        m_default_value (default_value)
+        {
+        }
+        
+        virtual 
+        ~OptionValueBoolean()
+        {
+        }
+        
+        //---------------------------------------------------------------------
+        // Virtual subclass pure virtual overrides
+        //---------------------------------------------------------------------
+        
+        virtual OptionValue::Type
+        GetType ()
+        {
+            return eTypeBoolean;
+        }
+        
+        virtual void
+        DumpValue (Stream &strm);
+        
+        virtual bool
+        SetValueFromCString (const char *value);
+        
+        virtual bool
+        ResetValueToDefault ()
+        {
+            m_current_value = m_default_value;
+            return true;
+        }
+        
+        //---------------------------------------------------------------------
+        // Subclass specific functions
+        //---------------------------------------------------------------------
+        
+        bool
+        GetCurrentValue() const
+        {
+            return m_current_value;
+        }
+        
+        bool
+        GetDefaultValue() const
+        {
+            return m_default_value;
+        }
+        
+        void
+        SetCurrentValue (bool value)
+        {
+            m_current_value = value;
+        }
+        
+        void
+        SetDefaultValue (bool value)
+        {
+            m_default_value = value;
+        }
+        
+    protected:
+        bool m_current_value;
+        bool m_default_value;
+    };
+    
+    //---------------------------------------------------------------------
+    // OptionValueSInt64
+    //---------------------------------------------------------------------
+    class OptionValueSInt64 : public OptionValue
+    {
+        OptionValueSInt64 (int64_t current_value, 
+                           int64_t default_value) :
+        m_current_value (current_value),
+        m_default_value (default_value)
+        {
+        }
+        
+        virtual 
+        ~OptionValueSInt64()
+        {
+        }
+        
+        //---------------------------------------------------------------------
+        // Virtual subclass pure virtual overrides
+        //---------------------------------------------------------------------
+        
+        virtual OptionValue::Type
+        GetType ()
+        {
+            return eTypeSInt64;
+        }
+        
+        virtual void
+        DumpValue (Stream &strm);
+        
+        virtual bool
+        SetValueFromCString (const char *value);
+        
+        virtual bool
+        ResetValueToDefault ()
+        {
+            m_current_value = m_default_value;
+            return true;
+        }
+        
+        //---------------------------------------------------------------------
+        // Subclass specific functions
+        //---------------------------------------------------------------------
+        
+        int64_t
+        GetCurrentValue() const
+        {
+            return m_current_value;
+        }
+        
+        int64_t
+        GetDefaultValue() const
+        {
+            return m_default_value;
+        }
+        
+        void
+        SetCurrentValue (int64_t value)
+        {
+            m_current_value = value;
+        }
+        
+        void
+        SetDefaultValue (int64_t value)
+        {
+            m_default_value = value;
+        }
+        
+    protected:
+        int64_t m_current_value;
+        int64_t m_default_value;
+    };
+    
+    //---------------------------------------------------------------------
+    // OptionValueUInt64
+    //---------------------------------------------------------------------
+    class OptionValueUInt64 : public OptionValue
+    {
+        OptionValueUInt64 (uint64_t current_value, 
+                           uint64_t default_value) :
+        m_current_value (current_value),
+        m_default_value (default_value)
+        {
+        }
+        
+        virtual 
+        ~OptionValueUInt64()
+        {
+        }
+        
+        //---------------------------------------------------------------------
+        // Virtual subclass pure virtual overrides
+        //---------------------------------------------------------------------
+        
+        virtual OptionValue::Type
+        GetType ()
+        {
+            return eTypeUInt64;
+        }
+        
+        virtual void
+        DumpValue (Stream &strm);
+        
+        virtual bool
+        SetValueFromCString (const char *value);
+        
+        virtual bool
+        ResetValueToDefault ()
+        {
+            m_current_value = m_default_value;
+            return true;
+        }
+        
+        //---------------------------------------------------------------------
+        // Subclass specific functions
+        //---------------------------------------------------------------------
+        
+        uint64_t
+        GetCurrentValue() const
+        {
+            return m_current_value;
+        }
+        
+        uint64_t
+        GetDefaultValue() const
+        {
+            return m_default_value;
+        }
+        
+        void
+        SetCurrentValue (uint64_t value)
+        {
+            m_current_value = value;
+        }
+        
+        void
+        SetDefaultValue (uint64_t value)
+        {
+            m_default_value = value;
+        }
+        
+    protected:
+        uint64_t m_current_value;
+        uint64_t m_default_value;
+    };
+
+    //---------------------------------------------------------------------
+    // OptionValueFileSpec
+    //---------------------------------------------------------------------
+    class OptionValueFileSpec : public OptionValue
+    {
+        OptionValueFileSpec (const FileSpec &current_value, 
+                             const FileSpec &default_value) :
+            m_current_value (current_value),
+            m_default_value (default_value)
+        {
+        }
+        
+        virtual 
+        ~OptionValueFileSpec()
+        {
+        }
+        
+        //---------------------------------------------------------------------
+        // Virtual subclass pure virtual overrides
+        //---------------------------------------------------------------------
+        
+        virtual OptionValue::Type
+        GetType ()
+        {
+            return eTypeFileSpec;
+        }
+        
+        virtual void
+        DumpValue (Stream &strm);
+        
+        virtual bool
+        SetValueFromCString (const char *value);
+        
+        virtual bool
+        ResetValueToDefault ()
+        {
+            m_current_value = m_default_value;
+            return true;
+        }
+        
+        //---------------------------------------------------------------------
+        // Subclass specific functions
+        //---------------------------------------------------------------------
+        
+        const FileSpec &
+        GetCurrentValue() const
+        {
+            return m_current_value;
+        }
+        
+        const FileSpec &
+        GetDefaultValue() const
+        {
+            return m_default_value;
+        }
+        
+        void
+        SetCurrentValue (const FileSpec &value)
+        {
+            m_current_value = value;
+        }
+        
+        void
+        SetDefaultValue (const FileSpec &value)
+        {
+            m_default_value = value;
+        }
+        
+    protected:
+        FileSpec m_current_value;
+        FileSpec m_default_value;
+    };
+    
+    //---------------------------------------------------------------------
+    // OptionValueArray
+    //---------------------------------------------------------------------
+    class OptionValueArray : public OptionValue
+    {
+        OptionValueArray () :
+            m_values ()
+        {
+        }
+        
+        virtual 
+        ~OptionValueArray()
+        {
+        }
+        
+        //---------------------------------------------------------------------
+        // Virtual subclass pure virtual overrides
+        //---------------------------------------------------------------------
+        
+        virtual OptionValue::Type
+        GetType ()
+        {
+            return eTypeArray;
+        }
+        
+        virtual void
+        DumpValue (Stream &strm);
+        
+        virtual bool
+        SetValueFromCString (const char *value);
+        
+        virtual bool
+        ResetValueToDefault ()
+        {
+            m_values.clear();
+            return true;
+        }
+        
+        //---------------------------------------------------------------------
+        // Subclass specific functions
+        //---------------------------------------------------------------------
+
+        uint32_t
+        GetNumValues() const
+        {
+            return m_values.size();
+        }
+
+        lldb::OptionValueSP
+        GetValueAtIndex (uint32_t idx) const
+        {
+            lldb::OptionValueSP value_sp;
+            if (idx < m_values.size())
+                value_sp = m_values[idx];
+            return value_sp;
+        }
+        
+        void
+        AppendValue (const lldb::OptionValueSP &value_sp)
+        {
+            m_values.push_back(value_sp);
+        }
+        
+        void
+        InsertValue (uint32_t idx, const lldb::OptionValueSP &value_sp)
+        {
+            if (idx < m_values.size())
+                m_values.insert(m_values.begin() + idx, value_sp);
+            else
+                m_values.push_back(value_sp);
+        }
+
+        bool
+        ReplaceValue (uint32_t idx, const lldb::OptionValueSP &value_sp)
+        {
+            if (idx < m_values.size())
+            {
+                m_values[idx] = value_sp;
+                return true;
+            }
+            return false;
+        }
+
+        bool
+        DeleteValue (uint32_t idx)
+        {
+            if (idx < m_values.size())
+            {
+                m_values.erase (m_values.begin() + idx);
+                return true;
+            }
+            return false;
+        }
+        
+    protected:
+        typedef std::vector<lldb::OptionValueSP> collection;
+        collection m_values;
+    };
+
+    
+    
+    //---------------------------------------------------------------------
+    // OptionValueDictionary
+    //---------------------------------------------------------------------
+    class OptionValueDictionary : public OptionValue
+    {
+        OptionValueDictionary () :
+        m_values ()
+        {
+        }
+        
+        virtual 
+        ~OptionValueDictionary()
+        {
+        }
+        
+        //---------------------------------------------------------------------
+        // Virtual subclass pure virtual overrides
+        //---------------------------------------------------------------------
+        
+        virtual OptionValue::Type
+        GetType ()
+        {
+            return eTypeDictionary;
+        }
+        
+        virtual void
+        DumpValue (Stream &strm);
+        
+        virtual bool
+        SetValueFromCString (const char *value);
+        
+        virtual bool
+        ResetValueToDefault ()
+        {
+            m_values.clear();
+            return true;
+        }
+        
+        //---------------------------------------------------------------------
+        // Subclass specific functions
+        //---------------------------------------------------------------------
+        
+        uint32_t
+        GetNumValues() const
+        {
+            return m_values.size();
+        }
+        
+        lldb::OptionValueSP
+        GetValueForKey (const ConstString &key) const
+        {
+            lldb::OptionValueSP value_sp;
+            collection::const_iterator pos = m_values.find (key);
+            if (pos != m_values.end())
+                value_sp = pos->second;
+            return value_sp;
+        }
+        
+        bool
+        SetValueForKey (const ConstString &key, 
+                        const lldb::OptionValueSP &value_sp, 
+                        bool can_replace)
+        {
+            if (!can_replace)
+            {
+                collection::const_iterator pos = m_values.find (key);
+                if (pos != m_values.end())
+                    return false;
+            }
+            m_values[key] = value_sp;
+            return true;
+        }
+        
+        bool
+        DeleteValueForKey (const ConstString &key)
+        {
+            collection::iterator pos = m_values.find (key);
+            if (pos != m_values.end())
+            {
+                m_values.erase(pos);
+                return true;
+            }
+            return false;
+        }
+        
+    protected:
+        typedef std::map<ConstString, lldb::OptionValueSP> collection;
+        collection m_values;
+    };
+    
+
+
+    //---------------------------------------------------------------------
+    // NamedOptionValue
+    //---------------------------------------------------------------------
+    class NamedOptionValue
+    {
+    public:
+        
+        NamedOptionValue (NamedOptionValue *parent, const ConstString &name) :
+            m_parent (parent),
+            m_name (name),
+            m_user_data (0)
+        {
+        }
+
+        virtual
+        ~NamedOptionValue ()
+        {
+        }
+        
+        NamedOptionValue *
+        GetParent ()
+        {
+            return m_parent;
+        }
+
+        const NamedOptionValue *
+        GetParent () const
+        {
+            return m_parent;
+        }
+
+        const ConstString &
+        GetName () const
+        {
+            return m_name;
+        }
+        
+        uint32_t
+        GetUserData () const
+        {
+            return m_user_data;
+        }
+
+        void
+        SetUserData (uint32_t user_data)
+        {
+            m_user_data = user_data;
+        }
+
+        void
+        GetQualifiedName (Stream &strm);
+
+        lldb::OptionValueSP
+        GetOptionValue ()
+        {
+            return m_value_sp;
+        }
+        
+        OptionValue::Type
+        GetValueType ();
+        
+        bool
+        DumpValue (Stream &strm);
+        
+        bool
+        SetValueFromCString (const char *value);
+        
+        bool
+        ResetValueToDefault ();
+        
+        OptionValueBoolean *
+        GetBooleanValue ();
+
+        OptionValueSInt64 *
+        GetSInt64Value ();
+        
+        OptionValueUInt64 *
+        GetUInt64Value ();        
+
+        OptionValueFileSpec *
+        GetFileSpecValue() ;
+
+        OptionValueArray *
+        GetArrayValue() ;
+
+        OptionValueDictionary *
+        GetDictionaryValue() ;
+
+    protected:
+        NamedOptionValue *m_parent;      // NULL if this is a root object
+        ConstString m_name;         // Name for this setting
+        uint32_t m_user_data;       // User data that can be used for anything.
+        lldb::OptionValueSP m_value_sp;   // Abstract option value
+    };
+
+    
+} // namespace lldb_private
+
+#endif  // liblldb_NamedOptionValue_h_

Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=129843&r1=129842&r2=129843&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward-rtti.h (original)
+++ lldb/trunk/include/lldb/lldb-forward-rtti.h Tue Apr 19 20:33:38 2011
@@ -50,6 +50,7 @@
     typedef SharedPtr<lldb_private::Log>::Type LogSP;
     typedef SharedPtr<lldb_private::LogChannel>::Type LogChannelSP;
     typedef SharedPtr<lldb_private::Module>::Type ModuleSP;
+    typedef SharedPtr<lldb_private::OptionValue>::Type OptionValueSP;
     typedef SharedPtr<lldb_private::Platform>::Type PlatformSP;
     typedef SharedPtr<lldb_private::Process>::Type ProcessSP;
     typedef SharedPtr<lldb_private::RegisterContext>::Type RegisterContextSP;

Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=129843&r1=129842&r2=129843&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Tue Apr 19 20:33:38 2011
@@ -99,6 +99,8 @@
 class   ObjectContainer;
 class   ObjectFile;
 class   Options;
+class   OptionValue;
+class   NamedOption;
 class   PathMappingList;
 class   Platform;
 class   Process;

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=129843&r1=129842&r2=129843&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Apr 19 20:33:38 2011
@@ -370,6 +370,7 @@
 		268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; };
 		2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2697A54B133A6305004E4240 /* PlatformDarwin.cpp */; };
 		2697A54E133A6305004E4240 /* PlatformDarwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 2697A54C133A6305004E4240 /* PlatformDarwin.h */; };
+		26A7A035135E6E4200FB369E /* NamedOptionValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A7A034135E6E4200FB369E /* NamedOptionValue.cpp */; };
 		26B1FA1413380E61002886E2 /* LLDBWrapPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */; };
 		26B1FCB813381071002886E2 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; };
 		26B1FCB913381071002886E2 /* DebugSymbols.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 265ABF6210F42EE900531910 /* DebugSymbols.framework */; };
@@ -426,7 +427,6 @@
 		9A357673116E7B6400E8ED2F /* SBStringList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A357672116E7B6400E8ED2F /* SBStringList.cpp */; };
 		9A3576A8116E9AB700E8ED2F /* SBHostOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A3576A7116E9AB700E8ED2F /* SBHostOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		9A3576AA116E9AC700E8ED2F /* SBHostOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */; };
-		9AA20A84133D278400E2E4A7 /* DisassemblerShark.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA20A82133D278400E2E4A7 /* DisassemblerShark.cpp */; };
 		9AA69DA61188F52100D753A0 /* PseudoTerminal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */; };
 		9AA69DAF118A023300D753A0 /* SBInputReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AA69DAE118A023300D753A0 /* SBInputReader.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		9AA69DB1118A024600D753A0 /* SBInputReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA69DB0118A024600D753A0 /* SBInputReader.cpp */; };
@@ -715,6 +715,8 @@
 		26A3B4AC1181454800381BC2 /* ObjectContainerBSDArchive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectContainerBSDArchive.cpp; sourceTree = "<group>"; };
 		26A3B4AD1181454800381BC2 /* ObjectContainerBSDArchive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectContainerBSDArchive.h; sourceTree = "<group>"; };
 		26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LLDBWrapPython.cpp; path = source/LLDBWrapPython.cpp; sourceTree = "<group>"; };
+		26A7A034135E6E4200FB369E /* NamedOptionValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NamedOptionValue.cpp; path = source/Interpreter/NamedOptionValue.cpp; sourceTree = "<group>"; };
+		26A7A036135E6E5300FB369E /* NamedOptionValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NamedOptionValue.h; path = include/lldb/Interpreter/NamedOptionValue.h; sourceTree = "<group>"; };
 		26B167A41123BF5500DC7B4F /* ThreadSafeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadSafeValue.h; path = include/lldb/Core/ThreadSafeValue.h; sourceTree = "<group>"; };
 		26B42C4C1187ABA50079C8C8 /* LLDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLDB.h; path = include/lldb/API/LLDB.h; sourceTree = "<group>"; };
 		26B4E26E112F35F700AB3F64 /* TimeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TimeValue.h; path = include/lldb/Host/TimeValue.h; sourceTree = "<group>"; };
@@ -1196,8 +1198,6 @@
 		9A9831081125FC5800A56CB0 /* SBTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBTarget.h; path = include/lldb/API/SBTarget.h; sourceTree = "<group>"; };
 		9A9831091125FC5800A56CB0 /* SBThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBThread.cpp; path = source/API/SBThread.cpp; sourceTree = "<group>"; };
 		9A98310A1125FC5800A56CB0 /* SBThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBThread.h; path = include/lldb/API/SBThread.h; sourceTree = "<group>"; };
-		9AA20A82133D278400E2E4A7 /* DisassemblerShark.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisassemblerShark.cpp; sourceTree = "<group>"; };
-		9AA20A83133D278400E2E4A7 /* DisassemblerShark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisassemblerShark.h; sourceTree = "<group>"; };
 		9AA69DAE118A023300D753A0 /* SBInputReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBInputReader.h; path = include/lldb/API/SBInputReader.h; sourceTree = "<group>"; };
 		9AA69DB0118A024600D753A0 /* SBInputReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBInputReader.cpp; path = source/API/SBInputReader.cpp; sourceTree = "<group>"; };
 		9AA69DB5118A027A00D753A0 /* InputReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InputReader.cpp; path = source/Core/InputReader.cpp; sourceTree = "<group>"; };
@@ -1366,7 +1366,6 @@
 			isa = PBXGroup;
 			children = (
 				260C897310F57C5600BB2B04 /* llvm */,
-				9AA20A81133D278400E2E4A7 /* shark */,
 			);
 			path = Disassembler;
 			sourceTree = "<group>";
@@ -2182,6 +2181,8 @@
 				26DFBC59113B48F300DD817F /* CommandObjectRegexCommand.cpp */,
 				26BC7DE410F1B7F900F91463 /* CommandReturnObject.h */,
 				26BC7F0A10F1B8DD00F91463 /* CommandReturnObject.cpp */,
+				26A7A036135E6E5300FB369E /* NamedOptionValue.h */,
+				26A7A034135E6E4200FB369E /* NamedOptionValue.cpp */,
 				26BC7D6D10F1B77400F91463 /* Options.h */,
 				26BC7E8610F1B85900F91463 /* Options.cpp */,
 				26D5E160135BAEB0006EA0A7 /* OptionGroupArchitecture.h */,
@@ -2509,15 +2510,6 @@
 			path = source/Host/common;
 			sourceTree = "<group>";
 		};
-		9AA20A81133D278400E2E4A7 /* shark */ = {
-			isa = PBXGroup;
-			children = (
-				9AA20A82133D278400E2E4A7 /* DisassemblerShark.cpp */,
-				9AA20A83133D278400E2E4A7 /* DisassemblerShark.h */,
-			);
-			path = shark;
-			sourceTree = "<group>";
-		};
 /* End PBXGroup section */
 
 /* Begin PBXHeadersBuildPhase section */
@@ -3160,7 +3152,6 @@
 				264A97BF133918BC0017F0BE /* PlatformRemoteGDBServer.cpp in Sources */,
 				2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */,
 				26651A18133BF9E0005B64B7 /* Opcode.cpp in Sources */,
-				9AA20A84133D278400E2E4A7 /* DisassemblerShark.cpp in Sources */,
 				266603CA1345B5A8004DA8B6 /* ConnectionSharedMemory.cpp in Sources */,
 				2671A0D013482601003A87BB /* ConnectionMachPort.cpp in Sources */,
 				4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */,
@@ -3168,6 +3159,7 @@
 				26D5E15F135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp in Sources */,
 				26D5E163135BB054006EA0A7 /* OptionGroupPlatform.cpp in Sources */,
 				26BD407F135D2AE000237D80 /* FileLineResolver.cpp in Sources */,
+				26A7A035135E6E4200FB369E /* NamedOptionValue.cpp in Sources */,
 				9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in Sources */,
 				9A22A163135E30370024DDC3 /* EmulationStateARM.cpp in Sources */,
 			);

Added: lldb/trunk/source/Interpreter/NamedOptionValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/NamedOptionValue.cpp?rev=129843&view=auto
==============================================================================
--- lldb/trunk/source/Interpreter/NamedOptionValue.cpp (added)
+++ lldb/trunk/source/Interpreter/NamedOptionValue.cpp Tue Apr 19 20:33:38 2011
@@ -0,0 +1,264 @@
+//===-- NamedOptionValue.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/NamedOptionValue.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Stream.h"
+#include "lldb/Interpreter/Args.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+//-------------------------------------------------------------------------
+// NamedOptionValue
+//-------------------------------------------------------------------------
+
+void
+NamedOptionValue::GetQualifiedName (Stream &strm)
+{
+    if (m_parent)
+    {
+        m_parent->GetQualifiedName (strm);
+        strm.PutChar('.');
+    }
+    strm << m_name;
+}
+
+OptionValue::Type
+NamedOptionValue::GetValueType ()
+{
+    if (m_value_sp)
+        return m_value_sp->GetType();
+    return OptionValue::eTypeInvalid;
+}
+
+bool
+NamedOptionValue::DumpValue (Stream &strm)
+{
+    if (m_value_sp)
+    {
+        m_value_sp->DumpValue (strm);
+        return true;
+    }
+    return false;
+}
+
+bool
+NamedOptionValue::SetValueFromCString (const char *value_cstr)
+{
+    if (m_value_sp)
+        return m_value_sp->SetValueFromCString (value_cstr);
+    return false;
+}
+
+bool
+NamedOptionValue::ResetValueToDefault ()
+{
+    if (m_value_sp)
+        return m_value_sp->ResetValueToDefault ();
+    return false;
+}
+
+
+OptionValueBoolean *
+NamedOptionValue::GetBooleanValue ()
+{
+    if (GetValueType() == OptionValue::eTypeBoolean)
+        return static_cast<OptionValueBoolean *>(m_value_sp.get());
+    return NULL;
+}
+
+OptionValueSInt64 *
+NamedOptionValue::GetSInt64Value ()
+{
+    if (GetValueType() == OptionValue::eTypeSInt64)
+        return static_cast<OptionValueSInt64 *>(m_value_sp.get());
+    return NULL;
+}
+
+OptionValueUInt64 *
+NamedOptionValue::GetUInt64Value ()
+{
+    if (GetValueType() == OptionValue::eTypeUInt64)
+        return static_cast<OptionValueUInt64 *>(m_value_sp.get());
+    return NULL;
+}
+
+
+OptionValueFileSpec *
+NamedOptionValue::GetFileSpecValue ()
+{
+    if (GetValueType() == OptionValue::eTypeFileSpec)
+        return static_cast<OptionValueFileSpec *>(m_value_sp.get());
+    return NULL;
+}
+
+OptionValueArray *
+NamedOptionValue::GetArrayValue ()
+{
+    if (GetValueType() == OptionValue::eTypeArray)
+        return static_cast<OptionValueArray *>(m_value_sp.get());
+    return NULL;
+}
+
+OptionValueDictionary *
+NamedOptionValue::GetDictionaryValue ()
+{
+    if (GetValueType() == OptionValue::eTypeDictionary)
+        return static_cast<OptionValueDictionary *>(m_value_sp.get());
+    return NULL;
+}
+
+//-------------------------------------------------------------------------
+// OptionValueBoolean
+//-------------------------------------------------------------------------
+void
+OptionValueBoolean::DumpValue (Stream &strm)
+{
+    strm.PutCString (m_current_value ? "true" : "false");
+}
+
+bool
+OptionValueBoolean::SetValueFromCString (const char *value_cstr)
+{
+    bool success = false;
+    bool value = Args::StringToBoolean(value_cstr, false, &success);
+    if (success)
+    {
+        m_current_value = value;
+        return true;
+    }
+    return false;
+}
+
+//-------------------------------------------------------------------------
+// OptionValueSInt64
+//-------------------------------------------------------------------------
+void
+OptionValueSInt64::DumpValue (Stream &strm)
+{
+    strm.Printf ("%lli", m_current_value);
+}
+
+bool
+OptionValueSInt64::SetValueFromCString (const char *value_cstr)
+{
+    bool success = false;
+    int64_t value = Args::StringToSInt64 (value_cstr, 0, 0, &success);
+    if (success)
+    {
+        m_current_value = value;
+        return true;
+    }
+    return false;
+}
+
+//-------------------------------------------------------------------------
+// OptionValueUInt64
+//-------------------------------------------------------------------------
+void
+OptionValueUInt64::DumpValue (Stream &strm)
+{
+    strm.Printf ("0x%llx", m_current_value);
+}
+
+bool
+OptionValueUInt64::SetValueFromCString (const char *value_cstr)
+{
+    bool success = false;
+    uint64_t value = Args::StringToUInt64 (value_cstr, 0, 0, &success);
+    if (success)
+    {
+        m_current_value = value;
+        return true;
+    }
+    return false;
+}
+
+//-------------------------------------------------------------------------
+// OptionValueFileSpec
+//-------------------------------------------------------------------------
+void
+OptionValueFileSpec::DumpValue (Stream &strm)
+{
+    if (m_current_value)
+    {
+        if (m_current_value.GetDirectory())
+        {
+            strm << '"' << m_current_value.GetDirectory();
+            if (m_current_value.GetFilename())
+                strm << '/' << m_current_value.GetFilename();
+            strm << '"';
+        }
+        else
+        {
+            strm << '"' << m_current_value.GetFilename() << '"';
+        }
+    }
+}
+
+bool
+OptionValueFileSpec::SetValueFromCString (const char *value_cstr)
+{
+    if (value_cstr && value_cstr[0])
+        m_current_value.SetFile(value_cstr, false);
+    else
+        m_current_value.Clear();
+    return true;
+}
+
+
+//-------------------------------------------------------------------------
+// OptionValueArray
+//-------------------------------------------------------------------------
+void
+OptionValueArray::DumpValue (Stream &strm)
+{
+    const uint32_t size = m_values.size();
+    for (uint32_t i = 0; i<size; ++i)
+    {
+        strm.Printf("[%u] ", i);
+        m_values[i]->DumpValue (strm);
+    }
+}
+
+bool
+OptionValueArray::SetValueFromCString (const char *value_cstr)
+{
+    // We must be able to set this using the array specific functions
+    return false;
+}
+
+//-------------------------------------------------------------------------
+// OptionValueDictionary
+//-------------------------------------------------------------------------
+void
+OptionValueDictionary::DumpValue (Stream &strm)
+{
+    collection::iterator pos, end = m_values.end();
+
+    for (pos = m_values.begin(); pos != end; ++pos)
+    {
+        strm.Printf("%s=", pos->first.GetCString());
+        pos->second->DumpValue (strm);
+    }
+}
+
+bool
+OptionValueDictionary::SetValueFromCString (const char *value_cstr)
+{
+    // We must be able to set this using the array specific functions
+    return false;
+}
+
+





More information about the lldb-commits mailing list