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

* addr2line.c (rb_dump_backtrace_with_lines): fetch path of the

executable from /proc/self/exe on Linux.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2014-03-24 06:28:32 +00:00
parent 23d790e46f
commit 2e47a521e6
2 changed files with 32 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Mon Mar 24 15:19:47 2014 NARUSE, Yui <naruse@ruby-lang.org>
* addr2line.c (rb_dump_backtrace_with_lines): fetch path of the
executable from /proc/self/exe on Linux.
Mon Mar 24 14:14:37 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* gc.c: Fix up default GC params by @csfrancis [fix GH-556]

View file

@ -618,13 +618,39 @@ rb_dump_backtrace_with_lines(int num_traces, void **traces, char **syms)
line_info_t *lines = (line_info_t *)calloc(num_traces, sizeof(line_info_t));
#ifdef HAVE_DLADDR
# ifdef __linux__
# define PROC_SELF_EXE "/proc/self/exe"
intptr_t main_fbase;
char *main_path;
{
Dl_info info;
dladdr(rb_dump_backtrace_with_lines, &info);
main_fbase = (intptr_t)info.dli_fbase;
}
{
ssize_t len = readlink(PROC_SELF_EXE, binary_filename, PATH_MAX);
main_path = (char *)alloca(len + 1);
if (!main_path) return;
strncpy(main_path, binary_filename, len);
main_path[len] = 0;
}
# endif
/* get object name in which the symbol is */
for (i = 0; i < num_traces; i++) {
Dl_info info;
if (dladdr(traces[i], &info)) {
lines[i].path = info.dli_fname;
/* this may set base addr even if executable is not shared object file */
lines[i].base_addr = (intptr_t)info.dli_fbase;
# ifdef __linux__
if (lines[i].base_addr == main_fbase) {
lines[i].path = main_path;
}
else {
lines[i].path = info.dli_fname;
}
# else
lines[i].path = info.dli_fname;
# endif
lines[i].line = 0;
if (info.dli_saddr) {
lines[i].sname = info.dli_sname;