[Lldb-commits] [lldb] r165672 - in /lldb/trunk: include/lldb/API/LLDB.h include/lldb/API/SBDeclaration.h include/lldb/API/SBDefines.h include/lldb/API/SBFileSpec.h include/lldb/API/SBStream.h include/lldb/API/SBValue.h lldb.xcodeproj/project.pbxproj scripts/Python/build-swig-Python.sh scripts/Python/interface/SBDeclaration.i scripts/Python/interface/SBValue.i scripts/Python/python-extensions.swig scripts/lldb.swig source/API/SBDeclaration.cpp source/API/SBValue.cpp

Enrico Granata egranata at apple.com
Wed Oct 10 15:54:17 PDT 2012


Author: enrico
Date: Wed Oct 10 17:54:17 2012
New Revision: 165672

URL: http://llvm.org/viewvc/llvm-project?rev=165672&view=rev
Log:
<rdar://problem/12462744> Implement a new SBDeclaration class to wrap an lldb_private::Declaration - make a GetDeclaration() API on SBValue to return a declaration. This will only work for vroot variables as they are they only objects for which we currently provide a valid Declaration

Added:
    lldb/trunk/include/lldb/API/SBDeclaration.h
    lldb/trunk/scripts/Python/interface/SBDeclaration.i
    lldb/trunk/source/API/SBDeclaration.cpp
Modified:
    lldb/trunk/include/lldb/API/LLDB.h
    lldb/trunk/include/lldb/API/SBDefines.h
    lldb/trunk/include/lldb/API/SBFileSpec.h
    lldb/trunk/include/lldb/API/SBStream.h
    lldb/trunk/include/lldb/API/SBValue.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/scripts/Python/build-swig-Python.sh
    lldb/trunk/scripts/Python/interface/SBValue.i
    lldb/trunk/scripts/Python/python-extensions.swig
    lldb/trunk/scripts/lldb.swig
    lldb/trunk/source/API/SBValue.cpp

Modified: lldb/trunk/include/lldb/API/LLDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/LLDB.h?rev=165672&r1=165671&r2=165672&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/LLDB.h (original)
+++ lldb/trunk/include/lldb/API/LLDB.h Wed Oct 10 17:54:17 2012
@@ -26,6 +26,7 @@
 #include "lldb/API/SBCompileUnit.h"
 #include "lldb/API/SBData.h"
 #include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBDeclaration.h"
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBEvent.h"
 #include "lldb/API/SBFileSpec.h"

Added: lldb/trunk/include/lldb/API/SBDeclaration.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDeclaration.h?rev=165672&view=auto
==============================================================================
--- lldb/trunk/include/lldb/API/SBDeclaration.h (added)
+++ lldb/trunk/include/lldb/API/SBDeclaration.h Wed Oct 10 17:54:17 2012
@@ -0,0 +1,89 @@
+//===-- SBDeclaration.h -------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SBDeclaration_h_
+#define LLDB_SBDeclaration_h_
+
+#include "lldb/API/SBDefines.h"
+#include "lldb/API/SBFileSpec.h"
+
+namespace lldb {
+    
+    class SBDeclaration
+    {
+    public:
+        
+        SBDeclaration ();
+        
+        SBDeclaration (const lldb::SBDeclaration &rhs);
+        
+        ~SBDeclaration ();
+        
+        const lldb::SBDeclaration &
+        operator = (const lldb::SBDeclaration &rhs);
+        
+        bool
+        IsValid () const;
+        
+        lldb::SBFileSpec
+        GetFileSpec () const;
+        
+        uint32_t
+        GetLine () const;
+        
+        uint32_t
+        GetColumn () const;
+        
+        void
+        SetFileSpec (lldb::SBFileSpec filespec);
+        
+        void
+        SetLine (uint32_t line);
+        
+        void
+        SetColumn (uint32_t column);
+        
+        bool
+        operator == (const lldb::SBDeclaration &rhs) const;
+        
+        bool
+        operator != (const lldb::SBDeclaration &rhs) const;
+        
+        bool
+        GetDescription (lldb::SBStream &description);
+        
+    protected:
+        
+        lldb_private::Declaration *
+        get ();
+        
+    private:
+        friend class SBValue;
+        
+        const lldb_private::Declaration *
+        operator->() const;
+        
+        lldb_private::Declaration &
+        ref();
+        
+        const lldb_private::Declaration &
+        ref() const;
+        
+        SBDeclaration (const lldb_private::Declaration *lldb_object_ptr);
+        
+        void
+        SetDeclaration (const lldb_private::Declaration &lldb_object_ref);
+        
+        std::auto_ptr<lldb_private::Declaration> m_opaque_ap;
+    };
+    
+    
+} // namespace lldb
+
+#endif // LLDB_SBDeclaration_h_

Modified: lldb/trunk/include/lldb/API/SBDefines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=165672&r1=165671&r2=165672&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDefines.h (original)
+++ lldb/trunk/include/lldb/API/SBDefines.h Wed Oct 10 17:54:17 2012
@@ -37,6 +37,7 @@
 class SBCompileUnit;
 class SBData;
 class SBDebugger;
+class SBDeclaration;
 class SBError;
 class SBEvent;
 class SBEventList;

Modified: lldb/trunk/include/lldb/API/SBFileSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=165672&r1=165671&r2=165672&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBFileSpec.h (original)
+++ lldb/trunk/include/lldb/API/SBFileSpec.h Wed Oct 10 17:54:17 2012
@@ -58,6 +58,7 @@
     friend class SBAttachInfo;
     friend class SBBlock;
     friend class SBCompileUnit;
+    friend class SBDeclaration;
     friend class SBFileSpecList;
     friend class SBHostOS;
     friend class SBLaunchInfo;

Modified: lldb/trunk/include/lldb/API/SBStream.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStream.h?rev=165672&r1=165671&r2=165672&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBStream.h (original)
+++ lldb/trunk/include/lldb/API/SBStream.h Wed Oct 10 17:54:17 2012
@@ -65,6 +65,7 @@
     friend class SBCompileUnit;
     friend class SBData;
     friend class SBDebugger;
+    friend class SBDeclaration;
     friend class SBEvent;
     friend class SBFileSpec;
     friend class SBFileSpecList;

Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=165672&r1=165671&r2=165672&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Wed Oct 10 17:54:17 2012
@@ -269,6 +269,9 @@
     lldb::SBData
     GetData ();
     
+    lldb::SBDeclaration
+    GetDeclaration ();
+    
     uint32_t
     GetNumChildren ();
 

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=165672&r1=165671&r2=165672&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Oct 10 17:54:17 2012
@@ -515,6 +515,7 @@
 		941BCC8214E48C4000BB969C /* SBTypeSynthetic.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568914E355F2003A195C /* SBTypeSynthetic.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		9443B122140C18C40013457C /* SBData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9443B121140C18C10013457C /* SBData.cpp */; };
 		9443B123140C26AB0013457C /* SBData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9443B120140C18A90013457C /* SBData.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		9452573A16262D0200325455 /* SBDeclaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9452573916262D0200325455 /* SBDeclaration.cpp */; };
 		9456F2241616671900656F91 /* DynamicLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9456F2211616644B00656F91 /* DynamicLibrary.cpp */; };
 		94611EB213CCA4A4003A22AF /* RefCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94611EB113CCA4A4003A22AF /* RefCounter.cpp */; };
 		9461569A14E358A6003A195C /* SBTypeFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568A14E35621003A195C /* SBTypeFilter.cpp */; };
@@ -1507,6 +1508,9 @@
 		9415F61713B2C0EF00A52B36 /* FormatManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = FormatManager.cpp; path = source/Core/FormatManager.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
 		9443B120140C18A90013457C /* SBData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBData.h; path = include/lldb/API/SBData.h; sourceTree = "<group>"; };
 		9443B121140C18C10013457C /* SBData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBData.cpp; path = source/API/SBData.cpp; sourceTree = "<group>"; };
+		9452573616262CD000325455 /* SBDeclaration.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBDeclaration.i; sourceTree = "<group>"; };
+		9452573816262CEF00325455 /* SBDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBDeclaration.h; path = include/lldb/API/SBDeclaration.h; sourceTree = "<group>"; };
+		9452573916262D0200325455 /* SBDeclaration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBDeclaration.cpp; path = source/API/SBDeclaration.cpp; sourceTree = "<group>"; };
 		9456F2211616644B00656F91 /* DynamicLibrary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicLibrary.cpp; sourceTree = "<group>"; };
 		9456F2231616645A00656F91 /* DynamicLibrary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DynamicLibrary.h; path = include/lldb/Host/DynamicLibrary.h; sourceTree = "<group>"; };
 		94611EAF13CCA363003A22AF /* RefCounter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RefCounter.h; path = include/lldb/Utility/RefCounter.h; sourceTree = "<group>"; };
@@ -2017,6 +2021,7 @@
 				2611FEF7142D83060017FEA3 /* SBCompileUnit.i */,
 				2611FEF8142D83060017FEA3 /* SBData.i */,
 				2611FEF9142D83060017FEA3 /* SBDebugger.i */,
