[Lldb-commits] [lldb] r185877 - Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of modul...

Greg Clayton gclayton at apple.com
Mon Jul 8 15:22:41 PDT 2013


Author: gclayton
Date: Mon Jul  8 17:22:41 2013
New Revision: 185877

URL: http://llvm.org/viewvc/llvm-project?rev=185877&view=rev
Log:
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).

There are two new classes:

lldb::SBModuleSpec
lldb::SBModuleSpecList

The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.


Added:
    lldb/trunk/include/lldb/API/SBModuleSpec.h
    lldb/trunk/scripts/Python/interface/SBModuleSpec.i
    lldb/trunk/source/API/SBModuleSpec.cpp
Modified:
    lldb/trunk/include/lldb/API/SBDefines.h
    lldb/trunk/include/lldb/API/SBFileSpec.h
    lldb/trunk/include/lldb/API/SBModule.h
    lldb/trunk/include/lldb/API/SBStream.h
    lldb/trunk/include/lldb/API/SBTarget.h
    lldb/trunk/include/lldb/Core/ModuleSpec.h
    lldb/trunk/include/lldb/Core/UUID.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/scripts/Python/build-swig-Python.sh
    lldb/trunk/scripts/Python/interface/SBModule.i
    lldb/trunk/scripts/Python/interface/SBTarget.i
    lldb/trunk/scripts/Python/python-extensions.swig
    lldb/trunk/scripts/lldb.swig
    lldb/trunk/source/API/SBFileSpec.cpp
    lldb/trunk/source/API/SBModule.cpp
    lldb/trunk/source/API/SBTarget.cpp
    lldb/trunk/source/Core/UUID.cpp

Modified: lldb/trunk/include/lldb/API/SBDefines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDefines.h (original)
+++ lldb/trunk/include/lldb/API/SBDefines.h Mon Jul  8 17:22:41 2013
@@ -54,6 +54,8 @@ class SBInstructionList;
 class SBLineEntry;
 class SBListener;
 class SBModule;
+class SBModuleSpec;
+class SBModuleSpecList;
 class SBProcess;
 class SBSourceManager;
 class SBStream;

Modified: lldb/trunk/include/lldb/API/SBFileSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBFileSpec.h (original)
+++ lldb/trunk/include/lldb/API/SBFileSpec.h Mon Jul  8 17:22:41 2013
@@ -64,13 +64,16 @@ private:
     friend class SBLaunchInfo;
     friend class SBLineEntry;
     friend class SBModule;
+    friend class SBModuleSpec;
     friend class SBProcess;
     friend class SBSourceManager;
     friend class SBThread;
     friend class SBTarget;
 
+    SBFileSpec (const lldb_private::FileSpec& fspec);
+
     void
-    SetFileSpec (const lldb_private::FileSpec& fs);
+    SetFileSpec (const lldb_private::FileSpec& fspec);
 
     const lldb_private::FileSpec *
     operator->() const;

Modified: lldb/trunk/include/lldb/API/SBModule.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBModule.h?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBModule.h (original)
+++ lldb/trunk/include/lldb/API/SBModule.h Mon Jul  8 17:22:41 2013
@@ -26,6 +26,8 @@ public:
 
     SBModule (const SBModule &rhs);
 
+    SBModule (const SBModuleSpec &module_spec);
+
     const SBModule &
     operator = (const SBModule &rhs);
 

Added: lldb/trunk/include/lldb/API/SBModuleSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBModuleSpec.h?rev=185877&view=auto
==============================================================================
--- lldb/trunk/include/lldb/API/SBModuleSpec.h (added)
+++ lldb/trunk/include/lldb/API/SBModuleSpec.h Mon Jul  8 17:22:41 2013
@@ -0,0 +1,154 @@
+//===-- SBModuleSpec.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_SBModuleSpec_h_
+#define LLDB_SBModuleSpec_h_
+
+#include "lldb/API/SBDefines.h"
+#include "lldb/API/SBFileSpec.h"
+
+namespace lldb {
+
+class SBModuleSpec
+{
+public:
+
+    SBModuleSpec ();
+
+    SBModuleSpec (const SBModuleSpec &rhs);
+
+    ~SBModuleSpec ();
+
+    const SBModuleSpec &
+    operator = (const SBModuleSpec &rhs);
+
+    bool
+    IsValid () const;
+
+    void
+    Clear();
+
+    //------------------------------------------------------------------
+    /// Get const accessor for the module file.
+    ///
+    /// This function returns the file for the module on the host system
+    /// that is running LLDB. This can differ from the path on the 
+    /// platform since we might be doing remote debugging.
+    ///
+    /// @return
+    ///     A const reference to the file specification object.
+    //------------------------------------------------------------------
+    lldb::SBFileSpec
+    GetFileSpec ();
+
+    void
+    SetFileSpec (const lldb::SBFileSpec &fspec);
+
+    //------------------------------------------------------------------
+    /// Get accessor for the module platform file.
+    ///
+    /// Platform file refers to the path of the module as it is known on
+    /// the remote system on which it is being debugged. For local 
+    /// debugging this is always the same as Module::GetFileSpec(). But
+    /// remote debugging might mention a file '/usr/lib/liba.dylib'
+    /// which might be locally downloaded and cached. In this case the
+    /// platform file could be something like:
+    /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
+    /// The file could also be cached in a local developer kit directory.
+    ///
+    /// @return
+    ///     A const reference to the file specification object.
+    //------------------------------------------------------------------
+    lldb::SBFileSpec
+    GetPlatformFileSpec ();
+
+    void
+    SetPlatformFileSpec (const lldb::SBFileSpec &fspec);
+
+    lldb::SBFileSpec
+    GetSymbolFileSpec ();
+    
+    void
+    SetSymbolFileSpec (const lldb::SBFileSpec &fspec);
+
+    const char *
+    GetObjectName ();
+    
+    void
+    SetObjectName (const char *name);
+
+    const char *
+    GetTriple ();
+
+    void
+    SetTriple (const char *triple);
+
+    const uint8_t *
+    GetUUIDBytes ();
+
+    size_t
+    GetUUIDLength ();
+
+    bool
+    SetUUIDBytes (const uint8_t *uuid, size_t uuid_len);
+
+    bool
+    GetDescription (lldb::SBStream &description);
+    
+private:
+    friend class SBModuleSpecList;
+    friend class SBModule;
+    friend class SBTarget;
+
+    std::unique_ptr<lldb_private::ModuleSpec> m_opaque_ap;
+};
+
+class SBModuleSpecList
+{
+public:
+    SBModuleSpecList();
+
+    SBModuleSpecList (const SBModuleSpecList &rhs);
+
+    ~SBModuleSpecList();
+
+    SBModuleSpecList &
+    operator = (const SBModuleSpecList &rhs);
+    
+    static SBModuleSpecList
+    GetModuleSpecifications (const char *path);
+    
+    void
+    Append (const SBModuleSpec &spec);
+    
+    void
+    Append (const SBModuleSpecList &spec_list);
+
+    SBModuleSpec
+    FindFirstMatchingSpec (const SBModuleSpec &match_spec);
+
+    SBModuleSpecList
+    FindMatchingSpecs (const SBModuleSpec &match_spec);
+
+    size_t
+    GetSize();
+    
+    SBModuleSpec
+    GetSpecAtIndex (size_t i);
+
+    bool
+    GetDescription (lldb::SBStream &description);
+    
+private:
+    std::unique_ptr<lldb_private::ModuleSpecList> m_opaque_ap;
+};
+
+} // namespace lldb
+
+#endif // LLDB_SBModuleSpec_h_

