* addr2line.c (main_exe_path): support FreeBSD.
At least sh, csh, tcsh, bash, and zsh sets realpath of the main executable for dladdr, but gdb doesn't. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
160b67df68
commit
c05940a403
@ -1,3 +1,9 @@
|
|||||||
|
Mon Apr 14 18:05:48 2014 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* addr2line.c (main_exe_path): support FreeBSD.
|
||||||
|
At least sh, csh, tcsh, bash, and zsh sets realpath of the main
|
||||||
|
executable for dladdr, but gdb doesn't.
|
||||||
|
|
||||||
Mon Apr 14 17:20:10 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Apr 14 17:20:10 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* proc.c (umethod_bind): use the ancestor iclass instead of new
|
* proc.c (umethod_bind): use the ancestor iclass instead of new
|
||||||
|
23
addr2line.c
23
addr2line.c
@ -623,6 +623,15 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define HAVE_MAIN_EXE_PATH
|
#define HAVE_MAIN_EXE_PATH
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
|
# include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
|
/* ssize_t main_exe_path(void)
|
||||||
|
*
|
||||||
|
* store the path of the main executable to `binary_filename`,
|
||||||
|
* and returns strlen(binary_filename).
|
||||||
|
* it is NUL terminated.
|
||||||
|
*/
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
ssize_t
|
ssize_t
|
||||||
main_exe_path(void)
|
main_exe_path(void)
|
||||||
@ -632,6 +641,20 @@ main_exe_path(void)
|
|||||||
binary_filename[len] = 0;
|
binary_filename[len] = 0;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
#elif defined(__FreeBSD__)
|
||||||
|
ssize_t
|
||||||
|
main_exe_path(void)
|
||||||
|
{
|
||||||
|
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
|
||||||
|
size_t len = PATH_MAX;
|
||||||
|
int err = sysctl(mib, 4, binary_filename, &len, NULL, 0);
|
||||||
|
if (err) {
|
||||||
|
kprintf("Can't get the path of ruby");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
len--; /* sysctl sets strlen+1 */
|
||||||
|
return len;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#undef HAVE_MAIN_EXE_PATH
|
#undef HAVE_MAIN_EXE_PATH
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user