31 static const int SIGNAL_MESSAGE_BUFSIZE = 2048;
41 #if defined(__aarch64__) && defined(__linux)
74 ProcessInfo__pid (
void)
77 return GetCurrentProcessId ();
85 ProcessInfo__ppid (
void)
88 PROCESS_BASIC_INFORMATION pbi;
89 if (NtQueryInformationProcess (GetCurrentProcess(),ProcessBasicInformation,
90 &pbi,
sizeof (pbi), 0) == STATUS_SUCCESS)
91 return pbi.InheritedFromUniqueProcessId;
156 #if !HAVE_POSIX_SIGNALS || !SA_SIGINFO
175 SignalDumpLibs (
const SharedLibrary::LibraryInfo &
info,
IOFD fd)
179 MYWRITE (
fd, buf, snprintf (buf, buf_size,
" 0x%08lx ",
info.m_text_start));
188 SEHFatal (PEXCEPTION_POINTERS
info)
190 Signal::fatal (SIGABRT,
info->ExceptionRecord,
info->ContextRecord);
191 return EXCEPTION_EXECUTE_HANDLER;
198 #if !HAVE_POSIX_SIGNALS
205 assert (
sig > 0 &&
sig < NSIG);
219 return strsignal (
sig);
220 #elif HAVE_SYS_SIGLIST
221 return sys_siglist [
sig];
226 static char buf [NSIG] [buf_size];
228 snprintf (buf [
sig], buf_size,
"Signal %d",
sig);
238 assert (
sig > 0 &&
sig < NSIG);
241 #if HAVE_POSIX_SIGNALS
242 struct sigaction
old;
243 STDC::memset (&
old, 0,
sizeof (
old));
244 if (sigaction (
sig, &
old, 0) == 0)
252 #else // ! HAVE_POSIX_SIGNALS
256 #endif // HAVE_POSIX_SIGNALS
279 assert (
sig > 0 &&
sig < NSIG);
284 #if !HAVE_POSIX_SIGNALS || !SA_SIGINFO
298 #if HAVE_POSIX_SIGNALS
299 struct sigaction
old, act;
300 STDC::memset (&act, 0,
sizeof (act));
301 STDC::memset (&
old, 0,
sizeof (
old));
302 act.sa_flags = SA_RESTART | SA_SIGINFO;
306 act.sa_mask = *blockMask;
307 else if (sigaction (
sig, &
old, 0) == 0)
308 act.sa_mask =
old.sa_mask;
315 if (sigaction (
sig, &act, &
old) == -1)
320 #endif // HAVE_POSIX_SIGNALS
340 #if HAVE_POSIX_SIGNALS
355 #if HAVE_POSIX_SIGNALS
357 sigprocmask (sense ? SIG_BLOCK : SIG_UNBLOCK,
mask, 0);
367 #if HAVE_POSIX_SIGNALS
369 sigprocmask (SIG_SETMASK,
mask,
old);
380 return ::raise (
sig);
382 return ::kill (getpid (),
sig);
401 #if HAVE_POSIX_RT_SIGNALS
419 #if HAVE_POSIX_RT_SIGNALS
438 #if HAVE_POSIX_RT_SIGNALS
455 #if HAVE_POSIX_RT_SIGNALS
475 #if HAVE_POSIX_SIGNALS
491 #if HAVE_POSIX_SIGNALS
535 #if HAVE_POSIX_RT_SIGNALS
545 sigwaitinfo (
mask, &myinfo);
548 ts.tv_sec = msecs / 1000;
549 ts.tv_nsec = (msecs % 1000) * 1000000;
550 if (sigtimedwait (
mask, &myinfo, &
ts) == -1 && errno == EINTR)
558 return myinfo.si_signo;
583 static int hups [] = {
603 for (
unsigned sig = 0; hups [
sig] != -1; ++
sig)
604 handle (hups [
sig], quit);
649 FatalReturn mainreturn ,
673 static const int hups [] = {
689 static int fatals [] = {
734 if (applicationName && *applicationName)
735 s_applicationName = applicationName;
750 delete SignalDumpCallback;
759 s_fatalReturn = mainreturn;
766 assert (s_fatalReturn || (s_fatalOptions & FATAL_AUTO_EXIT));
770 for (
unsigned sig = 0; hups [
sig] != -1; ++
sig)
771 handle (hups [
sig], fatal);
773 for (
unsigned sig = 0; fatals [
sig] != -1; ++
sig)
774 handle (fatals [
sig], fatal);
779 handle (SIGINT, fatal);
789 SetUnhandledExceptionFilter (&SEHFatal);
822 if (! s_quitHook || (*s_quitHook) (
sig,
info,
x))
897 assert (s_fatalReturn || (s_fatalOptions & FATAL_AUTO_EXIT));
899 #if !HAVE_POSIX_SIGNALS
903 handle (
sig, &fatal);
924 bool fatal = (
sig != SIGINT) || (s_fatalOptions & FATAL_ON_INT);
929 bool haveCore =
false;
930 if (s_inFatal == 1 && fatal && (s_fatalOptions & FATAL_DUMP_CORE))
935 haveCore = (
::stat (
"core", &st) == 0
936 && S_ISREG (st.st_mode)
945 if (s_inFatal > 1 || (s_fatalOptions & FATAL_AUTO_EXIT))
970 static const struct {
int sig;
int code;
const char *
desc; } infos [] = {
971 #if HAVE_POSIX_SIGNALS
972 { -1, SI_USER,
"user sent: kill, sigsend or raise" },
974 { -1, SI_KERNEL,
"kernel" },
976 { -1, SI_QUEUE,
"sigqueue" },
977 { -1, SI_TIMER,
"timer expired" },
978 { -1, SI_MESGQ,
"mesq state changed" },
979 { -1, SI_ASYNCIO,
"AIO completed" },
980 # ifdef SI_SIGIO // not solaris
981 { -1, SI_SIGIO,
"queued SIGIO" },
984 # ifdef ILL_NOOP // darwin
985 { SIGILL, ILL_NOOP,
"noop" },
987 { SIGILL, ILL_ILLOPC,
"illegal opcode" },
988 # ifdef ILL_ILLOPN // not darwin
989 { SIGILL, ILL_ILLOPN,
"illegal operand" },
991 # ifdef ILL_ILLADR // not darwin
992 { SIGILL, ILL_ILLADR,
"illegal addressing mode" },
994 { SIGILL, ILL_ILLTRP,
"illegal trap" },
995 { SIGILL, ILL_PRVOPC,
"privileged opcode" },
996 # ifdef ILL_PRVREG // not darwin
997 { SIGILL, ILL_PRVREG,
"privileged register" },
999 # ifdef ILL_COPROC // not darwin
1000 { SIGILL, ILL_COPROC,
"coprocessor error" },
1002 # ifdef ILL_BADSTK // not darwin
1003 { SIGILL, ILL_BADSTK,
"internal stack error" },
1006 # ifdef FPE_NOOP // darwin
1007 { SIGFPE, FPE_NOOP,
"noop" },
1009 # ifdef FPE_INTDIV // not darwin
1010 { SIGFPE, FPE_INTDIV,
"integer divide by zero" },
1012 # ifdef FPE_INTOVF // not darwin
1013 { SIGFPE, FPE_INTOVF,
"integer overflow" },
1015 { SIGFPE, FPE_FLTDIV,
"floating point divide by zero" },
1016 { SIGFPE, FPE_FLTOVF,
"floating point overflow" },
1017 { SIGFPE, FPE_FLTUND,
"floating point underflow" },
1018 { SIGFPE, FPE_FLTRES,
"floating point inexact result" },
1019 { SIGFPE, FPE_FLTINV,
"floating point invalid operation" },
1020 # ifdef FPE_FLTSUB // not darwin
1021 { SIGFPE, FPE_FLTSUB,
"subscript out of range" },
1024 # ifdef SEGV_NOOP // darwin
1025 { SIGSEGV, SEGV_NOOP,
"noop" },
1027 { SIGSEGV, SEGV_MAPERR,
"address not mapped to object" },
1028 { SIGSEGV, SEGV_ACCERR,
"invalid permissions for mapped object" },
1030 # ifdef BUS_NOOP // darwin
1031 { SIGBUS, BUS_NOOP,
"noop" },
1033 { SIGBUS, BUS_ADRALN,
"invalid address alignment" },
1034 # ifdef BUS_ADRERR // not darwin
1035 { SIGBUS, BUS_ADRERR,
"non-existent physical address" },
1037 # ifdef BUS_OBJERR // not darwin
1038 { SIGBUS, BUS_OBJERR,
"object specific hardware error" },
1041 # ifdef TRAP_BRKPT // not darwin
1042 { SIGTRAP, TRAP_BRKPT,
"process break point" },
1044 # ifdef TRAP_TRACE // not darwin
1045 { SIGTRAP, TRAP_TRACE,
"process trace trap" },
1048 # ifdef CLD_NOOP // darwin
1049 { SIGCHLD, CLD_NOOP,
"noop" },
1051 { SIGCHLD, CLD_EXITED,
"child has exited" },
1052 { SIGCHLD, CLD_KILLED,
"child was killed" },
1053 { SIGCHLD, CLD_DUMPED,
"child terminated abnormally" },
1054 { SIGCHLD, CLD_TRAPPED,
"traced child has trapped" },
1055 { SIGCHLD, CLD_STOPPED,
"child has stopped" },
1056 { SIGCHLD, CLD_CONTINUED,
"stopped child has continued" },
1058 # ifdef SIGPOLL // not darwin
1059 { SIGPOLL, POLL_IN,
"data input available" },
1060 { SIGPOLL, POLL_OUT,
"output buffers available" },
1061 { SIGPOLL, POLL_MSG,
"input message available" },
1062 { SIGPOLL, POLL_ERR,
"i/o error" },
1063 { SIGPOLL, POLL_PRI,
"high priority input available" },
1064 { SIGPOLL, POLL_HUP,
"device disconnected" },
1066 #endif // HAVE_POSIX_SIGNALS
1071 for (
unsigned i = 0; infos [
i].desc; ++
i)
1074 return infos [
i].desc;
1076 return "*unknown reason*";
1090 # define DOCODE(x) case x: name = #x
1092 const char *
name = 0;
1094 switch (
info->ExceptionCode)
1096 DOCODE(STATUS_ABANDONED_WAIT_0);
1097 DOCODE(STATUS_ACCESS_VIOLATION);
1098 DOCODE(STATUS_ARRAY_BOUNDS_EXCEEDED);
1099 DOCODE(STATUS_BREAKPOINT);
1100 DOCODE(STATUS_CONTROL_C_EXIT);
1101 DOCODE(STATUS_DATATYPE_MISALIGNMENT);
1102 DOCODE(STATUS_FLOAT_DENORMAL_OPERAND);
1103 DOCODE(STATUS_FLOAT_DIVIDE_BY_ZERO);
1104 DOCODE(STATUS_FLOAT_INEXACT_RESULT);
1105 DOCODE(STATUS_FLOAT_INVALID_OPERATION);
1106 DOCODE(STATUS_FLOAT_OVERFLOW);
1107 DOCODE(STATUS_FLOAT_STACK_CHECK);
1108 DOCODE(STATUS_FLOAT_UNDERFLOW);
1109 DOCODE(STATUS_GUARD_PAGE_VIOLATION);
1110 DOCODE(STATUS_ILLEGAL_INSTRUCTION);
1111 DOCODE(STATUS_INTEGER_DIVIDE_BY_ZERO);
1112 DOCODE(STATUS_INTEGER_OVERFLOW);
1113 DOCODE(STATUS_INVALID_DISPOSITION);
1114 DOCODE(STATUS_IN_PAGE_ERROR);
1115 DOCODE(STATUS_NONCONTINUABLE_EXCEPTION);
1116 DOCODE(STATUS_NO_MEMORY);
1117 DOCODE(STATUS_PENDING);
1118 DOCODE(STATUS_PRIVILEGED_INSTRUCTION);
1119 DOCODE(STATUS_SINGLE_STEP);
1120 DOCODE(STATUS_STACK_OVERFLOW);
1121 DOCODE(STATUS_TIMEOUT);
1122 DOCODE(STATUS_USER_APC);
1123 DOCODE(STATUS_WAIT_0);
1132 MYWRITE (
fd, buf, snprintf (buf, buf_size,
"Exception: %s\n",
name));
1134 MYWRITE (
fd, buf, snprintf (buf, buf_size,
"Exception %lu\n",
1135 info->ExceptionCode));
1136 MYWRITE (
fd, buf, snprintf (buf, buf_size,
" addr = %08lx",
info->ExceptionAddress));
1138 #elif HAVE_POSIX_SIGNALS
1140 MYWRITE (
fd, buf, snprintf (buf, buf_size,
1141 " signo = %d, errno = %d, code = %d (%s)\n",
1147 MYWRITE (
fd, buf, snprintf (buf, buf_size,
" pid = %ld, uid = %ld\n",
1148 (
long)
info->si_pid, (
long)
info->si_uid));
1151 if (
sig == SIGCHLD) {
1156 const long utime =
info->si_utime;
1158 MYWRITE (
fd, buf, snprintf (buf, buf_size,
1159 " status = %ld, utime = %ld, stime = %ld\n",
1164 MYWRITE (
fd, buf, snprintf (buf, buf_size,
" value = (%d, %p)\n",
1168 if (
sig == SIGILL ||
sig == SIGFPE ||
sig == SIGSEGV ||
sig == SIGBUS)
1169 MYWRITE (
fd, buf, snprintf (buf, buf_size,
" addr = %p\n",
info->si_addr));
1171 # ifdef SIGPOLL // not darwin
1174 MYWRITE (
fd, buf, snprintf (buf, buf_size,
" band = %ld, fd = %d\n",
1175 (
long)
info->si_band,
info->si_fd));
1177 #endif // HAVE_POSIX_SIGNALS
1187 for (
size_t i = 0;
i <
n; )
1189 size_t m = snprintf (buf, buf_size,
"\n ");
1190 for (
size_t j = 0;
i <
n && j < 32; ++j, ++
i)
1191 m += snprintf (buf +
m, buf_size-
m,
"%s%02x",
1192 j % 4 == 0 ?
" " :
"",
1193 (
unsigned int) (((
const unsigned char *)
data) [
i]));
1208 unsigned long sp = 0;
1209 #if defined _WIN32 && defined _M_IX86
1210 const CONTEXT *uc =
static_cast<const CONTEXT *
> (context);
1212 MYWRITE (
fd, buf, snprintf (buf, buf_size,
"\n"
1213 "\n eip: %04lx:%08lx eflags: %08lx"
1214 "\n eax: %08lx ebx: %08lx"
1215 " ecx: %08lx edx: %08lx"
1216 "\n esi: %08lx edi: %08lx"
1217 " ebp: %08lx esp: %08lx"
1218 "\n ds: %04lx es: %04lx"
1219 " fs: %04lx ss: %04lx",
1220 uc->SegCs, uc->Eip, uc->EFlags,
1221 uc->Eax, uc->Ebx, uc->Ecx, uc->Edx,
1222 uc->Esi, uc->Edi, uc->Ebp, uc->Esp,
1223 uc->SegDs, uc->SegEs, uc->SegFs, uc->SegSs));
1225 MYWRITE (
fd, buf, snprintf (buf, buf_size,
1226 "\n FPU: control = %08lx"
1229 "\n ip = %04lx:%08lx"
1230 "\n data = %04lx:%08lx"
1232 uc->FloatSave.ControlWord,
1233 uc->FloatSave.StatusWord,
1234 uc->FloatSave.TagWord,
1235 uc->FloatSave.ErrorSelector,
1236 uc->FloatSave.ErrorOffset,
1237 uc->FloatSave.DataSelector,
1238 uc->FloatSave.DataOffset,
1239 uc->FloatSave.Cr0NpxState));
1241 for (
int i = 0;
i < 8; ++
i)
1242 MYWRITE (
fd, buf, snprintf (buf, buf_size.
1243 "\n %%fp%d = [%02x%02x:%02x%02x%02x%02x"
1244 "%02x%02x%02x%02x]",
1246 uc->FloatSave.RegisterArea [
i * 10 + 0],
1247 uc->FloatSave.RegisterArea [
i * 10 + 1],
1248 uc->FloatSave.RegisterArea [
i * 10 + 2],
1249 uc->FloatSave.RegisterArea [
i * 10 + 3],
1250 uc->FloatSave.RegisterArea [
i * 10 + 4],
1251 uc->FloatSave.RegisterArea [
i * 10 + 5],
1252 uc->FloatSave.RegisterArea [
i * 10 + 6],
1253 uc->FloatSave.RegisterArea [
i * 10 + 7],
1254 uc->FloatSave.RegisterArea [
i * 10 + 8],
1255 uc->FloatSave.RegisterArea [
i * 10 + 9]));
1258 #elif HAVE_POSIX_SIGNALS
1260 const ucontext_t *uc =
static_cast<const ucontext_t *
> (context);
1261 const mcontext_t *
mc = &uc->uc_mcontext;
1262 MYWRITE (
fd, buf, snprintf (buf, buf_size,
" stack = (%x, %x, %p)",
1263 uc->uc_stack.ss_flags,
1264 unsigned(uc->uc_stack.ss_size),
1265 uc->uc_stack.ss_sp));
1268 #if defined __i386 && defined __linux
1269 # if !defined REG_CS && defined CS
1275 # define REG_EIP EIP
1276 # define REG_EFL EFL
1277 # define REG_EAX EAX
1278 # define REG_EBX EBX
1279 # define REG_ECX ECX
1280 # define REG_EDX EDX
1281 # define REG_ESI ESI
1282 # define REG_EDI EDI
1283 # define REG_EBP EBP
1284 # define REG_ESP ESP
1285 # define REG_UESP UESP
1286 # define REG_TRAPNO TRAPNO
1287 # define REG_ERR ERR
1289 sp =
mc->gregs[REG_ESP];
1290 MYWRITE (
fd, buf, snprintf (buf, buf_size,
1291 "\n eip: %04x:%08x eflags: %08x"
1292 "\n eax: %08x ebx: %08x"
1293 " ecx: %08x edx: %08x"
1294 "\n esi: %08x edi: %08x"
1295 " ebp: %08x esp: %08x"
1296 "\n ds: %04x es: %04x"
1297 " fs: %04x ss: %04x",
1298 mc->gregs [REG_CS] & 0xffff,
mc->gregs [REG_EIP],
1299 mc->gregs [REG_EFL],
1300 mc->gregs [REG_EAX],
mc->gregs [REG_EBX],
1301 mc->gregs [REG_ECX],
mc->gregs [REG_EDX],
1302 mc->gregs [REG_ESI],
mc->gregs [REG_EDI],
1303 mc->gregs [REG_EBP],
mc->gregs [REG_ESP],
1304 mc->gregs [REG_DS] & 0xffff,
1305 mc->gregs [REG_ES] & 0xffff,
1306 mc->gregs [REG_FS] & 0xffff,
1307 mc->gregs [REG_SS] & 0xffff));
1309 MYWRITE (
fd, buf, snprintf (buf, buf__size,
1310 "\n\n signal esp: %08x"
1312 " oldmask: %08lx cr2: %08lx",
1313 mc->gregs [REG_UESP],
1314 mc->gregs [REG_TRAPNO],
mc->gregs [REG_ERR],
1315 mc->oldmask,
mc->cr2));
1319 MYWRITE (
fd, buf, snprintf (buf, buf_size,
1321 "\n FPU: control = %08lx"
1324 "\n ip = %04lx:%08lx"
1325 "\n data = %04lx:%08lx"
1327 mc->fpregs->cw,
mc->fpregs->sw,
mc->fpregs->tag,
1328 mc->fpregs->cssel & 0xffff,
mc->fpregs->ipoff,
1329 mc->fpregs->datasel & 0xffff,
mc->fpregs->dataoff,
1330 mc->fpregs->status));
1332 for (
int i = 0;
i < 8; ++
i)
1333 MYWRITE (
fd, buf, snprintf (buf, buf_size,
1334 "\n %%fp%d = [%04hx:%04hx%04hx%04hx%04hx]",
1336 mc->fpregs->_st [
i].exponent,
1337 mc->fpregs->_st [
i].significand [0],
1338 mc->fpregs->_st [
i].significand [1],
1339 mc->fpregs->_st [
i].significand [2],
1340 mc->fpregs->_st [
i].significand [3]));
1343 #elif defined __x86_64__ && defined __linux
1344 sp =
mc->gregs[REG_RSP];
1345 MYWRITE (
fd, buf, snprintf (buf, buf_size,
1346 "\n rip: %04x:%016llx eflags: %016llx"
1347 "\n rax: %016llx rbx: %016llx"
1348 "\n rcx: %016llx rdx: %016llx"
1349 "\n r08: %016llx r09: %016llx"
1350 "\n r10: %016llx r11: %016llx"
1351 "\n r12: %016llx r13: %016llx"
1352 "\n r14: %016llx r15: %016llx"
1353 "\n rsi: %016llx rdi: %016llx"
1354 "\n rbp: %016llx rsp: %016llx"
1355 "\n gs: %04x fs: %04x",
1356 (
unsigned)
mc->gregs [REG_CSGSFS] & 0xffff,
1357 (
unsigned long long)
mc->gregs [REG_RIP],
1358 (
unsigned long long)
mc->gregs [REG_EFL],
1359 (
unsigned long long)
mc->gregs [REG_RAX],
1360 (
unsigned long long)
mc->gregs [REG_RBX],
1361 (
unsigned long long)
mc->gregs [REG_RCX],
1362 (
unsigned long long)
mc->gregs [REG_RDX],
1363 (
unsigned long long)
mc->gregs [REG_R8],
1364 (
unsigned long long)
mc->gregs [REG_R9],
1365 (
unsigned long long)
mc->gregs [REG_R10],
1366 (
unsigned long long)
mc->gregs [REG_R11],
1367 (
unsigned long long)
mc->gregs [REG_R12],
1368 (
unsigned long long)
mc->gregs [REG_R13],
1369 (
unsigned long long)
mc->gregs [REG_R14],
1370 (
unsigned long long)
mc->gregs [REG_R15],
1371 (
unsigned long long)
mc->gregs [REG_RSI],
1372 (
unsigned long long)
mc->gregs [REG_RDI],
1373 (
unsigned long long)
mc->gregs [REG_RBP],
1374 (
unsigned long long)
mc->gregs [REG_RSP],
1375 (
unsigned)(
mc->gregs [REG_CSGSFS]>>16) & 0xffff,
1376 (
unsigned)(
mc->gregs [REG_CSGSFS]>>32) & 0xffff));
1378 MYWRITE (
fd, buf, snprintf (buf, buf_size,
1381 " oldmask: %16llx cr2: %016llx",
1382 (
unsigned long long)
mc->gregs [REG_TRAPNO],
1383 (
unsigned long long)
mc->gregs [REG_ERR],
1384 (
unsigned long long)
mc->gregs [REG_OLDMASK],
1385 (
unsigned long long)
mc->gregs [REG_CR2]));
1389 MYWRITE (
fd, buf, snprintf (buf, buf_size,
1391 "\n FPU: control = %04x"
1398 "\n mxcr_mask= %08x",
1406 mc->fpregs->mxcr_mask));
1408 for (
int i = 0;
i < 8; ++
i)
1409 MYWRITE (
fd, buf, snprintf (buf, buf_size,
1410 "\n %%fp%d = [%04hx:%04hx%04hx%04hx%04hx]",
1412 mc->fpregs->_st [
i].exponent,
1413 mc->fpregs->_st [
i].significand [0],
1414 mc->fpregs->_st [
i].significand [1],
1415 mc->fpregs->_st [
i].significand [2],
1416 mc->fpregs->_st [
i].significand [3]));
1418 for (
int i = 0;
i < 16; ++
i)
1419 MYWRITE (
fd, buf, snprintf (buf, buf_size,
1420 "\n %%xmm%02d = [%08x %08x %08x %08x]",
1422 mc->fpregs->_xmm[
i].element[0],
1423 mc->fpregs->_xmm[
i].element[1],
1424 mc->fpregs->_xmm[
i].element[2],
1425 mc->fpregs->_xmm[
i].element[3]));
1428 #elif __APPLE__ && defined __ppc__
1429 MYWRITE (
fd, buf, snprintf (buf, buf_size,
"\n dar: %08lx dsisr: %08lx exception: %08lx",
1430 (*mc)->es.dar, (*mc)->es.dsisr, (*mc)->es.exception));
1432 MYWRITE (
fd, buf, snprintf (buf, buf_size,
1433 "\n srr0: %08x srr1: %08x cr: %08x xer: %08x"
1434 "\n lr: %08x ctr: %08x vrsave: %08x fpscr: %08x",
1435 (*mc)->ss.srr0, (*mc)->ss.srr1, (*mc)->ss.cr, (*mc)->ss.xer,
1436 (*mc)->ss.lr, (*mc)->ss.ctr, (*mc)->ss.vrsave, (*mc)->fs.fpscr));
1438 MYWRITE (
fd, buf, snprintf (buf, buf_size,
"\n vrvalid: %08x vscr: %08lx:%08lx:%08lx:%08lx\n",
1439 (*mc)->vs.save_vrvalid,
1440 (*mc)->vs.save_vscr [0], (*mc)->vs.save_vscr [1],
1441 (*mc)->vs.save_vscr [2], (*mc)->vs.save_vscr [3]));
1443 for (
unsigned int *regs = &(*mc)->ss.r0,
i = 0;
i < 32;
i += 4)
1444 MYWRITE (
fd, buf, snprintf (buf, buf_size,
"\n r%-2d %08x r%-2d %08x r%-2d %08x r%-2d %08x",
1445 i, regs [
i],
i+1, regs [
i+1],
i+2, regs [
i+2],
i+3, regs [
i+3]));
1446 for (
int i = 0;
i < 32; ++
i)
1447 MYWRITE (
fd, buf, snprintf (buf, buf_size,
"\n fp%-2d %016qx (%f)",
i,
1448 *(
unsigned long long *) &(*mc)->fs.fpregs [
i],
1449 (*mc)->fs.fpregs [
i]));
1450 for (
int i = 0;
i < 32; ++
i)
1451 MYWRITE (
fd, buf, snprintf (buf, buf_size,
"\n vr%-2d %08lx:%08lx:%08lx:%08lx",
i,
1452 (*mc)->vs.save_vr[
i][0], (*mc)->vs.save_vr[
i][1],
1453 (*mc)->vs.save_vr[
i][2], (*mc)->vs.save_vr[
i][3]));
1454 #elif defined __aarch64__ && defined __linux
1455 CxxUtils::aarch64_dump_registers (
fd, buf, buf_size, *
mc);
1457 for (
int i = 0;
i < NGREG;
i++)
1458 MYWRITE (
fd, buf, snprintf (buf, buf_size,
"%s %%r%02d = %08x",
1459 i % 4 == 0 ?
"\n" :
"",
i,
mc->gregs [
i]));
1462 #endif // __i386 && __linux, __sun, other
1465 #endif // HAVE_POSIX_SIGNALS
1508 static char buf[SIGNAL_MESSAGE_BUFSIZE];
1512 return fatalDump (
sig,
info,
extra, s_fatalFd, s_fatalOptions);
1519 const unsigned int buf_size =
sizeof (buf);
1520 bool haveCore =
false;
1530 if (s_applicationName)
1533 STDC::strlen (s_applicationName));
1538 snprintf (buf, SIGNAL_MESSAGE_BUFSIZE,
"(pid=%ld ppid=%ld) received fatal signal %d"
1540 (
long) ProcessInfo__pid (), (
long) ProcessInfo__ppid (),
1541 sig,
name (
sig), haveCore ?
" (core dumped)" :
""));
1543 MYWRITE (
fd, buf, snprintf(buf, buf_size,
"signal context:\n"));
1544 dumpInfo (
fd, buf, buf_size,
sig,
info);
1547 unsigned long sp = 0;
1548 if (
options & FATAL_DUMP_CONTEXT)
1549 sp = dumpContext (
fd, buf, buf_size,
extra);
1551 if (
options & FATAL_DUMP_STACK)
1553 MYWRITE (
fd, buf, snprintf(buf, buf_size,
"\nstack trace:\n"));
1555 MYWRITE (
fd, buf, snprintf(buf, buf_size,
"\n(backtrace failed; raw dump follows)\n"));
1556 MYWRITE (
fd, buf, snprintf(buf, buf_size,
"%016lx:", s_lastSP.load()));
1557 dumpMemory (
fd, buf, buf_size,
reinterpret_cast<void*
>(s_lastSP.load()), 1024);
1558 MYWRITE (
fd, buf, snprintf(buf, buf_size,
"\n\n"));
1562 DebugAids::stacktrace (
fd);
1567 if (
options & FATAL_DUMP_LIBS)
1569 MYWRITE (
fd, buf, snprintf(buf, buf_size,
"\nshared libraries present:\n"));
1593 {
return s_fatalHook; }
1599 {
return s_fatalReturn; }
1605 {
return s_fatalOptions; }
1611 {
return s_quitHook; }
1623 {
return s_inFatal; }
1630 {
return s_crashed; }
1641 Athena::Signal::handleFatal(
nullptr, 1);