Modified: lldb/trunk/include/lldb/API/SBStream.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStream.h?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBStream.h (original)
+++ lldb/trunk/include/lldb/API/SBStream.h Mon Jul  8 17:22:41 2013
@@ -75,6 +75,8 @@ protected:
     friend class SBInstructionList;
     friend class SBLineEntry;
     friend class SBModule;
+    friend class SBModuleSpec;
+    friend class SBModuleSpecList;
     friend class SBProcess;
     friend class SBSection;
     friend class SBSourceManager;

Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Mon Jul  8 17:22:41 2013
@@ -477,6 +477,10 @@ public:
                const char *triple,
                const char *uuid_cstr,
                const char *symfile);
+    
+    lldb::SBModule
+    AddModule (const SBModuleSpec &module_spec);
+
     uint32_t
     GetNumModules () const;
 

Modified: lldb/trunk/include/lldb/Core/ModuleSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleSpec.h?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ModuleSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ModuleSpec.h Mon Jul  8 17:22:41 2013
@@ -11,6 +11,7 @@
 #define liblldb_ModuleSpec_h_
 
 #include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/Stream.h"
 #include "lldb/Core/UUID.h"
 #include "lldb/Host/FileSpec.h"
 #include "lldb/Target/PathMappingList.h"
@@ -286,6 +287,123 @@ public:
         m_object_mod_time.Clear();
     }
 
+    
+    operator bool () const
+    {
+        if (m_file)
+            return true;
+        if (m_platform_file)
+            return true;
+        if (m_symbol_file)
+            return true;
+        if (m_arch.IsValid())
+            return true;
+        if (m_uuid.IsValid())
+            return true;
+        if (m_object_name)
+            return true;
+        if (m_object_mod_time.IsValid())
+            return true;
+        return false;
+    }
+
+    void
+    Dump (Stream &strm)
+    {
+        bool dumped_something = false;
+        if (m_file)
+        {
+            strm.PutCString("file = '");
+            strm << m_file;
+            strm.PutCString("'");
+            dumped_something = true;
+        }
+        if (m_platform_file)
+        {
+            if (dumped_something)
+                strm.PutCString(", ");
+            strm.PutCString("platform_file = '");
+            strm << m_platform_file;
+            strm.PutCString("'");
+            dumped_something = true;
+        }
+        if (m_symbol_file)
+        {
+            if (dumped_something)
+                strm.PutCString(", ");
+            strm.PutCString("symbol_file = '");
+            strm << m_symbol_file;
+            strm.PutCString("'");
+            dumped_something = true;
+        }
+        if (m_arch.IsValid())
+        {
+            if (dumped_something)
+                strm.PutCString(", ");
+            strm.Printf("arch = %s", m_arch.GetTriple().str().c_str());
+            dumped_something = true;
+        }
+        if (m_uuid.IsValid())
+        {
+            if (dumped_something)
+                strm.PutCString(", ");
+            strm.PutCString("uuid = ");
+            m_uuid.Dump(&strm);
+            dumped_something = true;
+            
+        }
+        if (m_object_name)
+        {
+            if (dumped_something)
+                strm.PutCString(", ");
+            strm.Printf("object_name = %s", m_object_name.GetCString());
+            dumped_something = true;
+        }
+    }
+
+    bool
+    Matches (const ModuleSpec &match_module_spec, bool exact_arch_match) const
+    {
+        if (match_module_spec.GetUUIDPtr() && match_module_spec.GetUUID() != GetUUID())
+            return false;
+        if (match_module_spec.GetObjectName() && match_module_spec.GetObjectName() != GetObjectName())
+            return false;
+        if (match_module_spec.GetFileSpecPtr())
+        {
+            const FileSpec &fspec = match_module_spec.GetFileSpec();
+            if (!FileSpec::Equal(fspec, GetFileSpec(), fspec.GetDirectory().IsEmpty() == false))
+                return false;
+        }
+        if (match_module_spec.GetPlatformFileSpecPtr())
+        {
+            const FileSpec &fspec = match_module_spec.GetPlatformFileSpec();
+            if (!FileSpec::Equal(fspec, GetPlatformFileSpec(), fspec.GetDirectory().IsEmpty() == false))
+                return false;
+            
+        }
+        if (match_module_spec.GetSymbolFileSpecPtr())
+        {
+            const FileSpec &fspec = match_module_spec.GetSymbolFileSpec();
+            if (!FileSpec::Equal(fspec, GetSymbolFileSpec(), fspec.GetDirectory().IsEmpty() == false))
+                return false;
+            
+        }
+        if (match_module_spec.GetArchitecturePtr())
+        {
+            if (exact_arch_match)
+            {
+                if (!GetArchitecture().IsExactMatch(match_module_spec.GetArchitecture()))
+                    return false;
+            }
+            else
+            {
+                if (!GetArchitecture().IsCompatibleMatch(match_module_spec.GetArchitecture()))
+                    return false;
+            }
+        }
+        return true;
+    }
+
 protected:
     FileSpec m_file;
     FileSpec m_platform_file;
