| 102 | } |
| 103 | |
| 104 | ByteBuf format_proc_threads(const Engine& eng, const Process& leader) { |
| 105 | auto threads = enumerate_threads(eng, leader); |
| 106 | std::string out; |
| 107 | out.reserve(2 * 1024); |
| 108 | out += fmt::format( |
| 109 | "# /proc/{}/threads.txt — threads of pid {} ({})\n" |
| 110 | "# Walks leader.signal->thread_head; tgid for all entries == {}.\n" |
| 111 | "# {} thread(s) total (incl. leader).\n" |
| 112 | "#\n" |
| 113 | "# TID state comm task_va\n" |
| 114 | "# ------- --------------------- --------------------- -------------------\n", |
| 115 | leader.pid, leader.pid, leader.comm, leader.tgid, threads.size()); |
| 116 | for (const auto& t : threads) { |
| 117 | out += fmt::format(" {:>6} {:<22} {:<22} {:#018x}\n", |
| 118 | t.pid, state_name(t.state), t.comm, t.task_va); |
| 119 | } |
| 120 | return ByteBuf(out.begin(), out.end()); |
| 121 | } |
| 122 | |
| 123 | ByteBuf format_global_threads(const Engine& eng) { |
| 124 | std::string out; |
no test coverage detected