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 <talshn@mellanox.com>
Subject: [dpdk-dev] [PATCH v3 2/2] eal/windows: support debug calls
Date: Tue, 23 Jun 2020 23:57:21 +0300 [thread overview]
Message-ID: <20200623205721.21200-3-talshn@mellanox.com> (raw)
In-Reply-To: <20200623205721.21200-1-talshn@mellanox.com>
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
next prev parent reply other threads:[~2020-06-23 20:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` talshn [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200623205721.21200-3-talshn@mellanox.com \
--to=talshn@mellanox.com \
--cc=bruce.richardson@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
--cc=harini.ramakrishnan@microsoft.com \
--cc=navasile@linux.microsoft.com \
--cc=ocardona@microsoft.com \
--cc=pallavi.kadam@intel.com \
--cc=ranjit.menon@intel.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).