From 94cec74096280509083798bfcbd1be169fd43562 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 11 Oct 2010 16:40:18 -0700 Subject: Try to print backtraces on failure --- src/rt/rust_task.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/rt/rust_task.cpp') diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 97eeb4bff5d..530e5997f55 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -4,6 +4,10 @@ #include "valgrind.h" #include "memcheck.h" +#ifndef __WIN32__ +#include +#endif + // Stacks // FIXME (issue #151): This should be 0x300; the change here is for @@ -366,6 +370,7 @@ void rust_task::fail(size_t nargs) { // See note in ::kill() regarding who should call this. dom->log(rust_log::TASK, "task %s @0x%" PRIxPTR " failing", name, this); + backtrace(); // Unblock the task so it can unwind. unblock(); if (this == dom->root_task) @@ -632,6 +637,18 @@ rust_task::log(uint32_t type_bits, char const *fmt, ...) { } } +void +rust_task::backtrace() { + if (!dom->get_log().is_tracing(rust_log::BT)) + return; + +#ifndef __WIN32__ + void *call_stack[256]; + int nframes = ::backtrace(call_stack, 256); + backtrace_symbols_fd(call_stack + 1, nframes - 1, 2); +#endif +} + rust_handle * rust_task::get_handle() { if (handle == NULL) { -- cgit 1.4.1-3-g733a5