2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#include "core/DynamicLoader.h"
44#ifndef DOXYGEN_SHOULD_SKIP_THIS
46#include "log/Logger.h"
60 std::string result = libFile;
63 const std::filesystem::path p(libFile);
66 if (std::filesystem::exists(p)) {
67 result = std::filesystem::canonical(p).string();
77 void* handle =
nullptr;
87 LOG(TRACE) <<
"DynLoader: dlOpen: " << lib
.fileName <<
": already open (refCount=" << lib
.refCount <<
")";
94 if (handle !=
nullptr) {
105 LOG(TRACE) <<
"DynLoader: dlOpen: " << libFile <<
": success";
115 if (handle ==
nullptr) {
116 LOG(TRACE) <<
"DynLoader: dlCloseDelayed: handle is nullptr";
120 LOG(TRACE) <<
"DynLoader: dlCloseDelayed: " << handle <<
": not opened using dlOpen";
124 LOG(TRACE) <<
"DynLoader: dlCloseDelayed: internal error: handle known but library record missing";
135 LOG(TRACE) <<
"DynLoader: dlCloseDelayed: " << lib
.fileName;
137 LOG(TRACE) <<
"DynLoader: dlCloseDelayed: " << lib
.fileName <<
": still referenced (refCount=" << lib
.refCount
148 if (handle ==
nullptr) {
149 LOG(TRACE) <<
"DynLoader: dlClose: handle is nullptr";
153 LOG(TRACE) <<
"DynLoader: dlClose: " << handle <<
": not opened using dlOpen";
157 LOG(TRACE) <<
"DynLoader: dlClose: internal error: handle known but library record missing";
166 LOG(TRACE) <<
"DynLoader: dlClose: " << lib
.fileName <<
": still referenced (refCount=" << lib
.refCount <<
")";
204 LOG(TRACE) <<
" dlClose: " << library
.fileName <<
": success";
212 LOG(TRACE) <<
"DynLoader: execDlCloseDeleyed";
214 for (
const std::string& canonicalFile :
closeQueue) {
233 LOG(TRACE) <<
"DynLoader: execDlCloseDeleyed done";
238 LOG(TRACE) <<
"DynLoader: execDlCloseAll";
248 LOG(TRACE) <<
"DynLoader: execDlCloseAll done";
static int realExecDlClose(const Library &library)
static int dlClose(void *handle)
static std::string canonicalizePath(const std::string &libFile)
static const char * dlError()
static void * dlOpen(const std::string &libFile, int flags=RTLD_LOCAL|RTLD_LAZY)
static void execDlCloseDeleyed()
static int dlClose(Library &library)
static const void * dlSym(void *handle, const std::string &symbol)
static std::map< void *, std::string > dlOpenedLibrariesByHandle
static std::map< std::string, Library > dlOpenedLibraries
static void execDlCloseAll()
static std::list< std::string > closeQueue
static void dlCloseDelayed(void *handle)
int dlclose(void *handle)
void * dlsym(void *handle, const char *symbol)
void * dlopen(const char *filename, int flags)
std::string canonicalFileName