comparison src/os/bsd/vm/os_bsd.cpp @ 14410:f42f2e2a1518

8020775: PPC64 (part 12): posix signal printing Summary: Implement methods printing posix signal information and call them in unix os files. Reviewed-by: kvn, dholmes, twisti Contributed-by: thomas.stuefe@sap.com
author goetz
date Fri, 26 Jul 2013 00:59:18 +0200
parents 438e13354adf
children e2722a66aba7
comparison
equal deleted inserted replaced
14409:b55e4bd0389e 14410:f42f2e2a1518
1616 st->print("\n/proc/meminfo:\n"); 1616 st->print("\n/proc/meminfo:\n");
1617 _print_ascii_file("/proc/meminfo", st); 1617 _print_ascii_file("/proc/meminfo", st);
1618 st->cr(); 1618 st->cr();
1619 } 1619 }
1620 1620
1621 // Taken from /usr/include/bits/siginfo.h Supposed to be architecture specific
1622 // but they're the same for all the bsd arch that we support
1623 // and they're the same for solaris but there's no common place to put this.
1624 const char *ill_names[] = { "ILL0", "ILL_ILLOPC", "ILL_ILLOPN", "ILL_ILLADR",
1625 "ILL_ILLTRP", "ILL_PRVOPC", "ILL_PRVREG",
1626 "ILL_COPROC", "ILL_BADSTK" };
1627
1628 const char *fpe_names[] = { "FPE0", "FPE_INTDIV", "FPE_INTOVF", "FPE_FLTDIV",
1629 "FPE_FLTOVF", "FPE_FLTUND", "FPE_FLTRES",
1630 "FPE_FLTINV", "FPE_FLTSUB", "FPE_FLTDEN" };
1631
1632 const char *segv_names[] = { "SEGV0", "SEGV_MAPERR", "SEGV_ACCERR" };
1633
1634 const char *bus_names[] = { "BUS0", "BUS_ADRALN", "BUS_ADRERR", "BUS_OBJERR" };
1635
1636 void os::print_siginfo(outputStream* st, void* siginfo) { 1621 void os::print_siginfo(outputStream* st, void* siginfo) {
1637 st->print("siginfo:"); 1622 const siginfo_t* si = (const siginfo_t*)siginfo;
1638 1623
1639 const int buflen = 100; 1624 os::Posix::print_siginfo_brief(st, si);
1640 char buf[buflen]; 1625
1641 siginfo_t *si = (siginfo_t*)siginfo; 1626 if (si && (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) &&
1642 st->print("si_signo=%s: ", os::exception_name(si->si_signo, buf, buflen));
1643 if (si->si_errno != 0 && strerror_r(si->si_errno, buf, buflen) == 0) {
1644 st->print("si_errno=%s", buf);
1645 } else {
1646 st->print("si_errno=%d", si->si_errno);
1647 }
1648 const int c = si->si_code;
1649 assert(c > 0, "unexpected si_code");
1650 switch (si->si_signo) {
1651 case SIGILL:
1652 st->print(", si_code=%d (%s)", c, c > 8 ? "" : ill_names[c]);
1653 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
1654 break;
1655 case SIGFPE:
1656 st->print(", si_code=%d (%s)", c, c > 9 ? "" : fpe_names[c]);
1657 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
1658 break;
1659 case SIGSEGV:
1660 st->print(", si_code=%d (%s)", c, c > 2 ? "" : segv_names[c]);
1661 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
1662 break;
1663 case SIGBUS:
1664 st->print(", si_code=%d (%s)", c, c > 3 ? "" : bus_names[c]);
1665 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
1666 break;
1667 default:
1668 st->print(", si_code=%d", si->si_code);
1669 // no si_addr
1670 }
1671
1672 if ((si->si_signo == SIGBUS || si->si_signo == SIGSEGV) &&
1673 UseSharedSpaces) { 1627 UseSharedSpaces) {
1674 FileMapInfo* mapinfo = FileMapInfo::current_info(); 1628 FileMapInfo* mapinfo = FileMapInfo::current_info();
1675 if (mapinfo->is_in_shared_space(si->si_addr)) { 1629 if (mapinfo->is_in_shared_space(si->si_addr)) {
1676 st->print("\n\nError accessing class data sharing archive." \ 1630 st->print("\n\nError accessing class data sharing archive." \
1677 " Mapped file inaccessible during execution, " \ 1631 " Mapped file inaccessible during execution, " \
3336 st->print("SIG_IGN"); 3290 st->print("SIG_IGN");
3337 } else { 3291 } else {
3338 st->print("[%s]", get_signal_handler_name(handler, buf, buflen)); 3292 st->print("[%s]", get_signal_handler_name(handler, buf, buflen));
3339 } 3293 }
3340 3294
3341 st->print(", sa_mask[0]=" PTR32_FORMAT, *(uint32_t*)&sa.sa_mask); 3295 st->print(", sa_mask[0]=");
3296 os::Posix::print_signal_set_short(st, &sa.sa_mask);
3342 3297
3343 address rh = VMError::get_resetted_sighandler(sig); 3298 address rh = VMError::get_resetted_sighandler(sig);
3344 // May be, handler was resetted by VMError? 3299 // May be, handler was resetted by VMError?
3345 if(rh != NULL) { 3300 if(rh != NULL) {
3346 handler = rh; 3301 handler = rh;
3347 sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK; 3302 sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK;
3348 } 3303 }
3349 3304
3350 st->print(", sa_flags=" PTR32_FORMAT, sa.sa_flags); 3305 st->print(", sa_flags=");
3306 os::Posix::print_sa_flags(st, sa.sa_flags);
3351 3307
3352 // Check: is it our handler? 3308 // Check: is it our handler?
3353 if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) || 3309 if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) ||
3354 handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) { 3310 handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) {
3355 // It is our signal handler 3311 // It is our signal handler