* [dpdk-dev] [PATCH v2 0/2] Support EAL debug functions on Windows @ 2020-06-08 8:32 talshn 2020-06-08 8:32 ` [dpdk-dev] [PATCH v2 1/2] eal: move OS common debug functions to single file talshn 2020-06-08 8:32 ` [dpdk-dev] [PATCH v2 2/2] eal/windows: support debug calls talshn 0 siblings, 2 replies; 9+ messages in thread From: talshn @ 2020-06-08 8:32 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, david.marchand, ranjit.menon, navasile, harini.ramakrishnan, ocardona, bruce.richardson, Tal Shnaiderman From: Tal Shnaiderman <talshn@mellanox.com> This patchset adds support for the EAL debug function on Windows by implementing backtracing in rte_dump_stack and cleanup calls in rte_eal_cleanup. Additionally, the functions rte_exit, __rte_panic and rte_dump_registers were moved to a common file to avoid code duplication. --- v2: Fix style and cross-compiling MinGW-w64 on Linux error[DmitryK] --- Tal Shnaiderman (2): eal: move OS common debug functions to single file eal/windows: support debug calls config/meson.build | 1 + lib/librte_eal/common/eal_common_debug.c | 58 ++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 2 + 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 -------------------- lib/librte_eal/windows/eal.c | 7 +++ lib/librte_eal/windows/eal_debug.c | 76 ++++++++++++++++++++++++++++---- 9 files changed, 138 insertions(+), 106 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_debug.c -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [dpdk-dev] [PATCH v2 1/2] eal: move OS common debug functions to single file 2020-06-08 8:32 [dpdk-dev] [PATCH v2 0/2] Support EAL debug functions on Windows talshn @ 2020-06-08 8:32 ` talshn 2020-06-23 17:46 ` Thomas Monjalon 2020-06-23 20:57 ` [dpdk-dev] [PATCH v3 0/2] Support EAL debug functions on Windows talshn 2020-06-08 8:32 ` [dpdk-dev] [PATCH v2 2/2] eal/windows: support debug calls talshn 1 sibling, 2 replies; 9+ messages in thread From: talshn @ 2020-06-08 8:32 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, david.marchand, ranjit.menon, navasile, harini.ramakrishnan, ocardona, bruce.richardson, Tal Shnaiderman From: Tal Shnaiderman <talshn@mellanox.com> 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 <talshn@mellanox.com> --- 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 <stdarg.h> +#include <rte_eal.h> +#include <rte_log.h> +#include <rte_debug.h> + +/* 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 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/2] eal: move OS common debug functions to single file 2020-06-08 8:32 ` [dpdk-dev] [PATCH v2 1/2] eal: move OS common debug functions to single file talshn @ 2020-06-23 17:46 ` Thomas Monjalon 2020-06-23 20:57 ` [dpdk-dev] [PATCH v3 0/2] Support EAL debug functions on Windows talshn 1 sibling, 0 replies; 9+ messages in thread From: Thomas Monjalon @ 2020-06-23 17:46 UTC (permalink / raw) To: Tal Shnaiderman Cc: dev, pallavi.kadam, dmitry.kozliuk, david.marchand, ranjit.menon, navasile, harini.ramakrishnan, ocardona, bruce.richardson 08/06/2020 10:32, talshn@mellanox.com: > From: Tal Shnaiderman <talshn@mellanox.com> > > Move common functions between Unix and Windows to eal_common_debug.c. [...] > --- /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 I think you should keep Intel copyright for this code. > + */ > +#include <stdarg.h> A blank line is missing after the copyright block. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [dpdk-dev] [PATCH v3 0/2] Support EAL debug functions on Windows 2020-06-08 8:32 ` [dpdk-dev] [PATCH v2 1/2] eal: move OS common debug functions to single file talshn 2020-06-23 17:46 ` Thomas Monjalon @ 2020-06-23 20:57 ` talshn 2020-06-23 20:57 ` [dpdk-dev] [PATCH v3 1/2] eal: move OS common debug functions to single file talshn ` (2 more replies) 1 sibling, 3 replies; 9+ messages in thread From: talshn @ 2020-06-23 20:57 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, david.marchand, ranjit.menon, navasile, harini.ramakrishnan, ocardona, bruce.richardson, Tal Shnaiderman From: Tal Shnaiderman <talshn@mellanox.com> This patchset adds support for the EAL debug function on Windows by implementing backtracing in rte_dump_stack and cleanup calls in rte_eal_cleanup. Additionally, the functions rte_exit, __rte_panic and rte_dump_registers were moved to a common file to avoid code duplication. --- v3: Fix license comment[ThomasM] v2: Fix style and cross-compiling MinGW-w64 on Linux error[DmitryK] --- Tal Shnaiderman (2): eal: move OS common debug functions to single file eal/windows: support debug calls config/meson.build | 1 + lib/librte_eal/common/eal_common_debug.c | 59 +++++++++++++++++++++++++ lib/librte_eal/common/meson.build | 2 + 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 -------------------- lib/librte_eal/windows/eal.c | 9 +++- lib/librte_eal/windows/eal_debug.c | 76 ++++++++++++++++++++++++++++---- 9 files changed, 140 insertions(+), 107 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_debug.c -- 2.16.1.windows.4 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [dpdk-dev] [PATCH v3 1/2] eal: move OS common debug functions to single file 2020-06-23 20:57 ` [dpdk-dev] [PATCH v3 0/2] Support EAL debug functions on Windows talshn @ 2020-06-23 20:57 ` talshn 2020-06-23 20:57 ` [dpdk-dev] [PATCH v3 2/2] eal/windows: support debug calls talshn 2020-06-23 22:48 ` [dpdk-dev] [PATCH v3 0/2] Support EAL debug functions on Windows Dmitry Kozlyuk 2 siblings, 0 replies; 9+ messages in thread From: talshn @ 2020-06-23 20:57 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, david.marchand, ranjit.menon, navasile, harini.ramakrishnan, ocardona, bruce.richardson, Tal Shnaiderman From: Tal Shnaiderman <talshn@mellanox.com> 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 <talshn@mellanox.com> --- lib/librte_eal/common/eal_common_debug.c | 59 ++++++++++++++++++++++++++++++++ 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, 62 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..722468754d --- /dev/null +++ b/lib/librte_eal/common/eal_common_debug.c @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation + */ + +#include <stdarg.h> +#include <rte_eal.h> +#include <rte_log.h> +#include <rte_debug.h> + +/* 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 4bdf77922f..02e5d28d45 100644 --- a/lib/librte_eal/common/meson.build +++ b/lib/librte_eal/common/meson.build @@ -35,6 +35,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 d18c00eeae..9988ea5b48 100644 --- a/lib/librte_eal/freebsd/Makefile +++ b/lib/librte_eal/freebsd/Makefile @@ -52,6 +52,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 5d97073ed2..180fc51984 100644 --- a/lib/librte_eal/linux/Makefile +++ b/lib/librte_eal/linux/Makefile @@ -60,6 +60,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 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [dpdk-dev] [PATCH v3 2/2] eal/windows: support debug calls 2020-06-23 20:57 ` [dpdk-dev] [PATCH v3 0/2] Support EAL debug functions on Windows talshn 2020-06-23 20:57 ` [dpdk-dev] [PATCH v3 1/2] eal: move OS common debug functions to single file talshn @ 2020-06-23 20:57 ` talshn 2020-06-23 22:48 ` [dpdk-dev] [PATCH v3 0/2] Support EAL debug functions on Windows Dmitry Kozlyuk 2 siblings, 0 replies; 9+ messages in thread From: talshn @ 2020-06-23 20:57 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, david.marchand, ranjit.menon, navasile, harini.ramakrishnan, ocardona, bruce.richardson, Tal Shnaiderman From: Tal Shnaiderman <talshn@mellanox.com> Support the debug functions in eal_common_debug.c for Windows. Implementation of rte_dump_stack to get a backtrace similarly to Unix and of rte_eal_cleanup in eal.c. Signed-off-by: Tal Shnaiderman <talshn@mellanox.com> --- config/meson.build | 1 + lib/librte_eal/common/meson.build | 1 + lib/librte_eal/windows/eal.c | 9 ++++- lib/librte_eal/windows/eal_debug.c | 76 ++++++++++++++++++++++++++++++++++---- 4 files changed, 78 insertions(+), 9 deletions(-) diff --git a/config/meson.build b/config/meson.build index bb64c3bd43..351e268c1f 100644 --- a/config/meson.build +++ b/config/meson.build @@ -276,6 +276,7 @@ if is_windows endif add_project_link_arguments('-ladvapi32', '-lsetupapi', language: 'c') + add_project_link_arguments('-ldbghelp', language: 'c') endif if get_option('b_lto') diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build index 02e5d28d45..036ff62ed6 100644 --- a/lib/librte_eal/common/meson.build +++ b/lib/librte_eal/common/meson.build @@ -7,6 +7,7 @@ if is_windows sources += files( 'eal_common_bus.c', 'eal_common_class.c', + 'eal_common_debug.c', 'eal_common_devargs.c', 'eal_common_dynmem.c', 'eal_common_errno.c', diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c index b6bffd3d92..97c8427c73 100644 --- a/lib/librte_eal/windows/eal.c +++ b/lib/librte_eal/windows/eal.c @@ -274,7 +274,14 @@ __rte_trace_point_register(rte_trace_point_t *trace, const char *name, return -ENOTSUP; } - /* Launch threads, called at application init(). */ +int +rte_eal_cleanup(void) +{ + eal_cleanup_config(&internal_config); + return 0; +} + +/* Launch threads, called at application init(). */ int rte_eal_init(int argc, char **argv) { diff --git a/lib/librte_eal/windows/eal_debug.c b/lib/librte_eal/windows/eal_debug.c index 669be6ff97..56ed70df7d 100644 --- a/lib/librte_eal/windows/eal_debug.c +++ b/lib/librte_eal/windows/eal_debug.c @@ -5,16 +5,76 @@ #include <stdarg.h> #include <rte_log.h> #include <rte_debug.h> +#include <rte_windows.h> - /* call abort(), it will generate a coredump if enabled */ +#include <dbghelp.h> + +#define BACKTRACE_SIZE 256 + +/* dump the stack of the calling core */ void -__rte_panic(const char *funcname, const char *format, ...) +rte_dump_stack(void) { - va_list ap; + PVOID stack_trace[BACKTRACE_SIZE] = {0}; + USHORT frame_num; + BOOL ret; + HANDLE process = GetCurrentProcess(); + + ret = SymInitialize(process, NULL, TRUE); + if (!ret) { + RTE_LOG_WIN32_ERR("SymInitialize()"); + return; + } + + SymSetOptions(SYMOPT_LOAD_LINES | SYMOPT_UNDNAME); + + frame_num = RtlCaptureStackBackTrace(0, BACKTRACE_SIZE, + stack_trace, NULL); + + while (frame_num > 0) { + DWORD64 address = (DWORD64)(stack_trace[frame_num - 1]); + DWORD64 sym_disp = 0; + DWORD error_code = 0, lin_disp; + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)]; + PSYMBOL_INFO symbol_info = (PSYMBOL_INFO)buffer; + IMAGEHLP_LINE64 line; + + symbol_info->SizeOfStruct = sizeof(SYMBOL_INFO); + symbol_info->MaxNameLen = MAX_SYM_NAME; + line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); + + ret = SymFromAddr(process, address, &sym_disp, symbol_info); + if (!ret) { + error_code = GetLastError(); + if (error_code == ERROR_INVALID_ADDRESS) { + /* Missing symbols, print message */ + rte_log(RTE_LOG_ERR, RTE_LOGTYPE_EAL, + "%d: [<missing_symbols>]\n", frame_num--); + continue; + } else { + RTE_LOG_WIN32_ERR("SymFromAddr()"); + goto end; + } + } + + ret = SymGetLineFromAddr64(process, address, &lin_disp, &line); + if (!ret) { + error_code = GetLastError(); + /* If ERROR_INVALID_ADDRESS tag unknown and proceed */ + if (error_code != ERROR_INVALID_ADDRESS) { + RTE_LOG_WIN32_ERR("SymGetLineFromAddr64()"); + goto end; + } + } - 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); - abort(); + rte_log(RTE_LOG_ERR, RTE_LOGTYPE_EAL, + "%d: [%s (%s+0x%0llx)[0x%0llX]]\n", frame_num, + error_code ? "<unknown>" : line.FileName, + symbol_info->Name, sym_disp, symbol_info->Address); + frame_num--; + } +end: + ret = SymCleanup(process); + if (!ret) + RTE_LOG_WIN32_ERR("SymCleanup()"); } -- 2.16.1.windows.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH v3 0/2] Support EAL debug functions on Windows 2020-06-23 20:57 ` [dpdk-dev] [PATCH v3 0/2] Support EAL debug functions on Windows talshn 2020-06-23 20:57 ` [dpdk-dev] [PATCH v3 1/2] eal: move OS common debug functions to single file talshn 2020-06-23 20:57 ` [dpdk-dev] [PATCH v3 2/2] eal/windows: support debug calls talshn @ 2020-06-23 22:48 ` Dmitry Kozlyuk 2020-06-24 9:17 ` Thomas Monjalon 2 siblings, 1 reply; 9+ messages in thread From: Dmitry Kozlyuk @ 2020-06-23 22:48 UTC (permalink / raw) To: talshn Cc: dev, thomas, pallavi.kadam, david.marchand, ranjit.menon, navasile, harini.ramakrishnan, ocardona, bruce.richardson On Tue, 23 Jun 2020 23:57:19 +0300, talshn@mellanox.com wrote: > From: Tal Shnaiderman <talshn@mellanox.com> > > This patchset adds support for the EAL debug function on Windows by implementing backtracing in rte_dump_stack and cleanup calls in rte_eal_cleanup. > > Additionally, the functions rte_exit, __rte_panic and rte_dump_registers were moved to a common file to avoid code duplication. > > --- > v3: Fix license comment[ThomasM] > > v2: Fix style and cross-compiling MinGW-w64 on Linux error[DmitryK] > --- Tested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> -- Dmitry Kozlyuk ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [dpdk-dev] [PATCH v3 0/2] Support EAL debug functions on Windows 2020-06-23 22:48 ` [dpdk-dev] [PATCH v3 0/2] Support EAL debug functions on Windows Dmitry Kozlyuk @ 2020-06-24 9:17 ` Thomas Monjalon 0 siblings, 0 replies; 9+ messages in thread From: Thomas Monjalon @ 2020-06-24 9:17 UTC (permalink / raw) To: talshn Cc: dev, pallavi.kadam, david.marchand, ranjit.menon, navasile, harini.ramakrishnan, ocardona, bruce.richardson, Dmitry Kozlyuk 24/06/2020 00:48, Dmitry Kozlyuk: > On Tue, 23 Jun 2020 23:57:19 +0300, talshn@mellanox.com wrote: > > > From: Tal Shnaiderman <talshn@mellanox.com> > > > > This patchset adds support for the EAL debug function on Windows by implementing backtracing in rte_dump_stack and cleanup calls in rte_eal_cleanup. > > > > Additionally, the functions rte_exit, __rte_panic and rte_dump_registers were moved to a common file to avoid code duplication. > > Tested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> Applied, thanks ^ permalink raw reply [flat|nested] 9+ messages in thread
* [dpdk-dev] [PATCH v2 2/2] eal/windows: support debug calls 2020-06-08 8:32 [dpdk-dev] [PATCH v2 0/2] Support EAL debug functions on Windows talshn 2020-06-08 8:32 ` [dpdk-dev] [PATCH v2 1/2] eal: move OS common debug functions to single file talshn @ 2020-06-08 8:32 ` talshn 1 sibling, 0 replies; 9+ messages in thread From: talshn @ 2020-06-08 8:32 UTC (permalink / raw) To: dev Cc: thomas, pallavi.kadam, dmitry.kozliuk, david.marchand, ranjit.menon, navasile, harini.ramakrishnan, ocardona, bruce.richardson, Tal Shnaiderman From: Tal Shnaiderman <talshn@mellanox.com> Support the debug functions in eal_common_debug.c for Windows. Implementation of rte_dump_stack to get a backtrace similarly to Unix and of rte_eal_cleanup in eal.c. Signed-off-by: Tal Shnaiderman <talshn@mellanox.com> --- config/meson.build | 1 + lib/librte_eal/common/meson.build | 1 + lib/librte_eal/windows/eal.c | 7 ++++ lib/librte_eal/windows/eal_debug.c | 76 ++++++++++++++++++++++++++++++++++---- 4 files changed, 77 insertions(+), 8 deletions(-) diff --git a/config/meson.build b/config/meson.build index 43ab113106..5f1e257da7 100644 --- a/config/meson.build +++ b/config/meson.build @@ -268,6 +268,7 @@ if is_windows if cc.get_id() == 'gcc' add_project_arguments('-D__USE_MINGW_ANSI_STDIO', language: 'c') endif + add_project_link_arguments('-ldbghelp', language: 'c') endif if get_option('b_lto') diff --git a/lib/librte_eal/common/meson.build b/lib/librte_eal/common/meson.build index 2bde920597..a1c362895b 100644 --- a/lib/librte_eal/common/meson.build +++ b/lib/librte_eal/common/meson.build @@ -8,6 +8,7 @@ if is_windows 'eal_common_bus.c', 'eal_common_class.c', 'eal_common_devargs.c', + 'eal_common_debug.c', 'eal_common_errno.c', 'eal_common_launch.c', 'eal_common_lcore.c', diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c index d084606a66..7278f2f07c 100644 --- a/lib/librte_eal/windows/eal.c +++ b/lib/librte_eal/windows/eal.c @@ -221,6 +221,13 @@ rte_eal_init_alert(const char *msg) RTE_LOG(ERR, EAL, "%s\n", msg); } +int +rte_eal_cleanup(void) +{ + eal_cleanup_config(&internal_config); + return 0; +} + /* Launch threads, called at application init(). */ int rte_eal_init(int argc, char **argv) diff --git a/lib/librte_eal/windows/eal_debug.c b/lib/librte_eal/windows/eal_debug.c index 669be6ff97..56ed70df7d 100644 --- a/lib/librte_eal/windows/eal_debug.c +++ b/lib/librte_eal/windows/eal_debug.c @@ -5,16 +5,76 @@ #include <stdarg.h> #include <rte_log.h> #include <rte_debug.h> +#include <rte_windows.h> - /* call abort(), it will generate a coredump if enabled */ +#include <dbghelp.h> + +#define BACKTRACE_SIZE 256 + +/* dump the stack of the calling core */ void -__rte_panic(const char *funcname, const char *format, ...) +rte_dump_stack(void) { - va_list ap; + PVOID stack_trace[BACKTRACE_SIZE] = {0}; + USHORT frame_num; + BOOL ret; + HANDLE process = GetCurrentProcess(); + + ret = SymInitialize(process, NULL, TRUE); + if (!ret) { + RTE_LOG_WIN32_ERR("SymInitialize()"); + return; + } + + SymSetOptions(SYMOPT_LOAD_LINES | SYMOPT_UNDNAME); + + frame_num = RtlCaptureStackBackTrace(0, BACKTRACE_SIZE, + stack_trace, NULL); + + while (frame_num > 0) { + DWORD64 address = (DWORD64)(stack_trace[frame_num - 1]); + DWORD64 sym_disp = 0; + DWORD error_code = 0, lin_disp; + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)]; + PSYMBOL_INFO symbol_info = (PSYMBOL_INFO)buffer; + IMAGEHLP_LINE64 line; + + symbol_info->SizeOfStruct = sizeof(SYMBOL_INFO); + symbol_info->MaxNameLen = MAX_SYM_NAME; + line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); + + ret = SymFromAddr(process, address, &sym_disp, symbol_info); + if (!ret) { + error_code = GetLastError(); + if (error_code == ERROR_INVALID_ADDRESS) { + /* Missing symbols, print message */ + rte_log(RTE_LOG_ERR, RTE_LOGTYPE_EAL, + "%d: [<missing_symbols>]\n", frame_num--); + continue; + } else { + RTE_LOG_WIN32_ERR("SymFromAddr()"); + goto end; + } + } + + ret = SymGetLineFromAddr64(process, address, &lin_disp, &line); + if (!ret) { + error_code = GetLastError(); + /* If ERROR_INVALID_ADDRESS tag unknown and proceed */ + if (error_code != ERROR_INVALID_ADDRESS) { + RTE_LOG_WIN32_ERR("SymGetLineFromAddr64()"); + goto end; + } + } - 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); - abort(); + rte_log(RTE_LOG_ERR, RTE_LOGTYPE_EAL, + "%d: [%s (%s+0x%0llx)[0x%0llX]]\n", frame_num, + error_code ? "<unknown>" : line.FileName, + symbol_info->Name, sym_disp, symbol_info->Address); + frame_num--; + } +end: + ret = SymCleanup(process); + if (!ret) + RTE_LOG_WIN32_ERR("SymCleanup()"); } -- 2.16.1.windows.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-06-24 9:18 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-06-08 8:32 [dpdk-dev] [PATCH v2 0/2] Support EAL debug functions on Windows talshn 2020-06-08 8:32 ` [dpdk-dev] [PATCH v2 1/2] eal: move OS common debug functions to single file talshn 2020-06-23 17:46 ` Thomas Monjalon 2020-06-23 20:57 ` [dpdk-dev] [PATCH v3 0/2] Support EAL debug functions on Windows talshn 2020-06-23 20:57 ` [dpdk-dev] [PATCH v3 1/2] eal: move OS common debug functions to single file talshn 2020-06-23 20:57 ` [dpdk-dev] [PATCH v3 2/2] eal/windows: support debug calls talshn 2020-06-23 22:48 ` [dpdk-dev] [PATCH v3 0/2] Support EAL debug functions on Windows Dmitry Kozlyuk 2020-06-24 9:17 ` Thomas Monjalon 2020-06-08 8:32 ` [dpdk-dev] [PATCH v2 2/2] eal/windows: support debug calls talshn
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.