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

Function DumpStack

src/arch/aarch64/backtrace.cpp:34–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34auto DumpStack() -> void {
35 std::array<uint64_t, kMaxFrameCount> buffer{};
36
37 // 获取调用栈中的地址
38 auto num_frames = backtrace(buffer);
39
40 // 打印函数名
41 for (auto current_frame_idx = 0; current_frame_idx < num_frames;
42 current_frame_idx++) {
43 for (auto symtab : KernelElfSingleton::instance().symtab) {
44 if ((ELF64_ST_TYPE(symtab.st_info) == STT_FUNC) &&
45 (buffer[current_frame_idx] >= symtab.st_value) &&
46 (buffer[current_frame_idx] <= symtab.st_value + symtab.st_size)) {
47 klog::Err("[{}] {:#x}",
48 reinterpret_cast<const char*>(
49 KernelElfSingleton::instance().strtab + symtab.st_name),
50 buffer[current_frame_idx]);
51 }
52 }
53 }
54}

Callers

nothing calls this directly

Calls 2

ErrFunction · 0.85
backtraceFunction · 0.70

Tested by

no test coverage detected