#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMDARWINKERNEL_H
#define LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMDARWINKERNEL_H
#include "PlatformDarwin.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/UUID.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private-enumerations.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileSystem.h"
#include <vector>
namespace lldb_private {
class ArchSpec;
class Debugger;
class FileSpecList;
class ModuleSpec;
class Process;
class Stream;
#if defined(__APPLE__)
class PlatformDarwinKernel : public PlatformDarwin {
public:
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
static void DebuggerInitialize(Debugger &debugger);
static void Initialize();
static void Terminate();
static llvm::StringRef GetPluginNameStatic() { return "darwin-kernel"; }
static llvm::StringRef GetDescriptionStatic();
PlatformDarwinKernel(LazyBool is_ios_debug_session);
~PlatformDarwinKernel() override;
llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
llvm::StringRef GetDescription() override { return GetDescriptionStatic(); }
void GetStatus(Stream &strm) override;
Status GetSharedModule(const ModuleSpec &module_spec, Process *process,
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr,
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules,
bool *did_create_ptr) override;
std::vector<ArchSpec>
GetSupportedArchitectures(const ArchSpec &process_host_arch) override;
bool SupportsModules() override { return false; }
void CalculateTrapHandlerSymbolNames() override;
protected:
typedef std::multimap<ConstString, FileSpec> BundleIDToKextMap;
typedef BundleIDToKextMap::iterator BundleIDToKextIterator;
typedef std::vector<FileSpec> KernelBinaryCollection;
typedef std::vector<FileSpec> DirectoriesSearchedCollection;
typedef DirectoriesSearchedCollection::iterator DirectoriesSearchedIterator;
void CollectKextAndKernelDirectories();
void GetUserSpecifiedDirectoriesToSearch();
static void AddRootSubdirsToSearchPaths(PlatformDarwinKernel *thisp,
const std::string &dir);
void AddSDKSubdirsToSearchPaths(const std::string &dir);
static FileSystem::EnumerateDirectoryResult
FindKDKandSDKDirectoriesInDirectory(void *baton, llvm::sys::fs::file_type ft,
llvm::StringRef path);
void SearchForKextsAndKernelsRecursively();
static FileSystem::EnumerateDirectoryResult
GetKernelsAndKextsInDirectoryWithRecursion(void *baton,
llvm::sys::fs::file_type ft,
llvm::StringRef path);
static FileSystem::EnumerateDirectoryResult
GetKernelsAndKextsInDirectoryNoRecursion(void *baton,
llvm::sys::fs::file_type ft,
llvm::StringRef path);
static FileSystem::EnumerateDirectoryResult
GetKernelsAndKextsInDirectoryHelper(void *baton, llvm::sys::fs::file_type ft,
llvm::StringRef path, bool recurse);
static std::vector<FileSpec>
SearchForExecutablesRecursively(const std::string &dir);
static void AddKextToMap(PlatformDarwinKernel *thisp,
const FileSpec &file_spec);
static bool KextHasdSYMSibling(const FileSpec &kext_bundle_filepath);
static bool KernelHasdSYMSibling(const FileSpec &kernel_filepath);
static bool
KerneldSYMHasNoSiblingBinary(const FileSpec &kernel_dsym_filepath);
static std::vector<FileSpec>
GetDWARFBinaryInDSYMBundle(const FileSpec &dsym_bundle);
Status GetSharedModuleKext(const ModuleSpec &module_spec, Process *process,
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr,
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules,
bool *did_create_ptr);
Status GetSharedModuleKernel(
const ModuleSpec &module_spec, Process *process,
lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr,
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr);
Status ExamineKextForMatchingUUID(const FileSpec &kext_bundle_path,
const UUID &uuid, const ArchSpec &arch,
lldb::ModuleSP &exe_module_sp);
bool LoadPlatformBinaryAndSetup(Process *process, lldb::addr_t addr,
bool notify) override;
void UpdateKextandKernelsLocalScan();
public:
BundleIDToKextMap m_name_to_kext_path_map_with_dsyms;
BundleIDToKextMap m_name_to_kext_path_map_without_dsyms;
DirectoriesSearchedCollection m_search_directories;
DirectoriesSearchedCollection m_search_directories_no_recursing;
KernelBinaryCollection m_kernel_binaries_with_dsyms;
KernelBinaryCollection m_kernel_binaries_without_dsyms;
KernelBinaryCollection m_kernel_dsyms_no_binaries;
KernelBinaryCollection m_kernel_dsyms_yaas;
LazyBool m_ios_debug_session;
std::once_flag m_kext_scan_flag;
PlatformDarwinKernel(const PlatformDarwinKernel &) = delete;
const PlatformDarwinKernel &operator=(const PlatformDarwinKernel &) = delete;
};
#else
class PlatformDarwinKernel { … };
#endif
}
#endif