From: Mathieu Desnoyers Date: Tue, 26 Mar 2013 13:29:04 +0000 (-0400) Subject: cyg_profile: implement fast and verbose .so X-Git-Tag: v2.2.0-rc1~34 X-Git-Url: http://git.lttng.org/?p=lttng-ust.git;a=commitdiff_plain;h=dd33005382c8852d04eef7f09f746c2fdfca1e52 cyg_profile: implement fast and verbose .so The "fast" .so (liblttng-ust-cyg-profile-fast.so) is for use-cases where we expect a complete event stream to be recorded, so we can skip duplicate information. The verbose .so (liblttng-ust-cyg-profile.so) is for use-cases where events discarded are expected, and the trace analyzer needs extra information to be able to reconstruct the program flow. Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust-cyg-profile/Makefile.am b/liblttng-ust-cyg-profile/Makefile.am index 98532987..d325f535 100644 --- a/liblttng-ust-cyg-profile/Makefile.am +++ b/liblttng-ust-cyg-profile/Makefile.am @@ -1,7 +1,9 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include AM_CFLAGS = -fno-strict-aliasing -lib_LTLIBRARIES = liblttng-ust-cyg-profile.la +lib_LTLIBRARIES = liblttng-ust-cyg-profile.la \ + liblttng-ust-cyg-profile-fast.la + liblttng_ust_cyg_profile_la_SOURCES = \ lttng-ust-cyg-profile.c \ lttng-ust-cyg-profile.h @@ -9,12 +11,21 @@ liblttng_ust_cyg_profile_la_LIBADD = \ -L$(top_builddir)/liblttng-ust/.libs \ -llttng-ust +liblttng_ust_cyg_profile_fast_la_SOURCES = \ + lttng-ust-cyg-profile-fast.c \ + lttng-ust-cyg-profile-fast.h +liblttng_ust_cyg_profile_fast_la_LIBADD = \ + -L$(top_builddir)/liblttng-ust/.libs \ + -llttng-ust + if LTTNG_UST_BUILD_WITH_LIBDL liblttng_ust_cyg_profile_la_LIBADD += -ldl +liblttng_ust_cyg_profile_fast_la_LIBADD += -ldl endif if LTTNG_UST_BUILD_WITH_LIBC_DL liblttng_ust_cyg_profile_la_LIBADD += -lc +liblttng_ust_cyg_profile_fast_la_LIBADD += -lc endif -noinst_SCRIPTS = run -EXTRA_DIST = run +noinst_SCRIPTS = run run-fast +EXTRA_DIST = run run-fast diff --git a/liblttng-ust-cyg-profile/lttng-ust-cyg-profile-fast.c b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile-fast.c new file mode 100644 index 00000000..ab42185c --- /dev/null +++ b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile-fast.c @@ -0,0 +1,43 @@ +/* + * 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 +#define _LGPL_SOURCE +#include +#include +#include + +#define TRACEPOINT_DEFINE +#define TRACEPOINT_CREATE_PROBES +#include "lttng-ust-cyg-profile-fast.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_fast, func_entry, this_fn); +} + +void __cyg_profile_func_exit(void *this_fn, void *call_site) +{ + tracepoint(lttng_ust_cyg_profile_fast, func_exit); +} diff --git a/liblttng-ust-cyg-profile/lttng-ust-cyg-profile-fast.h b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile-fast.h new file mode 100644 index 00000000..5356760f --- /dev/null +++ b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile-fast.h @@ -0,0 +1,63 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER lttng_ust_cyg_profile_fast + +#if !defined(_TRACEPOINT_LTTNG_UST_CYG_PROFILE_FAST_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_LTTNG_UST_CYG_PROFILE_FAST_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_fast, func_entry, + TP_ARGS(void *, func_addr), + TP_FIELDS( + ctf_integer_hex(void *, addr, func_addr) + ) +) + +TRACEPOINT_LOGLEVEL(lttng_ust_cyg_profile_fast, func_entry, + TRACE_DEBUG_FUNCTION) + +TRACEPOINT_EVENT(lttng_ust_cyg_profile_fast, func_exit, + TP_ARGS(void), + TP_FIELDS() +) + +TRACEPOINT_LOGLEVEL(lttng_ust_cyg_profile_fast, func_exit, + TRACE_DEBUG_FUNCTION) + +#endif /* _TRACEPOINT_LTTNG_UST_CYG_PROFILE_FAST_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./lttng-ust-cyg-profile-fast.h" + +/* This part must be outside ifdef protection */ +#include + +#ifdef __cplusplus +} +#endif diff --git a/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.c b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.c index d772e76b..2ff11595 100644 --- a/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.c +++ b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.c @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#define _LGPL_SOURCE #define _GNU_SOURCE #include #include @@ -33,10 +34,10 @@ void __cyg_profile_func_exit(void *this_fn, void *call_site) void __cyg_profile_func_enter(void *this_fn, void *call_site) { - tracepoint(lttng_ust_cyg_profile, func_entry, this_fn); + tracepoint(lttng_ust_cyg_profile, func_entry, this_fn, call_site); } void __cyg_profile_func_exit(void *this_fn, void *call_site) { - tracepoint(lttng_ust_cyg_profile, func_exit); + tracepoint(lttng_ust_cyg_profile, func_exit, this_fn, call_site); } diff --git a/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h index 48a7c735..7629fb99 100644 --- a/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h +++ b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h @@ -33,9 +33,10 @@ extern "C" { #include TRACEPOINT_EVENT(lttng_ust_cyg_profile, func_entry, - TP_ARGS(void *, func_addr), + TP_ARGS(void *, func_addr, void *, call_site), TP_FIELDS( ctf_integer_hex(void *, addr, func_addr) + ctf_integer_hex(void *, call_site, func_addr) ) ) @@ -43,8 +44,11 @@ TRACEPOINT_LOGLEVEL(lttng_ust_cyg_profile, func_entry, TRACE_DEBUG_FUNCTION) TRACEPOINT_EVENT(lttng_ust_cyg_profile, func_exit, - TP_ARGS(void), - TP_FIELDS() + TP_ARGS(void *, func_addr, void *, call_site), + TP_FIELDS( + ctf_integer_hex(void *, addr, func_addr) + ctf_integer_hex(void *, call_site, func_addr) + ) ) TRACEPOINT_LOGLEVEL(lttng_ust_cyg_profile, func_exit, diff --git a/liblttng-ust-cyg-profile/run-fast b/liblttng-ust-cyg-profile/run-fast new file mode 100755 index 00000000..dd24a370 --- /dev/null +++ b/liblttng-ust-cyg-profile/run-fast @@ -0,0 +1,3 @@ +#!/bin/sh + +LD_VERBOSE=1 LD_PRELOAD=.libs/liblttng-ust-cyg-profile-fast.so ${*}