xref: /dpdk/lib/eal/linux/eal_debug.c (revision 0f6bbf4e)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 #ifdef RTE_BACKTRACE
6 #include <execinfo.h>
7 #endif
8 #include <stdlib.h>
9 #include <stdio.h>
10 
11 #include <rte_log.h>
12 #include <rte_debug.h>
13 
14 #define BACKTRACE_SIZE 256
15 
16 /* dump the stack of the calling core */
17 void rte_dump_stack(void)
18 {
19 #ifdef RTE_BACKTRACE
20 	void *func[BACKTRACE_SIZE];
21 	char **symb = NULL;
22 	int size;
23 
24 	size = backtrace(func, BACKTRACE_SIZE);
25 	symb = backtrace_symbols(func, size);
26 
27 	if (symb == NULL)
28 		return;
29 
30 	while (size > 0) {
31 		rte_log(RTE_LOG_ERR, RTE_LOGTYPE_EAL,
32 			"%d: [%s]\n", size, symb[size - 1]);
33 		size --;
34 	}
35 
36 	free(symb);
37 #endif /* RTE_BACKTRACE */
38 }
39