2214
2215 st->print(", physical " UINT64_FORMAT "k",
2216 os::physical_memory() >> 10);
2217 st->print("(" UINT64_FORMAT "k free)",
2218 os::available_memory() >> 10);
2219 st->print(", swap " UINT64_FORMAT "k",
2220 ((jlong)si.totalswap * si.mem_unit) >> 10);
2221 st->print("(" UINT64_FORMAT "k free)",
2222 ((jlong)si.freeswap * si.mem_unit) >> 10);
2223 st->cr();
2224 }
2225
2226 void os::pd_print_cpu_info(outputStream* st) {
2227 st->print("\n/proc/cpuinfo:\n");
2228 if (!_print_ascii_file("/proc/cpuinfo", st)) {
2229 st->print(" <Not Available>");
2230 }
2231 st->cr();
2232 }
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) {
2250 st->print("siginfo:");
2251
2252 const int buflen = 100;
2253 char buf[buflen];
2254 siginfo_t *si = (siginfo_t*)siginfo;
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) {
2287 FileMapInfo* mapinfo = FileMapInfo::current_info();
2288 if (mapinfo->is_in_shared_space(si->si_addr)) {
2289 st->print("\n\nError accessing class data sharing archive." \
2290 " Mapped file inaccessible during execution, " \
2291 " possible disk/network problem.");
2292 }
2293 }
2294 st->cr();
2295 }
2296
2297
2298 static void print_signal_handler(outputStream* st, int sig,
2299 char* buf, size_t buflen);
2300
2301 void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
2302 st->print_cr("Signal Handlers:");
2303 print_signal_handler(st, SIGSEGV, buf, buflen);
2304 print_signal_handler(st, SIGBUS , buf, buflen);
2305 print_signal_handler(st, SIGFPE , buf, buflen);
4261
4262 sigaction(sig, NULL, &sa);
4263
4264 // See comment for SIGNIFICANT_SIGNAL_MASK define
4265 sa.sa_flags &= SIGNIFICANT_SIGNAL_MASK;
4266
4267 st->print("%s: ", os::exception_name(sig, buf, buflen));
4268
4269 address handler = (sa.sa_flags & SA_SIGINFO)
4270 ? CAST_FROM_FN_PTR(address, sa.sa_sigaction)
4271 : CAST_FROM_FN_PTR(address, sa.sa_handler);
4272
4273 if (handler == CAST_FROM_FN_PTR(address, SIG_DFL)) {
4274 st->print("SIG_DFL");
4275 } else if (handler == CAST_FROM_FN_PTR(address, SIG_IGN)) {
4276 st->print("SIG_IGN");
4277 } else {
4278 st->print("[%s]", get_signal_handler_name(handler, buf, buflen));
4279 }
4280
4281 st->print(", sa_mask[0]=" PTR32_FORMAT, *(uint32_t*)&sa.sa_mask);
4282
4283 address rh = VMError::get_resetted_sighandler(sig);
4284 // May be, handler was resetted by VMError?
4285 if(rh != NULL) {
4286 handler = rh;
4287 sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK;
4288 }
4289
4290 st->print(", sa_flags=" PTR32_FORMAT, sa.sa_flags);
4291
4292 // Check: is it our handler?
4293 if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) ||
4294 handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) {
4295 // It is our signal handler
4296 // check for flags, reset system-used one!
4297 if((int)sa.sa_flags != os::Linux::get_our_sigflags(sig)) {
4298 st->print(
4299 ", flags was changed from " PTR32_FORMAT ", consider using jsig library",
4300 os::Linux::get_our_sigflags(sig));
4301 }
4302 }
4303 st->cr();
4304 }
4305
4306
4307 #define DO_SIGNAL_CHECK(sig) \
4308 if (!sigismember(&check_signal_done, sig)) \
4309 os::Linux::check_signal_handler(sig)
4310
|
2214
2215 st->print(", physical " UINT64_FORMAT "k",
2216 os::physical_memory() >> 10);
2217 st->print("(" UINT64_FORMAT "k free)",
2218 os::available_memory() >> 10);
2219 st->print(", swap " UINT64_FORMAT "k",
2220 ((jlong)si.totalswap * si.mem_unit) >> 10);
2221 st->print("(" UINT64_FORMAT "k free)",
2222 ((jlong)si.freeswap * si.mem_unit) >> 10);
2223 st->cr();
2224 }
2225
2226 void os::pd_print_cpu_info(outputStream* st) {
2227 st->print("\n/proc/cpuinfo:\n");
2228 if (!_print_ascii_file("/proc/cpuinfo", st)) {
2229 st->print(" <Not Available>");
2230 }
2231 st->cr();
2232 }
2233
2234 void os::print_siginfo(outputStream* st, void* siginfo) {
2235 const siginfo_t* si = (const siginfo_t*)siginfo;
2236
2237 os::Posix::print_siginfo_brief(st, si);
2238
2239 if (si && (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) &&
2240 UseSharedSpaces) {
2241 FileMapInfo* mapinfo = FileMapInfo::current_info();
2242 if (mapinfo->is_in_shared_space(si->si_addr)) {
2243 st->print("\n\nError accessing class data sharing archive." \
2244 " Mapped file inaccessible during execution, " \
2245 " possible disk/network problem.");
2246 }
2247 }
2248 st->cr();
2249 }
2250
2251
2252 static void print_signal_handler(outputStream* st, int sig,
2253 char* buf, size_t buflen);
2254
2255 void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
2256 st->print_cr("Signal Handlers:");
2257 print_signal_handler(st, SIGSEGV, buf, buflen);
2258 print_signal_handler(st, SIGBUS , buf, buflen);
2259 print_signal_handler(st, SIGFPE , buf, buflen);
4215
4216 sigaction(sig, NULL, &sa);
4217
4218 // See comment for SIGNIFICANT_SIGNAL_MASK define
4219 sa.sa_flags &= SIGNIFICANT_SIGNAL_MASK;
4220
4221 st->print("%s: ", os::exception_name(sig, buf, buflen));
4222
4223 address handler = (sa.sa_flags & SA_SIGINFO)
4224 ? CAST_FROM_FN_PTR(address, sa.sa_sigaction)
4225 : CAST_FROM_FN_PTR(address, sa.sa_handler);
4226
4227 if (handler == CAST_FROM_FN_PTR(address, SIG_DFL)) {
4228 st->print("SIG_DFL");
4229 } else if (handler == CAST_FROM_FN_PTR(address, SIG_IGN)) {
4230 st->print("SIG_IGN");
4231 } else {
4232 st->print("[%s]", get_signal_handler_name(handler, buf, buflen));
4233 }
4234
4235 st->print(", sa_mask[0]=");
4236 os::Posix::print_signal_set_short(st, &sa.sa_mask);
4237
4238 address rh = VMError::get_resetted_sighandler(sig);
4239 // May be, handler was resetted by VMError?
4240 if(rh != NULL) {
4241 handler = rh;
4242 sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK;
4243 }
4244
4245 st->print(", sa_flags=");
4246 os::Posix::print_sa_flags(st, sa.sa_flags);
4247
4248 // Check: is it our handler?
4249 if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) ||
4250 handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) {
4251 // It is our signal handler
4252 // check for flags, reset system-used one!
4253 if((int)sa.sa_flags != os::Linux::get_our_sigflags(sig)) {
4254 st->print(
4255 ", flags was changed from " PTR32_FORMAT ", consider using jsig library",
4256 os::Linux::get_our_sigflags(sig));
4257 }
4258 }
4259 st->cr();
4260 }
4261
4262
4263 #define DO_SIGNAL_CHECK(sig) \
4264 if (!sigismember(&check_signal_done, sig)) \
4265 os::Linux::check_signal_handler(sig)
4266
|