From 44ad18e0a65e296b2e68a1452509f6222cdce743 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Tue, 16 Jun 2009 19:53:07 -0400 Subject: tracing: update sample event documentation The comments in the sample code is a bit confusing. This patch cleans them up a little. Signed-off-by: Steven Rostedt --- samples/trace_events/Makefile | 8 ++++++++ samples/trace_events/trace-events-sample.h | 27 ++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) (limited to 'samples') diff --git a/samples/trace_events/Makefile b/samples/trace_events/Makefile index 0d428dc67283..0f8d92120c4e 100644 --- a/samples/trace_events/Makefile +++ b/samples/trace_events/Makefile @@ -1,6 +1,14 @@ # builds the trace events example kernel modules; # then to use one (as root): insmod +# If you include a trace header outside of include/trace/events +# then the file that does the #define CREATE_TRACE_POINTS must +# have that tracer file in its main search path. This is because +# define_trace.h will include it, and must be able to find it from +# the include/trace directory. +# +# Here trace-events-sample.c does the CREATE_TRACE_POINTS. +# CFLAGS_trace-events-sample.o := -I$(src) obj-$(CONFIG_SAMPLE_TRACE_EVENTS) += trace-events-sample.o diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index 128a897687c5..9977a756fb32 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h @@ -19,16 +19,21 @@ * If TRACE_SYSTEM is defined, that will be the directory created * in the ftrace directory under /debugfs/tracing/events/ * - * The define_trace.h belowe will also look for a file name of + * The define_trace.h below will also look for a file name of * TRACE_SYSTEM.h where TRACE_SYSTEM is what is defined here. + * In this case, it would look for sample.h * - * If you want a different system than file name, you can override - * the header name by defining TRACE_INCLUDE_FILE + * If the header name will be different than the system name + * (as in this case), then you can override the header name that + * define_trace.h will look up by defining TRACE_INCLUDE_FILE * - * If this file was called, goofy.h, then we would define: + * This file is called trace-events-sample.h but we want the system + * to be called "sample". Therefore we must define the name of this + * file: * - * #define TRACE_INCLUDE_FILE goofy + * #define TRACE_INCLUDE_FILE trace-events-sample * + * As we do an the bottom of this file. */ #undef TRACE_SYSTEM #define TRACE_SYSTEM sample @@ -99,13 +104,13 @@ TRACE_EVENT(foo_bar, * * #define TRACE_INCLUDE_PATH ../../samples/trace_events * - * But I chose to simply make it use the current directory and then in - * the Makefile I added: + * But the safest and easiest way to simply make it use the directory + * that the file is in is to add in the Makefile: * - * CFLAGS_trace-events-sample.o := -I$(PWD)/samples/trace_events/ + * CFLAGS_trace-events-sample.o := -I$(src) * * This will make sure the current path is part of the include - * structure for our file so that we can find it. + * structure for our file so that define_trace.h can find it. * * I could have made only the top level directory the include: * @@ -115,8 +120,8 @@ TRACE_EVENT(foo_bar, * * #define TRACE_INCLUDE_PATH samples/trace_events * - * But then if something defines "samples" or "trace_events" then we - * could risk that being converted too, and give us an unexpected + * But then if something defines "samples" or "trace_events" as a macro + * then we could risk that being converted too, and give us an unexpected * result. */ #undef TRACE_INCLUDE_PATH -- cgit v1.2.3 From d0b6e04a4cd8360e3c9c419f7c30a3081a0c142a Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Mon, 13 Jul 2009 10:33:21 +0800 Subject: tracing/events: Move TRACE_SYSTEM outside of include guard If TRACE_INCLDUE_FILE is defined, will be included and compiled, otherwise it will be So TRACE_SYSTEM should be defined outside of #if proctection, just like TRACE_INCLUDE_FILE. Imaging this scenario: #include -> TRACE_SYSTEM == foo ... #include -> TRACE_SYSTEM == bar ... #define CREATE_TRACE_POINTS #include -> TRACE_SYSTEM == bar !!! and then bar.h will be included and compiled. Signed-off-by: Li Zefan Cc: Steven Rostedt Cc: Frederic Weisbecker LKML-Reference: <4A5A9CF1.2010007@cn.fujitsu.com> Signed-off-by: Ingo Molnar --- samples/trace_events/trace-events-sample.h | 37 ++++++++++++++++-------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'samples') diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index 9977a756fb32..f24ae370e514 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h @@ -1,20 +1,3 @@ -/* - * Notice that this file is not protected like a normal header. - * We also must allow for rereading of this file. The - * - * || defined(TRACE_HEADER_MULTI_READ) - * - * serves this purpose. - */ -#if !defined(_TRACE_EVENT_SAMPLE_H) || defined(TRACE_HEADER_MULTI_READ) -#define _TRACE_EVENT_SAMPLE_H - -/* - * All trace headers should include tracepoint.h, until we finally - * make it into a standard header. - */ -#include - /* * If TRACE_SYSTEM is defined, that will be the directory created * in the ftrace directory under /debugfs/tracing/events/ @@ -34,10 +17,30 @@ * #define TRACE_INCLUDE_FILE trace-events-sample * * As we do an the bottom of this file. + * + * Notice that TRACE_SYSTEM should be defined outside of #if + * protection, just like TRACE_INCLUDE_FILE. */ #undef TRACE_SYSTEM #define TRACE_SYSTEM sample +/* + * Notice that this file is not protected like a normal header. + * We also must allow for rereading of this file. The + * + * || defined(TRACE_HEADER_MULTI_READ) + * + * serves this purpose. + */ +#if !defined(_TRACE_EVENT_SAMPLE_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_EVENT_SAMPLE_H + +/* + * All trace headers should include tracepoint.h, until we finally + * make it into a standard header. + */ +#include + /* * The TRACE_EVENT macro is broken up into 5 parts. * -- cgit v1.2.3