summaryrefslogtreecommitdiffstats
path: root/src/udev/udev-trace.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
commit55944e5e40b1be2afc4855d8d2baf4b73d1876b5 (patch)
tree33f869f55a1b149e9b7c2b7e201867ca5dd52992 /src/udev/udev-trace.h
parentInitial commit. (diff)
downloadsystemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.tar.xz
systemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.zip
Adding upstream version 255.4.upstream/255.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/udev/udev-trace.h')
-rw-r--r--src/udev/udev-trace.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/udev/udev-trace.h b/src/udev/udev-trace.h
new file mode 100644
index 0000000..5e94390
--- /dev/null
+++ b/src/udev/udev-trace.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#if HAVE_SYS_SDT_H
+#define SDT_USE_VARIADIC
+#include <sys/sdt.h>
+
+#include "device-private.h"
+#include "device-util.h"
+#include "errno-util.h"
+
+/* Each trace point can have different number of additional arguments. Note that when the macro is used only
+ * additional arguments are listed in the macro invocation!
+ *
+ * Default arguments for each trace point are as follows:
+ * - arg0 - action
+ * - arg1 - sysname
+ * - arg2 - syspath
+ * - arg3 - subsystem
+ */
+#define DEVICE_TRACE_POINT(name, dev, ...) \
+ do { \
+ PROTECT_ERRNO; \
+ const char *_n = NULL, *_p = NULL, *_s = NULL; \
+ sd_device *_d = (dev); \
+ sd_device_action_t _a = _SD_DEVICE_ACTION_INVALID; \
+ (void) sd_device_get_action(_d, &_a); \
+ (void) sd_device_get_sysname(_d, &_n); \
+ (void) sd_device_get_syspath(_d, &_p); \
+ (void) sd_device_get_subsystem(_d, &_s); \
+ STAP_PROBEV(udev, name, device_action_to_string(_a), _n, _p, _s __VA_OPT__(,) __VA_ARGS__);\
+ } while (false);
+#else
+#define DEVICE_TRACE_POINT(name, dev, ...) ((void) 0)
+#endif