Skip to content

Commit e6b72e8

Browse files
devnexennobu
authored andcommitted
retrieve current path on macOS
1 parent 1408f15 commit e6b72e8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

addr2line.c

+13
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
#include <stdio.h>
2222
#include <errno.h>
2323

24+
#ifdef HAVE_LIBPROC_H
25+
#include <libproc.h>
26+
#endif
27+
2428
#ifdef HAVE_STDBOOL_H
2529
#include <stdbool.h>
2630
#else
@@ -2068,6 +2072,15 @@ main_exe_path(void)
20682072
len--; /* sysctl sets strlen+1 */
20692073
return len;
20702074
}
2075+
#elif defined(HAVE_LIBPROC_H)
2076+
static ssize_t
2077+
main_exe_path(void)
2078+
{
2079+
int len = proc_pidpath(getpid(), binary_filename, PATH_MAX);
2080+
if (len == 0) return 0;
2081+
binary_filename[len] = 0;
2082+
return len;
2083+
}
20712084
#else
20722085
#undef HAVE_MAIN_EXE_PATH
20732086
#endif

0 commit comments

Comments
 (0)