MCPcopy Create free account
hub / github.com/apache/trafficserver / ServerBacktrace

Function ServerBacktrace

src/traffic_crashlog/backtrace.cc:174–208  ·  view source on GitHub ↗

namespace

Source from the content-addressed store, hash-verified

172}
173} // namespace
174int
175ServerBacktrace(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

Callers 1

crashlog_write_backtraceFunction · 0.85

Calls 7

threads_for_processFunction · 0.85
backtrace_for_threadFunction · 0.85
readFromFDMethod · 0.80
chompMethod · 0.80
sizeMethod · 0.45
formatMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected