[PATCH 11/16] tracing: explain why stack tracer is empty

Steven Rostedt
2009-03-13T02:43:53Z

[-- Attachment #1: 0011-tracing-explain-why-stack-tracer-is-empty.patch --]
[-- Type: text/plain, Size: 1756 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

If the stack tracing is disabled (by default) the stack_trace file
will only contain the header:

# cat /debug/tracing/stack_trace
Depth Size Location (0 entries)
----- ---- --------

This can be frustrating to a developer that does not realize that the
stack tracer is disabled. This patch adds the following text:

# cat /debug/tracing/stack_trace
Depth Size Location (0 entries)
----- ---- --------
#
# Stack tracer disabled
#
# To enable the stack tracer, either add 'stacktrace' to the
# kernel command line
# or 'echo 1 > /proc/sys/kernel/stack_tracer_enabled'
#

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/trace/trace_stack.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 4564fd9..91ccbf3 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -245,6 +245,17 @@ static int trace_lookup_stack(struct seq_file *m, long i)
#endif
}

+static void print_disabled(struct seq_file *m)
+{
+ seq_puts(m, "#\n"
+ "# Stack tracer disabled\n"
+ "#\n"
+ "# To enable the stack tracer, either add 'stacktrace' to the\n"
+ "# kernel command line\n"
+ "# or 'echo 1 > /proc/sys/kernel/stack_tracer_enabled'\n"
+ "#\n");
+}
+
static int t_show(struct seq_file *m, void *v)
{
long i;
@@ -255,6 +266,10 @@ static int t_show(struct seq_file *m, void *v)
" (%d entries)\n"
" ----- ---- --------\n",
max_stack_trace.nr_entries);
+
+ if (!stack_tracer_enabled && !max_stack_size)
+ print_disabled(m);
+
return 0;
}

--
1.6.1.3

--