* \brief An owned vector of `FrameRef` instances representing the WebAssembly * call-stack on a trap. * * This can be used to iterate over the frames of a trap and determine what was * running when a trap happened. */
| 64 | * running when a trap happened. |
| 65 | */ |
| 66 | class Trace { |
| 67 | friend class Trap; |
| 68 | friend class Error; |
| 69 | |
| 70 | wasm_frame_vec_t vec; |
| 71 | |
| 72 | Trace(wasm_frame_vec_t vec) : vec(vec) {} |
| 73 | |
| 74 | public: |
| 75 | ~Trace() { wasm_frame_vec_delete(&vec); } |
| 76 | |
| 77 | Trace(const Trace &other) = delete; |
| 78 | Trace(Trace &&other) = delete; |
| 79 | Trace &operator=(const Trace &other) = delete; |
| 80 | Trace &operator=(Trace &&other) = delete; |
| 81 | |
| 82 | /// Iterator used to iterate over this trace. |
| 83 | typedef const FrameRef *iterator; |
| 84 | |
| 85 | /// Returns the start of iteration |
| 86 | iterator begin() const { |
| 87 | return reinterpret_cast<FrameRef *>(&vec.data[0]); // NOLINT |
| 88 | } |
| 89 | /// Returns the end of iteration |
| 90 | iterator end() const { |
| 91 | return reinterpret_cast<FrameRef *>(&vec.data[vec.size]); // NOLINT |
| 92 | } |
| 93 | /// Returns the size of this trace, or how many frames it contains. |
| 94 | size_t size() const { return vec.size; } |
| 95 | }; |
| 96 | |
| 97 | inline Trace Error::trace() const { |
| 98 | wasm_frame_vec_t frames; |
no outgoing calls
no test coverage detected