From: Mathieu Desnoyers Date: Fri, 22 Mar 2013 16:30:22 +0000 (-0400) Subject: Implement liblttng-ust-cyg-profile function entry/exit instrumentation X-Git-Tag: v2.2.0-rc1~37 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=70d654f22a6b52beddfb86ec3daa453073c356d2;p=lttng-ust.git Implement liblttng-ust-cyg-profile function entry/exit instrumentation Signed-off-by: Mathieu Desnoyers --- diff --git a/Makefile.am b/Makefile.am index e61735d4..dc88c46e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index fdc5c846..0d63749b 100644 --- a/configure.ac +++ b/configure.ac @@ -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 index 00000000..98532987 --- /dev/null +++ b/liblttng-ust-cyg-profile/Makefile.am @@ -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 index 00000000..d772e76b --- /dev/null +++ b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.c @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011-2013 Mathieu Desnoyers + * + * 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 +#include +#include + +#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 index 00000000..48a7c735 --- /dev/null +++ b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h @@ -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 + * + * 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 + +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 + +#ifdef __cplusplus +} +#endif diff --git a/liblttng-ust-cyg-profile/run b/liblttng-ust-cyg-profile/run new file mode 100755 index 00000000..b21233e0 --- /dev/null +++ b/liblttng-ust-cyg-profile/run @@ -0,0 +1,3 @@ +#!/bin/sh + +LD_VERBOSE=1 LD_PRELOAD=.libs/liblttng-ust-cyg-profile.so ${*}