comparison src/os/linux/vm/os_linux.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
2229 st->print(" <Not Available>"); 2229 st->print(" <Not Available>");
2230 } 2230 }
2231 st->cr(); 2231 st->cr();
2232 } 2232 }
2233 2233
2234 // Taken from /usr/include/bits/siginfo.h Supposed to be architecture specific
2235 // but they're the same for all the linux arch that we support
2236 // and they're the same for solaris but there's no common place to put this.
2237 const char *ill_names[] = { "ILL0", "ILL_ILLOPC", "ILL_ILLOPN", "ILL_ILLADR",
2238 "ILL_ILLTRP", "ILL_PRVOPC", "ILL_PRVREG",
2239 "ILL_COPROC", "ILL_BADSTK" };
2240
2241 const char *fpe_names[] = { "FPE0", "FPE_INTDIV", "FPE_INTOVF", "FPE_FLTDIV",
2242 "FPE_FLTOVF", "FPE_FLTUND", "FPE_FLTRES",
2243 "FPE_FLTINV", "FPE_FLTSUB", "FPE_FLTDEN" };
2244
2245 const char *segv_names[] = { "SEGV0", "SEGV_MAPERR", "SEGV_ACCERR" };
2246
2247 const char *bus_names[] = { "BUS0", "BUS_ADRALN", "BUS_ADRERR", "BUS_OBJERR" };
2248
2249 void os::print_siginfo(outputStream* st, void* siginfo) { 2234 void os::print_siginfo(outputStream* st, void* siginfo) {
2250 st->print("siginfo:"); 2235 const siginfo_t* si = (const siginfo_t*)siginfo;
2251 2236
2252 const int buflen = 100; 2237 os::Posix::print_siginfo_brief(st, si);
2253 char buf[buflen]; 2238
2254 siginfo_t *si = (siginfo_t*)siginfo; 2239 if (si && (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) &&
2255 st->print("si_signo=%s: ", os::exception_name(si->si_signo, buf, buflen));
2256 if (si->si_errno != 0 && strerror_r(si->si_errno, buf, buflen) == 0) {
2257 st->print("si_errno=%s", buf);
2258 } else {
2259 st->print("si_errno=%d", si->si_errno);
2260 }
2261 const int c = si->si_code;
2262 assert(c > 0, "unexpected si_code");
2263 switch (si->si_signo) {
2264 case SIGILL:
2265 st->print(", si_code=%d (%s)", c, c > 8 ? "" : ill_names[c]);
2266 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
2267 break;
2268 case SIGFPE:
2269 st->print(", si_code=%d (%s)", c, c > 9 ? "" : fpe_names[c]);
2270 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
2271 break;
2272 case SIGSEGV:
2273 st->print(", si_code=%d (%s)", c, c > 2 ? "" : segv_names[c]);
2274 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
2275 break;
2276 case SIGBUS:
2277 st->print(", si_code=%d (%s)", c, c > 3 ? "" : bus_names[c]);
2278 st->print(", si_addr=" PTR_FORMAT, si->si_addr);
2279 break;
2280 default:
2281 st->print(", si_code=%d", si->si_code);
2282 // no si_addr
2283 }
2284
2285 if ((si->si_signo == SIGBUS || si->si_signo == SIGSEGV) &&
2286 UseSharedSpaces) { 2240 UseSharedSpaces) {
2287 FileMapInfo* mapinfo = FileMapInfo::current_info(); 2241 FileMapInfo* mapinfo = FileMapInfo::current_info();
2288 if (mapinfo->is_in_shared_space(si->si_addr)) { 2242 if (mapinfo->is_in_shared_space(si->si_addr)) {
2289 st->print("\n\nError accessing class data sharing archive." \ 2243 st->print("\n\nError accessing class data sharing archive." \
2290 " Mapped file inaccessible during execution, " \ 2244 " Mapped file inaccessible during execution, " \
4276 st->print("SIG_IGN"); 4230 st->print("SIG_IGN");
4277 } else { 4231 } else {
4278 st->print("[%s]", get_signal_handler_name(handler, buf, buflen)); 4232 st->print("[%s]", get_signal_handler_name(handler, buf, buflen));
4279 } 4233 }
4280 4234
4281 st->print(", sa_mask[0]=" PTR32_FORMAT, *(uint32_t*)&sa.sa_mask); 4235 st->print(", sa_mask[0]=");
4236 os::Posix::print_signal_set_short(st, &sa.sa_mask);
4282 4237
4283 address rh = VMError::get_resetted_sighandler(sig); 4238 address rh = VMError::get_resetted_sighandler(sig);
4284 // May be, handler was resetted by VMError? 4239 // May be, handler was resetted by VMError?
4285 if(rh != NULL) { 4240 if(rh != NULL) {
4286 handler = rh; 4241 handler = rh;
4287 sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK; 4242 sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK;
4288 } 4243 }
4289 4244
4290 st->print(", sa_flags=" PTR32_FORMAT, sa.sa_flags); 4245 st->print(", sa_flags=");
4246 os::Posix::print_sa_flags(st, sa.sa_flags);
4291 4247
4292 // Check: is it our handler? 4248 // Check: is it our handler?
4293 if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) || 4249 if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) ||
4294 handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) { 4250 handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) {
4295 // It is our signal handler 4251 // It is our signal handler