MCPcopy Create free account
hub / github.com/apache/brpc / StackDumpSignalHandler

Function StackDumpSignalHandler

src/butil/debug/stack_trace_posix.cc:210–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208}
209
210void StackDumpSignalHandler(int signal, siginfo_t* info, void* void_context) {
211 // NOTE: This code MUST be async-signal safe.
212 // NO malloc or stdio is allowed here.
213
214 // Record the fact that we are in the signal handler now, so that the rest
215 // of StackTrace can behave in an async-signal-safe manner.
216 in_signal_handler = 1;
217
218 if (BeingDebugged())
219 BreakDebugger();
220
221 PrintToStderr("Received signal ");
222 char buf[1024] = { 0 };
223 internal::itoa_r(signal, buf, sizeof(buf), 10, 0);
224 PrintToStderr(buf);
225 if (signal == SIGBUS) {
226 if (info->si_code == BUS_ADRALN)
227 PrintToStderr(" BUS_ADRALN ");
228 else if (info->si_code == BUS_ADRERR)
229 PrintToStderr(" BUS_ADRERR ");
230 else if (info->si_code == BUS_OBJERR)
231 PrintToStderr(" BUS_OBJERR ");
232 else
233 PrintToStderr(" <unknown> ");
234 } else if (signal == SIGFPE) {
235 if (info->si_code == FPE_FLTDIV)
236 PrintToStderr(" FPE_FLTDIV ");
237 else if (info->si_code == FPE_FLTINV)
238 PrintToStderr(" FPE_FLTINV ");
239 else if (info->si_code == FPE_FLTOVF)
240 PrintToStderr(" FPE_FLTOVF ");
241 else if (info->si_code == FPE_FLTRES)
242 PrintToStderr(" FPE_FLTRES ");
243 else if (info->si_code == FPE_FLTSUB)
244 PrintToStderr(" FPE_FLTSUB ");
245 else if (info->si_code == FPE_FLTUND)
246 PrintToStderr(" FPE_FLTUND ");
247 else if (info->si_code == FPE_INTDIV)
248 PrintToStderr(" FPE_INTDIV ");
249 else if (info->si_code == FPE_INTOVF)
250 PrintToStderr(" FPE_INTOVF ");
251 else
252 PrintToStderr(" <unknown> ");
253 } else if (signal == SIGILL) {
254 if (info->si_code == ILL_BADSTK)
255 PrintToStderr(" ILL_BADSTK ");
256 else if (info->si_code == ILL_COPROC)
257 PrintToStderr(" ILL_COPROC ");
258 else if (info->si_code == ILL_ILLOPN)
259 PrintToStderr(" ILL_ILLOPN ");
260 else if (info->si_code == ILL_ILLADR)
261 PrintToStderr(" ILL_ILLADR ");
262 else if (info->si_code == ILL_ILLTRP)
263 PrintToStderr(" ILL_ILLTRP ");
264 else if (info->si_code == ILL_PRVOPC)
265 PrintToStderr(" ILL_PRVOPC ");
266 else if (info->si_code == ILL_PRVREG)
267 PrintToStderr(" ILL_PRVREG ");

Callers

nothing calls this directly

Calls 7

BeingDebuggedFunction · 0.85
BreakDebuggerFunction · 0.85
PrintToStderrFunction · 0.85
itoa_rFunction · 0.85
StackTraceClass · 0.85
snprintfFunction · 0.85
PrintMethod · 0.45

Tested by

no test coverage detected