mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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:
parent
5376610d0c
commit
a1a6fd90bb
3 changed files with 36 additions and 25 deletions
|
@ -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>
|
Tue Apr 2 15:22:09 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* test/ruby/envutil.rb (assert_separately): stop_auto_run of
|
* test/ruby/envutil.rb (assert_separately): stop_auto_run of
|
||||||
|
|
|
@ -336,6 +336,7 @@ VALUE rb_sourcefilename(void);
|
||||||
|
|
||||||
/* vm_dump.c */
|
/* vm_dump.c */
|
||||||
void rb_vm_bugreport(void);
|
void rb_vm_bugreport(void);
|
||||||
|
void rb_print_backtrace(void);
|
||||||
|
|
||||||
/* vm_eval.c */
|
/* vm_eval.c */
|
||||||
void Init_vm_eval(void);
|
void Init_vm_eval(void);
|
||||||
|
|
54
vm_dump.c
54
vm_dump.c
|
@ -674,6 +674,34 @@ dump_thread(void *arg)
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
void
|
||||||
rb_vm_bugreport(void)
|
rb_vm_bugreport(void)
|
||||||
{
|
{
|
||||||
|
@ -708,32 +736,8 @@ rb_vm_bugreport(void)
|
||||||
#if HAVE_BACKTRACE || defined(_WIN32)
|
#if HAVE_BACKTRACE || defined(_WIN32)
|
||||||
fprintf(stderr, "-- C level backtrace information "
|
fprintf(stderr, "-- C level backtrace information "
|
||||||
"-------------------------------------------\n");
|
"-------------------------------------------\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");
|
fprintf(stderr, "\n");
|
||||||
#endif /* HAVE_BACKTRACE */
|
#endif /* HAVE_BACKTRACE */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue