summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhei Makarov <serhei@serhei.io>2024-02-02 15:46:36 -0500
committerSerhei Makarov <serhei@serhei.io>2024-02-02 15:46:36 -0500
commitd696cd962751d2b28aca55f6e436a45692700465 (patch)
treecfd84bca70fb49072d63c34e98ecf1d511d12800
parent6b4ea440f3266b7268cfc055e0702154226e2251 (diff)
eu-stacktrace WIP configury: sysprof-N/sysprof-capture-types.hupstream/users/serhei/eu-stacktrace
-rw-r--r--configure.ac29
-rw-r--r--src/stacktrace.c30
2 files changed, 46 insertions, 13 deletions
diff --git a/configure.ac b/configure.ac
index 4b67c844..8472a294 100644
--- a/configure.ac
+++ b/configure.ac
@@ -879,6 +879,34 @@ AC_ARG_ENABLE(debuginfod-urls,
AC_SUBST(DEBUGINFOD_URLS, $default_debuginfod_urls)
AC_CONFIG_FILES([config/profile.sh config/profile.csh])
+AC_ARG_ENABLE([sysprof],AS_HELP_STRING([--enable-sysprof], [Include Sysprof support in eu-stacktrace]))
+AS_IF([test "x$enable_sysprof" != "xno"], [
+ enable_sysprof=no
+ AC_CACHE_CHECK([for sysprof-6/sysprof-capture-types.h], ac_cv_has_sysprof_6_headers,
+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sysprof-6/sysprof-capture-types.h>]])],
+ ac_cv_has_sysprof_6_headers=yes, ac_cv_has_sysprof_6_headers=no)])
+ AM_CONDITIONAL(HAVE_SYSPROF_6_HEADERS, test "x$ac_cv_has_sysprof_6_headers" = xyes)
+ AS_IF([test "x$ac_cv_has_sysprof_6_headers" = xyes], [
+ AC_DEFINE(HAVE_SYSPROF_6_HEADERS)
+ enable_sysprof=yes
+ ])
+ AH_TEMPLATE([HAVE_SYSPROF_6_HEADERS], [Define to 1 if `sysprof-6/sysprof-capture-types.h`
+ is provided by the system, 0 otherwise.])
+ AC_CACHE_CHECK([for sysprof-4/sysprof-capture-types.h], ac_cv_has_sysprof_4_headers,
+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sysprof-4/sysprof-capture-types.h>]])],
+ ac_cv_has_sysprof_4_headers=yes, ac_cv_has_sysprof_4_headers=no)])
+ AM_CONDITIONAL(HAVE_SYSPROF_4_HEADERS, test "x$ac_cv_has_sysprof_4_headers" = xyes)
+ AS_IF([test "x$ac_cv_has_sysprof_4_headers" = xyes], [
+ AC_DEFINE(HAVE_SYSPROF_4_HEADERS)
+ enable_sysprof=yes
+ ])
+ AH_TEMPLATE([HAVE_SYSPROF_4_HEADERS], [Define to 1 if `sysprof-4/sysprof-capture-types.h`
+ is provided by the system, 0 otherwise.])
+ if test "x$enable_sysprof" = "xno"; then
+ AC_MSG_ERROR([sysprof headers not found, use --disable-sysprof to disable.])
+ fi
+])
+
AC_OUTPUT
AC_MSG_NOTICE([
@@ -916,6 +944,7 @@ AC_MSG_NOTICE([
libdebuginfod client support : ${enable_libdebuginfod}
Debuginfod server support : ${enable_debuginfod}
Default DEBUGINFOD_URLS : ${default_debuginfod_urls}
+ Sysprof support in eu-stacktrace : ${enable_sysprof}
EXTRA TEST FEATURES (used with make check)
have bunzip2 installed (required) : ${HAVE_BUNZIP2}
diff --git a/src/stacktrace.c b/src/stacktrace.c
index 77b20832..f6258e7b 100644
--- a/src/stacktrace.c
+++ b/src/stacktrace.c
@@ -82,13 +82,17 @@
#include <system.h>
-/* TODO: Make optional through configury. The #ifdefs are included
- now so we don't miss any code that needs to be controlled with this
- option. */
-#define HAVE_SYSPROF_4_HEADERS
-#ifdef HAVE_SYSPROF_4_HEADERS
-
+#if HAVE_SYSPROF_6_HEADERS
+#include <sysprof-6/sysprof-capture-types.h>
+#define HAVE_SYSPROF_HEADERS 1
+#elif HAVE_SYSPROF_4_HEADERS
#include <sysprof-4/sysprof-capture-types.h>
+#define HAVE_SYSPROF_HEADERS 1
+#else
+#define HAVE_SYSPROF_HEADERS 0
+#endif
+
+#if HAVE_SYSPROF_HEADERS
/* XXX: To be added to new versions of sysprof. */
#ifndef SYSPROF_CAPTURE_FRAME_STACK_USER
@@ -118,8 +122,8 @@ typedef struct
} SysprofCaptureUserRegs
SYSPROF_ALIGNED_END(1);
-#endif // ifndef SYSPROF_CAPTURE_FRAME_STACK_USER
-#endif // ifdef HAVE_SYSPROF_4_HEADERS
+#endif /* SYSPROF_CAPTURE_FRAME_STACK_USER */
+#endif /* HAVE_SYSPROF_HEADERS */
static int maxframes = 256;
@@ -171,7 +175,7 @@ static bool show_summary = true; /* TODO: disable by default in release version
/* Sysprof format support.
TODO: Could split into a separate file or even a library. */
-#ifdef HAVE_SYSPROF_4_HEADERS
+#if HAVE_SYSPROF_HEADERS
/* XXX based on sysprof src/libsysprof-capture/sysprof-capture-reader.c
@@ -422,7 +426,7 @@ sysprof_reader_getframes (SysprofReader *reader,
return 0;
}
-#endif /* HAVE_SYSPROF4_HEADERS */
+#endif /* HAVE_SYSPROF_HEADERS */
/* Main program. */
@@ -501,7 +505,7 @@ parse_opt (int key, char *arg __attribute__ ((unused)),
return 0;
}
-#ifdef HAVE_SYSPROF_4_HEADERS
+#if HAVE_SYSPROF_HEADERS
int
sysprof_none_cb (SysprofCaptureFrame *frame __attribute__ ((unused)),
@@ -1163,7 +1167,7 @@ sysprof_unwind_cb (SysprofCaptureFrame *frame, void *arg)
error (EXIT_BAD, errno, N_("Write error to file or FIFO '%s'"), output_path);
return SYSPROF_CB_OK;
}
-#endif
+#endif /* HAVE_SYSPROF_HEADERS */
int
main (int argc, char **argv)
@@ -1222,7 +1226,7 @@ Utility is a work-in-progress, see README.eu-stacktrace in the source branch.")
if (output_fd < 0)
error (EXIT_BAD, errno, N_("Cannot open output file or FIFO '%s'"), output_path);
-#ifndef HAVE_SYSPROF_4_HEADERS
+#if !(HAVE_SYSPROF_HEADERS)
/* TODO: Should hide corresponding command line options when this is the case. */
error (EXIT_BAD, 0, N_("Sysprof support is not available in this version."));
#else