trace_events.h 1.4 KB
Newer Older
1 2 3
#ifndef _LINUX_KERNEL_TRACE_EVENTS_H
#define _LINUX_KERNEL_TRACE_EVENTS_H

4
#include <linux/debugfs.h>
5 6 7 8 9
#include <linux/ftrace.h>
#include "trace.h"

struct ftrace_event_call {
	char		*name;
10
	struct dentry	*dir;
11 12 13 14 15 16 17 18 19
	int		enabled;
	int		(*regfunc)(void);
	void		(*unregfunc)(void);
};


#undef TPFMT
#define TPFMT(fmt, args...)	fmt "\n", ##args

20 21
#undef TRACE_FORMAT
#define TRACE_FORMAT(call, proto, args, fmt)				\
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
static void ftrace_event_##call(proto)					\
{									\
	event_trace_printk(_RET_IP_, "(" #call ") " fmt);		\
}									\
									\
static int ftrace_reg_event_##call(void)				\
{									\
	int ret;							\
									\
	ret = register_trace_##call(ftrace_event_##call);		\
	if (!ret)							\
		pr_info("event trace: Could not activate trace point "	\
			"probe to " #call);				\
	return ret;							\
}									\
									\
static void ftrace_unreg_event_##call(void)				\
{									\
	unregister_trace_##call(ftrace_event_##call);			\
}									\
									\
static struct ftrace_event_call __used					\
44
__attribute__((__aligned__(4)))						\
45 46 47 48 49 50 51
__attribute__((section("_ftrace_events"))) event_##call = {		\
	.name 			= #call,				\
	.regfunc		= ftrace_reg_event_##call,		\
	.unregfunc		= ftrace_unreg_event_##call,		\
}

void event_trace_printk(unsigned long ip, const char *fmt, ...);
52 53
extern struct ftrace_event_call __start_ftrace_events[];
extern struct ftrace_event_call __stop_ftrace_events[];
54 55

#endif /* _LINUX_KERNEL_TRACE_EVENTS_H */