[Lldb-commits] [lldb] r246131 - Add functionality to the platforms to figure out the proper name for a dynamic library on the system given a basename

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 26 17:53:58 PDT 2015


Author: enrico
Date: Wed Aug 26 19:53:57 2015
New Revision: 246131

URL: http://llvm.org/viewvc/llvm-project?rev=246131&view=rev
Log:
Add functionality to the platforms to figure out the proper name for a dynamic library on the system given a basename
This will do things like,
given mylibrary,
return

libmylibrary.dylib on OSX
mylibrary.dll on Windows

and so on for other platforms
It is currently implemented for Windows, Darwin, and Linux. Other platforms should fill in accordingly


Modified:
    lldb/trunk/include/lldb/Target/Platform.h
    lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
    lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
    lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
    lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h
    lldb/trunk/source/Target/Platform.cpp

Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=246131&r1=246130&r2=246131&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Wed Aug 26 19:53:57 2015
@@ -268,6 +268,9 @@ class ModuleCache;
 
         virtual const char *
         GetHostname ();
+        
+        virtual ConstString
+        GetFullNameForDylib (ConstString basename);
 
         virtual const char *
         GetDescription () = 0;

Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=246131&r1=246130&r2=246131&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Wed Aug 26 19:53:57 2015
@@ -854,3 +854,14 @@ PlatformLinux::ConvertMmapFlagsToPlatfor
         flags_platform |= map_anon;
     return flags_platform;
 }
+
+ConstString
+PlatformLinux::GetFullNameForDylib (ConstString basename)
+{
+    if (basename.IsEmpty())
+        return basename;
+    
+    StreamString stream;
+    stream.Printf("lib%s.so", basename.GetCString());
+    return ConstString(stream.GetData());
+}

Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h?rev=246131&r1=246130&r2=246131&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h Wed Aug 26 19:53:57 2015
@@ -111,6 +111,9 @@ namespace platform_linux {
         uint64_t
         ConvertMmapFlagsToPlatform(const ArchSpec &arch, unsigned flags) override;
 
+        ConstString
+        GetFullNameForDylib (ConstString basename) override;
+        
     private:
         DISALLOW_COPY_AND_ASSIGN (PlatformLinux);
     };

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=246131&r1=246130&r2=246131&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Wed Aug 26 19:53:57 2015
@@ -1531,3 +1531,15 @@ PlatformDarwin::AddClangModuleCompilatio
         options.push_back(sysroot_spec.GetPath());
     }
 }
+
+ConstString
+PlatformDarwin::GetFullNameForDylib (ConstString basename)
+{
+    if (basename.IsEmpty())
+        return basename;
+    
+    StreamString stream;
+    stream.Printf("lib%s.dylib", basename.GetCString());
+    return ConstString(stream.GetData());
+}
+

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h?rev=246131&r1=246130&r2=246131&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h Wed Aug 26 19:53:57 2015
@@ -84,6 +84,9 @@ public:
     
     bool
     SupportsModules () override { return true; }
+    
+    lldb_private::ConstString
+    GetFullNameForDylib (lldb_private::ConstString basename) override;
 
 protected:
 

Modified: lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp?rev=246131&r1=246130&r2=246131&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp Wed Aug 26 19:53:57 2015
@@ -743,3 +743,14 @@ PlatformWindows::GetEnvironment(StringLi
 
     return Host::GetEnvironment(env);
 }
+
+ConstString
+PlatformWindows::GetFullNameForDylib (ConstString basename)
+{
+    if (basename.IsEmpty())
+        return basename;
+    
+    StreamString stream;
+    stream.Printf("%s.dll", basename.GetCString());
+    return ConstString(stream.GetData());
+}

Modified: lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h?rev=246131&r1=246130&r2=246131&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h (original)
+++ lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.h Wed Aug 26 19:53:57 2015
@@ -156,6 +156,9 @@ public:
     CalculateTrapHandlerSymbolNames () override
     {
     }
+    
+    ConstString
+    GetFullNameForDylib (ConstString basename) override;
 
 protected:
     lldb::PlatformSP m_remote_platform_sp;

Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=246131&r1=246130&r2=246131&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Wed Aug 26 19:53:57 2015
@@ -947,6 +947,12 @@ Platform::GetHostname ()
     return m_name.c_str();
 }
 
+ConstString
+Platform::GetFullNameForDylib (ConstString basename)
+{
+    return basename;
+}
+
 bool
 Platform::SetRemoteWorkingDirectory(const FileSpec &working_dir)
 {




More information about the lldb-commits mailing list