output_autoconf(s, o, "autoconf-module-sect-attrs.c", "STAPCONF_MODULE_SECT_ATTRS", NULL);
output_autoconf(s, o, "autoconf-utrace-via-tracepoints.c", "STAPCONF_UTRACE_VIA_TRACEPOINTS", NULL);
- output_autoconf(s, o, "autoconf-utrace-via-ftrace.c", "STAPCONF_UTRACE_VIA_FTRACE", NULL);
output_autoconf(s, o, "autoconf-vm-area-pte.c", "STAPCONF_VM_AREA_PTE", NULL);
output_autoconf(s, o, "autoconf-relay-umode_t.c", "STAPCONF_RELAY_UMODE_T", NULL);
output_autoconf(s, o, "autoconf-fs_supers-hlist.c", "STAPCONF_FS_SUPERS_HLIST", NULL);
+++ /dev/null
-#include <trace/events/sched.h>
-#include <trace/events/syscalls.h>
-#include <linux/ftrace.h>
-#include <linux/task_work.h>
-
-// The utrace-less task_finder needs either:
-// - 5 specific tracepoints
-// - 4 specific tracepoints and ftrace_set_filter()
-// Both scenarios need <linux/task_work.h>.
-//
-// Check scenario #2.
-
-void __sched_process_fork(void *cb_data __attribute__((unused)),
- struct task_struct *parent __attribute__((unused)),
- struct task_struct *child __attribute__((unused)))
-{
- return;
-}
-
-void __sched_process_exit(void *cb_data __attribute__((unused)),
- struct task_struct *task __attribute__((unused)))
-{
- return;
-}
-
-void __sys_enter(void *cb_data __attribute__ ((unused)),
- struct pt_regs *regs __attribute__((unused)),
- long id __attribute__((unused)))
-{
- return;
-}
-
-void __sys_exit(void *cb_data __attribute__ ((unused)),
- struct pt_regs *regs __attribute__((unused)),
- long ret __attribute__((unused)))
-{
- return;
-}
-
-struct ftrace_ops __ftrace_ops;
-
-void __autoconf_func(void)
-{
- char *report_exec_name;
- struct task_work work;
-
- (void) register_trace_sched_process_fork(__sched_process_fork, NULL);
- (void) register_trace_sched_process_exit(__sched_process_exit, NULL);
- (void) register_trace_sys_enter(__sys_enter, NULL);
- (void) register_trace_sys_exit(__sys_exit, NULL);
-
- report_exec_name = "*" __stringify(proc_exec_connector);
- ftrace_set_filter(&__ftrace_ops, report_exec_name,
- strlen(report_exec_name), 1);
- (void) register_ftrace_function(&__ftrace_ops);
- init_task_work(&work, NULL, NULL);
-}
#include "regs.c"
#include "regs-ia64.c"
-#if (defined(CONFIG_UTRACE) || defined(STAPCONF_UTRACE_VIA_TRACEPOINTS) \
- || defined(STAPCONF_UTRACE_VIA_FTRACE))
+#if (defined(CONFIG_UTRACE) || defined(STAPCONF_UTRACE_VIA_TRACEPOINTS))
#define HAVE_TASK_FINDER
#include "task_finder.c"
#endif
#ifndef _STP_UTRACE_C
#define _STP_UTRACE_C
-/*
- * Which internal utrace implementation shall we use?
- * (1) STAPCONF_UTRACE_VIA_TRACEPOINTS - Pure tracepoints (preferred).
- * (2) STAPCONF_UTRACE_VIA_FTRACE - Tracepoints, plus a bit of ftrace.
- */
-
-#if (!defined(STAPCONF_UTRACE_VIA_TRACEPOINTS) \
- && !defined(STAPCONF_UTRACE_VIA_FTRACE))
-#error "STAPCONF_UTRACE_VIA_TRACEPOINTS or STAPCONF_UTRACE_VIA_FTRACE must be defined."
+#if (!defined(STAPCONF_UTRACE_VIA_TRACEPOINTS))
+#error "STAPCONF_UTRACE_VIA_TRACEPOINTS must be defined."
#endif
-#if (defined(STAPCONF_UTRACE_VIA_TRACEPOINTS) \
- && defined(STAPCONF_UTRACE_VIA_FTRACE))
-/* If we've got both, prefer STAPCONF_UTRACE_VIA_TRACEPOINTS. */
-#undef STAPCONF_UTRACE_VIA_FTRACE
-#endif /* STAPCONF_UTRACE_VIA_TRACEPOINTS and STAPCONF_UTRACE_VIA_FTRACE */
#include "stp_utrace.h"
#include <linux/list.h>
#include <linux/sched.h>
#include <linux/freezer.h>
#include <linux/slab.h>
-#ifdef STAPCONF_UTRACE_VIA_FTRACE
-#include <linux/ftrace.h>
-#endif /* STAPCONF_UTRACE_VIA_FTRACE */
#include <linux/spinlock.h>
#include <trace/events/sched.h>
#include <trace/events/syscalls.h>
static void utrace_report_syscall_exit(void *cb_data __attribute__ ((unused)),
struct pt_regs *regs, long ret);
-#ifdef STAPCONF_UTRACE_VIA_TRACEPOINTS
static void utrace_report_exec(void *cb_data __attribute__ ((unused)),
struct task_struct *task,
pid_t old_pid __attribute__((unused)),
struct linux_binprm *bprm __attribute__ ((unused)));
-#else /* STAPCONF_UTRACE_VIA_FTRACE */
-static void utrace_report_exec(unsigned long ip __attribute__ ((unused)),
- unsigned long parent_ip __attribute__ ((unused)));
-
-static struct ftrace_ops utrace_report_exec_ops __read_mostly =
-{
- .func = utrace_report_exec,
-};
-#endif /* STAPCONF_UTRACE_VIA_FTRACE */
#define __UTRACE_UNREGISTERED 0
#define __UTRACE_REGISTERED 1
{
int i;
int rc = -1;
-#ifdef STAPCONF_UTRACE_VIA_FTRACE
- char *report_exec_name;
-#endif
#if !defined(STAPCONF_TASK_WORK_ADD_EXPORTED)
/* The task_work_add()/task_work_cancel() functions aren't
goto error4;
}
-#ifdef STAPCONF_UTRACE_VIA_TRACEPOINTS
rc = register_trace_sched_process_exec(utrace_report_exec, NULL);
if (unlikely(rc != 0)) {
_stp_error("register_sched_process_exec failed: %d", rc);
goto error5;
}
-#else /* STAPCONF_UTRACE_VIA_FTRACE */
- report_exec_name = "*" __stringify(proc_exec_connector);
- ftrace_set_filter(&utrace_report_exec_ops, report_exec_name,
- strlen(report_exec_name), 1);
- rc = register_ftrace_function(&utrace_report_exec_ops);
- if (unlikely(rc != 0)) {
- _stp_error("register_ftrace_function failed: %d", rc);
- goto error5;
- }
-#endif /* STAPCONF_UTRACE_VIA_FTRACE */
atomic_set(&utrace_state, __UTRACE_REGISTERED);
-
return 0;
error5:
#ifdef STP_TF_DEBUG
printk(KERN_ERR "%s:%d entry\n", __FUNCTION__, __LINE__);
#endif
-#ifdef STAPCONF_UTRACE_VIA_TRACEPOINTS
unregister_trace_sched_process_exec(utrace_report_exec, NULL);
-#else /* STAPCONF_UTRACE_VIA_FTRACE */
- unregister_ftrace_function(&utrace_report_exec_ops);
-#endif /* STAPCONF_UTRACE_VIA_FTRACE */
unregister_trace_sched_process_fork(utrace_report_clone, NULL);
unregister_trace_sched_process_exit(utrace_report_death, NULL);
unregister_trace_sys_enter(utrace_report_syscall_entry, NULL);
/*
* Called iff UTRACE_EVENT(EXEC) flag is set.
*/
-#ifdef STAPCONF_UTRACE_VIA_TRACEPOINTS
static void utrace_report_exec(void *cb_data __attribute__ ((unused)),
struct task_struct *task,
pid_t old_pid __attribute__((unused)),
struct linux_binprm *bprm __attribute__ ((unused)))
-#else /* STAPCONF_UTRACE_VIA_FTRACE */
-static void utrace_report_exec(unsigned long ip __attribute__ ((unused)),
- unsigned long parent_ip __attribute__ ((unused)))
-#endif /* STAPCONF_UTRACE_VIA_FTRACE */
{
-#ifdef STAPCONF_UTRACE_VIA_FTRACE
- struct task_struct *task = current;
-#endif
struct utrace *utrace = task_utrace_struct(task);
if (utrace && utrace->utrace_flags & UTRACE_EVENT(EXEC)) {
* Which utrace shall we use?
* (1) Built-in kernel utrace (preferred), indicated by
* CONFIG_UTRACE.
- * (2) Internal utrace. Requires either
- * STAPCONF_UTRACE_VIA_TRACEPOINTS or STAPCONF_UTRACE_VIA_FTRACE.
+ * (2) Internal utrace. Requires STAPCONF_UTRACE_VIA_TRACEPOINTS.
* (3) If we don't have either (old kernels or new kernels without all
* the pre-requisites), error.
*/
// We don't have utrace. For process probes that aren't
// uprobes-based, we just need the task_finder. The task_finder
- // needs CONFIG_TRACEPOINTS and specific tracepoints (and perhaps
- // some CONFIG_FTRACE support). There are specific autoconf tests
- // for its needs.
+ // needs CONFIG_TRACEPOINTS and specific tracepoints. There is a
+ // specific autoconf test for its needs.
//
// We'll just require CONFIG_TRACEPOINTS here as a quick-and-dirty
// approximation.
if {! [catch {exec grep -q utrace_attach $path} dummy]} {
return 1
- # (2) Tracepoint-based utrace. Check for either:
- # (2a) the set of 5 tracepoints we need (see
- # runtime/autoconf-utrace-via-ftrace.c)
- # (2b) the 4 tracepoints and the ftrace function we need (see
- # runtime/autoconf-utrace-via-ftrace.c)
- #
- # Since 4 tracepoints are shared between the 2 methods, that makes
- # things a bit easier.
+ # (2) Tracepoint-based utrace. Check for the set of 5 tracepoints
+ # we need and task_work_add() (see
+ # runtime/autoconf-utrace-via-tracepoints.c for details).
} elseif {! [catch {exec grep -q tracepoint_sched_process_fork $path} dummy]
&& ! [catch {exec grep -q tracepoint_sched_process_exit $path} dummy]
&& ! [catch {exec grep -q tracepoint_sys_enter $path} dummy]
&& ! [catch {exec grep -q tracepoint_sys_exit $path} dummy]
- && (! [catch {exec grep -q tracepoint_sched_process_exec $path} dummy]
- || ! [catch {exec grep -q ftrace_set_filter $path} dummy])} {
+ && ! [catch {exec grep -q tracepoint_sched_process_exec $path} dummy]
+ && ! [catch {exec grep -q tasK_worK_add $path} dummy]} {
return 1
}
return 0