diff options
| author | 2017-08-04 16:49:38 +0200 | |
|---|---|---|
| committer | 2017-08-04 16:50:18 +0200 | |
| commit | 74be62c7cefbf320e0605f3da6639ef80448ff00 (patch) | |
| tree | ea45fa2e0b343b792a03a66058b26a8d3e736787 /tools/include/linux/stacktrace.h | |
| parent | ALSA: hda: constify pci_device_id. (diff) | |
| parent | Merge tag 'asoc-fix-v4.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus (diff) | |
Merge branch 'for-linus' into for-next
Back-merge 4.13-rc devel branch for later development.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'tools/include/linux/stacktrace.h')
| -rw-r--r-- | tools/include/linux/stacktrace.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/include/linux/stacktrace.h b/tools/include/linux/stacktrace.h new file mode 100644 index 000000000000..39aecc6b19d1 --- /dev/null +++ b/tools/include/linux/stacktrace.h @@ -0,0 +1,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 |
