linux/arch/x86/kernel/stacktrace.c
<<
>>
Prefs
   1/*
   2 * Stack trace management functions
   3 *
   4 *  Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
   5 */
   6#include <linux/sched.h>
   7#include <linux/stacktrace.h>
   8#include <linux/module.h>
   9#include <asm/stacktrace.h>
  10
  11static void save_stack_warning(void *data, char *msg)
  12{
  13}
  14
  15static void
  16save_stack_warning_symbol(void *data, char *msg, unsigned long symbol)
  17{
  18}
  19
  20static int save_stack_stack(void *data, char *name)
  21{
  22        return -1;
  23}
  24
  25static void save_stack_address(void *data, unsigned long addr, int reliable)
  26{
  27        struct stack_trace *trace = data;
  28        if (!reliable)
  29                return;
  30        if (trace->skip > 0) {
  31                trace->skip--;
  32                return;
  33        }
  34        if (trace->nr_entries < trace->max_entries)
  35                trace->entries[trace->nr_entries++] = addr;
  36}
  37
  38static void
  39save_stack_address_nosched(void *data, unsigned long addr, int reliable)
  40{
  41        struct stack_trace *trace = (struct stack_trace *)data;
  42        if (!reliable)
  43                return;
  44        if (in_sched_functions(addr))
  45                return;
  46        if (trace->skip > 0) {
  47                trace->skip--;
  48                return;
  49        }
  50        if (trace->nr_entries < trace->max_entries)
  51                trace->entries[trace->nr_entries++] = addr;
  52}
  53
  54static const struct stacktrace_ops save_stack_ops = {
  55        .warning = save_stack_warning,
  56        .warning_symbol = save_stack_warning_symbol,
  57        .stack = save_stack_stack,
  58        .address = save_stack_address,
  59};
  60
  61static const struct stacktrace_ops save_stack_ops_nosched = {
  62        .warning = save_stack_warning,
  63        .warning_symbol = save_stack_warning_symbol,
  64        .stack = save_stack_stack,
  65        .address = save_stack_address_nosched,
  66};
  67
  68/*
  69 * Save stack-backtrace addresses into a stack_trace buffer.
  70 */
  71void save_stack_trace(struct stack_trace *trace)
  72{
  73        dump_trace(current, NULL, NULL, 0, &save_stack_ops, trace);
  74        if (trace->nr_entries < trace->max_entries)
  75                trace->entries[trace->nr_entries++] = ULONG_MAX;
  76}
  77EXPORT_SYMBOL_GPL(save_stack_trace);
  78
  79void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
  80{
  81        dump_trace(tsk, NULL, NULL, 0, &save_stack_ops_nosched, trace);
  82        if (trace->nr_entries < trace->max_entries)
  83                trace->entries[trace->nr_entries++] = ULONG_MAX;
  84}
  85EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
  86
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.