]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
eu-stacktrace WIP configury: sysprof-N/sysprof-capture-types.h
authorSerhei Makarov <serhei@serhei.io>
Fri, 2 Feb 2024 20:46:36 +0000 (15:46 -0500)
committerSerhei Makarov <serhei@serhei.io>
Fri, 2 Feb 2024 20:46:36 +0000 (15:46 -0500)
configure.ac
src/stacktrace.c

index 4b67c84425fa36846131a937cd4c7d05c8762761..8472a294ea2df83a9dc6ee6977a0cf0668bff136 100644 (file)
@@ -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}
index 77b208322d4dbbbacf37e324e255d5de532d696e..f6258e7b1fe1260546bedce729b24583b6291761 100644 (file)
 
 #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