@@ -319,7 +437,19 @@ public:
     ~ModuleSpecList ()
     {
     }
-    
+
+    ModuleSpecList &
+    operator = (const ModuleSpecList &rhs)
+    {
+        if (this != &rhs)
+        {
+            Mutex::Locker lhs_locker(m_mutex);
+            Mutex::Locker rhs_locker(rhs.m_mutex);
+            m_specs = rhs.m_specs;
+        }
+        return *this;
+    }
+
     size_t
     GetSize() const
     {
@@ -340,7 +470,15 @@ public:
         Mutex::Locker locker(m_mutex);
         m_specs.push_back (spec);
     }
-    
+
+    void
+    Append (const ModuleSpecList &rhs)
+    {
+        Mutex::Locker lhs_locker(m_mutex);
+        Mutex::Locker rhs_locker(rhs.m_mutex);
+        m_specs.insert(m_specs.end(), rhs.m_specs.begin(), rhs.m_specs.end());
+    }
+
     bool
     GetModuleSpecAtIndex (size_t i, ModuleSpec &module_spec) const
     {
@@ -354,58 +492,76 @@ public:
         return false;
     }
     
+    
     bool
     FindMatchingModuleSpec (const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const
     {
-        const FileSpec *file_ptr = module_spec.GetFileSpecPtr();
-        const FileSpec *platform_file_ptr = module_spec.GetPlatformFileSpecPtr();
-        const FileSpec *symbol_file_ptr = module_spec.GetSymbolFileSpecPtr();
-        const ArchSpec *arch_ptr = module_spec.GetArchitecturePtr();
-        const UUID *uuid_ptr = module_spec.GetUUIDPtr();
-        const bool check_module_name = (bool)module_spec.GetObjectName();
         Mutex::Locker locker(m_mutex);
+        bool exact_arch_match = true;
         for (auto spec: m_specs)
         {
-            if (uuid_ptr && spec.GetUUID() != *uuid_ptr)
-                continue;
-            if (check_module_name && module_spec.GetObjectName() != spec.GetObjectName())
-                continue;
-            if (file_ptr && !FileSpec::Equal(*file_ptr, spec.GetFileSpec(), file_ptr->GetDirectory().IsEmpty() == false))
-                continue;
-            if (platform_file_ptr && !FileSpec::Equal(*platform_file_ptr, spec.GetFileSpec(), platform_file_ptr->GetDirectory().IsEmpty() == false))
-                continue;
-            if (symbol_file_ptr && !FileSpec::Equal(*symbol_file_ptr, spec.GetFileSpec(), symbol_file_ptr->GetDirectory().IsEmpty() == false))
-                continue;
-            if (arch_ptr && !spec.GetArchitecture().IsExactMatch(*arch_ptr))
-                continue;
-            match_module_spec = spec;
-            return true;
+            if (spec.Matches(module_spec, exact_arch_match))
+            {
+                match_module_spec = spec;
+                return true;
+            }
         }
         
         // If there was an architecture, retry with a compatible arch
-        if (arch_ptr)
+        if (module_spec.GetArchitecturePtr())
         {
+            exact_arch_match = false;
             for (auto spec: m_specs)
             {
-                if (uuid_ptr && spec.GetUUID() != *uuid_ptr)
-                    continue;
-                if (check_module_name && module_spec.GetObjectName() != spec.GetObjectName())
-                    continue;
-                if (file_ptr && !FileSpec::Equal(*file_ptr, spec.GetFileSpec(), file_ptr->GetDirectory().IsEmpty() == false))
-                    continue;
-                if (platform_file_ptr && !FileSpec::Equal(*platform_file_ptr, spec.GetFileSpec(), platform_file_ptr->GetDirectory().IsEmpty() == false))
-                    continue;
-                if (symbol_file_ptr && !FileSpec::Equal(*symbol_file_ptr, spec.GetFileSpec(), symbol_file_ptr->GetDirectory().IsEmpty() == false))
-                    continue;
-                if (arch_ptr && !spec.GetArchitecture().IsCompatibleMatch(*arch_ptr))
-                    continue;
-                match_module_spec = spec;
-                return true;
+                if (spec.Matches(module_spec, exact_arch_match))
+                {
+                    match_module_spec = spec;
+                    return true;
+                }
             }
         }
         match_module_spec.Clear();
         return false;
     }
+    
+    size_t
+    FindMatchingModuleSpecs (const ModuleSpec &module_spec, ModuleSpecList &matching_list) const
+    {
+        Mutex::Locker locker(m_mutex);
+        bool exact_arch_match = true;
+        const size_t initial_match_count = matching_list.GetSize();
+        for (auto spec: m_specs)
+        {
+            if (spec.Matches(module_spec, exact_arch_match))
+                matching_list.Append (spec);
+        }
+        
+        // If there was an architecture, retry with a compatible arch if no matches were found
+        if (module_spec.GetArchitecturePtr() && (initial_match_count == matching_list.GetSize()))
+        {
+            exact_arch_match = false;
+            for (auto spec: m_specs)
+            {
+                if (spec.Matches(module_spec, exact_arch_match))
+                    matching_list.Append (spec);
+            }
+        }
+        return matching_list.GetSize() - initial_match_count;
+    }
+
+    void
+    Dump (Stream &strm)
+    {
+        Mutex::Locker locker(m_mutex);
+        uint32_t idx = 0;
+        for (auto spec: m_specs)
+        {
+            strm.Printf("[%u] ", idx);
+            spec.Dump (strm);
+            strm.EOL();
+            ++idx;
+        }
+    }
 
 protected:
     typedef std::vector<ModuleSpec> collection; ///< The module collection type.

Modified: lldb/trunk/include/lldb/Core/UUID.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UUID.h?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/UUID.h (original)
+++ lldb/trunk/include/lldb/Core/UUID.h Mon Jul  8 17:22:41 2013
@@ -52,7 +52,7 @@ public:
     bool
     IsValid () const;
 
-    void
+    bool
     SetBytes (const void *uuid_bytes, uint32_t num_uuid_bytes = 16);
 
     std::string

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Jul  8 17:22:41 2013
@@ -92,6 +92,8 @@
 		2635879417822FC2004C30BA /* SymbolVendorELF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2635879017822E56004C30BA /* SymbolVendorELF.cpp */; };
 		26368A3C126B697600E8659F /* darwin-debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26368A3B126B697600E8659F /* darwin-debug.cpp */; };
 		26368AF7126B960500E8659F /* darwin-debug in Resources */ = {isa = PBXBuildFile; fileRef = 26579F68126A25920007C5CB /* darwin-debug */; };
