def global_backtrace_report
if Kernel.respond_to?(:caller_for_all_threads)
output = "========== Process #{Process.pid}: backtrace dump ==========\n"
caller_for_all_threads.each_pair do |thread, stack|
output << ("-" * 60) << "\n"
output << "# Thread: #{thread.inspect}, "
if thread == Thread.main
output << "[main thread], "
end
if thread == Thread.current
output << "[current thread], "
end
output << "alive = #{thread.alive?}\n"
output << ("-" * 60) << "\n"
output << " " << stack.join("\n ")
output << "\n\n"
end
else
output = "========== Process #{Process.pid}: backtrace dump ==========\n"
output << ("-" * 60) << "\n"
output << "# Current thread: #{Thread.current.inspect}\n"
output << ("-" * 60) << "\n"
output << " " << caller.join("\n ")
end
return output
end