stacktrace.c 812 B

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