File: stacktrace.h

package info (click to toggle)
linux-tools 3.16-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 73,776 kB
  • sloc: ansic: 962,256; perl: 14,061; makefile: 6,629; sh: 5,629; cpp: 5,599; python: 4,547; asm: 4,106; yacc: 2,566; lex: 1,436; pascal: 80; awk: 6
file content (32 lines) | stat: -rw-r--r-- 639 bytes parent folder | download | duplicates (23)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef _LIBLOCKDEP_LINUX_STACKTRACE_H_
#define _LIBLOCKDEP_LINUX_STACKTRACE_H_

#include <execinfo.h>

struct stack_trace {
	unsigned int nr_entries, max_entries;
	unsigned long *entries;
	int skip;
};

static inline void print_stack_trace(struct stack_trace *trace, int spaces)
{
	backtrace_symbols_fd((void **)trace->entries, trace->nr_entries, 1);
}

#define save_stack_trace(trace)	\
	((trace)->nr_entries =	\
		backtrace((void **)(trace)->entries, (trace)->max_entries))

static inline int dump_stack(void)
{
	void *array[64];
	size_t size;

	size = backtrace(array, 64);
	backtrace_symbols_fd(array, size, 1);

	return 0;
}

#endif