2010-06-09 00:52:24 +08:00
|
|
|
//===-- PluginManager.cpp ---------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-05 08:20:57 +08:00
|
|
|
#include "lldb/lldb-python.h"
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/PluginManager.h"
|
|
|
|
|
2011-04-08 21:36:44 +08:00
|
|
|
#include <limits.h>
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2012-10-20 02:02:49 +08:00
|
|
|
#include "lldb/Core/Debugger.h"
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
#include "lldb/Core/Error.h"
|
2011-02-08 13:05:52 +08:00
|
|
|
#include "lldb/Host/FileSpec.h"
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
#include "lldb/Host/Host.h"
|
|
|
|
#include "lldb/Host/Mutex.h"
|
2012-10-20 02:02:49 +08:00
|
|
|
#include "lldb/Interpreter/OptionValueProperties.h"
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
using namespace lldb;
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb_private;
|
|
|
|
|
2010-06-12 07:44:18 +08:00
|
|
|
enum PluginAction
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
ePluginRegisterInstance,
|
|
|
|
ePluginUnregisterInstance,
|
|
|
|
ePluginGetInstanceAtIndex
|
|
|
|
};
|
|
|
|
|
2013-04-20 05:31:16 +08:00
|
|
|
|
|
|
|
typedef bool (*PluginInitCallback) (void);
|
|
|
|
typedef void (*PluginTermCallback) (void);
|
|
|
|
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
struct PluginInfo
|
|
|
|
{
|
|
|
|
void *plugin_handle;
|
2013-04-20 05:31:16 +08:00
|
|
|
PluginInitCallback plugin_init_callback;
|
|
|
|
PluginTermCallback plugin_term_callback;
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::map<FileSpec, PluginInfo> PluginTerminateMap;
|
|
|
|
|
|
|
|
static Mutex &
|
|
|
|
GetPluginMapMutex ()
|
|
|
|
{
|
|
|
|
static Mutex g_plugin_map_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_plugin_map_mutex;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PluginTerminateMap &
|
|
|
|
GetPluginMap ()
|
|
|
|
{
|
|
|
|
static PluginTerminateMap g_plugin_map;
|
|
|
|
return g_plugin_map;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
PluginIsLoaded (const FileSpec &plugin_file_spec)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetPluginMapMutex ());
|
|
|
|
PluginTerminateMap &plugin_map = GetPluginMap ();
|
|
|
|
return plugin_map.find (plugin_file_spec) != plugin_map.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
SetPluginInfo (const FileSpec &plugin_file_spec, const PluginInfo &plugin_info)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetPluginMapMutex ());
|
|
|
|
PluginTerminateMap &plugin_map = GetPluginMap ();
|
2013-07-17 08:26:30 +08:00
|
|
|
assert (plugin_map.find (plugin_file_spec) == plugin_map.end());
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
plugin_map[plugin_file_spec] = plugin_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FileSpec::EnumerateDirectoryResult
|
|
|
|
LoadPluginCallback
|
|
|
|
(
|
|
|
|
void *baton,
|
|
|
|
FileSpec::FileType file_type,
|
|
|
|
const FileSpec &file_spec
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// PluginManager *plugin_manager = (PluginManager *)baton;
|
|
|
|
Error error;
|
|
|
|
|
|
|
|
// If we have a regular file, a symbolic link or unknown file type, try
|
|
|
|
// and process the file. We must handle unknown as sometimes the directory
|
|
|
|
// enumeration might be enumerating a file system that doesn't have correct
|
|
|
|
// file type information.
|
|
|
|
if (file_type == FileSpec::eFileTypeRegular ||
|
|
|
|
file_type == FileSpec::eFileTypeSymbolicLink ||
|
|
|
|
file_type == FileSpec::eFileTypeUnknown )
|
|
|
|
{
|
|
|
|
FileSpec plugin_file_spec (file_spec);
|
|
|
|
plugin_file_spec.ResolvePath();
|
|
|
|
|
|
|
|
if (PluginIsLoaded (plugin_file_spec))
|
|
|
|
return FileSpec::eEnumerateDirectoryResultNext;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PluginInfo plugin_info = { NULL, NULL, NULL };
|
2011-02-08 08:35:34 +08:00
|
|
|
uint32_t flags = Host::eDynamicLibraryOpenOptionLazy |
|
|
|
|
Host::eDynamicLibraryOpenOptionLocal |
|
|
|
|
Host::eDynamicLibraryOpenOptionLimitGetSymbol;
|
|
|
|
|
|
|
|
plugin_info.plugin_handle = Host::DynamicLibraryOpen (plugin_file_spec, flags, error);
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
if (plugin_info.plugin_handle)
|
|
|
|
{
|
|
|
|
bool success = false;
|
2013-04-20 05:31:16 +08:00
|
|
|
plugin_info.plugin_init_callback = (PluginInitCallback)Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginInitialize", error);
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
if (plugin_info.plugin_init_callback)
|
|
|
|
{
|
|
|
|
// Call the plug-in "bool LLDBPluginInitialize(void)" function
|
2013-04-20 05:31:16 +08:00
|
|
|
success = plugin_info.plugin_init_callback();
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
// It is ok for the "LLDBPluginTerminate" symbol to be NULL
|
2013-04-20 05:31:16 +08:00
|
|
|
plugin_info.plugin_term_callback = (PluginTermCallback)Host::DynamicLibraryGetSymbol (plugin_info.plugin_handle, "LLDBPluginTerminate", error);
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Regardless of success or failure, cache the plug-in load
|
|
|
|
// in our plug-in info so we don't try to load it again and
|
|
|
|
// again.
|
|
|
|
SetPluginInfo (plugin_file_spec, plugin_info);
|
|
|
|
|
|
|
|
return FileSpec::eEnumerateDirectoryResultNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file_type == FileSpec::eFileTypeUnknown ||
|
|
|
|
file_type == FileSpec::eFileTypeDirectory ||
|
|
|
|
file_type == FileSpec::eFileTypeSymbolicLink )
|
|
|
|
{
|
|
|
|
// Try and recurse into anything that a directory or symbolic link.
|
|
|
|
// We must also do this for unknown as sometimes the directory enumeration
|
|
|
|
// might be enurating a file system that doesn't have correct file type
|
|
|
|
// information.
|
|
|
|
return FileSpec::eEnumerateDirectoryResultEnter;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FileSpec::eEnumerateDirectoryResultNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginManager::Initialize ()
|
|
|
|
{
|
2011-03-24 12:28:38 +08:00
|
|
|
#if 1
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
FileSpec dir_spec;
|
|
|
|
const bool find_directories = true;
|
|
|
|
const bool find_files = true;
|
|
|
|
const bool find_other = true;
|
|
|
|
char dir_path[PATH_MAX];
|
|
|
|
if (Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec))
|
|
|
|
{
|
|
|
|
if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path)))
|
|
|
|
{
|
|
|
|
FileSpec::EnumerateDirectory (dir_path,
|
|
|
|
find_directories,
|
|
|
|
find_files,
|
|
|
|
find_other,
|
|
|
|
LoadPluginCallback,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec))
|
|
|
|
{
|
|
|
|
if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path)))
|
|
|
|
{
|
|
|
|
FileSpec::EnumerateDirectory (dir_path,
|
|
|
|
find_directories,
|
|
|
|
find_files,
|
|
|
|
find_other,
|
|
|
|
LoadPluginCallback,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
}
|
2011-03-24 12:28:38 +08:00
|
|
|
#endif
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginManager::Terminate ()
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetPluginMapMutex ());
|
|
|
|
PluginTerminateMap &plugin_map = GetPluginMap ();
|
|
|
|
|
|
|
|
PluginTerminateMap::const_iterator pos, end = plugin_map.end();
|
|
|
|
for (pos = plugin_map.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
// 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.plugin_term_callback)
|
2013-04-20 05:31:16 +08:00
|
|
|
pos->second.plugin_term_callback();
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
Host::DynamicLibraryClose (pos->second.plugin_handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
plugin_map.clear();
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
#pragma mark ABI
|
|
|
|
|
|
|
|
|
2010-06-12 07:44:18 +08:00
|
|
|
struct ABIInstance
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
ABIInstance() :
|
|
|
|
name(),
|
|
|
|
description(),
|
|
|
|
create_callback(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2010-06-09 00:52:24 +08:00
|
|
|
std::string description;
|
|
|
|
ABICreateInstance create_callback;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<ABIInstance> ABIInstances;
|
|
|
|
|
2011-03-19 09:12:21 +08:00
|
|
|
static Mutex &
|
|
|
|
GetABIInstancesMutex ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-03-19 09:12:21 +08:00
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-03-19 09:12:21 +08:00
|
|
|
static ABIInstances &
|
|
|
|
GetABIInstances ()
|
|
|
|
{
|
|
|
|
static ABIInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::RegisterPlugin
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
(
|
2013-05-11 05:47:16 +08:00
|
|
|
const ConstString &name,
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
const char *description,
|
|
|
|
ABICreateInstance create_callback
|
|
|
|
)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
ABIInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
|
|
|
instance.name = name;
|
2010-06-09 00:52:24 +08:00
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
2011-03-19 09:12:21 +08:00
|
|
|
Mutex::Locker locker (GetABIInstancesMutex ());
|
|
|
|
GetABIInstances ().push_back (instance);
|
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (ABICreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-03-19 09:12:21 +08:00
|
|
|
Mutex::Locker locker (GetABIInstancesMutex ());
|
|
|
|
ABIInstances &instances = GetABIInstances ();
|
|
|
|
|
|
|
|
ABIInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ABICreateInstance
|
|
|
|
PluginManager::GetABICreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-03-19 09:12:21 +08:00
|
|
|
Mutex::Locker locker (GetABIInstancesMutex ());
|
|
|
|
ABIInstances &instances = GetABIInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
2010-06-12 07:44:18 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ABICreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetABICreateCallbackForPluginName (const ConstString &name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-03-19 09:12:21 +08:00
|
|
|
Mutex::Locker locker (GetABIInstancesMutex ());
|
|
|
|
ABIInstances &instances = GetABIInstances ();
|
|
|
|
|
|
|
|
ABIInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-03-19 09:12:21 +08:00
|
|
|
return pos->create_callback;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark Disassembler
|
|
|
|
|
|
|
|
|
2010-06-12 07:44:18 +08:00
|
|
|
struct DisassemblerInstance
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
DisassemblerInstance() :
|
|
|
|
name(),
|
|
|
|
description(),
|
|
|
|
create_callback(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2010-06-09 00:52:24 +08:00
|
|
|
std::string description;
|
|
|
|
DisassemblerCreateInstance create_callback;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<DisassemblerInstance> DisassemblerInstances;
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex &
|
|
|
|
GetDisassemblerMutex ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static DisassemblerInstances &
|
|
|
|
GetDisassemblerInstances ()
|
|
|
|
{
|
|
|
|
static DisassemblerInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::RegisterPlugin
|
|
|
|
(
|
2013-05-11 05:47:16 +08:00
|
|
|
const ConstString &name,
|
2010-06-09 00:52:24 +08:00
|
|
|
const char *description,
|
|
|
|
DisassemblerCreateInstance create_callback
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
DisassemblerInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
2010-06-09 00:52:24 +08:00
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetDisassemblerMutex ());
|
|
|
|
GetDisassemblerInstances ().push_back (instance);
|
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (DisassemblerCreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetDisassemblerMutex ());
|
|
|
|
DisassemblerInstances &instances = GetDisassemblerInstances ();
|
|
|
|
|
|
|
|
DisassemblerInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
DisassemblerCreateInstance
|
|
|
|
PluginManager::GetDisassemblerCreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetDisassemblerMutex ());
|
|
|
|
DisassemblerInstances &instances = GetDisassemblerInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
2010-06-12 07:44:18 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
DisassemblerCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetDisassemblerCreateCallbackForPluginName (const ConstString &name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetDisassemblerMutex ());
|
|
|
|
DisassemblerInstances &instances = GetDisassemblerInstances ();
|
|
|
|
|
|
|
|
DisassemblerInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-04-14 06:47:15 +08:00
|
|
|
return pos->create_callback;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark DynamicLoader
|
|
|
|
|
|
|
|
|
2010-06-12 07:44:18 +08:00
|
|
|
struct DynamicLoaderInstance
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
DynamicLoaderInstance() :
|
|
|
|
name(),
|
|
|
|
description(),
|
2012-10-20 02:02:49 +08:00
|
|
|
create_callback(NULL),
|
|
|
|
debugger_init_callback (NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2010-06-09 00:52:24 +08:00
|
|
|
std::string description;
|
|
|
|
DynamicLoaderCreateInstance create_callback;
|
2012-10-20 02:02:49 +08:00
|
|
|
DebuggerInitializeCallback debugger_init_callback;
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<DynamicLoaderInstance> DynamicLoaderInstances;
|
|
|
|
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex &
|
|
|
|
GetDynamicLoaderMutex ()
|
|
|
|
{
|
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static DynamicLoaderInstances &
|
|
|
|
GetDynamicLoaderInstances ()
|
|
|
|
{
|
|
|
|
static DynamicLoaderInstances g_instances;
|
|
|
|
return g_instances;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::RegisterPlugin
|
|
|
|
(
|
2013-05-11 05:47:16 +08:00
|
|
|
const ConstString &name,
|
2010-06-09 00:52:24 +08:00
|
|
|
const char *description,
|
2012-10-20 02:02:49 +08:00
|
|
|
DynamicLoaderCreateInstance create_callback,
|
|
|
|
DebuggerInitializeCallback debugger_init_callback
|
2010-06-09 00:52:24 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
DynamicLoaderInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
2010-06-09 00:52:24 +08:00
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
2012-10-20 02:02:49 +08:00
|
|
|
instance.debugger_init_callback = debugger_init_callback;
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetDynamicLoaderMutex ());
|
|
|
|
GetDynamicLoaderInstances ().push_back (instance);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (DynamicLoaderCreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetDynamicLoaderMutex ());
|
|
|
|
DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
|
|
|
|
|
|
|
|
DynamicLoaderInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
DynamicLoaderCreateInstance
|
|
|
|
PluginManager::GetDynamicLoaderCreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetDynamicLoaderMutex ());
|
|
|
|
DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
2010-06-12 07:44:18 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
DynamicLoaderCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const ConstString &name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetDynamicLoaderMutex ());
|
|
|
|
DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
|
|
|
|
|
|
|
|
DynamicLoaderInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-04-14 06:47:15 +08:00
|
|
|
return pos->create_callback;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-02-01 09:37:45 +08:00
|
|
|
#pragma mark EmulateInstruction
|
|
|
|
|
|
|
|
|
|
|
|
struct EmulateInstructionInstance
|
|
|
|
{
|
|
|
|
EmulateInstructionInstance() :
|
|
|
|
name(),
|
|
|
|
description(),
|
|
|
|
create_callback(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2011-02-01 09:37:45 +08:00
|
|
|
std::string description;
|
|
|
|
EmulateInstructionCreateInstance create_callback;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<EmulateInstructionInstance> EmulateInstructionInstances;
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex &
|
|
|
|
GetEmulateInstructionMutex ()
|
2011-02-01 09:37:45 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
|
|
|
}
|
|
|
|
|
|
|
|
static EmulateInstructionInstances &
|
|
|
|
GetEmulateInstructionInstances ()
|
|
|
|
{
|
|
|
|
static EmulateInstructionInstances g_instances;
|
|
|
|
return g_instances;
|
2011-02-01 09:37:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::RegisterPlugin
|
|
|
|
(
|
2013-05-11 05:47:16 +08:00
|
|
|
const ConstString &name,
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
const char *description,
|
|
|
|
EmulateInstructionCreateInstance create_callback
|
|
|
|
)
|
2011-02-01 09:37:45 +08:00
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
EmulateInstructionInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
2011-02-01 09:37:45 +08:00
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetEmulateInstructionMutex ());
|
|
|
|
GetEmulateInstructionInstances ().push_back (instance);
|
2011-02-01 09:37:45 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (EmulateInstructionCreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetEmulateInstructionMutex ());
|
|
|
|
EmulateInstructionInstances &instances = GetEmulateInstructionInstances ();
|
|
|
|
|
|
|
|
EmulateInstructionInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2011-02-01 09:37:45 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
EmulateInstructionCreateInstance
|
|
|
|
PluginManager::GetEmulateInstructionCreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetEmulateInstructionMutex ());
|
|
|
|
EmulateInstructionInstances &instances = GetEmulateInstructionInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
2011-02-01 09:37:45 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
EmulateInstructionCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const ConstString &name)
|
2011-02-01 09:37:45 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2011-02-01 09:37:45 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetEmulateInstructionMutex ());
|
|
|
|
EmulateInstructionInstances &instances = GetEmulateInstructionInstances ();
|
|
|
|
|
|
|
|
EmulateInstructionInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2011-02-01 09:37:45 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-04-14 06:47:15 +08:00
|
|
|
return pos->create_callback;
|
2011-02-01 09:37:45 +08:00
|
|
|
}
|
2011-08-22 10:49:39 +08:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#pragma mark OperatingSystem
|
|
|
|
|
|
|
|
|
|
|
|
struct OperatingSystemInstance
|
|
|
|
{
|
|
|
|
OperatingSystemInstance() :
|
|
|
|
name(),
|
|
|
|
description(),
|
|
|
|
create_callback(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2011-08-22 10:49:39 +08:00
|
|
|
std::string description;
|
|
|
|
OperatingSystemCreateInstance create_callback;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<OperatingSystemInstance> OperatingSystemInstances;
|
|
|
|
|
|
|
|
static Mutex &
|
|
|
|
GetOperatingSystemMutex ()
|
|
|
|
{
|
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
|
|
|
}
|
|
|
|
|
|
|
|
static OperatingSystemInstances &
|
|
|
|
GetOperatingSystemInstances ()
|
|
|
|
{
|
|
|
|
static OperatingSystemInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::RegisterPlugin (const ConstString &name,
|
|
|
|
const char *description,
|
|
|
|
OperatingSystemCreateInstance create_callback)
|
2011-08-22 10:49:39 +08:00
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
OperatingSystemInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
2011-08-22 10:49:39 +08:00
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
|
|
|
Mutex::Locker locker (GetOperatingSystemMutex ());
|
|
|
|
GetOperatingSystemInstances ().push_back (instance);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (OperatingSystemCreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetOperatingSystemMutex ());
|
|
|
|
OperatingSystemInstances &instances = GetOperatingSystemInstances ();
|
|
|
|
|
|
|
|
OperatingSystemInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
OperatingSystemCreateInstance
|
|
|
|
PluginManager::GetOperatingSystemCreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetOperatingSystemMutex ());
|
|
|
|
OperatingSystemInstances &instances = GetOperatingSystemInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
OperatingSystemCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetOperatingSystemCreateCallbackForPluginName (const ConstString &name)
|
2011-08-22 10:49:39 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2011-08-22 10:49:39 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetOperatingSystemMutex ());
|
|
|
|
OperatingSystemInstances &instances = GetOperatingSystemInstances ();
|
|
|
|
|
|
|
|
OperatingSystemInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-08-22 10:49:39 +08:00
|
|
|
return pos->create_callback;
|
|
|
|
}
|
2011-02-01 09:37:45 +08:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-09-23 10:01:19 +08:00
|
|
|
#pragma mark LanguageRuntime
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
|
2010-09-23 10:01:19 +08:00
|
|
|
struct LanguageRuntimeInstance
|
|
|
|
{
|
|
|
|
LanguageRuntimeInstance() :
|
|
|
|
name(),
|
|
|
|
description(),
|
|
|
|
create_callback(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2010-09-23 10:01:19 +08:00
|
|
|
std::string description;
|
|
|
|
LanguageRuntimeCreateInstance create_callback;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<LanguageRuntimeInstance> LanguageRuntimeInstances;
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex &
|
|
|
|
GetLanguageRuntimeMutex ()
|
2010-09-23 10:01:19 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
2010-09-23 10:01:19 +08:00
|
|
|
}
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static LanguageRuntimeInstances &
|
|
|
|
GetLanguageRuntimeInstances ()
|
|
|
|
{
|
|
|
|
static LanguageRuntimeInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
2010-09-23 10:01:19 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::RegisterPlugin
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
(
|
2013-05-11 05:47:16 +08:00
|
|
|
const ConstString &name,
|
Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:
extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);
If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:
bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);
This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.
To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:
static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);
static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);
static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);
lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:
typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};
typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);
static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);
This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.
Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.
Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.
Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.
llvm-svn: 124716
2011-02-02 10:24:04 +08:00
|
|
|
const char *description,
|
|
|
|
LanguageRuntimeCreateInstance create_callback
|
|
|
|
)
|
2010-09-23 10:01:19 +08:00
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
LanguageRuntimeInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
2010-09-23 10:01:19 +08:00
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetLanguageRuntimeMutex ());
|
|
|
|
GetLanguageRuntimeInstances ().push_back (instance);
|
2010-09-23 10:01:19 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (LanguageRuntimeCreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetLanguageRuntimeMutex ());
|
|
|
|
LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances ();
|
|
|
|
|
|
|
|
LanguageRuntimeInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2010-09-23 10:01:19 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
LanguageRuntimeCreateInstance
|
|
|
|
PluginManager::GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetLanguageRuntimeMutex ());
|
|
|
|
LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
2010-09-23 10:01:19 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
LanguageRuntimeCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name)
|
2010-09-23 10:01:19 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2010-09-23 10:01:19 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetLanguageRuntimeMutex ());
|
|
|
|
LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances ();
|
|
|
|
|
|
|
|
LanguageRuntimeInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2010-09-23 10:01:19 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-04-14 06:47:15 +08:00
|
|
|
return pos->create_callback;
|
2010-09-23 10:01:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-11-05 11:57:19 +08:00
|
|
|
#pragma mark SystemRuntime
|
|
|
|
|
|
|
|
|
|
|
|
struct SystemRuntimeInstance
|
|
|
|
{
|
|
|
|
SystemRuntimeInstance() :
|
|
|
|
name(),
|
|
|
|
description(),
|
|
|
|
create_callback(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ConstString name;
|
|
|
|
std::string description;
|
|
|
|
SystemRuntimeCreateInstance create_callback;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<SystemRuntimeInstance> SystemRuntimeInstances;
|
|
|
|
|
|
|
|
static Mutex &
|
|
|
|
GetSystemRuntimeMutex ()
|
|
|
|
{
|
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
|
|
|
}
|
|
|
|
|
|
|
|
static SystemRuntimeInstances &
|
|
|
|
GetSystemRuntimeInstances ()
|
|
|
|
{
|
|
|
|
static SystemRuntimeInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::RegisterPlugin
|
|
|
|
(
|
|
|
|
const ConstString &name,
|
|
|
|
const char *description,
|
|
|
|
SystemRuntimeCreateInstance create_callback
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
SystemRuntimeInstance instance;
|
|
|
|
assert ((bool)name);
|
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
|
|
|
Mutex::Locker locker (GetSystemRuntimeMutex ());
|
|
|
|
GetSystemRuntimeInstances ().push_back (instance);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (SystemRuntimeCreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetSystemRuntimeMutex ());
|
|
|
|
SystemRuntimeInstances &instances = GetSystemRuntimeInstances ();
|
|
|
|
|
|
|
|
SystemRuntimeInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SystemRuntimeCreateInstance
|
|
|
|
PluginManager::GetSystemRuntimeCreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetSystemRuntimeMutex ());
|
|
|
|
SystemRuntimeInstances &instances = GetSystemRuntimeInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
SystemRuntimeCreateInstance
|
|
|
|
PluginManager::GetSystemRuntimeCreateCallbackForPluginName (const ConstString &name)
|
|
|
|
{
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetSystemRuntimeMutex ());
|
|
|
|
SystemRuntimeInstances &instances = GetSystemRuntimeInstances ();
|
|
|
|
|
|
|
|
SystemRuntimeInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (name == pos->name)
|
|
|
|
return pos->create_callback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#pragma mark ObjectFile
|
|
|
|
|
2010-06-12 07:44:18 +08:00
|
|
|
struct ObjectFileInstance
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
ObjectFileInstance() :
|
|
|
|
name(),
|
|
|
|
description(),
|
2013-04-25 06:29:28 +08:00
|
|
|
create_callback(NULL),
|
|
|
|
create_memory_callback (NULL),
|
|
|
|
get_module_specifications (NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2010-06-09 00:52:24 +08:00
|
|
|
std::string description;
|
|
|
|
ObjectFileCreateInstance create_callback;
|
2012-02-05 10:38:54 +08:00
|
|
|
ObjectFileCreateMemoryInstance create_memory_callback;
|
2013-04-25 06:29:28 +08:00
|
|
|
ObjectFileGetModuleSpecifications get_module_specifications;
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<ObjectFileInstance> ObjectFileInstances;
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex &
|
|
|
|
GetObjectFileMutex ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static ObjectFileInstances &
|
|
|
|
GetObjectFileInstances ()
|
|
|
|
{
|
|
|
|
static ObjectFileInstances g_instances;
|
|
|
|
return g_instances;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::RegisterPlugin (const ConstString &name,
|
2013-04-25 06:29:28 +08:00
|
|
|
const char *description,
|
|
|
|
ObjectFileCreateInstance create_callback,
|
|
|
|
ObjectFileCreateMemoryInstance create_memory_callback,
|
|
|
|
ObjectFileGetModuleSpecifications get_module_specifications)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
ObjectFileInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
2010-06-09 00:52:24 +08:00
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
2012-02-05 10:38:54 +08:00
|
|
|
instance.create_memory_callback = create_memory_callback;
|
2013-04-25 06:29:28 +08:00
|
|
|
instance.get_module_specifications = get_module_specifications;
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetObjectFileMutex ());
|
|
|
|
GetObjectFileInstances ().push_back (instance);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (ObjectFileCreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetObjectFileMutex ());
|
|
|
|
ObjectFileInstances &instances = GetObjectFileInstances ();
|
|
|
|
|
|
|
|
ObjectFileInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjectFileCreateInstance
|
|
|
|
PluginManager::GetObjectFileCreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetObjectFileMutex ());
|
|
|
|
ObjectFileInstances &instances = GetObjectFileInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
2010-06-12 07:44:18 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-04-14 06:47:15 +08:00
|
|
|
|
2012-02-05 10:38:54 +08:00
|
|
|
|
|
|
|
ObjectFileCreateMemoryInstance
|
|
|
|
PluginManager::GetObjectFileCreateMemoryCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetObjectFileMutex ());
|
|
|
|
ObjectFileInstances &instances = GetObjectFileInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_memory_callback;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-04-25 06:29:28 +08:00
|
|
|
ObjectFileGetModuleSpecifications
|
|
|
|
PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetObjectFileMutex ());
|
|
|
|
ObjectFileInstances &instances = GetObjectFileInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].get_module_specifications;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
ObjectFileCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetObjectFileCreateCallbackForPluginName (const ConstString &name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetObjectFileMutex ());
|
|
|
|
ObjectFileInstances &instances = GetObjectFileInstances ();
|
|
|
|
|
|
|
|
ObjectFileInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-04-14 06:47:15 +08:00
|
|
|
return pos->create_callback;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-05 10:38:54 +08:00
|
|
|
ObjectFileCreateMemoryInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetObjectFileCreateMemoryCallbackForPluginName (const ConstString &name)
|
2012-02-05 10:38:54 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2012-02-05 10:38:54 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetObjectFileMutex ());
|
|
|
|
ObjectFileInstances &instances = GetObjectFileInstances ();
|
|
|
|
|
|
|
|
ObjectFileInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2012-02-05 10:38:54 +08:00
|
|
|
return pos->create_memory_callback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
#pragma mark ObjectContainer
|
|
|
|
|
2010-06-12 07:44:18 +08:00
|
|
|
struct ObjectContainerInstance
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
ObjectContainerInstance() :
|
|
|
|
name(),
|
|
|
|
description(),
|
2013-04-25 06:29:28 +08:00
|
|
|
create_callback (NULL),
|
|
|
|
get_module_specifications (NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2010-06-09 00:52:24 +08:00
|
|
|
std::string description;
|
|
|
|
ObjectContainerCreateInstance create_callback;
|
2013-04-25 06:29:28 +08:00
|
|
|
ObjectFileGetModuleSpecifications get_module_specifications;
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<ObjectContainerInstance> ObjectContainerInstances;
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex &
|
|
|
|
GetObjectContainerMutex ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static ObjectContainerInstances &
|
|
|
|
GetObjectContainerInstances ()
|
|
|
|
{
|
|
|
|
static ObjectContainerInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
bool
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::RegisterPlugin (const ConstString &name,
|
2013-04-25 06:29:28 +08:00
|
|
|
const char *description,
|
|
|
|
ObjectContainerCreateInstance create_callback,
|
|
|
|
ObjectFileGetModuleSpecifications get_module_specifications)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
ObjectContainerInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
2010-06-09 00:52:24 +08:00
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
2013-04-25 06:29:28 +08:00
|
|
|
instance.get_module_specifications = get_module_specifications;
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetObjectContainerMutex ());
|
|
|
|
GetObjectContainerInstances ().push_back (instance);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (ObjectContainerCreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetObjectContainerMutex ());
|
|
|
|
ObjectContainerInstances &instances = GetObjectContainerInstances ();
|
|
|
|
|
|
|
|
ObjectContainerInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjectContainerCreateInstance
|
|
|
|
PluginManager::GetObjectContainerCreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetObjectContainerMutex ());
|
|
|
|
ObjectContainerInstances &instances = GetObjectContainerInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
2010-06-12 07:44:18 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-04-14 06:47:15 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
ObjectContainerCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetObjectContainerCreateCallbackForPluginName (const ConstString &name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetObjectContainerMutex ());
|
|
|
|
ObjectContainerInstances &instances = GetObjectContainerInstances ();
|
|
|
|
|
|
|
|
ObjectContainerInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-04-14 06:47:15 +08:00
|
|
|
return pos->create_callback;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-04-25 06:29:28 +08:00
|
|
|
ObjectFileGetModuleSpecifications
|
|
|
|
PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetObjectContainerMutex ());
|
|
|
|
ObjectContainerInstances &instances = GetObjectContainerInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].get_module_specifications;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#pragma mark LogChannel
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
struct LogInstance
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
LogInstance() :
|
2010-06-09 00:52:24 +08:00
|
|
|
name(),
|
|
|
|
description(),
|
|
|
|
create_callback(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2010-06-09 00:52:24 +08:00
|
|
|
std::string description;
|
|
|
|
LogChannelCreateInstance create_callback;
|
|
|
|
};
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
typedef std::vector<LogInstance> LogInstances;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex &
|
|
|
|
GetLogMutex ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static LogInstances &
|
|
|
|
GetLogInstances ()
|
|
|
|
{
|
|
|
|
static LogInstances g_instances;
|
|
|
|
return g_instances;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
|
|
|
PluginManager::RegisterPlugin
|
|
|
|
(
|
2013-05-11 05:47:16 +08:00
|
|
|
const ConstString &name,
|
2010-06-09 00:52:24 +08:00
|
|
|
const char *description,
|
|
|
|
LogChannelCreateInstance create_callback
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
LogInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
2010-06-09 00:52:24 +08:00
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetLogMutex ());
|
|
|
|
GetLogInstances ().push_back (instance);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (LogChannelCreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetLogMutex ());
|
|
|
|
LogInstances &instances = GetLogInstances ();
|
|
|
|
|
|
|
|
LogInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
PluginManager::GetLogChannelCreateNameAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetLogMutex ());
|
|
|
|
LogInstances &instances = GetLogInstances ();
|
|
|
|
if (idx < instances.size())
|
2013-05-11 05:47:16 +08:00
|
|
|
return instances[idx].name.GetCString();
|
2010-06-09 00:52:24 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LogChannelCreateInstance
|
|
|
|
PluginManager::GetLogChannelCreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetLogMutex ());
|
|
|
|
LogInstances &instances = GetLogInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
2010-06-12 07:44:18 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
LogChannelCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetLogChannelCreateCallbackForPluginName (const ConstString &name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetLogMutex ());
|
|
|
|
LogInstances &instances = GetLogInstances ();
|
|
|
|
|
|
|
|
LogInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-04-14 06:47:15 +08:00
|
|
|
return pos->create_callback;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-03-09 06:40:15 +08:00
|
|
|
#pragma mark Platform
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-03-09 06:40:15 +08:00
|
|
|
struct PlatformInstance
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-03-09 06:40:15 +08:00
|
|
|
PlatformInstance() :
|
2010-06-09 00:52:24 +08:00
|
|
|
name(),
|
|
|
|
description(),
|
2013-04-05 13:06:39 +08:00
|
|
|
create_callback(NULL),
|
|
|
|
debugger_init_callback (NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
2011-03-09 06:40:15 +08:00
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2011-03-09 06:40:15 +08:00
|
|
|
std::string description;
|
|
|
|
PlatformCreateInstance create_callback;
|
2013-04-05 13:06:39 +08:00
|
|
|
DebuggerInitializeCallback debugger_init_callback;
|
2011-03-09 06:40:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<PlatformInstance> PlatformInstances;
|
|
|
|
|
2011-03-19 09:12:21 +08:00
|
|
|
static Mutex &
|
|
|
|
GetPlatformInstancesMutex ()
|
2011-03-09 06:40:15 +08:00
|
|
|
{
|
2011-03-19 09:12:21 +08:00
|
|
|
static Mutex g_platform_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_platform_instances_mutex;
|
2011-03-09 06:40:15 +08:00
|
|
|
}
|
|
|
|
|
2011-03-19 09:12:21 +08:00
|
|
|
static PlatformInstances &
|
|
|
|
GetPlatformInstances ()
|
|
|
|
{
|
|
|
|
static PlatformInstances g_platform_instances;
|
|
|
|
return g_platform_instances;
|
|
|
|
}
|
2011-03-09 06:40:15 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
|
2011-03-09 06:40:15 +08:00
|
|
|
bool
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::RegisterPlugin (const ConstString &name,
|
2011-03-09 06:40:15 +08:00
|
|
|
const char *description,
|
2013-04-05 13:06:39 +08:00
|
|
|
PlatformCreateInstance create_callback,
|
|
|
|
DebuggerInitializeCallback debugger_init_callback)
|
2011-03-09 06:40:15 +08:00
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-03-19 09:12:21 +08:00
|
|
|
Mutex::Locker locker (GetPlatformInstancesMutex ());
|
|
|
|
|
2011-03-09 06:40:15 +08:00
|
|
|
PlatformInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
2011-03-09 06:40:15 +08:00
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
2013-04-05 13:06:39 +08:00
|
|
|
instance.debugger_init_callback = debugger_init_callback;
|
2011-03-19 09:12:21 +08:00
|
|
|
GetPlatformInstances ().push_back (instance);
|
|
|
|
return true;
|
2011-03-09 06:40:15 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-05 13:06:39 +08:00
|
|
|
|
2011-03-09 06:40:15 +08:00
|
|
|
const char *
|
|
|
|
PluginManager::GetPlatformPluginNameAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-03-19 09:12:21 +08:00
|
|
|
Mutex::Locker locker (GetPlatformInstancesMutex ());
|
2011-04-14 06:47:15 +08:00
|
|
|
PlatformInstances &instances = GetPlatformInstances ();
|
|
|
|
if (idx < instances.size())
|
2013-05-11 05:47:16 +08:00
|
|
|
return instances[idx].name.GetCString();
|
2011-03-09 06:40:15 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
PluginManager::GetPlatformPluginDescriptionAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-03-19 09:12:21 +08:00
|
|
|
Mutex::Locker locker (GetPlatformInstancesMutex ());
|
2011-04-14 06:47:15 +08:00
|
|
|
PlatformInstances &instances = GetPlatformInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].description.c_str();
|
2011-03-09 06:40:15 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (PlatformCreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-03-19 09:12:21 +08:00
|
|
|
Mutex::Locker locker (GetPlatformInstancesMutex ());
|
2011-04-14 06:47:15 +08:00
|
|
|
PlatformInstances &instances = GetPlatformInstances ();
|
2011-03-19 09:12:21 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
PlatformInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2011-03-19 09:12:21 +08:00
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
instances.erase(pos);
|
2011-03-19 09:12:21 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2011-03-09 06:40:15 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
PlatformCreateInstance
|
|
|
|
PluginManager::GetPlatformCreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-03-19 09:12:21 +08:00
|
|
|
Mutex::Locker locker (GetPlatformInstancesMutex ());
|
2011-04-14 06:47:15 +08:00
|
|
|
PlatformInstances &instances = GetPlatformInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
2011-03-09 06:40:15 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PlatformCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetPlatformCreateCallbackForPluginName (const ConstString &name)
|
2011-03-09 06:40:15 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2011-03-09 06:40:15 +08:00
|
|
|
{
|
2011-03-19 09:12:21 +08:00
|
|
|
Mutex::Locker locker (GetPlatformInstancesMutex ());
|
2011-04-14 06:47:15 +08:00
|
|
|
PlatformInstances &instances = GetPlatformInstances ();
|
2011-03-19 09:12:21 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
PlatformInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2011-03-09 06:40:15 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-03-19 09:12:21 +08:00
|
|
|
return pos->create_callback;
|
2011-03-09 06:40:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
size_t
|
2011-04-14 06:47:15 +08:00
|
|
|
PluginManager::AutoCompletePlatformName (const char *name, StringList &matches)
|
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2011-04-14 06:47:15 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetPlatformInstancesMutex ());
|
|
|
|
PlatformInstances &instances = GetPlatformInstances ();
|
|
|
|
llvm::StringRef name_sref(name);
|
|
|
|
|
|
|
|
PlatformInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
llvm::StringRef plugin_name (pos->name.GetCString());
|
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
|
|
|
if (plugin_name.startswith(name_sref))
|
|
|
|
matches.AppendString (plugin_name.data());
|
2011-04-14 06:47:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return matches.GetSize();
|
|
|
|
}
|
2011-03-09 06:40:15 +08:00
|
|
|
#pragma mark Process
|
|
|
|
|
|
|
|
struct ProcessInstance
|
|
|
|
{
|
|
|
|
ProcessInstance() :
|
2013-07-16 06:54:20 +08:00
|
|
|
name(),
|
|
|
|
description(),
|
|
|
|
create_callback(NULL),
|
|
|
|
debugger_init_callback(NULL)
|
2011-03-09 06:40:15 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2010-06-09 00:52:24 +08:00
|
|
|
std::string description;
|
|
|
|
ProcessCreateInstance create_callback;
|
2013-07-16 06:54:20 +08:00
|
|
|
DebuggerInitializeCallback debugger_init_callback;
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<ProcessInstance> ProcessInstances;
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex &
|
|
|
|
GetProcessMutex ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ProcessInstances &
|
|
|
|
GetProcessInstances ()
|
|
|
|
{
|
|
|
|
static ProcessInstances g_instances;
|
|
|
|
return g_instances;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2013-07-16 06:54:20 +08:00
|
|
|
PluginManager::RegisterPlugin (const ConstString &name,
|
|
|
|
const char *description,
|
|
|
|
ProcessCreateInstance create_callback,
|
|
|
|
DebuggerInitializeCallback debugger_init_callback)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
ProcessInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
2010-06-09 00:52:24 +08:00
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
2013-07-16 06:54:20 +08:00
|
|
|
instance.debugger_init_callback = debugger_init_callback;
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetProcessMutex ());
|
|
|
|
GetProcessInstances ().push_back (instance);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-02-18 09:44:25 +08:00
|
|
|
const char *
|
|
|
|
PluginManager::GetProcessPluginNameAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetProcessMutex ());
|
|
|
|
ProcessInstances &instances = GetProcessInstances ();
|
|
|
|
if (idx < instances.size())
|
2013-05-11 05:47:16 +08:00
|
|
|
return instances[idx].name.GetCString();
|
2011-02-18 09:44:25 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
PluginManager::GetProcessPluginDescriptionAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetProcessMutex ());
|
|
|
|
ProcessInstances &instances = GetProcessInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].description.c_str();
|
2011-02-18 09:44:25 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (ProcessCreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetProcessMutex ());
|
|
|
|
ProcessInstances &instances = GetProcessInstances ();
|
|
|
|
|
|
|
|
ProcessInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessCreateInstance
|
|
|
|
PluginManager::GetProcessCreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetProcessMutex ());
|
|
|
|
ProcessInstances &instances = GetProcessInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
2010-06-12 07:44:18 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
ProcessCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetProcessCreateCallbackForPluginName (const ConstString &name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetProcessMutex ());
|
|
|
|
ProcessInstances &instances = GetProcessInstances ();
|
|
|
|
|
|
|
|
ProcessInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-04-14 06:47:15 +08:00
|
|
|
return pos->create_callback;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark SymbolFile
|
|
|
|
|
2010-06-12 07:44:18 +08:00
|
|
|
struct SymbolFileInstance
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
SymbolFileInstance() :
|
|
|
|
name(),
|
|
|
|
description(),
|
|
|
|
create_callback(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2010-06-09 00:52:24 +08:00
|
|
|
std::string description;
|
|
|
|
SymbolFileCreateInstance create_callback;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<SymbolFileInstance> SymbolFileInstances;
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex &
|
|
|
|
GetSymbolFileMutex ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static SymbolFileInstances &
|
|
|
|
GetSymbolFileInstances ()
|
|
|
|
{
|
|
|
|
static SymbolFileInstances g_instances;
|
|
|
|
return g_instances;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::RegisterPlugin
|
|
|
|
(
|
2013-05-11 05:47:16 +08:00
|
|
|
const ConstString &name,
|
2010-06-09 00:52:24 +08:00
|
|
|
const char *description,
|
|
|
|
SymbolFileCreateInstance create_callback
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
SymbolFileInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
2010-06-09 00:52:24 +08:00
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetSymbolFileMutex ());
|
|
|
|
GetSymbolFileInstances ().push_back (instance);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (SymbolFileCreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetSymbolFileMutex ());
|
|
|
|
SymbolFileInstances &instances = GetSymbolFileInstances ();
|
|
|
|
|
|
|
|
SymbolFileInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SymbolFileCreateInstance
|
|
|
|
PluginManager::GetSymbolFileCreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetSymbolFileMutex ());
|
|
|
|
SymbolFileInstances &instances = GetSymbolFileInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
2010-06-12 07:44:18 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-04-14 06:47:15 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SymbolFileCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetSymbolFileCreateCallbackForPluginName (const ConstString &name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetSymbolFileMutex ());
|
|
|
|
SymbolFileInstances &instances = GetSymbolFileInstances ();
|
|
|
|
|
|
|
|
SymbolFileInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-04-14 06:47:15 +08:00
|
|
|
return pos->create_callback;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark SymbolVendor
|
|
|
|
|
2010-06-12 07:44:18 +08:00
|
|
|
struct SymbolVendorInstance
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
SymbolVendorInstance() :
|
|
|
|
name(),
|
|
|
|
description(),
|
|
|
|
create_callback(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2010-06-09 00:52:24 +08:00
|
|
|
std::string description;
|
|
|
|
SymbolVendorCreateInstance create_callback;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<SymbolVendorInstance> SymbolVendorInstances;
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex &
|
|
|
|
GetSymbolVendorMutex ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static SymbolVendorInstances &
|
|
|
|
GetSymbolVendorInstances ()
|
|
|
|
{
|
|
|
|
static SymbolVendorInstances g_instances;
|
|
|
|
return g_instances;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::RegisterPlugin
|
|
|
|
(
|
2013-05-11 05:47:16 +08:00
|
|
|
const ConstString &name,
|
2010-06-09 00:52:24 +08:00
|
|
|
const char *description,
|
|
|
|
SymbolVendorCreateInstance create_callback
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
|
|
|
SymbolVendorInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
2010-06-09 00:52:24 +08:00
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetSymbolVendorMutex ());
|
|
|
|
GetSymbolVendorInstances ().push_back (instance);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::UnregisterPlugin (SymbolVendorCreateInstance create_callback)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetSymbolVendorMutex ());
|
|
|
|
SymbolVendorInstances &instances = GetSymbolVendorInstances ();
|
|
|
|
|
|
|
|
SymbolVendorInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SymbolVendorCreateInstance
|
|
|
|
PluginManager::GetSymbolVendorCreateCallbackAtIndex (uint32_t idx)
|
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetSymbolVendorMutex ());
|
|
|
|
SymbolVendorInstances &instances = GetSymbolVendorInstances ();
|
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
2010-06-12 07:44:18 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SymbolVendorCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetSymbolVendorCreateCallbackForPluginName (const ConstString &name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
Mutex::Locker locker (GetSymbolVendorMutex ());
|
|
|
|
SymbolVendorInstances &instances = GetSymbolVendorInstances ();
|
|
|
|
|
|
|
|
SymbolVendorInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-04-14 06:47:15 +08:00
|
|
|
return pos->create_callback;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-26 05:14:26 +08:00
|
|
|
#pragma mark UnwindAssembly
|
2010-09-10 15:49:16 +08:00
|
|
|
|
2011-04-26 05:14:26 +08:00
|
|
|
struct UnwindAssemblyInstance
|
2010-09-10 15:49:16 +08:00
|
|
|
{
|
2011-04-26 05:14:26 +08:00
|
|
|
UnwindAssemblyInstance() :
|
2010-09-10 15:49:16 +08:00
|
|
|
name(),
|
|
|
|
description(),
|
|
|
|
create_callback(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:47:16 +08:00
|
|
|
ConstString name;
|
2010-09-10 15:49:16 +08:00
|
|
|
std::string description;
|
2011-04-26 05:14:26 +08:00
|
|
|
UnwindAssemblyCreateInstance create_callback;
|
2010-09-10 15:49:16 +08:00
|
|
|
};
|
|
|
|
|
2011-04-26 05:14:26 +08:00
|
|
|
typedef std::vector<UnwindAssemblyInstance> UnwindAssemblyInstances;
|
2010-09-10 15:49:16 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex &
|
2011-04-26 05:14:26 +08:00
|
|
|
GetUnwindAssemblyMutex ()
|
2010-09-10 15:49:16 +08:00
|
|
|
{
|
2011-04-14 06:47:15 +08:00
|
|
|
static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
|
|
|
|
return g_instances_mutex;
|
|
|
|
}
|
2010-09-10 15:49:16 +08:00
|
|
|
|
2011-04-26 05:14:26 +08:00
|
|
|
static UnwindAssemblyInstances &
|
|
|
|
GetUnwindAssemblyInstances ()
|
2011-04-14 06:47:15 +08:00
|
|
|
{
|
2011-04-26 05:14:26 +08:00
|
|
|
static UnwindAssemblyInstances g_instances;
|
2011-04-14 06:47:15 +08:00
|
|
|
return g_instances;
|
2010-09-10 15:49:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::RegisterPlugin
|
|
|
|
(
|
2013-05-11 05:47:16 +08:00
|
|
|
const ConstString &name,
|
2010-09-10 15:49:16 +08:00
|
|
|
const char *description,
|
2011-04-26 05:14:26 +08:00
|
|
|
UnwindAssemblyCreateInstance create_callback
|
2010-09-10 15:49:16 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-04-26 05:14:26 +08:00
|
|
|
UnwindAssemblyInstance instance;
|
2013-05-11 05:47:16 +08:00
|
|
|
assert ((bool)name);
|
2010-09-10 15:49:16 +08:00
|
|
|
instance.name = name;
|
|
|
|
if (description && description[0])
|
|
|
|
instance.description = description;
|
|
|
|
instance.create_callback = create_callback;
|
2011-04-26 05:14:26 +08:00
|
|
|
Mutex::Locker locker (GetUnwindAssemblyMutex ());
|
|
|
|
GetUnwindAssemblyInstances ().push_back (instance);
|
2010-09-10 15:49:16 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-04-26 05:14:26 +08:00
|
|
|
PluginManager::UnregisterPlugin (UnwindAssemblyCreateInstance create_callback)
|
2010-09-10 15:49:16 +08:00
|
|
|
{
|
|
|
|
if (create_callback)
|
|
|
|
{
|
2011-04-26 05:14:26 +08:00
|
|
|
Mutex::Locker locker (GetUnwindAssemblyMutex ());
|
|
|
|
UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances ();
|
2011-04-14 06:47:15 +08:00
|
|
|
|
2011-04-26 05:14:26 +08:00
|
|
|
UnwindAssemblyInstances::iterator pos, end = instances.end();
|
2011-04-14 06:47:15 +08:00
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->create_callback == create_callback)
|
|
|
|
{
|
|
|
|
instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2010-09-10 15:49:16 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-04-26 05:14:26 +08:00
|
|
|
UnwindAssemblyCreateInstance
|
|
|
|
PluginManager::GetUnwindAssemblyCreateCallbackAtIndex (uint32_t idx)
|
2010-09-10 15:49:16 +08:00
|
|
|
{
|
2011-04-26 05:14:26 +08:00
|
|
|
Mutex::Locker locker (GetUnwindAssemblyMutex ());
|
|
|
|
UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances ();
|
2011-04-14 06:47:15 +08:00
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_callback;
|
2010-09-10 15:49:16 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
|
2011-04-26 05:14:26 +08:00
|
|
|
UnwindAssemblyCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetUnwindAssemblyCreateCallbackForPluginName (const ConstString &name)
|
2010-09-10 15:49:16 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name)
|
2010-09-10 15:49:16 +08:00
|
|
|
{
|
2011-04-26 05:14:26 +08:00
|
|
|
Mutex::Locker locker (GetUnwindAssemblyMutex ());
|
|
|
|
UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances ();
|
2011-04-14 06:47:15 +08:00
|
|
|
|
2011-04-26 05:14:26 +08:00
|
|
|
UnwindAssemblyInstances::iterator pos, end = instances.end();
|
2011-04-14 06:47:15 +08:00
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
2010-09-10 15:49:16 +08:00
|
|
|
{
|
2013-05-11 05:47:16 +08:00
|
|
|
if (name == pos->name)
|
2011-04-14 06:47:15 +08:00
|
|
|
return pos->create_callback;
|
2010-09-10 15:49:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-10-20 02:02:49 +08:00
|
|
|
void
|
|
|
|
PluginManager::DebuggerInitialize (Debugger &debugger)
|
|
|
|
{
|
2013-04-05 13:06:39 +08:00
|
|
|
// Initialize the DynamicLoader plugins
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetDynamicLoaderMutex ());
|
|
|
|
DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
|
2012-10-20 02:02:49 +08:00
|
|
|
|
2013-04-05 13:06:39 +08:00
|
|
|
DynamicLoaderInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->debugger_init_callback)
|
|
|
|
pos->debugger_init_callback (debugger);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize the Platform plugins
|
2012-10-20 02:02:49 +08:00
|
|
|
{
|
2013-04-05 13:06:39 +08:00
|
|
|
Mutex::Locker locker (GetPlatformInstancesMutex ());
|
|
|
|
PlatformInstances &instances = GetPlatformInstances ();
|
|
|
|
|
|
|
|
PlatformInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->debugger_init_callback)
|
|
|
|
pos->debugger_init_callback (debugger);
|
|
|
|
}
|
2012-10-20 02:02:49 +08:00
|
|
|
}
|
2013-07-16 06:54:20 +08:00
|
|
|
|
|
|
|
// Initialize the Process plugins
|
|
|
|
{
|
|
|
|
Mutex::Locker locker (GetProcessMutex());
|
|
|
|
ProcessInstances &instances = GetProcessInstances();
|
|
|
|
|
|
|
|
ProcessInstances::iterator pos, end = instances.end();
|
|
|
|
for (pos = instances.begin(); pos != end; ++ pos)
|
|
|
|
{
|
|
|
|
if (pos->debugger_init_callback)
|
|
|
|
pos->debugger_init_callback (debugger);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-20 02:02:49 +08:00
|
|
|
}
|
|
|
|
|
2013-07-16 06:54:20 +08:00
|
|
|
// This is the preferred new way to register plugin specific settings. e.g.
|
|
|
|
// This will put a plugin's settings under e.g. "plugin.<plugin_type_name>.<plugin_type_desc>.SETTINGNAME".
|
2012-10-20 02:02:49 +08:00
|
|
|
static lldb::OptionValuePropertiesSP
|
2013-07-16 06:54:20 +08:00
|
|
|
GetDebuggerPropertyForPlugins (Debugger &debugger,
|
2013-04-06 06:40:42 +08:00
|
|
|
const ConstString &plugin_type_name,
|
|
|
|
const ConstString &plugin_type_desc,
|
|
|
|
bool can_create)
|
2012-10-20 02:02:49 +08:00
|
|
|
{
|
|
|
|
lldb::OptionValuePropertiesSP parent_properties_sp (debugger.GetValueProperties());
|
|
|
|
if (parent_properties_sp)
|
|
|
|
{
|
|
|
|
static ConstString g_property_name("plugin");
|
|
|
|
|
|
|
|
OptionValuePropertiesSP plugin_properties_sp = parent_properties_sp->GetSubProperty (NULL, g_property_name);
|
|
|
|
if (!plugin_properties_sp && can_create)
|
|
|
|
{
|
|
|
|
plugin_properties_sp.reset (new OptionValueProperties (g_property_name));
|
|
|
|
parent_properties_sp->AppendProperty (g_property_name,
|
|
|
|
ConstString("Settings specify to plugins."),
|
|
|
|
true,
|
|
|
|
plugin_properties_sp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plugin_properties_sp)
|
|
|
|
{
|
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp = plugin_properties_sp->GetSubProperty (NULL, plugin_type_name);
|
|
|
|
if (!plugin_type_properties_sp && can_create)
|
|
|
|
{
|
|
|
|
plugin_type_properties_sp.reset (new OptionValueProperties (plugin_type_name));
|
|
|
|
plugin_properties_sp->AppendProperty (plugin_type_name,
|
|
|
|
plugin_type_desc,
|
|
|
|
true,
|
|
|
|
plugin_type_properties_sp);
|
|
|
|
}
|
|
|
|
return plugin_type_properties_sp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return lldb::OptionValuePropertiesSP();
|
|
|
|
}
|
|
|
|
|
2013-07-16 06:54:20 +08:00
|
|
|
// This is deprecated way to register plugin specific settings. e.g.
|
|
|
|
// "<plugin_type_name>.plugin.<plugin_type_desc>.SETTINGNAME"
|
2013-04-06 06:40:42 +08:00
|
|
|
// and Platform generic settings would be under "platform.SETTINGNAME".
|
|
|
|
static lldb::OptionValuePropertiesSP
|
2013-07-16 06:54:20 +08:00
|
|
|
GetDebuggerPropertyForPluginsOldStyle (Debugger &debugger,
|
|
|
|
const ConstString &plugin_type_name,
|
|
|
|
const ConstString &plugin_type_desc,
|
|
|
|
bool can_create)
|
2013-04-06 06:40:42 +08:00
|
|
|
{
|
|
|
|
static ConstString g_property_name("plugin");
|
|
|
|
lldb::OptionValuePropertiesSP parent_properties_sp (debugger.GetValueProperties());
|
|
|
|
if (parent_properties_sp)
|
|
|
|
{
|
|
|
|
OptionValuePropertiesSP plugin_properties_sp = parent_properties_sp->GetSubProperty (NULL, plugin_type_name);
|
|
|
|
if (!plugin_properties_sp && can_create)
|
|
|
|
{
|
|
|
|
plugin_properties_sp.reset (new OptionValueProperties (plugin_type_name));
|
|
|
|
parent_properties_sp->AppendProperty (plugin_type_name,
|
|
|
|
plugin_type_desc,
|
|
|
|
true,
|
|
|
|
plugin_properties_sp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plugin_properties_sp)
|
|
|
|
{
|
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp = plugin_properties_sp->GetSubProperty (NULL, g_property_name);
|
|
|
|
if (!plugin_type_properties_sp && can_create)
|
|
|
|
{
|
|
|
|
plugin_type_properties_sp.reset (new OptionValueProperties (g_property_name));
|
|
|
|
plugin_properties_sp->AppendProperty (g_property_name,
|
|
|
|
ConstString("Settings specific to plugins"),
|
|
|
|
true,
|
|
|
|
plugin_type_properties_sp);
|
|
|
|
}
|
|
|
|
return plugin_type_properties_sp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return lldb::OptionValuePropertiesSP();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-20 02:02:49 +08:00
|
|
|
lldb::OptionValuePropertiesSP
|
|
|
|
PluginManager::GetSettingForDynamicLoaderPlugin (Debugger &debugger, const ConstString &setting_name)
|
|
|
|
{
|
|
|
|
lldb::OptionValuePropertiesSP properties_sp;
|
2013-07-16 06:54:20 +08:00
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
|
2012-10-20 02:02:49 +08:00
|
|
|
ConstString("dynamic-loader"),
|
|
|
|
ConstString(), // not creating to so we don't need the description
|
|
|
|
false));
|
|
|
|
if (plugin_type_properties_sp)
|
|
|
|
properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name);
|
|
|
|
return properties_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::CreateSettingForDynamicLoaderPlugin (Debugger &debugger,
|
|
|
|
const lldb::OptionValuePropertiesSP &properties_sp,
|
|
|
|
const ConstString &description,
|
|
|
|
bool is_global_property)
|
|
|
|
{
|
|
|
|
if (properties_sp)
|
|
|
|
{
|
2013-07-16 06:54:20 +08:00
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
|
2012-10-20 02:02:49 +08:00
|
|
|
ConstString("dynamic-loader"),
|
|
|
|
ConstString("Settings for dynamic loader plug-ins"),
|
|
|
|
true));
|
|
|
|
if (plugin_type_properties_sp)
|
|
|
|
{
|
|
|
|
plugin_type_properties_sp->AppendProperty (properties_sp->GetName(),
|
|
|
|
description,
|
|
|
|
is_global_property,
|
|
|
|
properties_sp);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-05 13:06:39 +08:00
|
|
|
|
|
|
|
lldb::OptionValuePropertiesSP
|
|
|
|
PluginManager::GetSettingForPlatformPlugin (Debugger &debugger, const ConstString &setting_name)
|
|
|
|
{
|
|
|
|
lldb::OptionValuePropertiesSP properties_sp;
|
2013-07-16 06:54:20 +08:00
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger,
|
|
|
|
ConstString("platform"),
|
|
|
|
ConstString(), // not creating to so we don't need the description
|
|
|
|
false));
|
2013-04-05 13:06:39 +08:00
|
|
|
if (plugin_type_properties_sp)
|
|
|
|
properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name);
|
|
|
|
return properties_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::CreateSettingForPlatformPlugin (Debugger &debugger,
|
|
|
|
const lldb::OptionValuePropertiesSP &properties_sp,
|
|
|
|
const ConstString &description,
|
|
|
|
bool is_global_property)
|
2013-07-16 06:54:20 +08:00
|
|
|
{
|
|
|
|
if (properties_sp)
|
|
|
|
{
|
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPluginsOldStyle (debugger,
|
|
|
|
ConstString("platform"),
|
|
|
|
ConstString("Settings for platform plug-ins"),
|
|
|
|
true));
|
|
|
|
if (plugin_type_properties_sp)
|
|
|
|
{
|
|
|
|
plugin_type_properties_sp->AppendProperty (properties_sp->GetName(),
|
|
|
|
description,
|
|
|
|
is_global_property,
|
|
|
|
properties_sp);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lldb::OptionValuePropertiesSP
|
|
|
|
PluginManager::GetSettingForProcessPlugin (Debugger &debugger, const ConstString &setting_name)
|
|
|
|
{
|
|
|
|
lldb::OptionValuePropertiesSP properties_sp;
|
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
|
|
|
|
ConstString("process"),
|
|
|
|
ConstString(), // not creating to so we don't need the description
|
|
|
|
false));
|
|
|
|
if (plugin_type_properties_sp)
|
|
|
|
properties_sp = plugin_type_properties_sp->GetSubProperty (NULL, setting_name);
|
|
|
|
return properties_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginManager::CreateSettingForProcessPlugin (Debugger &debugger,
|
|
|
|
const lldb::OptionValuePropertiesSP &properties_sp,
|
|
|
|
const ConstString &description,
|
|
|
|
bool is_global_property)
|
2013-04-05 13:06:39 +08:00
|
|
|
{
|
|
|
|
if (properties_sp)
|
|
|
|
{
|
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp (GetDebuggerPropertyForPlugins (debugger,
|
2013-07-16 06:54:20 +08:00
|
|
|
ConstString("process"),
|
|
|
|
ConstString("Settings for process plug-ins"),
|
2013-04-05 13:06:39 +08:00
|
|
|
true));
|
|
|
|
if (plugin_type_properties_sp)
|
|
|
|
{
|
|
|
|
plugin_type_properties_sp->AppendProperty (properties_sp->GetName(),
|
|
|
|
description,
|
|
|
|
is_global_property,
|
|
|
|
properties_sp);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|