Commit abede42d authored by David Zeuthen's avatar David Zeuthen

build with -rdynamic for maint mode and use this to print a stack trace

parent d6411e8a
......@@ -52,6 +52,14 @@ fi
AM_CONDITIONAL(KIT_GCOV_ENABLED, test x$enable_gcov = xyes)
AM_CONDITIONAL(POLKIT_GCOV_ENABLED, test x$enable_gcov = xyes)
if test "${enable_verbose_mode}" != no; then
# To get -rdynamic you pass -export-dynamic to libtool.
AC_DEFINE(BUILT_R_DYNAMIC,1,[whether -export-dynamic was passed to libtool])
R_DYNAMIC_LDFLAG=-export-dynamic
else
R_DYNAMIC_LDFLAG=
fi
AC_SUBST(R_DYNAMIC_LDFLAG)
if test "${enable_man_page}" != no; then
dnl
......
......@@ -44,11 +44,11 @@ kit_test_SOURCES= \
kit-test-main.c
kit_test_LDADD=$(top_builddir)/src/kit/libkit.la
kit_test_LDFLAGS=
kit_test_LDFLAGS=@R_DYNAMIC_LDFLAG@
if KIT_GCOV_ENABLED
clean-gcov:
rm -f *.gcov .libs/*.gcda
rm -f *.gcov .libs/*.gcda *.gcda
.PHONY: coverage-report.txt covered-files.txt
......
......@@ -34,6 +34,10 @@
#include <string.h>
#include <errno.h>
#ifdef BUILT_R_DYNAMIC
#include <execinfo.h>
#endif
#include <kit/kit-memory.h>
#include <kit/kit-test.h>
......@@ -232,6 +236,42 @@ _kit_memory_fail_nth_alloc (int number)
#endif /* KIT_BUILD_TESTS */
/* There's probably a better place for this function ... */
/**
* kit_print_backtrace:
*
* Print a back trace if built with -rdynamic or similar.
*/
void
kit_print_backtrace (void)
{
#ifdef BUILT_R_DYNAMIC
void *bt[500];
int bt_size;
int i;
char **syms;
bt_size = backtrace (bt, 500);
syms = backtrace_symbols (bt, bt_size);
i = 0;
while (i < bt_size)
{
fprintf (stderr, " %s\n", syms[i]);
++i;
}
fprintf (stderr, "\n");
fflush (stderr);
free (syms);
#else
fprintf (stderr, " Not built with -rdynamic so unable to print a backtrace\n");
#endif
}
#ifdef KIT_BUILD_TESTS
......
......@@ -66,6 +66,8 @@ typedef int kit_bool_t;
# define FALSE 0
#endif
void kit_print_backtrace (void);
/**
* kit_assert:
* @expr: expression
......@@ -80,6 +82,7 @@ do {
; \
} else { \
kit_warning ("%s:%d:%s(): %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \
kit_print_backtrace (); \
exit (1); \
} \
} while (0)
......@@ -99,6 +102,7 @@ do {
; \
} else { \
kit_warning ("%s:%d:%s(): %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \
kit_print_backtrace (); \
return; \
} \
} while (0)
......@@ -119,6 +123,7 @@ do {
; \
} else { \
kit_warning ("%s:%d:%s(): %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \
kit_print_backtrace (); \
return val; \
} \
} while (0)
......
......@@ -27,7 +27,7 @@ libpolkit_dbus_la_SOURCES = \
libpolkit_dbus_la_LIBADD = @DBUS_LIBS@ $(top_builddir)/src/polkit/libpolkit.la $(SELINUX_LIBS) $(GLIB_LIBS)
libpolkit_dbus_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
libpolkit_dbus_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) @R_DYNAMIC_LDFLAG@
if POLKIT_AUTHDB_DEFAULT
libexec_PROGRAMS = polkit-read-auth-helper polkit-set-default-helper
......@@ -71,7 +71,7 @@ polkit_dbus_test_LDFLAGS=
if KIT_GCOV_ENABLED
clean-gcov:
rm -f *.gcov .libs/*.gcda
rm -f *.gcov .libs/*.gcda *.gcda
.PHONY: coverage-report.txt covered-files.txt
......
......@@ -34,7 +34,7 @@ endif
libpolkit_grant_la_LIBADD = @GLIB_LIBS@ @DBUS_LIBS@ $(top_builddir)/src/polkit/libpolkit.la
libpolkit_grant_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
libpolkit_grant_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) @R_DYNAMIC_LDFLAG@
# Only if the authdb backend has the capability POLKIT_AUTHORIZATION_DB_CAPABILITY_CAN_OBTAIN
# then the backend must supply the /usr/libexec/polkit-grant-helper program.. also remember to
......
......@@ -11,7 +11,8 @@ INCLUDES = \
-DPACKAGE_LIB_DIR=\""$(libdir)"\" \
-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
-DPOLKIT_COMPILATION \
-DTEST_DATA_DIR=\"$(top_srcdir)/test/\"
-DTEST_DATA_DIR=\"$(top_srcdir)/test/\" \
-DTEST_BUILD_DIR=\"$(top_builddir)\"
lib_LTLIBRARIES=libpolkit.la
......@@ -72,7 +73,7 @@ endif
libpolkit_la_LIBADD = @EXPAT_LIBS@ $(top_builddir)/src/kit/libkit.la
libpolkit_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
libpolkit_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) @R_DYNAMIC_LDFLAG@
## note that TESTS has special meaning (stuff to use in make check)
## so if adding tests not to be run in make check, don't add them to
......@@ -91,7 +92,7 @@ polkit_test_LDFLAGS=
if POLKIT_GCOV_ENABLED
clean-gcov:
rm -f *.gcov .libs/*.gcda
rm -f *.gcov .libs/*.gcda *.gcda
.PHONY: coverage-report.txt covered-files.txt
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment