1 /* 2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2012, 2018 SAP SE. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 // no precompiled headers 27 #include "jvm.h" 28 #include "asm/assembler.inline.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_ppc.hpp" 38 #include "os_share_linux.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.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 // put OS-includes here 57 # include <sys/types.h> 58 # include <sys/mman.h> 59 # include <pthread.h> 60 # include <signal.h> 61 # include <errno.h> 62 # include <dlfcn.h> 63 # include <stdlib.h> 64 # include <stdio.h> 65 # include <unistd.h> 66 # include <sys/resource.h> 67 # include <pthread.h> 68 # include <sys/stat.h> 69 # include <sys/time.h> 70 # include <sys/utsname.h> 71 # include <sys/socket.h> 72 # include <sys/wait.h> 73 # include <pwd.h> 74 # include <poll.h> 75 # include <ucontext.h> 76 77 78 address os::current_stack_pointer() { 79 intptr_t* csp; 80 81 // inline assembly `mr regno(csp), R1_SP': 82 __asm__ __volatile__ ("mr %0, 1":"=r"(csp):); 83 84 return (address) csp; 85 } 86 87 char* os::non_memory_address_word() { 88 // Must never look like an address returned by reserve_memory, 89 // even in its subfields (as defined by the CPU immediate fields, 90 // if the CPU splits constants across multiple instructions). 91 92 return (char*) -1; 93 } 94 95 void os::initialize_thread(Thread *thread) { } 96 97 // Frame information (pc, sp, fp) retrieved via ucontext 98 // always looks like a C-frame according to the frame 99 // conventions in frame_ppc64.hpp. 100 address os::Linux::ucontext_get_pc(const ucontext_t * uc) { 101 // On powerpc64, ucontext_t is not selfcontained but contains 102 // a pointer to an optional substructure (mcontext_t.regs) containing the volatile 103 // registers - NIP, among others. 104 // This substructure may or may not be there depending where uc came from: 105 // - if uc was handed over as the argument to a sigaction handler, a pointer to the 106 // substructure was provided by the kernel when calling the signal handler, and 107 // regs->nip can be accessed. 108 // - if uc was filled by getcontext(), it is undefined - getcontext() does not fill 109 // it because the volatile registers are not needed to make setcontext() work. 110 // Hopefully it was zero'd out beforehand. 111 guarantee(uc->uc_mcontext.regs != NULL, "only use ucontext_get_pc in sigaction context"); 112 return (address)uc->uc_mcontext.regs->nip; 113 } 114 115 // modify PC in ucontext. 116 // Note: Only use this for an ucontext handed down to a signal handler. See comment 117 // in ucontext_get_pc. 118 void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) { 119 guarantee(uc->uc_mcontext.regs != NULL, "only use ucontext_set_pc in sigaction context"); 120 uc->uc_mcontext.regs->nip = (unsigned long)pc; 121 } 122 123 static address ucontext_get_lr(const ucontext_t * uc) { 124 return (address)uc->uc_mcontext.regs->link; 125 } 126 127 intptr_t* os::Linux::ucontext_get_sp(const ucontext_t * uc) { 128 return (intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/]; 129 } 130 131 intptr_t* os::Linux::ucontext_get_fp(const ucontext_t * uc) { 132 return NULL; 133 } 134 135 ExtendedPC os::fetch_frame_from_context(const void* ucVoid, 136 intptr_t** ret_sp, intptr_t** ret_fp) { 137 138 ExtendedPC epc; 139 const ucontext_t* uc = (const ucontext_t*)ucVoid; 140 141 if (uc != NULL) { 142 epc = ExtendedPC(os::Linux::ucontext_get_pc(uc)); 143 if (ret_sp) *ret_sp = os::Linux::ucontext_get_sp(uc); 144 if (ret_fp) *ret_fp = os::Linux::ucontext_get_fp(uc); 145 } else { 146 // construct empty ExtendedPC for return value checking 147 epc = ExtendedPC(NULL); 148 if (ret_sp) *ret_sp = (intptr_t *)NULL; 149 if (ret_fp) *ret_fp = (intptr_t *)NULL; 150 } 151 152 return epc; 153 } 154 155 frame os::fetch_frame_from_context(const void* ucVoid) { 156 intptr_t* sp; 157 intptr_t* fp; 158 ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp); 159 return frame(sp, epc.pc()); 160 } 161 162 bool os::Linux::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) { 163 address pc = (address) os::Linux::ucontext_get_pc(uc); 164 if (Interpreter::contains(pc)) { 165 // Interpreter performs stack banging after the fixed frame header has 166 // been generated while the compilers perform it before. To maintain 167 // semantic consistency between interpreted and compiled frames, the 168 // method returns the Java sender of the current frame. 169 *fr = os::fetch_frame_from_context(uc); 170 if (!fr->is_first_java_frame()) { 171 assert(fr->safe_for_sender(thread), "Safety check"); 172 *fr = fr->java_sender(); 173 } 174 } else { 175 // More complex code with compiled code. 176 assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above"); 177 CodeBlob* cb = CodeCache::find_blob(pc); 178 if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) { 179 // Not sure where the pc points to, fallback to default 180 // stack overflow handling. In compiled code, we bang before 181 // the frame is complete. 182 return false; 183 } else { 184 intptr_t* sp = os::Linux::ucontext_get_sp(uc); 185 address lr = ucontext_get_lr(uc); 186 *fr = frame(sp, lr); 187 if (!fr->is_java_frame()) { 188 assert(fr->safe_for_sender(thread), "Safety check"); 189 assert(!fr->is_first_frame(), "Safety check"); 190 *fr = fr->java_sender(); 191 } 192 } 193 } 194 assert(fr->is_java_frame(), "Safety check"); 195 return true; 196 } 197 198 frame os::get_sender_for_C_frame(frame* fr) { 199 if (*fr->sp() == 0) { 200 // fr is the last C frame 201 return frame(NULL, NULL); 202 } 203 return frame(fr->sender_sp(), fr->sender_pc()); 204 } 205 206 207 frame os::current_frame() { 208 intptr_t* csp = (intptr_t*) *((intptr_t*) os::current_stack_pointer()); 209 // hack. 210 frame topframe(csp, (address)0x8); 211 // Return sender of sender of current topframe which hopefully 212 // both have pc != NULL. 213 frame tmp = os::get_sender_for_C_frame(&topframe); 214 return os::get_sender_for_C_frame(&tmp); 215 } 216 217 // Utility functions 218 219 extern "C" JNIEXPORT int 220 JVM_handle_linux_signal(int sig, 221 siginfo_t* info, 222 void* ucVoid, 223 int abort_if_unrecognized) { 224 ucontext_t* uc = (ucontext_t*) ucVoid; 225 226 Thread* t = Thread::current_or_null_safe(); 227 228 SignalHandlerMark shm(t); 229 230 // Note: it's not uncommon that JNI code uses signal/sigset to install 231 // then restore certain signal handler (e.g. to temporarily block SIGPIPE, 232 // or have a SIGILL handler when detecting CPU type). When that happens, 233 // JVM_handle_linux_signal() might be invoked with junk info/ucVoid. To 234 // avoid unnecessary crash when libjsig is not preloaded, try handle signals 235 // that do not require siginfo/ucontext first. 236 237 if (sig == SIGPIPE) { 238 if (os::Linux::chained_handler(sig, info, ucVoid)) { 239 return true; 240 } else { 241 // Ignoring SIGPIPE - see bugs 4229104 242 return true; 243 } 244 } 245 246 // Make the signal handler transaction-aware by checking the existence of a 247 // second (transactional) context with MSR TS bits active. If the signal is 248 // caught during a transaction, then just return to the HTM abort handler. 249 // Please refer to Linux kernel document powerpc/transactional_memory.txt, 250 // section "Signals". 251 if (uc && uc->uc_link) { 252 ucontext_t* second_uc = uc->uc_link; 253 254 // MSR TS bits are 29 and 30 (Power ISA, v2.07B, Book III-S, pp. 857-858, 255 // 3.2.1 "Machine State Register"), however note that ISA notation for bit 256 // numbering is MSB 0, so for normal bit numbering (LSB 0) they come to be 257 // bits 33 and 34. It's not related to endianness, just a notation matter. 258 if (second_uc->uc_mcontext.regs->msr & 0x600000000) { 259 if (TraceTraps) { 260 tty->print_cr("caught signal in transaction, " 261 "ignoring to jump to abort handler"); 262 } 263 // Return control to the HTM abort handler. 264 return true; 265 } 266 } 267 268 JavaThread* thread = NULL; 269 VMThread* vmthread = NULL; 270 if (os::Linux::signal_handlers_are_installed) { 271 if (t != NULL) { 272 if(t->is_Java_thread()) { 273 thread = (JavaThread*)t; 274 } else if(t->is_VM_thread()) { 275 vmthread = (VMThread *)t; 276 } 277 } 278 } 279 280 // Moved SafeFetch32 handling outside thread!=NULL conditional block to make 281 // it work if no associated JavaThread object exists. 282 if (uc) { 283 address const pc = os::Linux::ucontext_get_pc(uc); 284 if (pc && StubRoutines::is_safefetch_fault(pc)) { 285 os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); 286 return true; 287 } 288 } 289 290 // decide if this trap can be handled by a stub 291 address stub = NULL; 292 address pc = NULL; 293 294 //%note os_trap_1 295 if (info != NULL && uc != NULL && thread != NULL) { 296 pc = (address) os::Linux::ucontext_get_pc(uc); 297 298 // Handle ALL stack overflow variations here 299 if (sig == SIGSEGV) { 300 // Si_addr may not be valid due to a bug in the linux-ppc64 kernel (see 301 // comment below). Use get_stack_bang_address instead of si_addr. 302 address addr = ((NativeInstruction*)pc)->get_stack_bang_address(uc); 303 304 // Check if fault address is within thread stack. 305 if (thread->on_local_stack(addr)) { 306 // stack overflow 307 if (thread->in_stack_yellow_reserved_zone(addr)) { 308 if (thread->thread_state() == _thread_in_Java) { 309 if (thread->in_stack_reserved_zone(addr)) { 310 frame fr; 311 if (os::Linux::get_frame_at_stack_banging_point(thread, uc, &fr)) { 312 assert(fr.is_java_frame(), "Must be a Javac frame"); 313 frame activation = 314 SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr); 315 if (activation.sp() != NULL) { 316 thread->disable_stack_reserved_zone(); 317 if (activation.is_interpreted_frame()) { 318 thread->set_reserved_stack_activation((address)activation.fp()); 319 } else { 320 thread->set_reserved_stack_activation((address)activation.unextended_sp()); 321 } 322 return 1; 323 } 324 } 325 } 326 // Throw a stack overflow exception. 327 // Guard pages will be reenabled while unwinding the stack. 328 thread->disable_stack_yellow_reserved_zone(); 329 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW); 330 } else { 331 // Thread was in the vm or native code. Return and try to finish. 332 thread->disable_stack_yellow_reserved_zone(); 333 return 1; 334 } 335 } else if (thread->in_stack_red_zone(addr)) { 336 // Fatal red zone violation. Disable the guard pages and fall through 337 // to handle_unexpected_exception way down below. 338 thread->disable_stack_red_zone(); 339 tty->print_raw_cr("An irrecoverable stack overflow has occurred."); 340 341 // This is a likely cause, but hard to verify. Let's just print 342 // it as a hint. 343 tty->print_raw_cr("Please check if any of your loaded .so files has " 344 "enabled executable stack (see man page execstack(8))"); 345 } else { 346 // Accessing stack address below sp may cause SEGV if current 347 // thread has MAP_GROWSDOWN stack. This should only happen when 348 // current thread was created by user code with MAP_GROWSDOWN flag 349 // and then attached to VM. See notes in os_linux.cpp. 350 if (thread->osthread()->expanding_stack() == 0) { 351 thread->osthread()->set_expanding_stack(); 352 if (os::Linux::manually_expand_stack(thread, addr)) { 353 thread->osthread()->clear_expanding_stack(); 354 return 1; 355 } 356 thread->osthread()->clear_expanding_stack(); 357 } else { 358 fatal("recursive segv. expanding stack."); 359 } 360 } 361 } 362 } 363 364 if (thread->thread_state() == _thread_in_Java) { 365 // Java thread running in Java code => find exception handler if any 366 // a fault inside compiled code, the interpreter, or a stub 367 368 // A VM-related SIGILL may only occur if we are not in the zero page. 369 // On AIX, we get a SIGILL if we jump to 0x0 or to somewhere else 370 // in the zero page, because it is filled with 0x0. We ignore 371 // explicit SIGILLs in the zero page. 372 if (sig == SIGILL && (pc < (address) 0x200)) { 373 if (TraceTraps) { 374 tty->print_raw_cr("SIGILL happened inside zero page."); 375 } 376 goto report_and_die; 377 } 378 379 CodeBlob *cb = NULL; 380 // Handle signal from NativeJump::patch_verified_entry(). 381 if (( TrapBasedNotEntrantChecks && sig == SIGTRAP && nativeInstruction_at(pc)->is_sigtrap_zombie_not_entrant()) || 382 (!TrapBasedNotEntrantChecks && sig == SIGILL && nativeInstruction_at(pc)->is_sigill_zombie_not_entrant())) { 383 if (TraceTraps) { 384 tty->print_cr("trap: zombie_not_entrant (%s)", (sig == SIGTRAP) ? "SIGTRAP" : "SIGILL"); 385 } 386 stub = SharedRuntime::get_handle_wrong_method_stub(); 387 } 388 389 else if (sig == SIGSEGV && 390 // A linux-ppc64 kernel before 2.6.6 doesn't set si_addr on some segfaults 391 // in 64bit mode (cf. http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.6), 392 // especially when we try to read from the safepoint polling page. So the check 393 // (address)info->si_addr == os::get_standard_polling_page() 394 // doesn't work for us. We use: 395 ((NativeInstruction*)pc)->is_safepoint_poll() && 396 CodeCache::contains((void*) pc) && 397 ((cb = CodeCache::find_blob(pc)) != NULL) && 398 cb->is_compiled()) { 399 if (TraceTraps) { 400 tty->print_cr("trap: safepoint_poll at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc)); 401 } 402 stub = SharedRuntime::get_poll_stub(pc); 403 } 404 405 // SIGTRAP-based ic miss check in compiled code. 406 else if (sig == SIGTRAP && TrapBasedICMissChecks && 407 nativeInstruction_at(pc)->is_sigtrap_ic_miss_check()) { 408 if (TraceTraps) { 409 tty->print_cr("trap: ic_miss_check at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc)); 410 } 411 stub = SharedRuntime::get_ic_miss_stub(); 412 } 413 414 // SIGTRAP-based implicit null check in compiled code. 415 else if (sig == SIGTRAP && TrapBasedNullChecks && 416 nativeInstruction_at(pc)->is_sigtrap_null_check()) { 417 if (TraceTraps) { 418 tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc)); 419 } 420 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); 421 } 422 423 // SIGSEGV-based implicit null check in compiled code. 424 else if (sig == SIGSEGV && ImplicitNullChecks && 425 CodeCache::contains((void*) pc) && 426 !MacroAssembler::needs_explicit_null_check((intptr_t) info->si_addr)) { 427 if (TraceTraps) { 428 tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc)); 429 } 430 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); 431 } 432 433 #ifdef COMPILER2 434 // SIGTRAP-based implicit range check in compiled code. 435 else if (sig == SIGTRAP && TrapBasedRangeChecks && 436 nativeInstruction_at(pc)->is_sigtrap_range_check()) { 437 if (TraceTraps) { 438 tty->print_cr("trap: range_check at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc)); 439 } 440 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); 441 } 442 #endif 443 else if (sig == SIGBUS) { 444 // BugId 4454115: A read from a MappedByteBuffer can fault here if the 445 // underlying file has been truncated. Do not crash the VM in such a case. 446 CodeBlob* cb = CodeCache::find_blob_unsafe(pc); 447 CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; 448 if (nm != NULL && nm->has_unsafe_access()) { 449 address next_pc = pc + 4; 450 next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); 451 os::Linux::ucontext_set_pc(uc, next_pc); 452 return true; 453 } 454 } 455 } 456 457 else { // thread->thread_state() != _thread_in_Java 458 if (sig == SIGILL && VM_Version::is_determine_features_test_running()) { 459 // SIGILL must be caused by VM_Version::determine_features(). 460 *(int *)pc = 0; // patch instruction to 0 to indicate that it causes a SIGILL, 461 // flushing of icache is not necessary. 462 stub = pc + 4; // continue with next instruction. 463 } 464 else if (thread->thread_state() == _thread_in_vm && 465 sig == SIGBUS && thread->doing_unsafe_access()) { 466 address next_pc = pc + 4; 467 next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); 468 os::Linux::ucontext_set_pc(uc, pc + 4); 469 return true; 470 } 471 } 472 473 // Check to see if we caught the safepoint code in the 474 // process of write protecting the memory serialization page. 475 // It write enables the page immediately after protecting it 476 // so we can just return to retry the write. 477 if ((sig == SIGSEGV) && 478 // Si_addr may not be valid due to a bug in the linux-ppc64 kernel (see comment above). 479 // Use is_memory_serialization instead of si_addr. 480 ((NativeInstruction*)pc)->is_memory_serialization(thread, ucVoid)) { 481 // Synchronization problem in the pseudo memory barrier code (bug id 6546278) 482 // Block current thread until the memory serialize page permission restored. 483 os::block_on_serialize_page_trap(); 484 return true; 485 } 486 } 487 488 if (stub != NULL) { 489 // Save all thread context in case we need to restore it. 490 if (thread != NULL) thread->set_saved_exception_pc(pc); 491 os::Linux::ucontext_set_pc(uc, stub); 492 return true; 493 } 494 495 // signal-chaining 496 if (os::Linux::chained_handler(sig, info, ucVoid)) { 497 return true; 498 } 499 500 if (!abort_if_unrecognized) { 501 // caller wants another chance, so give it to him 502 return false; 503 } 504 505 if (pc == NULL && uc != NULL) { 506 pc = os::Linux::ucontext_get_pc(uc); 507 } 508 509 report_and_die: 510 // unmask current signal 511 sigset_t newset; 512 sigemptyset(&newset); 513 sigaddset(&newset, sig); 514 sigprocmask(SIG_UNBLOCK, &newset, NULL); 515 516 VMError::report_and_die(t, sig, pc, info, ucVoid); 517 518 ShouldNotReachHere(); 519 return false; 520 } 521 522 void os::Linux::init_thread_fpu_state(void) { 523 // Disable FP exceptions. 524 __asm__ __volatile__ ("mtfsfi 6,0"); 525 } 526 527 int os::Linux::get_fpu_control_word(void) { 528 // x86 has problems with FPU precision after pthread_cond_timedwait(). 529 // nothing to do on ppc64. 530 return 0; 531 } 532 533 void os::Linux::set_fpu_control_word(int fpu_control) { 534 // x86 has problems with FPU precision after pthread_cond_timedwait(). 535 // nothing to do on ppc64. 536 } 537 538 //////////////////////////////////////////////////////////////////////////////// 539 // thread stack 540 541 // Minimum usable stack sizes required to get to user code. Space for 542 // HotSpot guard pages is added later. 543 size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; 544 size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; 545 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; 546 547 // Return default stack size for thr_type. 548 size_t os::Posix::default_stack_size(os::ThreadType thr_type) { 549 // Default stack size (compiler thread needs larger stack). 550 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K); 551 return s; 552 } 553 554 ///////////////////////////////////////////////////////////////////////////// 555 // helper functions for fatal error handler 556 557 void os::print_context(outputStream *st, const void *context) { 558 if (context == NULL) return; 559 560 const ucontext_t* uc = (const ucontext_t*)context; 561 562 st->print_cr("Registers:"); 563 st->print("pc =" INTPTR_FORMAT " ", uc->uc_mcontext.regs->nip); 564 st->print("lr =" INTPTR_FORMAT " ", uc->uc_mcontext.regs->link); 565 st->print("ctr=" INTPTR_FORMAT " ", uc->uc_mcontext.regs->ctr); 566 st->cr(); 567 for (int i = 0; i < 32; i++) { 568 st->print("r%-2d=" INTPTR_FORMAT " ", i, uc->uc_mcontext.regs->gpr[i]); 569 if (i % 3 == 2) st->cr(); 570 } 571 st->cr(); 572 st->cr(); 573 574 intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); 575 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); 576 print_hex_dump(st, (address)sp, (address)(sp + 128), sizeof(intptr_t)); 577 st->cr(); 578 579 // Note: it may be unsafe to inspect memory near pc. For example, pc may 580 // point to garbage if entry point in an nmethod is corrupted. Leave 581 // this at the end, and hope for the best. 582 address pc = os::Linux::ucontext_get_pc(uc); 583 st->print_cr("Instructions: (pc=" PTR_FORMAT ")", p2i(pc)); 584 print_hex_dump(st, pc - 64, pc + 64, /*instrsize=*/4); 585 st->cr(); 586 } 587 588 void os::print_register_info(outputStream *st, const void *context) { 589 if (context == NULL) return; 590 591 const ucontext_t *uc = (const ucontext_t*)context; 592 593 st->print_cr("Register to memory mapping:"); 594 st->cr(); 595 596 // this is only for the "general purpose" registers 597 for (int i = 0; i < 32; i++) { 598 st->print("r%-2d=", i); 599 print_location(st, uc->uc_mcontext.regs->gpr[i]); 600 } 601 st->cr(); 602 } 603 604 extern "C" { 605 int SpinPause() { 606 return 0; 607 } 608 } 609 610 #ifndef PRODUCT 611 void os::verify_stack_alignment() { 612 assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment"); 613 } 614 #endif 615 616 int os::extra_bang_size_in_bytes() { 617 // PPC does not require the additional stack bang. 618 return 0; 619 }