cyg_profile: implement fast and verbose .so
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 26 Mar 2013 13:29:04 +0000 (09:29 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 26 Mar 2013 13:29:04 +0000 (09:29 -0400)
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 <mathieu.desnoyers@efficios.com>
liblttng-ust-cyg-profile/Makefile.am
liblttng-ust-cyg-profile/lttng-ust-cyg-profile-fast.c [new file with mode: 0644]
liblttng-ust-cyg-profile/lttng-ust-cyg-profile-fast.h [new file with mode: 0644]
liblttng-ust-cyg-profile/lttng-ust-cyg-profile.c
liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h
liblttng-ust-cyg-profile/run-fast [new file with mode: 0755]

index 985329877034d7b03bb5383f1db6e8d8fb7be1fc..d325f53518a94b4d36c22e0475016d85bce02102 100644 (file)
@@ -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 (file)
index 0000000..ab42185
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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
+#define _LGPL_SOURCE
+#include <dlfcn.h>
+#include <sys/types.h>
+#include <stdio.h>
+
+#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 (file)
index 0000000..5356760
--- /dev/null
@@ -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 <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_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 <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus
+}
+#endif
index d772e76b961a148d19bf04d56ae9481b697d99b5..2ff11595b5b9fc69e080c06a491772d00eaf7df8 100644 (file)
@@ -16,6 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#define _LGPL_SOURCE
 #define _GNU_SOURCE
 #include <dlfcn.h>
 #include <sys/types.h>
@@ -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);
 }
index 48a7c73574b1ebcfb918d731e16ce8aa2471691b..7629fb991c329419745cf99f0489cafedecadc78 100644 (file)
@@ -33,9 +33,10 @@ extern "C" {
 #include <lttng/tracepoint.h>
 
 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 (executable)
index 0000000..dd24a37
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+LD_VERBOSE=1 LD_PRELOAD=.libs/liblttng-ust-cyg-profile-fast.so ${*}
This page took 0.028178 seconds and 4 git commands to generate.