From f89fd4ab04aa57629043409b6b285c1a36e253f5 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 31 Jan 2021 20:27:32 +0100 Subject: [PATCH] Executable path discovery on BSDs. --- client/TracyProfiler.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 5d0ca5e6..b8e0ec7e 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -293,6 +293,24 @@ static const char* GetProcessExecutablePath() uint32_t size = 1024; _NSGetExecutablePath( buf, &size ); return buf; +#elif defined __DragonFly__ + static char buf[1024]; + readlink( "/proc/curproc/file", buf, 1024 ); + return buf; +#elif defined __FreeBSD__ + static char buf[1024]; + int mib[4]; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PATHNAME; + mib[3] = -1; + size_t cb = 1024; + sysctl( mib, 4, buf, &cb, nullptr, 0 ); + return buf; +#elif defined __NetBSD__ + static char buf[1024]; + readlink( "/proc/curproc/exe", buf, 1024 ); + return buf; #else return nullptr; #endif