MCPcopy Create free account
hub / github.com/apple/foundationdb / getImageInfo

Function getImageInfo

flow/Platform.actor.cpp:3348–3378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3346#endif
3347
3348platform::ImageInfo getImageInfo(const void* symbol) {
3349 Dl_info info;
3350 platform::ImageInfo imageInfo;
3351
3352#ifdef __linux__
3353 link_map* linkMap = nullptr;
3354 int res = dladdr1(symbol, &info, (void**)&linkMap, RTLD_DL_LINKMAP);
3355#else
3356 int res = dladdr(symbol, &info);
3357#endif
3358
3359 if (res != 0) {
3360 imageInfo.fileName = info.dli_fname;
3361 std::string imageFile = basename(info.dli_fname);
3362 // If we have a client library that doesn't end in the appropriate extension, we will get the wrong debug
3363 // suffix. This should only be a cosmetic problem, though.
3364#ifdef __linux__
3365 imageInfo.offset = (void*)linkMap->l_addr;
3366 if (imageFile.length() >= 3 && imageFile.rfind(".so") == imageFile.length() - 3) {
3367 imageInfo.symbolFileName = imageFile + "-debug";
3368 }
3369#else
3370 imageInfo.offset = info.dli_fbase;
3371 if (imageFile.length() >= 6 && imageFile.rfind(".dylib") == imageFile.length() - 6) {
3372 imageInfo.symbolFileName = imageFile + "-debug";
3373 }
3374#endif
3375 else {
3376 imageInfo.symbolFileName = imageFile + ".debug";
3377 }
3378 }
3379
3380 return imageInfo;
3381}

Callers 2

getCachedImageInfoFunction · 0.85
createDatabaseMethod · 0.85

Calls 4

basenameFunction · 0.85
getCachedImageInfoFunction · 0.85
ImageInfoClass · 0.85
lengthMethod · 0.45

Tested by

no test coverage detected