Skip to content

Commit c142be8

Browse files
committed
tracing: Add skip argument to trace_dump_stack()
Altough the trace_dump_stack() already skips three functions in the call to stack trace, which gets the stack trace to start at the caller of the function, the caller may want to skip some more too (as it may have helper functions). Add a skip argument to the trace_dump_stack() that lets the caller skip back tracing functions that it doesn't care about. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 3cd715d commit c142be8

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎include/linux/kernel.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ extern int __trace_puts(unsigned long ip, const char *str, int size);
597597
__trace_puts(_THIS_IP_, str, strlen(str)); \
598598
})
599599

600-
extern void trace_dump_stack(void);
600+
extern void trace_dump_stack(int skip);
601601

602602
/*
603603
* The double __builtin_constant_p is because gcc will give us an error

‎kernel/trace/trace.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,8 +1657,9 @@ void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
16571657

16581658
/**
16591659
* trace_dump_stack - record a stack back trace in the trace buffer
1660+
* @skip: Number of functions to skip (helper handlers)
16601661
*/
1661-
void trace_dump_stack(void)
1662+
void trace_dump_stack(int skip)
16621663
{
16631664
unsigned long flags;
16641665

@@ -1667,9 +1668,13 @@ void trace_dump_stack(void)
16671668

16681669
local_save_flags(flags);
16691670

1670-
/* skipping 3 traces, seems to get us at the caller of this function */
1671-
__ftrace_trace_stack(global_trace.trace_buffer.buffer, flags, 3,
1672-
preempt_count(), NULL);
1671+
/*
1672+
* Skip 3 more, seems to get us at the caller of
1673+
* this function.
1674+
*/
1675+
skip += 3;
1676+
__ftrace_trace_stack(global_trace.trace_buffer.buffer,
1677+
flags, skip, preempt_count(), NULL);
16731678
}
16741679

16751680
static DEFINE_PER_CPU(int, user_stack_count);

0 commit comments

Comments
 (0)