* vm_dump.c (rb_print_backtrace): separate to ease showing C backtrace.

* internal.h (rb_print_backtrace): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2013-04-02 07:02:54 +00:00
Родитель 5376610d0c
Коммит a1a6fd90bb
3 изменённых файлов: 36 добавлений и 25 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Tue Apr 2 16:00:06 2013 NARUSE, Yui <naruse@ruby-lang.org>
* vm_dump.c (rb_print_backtrace): separate to ease showing C backtrace.
* internal.h (rb_print_backtrace): ditto.
Tue Apr 2 15:22:09 2013 NARUSE, Yui <naruse@ruby-lang.org>
* test/ruby/envutil.rb (assert_separately): stop_auto_run of

Просмотреть файл

@ -336,6 +336,7 @@ VALUE rb_sourcefilename(void);
/* vm_dump.c */
void rb_vm_bugreport(void);
void rb_print_backtrace(void);
/* vm_eval.c */
void Init_vm_eval(void);

Просмотреть файл

@ -674,6 +674,34 @@ dump_thread(void *arg)
}
#endif
void
rb_print_backtrace(void)
{
#if HAVE_BACKTRACE
#define MAX_NATIVE_TRACE 1024
static void *trace[MAX_NATIVE_TRACE];
int n = backtrace(trace, MAX_NATIVE_TRACE);
char **syms = backtrace_symbols(trace, n);
if (syms) {
#ifdef USE_ELF
rb_dump_backtrace_with_lines(n, trace, syms);
#else
int i;
for (i=0; i<n; i++) {
fprintf(stderr, "%s\n", syms[i]);
}
#endif
free(syms);
}
#elif defined(_WIN32)
DWORD tid = GetCurrentThreadId();
HANDLE th = (HANDLE)_beginthread(dump_thread, 0, &tid);
if (th != (HANDLE)-1)
WaitForSingleObject(th, INFINITE);
#endif
}
void
rb_vm_bugreport(void)
{
@ -708,32 +736,8 @@ rb_vm_bugreport(void)
#if HAVE_BACKTRACE || defined(_WIN32)
fprintf(stderr, "-- C level backtrace information "
"-------------------------------------------\n");
rb_print_backtrace();
{
#if HAVE_BACKTRACE
#define MAX_NATIVE_TRACE 1024
static void *trace[MAX_NATIVE_TRACE];
int n = backtrace(trace, MAX_NATIVE_TRACE);
char **syms = backtrace_symbols(trace, n);
if (syms) {
#ifdef USE_ELF
rb_dump_backtrace_with_lines(n, trace, syms);
#else
int i;
for (i=0; i<n; i++) {
fprintf(stderr, "%s\n", syms[i]);
}
#endif
free(syms);
}
#elif defined(_WIN32)
DWORD tid = GetCurrentThreadId();
HANDLE th = (HANDLE)_beginthread(dump_thread, 0, &tid);
if (th != (HANDLE)-1)
WaitForSingleObject(th, INFINITE);
#endif
}
fprintf(stderr, "\n");
#endif /* HAVE_BACKTRACE */