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

Function DumpStack

src/arch/riscv64/backtrace.cpp:48–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48auto DumpStack() -> void {
49 std::array<uint64_t, kMaxFrameCount> buffer{};
50
51 // 获取调用栈中的地址
52 auto num_frames = backtrace(buffer);
53
54 // 打印函数名
55 for (auto current_frame_idx = 0; current_frame_idx < num_frames;
56 current_frame_idx++) {
57 for (auto symtab : KernelElfSingleton::instance().symtab) {
58 if ((ELF64_ST_TYPE(symtab.st_info) == STT_FUNC) &&
59 (buffer[current_frame_idx] >= symtab.st_value) &&
60 (buffer[current_frame_idx] <= symtab.st_value + symtab.st_size)) {
61 klog::Err("[{}] {:#x}",
62 reinterpret_cast<const char*>(
63 KernelElfSingleton::instance().strtab + symtab.st_name),
64 buffer[current_frame_idx]);
65 }
66 }
67 }
68}

Callers 3

PageFaultHandlerFunction · 0.70
mainFunction · 0.50
mainFunction · 0.50

Calls 2

ErrFunction · 0.85
backtraceFunction · 0.70

Tested by

no test coverage detected