本文整理汇总了C++中DynamicLibrary::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicLibrary::isValid方法的具体用法?C++ DynamicLibrary::isValid怎么用?C++ DynamicLibrary::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicLibrary
的用法示例。
在下文中一共展示了DynamicLibrary::isValid方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LLVMRustLoadDynamicLibrary
extern "C" LLVMBool LLVMRustLoadDynamicLibrary(const char *path)
{
std::string err;
DynamicLibrary lib = DynamicLibrary::getPermanentLibrary(path, &err);
if (!lib.isValid())
LLVMRustSetLastError(err.c_str());
return lib.isValid();
}
示例2: PtrFunc
TEST(DynamicLibrary, Overload) {
{
std::string Err;
llvm_shutdown_obj Shutdown;
DynamicLibrary DL =
DynamicLibrary::getPermanentLibrary(LibPath().c_str(), &Err);
EXPECT_TRUE(DL.isValid());
EXPECT_TRUE(Err.empty());
GetString GS = FuncPtr<GetString>(DL.getAddressOfSymbol("TestA"));
EXPECT_TRUE(GS != nullptr && GS != &TestA);
EXPECT_EQ(StdString(GS()), "LibCall");
GS = FuncPtr<GetString>(DynamicLibrary::SearchForAddressOfSymbol("TestA"));
EXPECT_TRUE(GS != nullptr && GS != &TestA);
EXPECT_EQ(StdString(GS()), "LibCall");
DL = DynamicLibrary::getPermanentLibrary(nullptr, &Err);
EXPECT_TRUE(DL.isValid());
EXPECT_TRUE(Err.empty());
// Test overloading local symbols does not occur by default
GS = FuncPtr<GetString>(DynamicLibrary::SearchForAddressOfSymbol("TestA"));
EXPECT_TRUE(GS != nullptr && GS == &TestA);
EXPECT_EQ(StdString(GS()), "ProcessCall");
GS = FuncPtr<GetString>(DL.getAddressOfSymbol("TestA"));
EXPECT_TRUE(GS != nullptr && GS == &TestA);
EXPECT_EQ(StdString(GS()), "ProcessCall");
// Test overloading by forcing library priority when searching for a symbol
DynamicLibrary::SearchOrder = DynamicLibrary::SO_LoadedFirst;
GS = FuncPtr<GetString>(DynamicLibrary::SearchForAddressOfSymbol("TestA"));
EXPECT_TRUE(GS != nullptr && GS != &TestA);
EXPECT_EQ(StdString(GS()), "LibCall");
DynamicLibrary::AddSymbol("TestA", PtrFunc(&OverloadTestA));
GS = FuncPtr<GetString>(DL.getAddressOfSymbol("TestA"));
EXPECT_TRUE(GS != nullptr && GS != &OverloadTestA);
GS = FuncPtr<GetString>(DynamicLibrary::SearchForAddressOfSymbol("TestA"));
EXPECT_TRUE(GS != nullptr && GS == &OverloadTestA);
EXPECT_EQ(StdString(GS()), "OverloadCall");
}
EXPECT_TRUE(FuncPtr<GetString>(DynamicLibrary::SearchForAddressOfSymbol(
"TestA")) == nullptr);
// Check serach ordering is reset to default after call to llvm_shutdown
EXPECT_TRUE(DynamicLibrary::SearchOrder == DynamicLibrary::SO_Linker);
}
示例3:
TEST(DynamicLibrary, Unsupported) {
std::string Err;
DynamicLibrary DL =
DynamicLibrary::getPermanentLibrary(LibPath().c_str(), &Err);
EXPECT_FALSE(DL.isValid());
EXPECT_EQ(Err, "dlopen() not supported on this platform");
}
示例4: registerBuiltinCheckers
ClangCheckerRegistry::ClangCheckerRegistry(ArrayRef<std::string> plugins,
DiagnosticsEngine *diags) {
registerBuiltinCheckers(*this);
for (ArrayRef<std::string>::iterator i = plugins.begin(), e = plugins.end();
i != e; ++i) {
// Get access to the plugin.
std::string err;
DynamicLibrary lib = DynamicLibrary::getPermanentLibrary(i->c_str(), &err);
if (!lib.isValid()) {
diags->Report(diag::err_fe_unable_to_load_plugin) << *i << err;
continue;
}
// See if it's compatible with this build of clang.
const char *pluginAPIVersion =
(const char *) lib.getAddressOfSymbol("clang_analyzerAPIVersionString");
if (!isCompatibleAPIVersion(pluginAPIVersion)) {
warnIncompatible(diags, *i, pluginAPIVersion);
continue;
}
// Register its checkers.
RegisterCheckersFn registerPluginCheckers =
(RegisterCheckersFn) (intptr_t) lib.getAddressOfSymbol(
"clang_registerCheckers");
if (registerPluginCheckers)
registerPluginCheckers(*this);
}
}
示例5: A
TEST(DynamicLibrary, Shutdown) {
std::string A("PipSqueak"), B, C("SecondLib");
std::vector<std::string> Order;
{
std::string Err;
llvm_shutdown_obj Shutdown;
DynamicLibrary DL =
DynamicLibrary::getPermanentLibrary(LibPath(A).c_str(), &Err);
EXPECT_TRUE(DL.isValid());
EXPECT_TRUE(Err.empty());
SetStrings SS_0 = FuncPtr<SetStrings>(
DynamicLibrary::SearchForAddressOfSymbol("SetStrings"));
EXPECT_TRUE(SS_0 != nullptr);
SS_0(A, B);
EXPECT_EQ(B, "Local::Local(PipSqueak)");
TestOrder TO_0 = FuncPtr<TestOrder>(
DynamicLibrary::SearchForAddressOfSymbol("TestOrder"));
EXPECT_TRUE(TO_0 != nullptr);
DynamicLibrary DL2 =
DynamicLibrary::getPermanentLibrary(LibPath(C).c_str(), &Err);
EXPECT_TRUE(DL2.isValid());
EXPECT_TRUE(Err.empty());
// Should find latest version of symbols in SecondLib
SetStrings SS_1 = FuncPtr<SetStrings>(
DynamicLibrary::SearchForAddressOfSymbol("SetStrings"));
EXPECT_TRUE(SS_1 != nullptr);
EXPECT_TRUE(SS_0 != SS_1);
TestOrder TO_1 = FuncPtr<TestOrder>(
DynamicLibrary::SearchForAddressOfSymbol("TestOrder"));
EXPECT_TRUE(TO_1 != nullptr);
EXPECT_TRUE(TO_0 != TO_1);
B.clear();
SS_1(C, B);
EXPECT_EQ(B, "Local::Local(SecondLib)");
TO_0(Order);
TO_1(Order);
}
EXPECT_EQ(A, "Global::~Global");
EXPECT_EQ(B, "Local::~Local");
EXPECT_TRUE(FuncPtr<SetStrings>(DynamicLibrary::SearchForAddressOfSymbol(
"SetStrings")) == nullptr);
// Test unload/destruction ordering
EXPECT_EQ(Order.size(), 2UL);
EXPECT_EQ(Order.front(), "SecondLib");
EXPECT_EQ(Order.back(), "PipSqueak");
}
示例6: loadCrate
bool RustMCJITMemoryManager::loadCrate(const char* file, std::string* err) {
DynamicLibrary crate = DynamicLibrary::getPermanentLibrary(file,
err);
if(crate.isValid()) {
crates.insert(&crate);
return true;
}
return false;
}
示例7: test_desobj
void test_desobj()
{
ErrorOr<ObjectFile *> objfile = ObjectFile::createObjectFile("/usr/lib/libQtCore.so");
ObjectFile *pobj = objfile.get();
qDebug()<<"heheho"<<pobj->getFileFormatName().data();
int i = 0;
DynamicLibrary dlib = DynamicLibrary::getPermanentLibrary("/usr/lib/libQt5Core.so");
qDebug()<<dlib.isValid();
void *addr = dlib.SearchForAddressOfSymbol("_ZN7QString4chopEi");
qDebug()<<"addr:"<<addr;
}