diff --git a/src/bytecode_util.cc b/src/bytecode_util.cc index 3c5f768f2..0d44c57e2 100644 --- a/src/bytecode_util.cc +++ b/src/bytecode_util.cc @@ -14,6 +14,10 @@ #include "include/proxy-wasm/bytecode_util.h" +#if !defined(_MSC_VER) +#include +#endif + #include namespace proxy_wasm { @@ -165,7 +169,16 @@ bool BytecodeUtil::getFunctionNameIndex(std::string_view bytecode, if (!parseVarint(pos, end, func_name_size) || pos + func_name_size > end) { return false; } - ret.insert({func_index, std::string(pos, func_name_size)}); + auto func_name = std::string(pos, func_name_size); +#if !defined(_MSC_VER) + int status; + char *data = abi::__cxa_demangle(func_name.c_str(), nullptr, nullptr, &status); + if (data != nullptr) { + func_name = std::string(data); + ::free(data); + } +#endif + ret.insert({func_index, func_name}); pos += func_name_size; } if (start + subsection_size != pos) { diff --git a/test/runtime_test.cc b/test/runtime_test.cc index d0f6fd0af..dfb2c3633 100644 --- a/test/runtime_test.cc +++ b/test/runtime_test.cc @@ -139,6 +139,7 @@ TEST_P(TestVm, WasmMemoryLimit) { EXPECT_TRUE(host->isErrorLogged("Uncaught RuntimeError: unreachable")); EXPECT_TRUE(host->isErrorLogged("Proxy-Wasm plugin in-VM backtrace:")); EXPECT_TRUE(host->isErrorLogged(" - rust_oom")); + EXPECT_TRUE(host->isErrorLogged(" - alloc::alloc::handle_alloc_error")); } } @@ -160,6 +161,7 @@ TEST_P(TestVm, Trap) { if (engine_ == "v8") { EXPECT_TRUE(host->isErrorLogged("Uncaught RuntimeError: unreachable")); EXPECT_TRUE(host->isErrorLogged("Proxy-Wasm plugin in-VM backtrace:")); + EXPECT_TRUE(host->isErrorLogged(" - std::panicking::begin_panic")); EXPECT_TRUE(host->isErrorLogged(" - trigger")); } } @@ -182,6 +184,7 @@ TEST_P(TestVm, Trap2) { if (engine_ == "v8") { EXPECT_TRUE(host->isErrorLogged("Uncaught RuntimeError: unreachable")); EXPECT_TRUE(host->isErrorLogged("Proxy-Wasm plugin in-VM backtrace:")); + EXPECT_TRUE(host->isErrorLogged(" - std::panicking::begin_panic")); EXPECT_TRUE(host->isErrorLogged(" - trigger2")); } }