]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
eu-stacktrace WIP: include sysprof-capture-types.h
authorSerhei Makarov <serhei@serhei.io>
Mon, 3 Apr 2023 19:49:07 +0000 (15:49 -0400)
committerSerhei Makarov <serhei@serhei.io>
Mon, 3 Apr 2023 19:57:48 +0000 (15:57 -0400)
This header defines the Sysprof data format; we could make it optional
through configury, but for now the prototype does not support any other
data format.

README.eu-stacktrace [new file with mode: 0644]
src/stacktrace.c

diff --git a/README.eu-stacktrace b/README.eu-stacktrace
new file mode 100644 (file)
index 0000000..3aaa63e
--- /dev/null
@@ -0,0 +1,6 @@
+# eu-stacktrace development branch
+
+Requirements:
+- /usr/include/sysprof-4 headers (e.g. `sysprof-devel` package on Fedora)
+
+...
index acb86a605738201a6e3d8e0636e7f038ba5662b7..485ddd7fbe1ef8c1e134ac95b2e8e9ede0ce4441 100644 (file)
 #include <stdio.h>
 #include <string.h>
 
+#include <system.h>
+
+/* TODO: Make optional through configury.  The #ifdefs are included
+   already 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
+#include <sysprof-4/sysprof-capture-types.h>
+#endif
+
 static char *input_path = NULL;
 static char *output_path = NULL;
 
@@ -35,6 +45,15 @@ static int processing_mode;
 #define FORMAT_SYSPROF 0x2
 static int input_format;
 
+/* Program exit codes. All samples processed without any errors is
+   GOOD.  Some non-fatal errors during processing is an ERROR.  A fatal
+   error or no samples processed at all is BAD.  A command line USAGE
+   exit is generated by argp_error. */
+#define EXIT_OK     0
+#define EXIT_ERROR  1
+#define EXIT_BAD    2
+#define EXIT_USAGE 64
+
 static error_t
 parse_opt (int key, char *arg __attribute__ ((unused)),
           struct argp_state *state)
@@ -134,4 +153,10 @@ Utility is a work-in-progress, see README.eu-stacktrace in the source branch.")
   argp_parse(&argp, argc, argv, 0, NULL, NULL);
 
   /* hello world */
+#ifdef HAVE_SYSPROF_4_HEADERS
+  printf("hello sysprof: %x\n", SYSPROF_CAPTURE_MAGIC);
+#else
+  /* 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."));
+#endif
 }