Tests: fix: test_list_triggers_cli fails to list userspace-probe-sdt trigger
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 14 Apr 2023 18:57:06 +0000 (14:57 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 17 Apr 2023 17:50:00 +0000 (13:50 -0400)
The listing of triggers which use an event rule match condition
consisting in a user space probe set on an SDT probe fails since
28f23191d.

The coding style imposes an order of includes. However, the order in
which the probe declarations generated by systemtap vs sdt.h matters.

From SYSTEMTAP(2):
  Sometimes, semaphore variables are not necessary nor helpful. Skipping
  them can simplify the build process, by omitting the extra "test.o"
  file. To skip dependence upon semaphore variables, include "<sys/sdt.h>"
  within the application before "test.h":
  [...]
  In this mode, the ENABLED() test is fixed at 1.

The reformatted version of userspace-probe-sdt-binary.c includes sdt.h
after the probe causing the probes to use a guarding semaphore.

Unfortunately, we can't instrument such probes and the registration of
the trigger silently fails. The silent failure is addressed by a
follow-up commit.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5146f55ed5d9d109f1f7bc32e0f7c2c8bf839f8e

tests/utils/testapp/userspace-probe-sdt-binary/libbar.c
tests/utils/testapp/userspace-probe-sdt-binary/libfoo.c
tests/utils/testapp/userspace-probe-sdt-binary/libzzz.c
tests/utils/testapp/userspace-probe-sdt-binary/sema.c
tests/utils/testapp/userspace-probe-sdt-binary/userspace-probe-sdt-binary.c

index 633fa0561c792a4085a30a4669cd072fa3686258..0a0edfb81a9249ea71b0fe2a51254c28066f1227 100644 (file)
@@ -5,9 +5,16 @@
  *
  */
 
+/*
+ * The order of inclusion is important here: including sdt.h _before_ the probe
+ * declarations ensures that semaphore-protected SDT probes (which we don't support) are not
+ * generated. See SYSTEMTAP(2) for more details.
+ */
+/* clang-format off */
+#include <sys/sdt.h>
 #include "foobar_provider.h"
+/* clang-format on */
 
-#include <sys/sdt.h>
 void bar_function()
 {
        FOOBAR_TP_IN_DLOPEN();
index 78c79fb84e13e8e4580678178ed9a25f52de63e4..283dac24e5387d6e1af90e4cc126ec3f6b7582f1 100644 (file)
@@ -5,9 +5,16 @@
  *
  */
 
+/*
+ * The order of inclusion is important here: including sdt.h _before_ the probe
+ * declarations ensures that semaphore-protected SDT probes (which we don't support) are not
+ * generated. See SYSTEMTAP(2) for more details.
+ */
+/* clang-format off */
+#include <sys/sdt.h>
 #include "foobar_provider.h"
+/* clang-format on */
 
-#include <sys/sdt.h>
 void foo_function()
 {
        FOOBAR_TP_IN_SHARED_OBJECT();
index ee7599f9e68ff27a7008b53859c3768a5b2ceef3..8b3a0b2081e4facef5aa5df988a1ad12bfe87d27 100644 (file)
@@ -5,9 +5,16 @@
  *
  */
 
+/*
+ * The order of inclusion is important here: including sdt.h _before_ the probe
+ * declarations ensures that semaphore-protected SDT probes (which we don't support) are not
+ * generated. See SYSTEMTAP(2) for more details.
+ */
+/* clang-format off */
+#include <sys/sdt.h>
 #include "foobar_provider.h"
+/* clang-format on */
 
-#include <sys/sdt.h>
 void overridable_function()
 {
        FOOBAR_TP_IN_LDPRELOAD();
index ffe2b5c6016a50355ba5de3d2f2df49b5e4a566d..ef8ed2629ddc6bc6fafa5c3fb3f26238593776aa 100644 (file)
@@ -5,9 +5,16 @@
  *
  */
 
+/*
+ * The order of inclusion is important here: including sdt.h _after_ the probe
+ * declarations ensures that semaphore-protected SDT probes are
+ * generated. See SYSTEMTAP(2) for more details.
+ */
+/* clang-format off */
 #include "foobar_provider.h"
-
 #include <sys/sdt.h>
+/* clang-format on */
+
 void sema_function()
 {
        FOOBAR_TP_WITH_SEMAPHORE();
index c9c8036970638788acbce1c4d91f18c0249ad24a..551b42b5a7e33310dd783b6a897de180fa48ea2d 100644 (file)
@@ -9,7 +9,16 @@
 #define _GNU_SOURCE
 #endif
 
+/*
+ * The order of inclusion is important here: including sdt.h _before_ the probe
+ * declarations ensures that semaphore-protected SDT probes (which we don't support) are not
+ * generated. See SYSTEMTAP(2) for more details.
+ */
+/* clang-format off */
+#include <sys/sdt.h>
 #include "foobar_provider.h"
+/* clang-format on */
+
 #include "libfoo.h"
 #include "sema.h"
 
@@ -18,7 +27,6 @@
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
-#include <sys/sdt.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 
This page took 0.027191 seconds and 4 git commands to generate.