Skip to contentSkip to conversation

tracing: use defined fields to print formats

PATCH Superseded Lai Jiangshan 1 participant 1 message Jul 22, 2009

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tracing: use defined fields to print formats

It seems that ftrace_format_##call() and ftrace_define_fields_##call() are duplicate more or less.

trace_define_field() defines fields and links them into strcut ftrace_event_call. We reuse them to print formats and remove ftrace_format_##call(). It make all things simpler.

TRACE_EVENT_FORMAT_NOFILTER is dropped. Because we should "trace_define_field()" fields for all struct ftrace_event_call, even it's no filter.

Only two things are changed between the old and the new format:

1) for __array()
TYPE ITEM[LEN] ==> TYPE[LEN] ITEM

2)
In events/ftrace/bprint/format
field:char buf; offset:20; size:0;
==> field:u32[] buf; offset:20; size:0;

In events/ftrace/print/format
field:char buf; offset:16; size:0;
==>field:char[] buf; offset:16; size:0;

changed from v1:
carefully compare the old and the new format, and fix the difference.

---
 include/linux/ftrace_event.h     |    2
 include/trace/ftrace.h           |   79 +++--------------------------
 kernel/trace/trace.h             |    2
 kernel/trace/trace_event_types.h |    6 +-
 kernel/trace/trace_events.c      |   59 ++++++++-------------
 kernel/trace/trace_export.c      |  106 ++++-----------------------------------
 6 files changed, 50 insertions(+), 204 deletions(-)
include/linux/ftrace_event.h +1 -1
index 5c093ff..738b33d 100644
@@ -111,8 +111,8 @@ struct ftrace_event_call {
 	int			(*regfunc)(void);
 	void			(*unregfunc)(void);
 	int			id;
+	const char		*print_fmt;
 	int			(*raw_init)(void);
-	int			(*show_format)(struct trace_seq *s);
 	int			(*define_fields)(void);
 	struct list_head	fields;
 	int			filter_active;
include/trace/ftrace.h +10 -69

137 lines not on this page · raw message

kernel/trace/trace.h +0 -2
index 06886a0..1551c45 100644
@@ -867,8 +867,6 @@ extern const char *__stop___trace_bprintk_fmt[];
 #undef TRACE_EVENT_FORMAT
 #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt)	\
 	extern struct ftrace_event_call event_##call;
-#undef TRACE_EVENT_FORMAT_NOFILTER
-#define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, tpfmt)
 #include "trace_event_types.h"
 
 #endif /* _LINUX_KERNEL_TRACE_H */
kernel/trace/trace_event_types.h +3 -3
index 6db005e..5b78571 100644
@@ -60,7 +60,7 @@ TRACE_EVENT_FORMAT(context_switch, TRACE_CTX, ctx_switch_entry, ignore,
 	TP_RAW_FMT("%u:%u:%u  ==+ %u:%u:%u [%03u]")
 );
 
-TRACE_EVENT_FORMAT_NOFILTER(special, TRACE_SPECIAL, special_entry, ignore,
+TRACE_EVENT_FORMAT(special, TRACE_SPECIAL, special_entry, ignore,
 	TRACE_STRUCT(
 		TRACE_FIELD(unsigned long, arg1, arg1)
 		TRACE_FIELD(unsigned long, arg2, arg2)
@@ -109,7 +109,7 @@ TRACE_EVENT_FORMAT(bprint, TRACE_BPRINT, bprint_entry, ignore,
 	TRACE_STRUCT(
 		TRACE_FIELD(unsigned long, ip, ip)
 		TRACE_FIELD(char *, fmt, fmt)
-		TRACE_FIELD_ZERO_CHAR(buf)
+		TRACE_FIELD_DYNAMIC_ARRAY(u32, buf)
 	),
 	TP_RAW_FMT("%08lx (%d) fmt:%p %s")
 );
@@ -117,7 +117,7 @@ TRACE_EVENT_FORMAT(bprint, TRACE_BPRINT, bprint_entry, ignore,
 TRACE_EVENT_FORMAT(print, TRACE_PRINT, print_entry, ignore,
 	TRACE_STRUCT(
 		TRACE_FIELD(unsigned long, ip, ip)
-		TRACE_FIELD_ZERO_CHAR(buf)
+		TRACE_FIELD_DYNAMIC_ARRAY(char, buf)
 	),
 	TP_RAW_FMT("%08lx (%d) fmt:%p %s")
 );
kernel/trace/trace_events.c +23 -36

95 lines not on this page · raw message

kernel/trace/trace_export.c +13 -93

148 lines not on this page · raw message