[Lldb-commits] [lldb] r216606 - Update LLDB to use LLVM's DynamicLibrary.
Zachary Turner
zturner at google.com
Wed Aug 27 13:15:09 PDT 2014
Author: zturner
Date: Wed Aug 27 15:15:09 2014
New Revision: 216606
URL: http://llvm.org/viewvc/llvm-project?rev=216606&view=rev
Log:
Update LLDB to use LLVM's DynamicLibrary.
LLDB had implemented its own DynamicLibrary class for plugin
support. LLVM has an equivalent mechanism, so this patch deletes
the duplicated code in LLDB and updates LLDB to reference the
mechanism provided by LLVM.
Removed:
lldb/trunk/include/lldb/Host/DynamicLibrary.h
lldb/trunk/source/Host/common/DynamicLibrary.cpp
Modified:
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/include/lldb/Host/Host.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/PluginManager.cpp
lldb/trunk/source/Host/CMakeLists.txt
lldb/trunk/source/Host/common/Host.cpp
lldb/trunk/source/Host/windows/Host.cpp
Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=216606&r1=216605&r2=216606&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Wed Aug 27 15:15:09 2014
@@ -31,6 +31,14 @@
#include "lldb/Target/Platform.h"
#include "lldb/Target/TargetList.h"
+namespace llvm
+{
+namespace sys
+{
+class DynamicLibrary;
+}
+}
+
namespace lldb_private {
//----------------------------------------------------------------------
@@ -51,9 +59,9 @@ friend class SourceManager; // For GetS
public:
- typedef lldb::DynamicLibrarySP (*LoadPluginCallbackType) (const lldb::DebuggerSP &debugger_sp,
- const FileSpec& spec,
- Error& error);
+ typedef llvm::sys::DynamicLibrary (*LoadPluginCallbackType) (const lldb::DebuggerSP &debugger_sp,
+ const FileSpec& spec,
+ Error& error);
static lldb::DebuggerSP
CreateInstance (lldb::LogOutputCallback log_callback = NULL, void *baton = NULL);
@@ -422,7 +430,7 @@ protected:
lldb::StreamSP m_log_callback_stream_sp;
ConstString m_instance_name;
static LoadPluginCallbackType g_load_plugin_callback;
- typedef std::vector<lldb::DynamicLibrarySP> LoadedPluginsList;
+ typedef std::vector<llvm::sys::DynamicLibrary> LoadedPluginsList;
LoadedPluginsList m_loaded_plugins;
lldb::thread_t m_event_handler_thread;
lldb::thread_t m_io_handler_thread;
Removed: lldb/trunk/include/lldb/Host/DynamicLibrary.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/DynamicLibrary.h?rev=216605&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/DynamicLibrary.h (original)
+++ lldb/trunk/include/lldb/Host/DynamicLibrary.h (removed)
@@ -1,51 +0,0 @@
-//===-- DynamicLibrary.h -------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_DynamicLibrary_h_
-#define liblldb_DynamicLibrary_h_
-
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/Host.h"
-
-namespace lldb_private {
-
-class DynamicLibrary
-{
-public:
- DynamicLibrary (const FileSpec& spec, uint32_t options = Host::eDynamicLibraryOpenOptionLazy |
- Host::eDynamicLibraryOpenOptionLocal |
- Host::eDynamicLibraryOpenOptionLimitGetSymbol);
-
- ~DynamicLibrary ();
-
- template <typename T = void*>
- T GetSymbol (const char* name)
- {
- Error err;
- if (!m_handle)
- return static_cast<T>(NULL);
- void* symbol = Host::DynamicLibraryGetSymbol (m_handle, name, err);
- if (!symbol)
- return static_cast<T>(NULL);
- return *reinterpret_cast<T*>(&symbol);
- }
-
- bool
- IsValid ();
-
-private:
- lldb_private::FileSpec m_filespec;
- void* m_handle;
-
- DISALLOW_COPY_AND_ASSIGN (DynamicLibrary);
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_DynamicLibrary_h_
Modified: lldb/trunk/include/lldb/Host/Host.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=216606&r1=216605&r2=216606&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Host.h (original)
+++ lldb/trunk/include/lldb/Host/Host.h Wed Aug 27 15:15:09 2014
@@ -371,25 +371,6 @@ public:
static size_t
GetEnvironment (StringList &env);
-
- enum DynamicLibraryOpenOptions
- {
- eDynamicLibraryOpenOptionLazy = (1u << 0), // Lazily resolve symbols in this dynamic library
- eDynamicLibraryOpenOptionLocal = (1u << 1), // Only open a shared library with local access (hide it from the global symbol namespace)
- eDynamicLibraryOpenOptionLimitGetSymbol = (1u << 2) // DynamicLibraryGetSymbol calls on this handle will only return matches from this shared library
- };
- static void *
- DynamicLibraryOpen (const FileSpec &file_spec,
- uint32_t options,
- Error &error);
-
- static Error
- DynamicLibraryClose (void *dynamic_library_handle);
-
- static void *
- DynamicLibraryGetSymbol (void *dynamic_library_handle,
- const char *symbol_name,
- Error &error);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=216606&r1=216605&r2=216606&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Wed Aug 27 15:15:09 2014
@@ -80,7 +80,6 @@ class Debugger;
class Declaration;
class Disassembler;
struct DumpValueObjectOptions;
-class DynamicLibrary;
class DynamicLoader;
class Editline;
class EmulateInstruction;
@@ -301,7 +300,6 @@ namespace lldb {
typedef std::shared_ptr<lldb_private::Debugger> DebuggerSP;
typedef std::weak_ptr<lldb_private::Debugger> DebuggerWP;
typedef std::shared_ptr<lldb_private::Disassembler> DisassemblerSP;
- typedef std::shared_ptr<lldb_private::DynamicLibrary> DynamicLibrarySP;
typedef std::shared_ptr<lldb_private::DynamicLoader> DynamicLoaderSP;
typedef std::shared_ptr<lldb_private::Event> EventSP;
typedef std::shared_ptr<lldb_private::ExecutionContextRef> ExecutionContextRefSP;
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=216606&r1=216605&r2=216606&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Aug 27 15:15:09 2014
@@ -631,7 +631,6 @@
9443B123140C26AB0013457C /* SBData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9443B120140C18A90013457C /* SBData.h */; settings = {ATTRIBUTES = (Public, ); }; };
945215DF17F639EE00521C0B /* ValueObjectPrinter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945215DE17F639EE00521C0B /* ValueObjectPrinter.cpp */; };
9452573A16262D0200325455 /* SBDeclaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9452573916262D0200325455 /* SBDeclaration.cpp */; };
- 9456F2241616671900656F91 /* DynamicLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9456F2211616644B00656F91 /* DynamicLibrary.cpp */; };
945759671534941F005A9070 /* PlatformPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945759651534941F005A9070 /* PlatformPOSIX.cpp */; };
945759681534941F005A9070 /* PlatformPOSIX.h in Headers */ = {isa = PBXBuildFile; fileRef = 945759661534941F005A9070 /* PlatformPOSIX.h */; };
945E8D80152F6AB40019BCCD /* StreamGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945E8D7F152F6AB40019BCCD /* StreamGDBRemote.cpp */; };
@@ -1912,8 +1911,6 @@
9452573616262CD000325455 /* SBDeclaration.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBDeclaration.i; sourceTree = "<group>"; };
9452573816262CEF00325455 /* SBDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBDeclaration.h; path = include/lldb/API/SBDeclaration.h; sourceTree = "<group>"; };
9452573916262D0200325455 /* SBDeclaration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBDeclaration.cpp; path = source/API/SBDeclaration.cpp; sourceTree = "<group>"; };
- 9456F2211616644B00656F91 /* DynamicLibrary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicLibrary.cpp; sourceTree = "<group>"; };
- 9456F2231616645A00656F91 /* DynamicLibrary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DynamicLibrary.h; path = include/lldb/Host/DynamicLibrary.h; sourceTree = "<group>"; };
945759651534941F005A9070 /* PlatformPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PlatformPOSIX.cpp; path = POSIX/PlatformPOSIX.cpp; sourceTree = "<group>"; };
945759661534941F005A9070 /* PlatformPOSIX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformPOSIX.h; path = POSIX/PlatformPOSIX.h; sourceTree = "<group>"; };
945E8D7D152F6AA80019BCCD /* StreamGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamGDBRemote.h; path = include/lldb/Core/StreamGDBRemote.h; sourceTree = "<group>"; };
@@ -3506,7 +3503,6 @@
3FDFE53E19A2940E009756A7 /* windows */,
26BC7DD210F1B7D500F91463 /* Condition.h */,
266F5CBB12FC846200DFCE33 /* Config.h */,
- 9456F2231616645A00656F91 /* DynamicLibrary.h */,
26CFDCA01861638D000E63E5 /* Editline.h */,
26BC7DD310F1B7D500F91463 /* Endian.h */,
260C6EA013011578005E16B0 /* File.h */,
@@ -4096,7 +4092,6 @@
69A01E1A1236C5D400C660B5 /* common */ = {
isa = PBXGroup;
children = (
- 9456F2211616644B00656F91 /* DynamicLibrary.cpp */,
26CFDCA2186163A4000E63E5 /* Editline.cpp */,
260C6EA213011581005E16B0 /* File.cpp */,
26FA43171301048600E71120 /* FileSpec.cpp */,
@@ -4785,7 +4780,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 9456F2241616671900656F91 /* DynamicLibrary.cpp in Sources */,
26D1804216CEDF0700EDFB5B /* TimeSpecTimeout.cpp in Sources */,
2689FFDA13353D9D00698AC0 /* lldb.cpp in Sources */,
2689FFDB13353DA300698AC0 /* lldb-log.cpp in Sources */,
Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=216606&r1=216605&r2=216606&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Wed Aug 27 15:15:09 2014
@@ -38,13 +38,14 @@
#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/DataFormatters/DataVisualization.h"
-#include "lldb/Host/DynamicLibrary.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionGroupPlatform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/TargetList.h"
+#include "llvm/Support/DynamicLibrary.h"
+
using namespace lldb;
using namespace lldb_private;
@@ -72,22 +73,22 @@ SBInputReader::IsActive() const
return false;
}
-static lldb::DynamicLibrarySP
+static llvm::sys::DynamicLibrary
LoadPlugin (const lldb::DebuggerSP &debugger_sp, const FileSpec& spec, Error& error)
{
- lldb::DynamicLibrarySP dynlib_sp(new lldb_private::DynamicLibrary(spec));
- if (dynlib_sp && dynlib_sp->IsValid())
+ llvm::sys::DynamicLibrary dynlib = llvm::sys::DynamicLibrary::getPermanentLibrary(spec.GetPath().c_str());
+ if (dynlib.isValid())
{
typedef bool (*LLDBCommandPluginInit) (lldb::SBDebugger& debugger);
lldb::SBDebugger debugger_sb(debugger_sp);
// This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger) function.
// TODO: mangle this differently for your system - on OSX, the first underscore needs to be removed and the second one stays
- LLDBCommandPluginInit init_func = dynlib_sp->GetSymbol<LLDBCommandPluginInit>("_ZN4lldb16PluginInitializeENS_10SBDebuggerE");
+ LLDBCommandPluginInit init_func = (LLDBCommandPluginInit)dynlib.getAddressOfSymbol("_ZN4lldb16PluginInitializeENS_10SBDebuggerE");
if (init_func)
{
if (init_func(debugger_sb))
- return dynlib_sp;
+ return dynlib;
else
error.SetErrorString("plug-in refused to load (lldb::PluginInitialize(lldb::SBDebugger) returned false)");
}
@@ -103,7 +104,7 @@ LoadPlugin (const lldb::DebuggerSP &debu
else
error.SetErrorString("no such file");
}
- return lldb::DynamicLibrarySP();
+ return llvm::sys::DynamicLibrary();
}
void
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=216606&r1=216605&r2=216606&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Wed Aug 27 15:15:09 2014
@@ -34,7 +34,6 @@
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/DataFormatters/TypeSummary.h"
-#include "lldb/Host/DynamicLibrary.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/Terminal.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -54,6 +53,8 @@
#include "lldb/Target/Thread.h"
#include "lldb/Utility/AnsiTerminal.h"
+#include "llvm/Support/DynamicLibrary.h"
+
using namespace lldb;
using namespace lldb_private;
@@ -413,10 +414,10 @@ Debugger::LoadPlugin (const FileSpec& sp
{
if (g_load_plugin_callback)
{
- lldb::DynamicLibrarySP dynlib_sp = g_load_plugin_callback (shared_from_this(), spec, error);
- if (dynlib_sp)
+ llvm::sys::DynamicLibrary dynlib = g_load_plugin_callback (shared_from_this(), spec, error);
+ if (dynlib.isValid())
{
- m_loaded_plugins.push_back(dynlib_sp);
+ m_loaded_plugins.push_back(dynlib);
return true;
}
}
Modified: lldb/trunk/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=216606&r1=216605&r2=216606&view=diff
==============================================================================
--- lldb/trunk/source/Core/PluginManager.cpp (original)
+++ lldb/trunk/source/Core/PluginManager.cpp Wed Aug 27 15:15:09 2014
@@ -25,6 +25,7 @@
#include "lldb/Interpreter/OptionValueProperties.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/DynamicLibrary.h"
using namespace lldb;
using namespace lldb_private;
@@ -42,7 +43,12 @@ typedef void (*PluginTermCallback) (void
struct PluginInfo
{
- void *plugin_handle;
+ PluginInfo()
+ : plugin_init_callback(nullptr), plugin_term_callback(nullptr)
+ {
+ }
+
+ llvm::sys::DynamicLibrary library;
PluginInitCallback plugin_init_callback;
PluginTermCallback plugin_term_callback;
};
@@ -113,20 +119,15 @@ LoadPluginCallback
return FileSpec::eEnumerateDirectoryResultNext;
else
{
- PluginInfo plugin_info = { NULL, NULL, NULL };
- uint32_t flags = Host::eDynamicLibraryOpenOptionLazy |
- Host::eDynamicLibraryOpenOptionLocal |
- Host::eDynamicLibraryOpenOptionLimitGetSymbol;
+ PluginInfo plugin_info;
- plugin_info.plugin_handle = Host::DynamicLibraryOpen (plugin_file_spec, flags, error);
- if (plugin_info.plugin_handle)
+ std::string pluginLoadError;
+ plugin_info.library = llvm::sys::DynamicLibrary::getPermanentLibrary (plugin_file_spec.GetPath().c_str(), &pluginLoadError);
+ if (plugin_info.library.isValid())
{
bool success = false;
plugin_info.plugin_init_callback =
- CastToFPtr<PluginInitCallback>(
- Host::DynamicLibraryGetSymbol(plugin_info.plugin_handle,
- "LLDBPluginInitialize",
- error));
+ CastToFPtr<PluginInitCallback>(plugin_info.library.getAddressOfSymbol("LLDBPluginInitialize"));
if (plugin_info.plugin_init_callback)
{
// Call the plug-in "bool LLDBPluginInitialize(void)" function
@@ -137,19 +138,14 @@ LoadPluginCallback
{
// It is ok for the "LLDBPluginTerminate" symbol to be NULL
plugin_info.plugin_term_callback =
- CastToFPtr<PluginTermCallback>(
- Host::DynamicLibraryGetSymbol(
- plugin_info.plugin_handle, "LLDBPluginTerminate",
- error));
+ CastToFPtr<PluginTermCallback>(plugin_info.library.getAddressOfSymbol("LLDBPluginTerminate"));
}
else
{
- // The initialize function returned FALSE which means the
- // plug-in might not be compatible, or might be too new or
- // too old, or might not want to run on this machine.
- Host::DynamicLibraryClose (plugin_info.plugin_handle);
- plugin_info.plugin_handle = NULL;
- plugin_info.plugin_init_callback = NULL;
+ // The initialize function returned FALSE which means the plug-in might not be
+ // compatible, or might be too new or too old, or might not want to run on this
+ // machine. Set it to a default-constructed instance to invalidate it.
+ plugin_info = PluginInfo();
}
// Regardless of success or failure, cache the plug-in load
@@ -225,11 +221,10 @@ PluginManager::Terminate ()
{
// Call the plug-in "void LLDBPluginTerminate (void)" function if there
// is one (if the symbol was not NULL).
- if (pos->second.plugin_handle)
+ if (pos->second.library.isValid())
{
if (pos->second.plugin_term_callback)
pos->second.plugin_term_callback();
- Host::DynamicLibraryClose (pos->second.plugin_handle);
}
}
plugin_map.clear();
Modified: lldb/trunk/source/Host/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/CMakeLists.txt?rev=216606&r1=216605&r2=216606&view=diff
==============================================================================
--- lldb/trunk/source/Host/CMakeLists.txt (original)
+++ lldb/trunk/source/Host/CMakeLists.txt Wed Aug 27 15:15:09 2014
@@ -5,7 +5,6 @@ endmacro()
add_host_subdirectory(common
common/Condition.cpp
- common/DynamicLibrary.cpp
common/Editline.cpp
common/File.cpp
common/FileCache.cpp
Removed: lldb/trunk/source/Host/common/DynamicLibrary.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/DynamicLibrary.cpp?rev=216605&view=auto
==============================================================================
--- lldb/trunk/source/Host/common/DynamicLibrary.cpp (original)
+++ lldb/trunk/source/Host/common/DynamicLibrary.cpp (removed)
@@ -1,33 +0,0 @@
-//===-- DynamicLibrary.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/Core/Error.h"
-#include "lldb/Host/DynamicLibrary.h"
-
-using namespace lldb_private;
-
-DynamicLibrary::DynamicLibrary (const FileSpec& spec, uint32_t options) : m_filespec(spec)
-{
- Error err;
- m_handle = Host::DynamicLibraryOpen (spec,options,err);
- if (err.Fail())
- m_handle = NULL;
-}
-
-bool
-DynamicLibrary::IsValid ()
-{
- return m_handle != NULL;
-}
-
-DynamicLibrary::~DynamicLibrary ()
-{
- if (m_handle)
- Host::DynamicLibraryClose (m_handle);
-}
Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=216606&r1=216605&r2=216606&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Wed Aug 27 15:15:09 2014
@@ -664,130 +664,6 @@ Host::ResolveExecutableInBundle (FileSpe
#ifndef _WIN32
-// Opaque info that tracks a dynamic library that was loaded
-struct DynamicLibraryInfo
-{
- DynamicLibraryInfo (const FileSpec &fs, int o, void *h) :
- file_spec (fs),
- open_options (o),
- handle (h)
- {
- }
-
- const FileSpec file_spec;
- uint32_t open_options;
- void * handle;
-};
-
-void *
-Host::DynamicLibraryOpen (const FileSpec &file_spec, uint32_t options, Error &error)
-{
- char path[PATH_MAX];
- if (file_spec.GetPath(path, sizeof(path)))
- {
- int mode = 0;
-
- if (options & eDynamicLibraryOpenOptionLazy)
- mode |= RTLD_LAZY;
- else
- mode |= RTLD_NOW;
-
-
- if (options & eDynamicLibraryOpenOptionLocal)
- mode |= RTLD_LOCAL;
- else
- mode |= RTLD_GLOBAL;
-
-#ifdef LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED
- if (options & eDynamicLibraryOpenOptionLimitGetSymbol)
- mode |= RTLD_FIRST;
-#endif
-
- void * opaque = ::dlopen (path, mode);
-
- if (opaque)
- {
- error.Clear();
- return new DynamicLibraryInfo (file_spec, options, opaque);
- }
- else
- {
- error.SetErrorString(::dlerror());
- }
- }
- else
- {
- error.SetErrorString("failed to extract path");
- }
- return NULL;
-}
-
-Error
-Host::DynamicLibraryClose (void *opaque)
-{
- Error error;
- if (opaque == NULL)
- {
- error.SetErrorString ("invalid dynamic library handle");
- }
- else
- {
- DynamicLibraryInfo *dylib_info = (DynamicLibraryInfo *) opaque;
- if (::dlclose (dylib_info->handle) != 0)
- {
- error.SetErrorString(::dlerror());
- }
-
- dylib_info->open_options = 0;
- dylib_info->handle = 0;
- delete dylib_info;
- }
- return error;
-}
-
-void *
-Host::DynamicLibraryGetSymbol (void *opaque, const char *symbol_name, Error &error)
-{
- if (opaque == NULL)
- {
- error.SetErrorString ("invalid dynamic library handle");
- }
- else
- {
- DynamicLibraryInfo *dylib_info = (DynamicLibraryInfo *) opaque;
-
- void *symbol_addr = ::dlsym (dylib_info->handle, symbol_name);
- if (symbol_addr)
- {
-#ifndef LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED
- // This host doesn't support limiting searches to this shared library
- // so we need to verify that the match came from this shared library
- // if it was requested in the Host::DynamicLibraryOpen() function.
- if (dylib_info->open_options & eDynamicLibraryOpenOptionLimitGetSymbol)
- {
- FileSpec match_dylib_spec (Host::GetModuleFileSpecForHostAddress (symbol_addr));
- if (match_dylib_spec != dylib_info->file_spec)
- {
- char dylib_path[PATH_MAX];
- if (dylib_info->file_spec.GetPath (dylib_path, sizeof(dylib_path)))
- error.SetErrorStringWithFormat ("symbol not found in \"%s\"", dylib_path);
- else
- error.SetErrorString ("symbol not found");
- return NULL;
- }
- }
-#endif
- error.Clear();
- return symbol_addr;
- }
- else
- {
- error.SetErrorString(::dlerror());
- }
- }
- return NULL;
-}
-
FileSpec
Host::GetModuleFileSpecForHostAddress (const void *host_addr)
{
Modified: lldb/trunk/source/Host/windows/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Host.cpp?rev=216606&r1=216605&r2=216606&view=diff
==============================================================================
--- lldb/trunk/source/Host/windows/Host.cpp (original)
+++ lldb/trunk/source/Host/windows/Host.cpp Wed Aug 27 15:15:09 2014
@@ -213,28 +213,6 @@ Host::GetModuleFileSpecForHostAddress (c
return module_filespec;
}
-void *
-Host::DynamicLibraryOpen(const FileSpec &file_spec, uint32_t options, Error &error)
-{
- error.SetErrorString("not implemented");
- return NULL;
-}
-
-Error
-Host::DynamicLibraryClose (void *opaque)
-{
- Error error;
- error.SetErrorString("not implemented");
- return error;
-}
-
-void *
-Host::DynamicLibraryGetSymbol(void *opaque, const char *symbol_name, Error &error)
-{
- error.SetErrorString("not implemented");
- return NULL;
-}
-
uint32_t
Host::FindProcesses (const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &process_infos)
{
More information about the lldb-commits
mailing list