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 #include <errno.h> 8 9 #include <rte_eal.h> 10 #include <rte_log.h> 11 #include <rte_debug.h> 12 #include <rte_errno.h> 13 14 void 15 __rte_panic(const char *funcname, const char *format, ...) 16 { 17 va_list ap; 18 19 rte_log(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, "PANIC in %s():\n", funcname); 20 va_start(ap, format); 21 rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); 22 va_end(ap); 23 rte_dump_stack(); 24 abort(); /* generate a coredump if enabled */ 25 } 26 27 /* 28 * Like rte_panic this terminates the application. However, no traceback is 29 * provided and no core-dump is generated. 30 */ 31 void 32 rte_exit(int exit_code, const char *format, ...) 33 { 34 va_list ap; 35 36 if (exit_code != 0) 37 RTE_LOG(CRIT, EAL, "Error - exiting with code: %d\n" 38 " Cause: ", exit_code); 39 40 va_start(ap, format); 41 rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); 42 va_end(ap); 43 44 if (rte_eal_cleanup() != 0 && rte_errno != EALREADY) 45 RTE_LOG(CRIT, EAL, 46 "EAL could not release all resources\n"); 47 exit(exit_code); 48 } 49