1 /* 2 * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 // no precompiled headers 26 #include "jvm.h" 27 #include "asm/macroAssembler.hpp" 28 #include "macroAssembler_sparc.hpp" 29 #include "classfile/classLoader.hpp" 30 #include "classfile/systemDictionary.hpp" 31 #include "classfile/vmSymbols.hpp" 32 #include "code/codeCache.hpp" 33 #include "code/icBuffer.hpp" 34 #include "code/vtableStubs.hpp" 35 #include "interpreter/interpreter.hpp" 36 #include "memory/allocation.inline.hpp" 37 #include "nativeInst_sparc.hpp" 38 #include "os_share_solaris.hpp" 39 #include "prims/jniFastGetField.hpp" 40 #include "prims/jvm_misc.hpp" 41 #include "runtime/arguments.hpp" 42 #include "runtime/extendedPC.hpp" 43 #include "runtime/frame.inline.hpp" 44 #include "runtime/interfaceSupport.inline.hpp" 45 #include "runtime/java.hpp" 46 #include "runtime/javaCalls.hpp" 47 #include "runtime/mutexLocker.hpp" 48 #include "runtime/osThread.hpp" 49 #include "runtime/sharedRuntime.hpp" 50 #include "runtime/stubRoutines.hpp" 51 #include "runtime/thread.inline.hpp" 52 #include "runtime/timer.hpp" 53 #include "utilities/events.hpp" 54 #include "utilities/vmError.hpp" 55 56 # include <signal.h> // needed first to avoid name collision for "std" with SC 5.0 57 58 // put OS-includes here 59 # include <sys/types.h> 60 # include <sys/mman.h> 61 # include <pthread.h> 62 # include <errno.h> 63 # include <dlfcn.h> 64 # include <stdio.h> 65 # include <unistd.h> 66 # include <sys/resource.h> 67 # include <thread.h> 68 # include <sys/stat.h> 69 # include <sys/time.h> 70 # include <sys/filio.h> 71 # include <sys/utsname.h> 72 # include <sys/systeminfo.h> 73 # include <sys/socket.h> 74 # include <sys/lwp.h> 75 # include <poll.h> 76 # include <sys/lwp.h> 77 78 # define _STRUCTURED_PROC 1 // this gets us the new structured proc interfaces of 5.6 & later 79 # include <sys/procfs.h> // see comment in <sys/procfs.h> 80 81 #define MAX_PATH (2 * K) 82 83 // Minimum usable stack sizes required to get to user code. Space for 84 // HotSpot guard pages is added later. 85 size_t os::Posix::_compiler_thread_min_stack_allowed = 104 * K; 86 size_t os::Posix::_java_thread_min_stack_allowed = 86 * K; 87 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; 88 89 static void handle_unflushed_register_windows(gwindows_t *win) { 90 int restore_count = win->wbcnt; 91 int i; 92 93 for(i=0; i<restore_count; i++) { 94 address sp = ((address)win->spbuf[i]) + STACK_BIAS; 95 address reg_win = (address)&win->wbuf[i]; 96 memcpy(sp,reg_win,sizeof(struct rwindow)); 97 } 98 } 99 100 char* os::non_memory_address_word() { 101 // Must never look like an address returned by reserve_memory, 102 // even in its subfields (as defined by the CPU immediate fields, 103 // if the CPU splits constants across multiple instructions). 104 // On SPARC, 0 != %hi(any real address), because there is no 105 // allocation in the first 1Kb of the virtual address space. 106 return (char*) 0; 107 } 108 109 // Validate a ucontext retrieved from walking a uc_link of a ucontext. 110 // There are issues with libthread giving out uc_links for different threads 111 // on the same uc_link chain and bad or circular links. 112 // 113 bool os::Solaris::valid_ucontext(Thread* thread, const ucontext_t* valid, const ucontext_t* suspect) { 114 if (valid >= suspect || 115 valid->uc_stack.ss_flags != suspect->uc_stack.ss_flags || 116 valid->uc_stack.ss_sp != suspect->uc_stack.ss_sp || 117 valid->uc_stack.ss_size != suspect->uc_stack.ss_size) { 118 DEBUG_ONLY(tty->print_cr("valid_ucontext: failed test 1");) 119 return false; 120 } 121 122 if (thread->is_Java_thread()) { 123 if (!valid_stack_address(thread, (address)suspect)) { 124 DEBUG_ONLY(tty->print_cr("valid_ucontext: uc_link not in thread stack");) 125 return false; 126 } 127 address _sp = (address)((intptr_t)suspect->uc_mcontext.gregs[REG_SP] + STACK_BIAS); 128 if (!valid_stack_address(thread, _sp) || 129 !frame::is_valid_stack_pointer(((JavaThread*)thread)->base_of_stack_pointer(), (intptr_t*)_sp)) { 130 DEBUG_ONLY(tty->print_cr("valid_ucontext: stackpointer not in thread stack");) 131 return false; 132 } 133 } 134 return true; 135 } 136 137 // We will only follow one level of uc_link since there are libthread 138 // issues with ucontext linking and it is better to be safe and just 139 // let caller retry later. 140 const ucontext_t* os::Solaris::get_valid_uc_in_signal_handler(Thread *thread, 141 const ucontext_t *uc) { 142 143 const ucontext_t *retuc = NULL; 144 145 // Sometimes the topmost register windows are not properly flushed. 146 // i.e., if the kernel would have needed to take a page fault 147 if (uc != NULL && uc->uc_mcontext.gwins != NULL) { 148 ::handle_unflushed_register_windows(uc->uc_mcontext.gwins); 149 } 150 151 if (uc != NULL) { 152 if (uc->uc_link == NULL) { 153 // cannot validate without uc_link so accept current ucontext 154 retuc = uc; 155 } else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) { 156 // first ucontext is valid so try the next one 157 uc = uc->uc_link; 158 if (uc->uc_link == NULL) { 159 // cannot validate without uc_link so accept current ucontext 160 retuc = uc; 161 } else if (os::Solaris::valid_ucontext(thread, uc, uc->uc_link)) { 162 // the ucontext one level down is also valid so return it 163 retuc = uc; 164 } 165 } 166 } 167 return retuc; 168 } 169 170 // Assumes ucontext is valid 171 ExtendedPC os::Solaris::ucontext_get_ExtendedPC(const ucontext_t *uc) { 172 address pc = (address)uc->uc_mcontext.gregs[REG_PC]; 173 // set npc to zero to avoid using it for safepoint, good for profiling only 174 return ExtendedPC(pc); 175 } 176 177 void os::Solaris::ucontext_set_pc(ucontext_t* uc, address pc) { 178 uc->uc_mcontext.gregs [REG_PC] = (greg_t) pc; 179 uc->uc_mcontext.gregs [REG_nPC] = (greg_t) (pc + 4); 180 } 181 182 // Assumes ucontext is valid 183 intptr_t* os::Solaris::ucontext_get_sp(const ucontext_t *uc) { 184 return (intptr_t*)((intptr_t)uc->uc_mcontext.gregs[REG_SP] + STACK_BIAS); 185 } 186 187 // Solaris X86 only 188 intptr_t* os::Solaris::ucontext_get_fp(const ucontext_t *uc) { 189 ShouldNotReachHere(); 190 return NULL; 191 } 192 193 address os::Solaris::ucontext_get_pc(const ucontext_t *uc) { 194 return (address) uc->uc_mcontext.gregs[REG_PC]; 195 } 196 197 198 // For Forte Analyzer AsyncGetCallTrace profiling support - thread 199 // is currently interrupted by SIGPROF. 200 // 201 // ret_fp parameter is only used by Solaris X86. 202 // 203 // The difference between this and os::fetch_frame_from_context() is that 204 // here we try to skip nested signal frames. 205 // This method is also used for stack overflow signal handling. 206 ExtendedPC os::Solaris::fetch_frame_from_ucontext(Thread* thread, 207 const ucontext_t* uc, intptr_t** ret_sp, intptr_t** ret_fp) { 208 209 assert(thread != NULL, "just checking"); 210 assert(ret_sp != NULL, "just checking"); 211 assert(ret_fp == NULL, "just checking"); 212 213 const ucontext_t *luc = os::Solaris::get_valid_uc_in_signal_handler(thread, uc); 214 215 return os::fetch_frame_from_context(luc, ret_sp, ret_fp); 216 } 217 218 219 // ret_fp parameter is only used by Solaris X86. 220 ExtendedPC os::fetch_frame_from_context(const void* ucVoid, 221 intptr_t** ret_sp, intptr_t** ret_fp) { 222 223 ExtendedPC epc; 224 const ucontext_t *uc = (const ucontext_t*)ucVoid; 225 226 if (uc != NULL) { 227 epc = os::Solaris::ucontext_get_ExtendedPC(uc); 228 if (ret_sp) *ret_sp = os::Solaris::ucontext_get_sp(uc); 229 } else { 230 // construct empty ExtendedPC for return value checking 231 epc = ExtendedPC(NULL); 232 if (ret_sp) *ret_sp = (intptr_t *)NULL; 233 } 234 235 return epc; 236 } 237 238 frame os::fetch_frame_from_context(const void* ucVoid) { 239 intptr_t* sp; 240 intptr_t* fp; 241 ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp); 242 return frame(sp, frame::unpatchable, epc.pc()); 243 } 244 245 frame os::fetch_frame_from_ucontext(Thread* thread, void* ucVoid) { 246 intptr_t* sp; 247 ExtendedPC epc = os::Solaris::fetch_frame_from_ucontext(thread, (ucontext_t*)ucVoid, &sp, NULL); 248 return frame(sp, frame::unpatchable, epc.pc()); 249 } 250 251 bool os::Solaris::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) { 252 address pc = (address) os::Solaris::ucontext_get_pc(uc); 253 if (Interpreter::contains(pc)) { 254 *fr = os::fetch_frame_from_ucontext(thread, uc); 255 if (!fr->is_first_java_frame()) { 256 assert(fr->safe_for_sender(thread), "Safety check"); 257 *fr = fr->java_sender(); 258 } 259 } else { 260 // more complex code with compiled code 261 assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above"); 262 CodeBlob* cb = CodeCache::find_blob(pc); 263 if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) { 264 // Not sure where the pc points to, fallback to default 265 // stack overflow handling 266 return false; 267 } else { 268 // Returned frame will be the caller of the method that faults on the stack bang. 269 // Register window not yet rotated (happens at SAVE after stack bang), so there is no new 270 // frame to go with the faulting PC. Using caller SP that is still in SP, and caller PC 271 // that was written to O7 at call. 272 intptr_t* sp = os::Solaris::ucontext_get_sp(uc); 273 address pc = (address)uc->uc_mcontext.gregs[REG_O7]; 274 *fr = frame(sp, frame::unpatchable, pc); 275 276 if (!fr->is_java_frame()) { 277 assert(fr->safe_for_sender(thread), "Safety check"); 278 *fr = fr->java_sender(); 279 } 280 } 281 } 282 assert(fr->is_java_frame(), "Safety check"); 283 return true; 284 } 285 286 frame os::get_sender_for_C_frame(frame* fr) { 287 return frame(fr->sender_sp(), frame::unpatchable, fr->sender_pc()); 288 } 289 290 // Returns an estimate of the current stack pointer. Result must be guaranteed to 291 // point into the calling threads stack, and be no lower than the current stack 292 // pointer. 293 address os::current_stack_pointer() { 294 volatile int dummy; 295 address sp = (address)&dummy + 8; // %%%% need to confirm if this is right 296 return sp; 297 } 298 299 frame os::current_frame() { 300 intptr_t* sp = StubRoutines::Sparc::flush_callers_register_windows_func()(); 301 frame myframe(sp, frame::unpatchable, 302 CAST_FROM_FN_PTR(address, os::current_frame)); 303 if (os::is_first_C_frame(&myframe)) { 304 // stack is not walkable 305 return frame(NULL, NULL, false); 306 } else { 307 return os::get_sender_for_C_frame(&myframe); 308 } 309 } 310 311 bool os::is_allocatable(size_t bytes) { 312 return true; 313 } 314 315 extern "C" JNIEXPORT int 316 JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, 317 int abort_if_unrecognized) { 318 ucontext_t* uc = (ucontext_t*) ucVoid; 319 320 Thread* t = Thread::current_or_null_safe(); 321 322 // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away 323 // (no destructors can be run) 324 os::ThreadCrashProtection::check_crash_protection(sig, t); 325 326 SignalHandlerMark shm(t); 327 328 if(sig == SIGPIPE || sig == SIGXFSZ) { 329 if (os::Solaris::chained_handler(sig, info, ucVoid)) { 330 return true; 331 } else { 332 // Ignoring SIGPIPE/SIGXFSZ - see bugs 4229104 or 6499219 333 return true; 334 } 335 } 336 337 JavaThread* thread = NULL; 338 VMThread* vmthread = NULL; 339 if (os::Solaris::signal_handlers_are_installed) { 340 if (t != NULL ){ 341 if(t->is_Java_thread()) { 342 thread = (JavaThread*)t; 343 } 344 else if(t->is_VM_thread()){ 345 vmthread = (VMThread *)t; 346 } 347 } 348 } 349 350 if (sig == ASYNC_SIGNAL) { 351 if (thread || vmthread) { 352 OSThread::SR_handler(t, uc); 353 return true; 354 } else if (os::Solaris::chained_handler(sig, info, ucVoid)) { 355 return true; 356 } else { 357 // If ASYNC_SIGNAL not chained, and this is a non-vm and 358 // non-java thread 359 return true; 360 } 361 } 362 363 if (info == NULL || info->si_code <= 0 || info->si_code == SI_NOINFO) { 364 // can't decode this kind of signal 365 info = NULL; 366 } else { 367 assert(sig == info->si_signo, "bad siginfo"); 368 } 369 370 // decide if this trap can be handled by a stub 371 address stub = NULL; 372 373 address pc = NULL; 374 address npc = NULL; 375 376 //%note os_trap_1 377 if (info != NULL && uc != NULL && thread != NULL) { 378 // factor me: getPCfromContext 379 pc = (address) uc->uc_mcontext.gregs[REG_PC]; 380 npc = (address) uc->uc_mcontext.gregs[REG_nPC]; 381 382 // SafeFetch() support 383 if (StubRoutines::is_safefetch_fault(pc)) { 384 os::Solaris::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); 385 return 1; 386 } 387 388 // Handle ALL stack overflow variations here 389 if (sig == SIGSEGV && info->si_code == SEGV_ACCERR) { 390 address addr = (address) info->si_addr; 391 if (thread->in_stack_yellow_reserved_zone(addr)) { 392 // Sometimes the register windows are not properly flushed. 393 if(uc->uc_mcontext.gwins != NULL) { 394 ::handle_unflushed_register_windows(uc->uc_mcontext.gwins); 395 } 396 if (thread->thread_state() == _thread_in_Java) { 397 if (thread->in_stack_reserved_zone(addr)) { 398 frame fr; 399 if (os::Solaris::get_frame_at_stack_banging_point(thread, uc, &fr)) { 400 assert(fr.is_java_frame(), "Must be a Java frame"); 401 frame activation = SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr); 402 if (activation.sp() != NULL) { 403 thread->disable_stack_reserved_zone(); 404 RegisterMap map(thread); 405 int frame_size = activation.frame_size(&map); 406 thread->set_reserved_stack_activation((address)(((address)activation.sp()) - STACK_BIAS)); 407 return true; 408 } 409 } 410 } 411 // Throw a stack overflow exception. Guard pages will be reenabled 412 // while unwinding the stack. 413 thread->disable_stack_yellow_reserved_zone(); 414 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW); 415 } else { 416 // Thread was in the vm or native code. Return and try to finish. 417 thread->disable_stack_yellow_reserved_zone(); 418 return true; 419 } 420 } else if (thread->in_stack_red_zone(addr)) { 421 // Fatal red zone violation. Disable the guard pages and fall through 422 // to handle_unexpected_exception way down below. 423 thread->disable_stack_red_zone(); 424 tty->print_raw_cr("An irrecoverable stack overflow has occurred."); 425 // Sometimes the register windows are not properly flushed. 426 if(uc->uc_mcontext.gwins != NULL) { 427 ::handle_unflushed_register_windows(uc->uc_mcontext.gwins); 428 } 429 } 430 } 431 432 433 if (thread->thread_state() == _thread_in_vm || 434 thread->thread_state() == _thread_in_native) { 435 if (sig == SIGBUS && thread->doing_unsafe_access()) { 436 if (UnsafeCopyMemory::contains_pc(pc)) { 437 npc = UnsafeCopyMemory::page_error_continue_pc(pc); 438 } 439 stub = SharedRuntime::handle_unsafe_access(thread, npc); 440 } 441 } 442 443 else if (thread->thread_state() == _thread_in_Java) { 444 // Java thread running in Java code => find exception handler if any 445 // a fault inside compiled code, the interpreter, or a stub 446 447 // Support Safepoint Polling 448 if (sig == SIGSEGV && os::is_poll_address((address)info->si_addr)) { 449 stub = SharedRuntime::get_poll_stub(pc); 450 } 451 452 // Not needed on x86 solaris because verify_oops doesn't generate 453 // SEGV/BUS like sparc does. 454 if ( (sig == SIGSEGV || sig == SIGBUS) 455 && pc >= MacroAssembler::_verify_oop_implicit_branch[0] 456 && pc < MacroAssembler::_verify_oop_implicit_branch[1] ) { 457 stub = MacroAssembler::_verify_oop_implicit_branch[2]; 458 warning("fixed up memory fault in +VerifyOops at address " INTPTR_FORMAT, info->si_addr); 459 } 460 461 // This is not factored because on x86 solaris the patching for 462 // zombies does not generate a SEGV. 463 else if (sig == SIGSEGV && nativeInstruction_at(pc)->is_zombie()) { 464 // zombie method (ld [%g0],%o7 instruction) 465 stub = SharedRuntime::get_handle_wrong_method_stub(); 466 467 // At the stub it needs to look like a call from the caller of this 468 // method (not a call from the segv site). 469 pc = (address)uc->uc_mcontext.gregs[REG_O7]; 470 } 471 else if (sig == SIGBUS && info->si_code == BUS_OBJERR) { 472 // BugId 4454115: A read from a MappedByteBuffer can fault 473 // here if the underlying file has been truncated. 474 // Do not crash the VM in such a case. 475 CodeBlob* cb = CodeCache::find_blob_unsafe(pc); 476 CompiledMethod* nm = cb->as_compiled_method_or_null(); 477 bool is_unsafe_arraycopy = (thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc)); 478 if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) { 479 if (is_unsafe_arraycopy) { 480 npc = UnsafeCopyMemory::page_error_continue_pc(pc); 481 } 482 stub = SharedRuntime::handle_unsafe_access(thread, npc); 483 } 484 } 485 486 else if (sig == SIGFPE && info->si_code == FPE_INTDIV) { 487 // integer divide by zero 488 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO); 489 } 490 else if (sig == SIGFPE && info->si_code == FPE_FLTDIV) { 491 // floating-point divide by zero 492 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO); 493 } 494 #ifdef COMPILER2 495 else if (sig == SIGILL && nativeInstruction_at(pc)->is_ic_miss_trap()) { 496 #ifdef ASSERT 497 #ifdef TIERED 498 CodeBlob* cb = CodeCache::find_blob_unsafe(pc); 499 assert(cb->is_compiled_by_c2(), "Wrong compiler"); 500 #endif // TIERED 501 #endif // ASSERT 502 // Inline cache missed and user trap "Tne G0+ST_RESERVED_FOR_USER_0+2" taken. 503 stub = SharedRuntime::get_ic_miss_stub(); 504 // At the stub it needs to look like a call from the caller of this 505 // method (not a call from the segv site). 506 pc = (address)uc->uc_mcontext.gregs[REG_O7]; 507 } 508 #endif // COMPILER2 509 510 else if (sig == SIGSEGV && info->si_code > 0 && MacroAssembler::uses_implicit_null_check(info->si_addr)) { 511 // Determination of interpreter/vtable stub/compiled code null exception 512 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); 513 } 514 } 515 516 // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in 517 // and the heap gets shrunk before the field access. 518 if ((sig == SIGSEGV) || (sig == SIGBUS)) { 519 address addr = JNI_FastGetField::find_slowcase_pc(pc); 520 if (addr != (address)-1) { 521 stub = addr; 522 } 523 } 524 } 525 526 if (stub != NULL) { 527 // save all thread context in case we need to restore it 528 529 thread->set_saved_exception_pc(pc); 530 thread->set_saved_exception_npc(npc); 531 532 // simulate a branch to the stub (a "call" in the safepoint stub case) 533 // factor me: setPC 534 os::Solaris::ucontext_set_pc(uc, stub); 535 536 return true; 537 } 538 539 // signal-chaining 540 if (os::Solaris::chained_handler(sig, info, ucVoid)) { 541 return true; 542 } 543 544 if (!abort_if_unrecognized) { 545 // caller wants another chance, so give it to him 546 return false; 547 } 548 549 if (!os::Solaris::libjsig_is_loaded) { 550 struct sigaction oldAct; 551 sigaction(sig, (struct sigaction *)0, &oldAct); 552 if (oldAct.sa_sigaction != signalHandler) { 553 void* sighand = oldAct.sa_sigaction ? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction) 554 : CAST_FROM_FN_PTR(void*, oldAct.sa_handler); 555 warning("Unexpected Signal %d occurred under user-defined signal handler " INTPTR_FORMAT, sig, (intptr_t)sighand); 556 } 557 } 558 559 if (pc == NULL && uc != NULL) { 560 pc = (address) uc->uc_mcontext.gregs[REG_PC]; 561 } 562 563 // Sometimes the register windows are not properly flushed. 564 if(uc->uc_mcontext.gwins != NULL) { 565 ::handle_unflushed_register_windows(uc->uc_mcontext.gwins); 566 } 567 568 // unmask current signal 569 sigset_t newset; 570 sigemptyset(&newset); 571 sigaddset(&newset, sig); 572 sigprocmask(SIG_UNBLOCK, &newset, NULL); 573 574 // Determine which sort of error to throw. Out of swap may signal 575 // on the thread stack, which could get a mapping error when touched. 576 address addr = (address) info->si_addr; 577 if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) { 578 vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "Out of swap space to map in thread stack."); 579 } 580 581 VMError::report_and_die(t, sig, pc, info, ucVoid); 582 583 ShouldNotReachHere(); 584 return false; 585 } 586 587 void os::print_context(outputStream *st, const void *context) { 588 if (context == NULL) return; 589 590 const ucontext_t *uc = (const ucontext_t*)context; 591 st->print_cr("Registers:"); 592 593 st->print_cr(" G1=" INTPTR_FORMAT " G2=" INTPTR_FORMAT 594 " G3=" INTPTR_FORMAT " G4=" INTPTR_FORMAT, 595 uc->uc_mcontext.gregs[REG_G1], 596 uc->uc_mcontext.gregs[REG_G2], 597 uc->uc_mcontext.gregs[REG_G3], 598 uc->uc_mcontext.gregs[REG_G4]); 599 st->print_cr(" G5=" INTPTR_FORMAT " G6=" INTPTR_FORMAT 600 " G7=" INTPTR_FORMAT " Y=" INTPTR_FORMAT, 601 uc->uc_mcontext.gregs[REG_G5], 602 uc->uc_mcontext.gregs[REG_G6], 603 uc->uc_mcontext.gregs[REG_G7], 604 uc->uc_mcontext.gregs[REG_Y]); 605 st->print_cr(" O0=" INTPTR_FORMAT " O1=" INTPTR_FORMAT 606 " O2=" INTPTR_FORMAT " O3=" INTPTR_FORMAT, 607 uc->uc_mcontext.gregs[REG_O0], 608 uc->uc_mcontext.gregs[REG_O1], 609 uc->uc_mcontext.gregs[REG_O2], 610 uc->uc_mcontext.gregs[REG_O3]); 611 st->print_cr(" O4=" INTPTR_FORMAT " O5=" INTPTR_FORMAT 612 " O6=" INTPTR_FORMAT " O7=" INTPTR_FORMAT, 613 uc->uc_mcontext.gregs[REG_O4], 614 uc->uc_mcontext.gregs[REG_O5], 615 uc->uc_mcontext.gregs[REG_O6], 616 uc->uc_mcontext.gregs[REG_O7]); 617 618 619 intptr_t *sp = (intptr_t *)os::Solaris::ucontext_get_sp(uc); 620 st->print_cr(" L0=" INTPTR_FORMAT " L1=" INTPTR_FORMAT 621 " L2=" INTPTR_FORMAT " L3=" INTPTR_FORMAT, 622 sp[L0->sp_offset_in_saved_window()], 623 sp[L1->sp_offset_in_saved_window()], 624 sp[L2->sp_offset_in_saved_window()], 625 sp[L3->sp_offset_in_saved_window()]); 626 st->print_cr(" L4=" INTPTR_FORMAT " L5=" INTPTR_FORMAT 627 " L6=" INTPTR_FORMAT " L7=" INTPTR_FORMAT, 628 sp[L4->sp_offset_in_saved_window()], 629 sp[L5->sp_offset_in_saved_window()], 630 sp[L6->sp_offset_in_saved_window()], 631 sp[L7->sp_offset_in_saved_window()]); 632 st->print_cr(" I0=" INTPTR_FORMAT " I1=" INTPTR_FORMAT 633 " I2=" INTPTR_FORMAT " I3=" INTPTR_FORMAT, 634 sp[I0->sp_offset_in_saved_window()], 635 sp[I1->sp_offset_in_saved_window()], 636 sp[I2->sp_offset_in_saved_window()], 637 sp[I3->sp_offset_in_saved_window()]); 638 st->print_cr(" I4=" INTPTR_FORMAT " I5=" INTPTR_FORMAT 639 " I6=" INTPTR_FORMAT " I7=" INTPTR_FORMAT, 640 sp[I4->sp_offset_in_saved_window()], 641 sp[I5->sp_offset_in_saved_window()], 642 sp[I6->sp_offset_in_saved_window()], 643 sp[I7->sp_offset_in_saved_window()]); 644 645 st->print_cr(" PC=" INTPTR_FORMAT " nPC=" INTPTR_FORMAT, 646 uc->uc_mcontext.gregs[REG_PC], 647 uc->uc_mcontext.gregs[REG_nPC]); 648 st->cr(); 649 st->cr(); 650 651 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); 652 print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t)); 653 st->cr(); 654 655 // Note: it may be unsafe to inspect memory near pc. For example, pc may 656 // point to garbage if entry point in an nmethod is corrupted. Leave 657 // this at the end, and hope for the best. 658 ExtendedPC epc = os::Solaris::ucontext_get_ExtendedPC(uc); 659 address pc = epc.pc(); 660 print_instructions(st, pc, sizeof(char)); 661 st->cr(); 662 } 663 664 void os::print_register_info(outputStream *st, const void *context) { 665 if (context == NULL) return; 666 667 const ucontext_t *uc = (const ucontext_t*)context; 668 intptr_t *sp = (intptr_t *)os::Solaris::ucontext_get_sp(uc); 669 670 st->print_cr("Register to memory mapping:"); 671 st->cr(); 672 673 // this is only for the "general purpose" registers 674 st->print("G1="); print_location(st, uc->uc_mcontext.gregs[REG_G1]); 675 st->print("G2="); print_location(st, uc->uc_mcontext.gregs[REG_G2]); 676 st->print("G3="); print_location(st, uc->uc_mcontext.gregs[REG_G3]); 677 st->print("G4="); print_location(st, uc->uc_mcontext.gregs[REG_G4]); 678 st->print("G5="); print_location(st, uc->uc_mcontext.gregs[REG_G5]); 679 st->print("G6="); print_location(st, uc->uc_mcontext.gregs[REG_G6]); 680 st->print("G7="); print_location(st, uc->uc_mcontext.gregs[REG_G7]); 681 st->cr(); 682 683 st->print("O0="); print_location(st, uc->uc_mcontext.gregs[REG_O0]); 684 st->print("O1="); print_location(st, uc->uc_mcontext.gregs[REG_O1]); 685 st->print("O2="); print_location(st, uc->uc_mcontext.gregs[REG_O2]); 686 st->print("O3="); print_location(st, uc->uc_mcontext.gregs[REG_O3]); 687 st->print("O4="); print_location(st, uc->uc_mcontext.gregs[REG_O4]); 688 st->print("O5="); print_location(st, uc->uc_mcontext.gregs[REG_O5]); 689 st->print("O6="); print_location(st, uc->uc_mcontext.gregs[REG_O6]); 690 st->print("O7="); print_location(st, uc->uc_mcontext.gregs[REG_O7]); 691 st->cr(); 692 693 st->print("L0="); print_location(st, sp[L0->sp_offset_in_saved_window()]); 694 st->print("L1="); print_location(st, sp[L1->sp_offset_in_saved_window()]); 695 st->print("L2="); print_location(st, sp[L2->sp_offset_in_saved_window()]); 696 st->print("L3="); print_location(st, sp[L3->sp_offset_in_saved_window()]); 697 st->print("L4="); print_location(st, sp[L4->sp_offset_in_saved_window()]); 698 st->print("L5="); print_location(st, sp[L5->sp_offset_in_saved_window()]); 699 st->print("L6="); print_location(st, sp[L6->sp_offset_in_saved_window()]); 700 st->print("L7="); print_location(st, sp[L7->sp_offset_in_saved_window()]); 701 st->cr(); 702 703 st->print("I0="); print_location(st, sp[I0->sp_offset_in_saved_window()]); 704 st->print("I1="); print_location(st, sp[I1->sp_offset_in_saved_window()]); 705 st->print("I2="); print_location(st, sp[I2->sp_offset_in_saved_window()]); 706 st->print("I3="); print_location(st, sp[I3->sp_offset_in_saved_window()]); 707 st->print("I4="); print_location(st, sp[I4->sp_offset_in_saved_window()]); 708 st->print("I5="); print_location(st, sp[I5->sp_offset_in_saved_window()]); 709 st->print("I6="); print_location(st, sp[I6->sp_offset_in_saved_window()]); 710 st->print("I7="); print_location(st, sp[I7->sp_offset_in_saved_window()]); 711 st->cr(); 712 } 713 714 void os::Solaris::init_thread_fpu_state(void) { 715 // Nothing needed on Sparc. 716 } 717 718 #ifndef PRODUCT 719 void os::verify_stack_alignment() { 720 } 721 #endif 722 723 int os::extra_bang_size_in_bytes() { 724 // SPARC does not require an additional stack bang. 725 return 0; 726 }