+		263C4938178B50C40070F12D /* SBModuleSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263C4937178B50C40070F12D /* SBModuleSpec.cpp */; };
+		263C493A178B50CF0070F12D /* SBModuleSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 263C4939178B50CF0070F12D /* SBModuleSpec.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		263E949F13661AEA00E7D1CE /* UnwindAssembly-x86.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263E949D13661AE400E7D1CE /* UnwindAssembly-x86.cpp */; };
 		2640E19F15DC78FD00F23B50 /* Property.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2640E19E15DC78FD00F23B50 /* Property.cpp */; };
 		2642FBAE13D003B400ED6808 /* CommunicationKDP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2642FBA813D003B400ED6808 /* CommunicationKDP.cpp */; };
@@ -923,6 +925,9 @@
 		263664921140A4930075843B /* Debugger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = Debugger.cpp; path = source/Core/Debugger.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
 		263664941140A4C10075843B /* Debugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = Debugger.h; path = include/lldb/Core/Debugger.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
 		26368A3B126B697600E8659F /* darwin-debug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "darwin-debug.cpp"; path = "tools/darwin-debug/darwin-debug.cpp"; sourceTree = "<group>"; };
+		263C4937178B50C40070F12D /* SBModuleSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBModuleSpec.cpp; path = source/API/SBModuleSpec.cpp; sourceTree = "<group>"; };
+		263C4939178B50CF0070F12D /* SBModuleSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBModuleSpec.h; path = include/lldb/API/SBModuleSpec.h; sourceTree = "<group>"; };
+		263C493B178B61CC0070F12D /* SBModuleSpec.i */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBModuleSpec.i; sourceTree = "<group>"; };
 		263E949D13661AE400E7D1CE /* UnwindAssembly-x86.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "UnwindAssembly-x86.cpp"; sourceTree = "<group>"; };
 		263E949E13661AE400E7D1CE /* UnwindAssembly-x86.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UnwindAssembly-x86.h"; sourceTree = "<group>"; };
 		263FEDA5112CC1DA00E4C208 /* ThreadSafeSTLMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadSafeSTLMap.h; path = include/lldb/Core/ThreadSafeSTLMap.h; sourceTree = "<group>"; };
@@ -2113,6 +2118,7 @@
 				2611FF04142D83060017FEA3 /* SBLineEntry.i */,
 				2611FF05142D83060017FEA3 /* SBListener.i */,
 				2611FF06142D83060017FEA3 /* SBModule.i */,
+				263C493B178B61CC0070F12D /* SBModuleSpec.i */,
 				2611FF07142D83060017FEA3 /* SBProcess.i */,
 				2611FF08142D83060017FEA3 /* SBSection.i */,
 				2611FF09142D83060017FEA3 /* SBSourceManager.i */,
@@ -2211,6 +2217,8 @@
 				9A9831011125FC5800A56CB0 /* SBListener.cpp */,
 				26DE204E11618E9800A093E2 /* SBModule.h */,
 				26DE204C11618E7A00A093E2 /* SBModule.cpp */,
+				263C4939178B50CF0070F12D /* SBModuleSpec.h */,
+				263C4937178B50C40070F12D /* SBModuleSpec.cpp */,
 				9A9831041125FC5800A56CB0 /* SBProcess.h */,
 				9A9831031125FC5800A56CB0 /* SBProcess.cpp */,
 				26B8283C142D01E9002DBC64 /* SBSection.h */,
@@ -3497,6 +3505,7 @@
 				268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */,
 				2668022C115FD13D008E1FE4 /* SBTarget.h in Headers */,
 				2668022E115FD13D008E1FE4 /* SBThread.h in Headers */,
+				263C493A178B50CF0070F12D /* SBModuleSpec.h in Headers */,
 				2617447A11685869005ADD65 /* SBType.h in Headers */,
 				9475C18914E5EA08001BFC6D /* SBTypeCategory.h in Headers */,
 				941BCC7F14E48C4000BB969C /* SBTypeFilter.h in Headers */,
@@ -3904,6 +3913,7 @@
 				4CF52AF8142829390051E832 /* SBFileSpecList.cpp in Sources */,
 				26B82840142D020F002DBC64 /* SBSection.cpp in Sources */,
 				B2A58724143119D50092BFBA /* SBWatchpoint.cpp in Sources */,
+				263C4938178B50C40070F12D /* SBModuleSpec.cpp in Sources */,
 				2660AAB914622483003A9694 /* LLDBWrapPython.cpp in Sources */,
 				9475C18814E5E9FA001BFC6D /* SBTypeCategory.cpp in Sources */,
 				9475C18E14E5F834001BFC6D /* SBTypeNameSpecifier.cpp in Sources */,

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=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/build-swig-Python.sh (original)
+++ lldb/trunk/scripts/Python/build-swig-Python.sh Mon Jul  8 17:22:41 2013
@@ -105,6 +105,7 @@ HEADER_FILES="${SRC_ROOT}/include/lldb/l
 " ${SRC_ROOT}/include/lldb/API/SBLineEntry.h"\
 " ${SRC_ROOT}/include/lldb/API/SBListener.h"\
 " ${SRC_ROOT}/include/lldb/API/SBModule.h"\
+" ${SRC_ROOT}/include/lldb/API/SBModuleSpec.h"\
 " ${SRC_ROOT}/include/lldb/API/SBProcess.h"\
 " ${SRC_ROOT}/include/lldb/API/SBSourceManager.h"\
 " ${SRC_ROOT}/include/lldb/API/SBStream.h"\
@@ -150,6 +151,7 @@ INTERFACE_FILES="${SRC_ROOT}/scripts/Pyt
 " ${SRC_ROOT}/scripts/Python/interface/SBLineEntry.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBListener.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBModule.i"\
+" ${SRC_ROOT}/scripts/Python/interface/SBModuleSpec.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBProcess.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBSourceManager.i"\
 " ${SRC_ROOT}/scripts/Python/interface/SBStream.i"\

Modified: lldb/trunk/scripts/Python/interface/SBModule.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBModule.i?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBModule.i (original)
+++ lldb/trunk/scripts/Python/interface/SBModule.i Mon Jul  8 17:22:41 2013
@@ -96,7 +96,9 @@ public:
 
     SBModule ();
 
-    SBModule (const SBModule &rhs);
+    SBModule (const lldb::SBModule &rhs);
+     
+    SBModule (const lldb::SBModuleSpec &module_spec);
     
     SBModule (lldb::SBProcess &process, 
               lldb::addr_t header_addr);

Added: lldb/trunk/scripts/Python/interface/SBModuleSpec.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBModuleSpec.i?rev=185877&view=auto
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBModuleSpec.i (added)
+++ lldb/trunk/scripts/Python/interface/SBModuleSpec.i Mon Jul  8 17:22:41 2013
@@ -0,0 +1,133 @@
+//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBModuleSpec
+{
+public:
+    
+    SBModuleSpec ();
+    
+    SBModuleSpec (const lldb::SBModuleSpec &rhs);
+    
+    ~SBModuleSpec ();
+    
+    bool
+    IsValid () const;
+    
+    void
+    Clear();
+    
+    //------------------------------------------------------------------
+    /// Get const accessor for the module file.
+    ///
+    /// This function returns the file for the module on the host system
+    /// that is running LLDB. This can differ from the path on the
+    /// platform since we might be doing remote debugging.
+    ///
+    /// @return
+    ///     A const reference to the file specification object.
+    //------------------------------------------------------------------
+    lldb::SBFileSpec
+    GetFileSpec ();
+    
+    void
+    SetFileSpec (const lldb::SBFileSpec &fspec);
+    
+    //------------------------------------------------------------------
+    /// Get accessor for the module platform file.
+    ///
+    /// Platform file refers to the path of the module as it is known on
+    /// the remote system on which it is being debugged. For local
+    /// debugging this is always the same as Module::GetFileSpec(). But
+    /// remote debugging might mention a file '/usr/lib/liba.dylib'
+    /// which might be locally downloaded and cached. In this case the
+    /// platform file could be something like:
+    /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
+    /// The file could also be cached in a local developer kit directory.
+    ///
+    /// @return
+    ///     A const reference to the file specification object.
+    //------------------------------------------------------------------
+    lldb::SBFileSpec
+    GetPlatformFileSpec ();
+    
+    void
+    SetPlatformFileSpec (const lldb::SBFileSpec &fspec);
+    
+    lldb::SBFileSpec
+    GetSymbolFileSpec ();
+    
+    void
+    SetSymbolFileSpec (const lldb::SBFileSpec &fspec);
+    
+    const char *
+    GetObjectName ();
+    
+    void
+    SetObjectName (const char *name);
+    
+    const char *
+    GetTriple ();
+    
+    void
+    SetTriple (const char *triple);
+    
+    const uint8_t *
+    GetUUIDBytes ();
+    
+    size_t
+    GetUUIDLength ();
+    
+    bool
+    SetUUIDBytes (const uint8_t *uuid, size_t uuid_len);
+    
+    bool
+    GetDescription (lldb::SBStream &description);
+    
+};
+
+
+class SBModuleSpecList
+{
+public:
+    SBModuleSpecList();
+    
+    SBModuleSpecList (const SBModuleSpecList &rhs);
+    
+    ~SBModuleSpecList();
+    
+    static SBModuleSpecList
+    GetModuleSpecifications (const char *path);
+    
+    void
+    Append (const lldb::SBModuleSpec &spec);
+    
+    void
+    Append (const lldb::SBModuleSpecList &spec_list);
+
+    lldb::SBModuleSpec
+    FindFirstMatchingSpec (const lldb::SBModuleSpec &match_spec);
+    
+    lldb::SBModuleSpecList
+    FindMatchingSpecs (const lldb::SBModuleSpec &match_spec);
+    
+    size_t
+    GetSize();
+    
+    lldb::SBModuleSpec
+    GetSpecAtIndex (size_t i);
+    
+    bool
+    GetDescription (lldb::SBStream &description);
+
+};
+
+} // namespace lldb

