MCPcopy Create free account
hub / github.com/alibaba/loongcollector / LoadMethod

Method LoadMethod

core/common/DynamicLibHelper.cpp:86–101  ·  view source on GitHub ↗

LoadMethod loads method named @methodName from opened lib. If error is found, @error param will be set, otherwise empty.

Source from the content-addressed store, hash-verified

84// LoadMethod loads method named @methodName from opened lib.
85// If error is found, @error param will be set, otherwise empty.
86void* DynamicLibLoader::LoadMethod(const std::string& methodName, std::string& error) {
87 error.clear();
88
89#if defined(__linux__)
90 dlerror(); // Clear last error.
91 auto methodPtr = dlsym(mLibPtr, methodName.c_str());
92 error = GetError();
93 return methodPtr;
94#elif defined(_MSC_VER)
95 auto methodPtr = GetProcAddress((HINSTANCE)mLibPtr, methodName.c_str());
96 if (methodPtr != NULL)
97 return methodPtr;
98 error = std::to_string(GetLastError());
99 return NULL;
100#endif
101}
102
103bool glibc::LoadGlibcFunc() {
104 if (g_loader == nullptr) {

Callers 5

LoadPluginBaseMethod · 0.80
FunctionProxyMethod · 0.80
LoadGlibcFuncMethod · 0.80
LoadProcessorPluginMethod · 0.80

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected