summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--benchmarks/Makefile.am4
-rw-r--r--configure.ac10
-rw-r--r--debugger/Makefile.am3
-rw-r--r--demos/Makefile.am4
-rw-r--r--lib/Makefile.am5
-rw-r--r--lib/igt_core.c31
-rw-r--r--tests/Makefile.am3
-rw-r--r--tools/Makefile.am4
8 files changed, 53 insertions, 11 deletions
diff --git a/benchmarks/Makefile.am b/benchmarks/Makefile.am
index 86f755a0..8473b180 100644
--- a/benchmarks/Makefile.am
+++ b/benchmarks/Makefile.am
@@ -2,5 +2,5 @@
include Makefile.sources
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib
-AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) $(CAIRO_CFLAGS)
-LDADD = $(top_builddir)/lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS)
+AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) $(CAIRO_CFLAGS) $(LIBUNWIND_CFLAGS)
+LDADD = $(top_builddir)/lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS) $(LIBUNWIND_LIBS)
diff --git a/configure.ac b/configure.ac
index 9b646ddb..b9ecef8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,6 +187,15 @@ AM_CONDITIONAL(BUILD_SHADER_DEBUGGER, [test "x$BUILD_SHADER_DEBUGGER" != xno])
AS_IF([test "x$BUILD_SHADER_DEBUGGER" != xno],
[enable_debugger=yes], [enable_debugger=no])
+AC_ARG_WITH(libunwind,
+ AS_HELP_STRING([--without-libunwind],
+ [Build tests without libunwind support]),
+ [], [with_libunwind=yes])
+if test "x$with_libunwind" = xyes; then
+ PKG_CHECK_MODULES(LIBUNWIND, libunwind, AC_DEFINE(HAVE_LIBUNWIND, 1, [libunwind support]),
+ AC_MSG_ERROR([libunwind not found. Use --without-libunwind to disable libunwind support.]))
+fi
+
# -----------------------------------------------------------------------------
# To build multithread code, gcc uses -pthread, Solaris Studio cc uses -mt
@@ -243,6 +252,7 @@ echo ""
echo " • Tests:"
echo " Build tests : ${BUILD_TESTS}"
echo " Compile prime tests: ${NOUVEAU}"
+echo " Print stack traces : ${with_libunwind}"
echo ""
echo " • Tools:"
echo " Assembler : ${enable_assembler}"
diff --git a/debugger/Makefile.am b/debugger/Makefile.am
index f1e49b92..0b6028b4 100644
--- a/debugger/Makefile.am
+++ b/debugger/Makefile.am
@@ -12,6 +12,7 @@ AM_CFLAGS = \
$(DRM_CFLAGS) \
$(PCIACCESS_CFLAGS) \
$(CAIRO_CFLAGS) \
+ $(LIBUNWIND_CFLAGS) \
$(CWARNFLAGS)
-LDADD = $(top_builddir)/lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS)
+LDADD = $(top_builddir)/lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS) $(LIBUNWIND_LIBS)
diff --git a/demos/Makefile.am b/demos/Makefile.am
index 49804d79..029581a6 100644
--- a/demos/Makefile.am
+++ b/demos/Makefile.am
@@ -3,5 +3,5 @@ bin_PROGRAMS = \
$(NULL)
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib
-AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) $(CAIRO_CFLAGS)
-LDADD = $(top_builddir)/lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS)
+AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) $(CAIRO_CFLAGS) $(LIBUNWIND_CFLAGS)
+LDADD = $(top_builddir)/lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS) $(LIBUNWIND_LIBS)
diff --git a/lib/Makefile.am b/lib/Makefile.am
index a5a43908..4db90d4a 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -9,12 +9,11 @@ noinst_LTLIBRARIES = libintel_tools.la
noinst_HEADERS = check-ndebug.h
AM_CPPFLAGS = -I$(top_srcdir)
-AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) \
+AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) $(LIBUNWIND_CFLAGS) \
-DIGT_DATADIR=\""$(abs_top_srcdir)/tests"\" \
-DIGT_LOG_DOMAIN=\""$(subst _,-,$*)"\" \
-pthread
-
-LDADD = $(CAIRO_LIBS)
+LDADD = $(CAIRO_LIBS) $(LIBUNWIND_LIBS)
AM_CFLAGS += $(CAIRO_CFLAGS)
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 7c68d4eb..4cc040f5 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -962,6 +962,33 @@ static bool run_under_gdb(void)
strncmp(basename(buf), "gdb", 3) == 0);
}
+#ifdef HAVE_LIBUNWIND
+#define UNW_LOCAL_ONLY
+#include <libunwind.h>
+
+static void print_backtrace(void)
+{
+ unw_cursor_t cursor;
+ unw_context_t uc;
+ int stack_num = 0;
+
+ printf("Stack trace:\n");
+
+ unw_getcontext(&uc);
+ unw_init_local(&cursor, &uc);
+ while (unw_step(&cursor) > 0) {
+ char name[255];
+ unw_word_t off;
+
+ if (unw_get_proc_name(&cursor, name, 255, &off) < 0)
+ strcpy(name, "<unknown>");
+
+ printf(" #%d [%s+0x%x]\n", stack_num++, name,
+ (unsigned int) off);
+ }
+}
+#endif
+
void __igt_fail_assert(int exitcode, const char *domain, const char *file,
const int line, const char *func, const char *assertion,
const char *f, ...)
@@ -983,6 +1010,10 @@ void __igt_fail_assert(int exitcode, const char *domain, const char *file,
va_end(args);
}
+#ifdef HAVE_LIBUNWIND
+ print_backtrace();
+#endif
+
if (run_under_gdb())
abort();
igt_fail(exitcode);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0ae2541e..93f41ba9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -37,9 +37,10 @@ AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) \
-I$(srcdir)/../lib \
-include "$(srcdir)/../lib/check-ndebug.h" \
-DIGT_DATADIR=\""$(abs_srcdir)"\" \
+ $(LIBUNWIND_CFLAGS) \
$(NULL)
-LDADD = ../lib/libintel_tools.la $(PCIACCESS_LIBS) $(DRM_LIBS)
+LDADD = ../lib/libintel_tools.la $(PCIACCESS_LIBS) $(DRM_LIBS) $(LIBUNWIND_LIBS)
LDADD += $(CAIRO_LIBS) $(LIBUDEV_LIBS) $(GLIB_LIBS)
AM_CFLAGS += $(CAIRO_CFLAGS) $(LIBUDEV_CFLAGS) $(GLIB_CFLAGS)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 64fa0604..04bfd128 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -7,6 +7,6 @@ SUBDIRS += quick_dump
endif
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib
-AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) $(CAIRO_CFLAGS)
-LDADD = $(top_builddir)/lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS) $(LIBUDEV_LIBS)
+AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) $(CAIRO_CFLAGS) $(LIBUNWIND_CFLAGS)
+LDADD = $(top_builddir)/lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS) $(LIBUDEV_LIBS) $(LIBUNWIND_LIBS)