x86: add save_stack_trace_bp() for tracing from a specific stack frame
authorVegard Nossum <vegard.nossum@gmail.com>
Tue, 20 May 2008 09:15:43 +0000 (11:15 +0200)
committerVegard Nossum <vegard.nossum@gmail.com>
Fri, 12 Jun 2009 21:01:05 +0000 (23:01 +0200)
This will help kmemcheck (and possibly other debugging tools) since we
can now simply pass regs->bp to the stack tracer instead of specifying
the number of stack frames to skip, which is unreliable if gcc decides
to inline functions, etc.

Note that this makes the API incomplete for other architectures, but I
expect that those can be updated lazily, e.g. when they need it.

Cc: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
arch/x86/kernel/stacktrace.c
include/linux/stacktrace.h

index 4aaf7e48394fb562343f27d811e7a9f329be2b76..c3eb207181feeef5be791127b61798b432935cc4 100644 (file)
@@ -77,6 +77,13 @@ void save_stack_trace(struct stack_trace *trace)
 }
 EXPORT_SYMBOL_GPL(save_stack_trace);
 
+void save_stack_trace_bp(struct stack_trace *trace, unsigned long bp)
+{
+       dump_trace(current, NULL, NULL, bp, &save_stack_ops, trace);
+       if (trace->nr_entries < trace->max_entries)
+               trace->entries[trace->nr_entries++] = ULONG_MAX;
+}
+
 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 {
        dump_trace(tsk, NULL, NULL, 0, &save_stack_ops_nosched, trace);
index 1a8cecc4f38cd2b91a90f267a54fd39bb4de196b..551f6c7d50443d22ba04439d572823a6a66e7529 100644 (file)
@@ -11,6 +11,7 @@ struct stack_trace {
 };
 
 extern void save_stack_trace(struct stack_trace *trace);
+extern void save_stack_trace_bp(struct stack_trace *trace, unsigned long bp);
 extern void save_stack_trace_tsk(struct task_struct *tsk,
                                struct stack_trace *trace);