| Elements
    6.2
    A C++ base framework for the Euclid Software. | 
 
 
 
Go to the documentation of this file.
   26 #include <sys/param.h> 
   27 #include <sys/times.h> 
   31 #include <mach-o/dyld.h>   
   49 #include <boost/filesystem/operations.hpp>   
   68   ::dladdr(FuncPtrCast<void*>(funct), 
m_dlinfo.
get());
 
   72   return ::basename(
const_cast<char*
>(
m_dlinfo->dli_fname));
 
   76   return const_cast<char*
>(
m_dlinfo->dli_fname);
 
   87 ModuleInfo::operator 
const Dl_info&() 
const {
 
   96   static string module{};
 
   99       string mod = ::basename(
const_cast<char*
>((
reinterpret_cast<Dl_info*
>(
moduleHandle()))->dli_fname));
 
  100       module     = mod.
substr(
static_cast<string::size_type
>(0), mod.
find(
'.'));
 
  108   static string module{};
 
  109   if (module.empty()) {
 
  114       if (::realpath(
path, name.data())) {
 
  115         module = name.data();
 
  130     } 
else if (module[loc] == 
'e' or module[loc] == 
'E') {
 
  132     } 
else if (module[loc] == 
's' and module[loc + 1] == 
'o') {
 
  144   static void*        hP  = 
reinterpret_cast<void*
>(pid);
 
  149   s_module_handle = handle;
 
  153   if (
nullptr == s_module_handle) {
 
  156       if (0 != ::dladdr(FuncPtrCast<void*>(
moduleHandle), &info)) {
 
  161   return s_module_handle;
 
  166   static Dl_info  infoBuf;
 
  167   static Dl_info* info;
 
  169   if (
nullptr == info) {
 
  170     void* handle = ::dlopen(
nullptr, RTLD_LAZY);
 
  171     if (
nullptr != handle) {
 
  172       void* func = ::dlsym(handle, 
"main");
 
  173       if (
nullptr != func) {
 
  174         if (0 != ::dladdr(func, &infoBuf)) {
 
  184   static string module{
""};
 
  185   if (module.empty()) {
 
  197   if (not boost::filesystem::exists(exe)) {
 
  199     self_str << 
"/proc/" << ::getpid();
 
  222     if (not(iss >> address >> perms >> offset >> dev >> inode >> pathname)) {
 
  225     if (perms == 
"r-xp" and boost::filesystem::exists(pathname)) {
 
  232   return linked_modules;
 
  237   if (s_linkedModules.size() == 0) {
 
  243   return s_linkedModules;
 
  250   char         pathbuf[PATH_MAX + 1];
 
  251   unsigned int bufsize = 
sizeof(pathbuf);
 
  252   _NSGetExecutablePath(pathbuf, &bufsize);
 
  253   path self_exe = 
path(
string(pathbuf));
 
  260   return boost::filesystem::canonical(self_exe);
 
  
boost::filesystem::path Item
const std::string name() const
ELEMENTS_API void setModuleHandle(ImageHandle handle)
Attach module handle.
provide functions to retrieve resources pointed by environment variables
const ELEMENTS_API std::string & moduleName()
Get the name of the (executable/DLL) file without file-type.
ELEMENTS_API ImageHandle exeHandle()
Handle to the executable file running.
defines a Small helper function that allows the cast from void * to function pointer
const ELEMENTS_API std::string & moduleNameFull()
Get the full name of the (executable/DLL) file.
const ELEMENTS_API std::vector< std::string > linkedModules()
Vector of names of linked modules.
ELEMENTS_API ModuleType moduleType()
Get type of the module.
const std::string libraryName() const
ELEMENTS_API ProcessHandle processHandle()
Handle to running process.
T emplace_back(T... args)
const ELEMENTS_API std::string & exeName()
Name of the executable file running.
const void * addresse() const
std::unique_ptr< Dl_info > m_dlinfo
ELEMENTS_API ImageHandle moduleHandle()
Handle to currently executed module.
void * ImageHandle
Definition of an image handle.
ELEMENTS_API Path::Item getSelfProc()
Get the path to the /proc directory of the process.
OS specific details to access at run-time the module configuration of the process.
ELEMENTS_API Path::Item getExecutablePath()
Get the full executable path.
ELEMENTS_API std::vector< Path::Item > linkedModulePaths()
Path::Item path
importing the path item from ElementsKernel