diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-03-05 21:35:29 -0500 |
---|---|---|
committer | Steven Rostedt <srostedt@redhat.com> | 2009-03-05 21:46:44 -0500 |
commit | 770cb24345c0f6e0d47bd2b94aa6d67bea6f8b54 (patch) | |
tree | ec76651c686c02249c1455446801cf2b9d823879 /kernel/trace/trace_export.c | |
parent | 33b0c229e3abeae00493ed1d6f0b07191977a0a2 (diff) |
tracing: add format files for ftrace default entries
Impact: allow user apps to read binary format of basic ftrace entries
Currently, only defined raw events export their formats so a binary
reader can parse them. There's no reason that the default ftrace entries
can't export their formats.
This patch adds a subsystem called "ftrace" in the events directory
that includes the ftrace entries for basic ftrace recorded items.
These only have three files in the events directory:
type : printf
available_types : printf
format : format for the event entry
For example:
# cat /debug/tracing/events/ftrace/wakeup/format
name: wakeup
ID: 3
format:
field:unsigned char type; offset:0; size:1;
field:unsigned char flags; offset:1; size:1;
field:unsigned char preempt_count; offset:2; size:1;
field:int pid; offset:4; size:4;
field:int tgid; offset:8; size:4;
field:unsigned int prev_pid; offset:12; size:4;
field:unsigned char prev_prio; offset:16; size:1;
field:unsigned char prev_state; offset:17; size:1;
field:unsigned int next_pid; offset:20; size:4;
field:unsigned char next_prio; offset:24; size:1;
field:unsigned char next_state; offset:25; size:1;
field:unsigned int next_cpu; offset:28; size:4;
print fmt: "%u:%u:%u ==+ %u:%u:%u [%03u]"
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Diffstat (limited to 'kernel/trace/trace_export.c')
-rw-r--r-- | kernel/trace/trace_export.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c new file mode 100644 index 000000000000..0fb7be73e31c --- /dev/null +++ b/kernel/trace/trace_export.c | |||
@@ -0,0 +1,81 @@ | |||
1 | /* | ||
2 | * trace_export.c - export basic ftrace utilities to user space | ||
3 | * | ||
4 | * Copyright (C) 2009 Steven Rostedt <srostedt@redhat.com> | ||
5 | */ | ||
6 | #include <linux/stringify.h> | ||
7 | #include <linux/kallsyms.h> | ||
8 | #include <linux/seq_file.h> | ||
9 | #include <linux/debugfs.h> | ||
10 | #include <linux/uaccess.h> | ||
11 | #include <linux/ftrace.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/fs.h> | ||
15 | |||
16 | #include "trace_output.h" | ||
17 | |||
18 | #include "trace_format.h" | ||
19 | |||
20 | #undef TRACE_FIELD_ZERO_CHAR | ||
21 | #define TRACE_FIELD_ZERO_CHAR(item) \ | ||
22 | ret = trace_seq_printf(s, "\tfield: char " #item ";\t" \ | ||
23 | "offset:%lu;\tsize:0;\n", \ | ||
24 | offsetof(typeof(field), item)); \ | ||
25 | if (!ret) \ | ||
26 | return 0; | ||
27 | |||
28 | |||
29 | #undef TPRAWFMT | ||
30 | #define TPRAWFMT(args...) args | ||
31 | |||
32 | #undef TRACE_EVENT_FORMAT | ||
33 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ | ||
34 | static int \ | ||
35 | ftrace_format_##call(struct trace_seq *s) \ | ||
36 | { \ | ||
37 | struct args field; \ | ||
38 | int ret; \ | ||
39 | \ | ||
40 | tstruct; \ | ||
41 | \ | ||
42 | trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \ | ||
43 | \ | ||
44 | return ret; \ | ||
45 | } | ||
46 | |||
47 | #include "trace_event_types.h" | ||
48 | |||
49 | #undef TRACE_ZERO_CHAR | ||
50 | #define TRACE_ZERO_CHAR(arg) | ||
51 | |||
52 | #undef TRACE_FIELD | ||
53 | #define TRACE_FIELD(type, item, assign)\ | ||
54 | entry->item = assign; | ||
55 | |||
56 | #undef TRACE_FIELD | ||
57 | #define TRACE_FIELD(type, item, assign)\ | ||
58 | entry->item = assign; | ||
59 | |||
60 | #undef TPCMD | ||
61 | #define TPCMD(cmd...) cmd | ||
62 | |||
63 | #undef TRACE_ENTRY | ||
64 | #define TRACE_ENTRY entry | ||
65 | |||
66 | #undef TRACE_FIELD_SPECIAL | ||
67 | #define TRACE_FIELD_SPECIAL(type_item, item, cmd) \ | ||
68 | cmd; | ||
69 | |||
70 | #undef TRACE_EVENT_FORMAT | ||
71 | #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ | ||
72 | \ | ||
73 | static struct ftrace_event_call __used \ | ||
74 | __attribute__((__aligned__(4))) \ | ||
75 | __attribute__((section("_ftrace_events"))) event_##call = { \ | ||
76 | .name = #call, \ | ||
77 | .id = proto, \ | ||
78 | .system = __stringify(TRACE_SYSTEM), \ | ||
79 | .show_format = ftrace_format_##call, \ | ||
80 | } | ||
81 | #include "trace_event_types.h" | ||