| 159 | } |
| 160 | |
| 161 | ByteBuf format_modules_summary(const Engine& eng) { |
| 162 | auto mods = enumerate_modules(eng); |
| 163 | if (mods.empty()) { |
| 164 | const char msg[] = |
| 165 | "; no loaded modules found.\n" |
| 166 | "; either the kernel has no out-of-tree modules, or `modules`\n" |
| 167 | "; symbol is missing / list walk failed.\n"; |
| 168 | return ByteBuf(msg, msg + sizeof(msg) - 1); |
| 169 | } |
| 170 | std::string out; |
| 171 | out.reserve(64 * 1024); |
| 172 | out += fmt::format("# {} loaded modules. Format:\n", mods.size()); |
| 173 | out += "# <name> <total_size_kb> <state> <text_base_va> <version>\n"; |
| 174 | out += "#\n"; |
| 175 | for (const auto& m : mods) { |
| 176 | u64 total = 0; |
| 177 | for (const auto& mem : m.mem) total += mem.size; |
| 178 | out += fmt::format("{:<24} {:>6} {:<8} {:#018x} {}\n", |
| 179 | m.name, total / 1024, state_name(m.state), |
| 180 | m.mem[MOD_TEXT].base, m.version); |
| 181 | } |
| 182 | return ByteBuf(out.begin(), out.end()); |
| 183 | } |
| 184 | |
| 185 | ByteBuf format_module_info(const LoadedModule& m) { |
| 186 | std::string out; |
no test coverage detected