+				9452573616262CD000325455 /* SBDeclaration.i */,
 				2611FEFA142D83060017FEA3 /* SBError.i */,
 				2611FEFB142D83060017FEA3 /* SBEvent.i */,
 				2611FEFC142D83060017FEA3 /* SBFileSpec.i */,
@@ -2106,6 +2111,8 @@
 				9443B121140C18C10013457C /* SBData.cpp */,
 				9A9830FB1125FC5800A56CB0 /* SBDebugger.h */,
 				9A9830FA1125FC5800A56CB0 /* SBDebugger.cpp */,
+				9452573816262CEF00325455 /* SBDeclaration.h */,
+				9452573916262D0200325455 /* SBDeclaration.cpp */,
 				2682F286115EF3BD00CCFF99 /* SBError.h */,
 				2682F284115EF3A700CCFF99 /* SBError.cpp */,
 				9A9830FE1125FC5800A56CB0 /* SBEvent.h */,
@@ -3763,6 +3770,7 @@
 				2660AAB914622483003A9694 /* LLDBWrapPython.cpp in Sources */,
 				9475C18814E5E9FA001BFC6D /* SBTypeCategory.cpp in Sources */,
 				9475C18E14E5F834001BFC6D /* SBTypeNameSpecifier.cpp in Sources */,
