tests: test_ust_constructor: Use a C-compiled shared object
authorKienan Stewart <kstewart@efficios.com>
Thu, 8 Feb 2024 14:02:48 +0000 (09:02 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 7 Mar 2024 17:11:52 +0000 (12:11 -0500)
Similar to the previous change, this change splits the c-style
constructors for the shared object into a separate object which can be
compiled with gcc instead of g++.

This makes it possible to test the constructors are traced even if
LTTng-UST uses the LTTNG_UST_ALLOCATE_COMPOUND_LITERAL_ON_HEAP build
configuration.

Change-Id: Icd96cb30cedc1615951a6fec3c72731776f95d81
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/ust/ust-constructor/test_ust_constructor.py
tests/utils/testapp/gen-ust-events-constructor/Makefile.am
tests/utils/testapp/gen-ust-events-constructor/main.cpp
tests/utils/testapp/gen-ust-events-constructor/tp-so.h
tests/utils/testapp/gen-ust-events-constructor/tp-so_c-define.c [new file with mode: 0644]
tests/utils/testapp/gen-ust-events-constructor/tp-so_c-provider.c [new file with mode: 0644]
tests/utils/testapp/gen-ust-events-constructor/tp-so_c.h [new file with mode: 0644]

index f9d97e20b39af30f2b375f31c5282e877e2539b7..8b1fc613faf2dd29c6dfbbe87139ddc79e7a074b 100755 (executable)
@@ -47,7 +47,7 @@ if process.returncode == 0:
     compound_literal_on_heap = True
 
 expected_events = [
-    {"name": "tp_so:constructor_c_provider_shared_library", "msg": None, "count": 0},
+    {"name": "tp_so_c:constructor_c_provider_shared_library", "msg": None, "count": 0},
     {
         "name": "tp_a:constructor_c_provider_static_archive",
         "msg": None,
@@ -264,7 +264,7 @@ expected_events = [
         "count": 0,
         "may_fail": compound_literal_on_heap,
     },
-    {"name": "tp_so:destructor_c_provider_shared_library", "msg": None, "count": 0},
+    {"name": "tp_so_c:destructor_c_provider_shared_library", "msg": None, "count": 0},
 ]
 
 num_tests = 7 + len(expected_events)
index a855b25fe8ad4ab2f1ef6fec2bcb71ac49b942ba..5e9fd90f0aeca714808e38c5877c7f59e46c0291 100644 (file)
@@ -24,6 +24,7 @@ FORCE_SHARED_LIB_OPTIONS = -module -shared -avoid-version \
 endif
 
 noinst_LTLIBRARIES = libtp-so-provider.la libtp-so-define.la \
+                    libtp-so_c-provider.la libtp-so_c-define.la \
                     libtp-a-provider.la libtp-a-define.la \
                     libtp-a_c-provider.la libtp-a_c-define.la
 
@@ -40,6 +41,16 @@ libtp_so_define_la_SOURCES = \
 libtp_so_define_la_LDFLAGS = \
        $(FORCE_SHARED_LIB_OPTIONS)
 
+libtp_so_c_provider_la_SOURCES = \
+       tp-so_c-provider.c \
+       tp-so_c.h
+libtp_so_c_provider_la_LDFLAGS = $(FORCE_SHARED_LIB_OPTIONS)
+
+libtp_so_c_define_la_SOURCES = \
+       tp-so_c-define.c \
+       tp-so_c.h
+libtp_so_c_define_la_LDFLAGS = $(FORCE_SHARED_LIB_OPTIONS)
+
 # static archives
 libtp_a_provider_la_SOURCES = \
        tp-a-provider.cpp \
@@ -72,6 +83,8 @@ gen_ust_events_constructor_SOURCES = main.cpp \
 gen_ust_events_constructor_LDADD = $(UST_LIBS) \
                $(builddir)/libtp-so-define.la \
                $(builddir)/libtp-so-provider.la \
+               $(builddir)/libtp-so_c-define.la \
+               $(builddir)/libtp-so_c-provider.la \
                $(builddir)/libtp-a-define.la \
                $(builddir)/libtp-a-provider.la \
                $(builddir)/libtp-a_c-define.la \
index 9b754f61f8d3757f9f423bdad95ba67abfc5b2c9..8f80fb092437a76c6ffe7e2004d92071f7561fd9 100644 (file)
@@ -7,6 +7,7 @@
 #include "obj.h"
 #include "tp-a.h"
 #include "tp-a_c.h"
+#include "tp-so_c.h"
 #include "tp-so.h"
 #include "tp.h"
 
 void test_constructor_so(void) __attribute__((constructor));
 void test_constructor_so(void)
 {
-       tracepoint(tp_so, constructor_c_provider_shared_library);
+       tracepoint(tp_so_c, constructor_c_provider_shared_library);
 }
 
 void test_destructor_so(void) __attribute__((destructor));
 void test_destructor_so(void)
 {
-       tracepoint(tp_so, destructor_c_provider_shared_library);
+       tracepoint(tp_so_c, destructor_c_provider_shared_library);
 }
 
 Objso g_objso_shared_library("global - shared library define and provider");
index 0bdc3ed2feb2f4b9da66e0dd11a7521c375bb8f8..41faec7d798c6f274c8f756bddae547a6376108c 100644 (file)
 
 #include <stdint.h>
 
-TRACEPOINT_EVENT(tp_so, constructor_c_provider_shared_library, TP_ARGS(), TP_FIELDS())
-
-TRACEPOINT_EVENT(tp_so, destructor_c_provider_shared_library, TP_ARGS(), TP_FIELDS())
-
 TRACEPOINT_EVENT(tp_so,
                 constructor_cplusplus_provider_shared_library,
                 TP_ARGS(const char *, msg),
diff --git a/tests/utils/testapp/gen-ust-events-constructor/tp-so_c-define.c b/tests/utils/testapp/gen-ust-events-constructor/tp-so_c-define.c
new file mode 100644 (file)
index 0000000..e16bce0
--- /dev/null
@@ -0,0 +1,7 @@
+/*
+ * Copyright (C) 2024 Kienan Stewart <kstewart@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ */
+#define TRACEPOINT_DEFINE
+#include "tp-so_c.h"
diff --git a/tests/utils/testapp/gen-ust-events-constructor/tp-so_c-provider.c b/tests/utils/testapp/gen-ust-events-constructor/tp-so_c-provider.c
new file mode 100644 (file)
index 0000000..aae3196
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2024 Kienan Stewart <kstewart@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "tp-so_c.h"
diff --git a/tests/utils/testapp/gen-ust-events-constructor/tp-so_c.h b/tests/utils/testapp/gen-ust-events-constructor/tp-so_c.h
new file mode 100644 (file)
index 0000000..58d77cd
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2024 Kienan Stewart <kstewart@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ */
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER tp_so_c
+
+#if !defined(_TRACEPOINT_TP_SO_C_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_TP_SO_C_H
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(tp_so_c, constructor_c_provider_shared_library, TP_ARGS(), TP_FIELDS())
+
+TRACEPOINT_EVENT(tp_so_c, destructor_c_provider_shared_library, TP_ARGS(), TP_FIELDS())
+
+#endif /* _TRACEPOINT_TP_SO_C_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./tp-so_c.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef _cplusplus
+}
+#endif
This page took 0.028532 seconds and 4 git commands to generate.