xref: /dpdk/lib/eal/common/eal_common_debug.c (revision 8f1d23ece06adff5eae9f1b4365bdbbd3abee2b2)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 #include <stdarg.h>
6 #include <stdlib.h>
7 
8 #include <rte_eal.h>
9 #include <rte_log.h>
10 #include <rte_debug.h>
11 
12 void
13 __rte_panic(const char *funcname, const char *format, ...)
14 {
15 	va_list ap;
16 
17 	rte_log(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, "PANIC in %s():\n", funcname);
18 	va_start(ap, format);
19 	rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap);
20 	va_end(ap);
21 	rte_dump_stack();
22 	abort(); /* generate a coredump if enabled */
23 }
24 
25 /*
26  * Like rte_panic this terminates the application. However, no traceback is
27  * provided and no core-dump is generated.
28  */
29 void
30 rte_exit(int exit_code, const char *format, ...)
31 {
32 	va_list ap;
33 
34 	if (exit_code != 0)
35 		RTE_LOG(CRIT, EAL, "Error - exiting with code: %d\n"
36 				"  Cause: ", exit_code);
37 
38 	va_start(ap, format);
39 	rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap);
40 	va_end(ap);
41 
42 	if (rte_eal_cleanup() != 0)
43 		RTE_LOG(CRIT, EAL,
44 			"EAL could not release all resources\n");
45 	exit(exit_code);
46 }
47