Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ datadog/maven/resources
.history
.claude/settings.local.json
/jmh-*
build_output.log
7 changes: 6 additions & 1 deletion ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ SpinLock LibraryPatcher::_lock;
const char* LibraryPatcher::_profiler_name = nullptr;
PatchEntry LibraryPatcher::_patched_entries[MAX_NATIVE_LIBS];
int LibraryPatcher::_size = 0;
static char _profiler_path[PATH_MAX];

void LibraryPatcher::initialize() {
if (_profiler_name == nullptr) {
Dl_info info;
void* caller_address = __builtin_return_address(0); // Get return address of caller
bool ret = dladdr(caller_address, &info);
assert(ret);
_profiler_name = realpath(info.dli_fname, nullptr);
_profiler_name = realpath(info.dli_fname, _profiler_path);
if (_profiler_name == nullptr) {
// realpath() failed, fall back to original path
_profiler_name = info.dli_fname;
}
_size = 0;
}
}
Expand Down