| 75 | } |
| 76 | |
| 77 | Span<const uint32_t> |
| 78 | interpreterStackTrace(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 | |
| 108 | Span<const uint32_t> compiledStackTrace(const Runtime::StackManager &StackMgr, |
| 109 | Span<uint32_t> Buffer) noexcept { |
no test coverage detected