From 373148e9cedd5ec0b2302f4afe3ecd543e405f4f Mon Sep 17 00:00:00 2001 From: Francis Giraldeau Date: Wed, 17 Jul 2013 17:06:23 -0400 Subject: [PATCH] Add kernel and userspace callstack event context MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit LTTng callstack context. The callstack context can be added to any kernel channel. It records either the kernel or the userspace callstack, up to a max depth. The context is a CTF sequence, such that it uses only the space required for the number of callstack entries. The symbol name resolution is left to the trace reader. Signed-off-by: Francis Giraldeau Signed-off-by: Mathieu Desnoyers Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau --- configure.ac | 45 ++++++++++++++++++++++++++++ include/lttng/event.h | 2 ++ src/bin/lttng-sessiond/context.c | 6 ++++ src/bin/lttng/commands/add_context.c | 6 ++++ src/common/lttng-kernel.h | 2 ++ 5 files changed, 61 insertions(+) diff --git a/configure.ac b/configure.ac index 7c85cff4a..6a26e4998 100644 --- a/configure.ac +++ b/configure.ac @@ -955,6 +955,51 @@ AS_IF([test x$build_lib_relayd = xyes], ] ) +# Find arch type +AS_CASE([$host_cpu], + [k1om], [ARCHTYPE="x86"], + [i386], [ARCHTYPE="x86"], + [i486], [ARCHTYPE="x86"], + [i586], [ARCHTYPE="x86"], + [i686], [ARCHTYPE="x86"], + [amd64], [ARCHTYPE="x86"], + [x86_64], [ARCHTYPE="x86"], + [powerpc], [ARCHTYPE="ppc"], + [ppc64], [ARCHTYPE="ppc"], + [powerpc64], [ARCHTYPE="ppc"], + [powerpc64le], [ARCHTYPE="ppc"], + [ppc], [ARCHTYPE="ppc"], + [s390], [ARCHTYPE="s390"], + [s390x], [ARCHTYPE="s390"], + [sparc], [ARCHTYPE="sparc64"], + [sparc64], [ARCHTYPE="sparc64"], + [alpha*], [ARCHTYPE="alpha"], + [ia64], [ARCHTYPE="ia64"], + [arm*], [ARCHTYPE="arm"], + [aarch64*], [ARCHTYPE="aarch64"], + [mips*], [ARCHTYPE="mips"], + [nios2*], [ARCHTYPE="nios2"], + [tile*], [ARCHTYPE="tile"], + [hppa*], [ARCHTYPE="hppa"], + [m68k], [ARCHTYPE="m68k"], + [riscv*], [ARCHTYPE="riscv"], + [ARCHTYPE="unknown"] +) + +AC_SUBST(ARCHTYPE) + +AH_TEMPLATE([HAVE_MODULES_USERSPACE_CALLSTACK_CONTEXT], [Define if you have LTTng-modules userspace callstack tracing support]) +AC_MSG_CHECKING([for architecture support of userspace callstack tracing from the kernel]) +AS_IF([test "x$ARCHTYPE" = "xx86"],[ + # Userspace callstack capture is only supported by the Linux kernel on x86. + AC_MSG_RESULT([yes]) + have_modules_userspace_callstack_context=yes + AC_DEFINE([HAVE_MODULES_USERSPACE_CALLSTACK_CONTEXT], [1]) +], [ + AC_MSG_RESULT([no]) + have_modules_userspace_callstack_context=no +]) +AM_CONDITIONAL([HAVE_MODULES_USERSPACE_CALLSTACK_CONTEXT], [test x$have_modules_userspace_callstack_context != xno]) # Export binaries build conditions. AM_CONDITIONAL([BUILD_BIN_LTTNG], [test x$enable_bin_lttng != xno]) diff --git a/include/lttng/event.h b/include/lttng/event.h index 16b4d4f59..b89590dbd 100644 --- a/include/lttng/event.h +++ b/include/lttng/event.h @@ -142,6 +142,8 @@ enum lttng_event_context_type { LTTNG_EVENT_CONTEXT_PREEMPTIBLE = 17, LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE = 18, LTTNG_EVENT_CONTEXT_MIGRATABLE = 19, + LTTNG_EVENT_CONTEXT_CALLSTACK_KERNEL = 20, + LTTNG_EVENT_CONTEXT_CALLSTACK_USER = 21, /* Supported on x86_32 and x86_64 only. */ }; enum lttng_event_field_type { diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c index 3c7c34df4..6cf301dcd 100644 --- a/src/bin/lttng-sessiond/context.c +++ b/src/bin/lttng-sessiond/context.c @@ -259,6 +259,12 @@ int context_kernel_add(struct ltt_kernel_session *ksession, case LTTNG_EVENT_CONTEXT_MIGRATABLE: kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_MIGRATABLE; break; + case LTTNG_EVENT_CONTEXT_CALLSTACK_KERNEL: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL; + break; + case LTTNG_EVENT_CONTEXT_CALLSTACK_USER: + kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_CALLSTACK_USER; + break; default: ret = LTTNG_ERR_KERN_CONTEXT_FAIL; goto error; diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c index 0adaa7538..2c29a45ca 100644 --- a/src/bin/lttng/commands/add_context.c +++ b/src/bin/lttng/commands/add_context.c @@ -84,6 +84,8 @@ enum context_type { CONTEXT_PREEMPTIBLE = 17, CONTEXT_NEED_RESCHEDULE = 18, CONTEXT_MIGRATABLE = 19, + CONTEXT_CALLSTACK_KERNEL = 20, + CONTEXT_CALLSTACK_USER = 21, }; /* @@ -240,6 +242,10 @@ const struct ctx_opts { { "preemptible", CONTEXT_PREEMPTIBLE }, { "need_reschedule", CONTEXT_NEED_RESCHEDULE }, { "migratable", CONTEXT_MIGRATABLE }, + { "callstack-kernel", CONTEXT_CALLSTACK_KERNEL }, +#if HAVE_MODULES_USERSPACE_CALLSTACK_CONTEXT + { "callstack-user", CONTEXT_CALLSTACK_USER }, +#endif /* Perf options */ diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h index 8d87539a4..9d6d60c40 100644 --- a/src/common/lttng-kernel.h +++ b/src/common/lttng-kernel.h @@ -58,6 +58,8 @@ enum lttng_kernel_context_type { LTTNG_KERNEL_CONTEXT_PREEMPTIBLE = 13, LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE = 14, LTTNG_KERNEL_CONTEXT_MIGRATABLE = 15, + LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL = 16, + LTTNG_KERNEL_CONTEXT_CALLSTACK_USER = 17, }; /* Perf counter attributes */ -- 2.34.1