================ @@ -139,8 +177,53 @@ FileSpec HostInfoPosix::GetDefaultShell() { return FileSpec("/bin/sh"); } +FileSpec HostInfoPosix::GetProgramFileSpec() { + static FileSpec g_program_filespec; + + if (!g_program_filespec) { + char exe_path[PATH_MAX]; + ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1); + if (len > 0) { + exe_path[len] = 0; + g_program_filespec.SetFile(exe_path, FileSpec::Style::native); + } + } + + return g_program_filespec; +} ---------------- labath wrote:
I'm not too sure about this one. While other posix-like systems do have a "proc" file system, its contents tends to be very different. Juding by [this manpage](https://man.freebsd.org/cgi/man.cgi?query=procfs) the FreeBSD equivalent to `/proc/self/exe` *might* be `/proc/curproc/file`. @DavidSpickett, do you know if code like this would work for FreeBSD (with a change in the file name)? If so, then I'd say this is sufficient reason to put this code here. Otherwise, I'd probably keep it in Linux. (Depending on how similar the two end up looking, we may want to have a common linux/aix class or accept the duplication) https://github.com/llvm/llvm-project/pull/119694 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits