namespace
| 172 | } |
| 173 | } // namespace |
| 174 | int |
| 175 | ServerBacktrace(unsigned /* options */, int pid, char **trace) |
| 176 | { |
| 177 | *trace = nullptr; |
| 178 | |
| 179 | threadlist threads(threads_for_process(pid)); |
| 180 | TextBuffer text(0); |
| 181 | |
| 182 | Dbg(dbg_ctl_backtrace, "tracing %zd threads for traffic_server PID %ld\n", threads.size(), (long)pid); |
| 183 | |
| 184 | for (auto threadid : threads) { |
| 185 | Dbg(dbg_ctl_backtrace, "tracing thread %ld\n", (long)threadid); |
| 186 | // Get the thread name using /proc/PID/comm |
| 187 | ats_scoped_fd fd; |
| 188 | char threadname[128]; |
| 189 | |
| 190 | snprintf(threadname, sizeof(threadname), "/proc/%ld/comm", static_cast<long>(threadid)); |
| 191 | fd = open(threadname, O_RDONLY); |
| 192 | if (fd >= 0) { |
| 193 | text.format("Thread %ld, ", static_cast<long>(threadid)); |
| 194 | text.readFromFD(fd); |
| 195 | text.chomp(); |
| 196 | } else { |
| 197 | text.format("Thread %ld", static_cast<long>(threadid)); |
| 198 | } |
| 199 | |
| 200 | text.format(":\n"); |
| 201 | |
| 202 | backtrace_for_thread(threadid, text); |
| 203 | text.format("\n"); |
| 204 | } |
| 205 | |
| 206 | *trace = text.release(); |
| 207 | return 0; |
| 208 | } |
| 209 | |
| 210 | #else /* TS_USE_REMOTE_UNWINDING */ |
| 211 |
no test coverage detected