199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 299a2dd95SBruce Richardson * Copyright(c) 2010-2014 Intel Corporation 399a2dd95SBruce Richardson */ 499a2dd95SBruce Richardson 599a2dd95SBruce Richardson #include <stdarg.h> 672b452c5SDmitry Kozlyuk #include <stdlib.h> 7a4a2ac98SBruce Richardson #include <errno.h> 872b452c5SDmitry Kozlyuk 999a2dd95SBruce Richardson #include <rte_eal.h> 1099a2dd95SBruce Richardson #include <rte_log.h> 1199a2dd95SBruce Richardson #include <rte_debug.h> 12a4a2ac98SBruce Richardson #include <rte_errno.h> 1399a2dd95SBruce Richardson 14ae67895bSDavid Marchand #include "eal_private.h" 15ae67895bSDavid Marchand 1699a2dd95SBruce Richardson void 1799a2dd95SBruce Richardson __rte_panic(const char *funcname, const char *format, ...) 1899a2dd95SBruce Richardson { 1999a2dd95SBruce Richardson va_list ap; 2099a2dd95SBruce Richardson 21ae67895bSDavid Marchand EAL_LOG(CRIT, "PANIC in %s():", funcname); 2299a2dd95SBruce Richardson va_start(ap, format); 2399a2dd95SBruce Richardson rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); 2499a2dd95SBruce Richardson va_end(ap); 2599a2dd95SBruce Richardson rte_dump_stack(); 2699a2dd95SBruce Richardson abort(); /* generate a coredump if enabled */ 2799a2dd95SBruce Richardson } 2899a2dd95SBruce Richardson 2999a2dd95SBruce Richardson /* 3099a2dd95SBruce Richardson * Like rte_panic this terminates the application. However, no traceback is 3199a2dd95SBruce Richardson * provided and no core-dump is generated. 3299a2dd95SBruce Richardson */ 3399a2dd95SBruce Richardson void 3499a2dd95SBruce Richardson rte_exit(int exit_code, const char *format, ...) 3599a2dd95SBruce Richardson { 3699a2dd95SBruce Richardson va_list ap; 3799a2dd95SBruce Richardson 3899a2dd95SBruce Richardson if (exit_code != 0) 39*c4e03acaSStephen Hemminger EAL_LOG(CRIT, "Error - exiting with code: %d", exit_code); 4099a2dd95SBruce Richardson 4199a2dd95SBruce Richardson va_start(ap, format); 4299a2dd95SBruce Richardson rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); 4399a2dd95SBruce Richardson va_end(ap); 4499a2dd95SBruce Richardson 45a4a2ac98SBruce Richardson if (rte_eal_cleanup() != 0 && rte_errno != EALREADY) 46*c4e03acaSStephen Hemminger EAL_LOG(CRIT, "EAL could not release all resources"); 4799a2dd95SBruce Richardson exit(exit_code); 4899a2dd95SBruce Richardson } 49