doc/man/tracelog.3
doc/man/vtracef.3
-tests/hello/hello
-tests/hello-many/hello-many
-tests/hello.cxx/hello
-tests/same_line_tracepoint/same_line_tracepoint
-tests/snprintf/test_snprintf
-tests/ust-elf/ust-elf
-tests/ust-elf/test_ust_elf
tests/benchmark/bench1
tests/benchmark/bench2
-tests/ctf-types/ctf-types
-tests/test-app-ctx/hello
-tests/gcc-weak-hidden/test_gcc_weak_hidden
-tests/pthread_name/test_pthread_name
+tests/compile/ctf-types/ctf-types
+tests/compile/hello.cxx/hello
+tests/compile/hello/hello
+tests/compile/hello-many/hello-many
+tests/compile/same_line_tracepoint/same_line_tracepoint
+tests/compile/test-app-ctx/hello
+tests/unit/gcc-weak-hidden/test_gcc_weak_hidden
+tests/unit/pthread_name/test_pthread_name
+tests/unit/snprintf/test_snprintf
+tests/unit/ust-elf/test_ust_elf
+tests/unit/ust-elf/ust-elf
# Java agent library
*.class
python-lttngust/lttngust/__init__.py
tools/Makefile
tests/Makefile
- tests/ctf-types/Makefile
- tests/hello/Makefile
- tests/hello-many/Makefile
- tests/hello.cxx/Makefile
- tests/same_line_tracepoint/Makefile
- tests/snprintf/Makefile
- tests/ust-elf/Makefile
+ tests/compile/Makefile
+ tests/compile/ctf-types/Makefile
+ tests/compile/hello.cxx/Makefile
+ tests/compile/hello/Makefile
+ tests/compile/hello-many/Makefile
+ tests/compile/same_line_tracepoint/Makefile
+ tests/compile/test-app-ctx/Makefile
tests/benchmark/Makefile
- tests/pthread_name/Makefile
+ tests/unit/gcc-weak-hidden/Makefile
+ tests/unit/Makefile
+ tests/unit/pthread_name/Makefile
+ tests/unit/snprintf/Makefile
+ tests/unit/ust-elf/Makefile
tests/utils/Makefile
- tests/test-app-ctx/Makefile
- tests/gcc-weak-hidden/Makefile
lttng-ust.pc
lttng-ust-ctl.pc
])
python-lttngust/lttngust/loghandler.py:python-lttngust/lttngust/loghandler.py
])
-AC_CONFIG_FILES([tests/ust-elf/test_ust_elf],[chmod +x tests/ust-elf/test_ust_elf])
+AC_CONFIG_FILES([tests/unit/ust-elf/test_ust_elf],[chmod +x tests/unit/ust-elf/test_ust_elf])
AC_OUTPUT
-SUBDIRS = utils hello same_line_tracepoint snprintf benchmark ust-elf \
- ctf-types test-app-ctx gcc-weak-hidden hello-many pthread_name
-
-if CXX_WORKS
-SUBDIRS += hello.cxx
-endif
+SUBDIRS = utils unit compile benchmark
LOG_DRIVER_FLAGS='--merge'
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/config/tap-driver.sh
-TESTS = snprintf/test_snprintf \
- ust-elf/test_ust_elf \
- gcc-weak-hidden/test_gcc_weak_hidden \
- pthread_name/test_pthread_name
+TESTS = \
+ unit/gcc-weak-hidden/test_gcc_weak_hidden \
+ unit/pthread_name/test_pthread_name \
+ unit/snprintf/test_snprintf \
+ unit/ust-elf/test_ust_elf
EXTRA_DIST = README
--- /dev/null
+SUBDIRS = \
+ ctf-types \
+ hello \
+ hello-many \
+ same_line_tracepoint \
+ test-app-ctx
+
+if CXX_WORKS
+SUBDIRS += hello.cxx
+endif
+
--- /dev/null
+AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
+
+noinst_PROGRAMS = ctf-types
+ctf_types_SOURCES = ctf-types.c tp.c ust_tests_ctf_types.h
+ctf_types_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
+ctf_types_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
+
+EXTRA_DIST = README
--- /dev/null
+This is a "hello world" application used to verify that an instrumented program
+with tracepoints using type declarations in CTF metadata can be built
+successfully.
--- /dev/null
+/*
+ * Copyright (C) 2014 Geneviève Bastien <gbastien@versatic.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <unistd.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_tests_ctf_types.h"
+
+int main(int argc, char **argv)
+{
+ int i;
+ int delay = 0;
+
+ if (argc == 2)
+ delay = atoi(argv[1]);
+
+ fprintf(stderr, "Hello, World!\n");
+
+ sleep(delay);
+
+ fprintf(stderr, "Tracing... ");
+ for (i = 0; i < 100; i++) {
+ tracepoint(ust_tests_ctf_types, tptest, i, i % 6,
+ i % 21);
+ }
+
+ for (i = 0; i < 10; i++) {
+ tracepoint(ust_tests_ctf_types, tptest_bis, i, i % 6);
+ }
+ fprintf(stderr, " done.\n");
+ return 0;
+}
--- /dev/null
+/*
+ * tp.c
+ *
+ * Copyright (c) 2014 Geneviève Bastien <gbastien@versatic.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_ctf_types.h"
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_ctf_types
+
+#if !defined(_TRACEPOINT_UST_TESTS_CTF_TYPES_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_CTF_TYPES_H
+
+/*
+ * Copyright (C) 2014 Geneviève Bastien <gbastien@versatic.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_ENUM(ust_tests_ctf_types, testenum,
+ TP_ENUM_VALUES(
+ ctf_enum_value("even", 0)
+ ctf_enum_value("uneven", 1)
+ ctf_enum_range("twoto4", 2, 4)
+ ctf_enum_value("five\"extra\\test", 5)
+ )
+)
+
+TRACEPOINT_ENUM(ust_tests_ctf_types, testenum2,
+ TP_ENUM_VALUES(
+ ctf_enum_value("zero", 0)
+ ctf_enum_value("five", 5)
+ ctf_enum_range("ten_to_twenty", 10, 20)
+ )
+)
+
+/*
+ * Enumeration field is used twice to make sure the type declaration
+ * is entered only once in the metadata file.
+ */
+TRACEPOINT_EVENT(ust_tests_ctf_types, tptest,
+ TP_ARGS(int, anint, int, enumval, int, enumval2),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_enum(ust_tests_ctf_types, testenum, int, enumfield, enumval)
+ ctf_enum(ust_tests_ctf_types, testenum, long long,
+ enumfield_bis, enumval)
+ ctf_enum(ust_tests_ctf_types, testenum2, unsigned int,
+ enumfield_third, enumval2)
+ )
+)
+
+/*
+ * Another tracepoint using the types to make sure each type is entered
+ * only once in the metadata file.
+ */
+TRACEPOINT_EVENT(ust_tests_ctf_types, tptest_bis,
+ TP_ARGS(int, anint, int, enumval),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_enum(ust_tests_ctf_types, testenum, unsigned char,
+ enumfield, enumval)
+ )
+)
+
+#endif /* _TRACEPOINT_UST_TESTS_CTF_TYPES_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./ust_tests_ctf_types.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
--- /dev/null
+AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
+
+noinst_PROGRAMS = hello-many
+hello_many_SOURCES = hello-many.c tp.c ust_tests_hello_many.h
+hello_many_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
+hello_many_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
+
+EXTRA_DIST = README
--- /dev/null
+This is a "hello world" application used to verify that an instrumented
+program which contains more than 30 tracepoints can be built successfully.
--- /dev/null
+/*
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_tests_hello_many.h"
+
+int main(int argc, char **argv)
+{
+ int delay = 0;
+
+ if (argc == 2)
+ delay = atoi(argv[1]);
+
+ fprintf(stderr, "Hello, World!\n");
+
+ sleep(delay);
+
+ fprintf(stderr, "Tracing... ");
+ tracepoint(ust_tests_hello_many, tptest_simple1);
+ tracepoint(ust_tests_hello_many, tptest_simple34);
+ fprintf(stderr, " done.\n");
+ return 0;
+}
--- /dev/null
+/*
+ * tp.c
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_hello_many.h"
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_hello_many
+
+#if !defined(_TRACEPOINT_UST_TESTS_HELLO_MANY_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_HELLO_MANY_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <lttng/tracepoint.h>
+#include <stdbool.h>
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple1,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple2,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple3,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple4,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple5,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple6,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple7,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple8,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple9,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple10,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple11,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple12,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple13,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple14,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple15,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple16,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple17,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple18,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple19,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple20,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple21,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple22,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple23,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple24,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple25,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple26,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple27,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple28,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple29,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple30,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple31,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple32,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple33,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple34,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple35,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple36,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple37,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple38,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple39,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple40,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+#endif /* _TRACEPOINT_UST_TESTS_HELLO_MANY_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./ust_tests_hello_many.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
--- /dev/null
+AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
+
+noinst_PROGRAMS = hello
+hello_SOURCES = hello.cpp tp-cpp.cpp ust_tests_hello.h
+hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
+
+EXTRA_DIST = README
--- /dev/null
+This is a "hello world" application used to verify that an instrumented
+program written in C++ can be built successfully.
+
+Only enabled if a C++ build environment is detected during configure.
--- /dev/null
+/*
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_tests_hello.h"
+
+void inthandler(int sig)
+{
+ printf("in SIGUSR1 handler\n");
+ tracepoint(ust_tests_hello, tptest_sighandler);
+}
+
+int init_int_handler(void)
+{
+ int result;
+ struct sigaction act;
+
+ memset(&act, 0, sizeof(act));
+ result = sigemptyset(&act.sa_mask);
+ if (result == -1) {
+ perror("sigemptyset");
+ return -1;
+ }
+
+ act.sa_handler = inthandler;
+ act.sa_flags = SA_RESTART;
+
+ /* Only defer ourselves. Also, try to restart interrupted
+ * syscalls to disturb the traced program as little as possible.
+ */
+ result = sigaction(SIGUSR1, &act, NULL);
+ if (result == -1) {
+ perror("sigaction");
+ return -1;
+ }
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int i, netint;
+ long values[] = { 1, 2, 3 };
+ char text[10] = "test";
+ double dbl = 2.0;
+ float flt = 2222.0;
+ int delay = 0;
+
+ init_int_handler();
+
+ if (argc == 2)
+ delay = atoi(argv[1]);
+
+ fprintf(stderr, "Hello, World!\n");
+
+ sleep(delay);
+
+ fprintf(stderr, "Tracing... ");
+ for (i = 0; i < 1000000; i++) {
+ netint = htonl(i);
+ tracepoint(ust_tests_hello, tptest, i, netint, values,
+ text, strlen(text), dbl, flt, 15);
+ //usleep(100000);
+ }
+ fprintf(stderr, " done.\n");
+ return 0;
+}
--- /dev/null
+/*
+ * tp.cpp
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_hello.h"
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_hello
+
+#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_HELLO_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <lttng/tracepoint.h>
+#include <stddef.h>
+
+TRACEPOINT_ENUM(ust_tests_hello, my_enum,
+ TP_ENUM_VALUES(
+ ctf_enum_value("zero", 0)
+ ctf_enum_value("one", 1)
+ ctf_enum_auto("two")
+ ctf_enum_value("three", 3)
+ ctf_enum_range("ten to twenty", 10, 20)
+ ctf_enum_auto("21!")
+ )
+)
+
+TRACEPOINT_EVENT(ust_tests_hello, tptest,
+ TP_ARGS(int, anint, int, netint, long *, values,
+ char *, text, size_t, textlen,
+ double, doublearg, float, floatarg,
+ int, enumarg),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer_hex(int, intfield2, anint)
+ ctf_integer(long, longfield, anint)
+ ctf_integer_network(int, netintfield, netint)
+ ctf_integer_network_hex(int, netintfieldhex, netint)
+ ctf_array(long, arrfield1, values, 3)
+ ctf_array_text(char, arrfield2, text, 10)
+ ctf_sequence(char, seqfield1, text,
+ size_t, textlen)
+ ctf_sequence_text(char, seqfield2, text,
+ size_t, textlen)
+ ctf_string(stringfield, text)
+ ctf_float(float, floatfield, floatarg)
+ ctf_float(double, doublefield, doublearg)
+ ctf_enum(ust_tests_hello, my_enum, int, enumfield, enumarg)
+ )
+)
+
+TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./ust_tests_hello.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
--- /dev/null
+AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
+
+noinst_PROGRAMS = hello
+hello_SOURCES = hello.c tp.c ust_tests_hello.h
+hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
+hello_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
+
+EXTRA_DIST = README
--- /dev/null
+# Example makefile for build outside of the LTTng-UST tree.
+
+hello:
+ ${CC} -O2 -I. -o hello -lc -llttng-ust hello.c tp.c
+
+.PHONY: clean
+clean:
+ rm -f hello
--- /dev/null
+# Example makefile for build outside of the LTTng-UST tree.
+
+hello:
+ ${CC} -O2 -I. -o hello -ldl -llttng-ust hello.c tp.c
+
+.PHONY: clean
+clean:
+ rm -f hello
--- /dev/null
+This is a "hello world" application used to verify that an instrumented
+program can be built successfully.
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <string.h>
+/*
+ * Work-around inet.h missing struct mmsghdr forward declaration, with
+ * triggers a warning when system files warnings are enabled.
+ */
+struct mmsghdr;
+#include <arpa/inet.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_tests_hello.h"
+
+void inthandler(int sig)
+{
+ printf("in SIGUSR1 handler\n");
+ tracepoint(ust_tests_hello, tptest_sighandler);
+}
+
+int init_int_handler(void)
+{
+ int result;
+ struct sigaction act;
+
+ memset(&act, 0, sizeof(act));
+ result = sigemptyset(&act.sa_mask);
+ if (result == -1) {
+ perror("sigemptyset");
+ return -1;
+ }
+
+ act.sa_handler = inthandler;
+ act.sa_flags = SA_RESTART;
+
+ /* Only defer ourselves. Also, try to restart interrupted
+ * syscalls to disturb the traced program as little as possible.
+ */
+ result = sigaction(SIGUSR1, &act, NULL);
+ if (result == -1) {
+ perror("sigaction");
+ return -1;
+ }
+
+ return 0;
+}
+
+void test_inc_count(void);
+
+int main(int argc, char **argv)
+{
+ int i, netint;
+ long values[] = { 1, 2, 3 };
+ char text[10] = "test";
+ double dbl = 2.0;
+ float flt = 2222.0;
+ int delay = 0;
+ bool mybool = 123; /* should print "1" */
+
+ init_int_handler();
+
+ if (argc == 2)
+ delay = atoi(argv[1]);
+
+ fprintf(stderr, "Hello, World!\n");
+
+ sleep(delay);
+
+ fprintf(stderr, "Tracing... ");
+ for (i = 0; i < 1000000; i++) {
+ netint = htonl(i);
+ tracepoint(ust_tests_hello, tptest, i, netint, values,
+ text, strlen(text), dbl, flt, mybool);
+ //usleep(100000);
+ }
+ fprintf(stderr, " done.\n");
+ return 0;
+}
--- /dev/null
+/*
+ * tp.c
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_hello.h"
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_hello
+
+#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_HELLO_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <lttng/tracepoint.h>
+#include <stdbool.h>
+#include <stddef.h>
+
+TRACEPOINT_EVENT(ust_tests_hello, tptest,
+ TP_ARGS(int, anint, int, netint, long *, values,
+ char *, text, size_t, textlen,
+ double, doublearg, float, floatarg,
+ bool, boolarg),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer_hex(int, intfield2, anint)
+ ctf_integer(long, longfield, anint)
+ ctf_integer_network(int, netintfield, netint)
+ ctf_integer_network_hex(int, netintfieldhex, netint)
+ ctf_array_nowrite(long, arrfield1z, values, 3)
+ ctf_array(long, blah, values, 3)
+ ctf_array(long, arrfield1, values, 3)
+ ctf_array_hex(long, arrfield1_hex, values, 3)
+ ctf_array_network(long, arrfield1_network, values, 3)
+ ctf_array_network_hex(long, arrfield1_network_hex, values, 3)
+ ctf_array_text(char, arrfield2, text, 10)
+ ctf_sequence(char, seqfield1, text,
+ size_t, textlen)
+ ctf_sequence_nowrite(char, seqfield1z, text,
+ size_t, textlen)
+ ctf_sequence_hex(char, seqfield1_hex, text,
+ size_t, textlen)
+ ctf_sequence_text(char, seqfield2, text,
+ size_t, textlen)
+ ctf_sequence_network(long, seqfield_network_3, values,
+ size_t, 3)
+ ctf_string(stringfield, text)
+ ctf_float(float, floatfield, floatarg)
+ ctf_float(double, doublefield, doublearg)
+ ctf_integer(bool, boolfield, boolarg)
+ ctf_integer_nowrite(int, filterfield, anint)
+ )
+)
+
+TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./ust_tests_hello.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
--- /dev/null
+AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
+
+noinst_PROGRAMS = same_line_tracepoint
+same_line_tracepoint_SOURCES = same_line_tracepoint.c ust_tests_sameline.h
+same_line_tracepoint_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
+
+EXTRA_DIST = README
--- /dev/null
+Same line tracepoint test
+-------------------------
+
+This is a build test that verifies multiple tracepoint can be placed on a single
+line.
--- /dev/null
+/* Copyright (C) 2013 Jérémie Galarneau
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define TRACEPOINT_DEFINE
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_sameline.h"
+
+int main()
+{
+ tracepoint(ust_tests_sameline, event1); tracepoint(ust_tests_sameline, event2);
+ return 0;
+}
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_sameline
+
+#if !defined(_TRACEPOINT_UST_TESTS_SAMELINE_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_SAMELINE_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(ust_tests_sameline, event1,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+TRACEPOINT_LOGLEVEL(ust_tests_sameline, event1, TRACE_CRIT)
+
+TRACEPOINT_EVENT(ust_tests_sameline, event2,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+TRACEPOINT_LOGLEVEL(ust_tests_sameline, event2, TRACE_CRIT)
+
+#endif /* _TRACEPOINT_UST_TESTS_SAMELINE_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./ust_tests_sameline.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
--- /dev/null
+AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
+
+noinst_PROGRAMS = hello
+hello_SOURCES = hello.c tp.c ust_tests_hello.h
+hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
+hello_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
--- /dev/null
+/*
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <fcntl.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+/*
+ * Work-around inet.h missing struct mmsghdr forward declaration, with
+ * triggers a warning when system files warnings are enabled.
+ */
+struct mmsghdr;
+#include <arpa/inet.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_tests_hello.h"
+
+/* Internal header. */
+#include <lttng/ust-events.h>
+#include <lttng/ringbuffer-config.h>
+#include <lttng/ust-context-provider.h>
+
+static __thread unsigned int test_count;
+
+void test_inc_count(void)
+{
+ test_count++;
+}
+
+static
+size_t test_get_size(struct lttng_ctx_field *field, size_t offset)
+{
+ int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES;
+ size_t size = 0;
+
+ size += lib_ring_buffer_align(offset, lttng_alignof(char));
+ size += sizeof(char); /* tag */
+ switch (sel) {
+ case LTTNG_UST_DYNAMIC_TYPE_NONE:
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_S8:
+ size += lib_ring_buffer_align(offset, lttng_alignof(int8_t));
+ size += sizeof(int8_t); /* variant */
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_S16:
+ size += lib_ring_buffer_align(offset, lttng_alignof(int16_t));
+ size += sizeof(int16_t); /* variant */
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_S32:
+ size += lib_ring_buffer_align(offset, lttng_alignof(int32_t));
+ size += sizeof(int32_t); /* variant */
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_S64:
+ size += lib_ring_buffer_align(offset, lttng_alignof(int64_t));
+ size += sizeof(int64_t); /* variant */
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_U8:
+ size += lib_ring_buffer_align(offset, lttng_alignof(uint8_t));
+ size += sizeof(uint8_t); /* variant */
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_U16:
+ size += lib_ring_buffer_align(offset, lttng_alignof(uint16_t));
+ size += sizeof(uint16_t); /* variant */
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_U32:
+ size += lib_ring_buffer_align(offset, lttng_alignof(uint32_t));
+ size += sizeof(uint32_t); /* variant */
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_U64:
+ size += lib_ring_buffer_align(offset, lttng_alignof(uint64_t));
+ size += sizeof(uint64_t); /* variant */
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_FLOAT:
+ size += lib_ring_buffer_align(offset, lttng_alignof(float));
+ size += sizeof(float); /* variant */
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_DOUBLE:
+ size += lib_ring_buffer_align(offset, lttng_alignof(double));
+ size += sizeof(double); /* variant */
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_STRING:
+ size += strlen("teststr") + 1;
+ break;
+ default:
+ abort();
+ }
+
+ return size;
+}
+
+static
+void test_record(struct lttng_ctx_field *field,
+ struct lttng_ust_lib_ring_buffer_ctx *ctx,
+ struct lttng_channel *chan)
+{
+ int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES;
+ char sel_char = (char) sel;
+
+ lib_ring_buffer_align_ctx(ctx, lttng_alignof(char));
+ chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
+ switch (sel) {
+ case LTTNG_UST_DYNAMIC_TYPE_NONE:
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_S8:
+ {
+ int8_t v = -8;
+
+ lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+ chan->ops->event_write(ctx, &v, sizeof(v));
+ break;
+ }
+ case LTTNG_UST_DYNAMIC_TYPE_S16:
+ {
+ int16_t v = -16;
+
+ lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+ chan->ops->event_write(ctx, &v, sizeof(v));
+ break;
+ }
+ case LTTNG_UST_DYNAMIC_TYPE_S32:
+ {
+ int32_t v = -32;
+
+ lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+ chan->ops->event_write(ctx, &v, sizeof(v));
+ break;
+ }
+ case LTTNG_UST_DYNAMIC_TYPE_S64:
+ {
+ int64_t v = -64;
+
+ lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+ chan->ops->event_write(ctx, &v, sizeof(v));
+ break;
+ }
+ case LTTNG_UST_DYNAMIC_TYPE_U8:
+ {
+ uint8_t v = 8;
+
+ lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+ chan->ops->event_write(ctx, &v, sizeof(v));
+ break;
+ }
+ case LTTNG_UST_DYNAMIC_TYPE_U16:
+ {
+ uint16_t v = 16;
+
+ lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+ chan->ops->event_write(ctx, &v, sizeof(v));
+ break;
+ }
+ case LTTNG_UST_DYNAMIC_TYPE_U32:
+ {
+ uint32_t v = 32;
+
+ lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+ chan->ops->event_write(ctx, &v, sizeof(v));
+ break;
+ }
+ case LTTNG_UST_DYNAMIC_TYPE_U64:
+ {
+ uint64_t v = 64;
+
+ lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+ chan->ops->event_write(ctx, &v, sizeof(v));
+ break;
+ }
+ case LTTNG_UST_DYNAMIC_TYPE_FLOAT:
+ {
+ float f = 22322.0;
+
+ lib_ring_buffer_align_ctx(ctx, lttng_alignof(f));
+ chan->ops->event_write(ctx, &f, sizeof(f));
+ break;
+ }
+ case LTTNG_UST_DYNAMIC_TYPE_DOUBLE:
+ {
+ double d = 2.0;
+
+ lib_ring_buffer_align_ctx(ctx, lttng_alignof(d));
+ chan->ops->event_write(ctx, &d, sizeof(d));
+ break;
+ }
+ case LTTNG_UST_DYNAMIC_TYPE_STRING:
+ {
+ const char *str = "teststr";
+ chan->ops->event_write(ctx, str, strlen(str) + 1);
+ break;
+ }
+ default:
+ abort();
+ }
+}
+
+static
+void test_get_value(struct lttng_ctx_field *field,
+ struct lttng_ctx_value *value)
+{
+ int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES;
+
+ value->sel = sel;
+ switch (sel) {
+ case LTTNG_UST_DYNAMIC_TYPE_NONE:
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_S8:
+ value->u.s64 = -8;
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_S16:
+ value->u.s64 = -16;
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_S32:
+ value->u.s64 = -32;
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_S64:
+ value->u.s64 = -64;
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_U8:
+ value->u.s64 = 8;
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_U16:
+ value->u.s64 = 16;
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_U32:
+ value->u.s64 = 32;
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_U64:
+ value->u.s64 = 64;
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_FLOAT:
+ value->u.d = 22322.0;
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_DOUBLE:
+ value->u.d = 2.0;
+ break;
+ case LTTNG_UST_DYNAMIC_TYPE_STRING:
+ value->u.str = "teststr";
+ break;
+ default:
+ abort();
+ }
+}
+
+struct lttng_ust_context_provider myprovider = {
+ .name = "$app.myprovider",
+ .get_size = test_get_size,
+ .record = test_record,
+ .get_value = test_get_value,
+};
+
+void inthandler(int sig)
+{
+ printf("in SIGUSR1 handler\n");
+ tracepoint(ust_tests_hello, tptest_sighandler);
+}
+
+int init_int_handler(void)
+{
+ int result;
+ struct sigaction act;
+
+ memset(&act, 0, sizeof(act));
+ result = sigemptyset(&act.sa_mask);
+ if (result == -1) {
+ perror("sigemptyset");
+ return -1;
+ }
+
+ act.sa_handler = inthandler;
+ act.sa_flags = SA_RESTART;
+
+ /* Only defer ourselves. Also, try to restart interrupted
+ * syscalls to disturb the traced program as little as possible.
+ */
+ result = sigaction(SIGUSR1, &act, NULL);
+ if (result == -1) {
+ perror("sigaction");
+ return -1;
+ }
+
+ return 0;
+}
+
+void test_inc_count(void);
+
+int main(int argc, char **argv)
+{
+ int i, netint;
+ long values[] = { 1, 2, 3 };
+ char text[10] = "test";
+ double dbl = 2.0;
+ float flt = 2222.0;
+ int delay = 0;
+ bool mybool = 123; /* should print "1" */
+
+ init_int_handler();
+
+ if (argc == 2)
+ delay = atoi(argv[1]);
+
+ if (lttng_ust_context_provider_register(&myprovider))
+ abort();
+
+ fprintf(stderr, "Hello, World!\n");
+
+ sleep(delay);
+
+ fprintf(stderr, "Tracing... ");
+ for (i = 0; i < 1000000; i++) {
+ netint = htonl(i);
+ tracepoint(ust_tests_hello, tptest, i, netint, values,
+ text, strlen(text), dbl, flt, mybool);
+ test_inc_count();
+ //usleep(100000);
+ }
+ lttng_ust_context_provider_unregister(&myprovider);
+ fprintf(stderr, " done.\n");
+ return 0;
+}
--- /dev/null
+/*
+ * tp.c
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_hello.h"
--- /dev/null
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_hello
+
+#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_HELLO_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <lttng/tracepoint.h>
+#include <stddef.h>
+#include <stdbool.h>
+
+TRACEPOINT_EVENT(ust_tests_hello, tptest,
+ TP_ARGS(int, anint, int, netint, long *, values,
+ char *, text, size_t, textlen,
+ double, doublearg, float, floatarg,
+ bool, boolarg),
+ TP_FIELDS(
+ ctf_integer(int, intfield, anint)
+ ctf_integer_hex(int, intfield2, anint)
+ ctf_integer(long, longfield, anint)
+ ctf_integer_network(int, netintfield, netint)
+ ctf_integer_network_hex(int, netintfieldhex, netint)
+ ctf_array(long, arrfield1, values, 3)
+ ctf_array_text(char, arrfield2, text, 10)
+ ctf_sequence(char, seqfield1, text,
+ size_t, textlen)
+ ctf_sequence_text(char, seqfield2, text,
+ size_t, textlen)
+ ctf_string(stringfield, text)
+ ctf_float(float, floatfield, floatarg)
+ ctf_float(double, doublefield, doublearg)
+ ctf_integer(bool, boolfield, boolarg)
+ ctf_integer_nowrite(int, filterfield, anint)
+ )
+)
+
+TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler,
+ TP_ARGS(),
+ TP_FIELDS()
+)
+
+#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./ust_tests_hello.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+++ /dev/null
-AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
-
-noinst_PROGRAMS = ctf-types
-ctf_types_SOURCES = ctf-types.c tp.c ust_tests_ctf_types.h
-ctf_types_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
-ctf_types_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
-
-EXTRA_DIST = README
+++ /dev/null
-This is a "hello world" application used to verify that an instrumented program
-with tracepoints using type declarations in CTF metadata can be built
-successfully.
+++ /dev/null
-/*
- * Copyright (C) 2014 Geneviève Bastien <gbastien@versatic.net>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; version 2.1 of
- * the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <unistd.h>
-
-#define TRACEPOINT_DEFINE
-#include "ust_tests_ctf_types.h"
-
-int main(int argc, char **argv)
-{
- int i;
- int delay = 0;
-
- if (argc == 2)
- delay = atoi(argv[1]);
-
- fprintf(stderr, "Hello, World!\n");
-
- sleep(delay);
-
- fprintf(stderr, "Tracing... ");
- for (i = 0; i < 100; i++) {
- tracepoint(ust_tests_ctf_types, tptest, i, i % 6,
- i % 21);
- }
-
- for (i = 0; i < 10; i++) {
- tracepoint(ust_tests_ctf_types, tptest_bis, i, i % 6);
- }
- fprintf(stderr, " done.\n");
- return 0;
-}
+++ /dev/null
-/*
- * tp.c
- *
- * Copyright (c) 2014 Geneviève Bastien <gbastien@versatic.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_ctf_types.h"
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER ust_tests_ctf_types
-
-#if !defined(_TRACEPOINT_UST_TESTS_CTF_TYPES_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_TESTS_CTF_TYPES_H
-
-/*
- * Copyright (C) 2014 Geneviève Bastien <gbastien@versatic.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_ENUM(ust_tests_ctf_types, testenum,
- TP_ENUM_VALUES(
- ctf_enum_value("even", 0)
- ctf_enum_value("uneven", 1)
- ctf_enum_range("twoto4", 2, 4)
- ctf_enum_value("five\"extra\\test", 5)
- )
-)
-
-TRACEPOINT_ENUM(ust_tests_ctf_types, testenum2,
- TP_ENUM_VALUES(
- ctf_enum_value("zero", 0)
- ctf_enum_value("five", 5)
- ctf_enum_range("ten_to_twenty", 10, 20)
- )
-)
-
-/*
- * Enumeration field is used twice to make sure the type declaration
- * is entered only once in the metadata file.
- */
-TRACEPOINT_EVENT(ust_tests_ctf_types, tptest,
- TP_ARGS(int, anint, int, enumval, int, enumval2),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_enum(ust_tests_ctf_types, testenum, int, enumfield, enumval)
- ctf_enum(ust_tests_ctf_types, testenum, long long,
- enumfield_bis, enumval)
- ctf_enum(ust_tests_ctf_types, testenum2, unsigned int,
- enumfield_third, enumval2)
- )
-)
-
-/*
- * Another tracepoint using the types to make sure each type is entered
- * only once in the metadata file.
- */
-TRACEPOINT_EVENT(ust_tests_ctf_types, tptest_bis,
- TP_ARGS(int, anint, int, enumval),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_enum(ust_tests_ctf_types, testenum, unsigned char,
- enumfield, enumval)
- )
-)
-
-#endif /* _TRACEPOINT_UST_TESTS_CTF_TYPES_H */
-
-#undef TRACEPOINT_INCLUDE
-#define TRACEPOINT_INCLUDE "./ust_tests_ctf_types.h"
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
+++ /dev/null
-AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
-
-noinst_LTLIBRARIES = libgcc-wh.la
-libgcc_wh_la_SOURCES = c.c d.c
-
-noinst_PROGRAMS = test_gcc_weak_hidden
-test_gcc_weak_hidden_SOURCES = main.c b.c
-test_gcc_weak_hidden_LDADD = $(top_builddir)/tests/utils/libtap.a \
- $(builddir)/libgcc-wh.la
+++ /dev/null
-int testint __attribute__((weak, visibility("hidden")));
-void *testptr __attribute__((weak, visibility("hidden")));
-struct {
- char a[24];
-} testsym_24_bytes __attribute__((weak, visibility("hidden")));
-
-void *testfct_int(void)
-{
- return &testint;
-}
-
-void *testfct_ptr(void)
-{
- return &testptr;
-}
-
-void *testfct_24_bytes(void)
-{
- return &testsym_24_bytes;
-}
+++ /dev/null
-int testint __attribute__((weak, visibility("hidden")));
-void *testptr __attribute__((weak, visibility("hidden")));
-struct {
- char a[24];
-} testsym_24_bytes __attribute__((weak, visibility("hidden")));
-
-void *testlibfct1_int(void)
-{
- return &testint;
-}
-
-void *testlibfct1_ptr(void)
-{
- return &testptr;
-}
-
-void *testlibfct1_24_bytes(void)
-{
- return &testsym_24_bytes;
-}
+++ /dev/null
-int testint __attribute__((weak, visibility("hidden")));
-void *testptr __attribute__((weak, visibility("hidden")));
-struct {
- char a[24];
-} testsym_24_bytes __attribute__((weak, visibility("hidden")));
-
-void *testlibfct2_int(void)
-{
- return &testint;
-}
-
-void *testlibfct2_ptr(void)
-{
- return &testptr;
-}
-
-void *testlibfct2_24_bytes(void)
-{
- return &testsym_24_bytes;
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program for any
- * purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is
- * granted, provided the above notices are retained, and a notice that
- * the code was modified is included with the above copyright notice.
- */
-
-#include <stdbool.h>
-#include "tap.h"
-
-#define NUM_TESTS 2
-
-int testint __attribute__((weak, visibility("hidden")));
-void *testptr __attribute__((weak, visibility("hidden")));
-struct {
- char a[24];
-} testsym_24_bytes __attribute__((weak, visibility("hidden")));
-
-void *testfct_int(void);
-void *testfct_ptr(void);
-void *testfct_24_bytes(void);
-
-void *testlibfct1_int(void);
-void *testlibfct1_ptr(void);
-void *testlibfct1_24_bytes(void);
-
-void *testlibfct2_int(void);
-void *testlibfct2_ptr(void);
-void *testlibfct2_24_bytes(void);
-
-enum {
- MATCH_PROGRAM_INT,
- MATCH_PROGRAM_PTR,
- MATCH_PROGRAM_24_BYTES,
- MATCH_LIB_INT,
- MATCH_LIB_PTR,
- MATCH_LIB_24_BYTES,
- NR_MATCH,
-};
-
-static bool match_matrix[NR_MATCH];
-
-int main()
-{
- plan_tests(NUM_TESTS);
-
- if (testfct_int() == &testint)
- match_matrix[MATCH_PROGRAM_INT] = true;
- if (testfct_ptr() == &testptr)
- match_matrix[MATCH_PROGRAM_PTR] = true;
- if (testfct_24_bytes() == &testsym_24_bytes)
- match_matrix[MATCH_PROGRAM_24_BYTES] = true;
-
- if (testlibfct1_int() == testlibfct2_int())
- match_matrix[MATCH_LIB_INT] = true;
- if (testlibfct1_ptr() == testlibfct2_ptr())
- match_matrix[MATCH_LIB_PTR] = true;
- if (testlibfct1_24_bytes() == testlibfct2_24_bytes())
- match_matrix[MATCH_LIB_24_BYTES] = true;
-
- diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (4 bytes integer object)",
- match_matrix[MATCH_PROGRAM_INT] ? "match" : "MISMATCH");
- diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (pointer object)",
- match_matrix[MATCH_PROGRAM_PTR] ? "match" : "MISMATCH");
- diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (24 bytes structure object)",
- match_matrix[MATCH_PROGRAM_24_BYTES] ? "match" : "MISMATCH");
-
- diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (4 bytes integer object)",
- match_matrix[MATCH_LIB_INT] ? "match" : "MISMATCH");
- diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (pointer object)",
- match_matrix[MATCH_LIB_PTR] ? "match" : "MISMATCH");
- diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (24 bytes structure object)",
- match_matrix[MATCH_LIB_24_BYTES] ? "match" : "MISMATCH");
-
- ok(match_matrix[MATCH_PROGRAM_INT] == match_matrix[MATCH_PROGRAM_PTR],
- "Weak-hidden behavior is the same for 4 bytes integer and pointer objects within main program");
- ok(match_matrix[MATCH_LIB_INT] == match_matrix[MATCH_LIB_PTR],
- "Weak-hidden behavior is the same for 4 bytes integer and pointer objects within shared library");
-
- return exit_status();
-}
+++ /dev/null
-AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
-
-noinst_PROGRAMS = hello-many
-hello_many_SOURCES = hello-many.c tp.c ust_tests_hello_many.h
-hello_many_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
-hello_many_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
-
-EXTRA_DIST = README
+++ /dev/null
-This is a "hello world" application used to verify that an instrumented
-program which contains more than 30 tracepoints can be built successfully.
+++ /dev/null
-/*
- * Copyright (C) 2009 Pierre-Marc Fournier
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; version 2.1 of
- * the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define TRACEPOINT_DEFINE
-#include "ust_tests_hello_many.h"
-
-int main(int argc, char **argv)
-{
- int delay = 0;
-
- if (argc == 2)
- delay = atoi(argv[1]);
-
- fprintf(stderr, "Hello, World!\n");
-
- sleep(delay);
-
- fprintf(stderr, "Tracing... ");
- tracepoint(ust_tests_hello_many, tptest_simple1);
- tracepoint(ust_tests_hello_many, tptest_simple34);
- fprintf(stderr, " done.\n");
- return 0;
-}
+++ /dev/null
-/*
- * tp.c
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_hello_many.h"
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER ust_tests_hello_many
-
-#if !defined(_TRACEPOINT_UST_TESTS_HELLO_MANY_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_TESTS_HELLO_MANY_H
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <lttng/tracepoint.h>
-#include <stdbool.h>
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple1,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple2,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple3,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple4,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple5,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple6,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple7,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple8,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple9,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple10,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple11,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple12,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple13,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple14,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple15,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple16,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple17,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple18,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple19,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple20,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple21,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple22,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple23,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple24,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple25,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple26,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple27,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple28,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple29,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple30,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple31,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple32,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple33,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple34,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple35,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple36,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple37,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple38,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple39,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple40,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-#endif /* _TRACEPOINT_UST_TESTS_HELLO_MANY_H */
-
-#undef TRACEPOINT_INCLUDE
-#define TRACEPOINT_INCLUDE "./ust_tests_hello_many.h"
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
+++ /dev/null
-AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
-
-noinst_PROGRAMS = hello
-hello_SOURCES = hello.cpp tp-cpp.cpp ust_tests_hello.h
-hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
-
-EXTRA_DIST = README
+++ /dev/null
-This is a "hello world" application used to verify that an instrumented
-program written in C++ can be built successfully.
-
-Only enabled if a C++ build environment is detected during configure.
+++ /dev/null
-/*
- * Copyright (C) 2009 Pierre-Marc Fournier
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; version 2.1 of
- * the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-
-#define TRACEPOINT_DEFINE
-#include "ust_tests_hello.h"
-
-void inthandler(int sig)
-{
- printf("in SIGUSR1 handler\n");
- tracepoint(ust_tests_hello, tptest_sighandler);
-}
-
-int init_int_handler(void)
-{
- int result;
- struct sigaction act;
-
- memset(&act, 0, sizeof(act));
- result = sigemptyset(&act.sa_mask);
- if (result == -1) {
- perror("sigemptyset");
- return -1;
- }
-
- act.sa_handler = inthandler;
- act.sa_flags = SA_RESTART;
-
- /* Only defer ourselves. Also, try to restart interrupted
- * syscalls to disturb the traced program as little as possible.
- */
- result = sigaction(SIGUSR1, &act, NULL);
- if (result == -1) {
- perror("sigaction");
- return -1;
- }
-
- return 0;
-}
-
-int main(int argc, char **argv)
-{
- int i, netint;
- long values[] = { 1, 2, 3 };
- char text[10] = "test";
- double dbl = 2.0;
- float flt = 2222.0;
- int delay = 0;
-
- init_int_handler();
-
- if (argc == 2)
- delay = atoi(argv[1]);
-
- fprintf(stderr, "Hello, World!\n");
-
- sleep(delay);
-
- fprintf(stderr, "Tracing... ");
- for (i = 0; i < 1000000; i++) {
- netint = htonl(i);
- tracepoint(ust_tests_hello, tptest, i, netint, values,
- text, strlen(text), dbl, flt, 15);
- //usleep(100000);
- }
- fprintf(stderr, " done.\n");
- return 0;
-}
+++ /dev/null
-/*
- * tp.cpp
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_hello.h"
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER ust_tests_hello
-
-#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_TESTS_HELLO_H
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <lttng/tracepoint.h>
-#include <stddef.h>
-
-TRACEPOINT_ENUM(ust_tests_hello, my_enum,
- TP_ENUM_VALUES(
- ctf_enum_value("zero", 0)
- ctf_enum_value("one", 1)
- ctf_enum_auto("two")
- ctf_enum_value("three", 3)
- ctf_enum_range("ten to twenty", 10, 20)
- ctf_enum_auto("21!")
- )
-)
-
-TRACEPOINT_EVENT(ust_tests_hello, tptest,
- TP_ARGS(int, anint, int, netint, long *, values,
- char *, text, size_t, textlen,
- double, doublearg, float, floatarg,
- int, enumarg),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer_hex(int, intfield2, anint)
- ctf_integer(long, longfield, anint)
- ctf_integer_network(int, netintfield, netint)
- ctf_integer_network_hex(int, netintfieldhex, netint)
- ctf_array(long, arrfield1, values, 3)
- ctf_array_text(char, arrfield2, text, 10)
- ctf_sequence(char, seqfield1, text,
- size_t, textlen)
- ctf_sequence_text(char, seqfield2, text,
- size_t, textlen)
- ctf_string(stringfield, text)
- ctf_float(float, floatfield, floatarg)
- ctf_float(double, doublefield, doublearg)
- ctf_enum(ust_tests_hello, my_enum, int, enumfield, enumarg)
- )
-)
-
-TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */
-
-#undef TRACEPOINT_INCLUDE
-#define TRACEPOINT_INCLUDE "./ust_tests_hello.h"
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
+++ /dev/null
-AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
-
-noinst_PROGRAMS = hello
-hello_SOURCES = hello.c tp.c ust_tests_hello.h
-hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
-hello_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
-
-EXTRA_DIST = README
+++ /dev/null
-# Example makefile for build outside of the LTTng-UST tree.
-
-hello:
- ${CC} -O2 -I. -o hello -lc -llttng-ust hello.c tp.c
-
-.PHONY: clean
-clean:
- rm -f hello
+++ /dev/null
-# Example makefile for build outside of the LTTng-UST tree.
-
-hello:
- ${CC} -O2 -I. -o hello -ldl -llttng-ust hello.c tp.c
-
-.PHONY: clean
-clean:
- rm -f hello
+++ /dev/null
-This is a "hello world" application used to verify that an instrumented
-program can be built successfully.
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2009 Pierre-Marc Fournier
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; version 2.1 of
- * the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <string.h>
-/*
- * Work-around inet.h missing struct mmsghdr forward declaration, with
- * triggers a warning when system files warnings are enabled.
- */
-struct mmsghdr;
-#include <arpa/inet.h>
-#include <stdlib.h>
-#include <stdbool.h>
-
-#define TRACEPOINT_DEFINE
-#include "ust_tests_hello.h"
-
-void inthandler(int sig)
-{
- printf("in SIGUSR1 handler\n");
- tracepoint(ust_tests_hello, tptest_sighandler);
-}
-
-int init_int_handler(void)
-{
- int result;
- struct sigaction act;
-
- memset(&act, 0, sizeof(act));
- result = sigemptyset(&act.sa_mask);
- if (result == -1) {
- perror("sigemptyset");
- return -1;
- }
-
- act.sa_handler = inthandler;
- act.sa_flags = SA_RESTART;
-
- /* Only defer ourselves. Also, try to restart interrupted
- * syscalls to disturb the traced program as little as possible.
- */
- result = sigaction(SIGUSR1, &act, NULL);
- if (result == -1) {
- perror("sigaction");
- return -1;
- }
-
- return 0;
-}
-
-void test_inc_count(void);
-
-int main(int argc, char **argv)
-{
- int i, netint;
- long values[] = { 1, 2, 3 };
- char text[10] = "test";
- double dbl = 2.0;
- float flt = 2222.0;
- int delay = 0;
- bool mybool = 123; /* should print "1" */
-
- init_int_handler();
-
- if (argc == 2)
- delay = atoi(argv[1]);
-
- fprintf(stderr, "Hello, World!\n");
-
- sleep(delay);
-
- fprintf(stderr, "Tracing... ");
- for (i = 0; i < 1000000; i++) {
- netint = htonl(i);
- tracepoint(ust_tests_hello, tptest, i, netint, values,
- text, strlen(text), dbl, flt, mybool);
- //usleep(100000);
- }
- fprintf(stderr, " done.\n");
- return 0;
-}
+++ /dev/null
-/*
- * tp.c
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_hello.h"
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER ust_tests_hello
-
-#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_TESTS_HELLO_H
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <lttng/tracepoint.h>
-#include <stdbool.h>
-#include <stddef.h>
-
-TRACEPOINT_EVENT(ust_tests_hello, tptest,
- TP_ARGS(int, anint, int, netint, long *, values,
- char *, text, size_t, textlen,
- double, doublearg, float, floatarg,
- bool, boolarg),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer_hex(int, intfield2, anint)
- ctf_integer(long, longfield, anint)
- ctf_integer_network(int, netintfield, netint)
- ctf_integer_network_hex(int, netintfieldhex, netint)
- ctf_array_nowrite(long, arrfield1z, values, 3)
- ctf_array(long, blah, values, 3)
- ctf_array(long, arrfield1, values, 3)
- ctf_array_hex(long, arrfield1_hex, values, 3)
- ctf_array_network(long, arrfield1_network, values, 3)
- ctf_array_network_hex(long, arrfield1_network_hex, values, 3)
- ctf_array_text(char, arrfield2, text, 10)
- ctf_sequence(char, seqfield1, text,
- size_t, textlen)
- ctf_sequence_nowrite(char, seqfield1z, text,
- size_t, textlen)
- ctf_sequence_hex(char, seqfield1_hex, text,
- size_t, textlen)
- ctf_sequence_text(char, seqfield2, text,
- size_t, textlen)
- ctf_sequence_network(long, seqfield_network_3, values,
- size_t, 3)
- ctf_string(stringfield, text)
- ctf_float(float, floatfield, floatarg)
- ctf_float(double, doublefield, doublearg)
- ctf_integer(bool, boolfield, boolarg)
- ctf_integer_nowrite(int, filterfield, anint)
- )
-)
-
-TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */
-
-#undef TRACEPOINT_INCLUDE
-#define TRACEPOINT_INCLUDE "./ust_tests_hello.h"
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
+++ /dev/null
-AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/liblttng-ust -I$(top_srcdir)/tests/utils
-
-noinst_PROGRAMS = test_pthread_name
-test_pthread_name_SOURCES = pthread_name.c
-test_pthread_name_LDADD = $(top_builddir)/tests/utils/libtap.a
+++ /dev/null
-/* Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <string.h>
-#include "compat.h"
-
-#include "tap.h"
-
-#define TEST_NAME_PROPER_LEN 16
-
-int main()
-{
- int ret;
- char name1[TEST_NAME_PROPER_LEN];
- char name2[TEST_NAME_PROPER_LEN];
- char too_long_name[] = "thisnameistoolong";
- char short_name[] = "labatt50";
- char short_name_ust[] = "labatt50-ust";
- char long_name[] = "procrastinating";
- char long_name_ust[] = "procrastina-ust";
-
- plan_tests(12);
-
- /* Get the initial thread name */
- ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
- ok(ret == 0, "Get the thread name: '%s'", name1);
-
- /* Set a thread name of more than 16 bytes, should fail */
- ret = lttng_pthread_setname_np(too_long_name);
- ok(ret == ERANGE, "Set a too long thread name: '%s'", too_long_name);
-
- /* Get the thread name again, shouldn't have changed */
- ret = lttng_pthread_getname_np(name2, TEST_NAME_PROPER_LEN);
- ok(ret == 0, "Get the thread name: '%s'", name2);
- ok(strcmp(name1, name2) == 0, "Compare the initial thread name: '%s' == '%s'", name1, name2);
-
- /* Set a thread name of less than 16 bytes */
- ret = lttng_pthread_setname_np(short_name);
- ok(ret == 0, "Set a short thread name: '%s'", short_name);
-
- /* Get the thread name again, should be the one we set */
- ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
- ok(ret == 0, "Get a short thread name: '%s'", name1);
- ok(strcmp(short_name, name1) == 0, "Compare the short thread name: '%s' == '%s'", short_name, name1);
-
- /* Append "-ust" to the thread name */
- lttng_ust_setustprocname();
- ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
- ok(strcmp(short_name_ust, name1) == 0, "Compare the short UST thread name: '%s' == '%s'", short_name_ust, name1);
-
-
- /* Set a thread name of 16 bytes */
- ret = lttng_pthread_setname_np(long_name);
- ok(ret == 0, "Set a long thread name: '%s'", long_name);
-
- /* Get the thread name again, should be the one we set */
- ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
- ok(ret == 0, "Get a long thread name: '%s'", name1);
- ok(strncmp(long_name, name1, TEST_NAME_PROPER_LEN - 1) == 0, "Compare the long thread name: '%s' == '%s'", long_name, name1);
-
- /* Append "-ust" to the thread name which will truncate its end */
- lttng_ust_setustprocname();
- ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
- ok(strcmp(long_name_ust, name1) == 0, "Compare the long UST thread name: '%s' == '%s'", long_name_ust, name1);
-
- return exit_status();
-}
+++ /dev/null
-AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
-
-noinst_PROGRAMS = same_line_tracepoint
-same_line_tracepoint_SOURCES = same_line_tracepoint.c ust_tests_sameline.h
-same_line_tracepoint_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
-
-EXTRA_DIST = README
+++ /dev/null
-Same line tracepoint test
--------------------------
-
-This is a build test that verifies multiple tracepoint can be placed on a single
-line.
+++ /dev/null
-/* Copyright (C) 2013 Jérémie Galarneau
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#define TRACEPOINT_DEFINE
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_sameline.h"
-
-int main()
-{
- tracepoint(ust_tests_sameline, event1); tracepoint(ust_tests_sameline, event2);
- return 0;
-}
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER ust_tests_sameline
-
-#if !defined(_TRACEPOINT_UST_TESTS_SAMELINE_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_TESTS_SAMELINE_H
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_EVENT(ust_tests_sameline, event1,
- TP_ARGS(),
- TP_FIELDS()
-)
-TRACEPOINT_LOGLEVEL(ust_tests_sameline, event1, TRACE_CRIT)
-
-TRACEPOINT_EVENT(ust_tests_sameline, event2,
- TP_ARGS(),
- TP_FIELDS()
-)
-TRACEPOINT_LOGLEVEL(ust_tests_sameline, event2, TRACE_CRIT)
-
-#endif /* _TRACEPOINT_UST_TESTS_SAMELINE_H */
-
-#undef TRACEPOINT_INCLUDE
-#define TRACEPOINT_INCLUDE "./ust_tests_sameline.h"
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
+++ /dev/null
-AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
-
-noinst_PROGRAMS = test_snprintf
-test_snprintf_SOURCES = snprintf.c
-test_snprintf_LDADD = $(top_builddir)/snprintf/libustsnprintf.la \
- $(top_builddir)/tests/utils/libtap.a
-
-EXTRA_DIST = README
+++ /dev/null
-ust_safe_snprintf test
--------------------
-
-Basic functionality test of the ust snprintf() implementation.
-
-DESCRIPTION
------------
-
-The ust_safe_snprintf() is tested against a known output string.
+++ /dev/null
-/* Copyright (C) 2009 Pierre-Marc Fournier
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <string.h>
-#include "ust_snprintf.h"
-
-#include "tap.h"
-
-int main()
-{
- char buf[100];
- char *expected;
- char test_fmt_str[] = "header %d, %s, %03d, '%3$*d'";
- char escaped_test_fmt_str[] = "header %%d, %%s, %%03d, '%%3$*d'";
-
- plan_tests(1);
-
- expected = "header 9999, hello, 005, ' 9'";
- ust_safe_snprintf(buf, 99, test_fmt_str, 9999, "hello", 5, 9);
-
- char test_desc_fmt_str[] = "Got expected output string with format string \"%s\"";
- char test_desc[sizeof(escaped_test_fmt_str) + sizeof(test_desc_fmt_str) - 1];
- sprintf(test_desc, test_desc_fmt_str, escaped_test_fmt_str);
- ok(strcmp(buf, expected) == 0, test_desc);
-
- return exit_status();
-}
+++ /dev/null
-AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
-
-noinst_PROGRAMS = hello
-hello_SOURCES = hello.c tp.c ust_tests_hello.h
-hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
-hello_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
+++ /dev/null
-/*
- * Copyright (C) 2009 Pierre-Marc Fournier
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; version 2.1 of
- * the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <fcntl.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-/*
- * Work-around inet.h missing struct mmsghdr forward declaration, with
- * triggers a warning when system files warnings are enabled.
- */
-struct mmsghdr;
-#include <arpa/inet.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdbool.h>
-
-#define TRACEPOINT_DEFINE
-#include "ust_tests_hello.h"
-
-/* Internal header. */
-#include <lttng/ust-events.h>
-#include <lttng/ringbuffer-config.h>
-#include <lttng/ust-context-provider.h>
-
-static __thread unsigned int test_count;
-
-void test_inc_count(void)
-{
- test_count++;
-}
-
-static
-size_t test_get_size(struct lttng_ctx_field *field, size_t offset)
-{
- int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES;
- size_t size = 0;
-
- size += lib_ring_buffer_align(offset, lttng_alignof(char));
- size += sizeof(char); /* tag */
- switch (sel) {
- case LTTNG_UST_DYNAMIC_TYPE_NONE:
- break;
- case LTTNG_UST_DYNAMIC_TYPE_S8:
- size += lib_ring_buffer_align(offset, lttng_alignof(int8_t));
- size += sizeof(int8_t); /* variant */
- break;
- case LTTNG_UST_DYNAMIC_TYPE_S16:
- size += lib_ring_buffer_align(offset, lttng_alignof(int16_t));
- size += sizeof(int16_t); /* variant */
- break;
- case LTTNG_UST_DYNAMIC_TYPE_S32:
- size += lib_ring_buffer_align(offset, lttng_alignof(int32_t));
- size += sizeof(int32_t); /* variant */
- break;
- case LTTNG_UST_DYNAMIC_TYPE_S64:
- size += lib_ring_buffer_align(offset, lttng_alignof(int64_t));
- size += sizeof(int64_t); /* variant */
- break;
- case LTTNG_UST_DYNAMIC_TYPE_U8:
- size += lib_ring_buffer_align(offset, lttng_alignof(uint8_t));
- size += sizeof(uint8_t); /* variant */
- break;
- case LTTNG_UST_DYNAMIC_TYPE_U16:
- size += lib_ring_buffer_align(offset, lttng_alignof(uint16_t));
- size += sizeof(uint16_t); /* variant */
- break;
- case LTTNG_UST_DYNAMIC_TYPE_U32:
- size += lib_ring_buffer_align(offset, lttng_alignof(uint32_t));
- size += sizeof(uint32_t); /* variant */
- break;
- case LTTNG_UST_DYNAMIC_TYPE_U64:
- size += lib_ring_buffer_align(offset, lttng_alignof(uint64_t));
- size += sizeof(uint64_t); /* variant */
- break;
- case LTTNG_UST_DYNAMIC_TYPE_FLOAT:
- size += lib_ring_buffer_align(offset, lttng_alignof(float));
- size += sizeof(float); /* variant */
- break;
- case LTTNG_UST_DYNAMIC_TYPE_DOUBLE:
- size += lib_ring_buffer_align(offset, lttng_alignof(double));
- size += sizeof(double); /* variant */
- break;
- case LTTNG_UST_DYNAMIC_TYPE_STRING:
- size += strlen("teststr") + 1;
- break;
- default:
- abort();
- }
-
- return size;
-}
-
-static
-void test_record(struct lttng_ctx_field *field,
- struct lttng_ust_lib_ring_buffer_ctx *ctx,
- struct lttng_channel *chan)
-{
- int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES;
- char sel_char = (char) sel;
-
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(char));
- chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
- switch (sel) {
- case LTTNG_UST_DYNAMIC_TYPE_NONE:
- break;
- case LTTNG_UST_DYNAMIC_TYPE_S8:
- {
- int8_t v = -8;
-
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
- break;
- }
- case LTTNG_UST_DYNAMIC_TYPE_S16:
- {
- int16_t v = -16;
-
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
- break;
- }
- case LTTNG_UST_DYNAMIC_TYPE_S32:
- {
- int32_t v = -32;
-
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
- break;
- }
- case LTTNG_UST_DYNAMIC_TYPE_S64:
- {
- int64_t v = -64;
-
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
- break;
- }
- case LTTNG_UST_DYNAMIC_TYPE_U8:
- {
- uint8_t v = 8;
-
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
- break;
- }
- case LTTNG_UST_DYNAMIC_TYPE_U16:
- {
- uint16_t v = 16;
-
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
- break;
- }
- case LTTNG_UST_DYNAMIC_TYPE_U32:
- {
- uint32_t v = 32;
-
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
- break;
- }
- case LTTNG_UST_DYNAMIC_TYPE_U64:
- {
- uint64_t v = 64;
-
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
- chan->ops->event_write(ctx, &v, sizeof(v));
- break;
- }
- case LTTNG_UST_DYNAMIC_TYPE_FLOAT:
- {
- float f = 22322.0;
-
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(f));
- chan->ops->event_write(ctx, &f, sizeof(f));
- break;
- }
- case LTTNG_UST_DYNAMIC_TYPE_DOUBLE:
- {
- double d = 2.0;
-
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(d));
- chan->ops->event_write(ctx, &d, sizeof(d));
- break;
- }
- case LTTNG_UST_DYNAMIC_TYPE_STRING:
- {
- const char *str = "teststr";
- chan->ops->event_write(ctx, str, strlen(str) + 1);
- break;
- }
- default:
- abort();
- }
-}
-
-static
-void test_get_value(struct lttng_ctx_field *field,
- struct lttng_ctx_value *value)
-{
- int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES;
-
- value->sel = sel;
- switch (sel) {
- case LTTNG_UST_DYNAMIC_TYPE_NONE:
- break;
- case LTTNG_UST_DYNAMIC_TYPE_S8:
- value->u.s64 = -8;
- break;
- case LTTNG_UST_DYNAMIC_TYPE_S16:
- value->u.s64 = -16;
- break;
- case LTTNG_UST_DYNAMIC_TYPE_S32:
- value->u.s64 = -32;
- break;
- case LTTNG_UST_DYNAMIC_TYPE_S64:
- value->u.s64 = -64;
- break;
- case LTTNG_UST_DYNAMIC_TYPE_U8:
- value->u.s64 = 8;
- break;
- case LTTNG_UST_DYNAMIC_TYPE_U16:
- value->u.s64 = 16;
- break;
- case LTTNG_UST_DYNAMIC_TYPE_U32:
- value->u.s64 = 32;
- break;
- case LTTNG_UST_DYNAMIC_TYPE_U64:
- value->u.s64 = 64;
- break;
- case LTTNG_UST_DYNAMIC_TYPE_FLOAT:
- value->u.d = 22322.0;
- break;
- case LTTNG_UST_DYNAMIC_TYPE_DOUBLE:
- value->u.d = 2.0;
- break;
- case LTTNG_UST_DYNAMIC_TYPE_STRING:
- value->u.str = "teststr";
- break;
- default:
- abort();
- }
-}
-
-struct lttng_ust_context_provider myprovider = {
- .name = "$app.myprovider",
- .get_size = test_get_size,
- .record = test_record,
- .get_value = test_get_value,
-};
-
-void inthandler(int sig)
-{
- printf("in SIGUSR1 handler\n");
- tracepoint(ust_tests_hello, tptest_sighandler);
-}
-
-int init_int_handler(void)
-{
- int result;
- struct sigaction act;
-
- memset(&act, 0, sizeof(act));
- result = sigemptyset(&act.sa_mask);
- if (result == -1) {
- perror("sigemptyset");
- return -1;
- }
-
- act.sa_handler = inthandler;
- act.sa_flags = SA_RESTART;
-
- /* Only defer ourselves. Also, try to restart interrupted
- * syscalls to disturb the traced program as little as possible.
- */
- result = sigaction(SIGUSR1, &act, NULL);
- if (result == -1) {
- perror("sigaction");
- return -1;
- }
-
- return 0;
-}
-
-void test_inc_count(void);
-
-int main(int argc, char **argv)
-{
- int i, netint;
- long values[] = { 1, 2, 3 };
- char text[10] = "test";
- double dbl = 2.0;
- float flt = 2222.0;
- int delay = 0;
- bool mybool = 123; /* should print "1" */
-
- init_int_handler();
-
- if (argc == 2)
- delay = atoi(argv[1]);
-
- if (lttng_ust_context_provider_register(&myprovider))
- abort();
-
- fprintf(stderr, "Hello, World!\n");
-
- sleep(delay);
-
- fprintf(stderr, "Tracing... ");
- for (i = 0; i < 1000000; i++) {
- netint = htonl(i);
- tracepoint(ust_tests_hello, tptest, i, netint, values,
- text, strlen(text), dbl, flt, mybool);
- test_inc_count();
- //usleep(100000);
- }
- lttng_ust_context_provider_unregister(&myprovider);
- fprintf(stderr, " done.\n");
- return 0;
-}
+++ /dev/null
-/*
- * tp.c
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_hello.h"
+++ /dev/null
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER ust_tests_hello
-
-#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_TESTS_HELLO_H
-
-/*
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <lttng/tracepoint.h>
-#include <stddef.h>
-#include <stdbool.h>
-
-TRACEPOINT_EVENT(ust_tests_hello, tptest,
- TP_ARGS(int, anint, int, netint, long *, values,
- char *, text, size_t, textlen,
- double, doublearg, float, floatarg,
- bool, boolarg),
- TP_FIELDS(
- ctf_integer(int, intfield, anint)
- ctf_integer_hex(int, intfield2, anint)
- ctf_integer(long, longfield, anint)
- ctf_integer_network(int, netintfield, netint)
- ctf_integer_network_hex(int, netintfieldhex, netint)
- ctf_array(long, arrfield1, values, 3)
- ctf_array_text(char, arrfield2, text, 10)
- ctf_sequence(char, seqfield1, text,
- size_t, textlen)
- ctf_sequence_text(char, seqfield2, text,
- size_t, textlen)
- ctf_string(stringfield, text)
- ctf_float(float, floatfield, floatarg)
- ctf_float(double, doublefield, doublearg)
- ctf_integer(bool, boolfield, boolarg)
- ctf_integer_nowrite(int, filterfield, anint)
- )
-)
-
-TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler,
- TP_ARGS(),
- TP_FIELDS()
-)
-
-#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */
-
-#undef TRACEPOINT_INCLUDE
-#define TRACEPOINT_INCLUDE "./ust_tests_hello.h"
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
--- /dev/null
+SUBDIRS = \
+ gcc-weak-hidden \
+ pthread_name \
+ snprintf \
+ ust-elf
--- /dev/null
+AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
+
+noinst_LTLIBRARIES = libgcc-wh.la
+libgcc_wh_la_SOURCES = c.c d.c
+
+noinst_PROGRAMS = test_gcc_weak_hidden
+test_gcc_weak_hidden_SOURCES = main.c b.c
+test_gcc_weak_hidden_LDADD = $(top_builddir)/tests/utils/libtap.a \
+ $(builddir)/libgcc-wh.la
--- /dev/null
+int testint __attribute__((weak, visibility("hidden")));
+void *testptr __attribute__((weak, visibility("hidden")));
+struct {
+ char a[24];
+} testsym_24_bytes __attribute__((weak, visibility("hidden")));
+
+void *testfct_int(void)
+{
+ return &testint;
+}
+
+void *testfct_ptr(void)
+{
+ return &testptr;
+}
+
+void *testfct_24_bytes(void)
+{
+ return &testsym_24_bytes;
+}
--- /dev/null
+int testint __attribute__((weak, visibility("hidden")));
+void *testptr __attribute__((weak, visibility("hidden")));
+struct {
+ char a[24];
+} testsym_24_bytes __attribute__((weak, visibility("hidden")));
+
+void *testlibfct1_int(void)
+{
+ return &testint;
+}
+
+void *testlibfct1_ptr(void)
+{
+ return &testptr;
+}
+
+void *testlibfct1_24_bytes(void)
+{
+ return &testsym_24_bytes;
+}
--- /dev/null
+int testint __attribute__((weak, visibility("hidden")));
+void *testptr __attribute__((weak, visibility("hidden")));
+struct {
+ char a[24];
+} testsym_24_bytes __attribute__((weak, visibility("hidden")));
+
+void *testlibfct2_int(void)
+{
+ return &testint;
+}
+
+void *testlibfct2_ptr(void)
+{
+ return &testptr;
+}
+
+void *testlibfct2_24_bytes(void)
+{
+ return &testsym_24_bytes;
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program for any
+ * purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is
+ * granted, provided the above notices are retained, and a notice that
+ * the code was modified is included with the above copyright notice.
+ */
+
+#include <stdbool.h>
+#include "tap.h"
+
+#define NUM_TESTS 2
+
+int testint __attribute__((weak, visibility("hidden")));
+void *testptr __attribute__((weak, visibility("hidden")));
+struct {
+ char a[24];
+} testsym_24_bytes __attribute__((weak, visibility("hidden")));
+
+void *testfct_int(void);
+void *testfct_ptr(void);
+void *testfct_24_bytes(void);
+
+void *testlibfct1_int(void);
+void *testlibfct1_ptr(void);
+void *testlibfct1_24_bytes(void);
+
+void *testlibfct2_int(void);
+void *testlibfct2_ptr(void);
+void *testlibfct2_24_bytes(void);
+
+enum {
+ MATCH_PROGRAM_INT,
+ MATCH_PROGRAM_PTR,
+ MATCH_PROGRAM_24_BYTES,
+ MATCH_LIB_INT,
+ MATCH_LIB_PTR,
+ MATCH_LIB_24_BYTES,
+ NR_MATCH,
+};
+
+static bool match_matrix[NR_MATCH];
+
+int main()
+{
+ plan_tests(NUM_TESTS);
+
+ if (testfct_int() == &testint)
+ match_matrix[MATCH_PROGRAM_INT] = true;
+ if (testfct_ptr() == &testptr)
+ match_matrix[MATCH_PROGRAM_PTR] = true;
+ if (testfct_24_bytes() == &testsym_24_bytes)
+ match_matrix[MATCH_PROGRAM_24_BYTES] = true;
+
+ if (testlibfct1_int() == testlibfct2_int())
+ match_matrix[MATCH_LIB_INT] = true;
+ if (testlibfct1_ptr() == testlibfct2_ptr())
+ match_matrix[MATCH_LIB_PTR] = true;
+ if (testlibfct1_24_bytes() == testlibfct2_24_bytes())
+ match_matrix[MATCH_LIB_24_BYTES] = true;
+
+ diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (4 bytes integer object)",
+ match_matrix[MATCH_PROGRAM_INT] ? "match" : "MISMATCH");
+ diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (pointer object)",
+ match_matrix[MATCH_PROGRAM_PTR] ? "match" : "MISMATCH");
+ diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (24 bytes structure object)",
+ match_matrix[MATCH_PROGRAM_24_BYTES] ? "match" : "MISMATCH");
+
+ diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (4 bytes integer object)",
+ match_matrix[MATCH_LIB_INT] ? "match" : "MISMATCH");
+ diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (pointer object)",
+ match_matrix[MATCH_LIB_PTR] ? "match" : "MISMATCH");
+ diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (24 bytes structure object)",
+ match_matrix[MATCH_LIB_24_BYTES] ? "match" : "MISMATCH");
+
+ ok(match_matrix[MATCH_PROGRAM_INT] == match_matrix[MATCH_PROGRAM_PTR],
+ "Weak-hidden behavior is the same for 4 bytes integer and pointer objects within main program");
+ ok(match_matrix[MATCH_LIB_INT] == match_matrix[MATCH_LIB_PTR],
+ "Weak-hidden behavior is the same for 4 bytes integer and pointer objects within shared library");
+
+ return exit_status();
+}
--- /dev/null
+AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/liblttng-ust -I$(top_srcdir)/tests/utils
+
+noinst_PROGRAMS = test_pthread_name
+test_pthread_name_SOURCES = pthread_name.c
+test_pthread_name_LDADD = $(top_builddir)/tests/utils/libtap.a
--- /dev/null
+/* Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "compat.h"
+
+#include "tap.h"
+
+#define TEST_NAME_PROPER_LEN 16
+
+int main()
+{
+ int ret;
+ char name1[TEST_NAME_PROPER_LEN];
+ char name2[TEST_NAME_PROPER_LEN];
+ char too_long_name[] = "thisnameistoolong";
+ char short_name[] = "labatt50";
+ char short_name_ust[] = "labatt50-ust";
+ char long_name[] = "procrastinating";
+ char long_name_ust[] = "procrastina-ust";
+
+ plan_tests(12);
+
+ /* Get the initial thread name */
+ ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
+ ok(ret == 0, "Get the thread name: '%s'", name1);
+
+ /* Set a thread name of more than 16 bytes, should fail */
+ ret = lttng_pthread_setname_np(too_long_name);
+ ok(ret == ERANGE, "Set a too long thread name: '%s'", too_long_name);
+
+ /* Get the thread name again, shouldn't have changed */
+ ret = lttng_pthread_getname_np(name2, TEST_NAME_PROPER_LEN);
+ ok(ret == 0, "Get the thread name: '%s'", name2);
+ ok(strcmp(name1, name2) == 0, "Compare the initial thread name: '%s' == '%s'", name1, name2);
+
+ /* Set a thread name of less than 16 bytes */
+ ret = lttng_pthread_setname_np(short_name);
+ ok(ret == 0, "Set a short thread name: '%s'", short_name);
+
+ /* Get the thread name again, should be the one we set */
+ ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
+ ok(ret == 0, "Get a short thread name: '%s'", name1);
+ ok(strcmp(short_name, name1) == 0, "Compare the short thread name: '%s' == '%s'", short_name, name1);
+
+ /* Append "-ust" to the thread name */
+ lttng_ust_setustprocname();
+ ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
+ ok(strcmp(short_name_ust, name1) == 0, "Compare the short UST thread name: '%s' == '%s'", short_name_ust, name1);
+
+
+ /* Set a thread name of 16 bytes */
+ ret = lttng_pthread_setname_np(long_name);
+ ok(ret == 0, "Set a long thread name: '%s'", long_name);
+
+ /* Get the thread name again, should be the one we set */
+ ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
+ ok(ret == 0, "Get a long thread name: '%s'", name1);
+ ok(strncmp(long_name, name1, TEST_NAME_PROPER_LEN - 1) == 0, "Compare the long thread name: '%s' == '%s'", long_name, name1);
+
+ /* Append "-ust" to the thread name which will truncate its end */
+ lttng_ust_setustprocname();
+ ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
+ ok(strcmp(long_name_ust, name1) == 0, "Compare the long UST thread name: '%s' == '%s'", long_name_ust, name1);
+
+ return exit_status();
+}
--- /dev/null
+AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
+
+noinst_PROGRAMS = test_snprintf
+test_snprintf_SOURCES = snprintf.c
+test_snprintf_LDADD = $(top_builddir)/snprintf/libustsnprintf.la \
+ $(top_builddir)/tests/utils/libtap.a
+
+EXTRA_DIST = README
--- /dev/null
+ust_safe_snprintf test
+-------------------
+
+Basic functionality test of the ust snprintf() implementation.
+
+DESCRIPTION
+-----------
+
+The ust_safe_snprintf() is tested against a known output string.
--- /dev/null
+/* Copyright (C) 2009 Pierre-Marc Fournier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "ust_snprintf.h"
+
+#include "tap.h"
+
+int main()
+{
+ char buf[100];
+ char *expected;
+ char test_fmt_str[] = "header %d, %s, %03d, '%3$*d'";
+ char escaped_test_fmt_str[] = "header %%d, %%s, %%03d, '%%3$*d'";
+
+ plan_tests(1);
+
+ expected = "header 9999, hello, 005, ' 9'";
+ ust_safe_snprintf(buf, 99, test_fmt_str, 9999, "hello", 5, 9);
+
+ char test_desc_fmt_str[] = "Got expected output string with format string \"%s\"";
+ char test_desc[sizeof(escaped_test_fmt_str) + sizeof(test_desc_fmt_str) - 1];
+ sprintf(test_desc, test_desc_fmt_str, escaped_test_fmt_str);
+ ok(strcmp(buf, expected) == 0, test_desc);
+
+ return exit_status();
+}
--- /dev/null
+AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
+
+noinst_PROGRAMS = ust-elf
+ust_elf_SOURCES = ust-elf.c
+ust_elf_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la \
+ $(top_builddir)/tests/utils/libtap.a
+
+# Directories added to EXTRA_DIST will be recursively copied to the distribution.
+EXTRA_DIST = \
+ $(srcdir)/data \
+ README.md
--- /dev/null
+lttng_ust_elf unit tests
+========================
+
+This is a series of unit tests for LTTng UST's ELF parser. The parser
+is used to retrieve memory size, build ID, and debug link information
+from ELF objects (standalone executable or shared object) for base
+address statedump or dl events.
+
+The parser should technically be able to read ELF files from any 32-
+or 64-bit architecture, little- or big- endian.
+
+However, to restrict the total amount of testing done, only 4
+architectures representing all combinations of bitness and endianness
+are currently tested:
+
+* x86
+* x86_64
+* armeb
+* aarch64_be
+
+For each architecture, there is a corresponding subdirectory under
+`data`, and each of these directories contains exactly 2 files,
+`main.elf` and `main.elf.debug`.
+
+The ELF files are generated from the trivial `main.c` program found in
+`data/`, using GNU toolchains. The program contains a static array in
+order to ensure the creation of a `.bss` section in the ELF file,
+which is one of the multiple factors leading to different file and
+in-memory size.
+
+The program is compiled with `gcc -g main.c -o main.elf`. On certain
+architectures, it is necessary to explicitly specify the
+`-Wl,--build-id=sha1` flags to include a build ID in the resulting
+executable.
+
+The debug information bundled in `main.elf` is then copied into
+`main.elf.debug` and stripped, and a debug link pointing to this file
+is added to the executable. The commands used are as follow:
+
+ $ objcopy --only-keep-debug main.elf main.elf.debug
+ $ strip -g main.elf
+ $ objcopy --add-gnu-debuglink=main.elf.debug main.elf
+
+There is also a series of tests used to check detection of
+position-independent code (PIC). These tests use three pre-compiled
+ELF files found under `data/pic/`, namely `hello.exec`, `hello.pie`,
+and `hello.pic`. These can be re-generated using the files `hello.c`
+and `libhello.c`, with the following commands:
+
+ $ gcc hello.c -o hello.exec
+ $ gcc hello.c -fPIC -pie -o hello.pie
+ $ gcc -shared -o hello.pic -fPIC libhello.c
--- /dev/null
+int main()
+{
+ char buf[100];
+
+ return 0;
+}
--- /dev/null
+#include <stdio.h>
+
+int main()
+{
+ puts("hello, world");
+
+ return 0;
+}
--- /dev/null
+#include <stdio.h>
+
+void hello()
+{
+ puts("hello, world");
+}
--- /dev/null
+#!/bin/sh
+
+TEST_DIR=$(dirname "$0")
+"${TEST_DIR}/ust-elf" "@abs_top_srcdir@/tests/unit/ust-elf"
--- /dev/null
+/*
+ * Copyright (C) 2015 Antoine Busque <abusque@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <limits.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <lttng/ust-elf.h>
+#include "tap.h"
+
+#define NUM_ARCH 4
+#define NUM_TESTS_PER_ARCH 11
+#define NUM_TESTS_PIC 3
+#define NUM_TESTS (NUM_ARCH * NUM_TESTS_PER_ARCH) + NUM_TESTS_PIC + 1
+
+/*
+ * Expected memsz were computed using libelf, build ID and debug link
+ * were determined through readelf.
+ */
+#define X86_MEMSZ 5732
+#define X86_64_MEMSZ 2099376
+#define ARMEB_MEMSZ 34196
+#define AARCH64_BE_MEMSZ 67632
+
+#define X86_CRC 0x1531f73c
+#define X86_64_CRC 0xa048a98f
+#define ARMEB_CRC 0x9d40261b
+#define AARCH64_BE_CRC 0x2b8cedce
+
+#define BUILD_ID_LEN 20
+#define DBG_FILE "main.elf.debug"
+
+static const uint8_t x86_build_id[BUILD_ID_LEN] = {
+ 0x27, 0x79, 0x2a, 0xe7, 0xaa, 0xef, 0x72, 0x5c, 0x9c, 0x52,
+ 0x80, 0xec, 0x1e, 0x18, 0xd8, 0x09, 0x02, 0xba, 0xbc, 0x82
+};
+static const uint8_t x86_64_build_id[BUILD_ID_LEN] = {
+ 0x0f, 0x87, 0xb2, 0xe2, 0x24, 0x9c, 0xe1, 0xc2, 0x24, 0xb1,
+ 0xf8, 0xb6, 0x65, 0x83, 0xa3, 0xc1, 0xcb, 0x30, 0x5c, 0x63
+};
+static const uint8_t armeb_build_id[BUILD_ID_LEN] = {
+ 0x60, 0x5d, 0x26, 0xa0, 0x0e, 0x30, 0xa4, 0x29, 0xf4, 0xf1,
+ 0x85, 0x53, 0xda, 0x90, 0x68, 0xe1, 0xf5, 0x67, 0xbe, 0x42
+};
+static const uint8_t aarch64_be_build_id[BUILD_ID_LEN] = {
+ 0xb9, 0x0a, 0xa0, 0xed, 0xd1, 0x41, 0x42, 0xc3, 0x34, 0x85,
+ 0xfa, 0x27, 0x2e, 0xa9, 0x2f, 0xd2, 0xe4, 0xf7, 0xb6, 0x60
+};
+
+static
+void test_elf(const char *test_dir, const char *arch, uint64_t exp_memsz,
+ const uint8_t *exp_build_id, uint32_t exp_crc)
+{
+ char path[PATH_MAX];
+ struct lttng_ust_elf *elf = NULL;
+ int ret = 0;
+ uint64_t memsz = 0;
+ int has_build_id = 0;
+ uint8_t *build_id = NULL;
+ size_t build_id_len = 0;
+ int has_debug_link = 0;
+ char *dbg_file = NULL;
+ uint32_t crc = 0;
+
+ diag("Testing %s support", arch);
+
+ snprintf(path, PATH_MAX, "%s/data/%s/main.elf", test_dir, arch);
+ elf = lttng_ust_elf_create(path);
+ ok(elf != NULL, "lttng_ust_elf_create");
+
+ ret = lttng_ust_elf_get_memsz(elf, &memsz);
+ ok(ret == 0, "lttng_ust_elf_get_memsz returned successfully");
+ ok(memsz == exp_memsz,
+ "memsz - expected: %lu, got: %lu",
+ exp_memsz, memsz);
+
+ ret = lttng_ust_elf_get_build_id(elf, &build_id, &build_id_len,
+ &has_build_id);
+ ok(ret == 0, "lttng_ust_elf_get_build_id returned successfully");
+ ok(has_build_id == 1, "build id marked as found");
+ ok(build_id_len == BUILD_ID_LEN,
+ "build_id_len - expected: %u, got: %u",
+ BUILD_ID_LEN, build_id_len);
+ ok(memcmp(build_id, exp_build_id, build_id_len) == 0,
+ "build_id has expected value");
+
+ ret = lttng_ust_elf_get_debug_link(elf, &dbg_file, &crc,
+ &has_debug_link);
+ ok(ret == 0, "lttng_ust_elf_get_debug_link returned successfully");
+ ok(has_debug_link == 1, "debug link marked as found");
+ ok(dbg_file && strcmp(dbg_file, DBG_FILE) == 0,
+ "debug link filename - expected: %s, got: %s",
+ DBG_FILE, dbg_file);
+ ok(crc == exp_crc,
+ "debug link crc - expected: %#x, got: %#x",
+ exp_crc, crc);
+
+ free(build_id);
+ free(dbg_file);
+ lttng_ust_elf_destroy(elf);
+}
+
+static
+void test_pic(const char *test_dir)
+{
+ char exec_path[PATH_MAX];
+ char pie_path[PATH_MAX];
+ char pic_path[PATH_MAX];
+ struct lttng_ust_elf *elf = NULL;
+ uint8_t is_pic;
+
+ snprintf(exec_path, PATH_MAX, "%s/data/pic/hello.exec", test_dir);
+ snprintf(pie_path, PATH_MAX, "%s/data/pic/hello.pie", test_dir);
+ snprintf(pic_path, PATH_MAX, "%s/data/pic/hello.pic", test_dir);
+
+ elf = lttng_ust_elf_create(exec_path);
+ is_pic = lttng_ust_elf_is_pic(elf);
+ ok(is_pic == 0, "hello.exec is not PIC");
+ lttng_ust_elf_destroy(elf);
+
+ elf = lttng_ust_elf_create(pie_path);
+ is_pic = lttng_ust_elf_is_pic(elf);
+ ok(is_pic == 1, "hello.pie is PIC");
+ lttng_ust_elf_destroy(elf);
+
+ elf = lttng_ust_elf_create(pic_path);
+ is_pic = lttng_ust_elf_is_pic(elf);
+ ok(is_pic == 1, "hello.pic is PIC");
+ lttng_ust_elf_destroy(elf);
+}
+
+int main(int argc, char **argv)
+{
+ const char *test_dir;
+
+ plan_tests(NUM_TESTS);
+
+ ok(argc == 2, "Invoke as: %s <path>", argv[0]);
+ if (argc != 2) {
+ return EXIT_FAILURE;
+ } else {
+ test_dir = argv[1];
+ }
+
+ test_elf(test_dir, "x86", X86_MEMSZ, x86_build_id, X86_CRC);
+ test_elf(test_dir, "x86_64", X86_64_MEMSZ, x86_64_build_id, X86_64_CRC);
+ test_elf(test_dir, "armeb", ARMEB_MEMSZ, armeb_build_id, ARMEB_CRC);
+ test_elf(test_dir, "aarch64_be", AARCH64_BE_MEMSZ, aarch64_be_build_id,
+ AARCH64_BE_CRC);
+ test_pic(test_dir);
+
+ return exit_status();
+}
+++ /dev/null
-AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
-
-noinst_PROGRAMS = ust-elf
-ust_elf_SOURCES = ust-elf.c
-ust_elf_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la \
- $(top_builddir)/tests/utils/libtap.a
-
-# Directories added to EXTRA_DIST will be recursively copied to the distribution.
-EXTRA_DIST = \
- $(srcdir)/data \
- README.md
+++ /dev/null
-lttng_ust_elf unit tests
-========================
-
-This is a series of unit tests for LTTng UST's ELF parser. The parser
-is used to retrieve memory size, build ID, and debug link information
-from ELF objects (standalone executable or shared object) for base
-address statedump or dl events.
-
-The parser should technically be able to read ELF files from any 32-
-or 64-bit architecture, little- or big- endian.
-
-However, to restrict the total amount of testing done, only 4
-architectures representing all combinations of bitness and endianness
-are currently tested:
-
-* x86
-* x86_64
-* armeb
-* aarch64_be
-
-For each architecture, there is a corresponding subdirectory under
-`data`, and each of these directories contains exactly 2 files,
-`main.elf` and `main.elf.debug`.
-
-The ELF files are generated from the trivial `main.c` program found in
-`data/`, using GNU toolchains. The program contains a static array in
-order to ensure the creation of a `.bss` section in the ELF file,
-which is one of the multiple factors leading to different file and
-in-memory size.
-
-The program is compiled with `gcc -g main.c -o main.elf`. On certain
-architectures, it is necessary to explicitly specify the
-`-Wl,--build-id=sha1` flags to include a build ID in the resulting
-executable.
-
-The debug information bundled in `main.elf` is then copied into
-`main.elf.debug` and stripped, and a debug link pointing to this file
-is added to the executable. The commands used are as follow:
-
- $ objcopy --only-keep-debug main.elf main.elf.debug
- $ strip -g main.elf
- $ objcopy --add-gnu-debuglink=main.elf.debug main.elf
-
-There is also a series of tests used to check detection of
-position-independent code (PIC). These tests use three pre-compiled
-ELF files found under `data/pic/`, namely `hello.exec`, `hello.pie`,
-and `hello.pic`. These can be re-generated using the files `hello.c`
-and `libhello.c`, with the following commands:
-
- $ gcc hello.c -o hello.exec
- $ gcc hello.c -fPIC -pie -o hello.pie
- $ gcc -shared -o hello.pic -fPIC libhello.c
+++ /dev/null
-int main()
-{
- char buf[100];
-
- return 0;
-}
+++ /dev/null
-#include <stdio.h>
-
-int main()
-{
- puts("hello, world");
-
- return 0;
-}
+++ /dev/null
-#include <stdio.h>
-
-void hello()
-{
- puts("hello, world");
-}
+++ /dev/null
-#!/bin/sh
-
-TEST_DIR=$(dirname "$0")
-"${TEST_DIR}/ust-elf" "@abs_top_srcdir@/tests/ust-elf"
+++ /dev/null
-/*
- * Copyright (C) 2015 Antoine Busque <abusque@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <limits.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <lttng/ust-elf.h>
-#include "tap.h"
-
-#define NUM_ARCH 4
-#define NUM_TESTS_PER_ARCH 11
-#define NUM_TESTS_PIC 3
-#define NUM_TESTS (NUM_ARCH * NUM_TESTS_PER_ARCH) + NUM_TESTS_PIC + 1
-
-/*
- * Expected memsz were computed using libelf, build ID and debug link
- * were determined through readelf.
- */
-#define X86_MEMSZ 5732
-#define X86_64_MEMSZ 2099376
-#define ARMEB_MEMSZ 34196
-#define AARCH64_BE_MEMSZ 67632
-
-#define X86_CRC 0x1531f73c
-#define X86_64_CRC 0xa048a98f
-#define ARMEB_CRC 0x9d40261b
-#define AARCH64_BE_CRC 0x2b8cedce
-
-#define BUILD_ID_LEN 20
-#define DBG_FILE "main.elf.debug"
-
-static const uint8_t x86_build_id[BUILD_ID_LEN] = {
- 0x27, 0x79, 0x2a, 0xe7, 0xaa, 0xef, 0x72, 0x5c, 0x9c, 0x52,
- 0x80, 0xec, 0x1e, 0x18, 0xd8, 0x09, 0x02, 0xba, 0xbc, 0x82
-};
-static const uint8_t x86_64_build_id[BUILD_ID_LEN] = {
- 0x0f, 0x87, 0xb2, 0xe2, 0x24, 0x9c, 0xe1, 0xc2, 0x24, 0xb1,
- 0xf8, 0xb6, 0x65, 0x83, 0xa3, 0xc1, 0xcb, 0x30, 0x5c, 0x63
-};
-static const uint8_t armeb_build_id[BUILD_ID_LEN] = {
- 0x60, 0x5d, 0x26, 0xa0, 0x0e, 0x30, 0xa4, 0x29, 0xf4, 0xf1,
- 0x85, 0x53, 0xda, 0x90, 0x68, 0xe1, 0xf5, 0x67, 0xbe, 0x42
-};
-static const uint8_t aarch64_be_build_id[BUILD_ID_LEN] = {
- 0xb9, 0x0a, 0xa0, 0xed, 0xd1, 0x41, 0x42, 0xc3, 0x34, 0x85,
- 0xfa, 0x27, 0x2e, 0xa9, 0x2f, 0xd2, 0xe4, 0xf7, 0xb6, 0x60
-};
-
-static
-void test_elf(const char *test_dir, const char *arch, uint64_t exp_memsz,
- const uint8_t *exp_build_id, uint32_t exp_crc)
-{
- char path[PATH_MAX];
- struct lttng_ust_elf *elf = NULL;
- int ret = 0;
- uint64_t memsz = 0;
- int has_build_id = 0;
- uint8_t *build_id = NULL;
- size_t build_id_len = 0;
- int has_debug_link = 0;
- char *dbg_file = NULL;
- uint32_t crc = 0;
-
- diag("Testing %s support", arch);
-
- snprintf(path, PATH_MAX, "%s/data/%s/main.elf", test_dir, arch);
- elf = lttng_ust_elf_create(path);
- ok(elf != NULL, "lttng_ust_elf_create");
-
- ret = lttng_ust_elf_get_memsz(elf, &memsz);
- ok(ret == 0, "lttng_ust_elf_get_memsz returned successfully");
- ok(memsz == exp_memsz,
- "memsz - expected: %lu, got: %lu",
- exp_memsz, memsz);
-
- ret = lttng_ust_elf_get_build_id(elf, &build_id, &build_id_len,
- &has_build_id);
- ok(ret == 0, "lttng_ust_elf_get_build_id returned successfully");
- ok(has_build_id == 1, "build id marked as found");
- ok(build_id_len == BUILD_ID_LEN,
- "build_id_len - expected: %u, got: %u",
- BUILD_ID_LEN, build_id_len);
- ok(memcmp(build_id, exp_build_id, build_id_len) == 0,
- "build_id has expected value");
-
- ret = lttng_ust_elf_get_debug_link(elf, &dbg_file, &crc,
- &has_debug_link);
- ok(ret == 0, "lttng_ust_elf_get_debug_link returned successfully");
- ok(has_debug_link == 1, "debug link marked as found");
- ok(dbg_file && strcmp(dbg_file, DBG_FILE) == 0,
- "debug link filename - expected: %s, got: %s",
- DBG_FILE, dbg_file);
- ok(crc == exp_crc,
- "debug link crc - expected: %#x, got: %#x",
- exp_crc, crc);
-
- free(build_id);
- free(dbg_file);
- lttng_ust_elf_destroy(elf);
-}
-
-static
-void test_pic(const char *test_dir)
-{
- char exec_path[PATH_MAX];
- char pie_path[PATH_MAX];
- char pic_path[PATH_MAX];
- struct lttng_ust_elf *elf = NULL;
- uint8_t is_pic;
-
- snprintf(exec_path, PATH_MAX, "%s/data/pic/hello.exec", test_dir);
- snprintf(pie_path, PATH_MAX, "%s/data/pic/hello.pie", test_dir);
- snprintf(pic_path, PATH_MAX, "%s/data/pic/hello.pic", test_dir);
-
- elf = lttng_ust_elf_create(exec_path);
- is_pic = lttng_ust_elf_is_pic(elf);
- ok(is_pic == 0, "hello.exec is not PIC");
- lttng_ust_elf_destroy(elf);
-
- elf = lttng_ust_elf_create(pie_path);
- is_pic = lttng_ust_elf_is_pic(elf);
- ok(is_pic == 1, "hello.pie is PIC");
- lttng_ust_elf_destroy(elf);
-
- elf = lttng_ust_elf_create(pic_path);
- is_pic = lttng_ust_elf_is_pic(elf);
- ok(is_pic == 1, "hello.pic is PIC");
- lttng_ust_elf_destroy(elf);
-}
-
-int main(int argc, char **argv)
-{
- const char *test_dir;
-
- plan_tests(NUM_TESTS);
-
- ok(argc == 2, "Invoke as: %s <path>", argv[0]);
- if (argc != 2) {
- return EXIT_FAILURE;
- } else {
- test_dir = argv[1];
- }
-
- test_elf(test_dir, "x86", X86_MEMSZ, x86_build_id, X86_CRC);
- test_elf(test_dir, "x86_64", X86_64_MEMSZ, x86_64_build_id, X86_64_CRC);
- test_elf(test_dir, "armeb", ARMEB_MEMSZ, armeb_build_id, ARMEB_CRC);
- test_elf(test_dir, "aarch64_be", AARCH64_BE_MEMSZ, aarch64_be_build_id,
- AARCH64_BE_CRC);
- test_pic(test_dir);
-
- return exit_status();
-}