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