[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- PluginManager.cpp -------------------------------------------------===//
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Core/PluginManager.h"
|
|
|
|
|
2012-10-20 02:02:49 +08:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2018-11-01 08:33:27 +08:00
|
|
|
#include "lldb/Host/FileSystem.h"
|
2014-08-22 01:29:12 +08:00
|
|
|
#include "lldb/Host/HostInfo.h"
|
2012-10-20 02:02:49 +08:00
|
|
|
#include "lldb/Interpreter/OptionValueProperties.h"
|
2021-04-27 04:47:05 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
2018-11-12 07:16:43 +08:00
|
|
|
#include "lldb/Utility/ConstString.h"
|
2017-03-23 02:40:07 +08:00
|
|
|
#include "lldb/Utility/FileSpec.h"
|
2017-05-12 12:51:55 +08:00
|
|
|
#include "lldb/Utility/Status.h"
|
2018-11-12 07:16:43 +08:00
|
|
|
#include "lldb/Utility/StringList.h"
|
2017-04-07 05:28:29 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/Support/DynamicLibrary.h"
|
2018-11-12 07:16:43 +08:00
|
|
|
#include "llvm/Support/FileSystem.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2021-05-26 18:19:37 +08:00
|
|
|
#include <cassert>
|
2018-11-12 07:16:43 +08:00
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
2017-04-07 05:28:29 +08:00
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
2018-11-12 07:16:43 +08:00
|
|
|
#include <utility>
|
2017-04-07 05:28:29 +08:00
|
|
|
#include <vector>
|
2020-02-19 15:52:07 +08:00
|
|
|
#if defined(_WIN32)
|
|
|
|
#include "lldb/Host/windows/PosixApi.h"
|
|
|
|
#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
|
|
|
|
|
|
|
using namespace lldb;
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb_private;
|
|
|
|
|
2016-03-12 05:55:47 +08:00
|
|
|
typedef bool (*PluginInitCallback)();
|
|
|
|
typedef void (*PluginTermCallback)();
|
2013-04-20 05:31:16 +08:00
|
|
|
|
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 {
|
2021-07-03 02:27:37 +08:00
|
|
|
PluginInfo() = default;
|
2014-08-28 04:15:09 +08:00
|
|
|
|
|
|
|
llvm::sys::DynamicLibrary library;
|
2013-04-20 05:31:16 +08:00
|
|
|
PluginInitCallback plugin_init_callback = nullptr;
|
|
|
|
PluginTermCallback plugin_term_callback = nullptr;
|
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;
|
|
|
|
|
2016-05-18 09:59:10 +08:00
|
|
|
static std::recursive_mutex &GetPluginMapMutex() {
|
|
|
|
static std::recursive_mutex g_plugin_map_mutex;
|
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
|
|
|
return g_plugin_map_mutex;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
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
|
|
|
static PluginTerminateMap &GetPluginMap() {
|
|
|
|
static PluginTerminateMap g_plugin_map;
|
|
|
|
return g_plugin_map;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
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
|
|
|
static bool PluginIsLoaded(const FileSpec &plugin_file_spec) {
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
|
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
|
|
|
PluginTerminateMap &plugin_map = GetPluginMap();
|
|
|
|
return plugin_map.find(plugin_file_spec) != plugin_map.end();
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
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
|
|
|
static void SetPluginInfo(const FileSpec &plugin_file_spec,
|
|
|
|
const PluginInfo &plugin_info) {
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
|
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
|
|
|
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;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-07-23 05:59:22 +08:00
|
|
|
template <typename FPtrTy> static FPtrTy CastToFPtr(void *VPtr) {
|
[lldb] Fix ARM32 inferior calls
echo -e '#include <unistd.h>\nint main(void){\nsync();return 0;}'|./bin/clang -g -x c -;./bin/lldb -o 'file ./a.out' -o 'b main' -o r -o 'p (void)sync()'
Actual:
error: Expression can't be run, because there is no JIT compiled function
Expected:
<nothing, sync() has been executed>
This patch has been checked by:
D71707: clang-tidy: new bugprone-pointer-cast-widening
https://reviews.llvm.org/D71707
Casting from 32-bit `void *` to `uint64_t` requires an intermediate `uintptr_t` cast otherwise the pointer gets sign-extended:
echo -e '#include <stdio.h>\n#include <stdint.h>\nint main(void){void *p=(void *)0x80000000;unsigned long long ull=(unsigned long long)p;unsigned long long ull2=(unsigned long
long)(uintptr_t)p;printf("p=%p ull=0x%llx ull2=0x%llx\\n",p,ull,ull2);return 0;}'|gcc -Wall -m32 -x c -;./a.out
<stdin>: In function ‘main’:
<stdin>:3:66: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
p=0x80000000 ull=0xffffffff80000000 ull2=0x80000000
With debug output:
Actual:
IRMemoryMap::WriteMemory (0xb6ff8640, 0xffffffffb6f82158, 0x112) went to [0xb6ff8640..0xb6ff86b3)
Code can be run in the target.
Found function, has local address 0xffffffffb6f84000 and remote address 0xffffffffffffffff
Couldn't disassemble function : Couldn't find code range for function _Z12$__lldb_exprPv
Sections:
[0xb6f84000+0x3c]->0xb6ff9020 (alignment 4, section ID 0, name .text)
...
HandleCommand, command did not succeed
error: Expression can't be run, because there is no JIT compiled function
Expected:
IRMemoryMap::WriteMemory (0xb6ff8640, 0xb6faa15c, 0x128) went to [0xb6ff8640..0xb6ff86c3)
IRExecutionUnit::GetRemoteAddressForLocal() found 0xb6fac000 in [0xb6fac000..0xb6fac040], and returned 0xb6ff9020 from [0xb6ff9020..0xb6ff9060].
Code can be run in the target.
Found function, has local address 0xb6fac000 and remote address 0xb6ff9020
Function's code range is [0xb6ff9020+0x40]
...
Function data has contents:
0xb6ff9020: 10 4c 2d e9 08 b0 8d e2 08 d0 4d e2 00 40 a0 e1
...
Function disassembly:
0xb6ff9020: 0xe92d4c10 push {r4, r10, r11, lr}
Differential revision: https://reviews.llvm.org/D71498
2019-12-21 18:12:17 +08:00
|
|
|
return reinterpret_cast<FPtrTy>(VPtr);
|
2014-07-23 05:59:22 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-11-01 08:33:27 +08:00
|
|
|
static FileSystem::EnumerateDirectoryResult
|
2017-03-09 01:56:08 +08:00
|
|
|
LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
|
2018-11-01 08:33:27 +08:00
|
|
|
llvm::StringRef path) {
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-03-09 01:56:08 +08:00
|
|
|
namespace fs = llvm::sys::fs;
|
2018-05-01 00:49:04 +08:00
|
|
|
// 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
|
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
|
|
|
// enumeration might be enumerating a file system that doesn't have correct
|
|
|
|
// file type information.
|
2017-03-09 01:56:08 +08:00
|
|
|
if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
|
|
|
|
ft == fs::file_type::type_unknown) {
|
2018-11-02 05:05:36 +08:00
|
|
|
FileSpec plugin_file_spec(path);
|
|
|
|
FileSystem::Instance().Resolve(plugin_file_spec);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
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 (PluginIsLoaded(plugin_file_spec))
|
2018-11-01 08:33:27 +08:00
|
|
|
return FileSystem::eEnumerateDirectoryResultNext;
|
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 {
|
2014-08-28 04:15:09 +08:00
|
|
|
PluginInfo plugin_info;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-08-28 04:15:09 +08:00
|
|
|
std::string pluginLoadError;
|
|
|
|
plugin_info.library = llvm::sys::DynamicLibrary::getPermanentLibrary(
|
|
|
|
plugin_file_spec.GetPath().c_str(), &pluginLoadError);
|
|
|
|
if (plugin_info.library.isValid()) {
|
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
|
|
|
bool success = false;
|
2014-07-23 05:59:22 +08:00
|
|
|
plugin_info.plugin_init_callback = CastToFPtr<PluginInitCallback>(
|
2014-08-28 04:15:09 +08:00
|
|
|
plugin_info.library.getAddressOfSymbol("LLDBPluginInitialize"));
|
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
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
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) {
|
2016-03-12 05:55:47 +08:00
|
|
|
// It is ok for the "LLDBPluginTerminate" symbol to be nullptr
|
2014-07-23 05:59:22 +08:00
|
|
|
plugin_info.plugin_term_callback = CastToFPtr<PluginTermCallback>(
|
2014-08-28 04:15:09 +08:00
|
|
|
plugin_info.library.getAddressOfSymbol("LLDBPluginTerminate"));
|
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 {
|
2014-08-28 04:15:09 +08:00
|
|
|
// The initialize function returned FALSE which means the plug-in
|
2018-05-01 00:49:04 +08:00
|
|
|
// might not be compatible, or might be too new or too old, or might
|
|
|
|
// not want to run on this machine. Set it to a default-constructed
|
|
|
|
// instance to invalidate it.
|
2014-08-28 04:15:09 +08:00
|
|
|
plugin_info = PluginInfo();
|
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
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// 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.
|
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
|
|
|
SetPluginInfo(plugin_file_spec, plugin_info);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-11-01 08:33:27 +08:00
|
|
|
return FileSystem::eEnumerateDirectoryResultNext;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-03-09 01:56:08 +08:00
|
|
|
if (ft == fs::file_type::directory_file ||
|
|
|
|
ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) {
|
2018-05-01 00:49:04 +08:00
|
|
|
// 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
|
|
|
|
// enumerating a file system that doesn't have correct file type
|
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
|
|
|
// information.
|
2018-11-01 08:33:27 +08:00
|
|
|
return FileSystem::eEnumerateDirectoryResultEnter;
|
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
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-11-01 08:33:27 +08:00
|
|
|
return FileSystem::eEnumerateDirectoryResultNext;
|
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
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
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::Initialize() {
|
|
|
|
const bool find_directories = true;
|
|
|
|
const bool find_files = true;
|
|
|
|
const bool find_other = true;
|
|
|
|
char dir_path[PATH_MAX];
|
2018-06-19 23:09:07 +08:00
|
|
|
if (FileSpec dir_spec = HostInfo::GetSystemPluginDir()) {
|
2018-11-02 01:09:25 +08:00
|
|
|
if (FileSystem::Instance().Exists(dir_spec) &&
|
|
|
|
dir_spec.GetPath(dir_path, sizeof(dir_path))) {
|
2018-11-01 08:33:27 +08:00
|
|
|
FileSystem::Instance().EnumerateDirectory(dir_path, find_directories,
|
|
|
|
find_files, find_other,
|
|
|
|
LoadPluginCallback, nullptr);
|
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
|
|
|
}
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-06-19 23:09:07 +08:00
|
|
|
if (FileSpec dir_spec = HostInfo::GetUserPluginDir()) {
|
2018-11-02 01:09:25 +08:00
|
|
|
if (FileSystem::Instance().Exists(dir_spec) &&
|
|
|
|
dir_spec.GetPath(dir_path, sizeof(dir_path))) {
|
2018-11-01 08:33:27 +08:00
|
|
|
FileSystem::Instance().EnumerateDirectory(dir_path, find_directories,
|
|
|
|
find_files, find_other,
|
|
|
|
LoadPluginCallback, nullptr);
|
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() {
|
2016-05-18 09:59:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(GetPluginMapMutex());
|
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
|
|
|
PluginTerminateMap &plugin_map = GetPluginMap();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
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
|
|
|
PluginTerminateMap::const_iterator pos, end = plugin_map.end();
|
|
|
|
for (pos = plugin_map.begin(); pos != end; ++pos) {
|
2018-05-01 00:49:04 +08:00
|
|
|
// Call the plug-in "void LLDBPluginTerminate (void)" function if there is
|
|
|
|
// one (if the symbol was not nullptr).
|
2014-08-28 04:15:09 +08:00
|
|
|
if (pos->second.library.isValid()) {
|
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 (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
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
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.clear();
|
|
|
|
}
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
template <typename Callback> struct PluginInstance {
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef Callback CallbackType;
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
PluginInstance() = default;
|
2021-11-03 19:59:51 +08:00
|
|
|
PluginInstance(llvm::StringRef name, llvm::StringRef description,
|
|
|
|
Callback create_callback,
|
2020-02-19 09:08:46 +08:00
|
|
|
DebuggerInitializeCallback debugger_init_callback = nullptr)
|
2021-11-03 19:59:51 +08:00
|
|
|
: name(name), description(description), create_callback(create_callback),
|
2020-02-19 09:08:46 +08:00
|
|
|
debugger_init_callback(debugger_init_callback) {}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2021-11-03 19:59:51 +08:00
|
|
|
llvm::StringRef name;
|
|
|
|
llvm::StringRef description;
|
2020-02-19 09:08:46 +08:00
|
|
|
Callback create_callback;
|
|
|
|
DebuggerInitializeCallback debugger_init_callback;
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
|
|
|
|
2020-02-19 15:52:07 +08:00
|
|
|
template <typename Instance> class PluginInstances {
|
|
|
|
public:
|
|
|
|
template <typename... Args>
|
2021-11-03 19:59:51 +08:00
|
|
|
bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
|
2020-02-19 15:52:07 +08:00
|
|
|
typename Instance::CallbackType callback,
|
2021-11-03 19:59:51 +08:00
|
|
|
Args &&...args) {
|
2020-02-19 15:52:07 +08:00
|
|
|
if (!callback)
|
|
|
|
return false;
|
2021-11-03 19:59:51 +08:00
|
|
|
assert(!name.empty());
|
2020-02-19 15:52:07 +08:00
|
|
|
Instance instance =
|
|
|
|
Instance(name, description, callback, std::forward<Args>(args)...);
|
|
|
|
m_instances.push_back(instance);
|
|
|
|
return false;
|
|
|
|
}
|
2020-02-19 09:08:46 +08:00
|
|
|
|
2020-02-19 15:52:07 +08:00
|
|
|
bool UnregisterPlugin(typename Instance::CallbackType callback) {
|
|
|
|
if (!callback)
|
|
|
|
return false;
|
|
|
|
auto pos = m_instances.begin();
|
|
|
|
auto end = m_instances.end();
|
|
|
|
for (; pos != end; ++pos) {
|
|
|
|
if (pos->create_callback == callback) {
|
|
|
|
m_instances.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2020-02-19 15:52:07 +08:00
|
|
|
typename Instance::CallbackType GetCallbackAtIndex(uint32_t idx) {
|
|
|
|
if (Instance *instance = GetInstanceAtIndex(idx))
|
|
|
|
return instance->create_callback;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2021-11-03 19:59:51 +08:00
|
|
|
llvm::StringRef GetDescriptionAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
if (Instance *instance = GetInstanceAtIndex(idx))
|
2021-11-03 19:59:51 +08:00
|
|
|
return instance->description;
|
|
|
|
return "";
|
2020-02-19 15:52:07 +08:00
|
|
|
}
|
|
|
|
|
2021-11-03 19:59:51 +08:00
|
|
|
llvm::StringRef GetNameAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
if (Instance *instance = GetInstanceAtIndex(idx))
|
2021-11-03 19:59:51 +08:00
|
|
|
return instance->name;
|
|
|
|
return "";
|
2020-02-19 15:52:07 +08:00
|
|
|
}
|
|
|
|
|
2021-11-03 19:59:51 +08:00
|
|
|
typename Instance::CallbackType GetCallbackForName(llvm::StringRef name) {
|
|
|
|
if (name.empty())
|
2020-02-19 15:52:07 +08:00
|
|
|
return nullptr;
|
|
|
|
for (auto &instance : m_instances) {
|
|
|
|
if (name == instance.name)
|
|
|
|
return instance.create_callback;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PerformDebuggerCallback(Debugger &debugger) {
|
|
|
|
for (auto &instance : m_instances) {
|
|
|
|
if (instance.debugger_init_callback)
|
|
|
|
instance.debugger_init_callback(debugger);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::vector<Instance> &GetInstances() const { return m_instances; }
|
|
|
|
std::vector<Instance> &GetInstances() { return m_instances; }
|
|
|
|
|
|
|
|
Instance *GetInstanceAtIndex(uint32_t idx) {
|
|
|
|
if (idx < m_instances.size())
|
|
|
|
return &m_instances[idx];
|
|
|
|
return nullptr;
|
|
|
|
}
|
[intel pt] Refactor parsing
With the feedback I was getting in different diffs, I realized that splitting the parsing logic into two classes was not easy to deal with. I do see value in doing that, but I'd rather leave that as a refactor after most of the intel-pt logic is in place. Thus, I'm merging the common parser into the intel pt one, having thus only one that is fully aware of Intel PT during parsing and object creation.
Besides, based on the feedback in https://reviews.llvm.org/D88769, I'm creating a ThreadIntelPT class that will be able to orchestrate decoding of its own trace and can handle the stop events correctly.
This leaves the TraceIntelPT class as an initialization class that glues together different components. Right now it can initialize a trace session from a json file, and in the future will be able to initialize a trace session from a live process.
Besides, I'm renaming SettingsParser to SessionParser, which I think is a better name, as the json object represents a trace session of possibly many processes.
With the current set of targets, we have the following
- Trace: main interface for dealing with trace sessions
- TraceIntelPT: plugin Trace for dealing with intel pt sessions
- TraceIntelPTSessionParser: a parser of a json trace session file that can create a corresponding TraceIntelPT instance along with Targets, ProcessTraces (to be created in https://reviews.llvm.org/D88769), and ThreadIntelPT threads.
- ProcessTrace: (to be created in https://reviews.llvm.org/D88769) can handle the correct state of the traces as the user traverses the trace. I don't think there'll be a need an intel-pt specific implementation of this class.
- ThreadIntelPT: a thread implementation that can handle the decoding of its own trace file, along with keeping track of the current position the user is looking at when doing reverse debugging.
Differential Revision: https://reviews.llvm.org/D88841
2020-10-04 03:23:12 +08:00
|
|
|
|
|
|
|
private:
|
2020-02-19 15:52:07 +08:00
|
|
|
std::vector<Instance> m_instances;
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma mark ABI
|
|
|
|
|
|
|
|
typedef PluginInstance<ABICreateInstance> ABIInstance;
|
|
|
|
typedef PluginInstances<ABIInstance> ABIInstances;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-03-19 09:12:21 +08:00
|
|
|
static ABIInstances &GetABIInstances() {
|
|
|
|
static ABIInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2021-10-19 19:09:38 +08:00
|
|
|
bool PluginManager::RegisterPlugin(llvm::StringRef name,
|
|
|
|
llvm::StringRef description,
|
2016-03-12 05:55:47 +08:00
|
|
|
ABICreateInstance create_callback) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetABIInstances().RegisterPlugin(name, description, create_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(ABICreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetABIInstances().UnregisterPlugin(create_callback);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ABICreateInstance PluginManager::GetABICreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetABIInstances().GetCallbackAtIndex(idx);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2017-10-26 05:05:31 +08:00
|
|
|
#pragma mark Architecture
|
|
|
|
|
2020-02-19 12:16:59 +08:00
|
|
|
typedef PluginInstance<ArchitectureCreateInstance> ArchitectureInstance;
|
2017-10-26 05:05:31 +08:00
|
|
|
typedef std::vector<ArchitectureInstance> ArchitectureInstances;
|
|
|
|
|
|
|
|
static ArchitectureInstances &GetArchitectureInstances() {
|
|
|
|
static ArchitectureInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
|
|
|
|
2021-10-19 19:09:38 +08:00
|
|
|
void PluginManager::RegisterPlugin(llvm::StringRef name,
|
2017-10-26 05:05:31 +08:00
|
|
|
llvm::StringRef description,
|
|
|
|
ArchitectureCreateInstance create_callback) {
|
2021-11-03 19:59:51 +08:00
|
|
|
GetArchitectureInstances().push_back({name, description, create_callback});
|
2017-10-26 05:05:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PluginManager::UnregisterPlugin(
|
|
|
|
ArchitectureCreateInstance create_callback) {
|
|
|
|
auto &instances = GetArchitectureInstances();
|
|
|
|
|
|
|
|
for (auto pos = instances.begin(), end = instances.end(); pos != end; ++pos) {
|
|
|
|
if (pos->create_callback == create_callback) {
|
|
|
|
instances.erase(pos);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
llvm_unreachable("Plugin not found");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<Architecture>
|
|
|
|
PluginManager::CreateArchitectureInstance(const ArchSpec &arch) {
|
|
|
|
for (const auto &instances : GetArchitectureInstances()) {
|
|
|
|
if (auto plugin_up = instances.create_callback(arch))
|
|
|
|
return plugin_up;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#pragma mark Disassembler
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
typedef PluginInstance<DisassemblerCreateInstance> DisassemblerInstance;
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<DisassemblerInstance> DisassemblerInstances;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static DisassemblerInstances &GetDisassemblerInstances() {
|
2011-04-26 05:14:26 +08:00
|
|
|
static DisassemblerInstances g_instances;
|
2010-06-09 00:52:24 +08:00
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2021-10-19 19:09:38 +08:00
|
|
|
bool PluginManager::RegisterPlugin(llvm::StringRef name,
|
|
|
|
llvm::StringRef description,
|
2010-06-09 00:52:24 +08:00
|
|
|
DisassemblerCreateInstance create_callback) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetDisassemblerInstances().RegisterPlugin(name, description,
|
|
|
|
create_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
2016-03-12 05:55:47 +08:00
|
|
|
DisassemblerCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetDisassemblerInstances().UnregisterPlugin(create_callback);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
DisassemblerCreateInstance
|
|
|
|
PluginManager::GetDisassemblerCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetDisassemblerInstances().GetCallbackAtIndex(idx);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
DisassemblerCreateInstance
|
2021-10-19 19:09:38 +08:00
|
|
|
PluginManager::GetDisassemblerCreateCallbackForPluginName(
|
|
|
|
llvm::StringRef name) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetDisassemblerInstances().GetCallbackForName(name);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark DynamicLoader
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
typedef PluginInstance<DynamicLoaderCreateInstance> DynamicLoaderInstance;
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<DynamicLoaderInstance> DynamicLoaderInstances;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
static DynamicLoaderInstances &GetDynamicLoaderInstances() {
|
2011-04-14 06:47:15 +08:00
|
|
|
static DynamicLoaderInstances g_instances;
|
2010-06-09 00:52:24 +08:00
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-21 19:32:42 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2010-06-09 00:52:24 +08:00
|
|
|
DynamicLoaderCreateInstance create_callback,
|
|
|
|
DebuggerInitializeCallback debugger_init_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetDynamicLoaderInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, debugger_init_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
2016-03-12 05:55:47 +08:00
|
|
|
DynamicLoaderCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetDynamicLoaderInstances().UnregisterPlugin(create_callback);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
DynamicLoaderCreateInstance
|
|
|
|
PluginManager::GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetDynamicLoaderInstances().GetCallbackAtIndex(idx);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
DynamicLoaderCreateInstance
|
2021-10-21 19:32:42 +08:00
|
|
|
PluginManager::GetDynamicLoaderCreateCallbackForPluginName(
|
|
|
|
llvm::StringRef name) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetDynamicLoaderInstances().GetCallbackForName(name);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2014-03-05 18:12:43 +08:00
|
|
|
#pragma mark JITLoader
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
typedef PluginInstance<JITLoaderCreateInstance> JITLoaderInstance;
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<JITLoaderInstance> JITLoaderInstances;
|
2014-03-05 18:12:43 +08:00
|
|
|
|
|
|
|
static JITLoaderInstances &GetJITLoaderInstances() {
|
|
|
|
static JITLoaderInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
|
|
|
|
2016-03-12 05:55:47 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-21 19:32:42 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2014-03-05 18:12:43 +08:00
|
|
|
JITLoaderCreateInstance create_callback,
|
|
|
|
DebuggerInitializeCallback debugger_init_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetJITLoaderInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, debugger_init_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2014-03-05 18:12:43 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(JITLoaderCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetJITLoaderInstances().UnregisterPlugin(create_callback);
|
2014-03-05 18:12:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
JITLoaderCreateInstance
|
|
|
|
PluginManager::GetJITLoaderCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetJITLoaderInstances().GetCallbackAtIndex(idx);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-02-01 09:37:45 +08:00
|
|
|
#pragma mark EmulateInstruction
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
typedef PluginInstance<EmulateInstructionCreateInstance>
|
|
|
|
EmulateInstructionInstance;
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<EmulateInstructionInstance> EmulateInstructionInstances;
|
2011-02-01 09:37:45 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static EmulateInstructionInstances &GetEmulateInstructionInstances() {
|
|
|
|
static EmulateInstructionInstances g_instances;
|
2011-02-01 09:37:45 +08:00
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-02-01 09:37:45 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-21 19:32:42 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2011-02-01 09:37:45 +08:00
|
|
|
EmulateInstructionCreateInstance create_callback) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetEmulateInstructionInstances().RegisterPlugin(name, description,
|
|
|
|
create_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
2016-03-12 05:55:47 +08:00
|
|
|
EmulateInstructionCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetEmulateInstructionInstances().UnregisterPlugin(create_callback);
|
2011-02-01 09:37:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
EmulateInstructionCreateInstance
|
|
|
|
PluginManager::GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetEmulateInstructionInstances().GetCallbackAtIndex(idx);
|
2011-02-01 09:37:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
EmulateInstructionCreateInstance
|
2013-05-11 05:47:16 +08:00
|
|
|
PluginManager::GetEmulateInstructionCreateCallbackForPluginName(
|
2021-10-21 19:32:42 +08:00
|
|
|
llvm::StringRef name) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetEmulateInstructionInstances().GetCallbackForName(name);
|
2011-08-22 10:49:39 +08:00
|
|
|
}
|
|
|
|
|
2016-03-12 05:55:47 +08:00
|
|
|
#pragma mark OperatingSystem
|
2011-08-22 10:49:39 +08:00
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
typedef PluginInstance<OperatingSystemCreateInstance> OperatingSystemInstance;
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<OperatingSystemInstance> OperatingSystemInstances;
|
2011-08-22 10:49:39 +08:00
|
|
|
|
|
|
|
static OperatingSystemInstances &GetOperatingSystemInstances() {
|
|
|
|
static OperatingSystemInstances g_instances;
|
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-08-22 10:49:39 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-18 16:39:58 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2011-08-22 10:49:39 +08:00
|
|
|
OperatingSystemCreateInstance create_callback,
|
|
|
|
DebuggerInitializeCallback debugger_init_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetOperatingSystemInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, debugger_init_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
2015-09-17 05:20:44 +08:00
|
|
|
OperatingSystemCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetOperatingSystemInstances().UnregisterPlugin(create_callback);
|
2011-08-22 10:49:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
OperatingSystemCreateInstance
|
|
|
|
PluginManager::GetOperatingSystemCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetOperatingSystemInstances().GetCallbackAtIndex(idx);
|
2011-08-22 10:49:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
OperatingSystemCreateInstance
|
2021-10-18 16:39:58 +08:00
|
|
|
PluginManager::GetOperatingSystemCreateCallbackForPluginName(
|
|
|
|
llvm::StringRef name) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetOperatingSystemInstances().GetCallbackForName(name);
|
2011-02-01 09:37:45 +08:00
|
|
|
}
|
|
|
|
|
2015-08-28 05:33:50 +08:00
|
|
|
#pragma mark Language
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
typedef PluginInstance<LanguageCreateInstance> LanguageInstance;
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<LanguageInstance> LanguageInstances;
|
2015-08-28 05:33:50 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static LanguageInstances &GetLanguageInstances() {
|
|
|
|
static LanguageInstances g_instances;
|
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2021-10-22 02:13:45 +08:00
|
|
|
bool PluginManager::RegisterPlugin(llvm::StringRef name,
|
|
|
|
llvm::StringRef description,
|
2016-03-12 05:55:47 +08:00
|
|
|
LanguageCreateInstance create_callback) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetLanguageInstances().RegisterPlugin(name, description,
|
|
|
|
create_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-08-28 05:33:50 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(LanguageCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetLanguageInstances().UnregisterPlugin(create_callback);
|
2015-08-28 05:33:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
LanguageCreateInstance
|
|
|
|
PluginManager::GetLanguageCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetLanguageInstances().GetCallbackAtIndex(idx);
|
2015-08-28 05:33:50 +08:00
|
|
|
}
|
|
|
|
|
2010-09-23 10:01:19 +08:00
|
|
|
#pragma mark LanguageRuntime
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
struct LanguageRuntimeInstance
|
|
|
|
: public PluginInstance<LanguageRuntimeCreateInstance> {
|
2020-02-19 15:52:07 +08:00
|
|
|
LanguageRuntimeInstance(
|
2021-11-03 19:59:51 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2021-10-22 02:13:45 +08:00
|
|
|
CallbackType create_callback,
|
2020-02-19 15:52:07 +08:00
|
|
|
DebuggerInitializeCallback debugger_init_callback,
|
|
|
|
LanguageRuntimeGetCommandObject command_callback,
|
|
|
|
LanguageRuntimeGetExceptionPrecondition precondition_callback)
|
|
|
|
: PluginInstance<LanguageRuntimeCreateInstance>(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, debugger_init_callback),
|
2020-02-19 15:52:07 +08:00
|
|
|
command_callback(command_callback),
|
|
|
|
precondition_callback(precondition_callback) {}
|
|
|
|
|
2015-05-05 02:39:38 +08:00
|
|
|
LanguageRuntimeGetCommandObject command_callback;
|
2019-06-22 03:43:07 +08:00
|
|
|
LanguageRuntimeGetExceptionPrecondition precondition_callback;
|
2010-09-23 10:01:19 +08:00
|
|
|
};
|
|
|
|
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<LanguageRuntimeInstance> LanguageRuntimeInstances;
|
2010-09-23 10:01:19 +08:00
|
|
|
|
|
|
|
static LanguageRuntimeInstances &GetLanguageRuntimeInstances() {
|
2011-04-14 06:47:15 +08:00
|
|
|
static LanguageRuntimeInstances g_instances;
|
2010-09-23 10:01:19 +08:00
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-09-23 10:01:19 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-22 02:13:45 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2010-09-23 10:01:19 +08:00
|
|
|
LanguageRuntimeCreateInstance create_callback,
|
2019-06-22 03:43:07 +08:00
|
|
|
LanguageRuntimeGetCommandObject command_callback,
|
|
|
|
LanguageRuntimeGetExceptionPrecondition precondition_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetLanguageRuntimeInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, nullptr, command_callback,
|
|
|
|
precondition_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
2016-03-12 05:55:47 +08:00
|
|
|
LanguageRuntimeCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetLanguageRuntimeInstances().UnregisterPlugin(create_callback);
|
2010-09-23 10:01:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
LanguageRuntimeCreateInstance
|
|
|
|
PluginManager::GetLanguageRuntimeCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetLanguageRuntimeInstances().GetCallbackAtIndex(idx);
|
2010-09-23 10:01:19 +08:00
|
|
|
}
|
|
|
|
|
2015-05-05 02:39:38 +08:00
|
|
|
LanguageRuntimeGetCommandObject
|
|
|
|
PluginManager::GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
const auto &instances = GetLanguageRuntimeInstances().GetInstances();
|
2015-05-05 02:39:38 +08:00
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].command_callback;
|
2016-03-12 05:55:47 +08:00
|
|
|
return nullptr;
|
2015-05-05 02:39:38 +08:00
|
|
|
}
|
|
|
|
|
2019-06-22 03:43:07 +08:00
|
|
|
LanguageRuntimeGetExceptionPrecondition
|
|
|
|
PluginManager::GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
const auto &instances = GetLanguageRuntimeInstances().GetInstances();
|
2019-06-22 03:43:07 +08:00
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].precondition_callback;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-11-05 11:57:19 +08:00
|
|
|
#pragma mark SystemRuntime
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
typedef PluginInstance<SystemRuntimeCreateInstance> SystemRuntimeInstance;
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<SystemRuntimeInstance> SystemRuntimeInstances;
|
2013-11-05 11:57:19 +08:00
|
|
|
|
|
|
|
static SystemRuntimeInstances &GetSystemRuntimeInstances() {
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
static SystemRuntimeInstances g_instances;
|
2013-11-05 11:57:19 +08:00
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2013-11-05 11:57:19 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-22 02:13:45 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2013-11-05 11:57:19 +08:00
|
|
|
SystemRuntimeCreateInstance create_callback) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetSystemRuntimeInstances().RegisterPlugin(name, description,
|
|
|
|
create_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
2016-03-12 05:55:47 +08:00
|
|
|
SystemRuntimeCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetSystemRuntimeInstances().UnregisterPlugin(create_callback);
|
2013-11-05 11:57:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SystemRuntimeCreateInstance
|
|
|
|
PluginManager::GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetSystemRuntimeInstances().GetCallbackAtIndex(idx);
|
2013-11-05 11:57:19 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#pragma mark ObjectFile
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
struct ObjectFileInstance : public PluginInstance<ObjectFileCreateInstance> {
|
2020-02-19 15:52:07 +08:00
|
|
|
ObjectFileInstance(
|
2021-11-03 19:59:51 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
|
|
|
CallbackType create_callback,
|
2020-02-19 15:52:07 +08:00
|
|
|
ObjectFileCreateMemoryInstance create_memory_callback,
|
|
|
|
ObjectFileGetModuleSpecifications get_module_specifications,
|
|
|
|
ObjectFileSaveCore save_core)
|
2021-11-03 19:59:51 +08:00
|
|
|
: PluginInstance<ObjectFileCreateInstance>(name, description,
|
2020-02-19 15:52:07 +08:00
|
|
|
create_callback),
|
|
|
|
create_memory_callback(create_memory_callback),
|
|
|
|
get_module_specifications(get_module_specifications),
|
|
|
|
save_core(save_core) {}
|
|
|
|
|
2012-02-05 10:38:54 +08:00
|
|
|
ObjectFileCreateMemoryInstance create_memory_callback;
|
2013-04-25 06:29:28 +08:00
|
|
|
ObjectFileGetModuleSpecifications get_module_specifications;
|
2014-06-13 08:54:12 +08:00
|
|
|
ObjectFileSaveCore save_core;
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<ObjectFileInstance> ObjectFileInstances;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
static ObjectFileInstances &GetObjectFileInstances() {
|
2011-04-14 06:47:15 +08:00
|
|
|
static ObjectFileInstances g_instances;
|
2010-06-09 00:52:24 +08:00
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-18 16:39:58 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2010-06-09 00:52:24 +08:00
|
|
|
ObjectFileCreateInstance create_callback,
|
2013-04-25 06:29:28 +08:00
|
|
|
ObjectFileCreateMemoryInstance create_memory_callback,
|
2014-06-13 08:54:12 +08:00
|
|
|
ObjectFileGetModuleSpecifications get_module_specifications,
|
2010-06-09 00:52:24 +08:00
|
|
|
ObjectFileSaveCore save_core) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetObjectFileInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, create_memory_callback,
|
|
|
|
get_module_specifications, save_core);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(ObjectFileCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetObjectFileInstances().UnregisterPlugin(create_callback);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ObjectFileCreateInstance
|
|
|
|
PluginManager::GetObjectFileCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetObjectFileInstances().GetCallbackAtIndex(idx);
|
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) {
|
2020-02-19 15:52:07 +08:00
|
|
|
const auto &instances = GetObjectFileInstances().GetInstances();
|
2012-02-05 10:38:54 +08:00
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].create_memory_callback;
|
2016-03-12 05:55:47 +08:00
|
|
|
return nullptr;
|
2012-02-05 10:38:54 +08:00
|
|
|
}
|
|
|
|
|
2013-04-25 06:29:28 +08:00
|
|
|
ObjectFileGetModuleSpecifications
|
|
|
|
PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex(
|
|
|
|
uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
const auto &instances = GetObjectFileInstances().GetInstances();
|
2013-04-25 06:29:28 +08:00
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].get_module_specifications;
|
2016-03-12 05:55:47 +08:00
|
|
|
return nullptr;
|
2013-04-25 06:29:28 +08:00
|
|
|
}
|
|
|
|
|
2014-06-13 08:54:12 +08:00
|
|
|
ObjectFileCreateMemoryInstance
|
|
|
|
PluginManager::GetObjectFileCreateMemoryCallbackForPluginName(
|
2021-10-18 16:39:58 +08:00
|
|
|
llvm::StringRef name) {
|
2020-02-19 15:52:07 +08:00
|
|
|
const auto &instances = GetObjectFileInstances().GetInstances();
|
|
|
|
for (auto &instance : instances) {
|
2021-11-03 19:59:51 +08:00
|
|
|
if (instance.name == name)
|
2020-02-19 15:52:07 +08:00
|
|
|
return instance.create_memory_callback;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2016-03-12 05:55:47 +08:00
|
|
|
return nullptr;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status PluginManager::SaveCore(const lldb::ProcessSP &process_sp,
|
2021-06-21 03:19:50 +08:00
|
|
|
const FileSpec &outfile,
|
2021-09-01 21:13:56 +08:00
|
|
|
lldb::SaveCoreStyle &core_style,
|
2021-10-18 16:39:58 +08:00
|
|
|
llvm::StringRef plugin_name) {
|
|
|
|
if (plugin_name.empty()) {
|
2021-04-27 04:47:05 +08:00
|
|
|
// Try saving core directly from the process plugin first.
|
|
|
|
llvm::Expected<bool> ret = process_sp->SaveCore(outfile.GetPath());
|
|
|
|
if (!ret)
|
2021-09-07 03:17:29 +08:00
|
|
|
return Status(ret.takeError());
|
2021-04-27 04:47:05 +08:00
|
|
|
if (ret.get())
|
|
|
|
return Status();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fall back to object plugins.
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2020-02-19 15:52:07 +08:00
|
|
|
auto &instances = GetObjectFileInstances().GetInstances();
|
|
|
|
for (auto &instance : instances) {
|
2021-11-03 19:59:51 +08:00
|
|
|
if (plugin_name.empty() || instance.name == plugin_name) {
|
2021-10-21 20:01:24 +08:00
|
|
|
if (instance.save_core &&
|
|
|
|
instance.save_core(process_sp, outfile, core_style, error))
|
|
|
|
return error;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2014-06-13 08:54:12 +08:00
|
|
|
error.SetErrorString(
|
|
|
|
"no ObjectFile plugins were able to save a core for this process");
|
|
|
|
return error;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
#pragma mark ObjectContainer
|
|
|
|
|
2020-02-19 15:52:07 +08:00
|
|
|
struct ObjectContainerInstance
|
|
|
|
: public PluginInstance<ObjectContainerCreateInstance> {
|
|
|
|
ObjectContainerInstance(
|
2021-11-03 19:59:51 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
|
|
|
CallbackType create_callback,
|
2020-02-19 15:52:07 +08:00
|
|
|
ObjectFileGetModuleSpecifications get_module_specifications)
|
2021-11-03 19:59:51 +08:00
|
|
|
: PluginInstance<ObjectContainerCreateInstance>(name, description,
|
|
|
|
create_callback),
|
2020-02-19 15:52:07 +08:00
|
|
|
get_module_specifications(get_module_specifications) {}
|
|
|
|
|
2013-04-25 06:29:28 +08:00
|
|
|
ObjectFileGetModuleSpecifications get_module_specifications;
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<ObjectContainerInstance> ObjectContainerInstances;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
static ObjectContainerInstances &GetObjectContainerInstances() {
|
2011-04-14 06:47:15 +08:00
|
|
|
static ObjectContainerInstances g_instances;
|
2010-06-09 00:52:24 +08:00
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-18 16:39:58 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2010-06-09 00:52:24 +08:00
|
|
|
ObjectContainerCreateInstance create_callback,
|
|
|
|
ObjectFileGetModuleSpecifications get_module_specifications) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetObjectContainerInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, get_module_specifications);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
2013-04-25 06:29:28 +08:00
|
|
|
ObjectContainerCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetObjectContainerInstances().UnregisterPlugin(create_callback);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ObjectContainerCreateInstance
|
|
|
|
PluginManager::GetObjectContainerCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetObjectContainerInstances().GetCallbackAtIndex(idx);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-04-14 06:47:15 +08:00
|
|
|
|
2013-04-25 06:29:28 +08:00
|
|
|
ObjectFileGetModuleSpecifications
|
|
|
|
PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex(
|
|
|
|
uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
const auto &instances = GetObjectContainerInstances().GetInstances();
|
2013-04-25 06:29:28 +08:00
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].get_module_specifications;
|
2016-03-12 05:55:47 +08:00
|
|
|
return nullptr;
|
2013-04-25 06:29:28 +08:00
|
|
|
}
|
|
|
|
|
2011-03-09 06:40:15 +08:00
|
|
|
#pragma mark Platform
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
typedef PluginInstance<PlatformCreateInstance> PlatformInstance;
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<PlatformInstance> PlatformInstances;
|
2011-03-09 06:40:15 +08:00
|
|
|
|
|
|
|
static PlatformInstances &GetPlatformInstances() {
|
2011-03-19 09:12:21 +08:00
|
|
|
static PlatformInstances g_platform_instances;
|
|
|
|
return g_platform_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-03-09 06:40:15 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-22 03:00:33 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2011-03-09 06:40:15 +08:00
|
|
|
PlatformCreateInstance create_callback,
|
|
|
|
DebuggerInitializeCallback debugger_init_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetPlatformInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, debugger_init_callback);
|
2020-02-19 15:52:07 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2020-02-19 15:52:07 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(PlatformCreateInstance create_callback) {
|
|
|
|
return GetPlatformInstances().UnregisterPlugin(create_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2021-10-22 03:00:33 +08:00
|
|
|
llvm::StringRef PluginManager::GetPlatformPluginNameAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetPlatformInstances().GetNameAtIndex(idx);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2021-10-22 03:00:33 +08:00
|
|
|
llvm::StringRef
|
|
|
|
PluginManager::GetPlatformPluginDescriptionAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetPlatformInstances().GetDescriptionAtIndex(idx);
|
2011-03-09 06:40:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
PlatformCreateInstance
|
|
|
|
PluginManager::GetPlatformCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetPlatformInstances().GetCallbackAtIndex(idx);
|
2011-03-09 06:40:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
PlatformCreateInstance
|
2021-10-22 03:00:33 +08:00
|
|
|
PluginManager::GetPlatformCreateCallbackForPluginName(llvm::StringRef name) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetPlatformInstances().GetCallbackForName(name);
|
2011-03-09 06:40:15 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
[lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:
* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.
I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.
A few words why those things should be removed/replaced:
* The return values are really cryptic, partly redundant and rarely documented.
They are also completely ignored by Xcode, so whatever information they contain will end up
breaking Xcode's completion mechanism. They are also partly impossible to even implement
as we assign negative values special meaning and our completion API sometimes returns size_t.
Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
in some untested code path to expand the history repeat character to the full command, but
I haven't figured out why that doesn't work at the moment.
Completion functions return -1 to 'insert the completion character', but that isn't implemented
(even though we seem to activate this feature in LLDB sometimes).
All positive values have to match the number of results. This is obviously just redundant information
as the user can just look at the result list to get that information (which is what Xcode does).
* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
that we calculate this to make the life of the API caller easier, but obviously forcing people to have
1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
0-based like Xcode has to do).
* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
idea is that we let the top-level API know that we just provided a full completion. Interestingly we
`WordComplete` is just a single bool that somehow represents all N completions. And we always
provide full completions in LLDB, so in theory it should always be true.
The only use it currently serves is providing redundant information about whether we have a single
definitive completion or not (which we already know from the number of results we get).
This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.
For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).
I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits
Reviewers: JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arphaman, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D66536
llvm-svn: 369624
2019-08-22 15:41:23 +08:00
|
|
|
void PluginManager::AutoCompletePlatformName(llvm::StringRef name,
|
|
|
|
CompletionRequest &request) {
|
2020-02-19 15:52:07 +08:00
|
|
|
for (const auto &instance : GetPlatformInstances().GetInstances()) {
|
2021-11-03 19:59:51 +08:00
|
|
|
if (instance.name.startswith(name))
|
|
|
|
request.AddCompletion(instance.name);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2011-04-14 06:47:15 +08:00
|
|
|
}
|
2016-03-12 05:55:47 +08:00
|
|
|
|
2011-03-09 06:40:15 +08:00
|
|
|
#pragma mark Process
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
typedef PluginInstance<ProcessCreateInstance> ProcessInstance;
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<ProcessInstance> ProcessInstances;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static ProcessInstances &GetProcessInstances() {
|
|
|
|
static ProcessInstances g_instances;
|
|
|
|
return g_instances;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-07-16 06:54:20 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-23 01:53:43 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2013-07-16 06:54:20 +08:00
|
|
|
ProcessCreateInstance create_callback,
|
|
|
|
DebuggerInitializeCallback debugger_init_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetProcessInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, debugger_init_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2020-02-19 15:52:07 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(ProcessCreateInstance create_callback) {
|
|
|
|
return GetProcessInstances().UnregisterPlugin(create_callback);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2021-10-23 01:53:43 +08:00
|
|
|
llvm::StringRef PluginManager::GetProcessPluginNameAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetProcessInstances().GetNameAtIndex(idx);
|
2011-02-18 09:44:25 +08:00
|
|
|
}
|
|
|
|
|
2021-10-23 01:53:43 +08:00
|
|
|
llvm::StringRef PluginManager::GetProcessPluginDescriptionAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetProcessInstances().GetDescriptionAtIndex(idx);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ProcessCreateInstance
|
|
|
|
PluginManager::GetProcessCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetProcessInstances().GetCallbackAtIndex(idx);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ProcessCreateInstance
|
2021-10-23 01:53:43 +08:00
|
|
|
PluginManager::GetProcessCreateCallbackForPluginName(llvm::StringRef name) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetProcessInstances().GetCallbackForName(name);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2020-05-27 20:06:28 +08:00
|
|
|
void PluginManager::AutoCompleteProcessName(llvm::StringRef name,
|
|
|
|
CompletionRequest &request) {
|
|
|
|
for (const auto &instance : GetProcessInstances().GetInstances()) {
|
2021-11-03 19:59:51 +08:00
|
|
|
if (instance.name.startswith(name))
|
|
|
|
request.AddCompletion(instance.name, instance.description);
|
2020-05-27 20:06:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-31 04:28:07 +08:00
|
|
|
#pragma mark ScriptInterpreter
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
struct ScriptInterpreterInstance
|
|
|
|
: public PluginInstance<ScriptInterpreterCreateInstance> {
|
2021-11-03 19:59:51 +08:00
|
|
|
ScriptInterpreterInstance(llvm::StringRef name, llvm::StringRef description,
|
2020-02-19 15:52:07 +08:00
|
|
|
CallbackType create_callback,
|
|
|
|
lldb::ScriptLanguage language)
|
2021-11-03 19:59:51 +08:00
|
|
|
: PluginInstance<ScriptInterpreterCreateInstance>(name, description,
|
|
|
|
create_callback),
|
2020-02-19 15:52:07 +08:00
|
|
|
language(language) {}
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
lldb::ScriptLanguage language = lldb::eScriptLanguageNone;
|
2015-07-31 04:28:07 +08:00
|
|
|
};
|
|
|
|
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<ScriptInterpreterInstance> ScriptInterpreterInstances;
|
2015-07-31 04:28:07 +08:00
|
|
|
|
|
|
|
static ScriptInterpreterInstances &GetScriptInterpreterInstances() {
|
|
|
|
static ScriptInterpreterInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-23 01:53:43 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2015-07-31 04:28:07 +08:00
|
|
|
lldb::ScriptLanguage script_language,
|
|
|
|
ScriptInterpreterCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetScriptInterpreterInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, script_language);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-07-31 04:28:07 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
|
|
|
ScriptInterpreterCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetScriptInterpreterInstances().UnregisterPlugin(create_callback);
|
2015-07-31 04:28:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ScriptInterpreterCreateInstance
|
|
|
|
PluginManager::GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetScriptInterpreterInstances().GetCallbackAtIndex(idx);
|
2015-07-31 04:28:07 +08:00
|
|
|
}
|
|
|
|
|
2019-04-27 01:58:19 +08:00
|
|
|
lldb::ScriptInterpreterSP
|
|
|
|
PluginManager::GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang,
|
|
|
|
Debugger &debugger) {
|
2020-02-19 15:52:07 +08:00
|
|
|
const auto &instances = GetScriptInterpreterInstances().GetInstances();
|
2015-07-31 04:28:07 +08:00
|
|
|
ScriptInterpreterCreateInstance none_instance = nullptr;
|
2020-02-19 15:52:07 +08:00
|
|
|
for (const auto &instance : instances) {
|
|
|
|
if (instance.language == lldb::eScriptLanguageNone)
|
|
|
|
none_instance = instance.create_callback;
|
2015-07-31 04:28:07 +08:00
|
|
|
|
2020-02-19 15:52:07 +08:00
|
|
|
if (script_lang == instance.language)
|
|
|
|
return instance.create_callback(debugger);
|
2015-07-31 04:28:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we didn't find one, return the ScriptInterpreter for the null language.
|
|
|
|
assert(none_instance != nullptr);
|
2019-04-27 01:58:19 +08:00
|
|
|
return none_instance(debugger);
|
2015-07-31 04:28:07 +08:00
|
|
|
}
|
|
|
|
|
2016-08-19 12:21:48 +08:00
|
|
|
#pragma mark StructuredDataPlugin
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
struct StructuredDataPluginInstance
|
|
|
|
: public PluginInstance<StructuredDataPluginCreateInstance> {
|
2020-02-19 15:52:07 +08:00
|
|
|
StructuredDataPluginInstance(
|
2021-11-03 19:59:51 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
|
|
|
CallbackType create_callback,
|
2020-02-19 15:52:07 +08:00
|
|
|
DebuggerInitializeCallback debugger_init_callback,
|
|
|
|
StructuredDataFilterLaunchInfo filter_callback)
|
|
|
|
: PluginInstance<StructuredDataPluginCreateInstance>(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, debugger_init_callback),
|
2020-02-19 15:52:07 +08:00
|
|
|
filter_callback(filter_callback) {}
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
StructuredDataFilterLaunchInfo filter_callback = nullptr;
|
2016-08-19 12:21:48 +08:00
|
|
|
};
|
|
|
|
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<StructuredDataPluginInstance>
|
|
|
|
StructuredDataPluginInstances;
|
2016-08-19 12:21:48 +08:00
|
|
|
|
|
|
|
static StructuredDataPluginInstances &GetStructuredDataPluginInstances() {
|
|
|
|
static StructuredDataPluginInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
|
|
|
|
2016-03-12 05:55:47 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-23 01:53:43 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2016-08-19 12:21:48 +08:00
|
|
|
StructuredDataPluginCreateInstance create_callback,
|
|
|
|
DebuggerInitializeCallback debugger_init_callback,
|
|
|
|
StructuredDataFilterLaunchInfo filter_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetStructuredDataPluginInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, debugger_init_callback,
|
|
|
|
filter_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2016-08-19 12:21:48 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
|
|
|
StructuredDataPluginCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetStructuredDataPluginInstances().UnregisterPlugin(create_callback);
|
2016-08-19 12:21:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
StructuredDataPluginCreateInstance
|
|
|
|
PluginManager::GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetStructuredDataPluginInstances().GetCallbackAtIndex(idx);
|
2016-08-19 12:21:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
StructuredDataFilterLaunchInfo
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
PluginManager::GetStructuredDataFilterCallbackAtIndex(
|
2016-08-19 12:21:48 +08:00
|
|
|
uint32_t idx, bool &iteration_complete) {
|
2020-02-19 15:52:07 +08:00
|
|
|
const auto &instances = GetStructuredDataPluginInstances().GetInstances();
|
2011-04-14 06:47:15 +08:00
|
|
|
if (idx < instances.size()) {
|
2016-08-19 12:21:48 +08:00
|
|
|
iteration_complete = false;
|
2015-10-09 07:07:53 +08:00
|
|
|
return instances[idx].filter_callback;
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2016-08-19 12:21:48 +08:00
|
|
|
iteration_complete = true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2016-03-12 05:55:47 +08:00
|
|
|
return nullptr;
|
2016-08-19 12:21:48 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#pragma mark SymbolFile
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
typedef PluginInstance<SymbolFileCreateInstance> SymbolFileInstance;
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<SymbolFileInstance> SymbolFileInstances;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-04-14 06:47:15 +08:00
|
|
|
static SymbolFileInstances &GetSymbolFileInstances() {
|
|
|
|
static SymbolFileInstances g_instances;
|
2011-03-19 09:12:21 +08:00
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-22 02:13:45 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2016-03-12 05:55:47 +08:00
|
|
|
SymbolFileCreateInstance create_callback,
|
2013-04-05 13:06:39 +08:00
|
|
|
DebuggerInitializeCallback debugger_init_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetSymbolFileInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, debugger_init_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(SymbolFileCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetSymbolFileInstances().UnregisterPlugin(create_callback);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SymbolFileCreateInstance
|
|
|
|
PluginManager::GetSymbolFileCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetSymbolFileInstances().GetCallbackAtIndex(idx);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-04-14 06:47:15 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#pragma mark SymbolVendor
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
typedef PluginInstance<SymbolVendorCreateInstance> SymbolVendorInstance;
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<SymbolVendorInstance> SymbolVendorInstances;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
static SymbolVendorInstances &GetSymbolVendorInstances() {
|
2011-04-14 06:47:15 +08:00
|
|
|
static SymbolVendorInstances g_instances;
|
2010-06-09 00:52:24 +08:00
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2021-10-29 17:40:54 +08:00
|
|
|
bool PluginManager::RegisterPlugin(llvm::StringRef name,
|
|
|
|
llvm::StringRef description,
|
2010-06-09 00:52:24 +08:00
|
|
|
SymbolVendorCreateInstance create_callback) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetSymbolVendorInstances().RegisterPlugin(name, description,
|
|
|
|
create_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
2016-03-12 05:55:47 +08:00
|
|
|
SymbolVendorCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetSymbolVendorInstances().UnregisterPlugin(create_callback);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SymbolVendorCreateInstance
|
|
|
|
PluginManager::GetSymbolVendorCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetSymbolVendorInstances().GetCallbackAtIndex(idx);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2020-08-18 08:21:52 +08:00
|
|
|
#pragma mark Trace
|
|
|
|
|
2020-11-10 05:36:26 +08:00
|
|
|
struct TraceInstance
|
|
|
|
: public PluginInstance<TraceCreateInstanceForSessionFile> {
|
|
|
|
TraceInstance(
|
2021-11-03 19:59:51 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2020-11-10 05:36:26 +08:00
|
|
|
CallbackType create_callback_for_session_file,
|
|
|
|
TraceCreateInstanceForLiveProcess create_callback_for_live_process,
|
|
|
|
llvm::StringRef schema)
|
|
|
|
: PluginInstance<TraceCreateInstanceForSessionFile>(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback_for_session_file),
|
2020-11-10 05:36:26 +08:00
|
|
|
schema(schema),
|
|
|
|
create_callback_for_live_process(create_callback_for_live_process) {}
|
[intel pt] Refactor parsing
With the feedback I was getting in different diffs, I realized that splitting the parsing logic into two classes was not easy to deal with. I do see value in doing that, but I'd rather leave that as a refactor after most of the intel-pt logic is in place. Thus, I'm merging the common parser into the intel pt one, having thus only one that is fully aware of Intel PT during parsing and object creation.
Besides, based on the feedback in https://reviews.llvm.org/D88769, I'm creating a ThreadIntelPT class that will be able to orchestrate decoding of its own trace and can handle the stop events correctly.
This leaves the TraceIntelPT class as an initialization class that glues together different components. Right now it can initialize a trace session from a json file, and in the future will be able to initialize a trace session from a live process.
Besides, I'm renaming SettingsParser to SessionParser, which I think is a better name, as the json object represents a trace session of possibly many processes.
With the current set of targets, we have the following
- Trace: main interface for dealing with trace sessions
- TraceIntelPT: plugin Trace for dealing with intel pt sessions
- TraceIntelPTSessionParser: a parser of a json trace session file that can create a corresponding TraceIntelPT instance along with Targets, ProcessTraces (to be created in https://reviews.llvm.org/D88769), and ThreadIntelPT threads.
- ProcessTrace: (to be created in https://reviews.llvm.org/D88769) can handle the correct state of the traces as the user traverses the trace. I don't think there'll be a need an intel-pt specific implementation of this class.
- ThreadIntelPT: a thread implementation that can handle the decoding of its own trace file, along with keeping track of the current position the user is looking at when doing reverse debugging.
Differential Revision: https://reviews.llvm.org/D88841
2020-10-04 03:23:12 +08:00
|
|
|
|
|
|
|
llvm::StringRef schema;
|
2020-11-10 05:36:26 +08:00
|
|
|
TraceCreateInstanceForLiveProcess create_callback_for_live_process;
|
[intel pt] Refactor parsing
With the feedback I was getting in different diffs, I realized that splitting the parsing logic into two classes was not easy to deal with. I do see value in doing that, but I'd rather leave that as a refactor after most of the intel-pt logic is in place. Thus, I'm merging the common parser into the intel pt one, having thus only one that is fully aware of Intel PT during parsing and object creation.
Besides, based on the feedback in https://reviews.llvm.org/D88769, I'm creating a ThreadIntelPT class that will be able to orchestrate decoding of its own trace and can handle the stop events correctly.
This leaves the TraceIntelPT class as an initialization class that glues together different components. Right now it can initialize a trace session from a json file, and in the future will be able to initialize a trace session from a live process.
Besides, I'm renaming SettingsParser to SessionParser, which I think is a better name, as the json object represents a trace session of possibly many processes.
With the current set of targets, we have the following
- Trace: main interface for dealing with trace sessions
- TraceIntelPT: plugin Trace for dealing with intel pt sessions
- TraceIntelPTSessionParser: a parser of a json trace session file that can create a corresponding TraceIntelPT instance along with Targets, ProcessTraces (to be created in https://reviews.llvm.org/D88769), and ThreadIntelPT threads.
- ProcessTrace: (to be created in https://reviews.llvm.org/D88769) can handle the correct state of the traces as the user traverses the trace. I don't think there'll be a need an intel-pt specific implementation of this class.
- ThreadIntelPT: a thread implementation that can handle the decoding of its own trace file, along with keeping track of the current position the user is looking at when doing reverse debugging.
Differential Revision: https://reviews.llvm.org/D88841
2020-10-04 03:23:12 +08:00
|
|
|
};
|
|
|
|
|
2020-08-18 08:21:52 +08:00
|
|
|
typedef PluginInstances<TraceInstance> TraceInstances;
|
|
|
|
|
2020-10-27 12:22:06 +08:00
|
|
|
static TraceInstances &GetTracePluginInstances() {
|
2020-08-18 08:21:52 +08:00
|
|
|
static TraceInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
|
|
|
|
2020-11-10 05:36:26 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-29 17:40:54 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2020-11-10 05:36:26 +08:00
|
|
|
TraceCreateInstanceForSessionFile create_callback_for_session_file,
|
|
|
|
TraceCreateInstanceForLiveProcess create_callback_for_live_process,
|
|
|
|
llvm::StringRef schema) {
|
2020-10-27 12:22:06 +08:00
|
|
|
return GetTracePluginInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback_for_session_file,
|
|
|
|
create_callback_for_live_process, schema);
|
2020-08-18 08:21:52 +08:00
|
|
|
}
|
|
|
|
|
2020-11-10 05:36:26 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
|
|
|
TraceCreateInstanceForSessionFile create_callback_for_session_file) {
|
|
|
|
return GetTracePluginInstances().UnregisterPlugin(
|
|
|
|
create_callback_for_session_file);
|
2020-08-18 08:21:52 +08:00
|
|
|
}
|
|
|
|
|
2020-11-10 05:36:26 +08:00
|
|
|
TraceCreateInstanceForSessionFile
|
2021-10-29 17:40:54 +08:00
|
|
|
PluginManager::GetTraceCreateCallback(llvm::StringRef plugin_name) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetTracePluginInstances().GetCallbackForName(plugin_name);
|
2020-08-18 08:21:52 +08:00
|
|
|
}
|
|
|
|
|
2020-11-10 05:36:26 +08:00
|
|
|
TraceCreateInstanceForLiveProcess
|
2021-10-29 17:40:54 +08:00
|
|
|
PluginManager::GetTraceCreateCallbackForLiveProcess(llvm::StringRef plugin_name) {
|
2020-10-27 12:22:06 +08:00
|
|
|
for (const TraceInstance &instance : GetTracePluginInstances().GetInstances())
|
2021-11-03 19:59:51 +08:00
|
|
|
if (instance.name == plugin_name)
|
2020-11-10 05:36:26 +08:00
|
|
|
return instance.create_callback_for_live_process;
|
|
|
|
return nullptr;
|
[intel pt] Refactor parsing
With the feedback I was getting in different diffs, I realized that splitting the parsing logic into two classes was not easy to deal with. I do see value in doing that, but I'd rather leave that as a refactor after most of the intel-pt logic is in place. Thus, I'm merging the common parser into the intel pt one, having thus only one that is fully aware of Intel PT during parsing and object creation.
Besides, based on the feedback in https://reviews.llvm.org/D88769, I'm creating a ThreadIntelPT class that will be able to orchestrate decoding of its own trace and can handle the stop events correctly.
This leaves the TraceIntelPT class as an initialization class that glues together different components. Right now it can initialize a trace session from a json file, and in the future will be able to initialize a trace session from a live process.
Besides, I'm renaming SettingsParser to SessionParser, which I think is a better name, as the json object represents a trace session of possibly many processes.
With the current set of targets, we have the following
- Trace: main interface for dealing with trace sessions
- TraceIntelPT: plugin Trace for dealing with intel pt sessions
- TraceIntelPTSessionParser: a parser of a json trace session file that can create a corresponding TraceIntelPT instance along with Targets, ProcessTraces (to be created in https://reviews.llvm.org/D88769), and ThreadIntelPT threads.
- ProcessTrace: (to be created in https://reviews.llvm.org/D88769) can handle the correct state of the traces as the user traverses the trace. I don't think there'll be a need an intel-pt specific implementation of this class.
- ThreadIntelPT: a thread implementation that can handle the decoding of its own trace file, along with keeping track of the current position the user is looking at when doing reverse debugging.
Differential Revision: https://reviews.llvm.org/D88841
2020-10-04 03:23:12 +08:00
|
|
|
}
|
|
|
|
|
2021-10-29 17:40:54 +08:00
|
|
|
llvm::StringRef PluginManager::GetTraceSchema(llvm::StringRef plugin_name) {
|
2020-10-27 12:22:06 +08:00
|
|
|
for (const TraceInstance &instance : GetTracePluginInstances().GetInstances())
|
2021-11-03 19:59:51 +08:00
|
|
|
if (instance.name == plugin_name)
|
2020-11-10 05:36:26 +08:00
|
|
|
return instance.schema;
|
|
|
|
return llvm::StringRef();
|
2020-10-27 12:22:06 +08:00
|
|
|
}
|
|
|
|
|
[intel pt] Refactor parsing
With the feedback I was getting in different diffs, I realized that splitting the parsing logic into two classes was not easy to deal with. I do see value in doing that, but I'd rather leave that as a refactor after most of the intel-pt logic is in place. Thus, I'm merging the common parser into the intel pt one, having thus only one that is fully aware of Intel PT during parsing and object creation.
Besides, based on the feedback in https://reviews.llvm.org/D88769, I'm creating a ThreadIntelPT class that will be able to orchestrate decoding of its own trace and can handle the stop events correctly.
This leaves the TraceIntelPT class as an initialization class that glues together different components. Right now it can initialize a trace session from a json file, and in the future will be able to initialize a trace session from a live process.
Besides, I'm renaming SettingsParser to SessionParser, which I think is a better name, as the json object represents a trace session of possibly many processes.
With the current set of targets, we have the following
- Trace: main interface for dealing with trace sessions
- TraceIntelPT: plugin Trace for dealing with intel pt sessions
- TraceIntelPTSessionParser: a parser of a json trace session file that can create a corresponding TraceIntelPT instance along with Targets, ProcessTraces (to be created in https://reviews.llvm.org/D88769), and ThreadIntelPT threads.
- ProcessTrace: (to be created in https://reviews.llvm.org/D88769) can handle the correct state of the traces as the user traverses the trace. I don't think there'll be a need an intel-pt specific implementation of this class.
- ThreadIntelPT: a thread implementation that can handle the decoding of its own trace file, along with keeping track of the current position the user is looking at when doing reverse debugging.
Differential Revision: https://reviews.llvm.org/D88841
2020-10-04 03:23:12 +08:00
|
|
|
llvm::StringRef PluginManager::GetTraceSchema(size_t index) {
|
2020-10-27 12:22:06 +08:00
|
|
|
if (TraceInstance *instance =
|
|
|
|
GetTracePluginInstances().GetInstanceAtIndex(index))
|
[intel pt] Refactor parsing
With the feedback I was getting in different diffs, I realized that splitting the parsing logic into two classes was not easy to deal with. I do see value in doing that, but I'd rather leave that as a refactor after most of the intel-pt logic is in place. Thus, I'm merging the common parser into the intel pt one, having thus only one that is fully aware of Intel PT during parsing and object creation.
Besides, based on the feedback in https://reviews.llvm.org/D88769, I'm creating a ThreadIntelPT class that will be able to orchestrate decoding of its own trace and can handle the stop events correctly.
This leaves the TraceIntelPT class as an initialization class that glues together different components. Right now it can initialize a trace session from a json file, and in the future will be able to initialize a trace session from a live process.
Besides, I'm renaming SettingsParser to SessionParser, which I think is a better name, as the json object represents a trace session of possibly many processes.
With the current set of targets, we have the following
- Trace: main interface for dealing with trace sessions
- TraceIntelPT: plugin Trace for dealing with intel pt sessions
- TraceIntelPTSessionParser: a parser of a json trace session file that can create a corresponding TraceIntelPT instance along with Targets, ProcessTraces (to be created in https://reviews.llvm.org/D88769), and ThreadIntelPT threads.
- ProcessTrace: (to be created in https://reviews.llvm.org/D88769) can handle the correct state of the traces as the user traverses the trace. I don't think there'll be a need an intel-pt specific implementation of this class.
- ThreadIntelPT: a thread implementation that can handle the decoding of its own trace file, along with keeping track of the current position the user is looking at when doing reverse debugging.
Differential Revision: https://reviews.llvm.org/D88841
2020-10-04 03:23:12 +08:00
|
|
|
return instance->schema;
|
|
|
|
return llvm::StringRef();
|
|
|
|
}
|
|
|
|
|
2021-07-22 05:46:51 +08:00
|
|
|
#pragma mark TraceExporter
|
|
|
|
|
|
|
|
struct TraceExporterInstance
|
|
|
|
: public PluginInstance<TraceExporterCreateInstance> {
|
|
|
|
TraceExporterInstance(
|
2021-11-03 19:59:51 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2021-07-22 05:46:51 +08:00
|
|
|
TraceExporterCreateInstance create_instance,
|
|
|
|
ThreadTraceExportCommandCreator create_thread_trace_export_command)
|
2021-11-03 19:59:51 +08:00
|
|
|
: PluginInstance<TraceExporterCreateInstance>(name, description,
|
|
|
|
create_instance),
|
2021-07-22 05:46:51 +08:00
|
|
|
create_thread_trace_export_command(create_thread_trace_export_command) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ThreadTraceExportCommandCreator create_thread_trace_export_command;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef PluginInstances<TraceExporterInstance> TraceExporterInstances;
|
|
|
|
|
|
|
|
static TraceExporterInstances &GetTraceExporterInstances() {
|
|
|
|
static TraceExporterInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-29 17:40:54 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2021-07-22 05:46:51 +08:00
|
|
|
TraceExporterCreateInstance create_callback,
|
|
|
|
ThreadTraceExportCommandCreator create_thread_trace_export_command) {
|
|
|
|
return GetTraceExporterInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, create_thread_trace_export_command);
|
2021-07-22 05:46:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TraceExporterCreateInstance
|
2021-10-29 17:40:54 +08:00
|
|
|
PluginManager::GetTraceExporterCreateCallback(llvm::StringRef plugin_name) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetTraceExporterInstances().GetCallbackForName(plugin_name);
|
2021-07-22 05:46:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PluginManager::UnregisterPlugin(
|
|
|
|
TraceExporterCreateInstance create_callback) {
|
|
|
|
return GetTraceExporterInstances().UnregisterPlugin(create_callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
ThreadTraceExportCommandCreator
|
|
|
|
PluginManager::GetThreadTraceExportCommandCreatorAtIndex(uint32_t index) {
|
|
|
|
if (TraceExporterInstance *instance =
|
|
|
|
GetTraceExporterInstances().GetInstanceAtIndex(index))
|
|
|
|
return instance->create_thread_trace_export_command;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2021-10-29 17:40:54 +08:00
|
|
|
llvm::StringRef
|
|
|
|
PluginManager::GetTraceExporterPluginNameAtIndex(uint32_t index) {
|
2021-07-22 05:46:51 +08:00
|
|
|
return GetTraceExporterInstances().GetNameAtIndex(index);
|
|
|
|
}
|
|
|
|
|
2011-04-26 05:14:26 +08:00
|
|
|
#pragma mark UnwindAssembly
|
2010-09-10 15:49:16 +08:00
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
typedef PluginInstance<UnwindAssemblyCreateInstance> UnwindAssemblyInstance;
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<UnwindAssemblyInstance> UnwindAssemblyInstances;
|
2010-09-10 15:49:16 +08:00
|
|
|
|
2011-04-26 05:14:26 +08:00
|
|
|
static UnwindAssemblyInstances &GetUnwindAssemblyInstances() {
|
|
|
|
static UnwindAssemblyInstances g_instances;
|
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2011-04-26 05:14:26 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-29 17:40:54 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2011-04-26 05:14:26 +08:00
|
|
|
UnwindAssemblyCreateInstance create_callback) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetUnwindAssemblyInstances().RegisterPlugin(name, description,
|
|
|
|
create_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
2016-03-12 05:55:47 +08:00
|
|
|
UnwindAssemblyCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetUnwindAssemblyInstances().UnregisterPlugin(create_callback);
|
2010-09-10 15:49:16 +08:00
|
|
|
}
|
|
|
|
|
2011-04-26 05:14:26 +08:00
|
|
|
UnwindAssemblyCreateInstance
|
|
|
|
PluginManager::GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetUnwindAssemblyInstances().GetCallbackAtIndex(idx);
|
2010-09-10 15:49:16 +08:00
|
|
|
}
|
|
|
|
|
2014-09-04 09:03:18 +08:00
|
|
|
#pragma mark MemoryHistory
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
typedef PluginInstance<MemoryHistoryCreateInstance> MemoryHistoryInstance;
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<MemoryHistoryInstance> MemoryHistoryInstances;
|
2014-09-04 09:03:18 +08:00
|
|
|
|
|
|
|
static MemoryHistoryInstances &GetMemoryHistoryInstances() {
|
|
|
|
static MemoryHistoryInstances g_instances;
|
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2014-09-04 09:03:18 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-29 17:40:54 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2014-09-04 09:03:18 +08:00
|
|
|
MemoryHistoryCreateInstance create_callback) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetMemoryHistoryInstances().RegisterPlugin(name, description,
|
|
|
|
create_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
2016-03-12 05:55:47 +08:00
|
|
|
MemoryHistoryCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetMemoryHistoryInstances().UnregisterPlugin(create_callback);
|
2014-09-04 09:03:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MemoryHistoryCreateInstance
|
|
|
|
PluginManager::GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetMemoryHistoryInstances().GetCallbackAtIndex(idx);
|
2014-09-04 09:03:18 +08:00
|
|
|
}
|
|
|
|
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
#pragma mark InstrumentationRuntime
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
struct InstrumentationRuntimeInstance
|
|
|
|
: public PluginInstance<InstrumentationRuntimeCreateInstance> {
|
2020-02-19 15:52:07 +08:00
|
|
|
InstrumentationRuntimeInstance(
|
2021-11-03 19:59:51 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
|
|
|
CallbackType create_callback,
|
2020-02-19 15:52:07 +08:00
|
|
|
InstrumentationRuntimeGetType get_type_callback)
|
2021-11-03 19:59:51 +08:00
|
|
|
: PluginInstance<InstrumentationRuntimeCreateInstance>(name, description,
|
|
|
|
create_callback),
|
2020-02-19 15:52:07 +08:00
|
|
|
get_type_callback(get_type_callback) {}
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
InstrumentationRuntimeGetType get_type_callback = nullptr;
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
};
|
|
|
|
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<InstrumentationRuntimeInstance>
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
InstrumentationRuntimeInstances;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
static InstrumentationRuntimeInstances &GetInstrumentationRuntimeInstances() {
|
|
|
|
static InstrumentationRuntimeInstances g_instances;
|
2016-08-19 12:21:48 +08:00
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2016-08-19 12:21:48 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-10-29 17:40:54 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
InstrumentationRuntimeCreateInstance create_callback,
|
2016-03-12 05:55:47 +08:00
|
|
|
InstrumentationRuntimeGetType get_type_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetInstrumentationRuntimeInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, get_type_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
InstrumentationRuntimeCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetInstrumentationRuntimeInstances().UnregisterPlugin(create_callback);
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
InstrumentationRuntimeGetType
|
|
|
|
PluginManager::GetInstrumentationRuntimeGetTypeCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
const auto &instances = GetInstrumentationRuntimeInstances().GetInstances();
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
if (idx < instances.size())
|
|
|
|
return instances[idx].get_type_callback;
|
2016-03-12 05:55:47 +08:00
|
|
|
return nullptr;
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
InstrumentationRuntimeCreateInstance
|
|
|
|
PluginManager::GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetInstrumentationRuntimeInstances().GetCallbackAtIndex(idx);
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
}
|
|
|
|
|
TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
This cleans up type systems to be more pluggable. Prior to this we had issues:
- Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()"
- Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem
- Cleaned up Module so that it no longer has dedicated type system member variables:
lldb::ClangASTContextUP m_ast; ///< The Clang AST context for this module.
lldb::GoASTContextUP m_go_ast; ///< The Go AST context for this module.
Now we have a type system map:
typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract:
class CompilerType
{
...
//----------------------------------------------------------------------
// Return a new CompilerType that is a L value reference to this type if
// this type is valid and the type system supports L value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetLValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType that is a R value reference to this type if
// this type is valid and the type system supports R value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetRValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a const modifier to this type if
// this type is valid and the type system supports const modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddConstModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a volatile modifier to this type if
// this type is valid and the type system supports volatile modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddVolatileModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a restrict modifier to this type if
// this type is valid and the type system supports restrict modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddRestrictModifier () const;
//----------------------------------------------------------------------
// Create a typedef to this type using "name" as the name of the typedef
// this type is valid and the type system supports typedefs, else return
// an invalid type.
//----------------------------------------------------------------------
CompilerType
CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
};
Other changes include:
- Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);"
- Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed
llvm-svn: 247953
2015-09-18 06:23:34 +08:00
|
|
|
#pragma mark TypeSystem
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
struct TypeSystemInstance : public PluginInstance<TypeSystemCreateInstance> {
|
2021-11-03 19:59:51 +08:00
|
|
|
TypeSystemInstance(llvm::StringRef name, llvm::StringRef description,
|
2020-02-19 15:52:07 +08:00
|
|
|
CallbackType create_callback,
|
|
|
|
LanguageSet supported_languages_for_types,
|
|
|
|
LanguageSet supported_languages_for_expressions)
|
2021-11-03 19:59:51 +08:00
|
|
|
: PluginInstance<TypeSystemCreateInstance>(name, description,
|
2020-02-19 15:52:07 +08:00
|
|
|
create_callback),
|
|
|
|
supported_languages_for_types(supported_languages_for_types),
|
|
|
|
supported_languages_for_expressions(
|
|
|
|
supported_languages_for_expressions) {}
|
|
|
|
|
2019-08-23 05:45:58 +08:00
|
|
|
LanguageSet supported_languages_for_types;
|
|
|
|
LanguageSet supported_languages_for_expressions;
|
TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
This cleans up type systems to be more pluggable. Prior to this we had issues:
- Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()"
- Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem
- Cleaned up Module so that it no longer has dedicated type system member variables:
lldb::ClangASTContextUP m_ast; ///< The Clang AST context for this module.
lldb::GoASTContextUP m_go_ast; ///< The Go AST context for this module.
Now we have a type system map:
typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract:
class CompilerType
{
...
//----------------------------------------------------------------------
// Return a new CompilerType that is a L value reference to this type if
// this type is valid and the type system supports L value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetLValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType that is a R value reference to this type if
// this type is valid and the type system supports R value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetRValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a const modifier to this type if
// this type is valid and the type system supports const modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddConstModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a volatile modifier to this type if
// this type is valid and the type system supports volatile modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddVolatileModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a restrict modifier to this type if
// this type is valid and the type system supports restrict modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddRestrictModifier () const;
//----------------------------------------------------------------------
// Create a typedef to this type using "name" as the name of the typedef
// this type is valid and the type system supports typedefs, else return
// an invalid type.
//----------------------------------------------------------------------
CompilerType
CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
};
Other changes include:
- Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);"
- Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed
llvm-svn: 247953
2015-09-18 06:23:34 +08:00
|
|
|
};
|
|
|
|
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<TypeSystemInstance> TypeSystemInstances;
|
TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
This cleans up type systems to be more pluggable. Prior to this we had issues:
- Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()"
- Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem
- Cleaned up Module so that it no longer has dedicated type system member variables:
lldb::ClangASTContextUP m_ast; ///< The Clang AST context for this module.
lldb::GoASTContextUP m_go_ast; ///< The Go AST context for this module.
Now we have a type system map:
typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract:
class CompilerType
{
...
//----------------------------------------------------------------------
// Return a new CompilerType that is a L value reference to this type if
// this type is valid and the type system supports L value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetLValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType that is a R value reference to this type if
// this type is valid and the type system supports R value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetRValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a const modifier to this type if
// this type is valid and the type system supports const modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddConstModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a volatile modifier to this type if
// this type is valid and the type system supports volatile modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddVolatileModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a restrict modifier to this type if
// this type is valid and the type system supports restrict modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddRestrictModifier () const;
//----------------------------------------------------------------------
// Create a typedef to this type using "name" as the name of the typedef
// this type is valid and the type system supports typedefs, else return
// an invalid type.
//----------------------------------------------------------------------
CompilerType
CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
};
Other changes include:
- Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);"
- Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed
llvm-svn: 247953
2015-09-18 06:23:34 +08:00
|
|
|
|
|
|
|
static TypeSystemInstances &GetTypeSystemInstances() {
|
|
|
|
static TypeSystemInstances g_instances;
|
2011-04-14 06:47:15 +08:00
|
|
|
return g_instances;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2019-08-23 05:45:58 +08:00
|
|
|
bool PluginManager::RegisterPlugin(
|
2021-11-02 23:09:14 +08:00
|
|
|
llvm::StringRef name, llvm::StringRef description,
|
2019-08-23 05:45:58 +08:00
|
|
|
TypeSystemCreateInstance create_callback,
|
|
|
|
LanguageSet supported_languages_for_types,
|
|
|
|
LanguageSet supported_languages_for_expressions) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetTypeSystemInstances().RegisterPlugin(
|
2021-11-03 19:59:51 +08:00
|
|
|
name, description, create_callback, supported_languages_for_types,
|
|
|
|
supported_languages_for_expressions);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
This cleans up type systems to be more pluggable. Prior to this we had issues:
- Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()"
- Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem
- Cleaned up Module so that it no longer has dedicated type system member variables:
lldb::ClangASTContextUP m_ast; ///< The Clang AST context for this module.
lldb::GoASTContextUP m_go_ast; ///< The Go AST context for this module.
Now we have a type system map:
typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract:
class CompilerType
{
...
//----------------------------------------------------------------------
// Return a new CompilerType that is a L value reference to this type if
// this type is valid and the type system supports L value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetLValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType that is a R value reference to this type if
// this type is valid and the type system supports R value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetRValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a const modifier to this type if
// this type is valid and the type system supports const modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddConstModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a volatile modifier to this type if
// this type is valid and the type system supports volatile modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddVolatileModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a restrict modifier to this type if
// this type is valid and the type system supports restrict modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddRestrictModifier () const;
//----------------------------------------------------------------------
// Create a typedef to this type using "name" as the name of the typedef
// this type is valid and the type system supports typedefs, else return
// an invalid type.
//----------------------------------------------------------------------
CompilerType
CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
};
Other changes include:
- Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);"
- Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed
llvm-svn: 247953
2015-09-18 06:23:34 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(TypeSystemCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetTypeSystemInstances().UnregisterPlugin(create_callback);
|
TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
This cleans up type systems to be more pluggable. Prior to this we had issues:
- Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()"
- Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem
- Cleaned up Module so that it no longer has dedicated type system member variables:
lldb::ClangASTContextUP m_ast; ///< The Clang AST context for this module.
lldb::GoASTContextUP m_go_ast; ///< The Go AST context for this module.
Now we have a type system map:
typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract:
class CompilerType
{
...
//----------------------------------------------------------------------
// Return a new CompilerType that is a L value reference to this type if
// this type is valid and the type system supports L value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetLValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType that is a R value reference to this type if
// this type is valid and the type system supports R value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetRValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a const modifier to this type if
// this type is valid and the type system supports const modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddConstModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a volatile modifier to this type if
// this type is valid and the type system supports volatile modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddVolatileModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a restrict modifier to this type if
// this type is valid and the type system supports restrict modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddRestrictModifier () const;
//----------------------------------------------------------------------
// Create a typedef to this type using "name" as the name of the typedef
// this type is valid and the type system supports typedefs, else return
// an invalid type.
//----------------------------------------------------------------------
CompilerType
CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
};
Other changes include:
- Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);"
- Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed
llvm-svn: 247953
2015-09-18 06:23:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TypeSystemCreateInstance
|
|
|
|
PluginManager::GetTypeSystemCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetTypeSystemInstances().GetCallbackAtIndex(idx);
|
TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
This cleans up type systems to be more pluggable. Prior to this we had issues:
- Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()"
- Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem
- Cleaned up Module so that it no longer has dedicated type system member variables:
lldb::ClangASTContextUP m_ast; ///< The Clang AST context for this module.
lldb::GoASTContextUP m_go_ast; ///< The Go AST context for this module.
Now we have a type system map:
typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract:
class CompilerType
{
...
//----------------------------------------------------------------------
// Return a new CompilerType that is a L value reference to this type if
// this type is valid and the type system supports L value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetLValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType that is a R value reference to this type if
// this type is valid and the type system supports R value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetRValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a const modifier to this type if
// this type is valid and the type system supports const modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddConstModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a volatile modifier to this type if
// this type is valid and the type system supports volatile modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddVolatileModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a restrict modifier to this type if
// this type is valid and the type system supports restrict modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddRestrictModifier () const;
//----------------------------------------------------------------------
// Create a typedef to this type using "name" as the name of the typedef
// this type is valid and the type system supports typedefs, else return
// an invalid type.
//----------------------------------------------------------------------
CompilerType
CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
};
Other changes include:
- Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);"
- Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed
llvm-svn: 247953
2015-09-18 06:23:34 +08:00
|
|
|
}
|
|
|
|
|
2019-08-23 05:45:58 +08:00
|
|
|
LanguageSet PluginManager::GetAllTypeSystemSupportedLanguagesForTypes() {
|
2020-02-19 15:52:07 +08:00
|
|
|
const auto &instances = GetTypeSystemInstances().GetInstances();
|
2019-08-23 05:45:58 +08:00
|
|
|
LanguageSet all;
|
|
|
|
for (unsigned i = 0; i < instances.size(); ++i)
|
|
|
|
all.bitvector |= instances[i].supported_languages_for_types.bitvector;
|
|
|
|
return all;
|
2015-10-09 07:07:53 +08:00
|
|
|
}
|
|
|
|
|
2019-08-23 05:45:58 +08:00
|
|
|
LanguageSet PluginManager::GetAllTypeSystemSupportedLanguagesForExpressions() {
|
2020-02-19 15:52:07 +08:00
|
|
|
const auto &instances = GetTypeSystemInstances().GetInstances();
|
2019-08-23 05:45:58 +08:00
|
|
|
LanguageSet all;
|
|
|
|
for (unsigned i = 0; i < instances.size(); ++i)
|
|
|
|
all.bitvector |= instances[i].supported_languages_for_expressions.bitvector;
|
|
|
|
return all;
|
2015-10-09 07:07:53 +08:00
|
|
|
}
|
TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
This cleans up type systems to be more pluggable. Prior to this we had issues:
- Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()"
- Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem
- Cleaned up Module so that it no longer has dedicated type system member variables:
lldb::ClangASTContextUP m_ast; ///< The Clang AST context for this module.
lldb::GoASTContextUP m_go_ast; ///< The Go AST context for this module.
Now we have a type system map:
typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract:
class CompilerType
{
...
//----------------------------------------------------------------------
// Return a new CompilerType that is a L value reference to this type if
// this type is valid and the type system supports L value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetLValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType that is a R value reference to this type if
// this type is valid and the type system supports R value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetRValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a const modifier to this type if
// this type is valid and the type system supports const modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddConstModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a volatile modifier to this type if
// this type is valid and the type system supports volatile modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddVolatileModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a restrict modifier to this type if
// this type is valid and the type system supports restrict modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddRestrictModifier () const;
//----------------------------------------------------------------------
// Create a typedef to this type using "name" as the name of the typedef
// this type is valid and the type system supports typedefs, else return
// an invalid type.
//----------------------------------------------------------------------
CompilerType
CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
};
Other changes include:
- Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);"
- Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed
llvm-svn: 247953
2015-09-18 06:23:34 +08:00
|
|
|
|
2015-10-20 07:11:07 +08:00
|
|
|
#pragma mark REPL
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
struct REPLInstance : public PluginInstance<REPLCreateInstance> {
|
2021-11-03 19:59:51 +08:00
|
|
|
REPLInstance(llvm::StringRef name, llvm::StringRef description,
|
2020-02-19 15:52:07 +08:00
|
|
|
CallbackType create_callback, LanguageSet supported_languages)
|
2021-11-03 19:59:51 +08:00
|
|
|
: PluginInstance<REPLCreateInstance>(name, description, create_callback),
|
2020-02-19 15:52:07 +08:00
|
|
|
supported_languages(supported_languages) {}
|
|
|
|
|
2019-08-23 05:45:58 +08:00
|
|
|
LanguageSet supported_languages;
|
2015-10-20 07:11:07 +08:00
|
|
|
};
|
|
|
|
|
2020-02-19 15:52:07 +08:00
|
|
|
typedef PluginInstances<REPLInstance> REPLInstances;
|
2015-10-20 07:11:07 +08:00
|
|
|
|
|
|
|
static REPLInstances &GetREPLInstances() {
|
|
|
|
static REPLInstances g_instances;
|
|
|
|
return g_instances;
|
|
|
|
}
|
|
|
|
|
2021-11-02 23:09:14 +08:00
|
|
|
bool PluginManager::RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
|
2019-08-23 05:45:58 +08:00
|
|
|
REPLCreateInstance create_callback,
|
|
|
|
LanguageSet supported_languages) {
|
2021-11-03 19:59:51 +08:00
|
|
|
return GetREPLInstances().RegisterPlugin(name, description, create_callback,
|
|
|
|
supported_languages);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-10-20 07:11:07 +08:00
|
|
|
bool PluginManager::UnregisterPlugin(REPLCreateInstance create_callback) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetREPLInstances().UnregisterPlugin(create_callback);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-10-22 03:14:33 +08:00
|
|
|
REPLCreateInstance PluginManager::GetREPLCreateCallbackAtIndex(uint32_t idx) {
|
2020-02-19 15:52:07 +08:00
|
|
|
return GetREPLInstances().GetCallbackAtIndex(idx);
|
2015-10-20 07:11:07 +08:00
|
|
|
}
|
|
|
|
|
2021-12-15 04:04:28 +08:00
|
|
|
LanguageSet PluginManager::GetREPLSupportedLanguagesAtIndex(uint32_t idx) {
|
|
|
|
const auto &instances = GetREPLInstances().GetInstances();
|
|
|
|
return idx < instances.size() ? instances[idx].supported_languages
|
|
|
|
: LanguageSet();
|
|
|
|
}
|
|
|
|
|
2019-08-23 05:45:58 +08:00
|
|
|
LanguageSet PluginManager::GetREPLAllTypeSystemSupportedLanguages() {
|
2020-02-19 15:52:07 +08:00
|
|
|
const auto &instances = GetREPLInstances().GetInstances();
|
2019-08-23 05:45:58 +08:00
|
|
|
LanguageSet all;
|
|
|
|
for (unsigned i = 0; i < instances.size(); ++i)
|
|
|
|
all.bitvector |= instances[i].supported_languages.bitvector;
|
|
|
|
return all;
|
2015-10-22 03:14:33 +08:00
|
|
|
}
|
|
|
|
|
LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and report data extraction
Reviewed at http://reviews.llvm.org/D5592
This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API.
More precisely this patch...
adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded
an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable
adds a collection of these plugins into the Process class
AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan
this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo
the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data
the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now)
SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream
adds a test case for all of this
I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose.
Kuba
llvm-svn: 219546
2014-10-11 07:43:03 +08:00
|
|
|
#pragma mark PluginManager
|
|
|
|
|
2012-10-20 02:02:49 +08:00
|
|
|
void PluginManager::DebuggerInitialize(Debugger &debugger) {
|
2020-02-19 15:52:07 +08:00
|
|
|
GetDynamicLoaderInstances().PerformDebuggerCallback(debugger);
|
|
|
|
GetJITLoaderInstances().PerformDebuggerCallback(debugger);
|
|
|
|
GetPlatformInstances().PerformDebuggerCallback(debugger);
|
|
|
|
GetProcessInstances().PerformDebuggerCallback(debugger);
|
|
|
|
GetSymbolFileInstances().PerformDebuggerCallback(debugger);
|
|
|
|
GetOperatingSystemInstances().PerformDebuggerCallback(debugger);
|
|
|
|
GetStructuredDataPluginInstances().PerformDebuggerCallback(debugger);
|
2020-10-27 12:22:06 +08:00
|
|
|
GetTracePluginInstances().PerformDebuggerCallback(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".
|
2020-02-19 09:08:46 +08:00
|
|
|
static lldb::OptionValuePropertiesSP
|
|
|
|
GetDebuggerPropertyForPlugins(Debugger &debugger, ConstString plugin_type_name,
|
|
|
|
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");
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-03-12 05:55:47 +08:00
|
|
|
OptionValuePropertiesSP plugin_properties_sp =
|
|
|
|
parent_properties_sp->GetSubProperty(nullptr, g_property_name);
|
2012-10-20 02:02:49 +08:00
|
|
|
if (!plugin_properties_sp && can_create) {
|
2017-04-07 05:28:29 +08:00
|
|
|
plugin_properties_sp =
|
|
|
|
std::make_shared<OptionValueProperties>(g_property_name);
|
2012-10-20 02:02:49 +08:00
|
|
|
parent_properties_sp->AppendProperty(
|
|
|
|
g_property_name, ConstString("Settings specify to plugins."), true,
|
|
|
|
plugin_properties_sp);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-20 02:02:49 +08:00
|
|
|
if (plugin_properties_sp) {
|
2016-03-12 05:55:47 +08:00
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp =
|
|
|
|
plugin_properties_sp->GetSubProperty(nullptr, plugin_type_name);
|
2012-10-20 02:02:49 +08:00
|
|
|
if (!plugin_type_properties_sp && can_create) {
|
2017-04-07 05:28:29 +08:00
|
|
|
plugin_type_properties_sp =
|
|
|
|
std::make_shared<OptionValueProperties>(plugin_type_name);
|
2012-10-20 02:02:49 +08:00
|
|
|
plugin_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
|
|
|
|
true, plugin_type_properties_sp);
|
|
|
|
}
|
|
|
|
return plugin_type_properties_sp;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-10-20 02:02:49 +08:00
|
|
|
return lldb::OptionValuePropertiesSP();
|
|
|
|
}
|
|
|
|
|
2013-07-16 06:54:20 +08:00
|
|
|
// This is deprecated way to register plugin specific settings. e.g.
|
2018-05-01 00:49:04 +08:00
|
|
|
// "<plugin_type_name>.plugin.<plugin_type_desc>.SETTINGNAME" and Platform
|
|
|
|
// generic settings would be under "platform.SETTINGNAME".
|
2013-07-16 06:54:20 +08:00
|
|
|
static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsOldStyle(
|
2019-03-07 05:22:25 +08:00
|
|
|
Debugger &debugger, ConstString plugin_type_name,
|
|
|
|
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) {
|
2016-03-12 05:55:47 +08:00
|
|
|
OptionValuePropertiesSP plugin_properties_sp =
|
|
|
|
parent_properties_sp->GetSubProperty(nullptr, plugin_type_name);
|
2013-04-06 06:40:42 +08:00
|
|
|
if (!plugin_properties_sp && can_create) {
|
2017-04-07 05:28:29 +08:00
|
|
|
plugin_properties_sp =
|
|
|
|
std::make_shared<OptionValueProperties>(plugin_type_name);
|
2013-04-06 06:40:42 +08:00
|
|
|
parent_properties_sp->AppendProperty(plugin_type_name, plugin_type_desc,
|
|
|
|
true, plugin_properties_sp);
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-04-06 06:40:42 +08:00
|
|
|
if (plugin_properties_sp) {
|
2016-03-12 05:55:47 +08:00
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp =
|
|
|
|
plugin_properties_sp->GetSubProperty(nullptr, g_property_name);
|
2013-04-06 06:40:42 +08:00
|
|
|
if (!plugin_type_properties_sp && can_create) {
|
2017-04-07 05:28:29 +08:00
|
|
|
plugin_type_properties_sp =
|
|
|
|
std::make_shared<OptionValueProperties>(g_property_name);
|
2013-04-06 06:40:42 +08:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2015-09-17 01:38:36 +08:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
typedef lldb::OptionValuePropertiesSP
|
2020-02-19 09:08:46 +08:00
|
|
|
GetDebuggerPropertyForPluginsPtr(Debugger &, ConstString, ConstString,
|
|
|
|
bool can_create);
|
2021-10-05 14:29:16 +08:00
|
|
|
}
|
2013-04-06 06:40:42 +08:00
|
|
|
|
2021-10-05 14:29:16 +08:00
|
|
|
static lldb::OptionValuePropertiesSP
|
2019-03-07 05:22:25 +08:00
|
|
|
GetSettingForPlugin(Debugger &debugger, ConstString setting_name,
|
|
|
|
ConstString plugin_type_name,
|
2015-09-17 01:38:36 +08:00
|
|
|
GetDebuggerPropertyForPluginsPtr get_debugger_property =
|
|
|
|
GetDebuggerPropertyForPlugins) {
|
2012-10-20 02:02:49 +08:00
|
|
|
lldb::OptionValuePropertiesSP properties_sp;
|
2015-09-17 01:38:36 +08:00
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp(get_debugger_property(
|
|
|
|
debugger, plugin_type_name,
|
|
|
|
ConstString(), // not creating to so we don't need the description
|
|
|
|
false));
|
2012-10-20 02:02:49 +08:00
|
|
|
if (plugin_type_properties_sp)
|
2015-09-17 01:38:36 +08:00
|
|
|
properties_sp =
|
|
|
|
plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
|
2012-10-20 02:02:49 +08:00
|
|
|
return properties_sp;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2021-10-05 14:29:16 +08:00
|
|
|
static bool
|
|
|
|
CreateSettingForPlugin(Debugger &debugger, ConstString plugin_type_name,
|
|
|
|
ConstString plugin_type_desc,
|
|
|
|
const lldb::OptionValuePropertiesSP &properties_sp,
|
|
|
|
ConstString description, bool is_global_property,
|
|
|
|
GetDebuggerPropertyForPluginsPtr get_debugger_property =
|
|
|
|
GetDebuggerPropertyForPlugins) {
|
2012-10-20 02:02:49 +08:00
|
|
|
if (properties_sp) {
|
2015-09-17 01:38:36 +08:00
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp(
|
|
|
|
get_debugger_property(debugger, plugin_type_name, plugin_type_desc,
|
|
|
|
true));
|
2012-10-20 02:02:49 +08:00
|
|
|
if (plugin_type_properties_sp) {
|
|
|
|
plugin_type_properties_sp->AppendProperty(properties_sp->GetName(),
|
|
|
|
description, is_global_property,
|
|
|
|
properties_sp);
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2012-10-20 02:02:49 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-10-05 14:29:16 +08:00
|
|
|
static const char *kDynamicLoaderPluginName("dynamic-loader");
|
|
|
|
static const char *kPlatformPluginName("platform");
|
|
|
|
static const char *kProcessPluginName("process");
|
|
|
|
static const char *kSymbolFilePluginName("symbol-file");
|
|
|
|
static const char *kJITLoaderPluginName("jit-loader");
|
|
|
|
static const char *kStructuredDataPluginName("structured-data");
|
2013-04-05 13:06:39 +08:00
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
lldb::OptionValuePropertiesSP
|
|
|
|
PluginManager::GetSettingForDynamicLoaderPlugin(Debugger &debugger,
|
|
|
|
ConstString setting_name) {
|
2015-09-17 01:38:36 +08:00
|
|
|
return GetSettingForPlugin(debugger, setting_name,
|
|
|
|
ConstString(kDynamicLoaderPluginName));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PluginManager::CreateSettingForDynamicLoaderPlugin(
|
|
|
|
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
2019-03-07 05:22:25 +08:00
|
|
|
ConstString description, bool is_global_property) {
|
2015-09-17 01:38:36 +08:00
|
|
|
return CreateSettingForPlugin(
|
|
|
|
debugger, ConstString(kDynamicLoaderPluginName),
|
|
|
|
ConstString("Settings for dynamic loader plug-ins"), properties_sp,
|
|
|
|
description, is_global_property);
|
2013-07-16 06:54:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb::OptionValuePropertiesSP
|
|
|
|
PluginManager::GetSettingForPlatformPlugin(Debugger &debugger,
|
2019-03-07 05:22:25 +08:00
|
|
|
ConstString setting_name) {
|
2015-09-17 01:38:36 +08:00
|
|
|
return GetSettingForPlugin(debugger, setting_name,
|
|
|
|
ConstString(kPlatformPluginName),
|
|
|
|
GetDebuggerPropertyForPluginsOldStyle);
|
2013-07-16 06:54:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PluginManager::CreateSettingForPlatformPlugin(
|
|
|
|
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
2019-03-07 05:22:25 +08:00
|
|
|
ConstString description, bool is_global_property) {
|
2015-09-17 01:38:36 +08:00
|
|
|
return CreateSettingForPlugin(debugger, ConstString(kPlatformPluginName),
|
|
|
|
ConstString("Settings for platform plug-ins"),
|
|
|
|
properties_sp, description, is_global_property,
|
|
|
|
GetDebuggerPropertyForPluginsOldStyle);
|
2013-04-05 13:06:39 +08:00
|
|
|
}
|
|
|
|
|
2015-07-30 06:18:16 +08:00
|
|
|
lldb::OptionValuePropertiesSP
|
|
|
|
PluginManager::GetSettingForProcessPlugin(Debugger &debugger,
|
2019-03-07 05:22:25 +08:00
|
|
|
ConstString setting_name) {
|
2015-09-17 01:38:36 +08:00
|
|
|
return GetSettingForPlugin(debugger, setting_name,
|
|
|
|
ConstString(kProcessPluginName));
|
2015-07-30 06:18:16 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-07-30 06:18:16 +08:00
|
|
|
bool PluginManager::CreateSettingForProcessPlugin(
|
|
|
|
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
2019-03-07 05:22:25 +08:00
|
|
|
ConstString description, bool is_global_property) {
|
2015-09-17 01:38:36 +08:00
|
|
|
return CreateSettingForPlugin(debugger, ConstString(kProcessPluginName),
|
|
|
|
ConstString("Settings for process plug-ins"),
|
|
|
|
properties_sp, description, is_global_property);
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::OptionValuePropertiesSP
|
|
|
|
PluginManager::GetSettingForSymbolFilePlugin(Debugger &debugger,
|
2019-03-07 05:22:25 +08:00
|
|
|
ConstString setting_name) {
|
2015-09-17 01:38:36 +08:00
|
|
|
return GetSettingForPlugin(debugger, setting_name,
|
|
|
|
ConstString(kSymbolFilePluginName));
|
2015-07-30 06:18:16 +08:00
|
|
|
}
|
2015-09-17 05:20:44 +08:00
|
|
|
|
|
|
|
bool PluginManager::CreateSettingForSymbolFilePlugin(
|
|
|
|
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
2019-03-07 05:22:25 +08:00
|
|
|
ConstString description, bool is_global_property) {
|
2015-09-17 05:20:44 +08:00
|
|
|
return CreateSettingForPlugin(
|
|
|
|
debugger, ConstString(kSymbolFilePluginName),
|
|
|
|
ConstString("Settings for symbol file plug-ins"), properties_sp,
|
|
|
|
description, is_global_property);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2015-09-17 05:20:44 +08:00
|
|
|
|
|
|
|
lldb::OptionValuePropertiesSP
|
|
|
|
PluginManager::GetSettingForJITLoaderPlugin(Debugger &debugger,
|
2019-03-07 05:22:25 +08:00
|
|
|
ConstString setting_name) {
|
2015-09-17 05:20:44 +08:00
|
|
|
return GetSettingForPlugin(debugger, setting_name,
|
|
|
|
ConstString(kJITLoaderPluginName));
|
|
|
|
}
|
2016-08-19 12:21:48 +08:00
|
|
|
|
|
|
|
bool PluginManager::CreateSettingForJITLoaderPlugin(
|
|
|
|
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
2019-03-07 05:22:25 +08:00
|
|
|
ConstString description, bool is_global_property) {
|
2016-08-19 12:21:48 +08:00
|
|
|
return CreateSettingForPlugin(debugger, ConstString(kJITLoaderPluginName),
|
2015-09-17 01:38:36 +08:00
|
|
|
ConstString("Settings for JIT loader plug-ins"),
|
2015-09-17 05:20:44 +08:00
|
|
|
properties_sp, description, is_global_property);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-09-17 05:20:44 +08:00
|
|
|
static const char *kOperatingSystemPluginName("os");
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
lldb::OptionValuePropertiesSP
|
|
|
|
PluginManager::GetSettingForOperatingSystemPlugin(Debugger &debugger,
|
|
|
|
ConstString setting_name) {
|
2015-09-17 05:20:44 +08:00
|
|
|
lldb::OptionValuePropertiesSP properties_sp;
|
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp(
|
2016-08-19 12:21:48 +08:00
|
|
|
GetDebuggerPropertyForPlugins(
|
2015-09-17 05:20:44 +08:00
|
|
|
debugger, ConstString(kOperatingSystemPluginName),
|
|
|
|
ConstString(), // not creating to so we don't need the description
|
2016-08-19 12:21:48 +08:00
|
|
|
false));
|
2015-09-17 05:20:44 +08:00
|
|
|
if (plugin_type_properties_sp)
|
|
|
|
properties_sp =
|
2016-08-19 12:21:48 +08:00
|
|
|
plugin_type_properties_sp->GetSubProperty(nullptr, setting_name);
|
2015-09-17 05:20:44 +08:00
|
|
|
return properties_sp;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2015-09-17 05:20:44 +08:00
|
|
|
bool PluginManager::CreateSettingForOperatingSystemPlugin(
|
2013-04-05 13:06:39 +08:00
|
|
|
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
2019-03-07 05:22:25 +08:00
|
|
|
ConstString description, bool is_global_property) {
|
2015-09-17 05:20:44 +08:00
|
|
|
if (properties_sp) {
|
|
|
|
lldb::OptionValuePropertiesSP plugin_type_properties_sp(
|
|
|
|
GetDebuggerPropertyForPlugins(
|
|
|
|
debugger, ConstString(kOperatingSystemPluginName),
|
|
|
|
ConstString("Settings for operating system plug-ins"), true));
|
|
|
|
if (plugin_type_properties_sp) {
|
|
|
|
plugin_type_properties_sp->AppendProperty(properties_sp->GetName(),
|
|
|
|
description, is_global_property,
|
|
|
|
properties_sp);
|
2015-10-20 07:11:07 +08:00
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
TypeSystem is now a plugin interface and removed any "ClangASTContext &Class::GetClangASTContext()" functions.
This cleans up type systems to be more pluggable. Prior to this we had issues:
- Module, SymbolFile, and many others has "ClangASTContext &GetClangASTContext()" functions. All have been switched over to use "TypeSystem *GetTypeSystemForLanguage()"
- Cleaned up any places that were using the GetClangASTContext() functions to use TypeSystem
- Cleaned up Module so that it no longer has dedicated type system member variables:
lldb::ClangASTContextUP m_ast; ///< The Clang AST context for this module.
lldb::GoASTContextUP m_go_ast; ///< The Go AST context for this module.
Now we have a type system map:
typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> TypeSystemMap;
TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- Many places in code were using ClangASTContext static functions to place with CompilerType objects and add modifiers (const, volatile, restrict) and to make typedefs, L and R value references and more. These have been made into CompilerType functions that are abstract:
class CompilerType
{
...
//----------------------------------------------------------------------
// Return a new CompilerType that is a L value reference to this type if
// this type is valid and the type system supports L value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetLValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType that is a R value reference to this type if
// this type is valid and the type system supports R value references,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
GetRValueReferenceType () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a const modifier to this type if
// this type is valid and the type system supports const modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddConstModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a volatile modifier to this type if
// this type is valid and the type system supports volatile modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddVolatileModifier () const;
//----------------------------------------------------------------------
// Return a new CompilerType adds a restrict modifier to this type if
// this type is valid and the type system supports restrict modifiers,
// else return an invalid type.
//----------------------------------------------------------------------
CompilerType
AddRestrictModifier () const;
//----------------------------------------------------------------------
// Create a typedef to this type using "name" as the name of the typedef
// this type is valid and the type system supports typedefs, else return
// an invalid type.
//----------------------------------------------------------------------
CompilerType
CreateTypedef (const char *name, const CompilerDeclContext &decl_ctx) const;
};
Other changes include:
- Removed "CompilerType TypeSystem::GetIntTypeFromBitSize(...)" and CompilerType TypeSystem::GetFloatTypeFromBitSize(...) and replaced it with "CompilerType TypeSystem::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size);"
- Fixed code in Type.h to not request the full type for a type for no good reason, just request the forward type and let the type expand as needed
llvm-svn: 247953
2015-09-18 06:23:34 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2020-02-19 09:08:46 +08:00
|
|
|
lldb::OptionValuePropertiesSP
|
|
|
|
PluginManager::GetSettingForStructuredDataPlugin(Debugger &debugger,
|
|
|
|
ConstString setting_name) {
|
2016-08-19 12:21:48 +08:00
|
|
|
return GetSettingForPlugin(debugger, setting_name,
|
2015-09-17 01:38:36 +08:00
|
|
|
ConstString(kStructuredDataPluginName));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2016-08-19 12:21:48 +08:00
|
|
|
bool PluginManager::CreateSettingForStructuredDataPlugin(
|
|
|
|
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
2019-03-07 05:22:25 +08:00
|
|
|
ConstString description, bool is_global_property) {
|
2016-08-19 12:21:48 +08:00
|
|
|
return CreateSettingForPlugin(
|
|
|
|
debugger, ConstString(kStructuredDataPluginName),
|
|
|
|
ConstString("Settings for structured data plug-ins"), properties_sp,
|
|
|
|
description, is_global_property);
|
|
|
|
}
|