MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / backtrace

Function backtrace

src/arch/aarch64/backtrace.cpp:18–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
34auto DumpStack() -> void {
35 std::array<uint64_t, kMaxFrameCount> buffer{};

Callers 1

DumpStackFunction · 0.70

Calls 2

ReadFunction · 0.85
max_sizeMethod · 0.80

Tested by

no test coverage detected