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