MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / interpreterStackTrace

Function interpreterStackTrace

lib/system/stacktrace.cpp:77–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77Span<const uint32_t>
78interpreterStackTrace(const Runtime::StackManager &StackMgr,
79 Span<uint32_t> Buffer) noexcept {
80 size_t Index = 0;
81 if (auto Module = StackMgr.getModule()) {
82 const auto FuncInsts = Module->getFunctionInstances();
83 std::map<AST::InstrView::iterator, int64_t> Funcs;
84 for (size_t I = 0; I < FuncInsts.size(); ++I) {
85 const auto &Func = FuncInsts[I];
86 if (Func && Func->isWasmFunction()) {
87 const auto &Instrs = Func->getInstrs();
88 Funcs.emplace(Instrs.end(), INT64_C(-1));
89 Funcs.emplace(Instrs.begin(), I);
90 }
91 }
92 for (const auto &Frame : StackMgr.getFramesSpan()) {
93 auto Entry = Frame.From;
94 auto Iter = Funcs.lower_bound(Entry);
95 if ((Iter == Funcs.end() || Iter->first > Entry) &&
96 Iter != Funcs.begin()) {
97 --Iter;
98 }
99 if (Iter != Funcs.end() && Iter->first < Entry &&
100 Iter->second >= INT64_C(0) && Index < Buffer.size()) {
101 Buffer[Index++] = static_cast<uint32_t>(Iter->second);
102 }
103 }
104 }
105 return Buffer.first(Index);
106}
107
108Span<const uint32_t> compiledStackTrace(const Runtime::StackManager &StackMgr,
109 Span<uint32_t> Buffer) noexcept {

Callers 2

enterFunctionMethod · 0.85
executeMethod · 0.85

Calls 10

getFunctionInstancesMethod · 0.80
isWasmFunctionMethod · 0.80
getFramesSpanMethod · 0.80
firstMethod · 0.80
getModuleMethod · 0.45
sizeMethod · 0.45
getInstrsMethod · 0.45
emplaceMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected