aboutsummaryrefslogtreecommitdiffstats
path: root/addr2line.c
diff options
context:
space:
mode:
Diffstat (limited to 'addr2line.c')
-rw-r--r--addr2line.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/addr2line.c b/addr2line.c
index 9e7df4e7fb..635194b96b 100644
--- a/addr2line.c
+++ b/addr2line.c
@@ -21,6 +21,10 @@
#include <stdio.h>
#include <errno.h>
+#ifdef HAVE_LIBPROC_H
+#include <libproc.h>
+#endif
+
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#else
@@ -2068,6 +2072,15 @@ main_exe_path(void)
len--; /* sysctl sets strlen+1 */
return len;
}
+#elif defined(HAVE_LIBPROC_H)
+static ssize_t
+main_exe_path(void)
+{
+ int len = proc_pidpath(getpid(), binary_filename, PATH_MAX);
+ if (len == 0) return 0;
+ binary_filename[len] = 0;
+ return len;
+}
#else
#undef HAVE_MAIN_EXE_PATH
#endif