Modified: lldb/trunk/scripts/Python/interface/SBTarget.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTarget.i?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBTarget.i (original)
+++ lldb/trunk/scripts/Python/interface/SBTarget.i Mon Jul  8 17:22:41 2013
@@ -515,6 +515,9 @@ public:
                const char *uuid_cstr,
                const char *symfile);
 
+    lldb::SBModule
+    AddModule (const SBModuleSpec &module_spec);
+
     uint32_t
     GetNumModules () const;
 

Modified: lldb/trunk/scripts/Python/python-extensions.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-extensions.swig (original)
+++ lldb/trunk/scripts/Python/python-extensions.swig Mon Jul  8 17:22:41 2013
@@ -353,6 +353,37 @@
             return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
     %}
 }
+
+%extend lldb::SBModuleSpec {
+        PyObject *lldb::SBModuleSpec::__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::SBModuleSpecList {
+        PyObject *lldb::SBModuleSpecList::__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::SBProcess {
         PyObject *lldb::SBProcess::__str__ (){
                 lldb::SBStream description;

Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Mon Jul  8 17:22:41 2013
@@ -78,6 +78,7 @@ import os
 #include "lldb/API/SBLineEntry.h"
 #include "lldb/API/SBListener.h"
 #include "lldb/API/SBModule.h"
+#include "lldb/API/SBModuleSpec.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBSection.h"
 #include "lldb/API/SBSourceManager.h"
@@ -141,6 +142,7 @@ import os
 %include "./Python/interface/SBLineEntry.i"
 %include "./Python/interface/SBListener.i"
 %include "./Python/interface/SBModule.i"
+%include "./Python/interface/SBModuleSpec.i"
 %include "./Python/interface/SBProcess.i"
 %include "./Python/interface/SBSection.i"
 %include "./Python/interface/SBSourceManager.i"

Modified: lldb/trunk/source/API/SBFileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpec.cpp?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFileSpec.cpp (original)
+++ lldb/trunk/source/API/SBFileSpec.cpp Mon Jul  8 17:22:41 2013
@@ -21,25 +21,18 @@ using namespace lldb_private;
 
 
 SBFileSpec::SBFileSpec () :
-    m_opaque_ap()
+    m_opaque_ap(new lldb_private::FileSpec())
 {
 }
 
 SBFileSpec::SBFileSpec (const SBFileSpec &rhs) :
-    m_opaque_ap()
+    m_opaque_ap(new lldb_private::FileSpec(*rhs.m_opaque_ap))
 {
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
-    if (rhs.m_opaque_ap.get())
-        m_opaque_ap.reset (new FileSpec (rhs.get()));
+}
 
-    if (log)
-    {
-        SBStream sstr;
-        GetDescription (sstr);
-        log->Printf ("SBFileSpec::SBFileSpec (const SBFileSpec rhs.ap=%p) => SBFileSpec(%p): %s",
-                     rhs.m_opaque_ap.get(), m_opaque_ap.get(), sstr.GetData());
-    }
+SBFileSpec::SBFileSpec (const lldb_private::FileSpec& fspec) :
+    m_opaque_ap(new lldb_private::FileSpec(fspec))
+{
 }
 
 // Deprected!!!
@@ -51,11 +44,6 @@ SBFileSpec::SBFileSpec (const char *path
 SBFileSpec::SBFileSpec (const char *path, bool resolve) :
     m_opaque_ap(new FileSpec (path, resolve))
 {
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
-    if (log)
-        log->Printf ("SBFileSpec::SBFileSpec (path=\"%s\", resolve=%i) => SBFileSpec(%p)", path, 
-                     resolve, m_opaque_ap.get());
 }
 
 SBFileSpec::~SBFileSpec ()
@@ -66,17 +54,14 @@ const SBFileSpec &
 SBFileSpec::operator = (const SBFileSpec &rhs)
 {
     if (this != &rhs)
-    {
-        if (rhs.IsValid())
-            m_opaque_ap.reset (new lldb_private::FileSpec(*rhs.m_opaque_ap.get()));
-    }
+        *m_opaque_ap = *rhs.m_opaque_ap;
     return *this;
 }
 
 bool
 SBFileSpec::IsValid() const
 {
-    return m_opaque_ap.get() != NULL;
+    return *m_opaque_ap;
 }
 
 bool
@@ -84,9 +69,7 @@ SBFileSpec::Exists () const
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
-    bool result = false;
-    if (m_opaque_ap.get())
-        result = m_opaque_ap->Exists();
+    bool result = m_opaque_ap->Exists();
 
     if (log)
         log->Printf ("SBFileSpec(%p)::Exists () => %s", m_opaque_ap.get(), (result ? "true" : "false"));
@@ -97,9 +80,7 @@ SBFileSpec::Exists () const
 bool
 SBFileSpec::ResolveExecutableLocation ()
 {
-    if (m_opaque_ap.get())
-        return m_opaque_ap->ResolveExecutableLocation ();
-    return false;
+    return m_opaque_ap->ResolveExecutableLocation ();
 }
 
 int
@@ -111,9 +92,7 @@ SBFileSpec::ResolvePath (const char *src
 const char *
 SBFileSpec::GetFilename() const
 {
-    const char *s = NULL;
-    if (m_opaque_ap.get())
-        s = m_opaque_ap->GetFilename().AsCString();
+    const char *s = m_opaque_ap->GetFilename().AsCString();
 
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
@@ -130,9 +109,7 @@ SBFileSpec::GetFilename() const
 const char *
 SBFileSpec::GetDirectory() const
 {
-    const char *s = NULL;
-    if (m_opaque_ap.get())
-        s = m_opaque_ap->GetDirectory().AsCString();
+    const char *s = m_opaque_ap->GetDirectory().AsCString();
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
     {
@@ -149,9 +126,7 @@ SBFileSpec::GetPath (char *dst_path, siz
 {
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
-    uint32_t result = 0;
-    if (m_opaque_ap.get())
-        result = m_opaque_ap->GetPath (dst_path, dst_len);
+    uint32_t result = m_opaque_ap->GetPath (dst_path, dst_len);
 
     if (log)
         log->Printf ("SBFileSpec(%p)::GetPath (dst_path=\"%.*s\", dst_len=%" PRIu64 ") => %u",
@@ -192,24 +167,15 @@ SBFileSpec::ref() const
 void
 SBFileSpec::SetFileSpec (const lldb_private::FileSpec& fs)
 {
-    if (m_opaque_ap.get())
-        *m_opaque_ap = fs;
-    else
-        m_opaque_ap.reset (new FileSpec (fs));
+    *m_opaque_ap = fs;
 }
 
 bool
 SBFileSpec::GetDescription (SBStream &description) const
 {
     Stream &strm = description.ref();
-    if (m_opaque_ap.get())
-    {
-        char path[PATH_MAX];
-        if (m_opaque_ap->GetPath(path, sizeof(path)))
-            strm.PutCString (path);
-    }
-    else
-        strm.PutCString ("No value");
-    
+    char path[PATH_MAX];
+    if (m_opaque_ap->GetPath(path, sizeof(path)))
+        strm.PutCString (path);    
     return true;
 }

Modified: lldb/trunk/source/API/SBModule.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/source/API/SBModule.cpp (original)
+++ lldb/trunk/source/API/SBModule.cpp Mon Jul  8 17:22:41 2013
@@ -10,6 +10,7 @@
 #include "lldb/API/SBModule.h"
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBModuleSpec.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBSymbolContextList.h"
@@ -39,6 +40,19 @@ SBModule::SBModule (const lldb::ModuleSP
 {
 }
 
+SBModule::SBModule(const SBModuleSpec &module_spec) :
+    m_opaque_sp ()
+{
+    ModuleSP module_sp;
+    Error error = ModuleList::GetSharedModule (*module_spec.m_opaque_ap,
+                                               module_sp,
+                                               NULL,
+                                               NULL,
+                                               NULL);
+    if (module_sp)
+        SetSP(module_sp);
+}
+
 SBModule::SBModule(const SBModule &rhs) :
     m_opaque_sp (rhs.m_opaque_sp)
 {

Added: lldb/trunk/source/API/SBModuleSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModuleSpec.cpp?rev=185877&view=auto
==============================================================================
--- lldb/trunk/source/API/SBModuleSpec.cpp (added)
+++ lldb/trunk/source/API/SBModuleSpec.cpp Mon Jul  8 17:22:41 2013
@@ -0,0 +1,230 @@
+//===-- SBModuleSpec.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/SBModuleSpec.h"
+#include "lldb/API/SBStream.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Symbol/ObjectFile.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+
+SBModuleSpec::SBModuleSpec () :
+    m_opaque_ap (new lldb_private::ModuleSpec())
+{
+}
+
+SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs) :
+    m_opaque_ap (new lldb_private::ModuleSpec(*rhs.m_opaque_ap))
+{
+}
+
+const SBModuleSpec &
+SBModuleSpec::operator = (const SBModuleSpec &rhs)
+{
+    if (this != &rhs)
+        *m_opaque_ap = *(rhs.m_opaque_ap);
+    return *this;
+}
+
+SBModuleSpec::~SBModuleSpec ()
+{
+}
+
+bool
+SBModuleSpec::IsValid () const
+{
+    return *m_opaque_ap;
+}
+
+void
+SBModuleSpec::Clear()
+{
+    m_opaque_ap->Clear();
+}
+
+SBFileSpec
+SBModuleSpec::GetFileSpec ()
+{
+    SBFileSpec sb_spec(m_opaque_ap->GetFileSpec());
+    return sb_spec;
+}
+
+void
+SBModuleSpec::SetFileSpec (const lldb::SBFileSpec &sb_spec)
+{
+    m_opaque_ap->GetFileSpec() = *sb_spec;
+}
+
+lldb::SBFileSpec
+SBModuleSpec::GetPlatformFileSpec ()
+{
+    return SBFileSpec(m_opaque_ap->GetPlatformFileSpec());
+}
+
+void
+SBModuleSpec::SetPlatformFileSpec (const lldb::SBFileSpec &sb_spec)
+{
+    m_opaque_ap->GetPlatformFileSpec() = *sb_spec;
+}
+
+lldb::SBFileSpec
+SBModuleSpec::GetSymbolFileSpec ()
+{
+    return SBFileSpec(m_opaque_ap->GetSymbolFileSpec());
+}
+
+void
+SBModuleSpec::SetSymbolFileSpec (const lldb::SBFileSpec &sb_spec)
+{
+    m_opaque_ap->GetSymbolFileSpec() = *sb_spec;
+}
+
+const char *
+SBModuleSpec::GetObjectName ()
+{
+    return m_opaque_ap->GetObjectName().GetCString();
+}
+
+void
+SBModuleSpec::SetObjectName (const char *name)
+{
+    m_opaque_ap->GetObjectName().SetCString(name);
+}
+
+const char *
+SBModuleSpec::GetTriple ()
+{
+    std::string triple (m_opaque_ap->GetArchitecture().GetTriple().str());
+    // Unique the string so we don't run into ownership issues since
+    // the const strings put the string into the string pool once and
+    // the strings never comes out
+    ConstString const_triple (triple.c_str());
+    return const_triple.GetCString();
+}
+
+void
+SBModuleSpec::SetTriple (const char *triple)
+{
+    m_opaque_ap->GetArchitecture().SetTriple(triple);
+}
+
+const uint8_t *
+SBModuleSpec::GetUUIDBytes ()
+{
+    return (const uint8_t *)m_opaque_ap->GetUUID().GetBytes();
+}
+
+size_t
+SBModuleSpec::GetUUIDLength ()
+{
+    return m_opaque_ap->GetUUID().GetByteSize();
+}
+
+bool
+SBModuleSpec::SetUUIDBytes (const uint8_t *uuid, size_t uuid_len)
+{
+    return m_opaque_ap->GetUUID().SetBytes(uuid, uuid_len);
+}
+
+bool
+SBModuleSpec::GetDescription (lldb::SBStream &description)
+{
+    m_opaque_ap->Dump (description.ref());
+    return true;
+}
+
+SBModuleSpecList::SBModuleSpecList() :
+    m_opaque_ap(new ModuleSpecList())
+{
+    
+}
+
+SBModuleSpecList::SBModuleSpecList (const SBModuleSpecList &rhs) :
+    m_opaque_ap(new ModuleSpecList(*rhs.m_opaque_ap))
+{
+    
+}
+
+SBModuleSpecList &
+SBModuleSpecList::operator = (const SBModuleSpecList &rhs)
+{
+    if (this != &rhs)
+        *m_opaque_ap = *rhs.m_opaque_ap;
+    return *this;
+}
+
+SBModuleSpecList::~SBModuleSpecList()
+{
+    
+}
+
+SBModuleSpecList
+SBModuleSpecList::GetModuleSpecifications (const char *path)
+{
+    SBModuleSpecList specs;
+    FileSpec file_spec(path, true);
+    Host::ResolveExecutableInBundle(file_spec);
+    ObjectFile::GetModuleSpecifications(file_spec, 0, *specs.m_opaque_ap);
+    return specs;
+}
+
+void
+SBModuleSpecList::Append (const SBModuleSpec &spec)
+{
+    m_opaque_ap->Append (*spec.m_opaque_ap);
+}
+
+void
+SBModuleSpecList::Append (const SBModuleSpecList &spec_list)
+{
+    m_opaque_ap->Append (*spec_list.m_opaque_ap);
+}
+
+size_t
+SBModuleSpecList::GetSize()
+{
+    return m_opaque_ap->GetSize();
+}
+
+SBModuleSpec
+SBModuleSpecList::GetSpecAtIndex (size_t i)
+{
+    SBModuleSpec sb_module_spec;
+    m_opaque_ap->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_ap);
+    return sb_module_spec;
+}
+
+SBModuleSpec
+SBModuleSpecList::FindFirstMatchingSpec (const SBModuleSpec &match_spec)
+{
+    SBModuleSpec sb_module_spec;
+    m_opaque_ap->FindMatchingModuleSpec(*match_spec.m_opaque_ap, *sb_module_spec.m_opaque_ap);
+    return sb_module_spec;
+}
+
+SBModuleSpecList
+SBModuleSpecList::FindMatchingSpecs (const SBModuleSpec &match_spec)
+{
+    SBModuleSpecList specs;
+    m_opaque_ap->FindMatchingModuleSpecs(*match_spec.m_opaque_ap, *specs.m_opaque_ap);
+    return specs;
+    
+}
+
+bool
+SBModuleSpecList::GetDescription (lldb::SBStream &description)
+{
+    m_opaque_ap->Dump (description.ref());
+    return true;
+}

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Mon Jul  8 17:22:41 2013
@@ -19,6 +19,7 @@
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBListener.h"
 #include "lldb/API/SBModule.h"
+#include "lldb/API/SBModuleSpec.h"
 #include "lldb/API/SBSourceManager.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBStream.h"
@@ -1913,6 +1914,16 @@ SBTarget::AddModule (const char *path,
     return sb_module;
 }
 
+lldb::SBModule
+SBTarget::AddModule (const SBModuleSpec &module_spec)
+{
+    lldb::SBModule sb_module;
+    TargetSP target_sp(GetSP());
+    if (target_sp)
+        sb_module.SetSP(target_sp->GetSharedModule (*module_spec.m_opaque_ap));
+    return sb_module;
+}
+
 bool
 SBTarget::AddModule (lldb::SBModule &module)
 {

Modified: lldb/trunk/source/Core/UUID.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UUID.cpp?rev=185877&r1=185876&r2=185877&view=diff
==============================================================================
--- lldb/trunk/source/Core/UUID.cpp (original)
+++ lldb/trunk/source/Core/UUID.cpp Mon Jul  8 17:22:41 2013
@@ -105,25 +105,34 @@ UUID::Dump (Stream *s) const
     }
 }
 
-void
+bool
 UUID::SetBytes (const void *uuid_bytes, uint32_t num_uuid_bytes)
 {
-    if (uuid_bytes && num_uuid_bytes >= 20)
+    if (uuid_bytes)
     {
-        m_num_uuid_bytes = 20;
-        ::memcpy (m_uuid, uuid_bytes, m_num_uuid_bytes);
-    }
-    else if (uuid_bytes && num_uuid_bytes >= 16)
-    {
-        m_num_uuid_bytes = 16;
-        ::memcpy (m_uuid, uuid_bytes, m_num_uuid_bytes);
-        m_uuid[16] = m_uuid[17] = m_uuid[18] = m_uuid[19] = 0;
-    }
-    else
-    {
-        m_num_uuid_bytes = 16;
-        ::memset (m_uuid, 0, sizeof(m_uuid));
+        switch (num_uuid_bytes)
+        {
+            case 20:
+                m_num_uuid_bytes = 20;
+                break;
+            case 16:
+                m_num_uuid_bytes = 16;
+                m_uuid[16] = m_uuid[17] = m_uuid[18] = m_uuid[19] = 0;
+                break;
+            default:
+                // Unsupported UUID byte size
+                m_num_uuid_bytes = 0;
+                break;
+        }
+
+        if (m_num_uuid_bytes > 0)
+        {
+            ::memcpy (m_uuid, uuid_bytes, m_num_uuid_bytes);
+            return true;
+        }
     }
+    ::memset (m_uuid, 0, sizeof(m_uuid));
+    return false;
 }
 
 size_t





More information about the lldb-commits mailing list