| 46 | } |
| 47 | |
| 48 | auto 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 | } |
no test coverage detected