+				9452573A16262D0200325455 /* SBDeclaration.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: lldb/trunk/scripts/Python/build-swig-Python.sh
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/build-swig-Python.sh?rev=165672&r1=165671&r2=165672&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/build-swig-Python.sh (original)
+++ lldb/trunk/scripts/Python/build-swig-Python.sh Wed Oct 10 17:54:17 2012
@@ -117,6 +117,7 @@
 " ${SRC_ROOT}/scripts/Python/interface/SBCompileUnit.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBData.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBDebugger.i"\
+" ${SRC_ROOT}/scripts/Python/interface/SBDeclaration.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBError.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBEvent.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBFileSpec.i"\

Added: lldb/trunk/scripts/Python/interface/SBDeclaration.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBDeclaration.i?rev=165672&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBDeclaration.i (added)
+++ lldb/trunk/scripts/Python/interface/SBDeclaration.i Wed Oct 10 17:54:17 2012
@@ -0,0 +1,62 @@
+//===-- SWIG Interface for SBDeclaration --------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+    
+    %feature("docstring",
+    "Specifies an association with a line and column for a variable."
+    ) SBDeclaration;
+    class SBDeclaration
+    {
+        public:
+        
+        SBDeclaration ();
+        
+        SBDeclaration (const lldb::SBDeclaration &rhs);
+        
+        ~SBDeclaration ();
+        
+        bool
+        IsValid () const;
+        
+        lldb::SBFileSpec
+        GetFileSpec () const;
+        
+        uint32_t
+        GetLine () const;
+        
+        uint32_t
+        GetColumn () const;
+        
+        bool
+        GetDescription (lldb::SBStream &description);
+        
+        void
+        SetFileSpec (lldb::SBFileSpec filespec);
+        
+        void
+        SetLine (uint32_t line);
+        
+        void
+        SetColumn (uint32_t column);
+        
+        %pythoncode %{
+            __swig_getmethods__["file"] = GetFileSpec
+            if _newclass: file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''')
+            
+            __swig_getmethods__["line"] = GetLine
+            if _newclass: ling = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''')
+            
+            __swig_getmethods__["column"] = GetColumn
+            if _newclass: column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''')
+            %}
+        
+    };
+    
+} // namespace lldb

Modified: lldb/trunk/scripts/Python/interface/SBValue.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValue.i?rev=165672&r1=165671&r2=165672&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBValue.i (original)
+++ lldb/trunk/scripts/Python/interface/SBValue.i Wed Oct 10 17:54:17 2012
@@ -281,6 +281,9 @@
     lldb::SBValue
     GetValueForExpressionPath(const char* expr_path);
 
+    lldb::SBDeclaration
+    GetDeclaration ();
+    
     uint32_t
     GetNumChildren ();
 

Modified: lldb/trunk/scripts/Python/python-extensions.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=165672&r1=165671&r2=165672&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-extensions.swig (original)
+++ lldb/trunk/scripts/Python/python-extensions.swig Wed Oct 10 17:54:17 2012
@@ -111,6 +111,20 @@
                     return PyString_FromString("");
         }
 }
+%extend lldb::SBDeclaration {
+        PyObject *lldb::SBDeclaration::__str__ (){
+                lldb::SBStream description;
+                $self->GetDescription (description);
+                const char *desc = description.GetData();
+                size_t desc_len = description.GetSize();
+                if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+                    --desc_len;
+                if (desc_len > 0)
+                    return PyString_FromStringAndSize (desc, desc_len);
+                else
+                    return PyString_FromString("");
+        }
+}
 %extend lldb::SBError {
         PyObject *lldb::SBError::__str__ (){
                 lldb::SBStream description;

Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=165672&r1=165671&r2=165672&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Wed Oct 10 17:54:17 2012
@@ -63,6 +63,7 @@
 #include "lldb/API/SBCompileUnit.h"
 #include "lldb/API/SBData.h"
 #include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBDeclaration.h"
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBEvent.h"
 #include "lldb/API/SBFileSpec.h"
@@ -121,6 +122,7 @@
 %include "./Python/interface/SBCompileUnit.i"
 %include "./Python/interface/SBData.i"
 %include "./Python/interface/SBDebugger.i"
+%include "./Python/interface/SBDeclaration.i"
 %include "./Python/interface/SBError.i"
 %include "./Python/interface/SBEvent.i"
 %include "./Python/interface/SBFileSpec.i"

Added: lldb/trunk/source/API/SBDeclaration.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDeclaration.cpp?rev=165672&view=auto
==============================================================================
--- lldb/trunk/source/API/SBDeclaration.cpp (added)
+++ lldb/trunk/source/API/SBDeclaration.cpp Wed Oct 10 17:54:17 2012
@@ -0,0 +1,204 @@
+//===-- SBDeclaration.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/API/SBDeclaration.h"
+#include "lldb/API/SBStream.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Symbol/Declaration.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+
+SBDeclaration::SBDeclaration () :
+    m_opaque_ap ()
+{
+}
+
+SBDeclaration::SBDeclaration (const SBDeclaration &rhs) :
+    m_opaque_ap ()
+{
+    if (rhs.IsValid())
+        ref() = rhs.ref();
+}
+
+SBDeclaration::SBDeclaration (const lldb_private::Declaration *lldb_object_ptr) :
+    m_opaque_ap ()
+{
+    if (lldb_object_ptr)
+        ref() = *lldb_object_ptr;
+}
+
+const SBDeclaration &
+SBDeclaration::operator = (const SBDeclaration &rhs)
+{
+    if (this != &rhs)
+    {
+        if (rhs.IsValid())
+            ref() = rhs.ref();
+        else
+            m_opaque_ap.reset();
+    }
+    return *this;
+}
+
+void
+SBDeclaration::SetDeclaration (const lldb_private::Declaration &lldb_object_ref)
+{
+    ref() = lldb_object_ref;
+}
+
+
+SBDeclaration::~SBDeclaration ()
+{
+}
+
+
+bool
+SBDeclaration::IsValid () const
+{
+    return m_opaque_ap.get() && m_opaque_ap->IsValid();
+}
+
+
+SBFileSpec
+SBDeclaration::GetFileSpec () const
+{
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    
+    SBFileSpec sb_file_spec;
+    if (m_opaque_ap.get() && m_opaque_ap->GetFile())
+        sb_file_spec.SetFileSpec(m_opaque_ap->GetFile());
+    
+    if (log)
+    {
+        SBStream sstr;
+        sb_file_spec.GetDescription (sstr);
+        log->Printf ("SBLineEntry(%p)::GetFileSpec () => SBFileSpec(%p): %s", m_opaque_ap.get(),
+                     sb_file_spec.get(), sstr.GetData());
+    }
+    
+    return sb_file_spec;
+}
+
+uint32_t
+SBDeclaration::GetLine () const
+{
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    
+    uint32_t line = 0;
+    if (m_opaque_ap.get())
+        line = m_opaque_ap->GetLine();
+    
+    if (log)
+        log->Printf ("SBLineEntry(%p)::GetLine () => %u", m_opaque_ap.get(), line);
+    
+    return line;
+}
+
+
+uint32_t
+SBDeclaration::GetColumn () const
+{
+    if (m_opaque_ap.get())
+        return m_opaque_ap->GetColumn();
+    return 0;
+}
+
+void
+SBDeclaration::SetFileSpec (lldb::SBFileSpec filespec)
+{
+    if (filespec.IsValid())
+        ref().SetFile(filespec.ref());
+    else
+        ref().SetFile(FileSpec());
+}
+void
+SBDeclaration::SetLine (uint32_t line)
+{
+    ref().SetLine(line);
+}
+
+void
+SBDeclaration::SetColumn (uint32_t column)
+{
+    ref().SetColumn(column);
+}
+
+
+
+bool
+SBDeclaration::operator == (const SBDeclaration &rhs) const
+{
+    lldb_private::Declaration *lhs_ptr = m_opaque_ap.get();
+    lldb_private::Declaration *rhs_ptr = rhs.m_opaque_ap.get();
+    
+    if (lhs_ptr && rhs_ptr)
+        return lldb_private::Declaration::Compare (*lhs_ptr, *rhs_ptr) == 0;
+    
+    return lhs_ptr == rhs_ptr;
+}
+
+bool
+SBDeclaration::operator != (const SBDeclaration &rhs) const
+{
+    lldb_private::Declaration *lhs_ptr = m_opaque_ap.get();
+    lldb_private::Declaration *rhs_ptr = rhs.m_opaque_ap.get();
+    
+    if (lhs_ptr && rhs_ptr)
+        return lldb_private::Declaration::Compare (*lhs_ptr, *rhs_ptr) != 0;
+    
+    return lhs_ptr != rhs_ptr;
+}
+
+const lldb_private::Declaration *
+SBDeclaration::operator->() const
+{
+    return m_opaque_ap.get();
+}
+
+lldb_private::Declaration &
+SBDeclaration::ref()
+{
+    if (m_opaque_ap.get() == NULL)
+        m_opaque_ap.reset (new lldb_private::Declaration ());
+    return *m_opaque_ap;
+}
+
+const lldb_private::Declaration &
+SBDeclaration::ref() const
+{
+    return *m_opaque_ap;
+}
+
+bool
+SBDeclaration::GetDescription (SBStream &description)
+{
+    Stream &strm = description.ref();
+    
+    if (m_opaque_ap.get())
+    {
+        char file_path[PATH_MAX*2];
+        m_opaque_ap->GetFile().GetPath (file_path, sizeof (file_path));
+        strm.Printf ("%s:%u", file_path, GetLine());
+        if (GetColumn() > 0)
+            strm.Printf (":%u", GetColumn());
+    }
+    else
+        strm.PutCString ("No value");
+    
+    return true;
+}
+
+lldb_private::Declaration *
+SBDeclaration::get ()
+{
+    return m_opaque_ap.get();
+}

Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=165672&r1=165671&r2=165672&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Wed Oct 10 17:54:17 2012
@@ -9,6 +9,7 @@
 
 #include "lldb/API/SBValue.h"
 
+#include "lldb/API/SBDeclaration.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBTypeFilter.h"
 #include "lldb/API/SBTypeFormat.h"
@@ -28,6 +29,7 @@
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/Declaration.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Type.h"
 #include "lldb/Symbol/Variable.h"
@@ -1694,6 +1696,20 @@
     return sb_data;
 }
 
+lldb::SBDeclaration
+SBValue::GetDeclaration ()
+{
+    lldb::ValueObjectSP value_sp(GetSP());
+    SBDeclaration decl_sb;
+    if (value_sp)
+    {
+        Declaration decl;
+        if (value_sp->GetDeclaration(decl))
+            decl_sb.SetDeclaration(decl);
+    }
+    return decl_sb;
+}
+
 lldb::SBWatchpoint
 SBValue::Watch (bool resolve_location, bool read, bool write, SBError &error)
 {





More information about the lldb-commits mailing list