stacktrace.c 776 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * arch/ia64/kernel/stacktrace.c
  3. *
  4. * Stack trace management functions
  5. *
  6. */
  7. #include <linux/sched.h>
  8. #include <linux/stacktrace.h>
  9. #include <linux/module.h>
  10. static void
  11. ia64_do_save_stack(struct unw_frame_info *info, void *arg)
  12. {
  13. struct stack_trace *trace = arg;
  14. unsigned long ip;
  15. int skip = trace->skip;
  16. trace->nr_entries = 0;
  17. do {
  18. unw_get_ip(info, &ip);
  19. if (ip == 0)
  20. break;
  21. if (skip == 0) {
  22. trace->entries[trace->nr_entries++] = ip;
  23. if (trace->nr_entries == trace->max_entries)
  24. break;
  25. } else
  26. skip--;
  27. } while (unw_unwind(info) >= 0);
  28. }
  29. /*
  30. * Save stack-backtrace addresses into a stack_trace buffer.
  31. */
  32. void save_stack_trace(struct stack_trace *trace)
  33. {
  34. unw_init_running(ia64_do_save_stack, trace);
  35. }
  36. EXPORT_SYMBOL(save_stack_trace);