diff --git a/src/Makefile.am b/src/Makefile.am index 3234d97..8c4cba6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,9 +15,9 @@ # this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_builddir)/src/include +AM_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_builddir)/src/include -rdynamic -LDFLAGS += $(SQLITE_LIBS) -lpthread +LDFLAGS += $(SQLITE_LIBS) -lpthread -rdynamic bin_PROGRAMS = distromatic diff --git a/src/distromatic.c b/src/distromatic.c index af179e9..0b28748 100644 --- a/src/distromatic.c +++ b/src/distromatic.c @@ -25,6 +25,7 @@ #include #include #include +#include #if HAVE_UNISTD_H # include @@ -193,6 +194,26 @@ program_version(void) { printf("%s\n", freelicense[linenum]); } +/* Obtain a backtrace and print it to stdout. */ +void backtraceHandler(int sig) +{ + void *array[10]; + size_t size; + char **strings; + size_t i; + + size = backtrace (array, 10); + strings = (char**)backtrace_symbols (array, size); + + printf ("Obtained %zd stack frames.\n", size); + + for (i = 0; i < size; i++) + printf ("%s\n", strings[i]); + + free (strings); + exit(1); +} + /* * checks if given single requirement is met by given provides * @@ -1165,6 +1186,9 @@ main(int argc, char *argv[]) { 0, 0, 0, 0 } }; + // install backtrace handler + signal(SIGSEGV, backtraceHandler); + start_time=time(NULL); opterr = 1;