From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0F3F4A00BE; Mon, 8 Jun 2020 10:32:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 062F61BE81; Mon, 8 Jun 2020 10:32:41 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 85B791BE7D for ; Mon, 8 Jun 2020 10:32:39 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from talshn@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Jun 2020 11:32:34 +0300 Received: from l-wincomp04-vm.labs.mlnx (l-wincomp04-vm.mtl.labs.mlnx [10.237.1.5]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0588WYTD028036; Mon, 8 Jun 2020 11:32:34 +0300 From: talshn@mellanox.com To: dev@dpdk.org Cc: thomas@monjalon.net, pallavi.kadam@intel.com, dmitry.kozliuk@gmail.com, david.marchand@redhat.com, ranjit.menon@intel.com, navasile@linux.microsoft.com, harini.ramakrishnan@microsoft.com, ocardona@microsoft.com, bruce.richardson@intel.com, Tal Shnaiderman Date: Mon, 8 Jun 2020 11:32:26 +0300 Message-Id: <20200608083227.16020-2-talshn@mellanox.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20200608083227.16020-1-talshn@mellanox.com> References: <20200608083227.16020-1-talshn@mellanox.com> Subject: [dpdk-dev] [PATCH v2 1/2] eal: move OS common debug functions to single file X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Tal Shnaiderman Move common functions between Unix and Windows to eal_common_debug.c. Those functions are rte_exit, __rte_panic and rte_dump_registers which has the same implementation on Unix and Windows. Signed-off-by: Tal Shnaiderman --- lib/librte_eal/common/eal_common_debug.c | 58 ++++++++++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 1 + lib/librte_eal/freebsd/Makefile | 1 + lib/librte_eal/freebsd/eal_debug.c | 49 --------------------------- lib/librte_eal/linux/Makefile | 1 + lib/librte_eal/linux/eal_debug.c | 49 --------------------------- 6 files changed, 61 insertions(+), 98 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_debug.c diff --git a/lib/librte_eal/common/eal_common_debug.c b/lib/librte_eal/common/eal_common_debug.c new file mode 100644 index 0000000000..ae4bee675d --- /dev/null +++ b/lib/librte_eal/common/eal_common_debug.c @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2020 Mellanox Technologies, Ltd + */ +#include +#include +#include +#include + +/* not implemented */ +void +rte_dump_registers(void) +{ + return; +} + +/* call abort(), it will generate a coredump if enabled */ +void +__rte_panic(const char *funcname, const char *format, ...) +{ + va_list ap; + + rte_log(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, "PANIC in %s():\n", funcname); + va_start(ap, format); + rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); + va_end(ap); + rte_dump_stack(); + rte_dump_registers(); + abort(); +} + +/* + * Like rte_panic this terminates the application. However, no traceback is + * provided and no core-dump is generated. + */ +void +rte_exit(int exit_code, const char *format, ...) +{ + va_list ap; + + if (exit_code != 0) + RTE_LOG(CRIT, EAL, "Error - exiting with code: %d\n" + " Cause: ", exit_code); + + va_start(ap, format); + rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); + va_end(ap); + +#ifndef RTE_EAL_ALWAYS_PANIC_ON_ERROR + if (rte_eal_cleanup() != 0) + RTE_LOG(CRIT, EAL, + "EAL could not release all resources\n"); + exit(exit_code); +#else + rte_dump_stack(); + rte_dump_registers(); + abort(); +#endif +} diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build index 55aaeb18e1..2bde920597 100644 --- a/lib/librte_eal/common/meson.build +++ b/lib/librte_eal/common/meson.build @@ -22,6 +22,7 @@ sources += files( 'eal_common_bus.c', 'eal_common_cpuflags.c', 'eal_common_class.c', + 'eal_common_debug.c', 'eal_common_devargs.c', 'eal_common_dev.c', 'eal_common_errno.c', diff --git a/lib/librte_eal/freebsd/Makefile b/lib/librte_eal/freebsd/Makefile index af95386d48..81fa1f29c6 100644 --- a/lib/librte_eal/freebsd/Makefile +++ b/lib/librte_eal/freebsd/Makefile @@ -51,6 +51,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_cpuflags.c SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_hypervisor.c SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_string_fns.c SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_hexdump.c +SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_debug.c SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_devargs.c SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_class.c SRCS-$(CONFIG_RTE_EXEC_ENV_FREEBSD) += eal_common_bus.c diff --git a/lib/librte_eal/freebsd/eal_debug.c b/lib/librte_eal/freebsd/eal_debug.c index 5d92500bf5..64dab4e0da 100644 --- a/lib/librte_eal/freebsd/eal_debug.c +++ b/lib/librte_eal/freebsd/eal_debug.c @@ -41,52 +41,3 @@ void rte_dump_stack(void) free(symb); #endif /* RTE_BACKTRACE */ } - -/* not implemented in this environment */ -void rte_dump_registers(void) -{ - return; -} - -/* call abort(), it will generate a coredump if enabled */ -void __rte_panic(const char *funcname, const char *format, ...) -{ - va_list ap; - - rte_log(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, "PANIC in %s():\n", funcname); - va_start(ap, format); - rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); - va_end(ap); - rte_dump_stack(); - rte_dump_registers(); - abort(); -} - -/* - * Like rte_panic this terminates the application. However, no traceback is - * provided and no core-dump is generated. - */ -void -rte_exit(int exit_code, const char *format, ...) -{ - va_list ap; - - if (exit_code != 0) - RTE_LOG(CRIT, EAL, "Error - exiting with code: %d\n" - " Cause: ", exit_code); - - va_start(ap, format); - rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); - va_end(ap); - -#ifndef RTE_EAL_ALWAYS_PANIC_ON_ERROR - if (rte_eal_cleanup() != 0) - RTE_LOG(CRIT, EAL, - "EAL could not release all resources\n"); - exit(exit_code); -#else - rte_dump_stack(); - rte_dump_registers(); - abort(); -#endif -} diff --git a/lib/librte_eal/linux/Makefile b/lib/librte_eal/linux/Makefile index 48cc34844a..77da140bee 100644 --- a/lib/librte_eal/linux/Makefile +++ b/lib/librte_eal/linux/Makefile @@ -58,6 +58,7 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_cpuflags.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_hypervisor.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_string_fns.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_hexdump.c +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_debug.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_devargs.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_class.c SRCS-$(CONFIG_RTE_EXEC_ENV_LINUX) += eal_common_bus.c diff --git a/lib/librte_eal/linux/eal_debug.c b/lib/librte_eal/linux/eal_debug.c index 5d92500bf5..64dab4e0da 100644 --- a/lib/librte_eal/linux/eal_debug.c +++ b/lib/librte_eal/linux/eal_debug.c @@ -41,52 +41,3 @@ void rte_dump_stack(void) free(symb); #endif /* RTE_BACKTRACE */ } - -/* not implemented in this environment */ -void rte_dump_registers(void) -{ - return; -} - -/* call abort(), it will generate a coredump if enabled */ -void __rte_panic(const char *funcname, const char *format, ...) -{ - va_list ap; - - rte_log(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, "PANIC in %s():\n", funcname); - va_start(ap, format); - rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); - va_end(ap); - rte_dump_stack(); - rte_dump_registers(); - abort(); -} - -/* - * Like rte_panic this terminates the application. However, no traceback is - * provided and no core-dump is generated. - */ -void -rte_exit(int exit_code, const char *format, ...) -{ - va_list ap; - - if (exit_code != 0) - RTE_LOG(CRIT, EAL, "Error - exiting with code: %d\n" - " Cause: ", exit_code); - - va_start(ap, format); - rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap); - va_end(ap); - -#ifndef RTE_EAL_ALWAYS_PANIC_ON_ERROR - if (rte_eal_cleanup() != 0) - RTE_LOG(CRIT, EAL, - "EAL could not release all resources\n"); - exit(exit_code); -#else - rte_dump_stack(); - rte_dump_registers(); - abort(); -#endif -} -- 2.16.1.windows.4