1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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:
naruse 2014-04-14 10:08:02 +00:00
parent 160b67df68
commit c05940a403
2 changed files with 29 additions and 0 deletions

View file

@ -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>
* proc.c (umethod_bind): use the ancestor iclass instead of new

View file

@ -623,6 +623,15 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
}
#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__)
ssize_t
main_exe_path(void)
@ -632,6 +641,20 @@ main_exe_path(void)
binary_filename[len] = 0;
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
#undef HAVE_MAIN_EXE_PATH
#endif