From 1300e68fa5afd244912307176bb73203c0b15b29 Mon Sep 17 00:00:00 2001 From: axel Date: Sat, 20 Jan 2007 12:36:49 +1000 Subject: [PATCH] Add support for backtraces - if the compiler and libc version supports it (probably only glibc/gcc) then a stack trace is printed on serious bugs darcs-hash:20070120023649-ac50b-5efa310bea0deddfa1d8dfca1000163eee89c7cb.gz --- common.c | 26 ++++++++++++++++++++++++++ common.h | 28 +++++++++++++++++----------- configure.ac | 12 +++++++++--- env.c | 2 +- fallback.c | 13 +++++++++++++ main.c | 1 - 6 files changed, 66 insertions(+), 16 deletions(-) diff --git a/common.c b/common.c index 1e42cb731..0b7a26aed 100644 --- a/common.c +++ b/common.c @@ -44,6 +44,10 @@ parts of fish. #include #include +#ifdef HAVE_EXECINFO_H +#include +#endif + #ifndef HOST_NAME_MAX /** Maximum length of hostname return. It is ok if this is too short, @@ -110,6 +114,28 @@ static struct winsize termsize; */ static string_buffer_t *setlocale_buff=0; + +void show_stackframe() +{ + void *trace[32]; + char **messages = (char **)NULL; + int i, trace_size = 0; + + trace_size = backtrace(trace, 32); + messages = backtrace_symbols(trace, trace_size); + + if( messages ) + { + debug( 0, L"Backtrace:" ); + for( i=0; i