diff options
| author | Greg Clayton <gclayton@apple.com> | 2013-07-08 22:22:41 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2013-07-08 22:22:41 +0000 |
| commit | 226cce25116af0f3132941b27492f349f62052a4 (patch) | |
| tree | aeee7174537ac09c746b680bcf52cf298ed2a7c0 | |
| parent | 8bad86c81be924bdfe1814da69dafda8b0237503 (diff) | |
| download | bcm5719-llvm-226cce25116af0f3132941b27492f349f62052a4.tar.gz bcm5719-llvm-226cce25116af0f3132941b27492f349f62052a4.zip | |
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.
llvm-svn: 185877
| -rw-r--r-- | lldb/include/lldb/API/SBDefines.h | 2 | ||||
| -rw-r--r-- | lldb/include/lldb/API/SBFileSpec.h | 5 | ||||
| -rw-r--r-- | lldb/include/lldb/API/SBModule.h | 2 | ||||
| -rw-r--r-- | lldb/include/lldb/API/SBModuleSpec.h | 154 | ||||
| -rw-r--r-- | lldb/include/lldb/API/SBStream.h | 2 | ||||
| -rw-r--r-- | lldb/include/lldb/API/SBTarget.h | 4 | ||||
| -rw-r--r-- | lldb/include/lldb/Core/ModuleSpec.h | 230 | ||||
| -rw-r--r-- | lldb/include/lldb/Core/UUID.h | 2 | ||||
| -rw-r--r-- | lldb/lldb.xcodeproj/project.pbxproj | 10 | ||||
| -rwxr-xr-x | lldb/scripts/Python/build-swig-Python.sh | 2 | ||||
| -rw-r--r-- | lldb/scripts/Python/interface/SBModule.i | 4 | ||||
| -rw-r--r-- | lldb/scripts/Python/interface/SBModuleSpec.i | 133 | ||||
| -rw-r--r-- | lldb/scripts/Python/interface/SBTarget.i | 3 | ||||
| -rw-r--r-- | lldb/scripts/Python/python-extensions.swig | 31 | ||||
| -rw-r--r-- | lldb/scripts/lldb.swig | 2 | ||||
| -rw-r--r-- | lldb/source/API/SBFileSpec.cpp | 68 | ||||
| -rw-r--r-- | lldb/source/API/SBModule.cpp | 14 | ||||
| -rw-r--r-- | lldb/source/API/SBModuleSpec.cpp | 230 | ||||
| -rw-r--r-- | lldb/source/API/SBTarget.cpp | 11 | ||||
| -rw-r--r-- | lldb/source/Core/UUID.cpp | 39 |
20 files changed, 842 insertions, 106 deletions
diff --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h index 2388c36b35d..2cdf92170d8 100644 --- a/lldb/include/lldb/API/SBDefines.h +++ b/lldb/include/lldb/API/SBDefines.h @@ -54,6 +54,8 @@ class SBInstructionList; class SBLineEntry; class SBListener; class SBModule; +class SBModuleSpec; +class SBModuleSpecList; class SBProcess; class SBSourceManager; class SBStream; diff --git a/lldb/include/lldb/API/SBFileSpec.h b/lldb/include/lldb/API/SBFileSpec.h index cc657b7a1a9..e44abe4759c 100644 --- a/lldb/include/lldb/API/SBFileSpec.h +++ b/lldb/include/lldb/API/SBFileSpec.h @@ -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; diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h index 53d2d711d8b..a3c4879aa2f 100644 --- a/lldb/include/lldb/API/SBModule.h +++ b/lldb/include/lldb/API/SBModule.h @@ -26,6 +26,8 @@ public: SBModule (const SBModule &rhs); + SBModule (const SBModuleSpec &module_spec); + const SBModule & operator = (const SBModule &rhs); diff --git a/lldb/include/lldb/API/SBModuleSpec.h b/lldb/include/lldb/API/SBModuleSpec.h new file mode 100644 index 00000000000..a615e017cbc --- /dev/null +++ b/lldb/include/lldb/API/SBModuleSpec.h @@ -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_ diff --git a/lldb/include/lldb/API/SBStream.h b/lldb/include/lldb/API/SBStream.h index 5d038be5082..038adf68542 100644 --- a/lldb/include/lldb/API/SBStream.h +++ b/lldb/include/lldb/API/SBStream.h @@ -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; diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 2434623e0e6..15aeed4b600 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -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; diff --git a/lldb/include/lldb/Core/ModuleSpec.h b/lldb/include/lldb/Core/ModuleSpec.h index 9882b243ca4..67bd4ba3dd1 100644 --- a/lldb/include/lldb/Core/ModuleSpec.h +++ b/lldb/include/lldb/Core/ModuleSpec.h @@ -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. diff --git a/lldb/include/lldb/Core/UUID.h b/lldb/include/lldb/Core/UUID.h index 8a1a173ac30..fe72b8eb0c7 100644 --- a/lldb/include/lldb/Core/UUID.h +++ b/lldb/include/lldb/Core/UUID.h @@ -52,7 +52,7 @@ public: bool IsValid () const; - void + bool SetBytes (const void *uuid_bytes, uint32_t num_uuid_bytes = 16); std::string diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index b96a15043ef..e7c5938406e 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -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 */, diff --git a/lldb/scripts/Python/build-swig-Python.sh b/lldb/scripts/Python/build-swig-Python.sh index 96c4b2b73f6..28e7df91c1c 100755 --- a/lldb/scripts/Python/build-swig-Python.sh +++ b/lldb/scripts/Python/build-swig-Python.sh @@ -105,6 +105,7 @@ HEADER_FILES="${SRC_ROOT}/include/lldb/lldb.h"\ " ${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/Python/interface/SBAddress.i"\ " ${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"\ diff --git a/lldb/scripts/Python/interface/SBModule.i b/lldb/scripts/Python/interface/SBModule.i index aa2571c1090..fdf017754d0 100644 --- a/lldb/scripts/Python/interface/SBModule.i +++ b/lldb/scripts/Python/interface/SBModule.i @@ -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); diff --git a/lldb/scripts/Python/interface/SBModuleSpec.i b/lldb/scripts/Python/interface/SBModuleSpec.i new file mode 100644 index 00000000000..55fd9b1a043 --- /dev/null +++ b/lldb/scripts/Python/interface/SBModuleSpec.i @@ -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 diff --git a/lldb/scripts/Python/interface/SBTarget.i b/lldb/scripts/Python/interface/SBTarget.i index e7dba2a7a00..a171d6f087a 100644 --- a/lldb/scripts/Python/interface/SBTarget.i +++ b/lldb/scripts/Python/interface/SBTarget.i @@ -515,6 +515,9 @@ public: const char *uuid_cstr, const char *symfile); + lldb::SBModule + AddModule (const SBModuleSpec &module_spec); + uint32_t GetNumModules () const; diff --git a/lldb/scripts/Python/python-extensions.swig b/lldb/scripts/Python/python-extensions.swig index 14dc044856e..c4bc8b9141b 100644 --- a/lldb/scripts/Python/python-extensions.swig +++ b/lldb/scripts/Python/python-extensions.swig @@ -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; diff --git a/lldb/scripts/lldb.swig b/lldb/scripts/lldb.swig index b813f516e4b..6be699f42c1 100644 --- a/lldb/scripts/lldb.swig +++ b/lldb/scripts/lldb.swig @@ -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" diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp index cedff0386e8..4413689501a 100644 --- a/lldb/source/API/SBFileSpec.cpp +++ b/lldb/source/API/SBFileSpec.cpp @@ -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_path, char *dst_path, size_t dst_len) 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, size_t dst_len) const { 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; } diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 11a2c6c419d..661fa56a867 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -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& module_sp) : { } +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) { diff --git a/lldb/source/API/SBModuleSpec.cpp b/lldb/source/API/SBModuleSpec.cpp new file mode 100644 index 00000000000..8b7ac1d86f9 --- /dev/null +++ b/lldb/source/API/SBModuleSpec.cpp @@ -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; +} diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 42f4ca1c313..7e47fbf0187 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -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) { diff --git a/lldb/source/Core/UUID.cpp b/lldb/source/Core/UUID.cpp index 8b2158b88e2..c1b3eb13d65 100644 --- a/lldb/source/Core/UUID.cpp +++ b/lldb/source/Core/UUID.cpp @@ -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) - { - m_num_uuid_bytes = 20; - ::memcpy (m_uuid, uuid_bytes, m_num_uuid_bytes); - } - else if (uuid_bytes && num_uuid_bytes >= 16) + if (uuid_bytes) { - 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 |

