ruby-changes:33315
From: naruse <ko1@a...>
Date: Mon, 24 Mar 2014 15:28:37 +0900 (JST)
Subject: [ruby-changes:33315] naruse:r45394 (trunk): * addr2line.c (rb_dump_backtrace_with_lines): fetch path of the
naruse 2014-03-24 15:28:32 +0900 (Mon, 24 Mar 2014) New Revision: 45394 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45394 Log: * addr2line.c (rb_dump_backtrace_with_lines): fetch path of the executable from /proc/self/exe on Linux. Modified files: trunk/ChangeLog trunk/addr2line.c Index: ChangeLog =================================================================== --- ChangeLog (revision 45393) +++ ChangeLog (revision 45394) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Mar 24 15:19:47 2014 NARUSE, Yui <naruse@r...> + + * 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@g...> * gc.c: Fix up default GC params by @csfrancis [fix GH-556] Index: addr2line.c =================================================================== --- addr2line.c (revision 45393) +++ addr2line.c (revision 45394) @@ -618,13 +618,39 @@ rb_dump_backtrace_with_lines(int num_tra https://github.com/ruby/ruby/blob/trunk/addr2line.c#L618 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; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/