diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2014-01-07 10:31:04 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2014-01-09 21:20:32 -0500 |
commit | dd97b95438c812d8fd93d9426661a6c8e1520005 (patch) | |
tree | 1fa83336880595da7dc881fde5aab453d17e12ab /kernel/trace | |
parent | 13a1e4aef53b2a7684ddee374e749999ba103b4a (diff) |
tracing: Show available event triggers when no trigger is set
Currently there's no way to know what triggers exist on a kernel without
looking at the source of the kernel or randomly trying out triggers.
Instead of creating another file in the debugfs system, simply show
what available triggers are there when cat'ing the trigger file when
it has no events:
[root /sys/kernel/debug/tracing]# cat events/sched/sched_switch/trigger
# Available triggers:
# traceon traceoff snapshot stacktrace enable_event disable_event
This stays consistent with other debugfs files where meta data like
this is always proceeded with a '#' at the start of the line so that
tools can strip these out.
Link: http://lkml.kernel.org/r/20140107103548.0a84536d@gandalf.local.home
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/trace_events_trigger.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c index a53e0da7e333..8efbb69b04f0 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c | |||
@@ -115,10 +115,15 @@ event_triggers_post_call(struct ftrace_event_file *file, | |||
115 | } | 115 | } |
116 | EXPORT_SYMBOL_GPL(event_triggers_post_call); | 116 | EXPORT_SYMBOL_GPL(event_triggers_post_call); |
117 | 117 | ||
118 | #define SHOW_AVAILABLE_TRIGGERS (void *)(1UL) | ||
119 | |||
118 | static void *trigger_next(struct seq_file *m, void *t, loff_t *pos) | 120 | static void *trigger_next(struct seq_file *m, void *t, loff_t *pos) |
119 | { | 121 | { |
120 | struct ftrace_event_file *event_file = event_file_data(m->private); | 122 | struct ftrace_event_file *event_file = event_file_data(m->private); |
121 | 123 | ||
124 | if (t == SHOW_AVAILABLE_TRIGGERS) | ||
125 | return NULL; | ||
126 | |||
122 | return seq_list_next(t, &event_file->triggers, pos); | 127 | return seq_list_next(t, &event_file->triggers, pos); |
123 | } | 128 | } |
124 | 129 | ||
@@ -132,6 +137,9 @@ static void *trigger_start(struct seq_file *m, loff_t *pos) | |||
132 | if (unlikely(!event_file)) | 137 | if (unlikely(!event_file)) |
133 | return ERR_PTR(-ENODEV); | 138 | return ERR_PTR(-ENODEV); |
134 | 139 | ||
140 | if (list_empty(&event_file->triggers)) | ||
141 | return *pos == 0 ? SHOW_AVAILABLE_TRIGGERS : NULL; | ||
142 | |||
135 | return seq_list_start(&event_file->triggers, *pos); | 143 | return seq_list_start(&event_file->triggers, *pos); |
136 | } | 144 | } |
137 | 145 | ||
@@ -143,6 +151,18 @@ static void trigger_stop(struct seq_file *m, void *t) | |||
143 | static int trigger_show(struct seq_file *m, void *v) | 151 | static int trigger_show(struct seq_file *m, void *v) |
144 | { | 152 | { |
145 | struct event_trigger_data *data; | 153 | struct event_trigger_data *data; |
154 | struct event_command *p; | ||
155 | |||
156 | if (v == SHOW_AVAILABLE_TRIGGERS) { | ||
157 | seq_puts(m, "# Available triggers:\n"); | ||
158 | seq_putc(m, '#'); | ||
159 | mutex_lock(&trigger_cmd_mutex); | ||
160 | list_for_each_entry_reverse(p, &trigger_commands, list) | ||
161 | seq_printf(m, " %s", p->name); | ||
162 | seq_putc(m, '\n'); | ||
163 | mutex_unlock(&trigger_cmd_mutex); | ||
164 | return 0; | ||
165 | } | ||
146 | 166 | ||
147 | data = list_entry(v, struct event_trigger_data, list); | 167 | data = list_entry(v, struct event_trigger_data, list); |
148 | data->ops->print(m, data->ops, data); | 168 | data->ops->print(m, data->ops, data); |