Check if the triggerFunc is in a library.
This patch should fix an assert in the incrementals.
This commit is contained in:
parent
d71643dcf8
commit
81e2eda009
@ -122,6 +122,15 @@ namespace cling {
|
||||
static void ExposeHiddenSharedLibrarySymbols(void* handle);
|
||||
|
||||
static std::string normalizePath(llvm::StringRef path);
|
||||
|
||||
/// Returns true if file is a shared library.
|
||||
///
|
||||
///\param[in] libFullPath - the full path to file.
|
||||
///
|
||||
///\param[out] exists - sets if the file exists. Useful to distinguish if it
|
||||
/// is a library but of incompatible file format.
|
||||
///
|
||||
static bool isSharedLibrary(llvm::StringRef libFullPath, bool* exists = 0);
|
||||
};
|
||||
} // end namespace cling
|
||||
#endif // CLING_DYNAMIC_LIBRARY_MANAGER_H
|
||||
|
@ -63,33 +63,6 @@ namespace cling {
|
||||
|
||||
DynamicLibraryManager::~DynamicLibraryManager() {}
|
||||
|
||||
static bool isSharedLib(llvm::StringRef LibName, bool* exists = 0) {
|
||||
using namespace llvm;
|
||||
file_magic Magic;
|
||||
const std::error_code Error = identify_magic(LibName, Magic);
|
||||
if (exists)
|
||||
*exists = !Error;
|
||||
|
||||
return !Error &&
|
||||
#ifdef __APPLE__
|
||||
(Magic == file_magic::macho_fixed_virtual_memory_shared_lib
|
||||
|| Magic == file_magic::macho_dynamically_linked_shared_lib
|
||||
|| Magic == file_magic::macho_dynamically_linked_shared_lib_stub
|
||||
|| Magic == file_magic::macho_universal_binary)
|
||||
#elif defined(LLVM_ON_UNIX)
|
||||
#ifdef __CYGWIN__
|
||||
(Magic == file_magic::pecoff_executable)
|
||||
#else
|
||||
(Magic == file_magic::elf_shared_object)
|
||||
#endif
|
||||
#elif defined(LLVM_ON_WIN32)
|
||||
(Magic == file_magic::pecoff_executable || platform::IsDLL(LibName.str()))
|
||||
#else
|
||||
# error "Unsupported platform."
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
std::string
|
||||
DynamicLibraryManager::lookupLibInPaths(llvm::StringRef libStem) const {
|
||||
llvm::SmallVector<std::string, 128>
|
||||
@ -101,7 +74,7 @@ namespace cling {
|
||||
llvm::SmallString<512> ThisPath(*IPath); // FIXME: move alloc outside loop
|
||||
llvm::sys::path::append(ThisPath, libStem);
|
||||
bool exists;
|
||||
if (isSharedLib(ThisPath.str(), &exists))
|
||||
if (isSharedLibrary(ThisPath.str(), &exists))
|
||||
return ThisPath.str();
|
||||
if (exists)
|
||||
return "";
|
||||
@ -169,7 +142,7 @@ namespace cling {
|
||||
DynamicLibraryManager::lookupLibrary(llvm::StringRef libStem) const {
|
||||
// If it is an absolute path, don't try iterate over the paths.
|
||||
if (llvm::sys::path::is_absolute(libStem)) {
|
||||
if (isSharedLib(libStem))
|
||||
if (isSharedLibrary(libStem))
|
||||
return normalizePath(libStem);
|
||||
else
|
||||
return std::string();
|
||||
@ -181,7 +154,7 @@ namespace cling {
|
||||
foundName = lookupLibMaybeAddExt("lib" + libStem.str());
|
||||
}
|
||||
|
||||
if (!foundName.empty() && isSharedLib(foundName))
|
||||
if (!foundName.empty() && isSharedLibrary(foundName))
|
||||
return platform::NormalizePath(foundName);
|
||||
|
||||
return std::string();
|
||||
@ -268,4 +241,34 @@ namespace cling {
|
||||
void DynamicLibraryManager::ExposeHiddenSharedLibrarySymbols(void* handle) {
|
||||
llvm::sys::DynamicLibrary::addPermanentLibrary(const_cast<void*>(handle));
|
||||
}
|
||||
|
||||
bool DynamicLibraryManager::isSharedLibrary(llvm::StringRef libFullPath,
|
||||
bool* exists /*=0*/) {
|
||||
using namespace llvm;
|
||||
file_magic Magic;
|
||||
const std::error_code Error = identify_magic(libFullPath, Magic);
|
||||
if (exists)
|
||||
*exists = !Error;
|
||||
|
||||
return !Error &&
|
||||
#ifdef __APPLE__
|
||||
(Magic == file_magic::macho_fixed_virtual_memory_shared_lib
|
||||
|| Magic == file_magic::macho_dynamically_linked_shared_lib
|
||||
|| Magic == file_magic::macho_dynamically_linked_shared_lib_stub
|
||||
|| Magic == file_magic::macho_universal_binary)
|
||||
#elif defined(LLVM_ON_UNIX)
|
||||
#ifdef __CYGWIN__
|
||||
(Magic == file_magic::pecoff_executable)
|
||||
#else
|
||||
(Magic == file_magic::elf_shared_object)
|
||||
#endif
|
||||
#elif defined(LLVM_ON_WIN32)
|
||||
(Magic == file_magic::pecoff_executable
|
||||
|| platform::IsDLL(libFullPath.str()))
|
||||
#else
|
||||
# error "Unsupported platform."
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
} // end namespace cling
|
||||
|
Loading…
x
Reference in New Issue
Block a user