Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/bytecode_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

#include "include/proxy-wasm/bytecode_util.h"

#if !defined(_MSC_VER)
#include <cxxabi.h>
#endif

#include <cstring>

namespace proxy_wasm {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions test/runtime_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}

Expand All @@ -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"));
}
}
Expand All @@ -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"));
}
}
Expand Down