stacktrace.c 845 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * arch/sh/kernel/stacktrace.c
  3. *
  4. * Stack trace management functions
  5. *
  6. * Copyright (C) 2006 Paul Mundt
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/sched.h>
  13. #include <linux/stacktrace.h>
  14. #include <linux/thread_info.h>
  15. #include <asm/ptrace.h>
  16. /*
  17. * Save stack-backtrace addresses into a stack_trace buffer.
  18. */
  19. void save_stack_trace(struct stack_trace *trace)
  20. {
  21. unsigned long *sp = (unsigned long *)current_stack_pointer;
  22. while (!kstack_end(sp)) {
  23. unsigned long addr = *sp++;
  24. if (__kernel_text_address(addr)) {
  25. if (trace->skip > 0)
  26. trace->skip--;
  27. else
  28. trace->entries[trace->nr_entries++] = addr;
  29. if (trace->nr_entries >= trace->max_entries)
  30. break;
  31. }
  32. }
  33. }