root/tools/include/linux/stacktrace.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. print_stack_trace
  2. dump_stack

   1 /* SPDX-License-Identifier: GPL-2.0 */
   2 #ifndef _LIBLOCKDEP_LINUX_STACKTRACE_H_
   3 #define _LIBLOCKDEP_LINUX_STACKTRACE_H_
   4 
   5 #include <execinfo.h>
   6 
   7 struct stack_trace {
   8         unsigned int nr_entries, max_entries;
   9         unsigned long *entries;
  10         int skip;
  11 };
  12 
  13 static inline void print_stack_trace(struct stack_trace *trace, int spaces)
  14 {
  15         backtrace_symbols_fd((void **)trace->entries, trace->nr_entries, 1);
  16 }
  17 
  18 #define save_stack_trace(trace) \
  19         ((trace)->nr_entries =  \
  20                 backtrace((void **)(trace)->entries, (trace)->max_entries))
  21 
  22 static inline int dump_stack(void)
  23 {
  24         void *array[64];
  25         size_t size;
  26 
  27         size = backtrace(array, 64);
  28         backtrace_symbols_fd(array, size, 1);
  29 
  30         return 0;
  31 }
  32 
  33 #endif

/* [<][>][^][v][top][bottom][index][help] */