| 16 | #include "kernel_log.hpp" |
| 17 | |
| 18 | __always_inline auto backtrace(std::array<uint64_t, kMaxFrameCount>& buffer) |
| 19 | -> int { |
| 20 | auto* x29 = reinterpret_cast<uint64_t*>(cpu_io::X29::Read()); |
| 21 | size_t count = 0; |
| 22 | while ((x29 != nullptr) && (x29[0] != 0U) && |
| 23 | x29[0] >= reinterpret_cast<uint64_t>(__executable_start) && |
| 24 | x29[0] <= reinterpret_cast<uint64_t>(__etext) && |
| 25 | count < buffer.max_size()) { |
| 26 | auto lr = x29[1]; |
| 27 | x29 = reinterpret_cast<uint64_t*>(x29[0]); |
| 28 | buffer[count++] = lr; |
| 29 | } |
| 30 | |
| 31 | return static_cast<int>(count); |
| 32 | } |
| 33 | |
| 34 | auto DumpStack() -> void { |
| 35 | std::array<uint64_t, kMaxFrameCount> buffer{}; |