Implement liblttng-ust-cyg-profile function entry/exit instrumentation
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 22 Mar 2013 16:30:22 +0000 (12:30 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 22 Mar 2013 16:30:22 +0000 (12:30 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Makefile.am
configure.ac
liblttng-ust-cyg-profile/Makefile.am [new file with mode: 0644]
liblttng-ust-cyg-profile/lttng-ust-cyg-profile.c [new file with mode: 0644]
liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h [new file with mode: 0644]
liblttng-ust-cyg-profile/run [new file with mode: 0755]

index e61735d421e8cf719d5a62e93c9dd7e01900847e..dc88c46ea07b47ba17026b4757383c2d8e45e540 100644 (file)
@@ -5,6 +5,7 @@ SUBDIRS = . include snprintf libringbuffer liblttng-ust-comm \
                liblttng-ust-ctl \
                liblttng-ust-fork \
                liblttng-ust-libc-wrapper \
+               liblttng-ust-cyg-profile \
                tools \
                tests \
                doc
index fdc5c8462bd8f1cb747ca6309c7c8e6a310049d3..0d63749bb6ab80110fbec2076f94ce7e0c00a87f 100644 (file)
@@ -279,6 +279,7 @@ AC_CONFIG_FILES([
        liblttng-ust-fork/Makefile
        liblttng-ust-java/Makefile
        liblttng-ust-libc-wrapper/Makefile
+       liblttng-ust-cyg-profile/Makefile
        tools/Makefile
        tests/Makefile
        tests/hello/Makefile
diff --git a/liblttng-ust-cyg-profile/Makefile.am b/liblttng-ust-cyg-profile/Makefile.am
new file mode 100644 (file)
index 0000000..9853298
--- /dev/null
@@ -0,0 +1,20 @@
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include
+AM_CFLAGS = -fno-strict-aliasing
+
+lib_LTLIBRARIES = liblttng-ust-cyg-profile.la
+liblttng_ust_cyg_profile_la_SOURCES = \
+       lttng-ust-cyg-profile.c \
+       lttng-ust-cyg-profile.h
+liblttng_ust_cyg_profile_la_LIBADD = \
+       -L$(top_builddir)/liblttng-ust/.libs \
+       -llttng-ust
+
+if LTTNG_UST_BUILD_WITH_LIBDL
+liblttng_ust_cyg_profile_la_LIBADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+liblttng_ust_cyg_profile_la_LIBADD += -lc
+endif
+
+noinst_SCRIPTS = run
+EXTRA_DIST = run
diff --git a/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.c b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.c
new file mode 100644 (file)
index 0000000..d772e76
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2011-2013  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; 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 _GNU_SOURCE
+#include <dlfcn.h>
+#include <sys/types.h>
+#include <stdio.h>
+
+#define TRACEPOINT_DEFINE
+#define TRACEPOINT_CREATE_PROBES
+#include "lttng-ust-cyg-profile.h"
+
+void __cyg_profile_func_enter(void *this_fn, void *call_site)
+       __attribute__((no_instrument_function));
+
+void __cyg_profile_func_exit(void *this_fn, void *call_site)
+       __attribute__((no_instrument_function));
+
+void __cyg_profile_func_enter(void *this_fn, void *call_site)
+{
+       tracepoint(lttng_ust_cyg_profile, func_entry, this_fn);
+}
+
+void __cyg_profile_func_exit(void *this_fn, void *call_site)
+{
+       tracepoint(lttng_ust_cyg_profile, func_exit);
+}
diff --git a/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h
new file mode 100644 (file)
index 0000000..48a7c73
--- /dev/null
@@ -0,0 +1,63 @@
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER lttng_ust_cyg_profile
+
+#if !defined(_TRACEPOINT_LTTNG_UST_CYG_PROFILE_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_LTTNG_UST_CYG_PROFILE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011-2013  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(lttng_ust_cyg_profile, func_entry,
+       TP_ARGS(void *, func_addr),
+       TP_FIELDS(
+               ctf_integer_hex(void *, addr, func_addr)
+       )
+)
+
+TRACEPOINT_LOGLEVEL(lttng_ust_cyg_profile, func_entry,
+       TRACE_DEBUG_FUNCTION)
+
+TRACEPOINT_EVENT(lttng_ust_cyg_profile, func_exit,
+       TP_ARGS(void),
+       TP_FIELDS()
+)
+
+TRACEPOINT_LOGLEVEL(lttng_ust_cyg_profile, func_exit,
+       TRACE_DEBUG_FUNCTION)
+
+#endif /* _TRACEPOINT_LTTNG_UST_CYG_PROFILE_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./lttng-ust-cyg-profile.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/liblttng-ust-cyg-profile/run b/liblttng-ust-cyg-profile/run
new file mode 100755 (executable)
index 0000000..b21233e
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+LD_VERBOSE=1 LD_PRELOAD=.libs/liblttng-ust-cyg-profile.so ${*}
This page took 0.030774 seconds and 4 git commands to generate.