1 /* 2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2016, 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 // This file is organized as os_linux_x86.cpp. 27 28 // no precompiled headers 29 #include "jvm.h" 30 #include "asm/assembler.inline.hpp" 31 #include "classfile/classLoader.hpp" 32 #include "classfile/systemDictionary.hpp" 33 #include "classfile/vmSymbols.hpp" 34 #include "code/icBuffer.hpp" 35 #include "code/nativeInst.hpp" 36 #include "code/vtableStubs.hpp" 37 #include "compiler/disassembler.hpp" 38 #include "interpreter/interpreter.hpp" 39 #include "memory/allocation.inline.hpp" 40 #include "nativeInst_s390.hpp" 41 #include "os_share_linux.hpp" 42 #include "prims/jniFastGetField.hpp" 43 #include "prims/jvm_misc.hpp" 44 #include "runtime/arguments.hpp" 45 #include "runtime/extendedPC.hpp" 46 #include "runtime/frame.inline.hpp" 47 #include "runtime/interfaceSupport.inline.hpp" 48 #include "runtime/java.hpp" 49 #include "runtime/javaCalls.hpp" 50 #include "runtime/mutexLocker.hpp" 51 #include "runtime/osThread.hpp" 52 #include "runtime/sharedRuntime.hpp" 53 #include "runtime/stubRoutines.hpp" 54 #include "runtime/thread.inline.hpp" 55 #include "runtime/timer.hpp" 56 #include "utilities/events.hpp" 57 #include "utilities/debug.hpp" 58 #include "utilities/vmError.hpp" 59 60 // put OS-includes here 61 # include <sys/types.h> 62 # include <sys/mman.h> 63 # include <pthread.h> 64 # include <signal.h> 65 # include <errno.h> 66 # include <dlfcn.h> 67 # include <stdlib.h> 68 # include <stdio.h> 69 # include <unistd.h> 70 # include <sys/resource.h> 71 # include <pthread.h> 72 # include <sys/stat.h> 73 # include <sys/time.h> 74 # include <sys/utsname.h> 75 # include <sys/socket.h> 76 # include <sys/wait.h> 77 # include <pwd.h> 78 # include <poll.h> 79 # include <ucontext.h> 80 81 address os::current_stack_pointer() { 82 intptr_t* csp; 83 84 // Inline assembly for `z_lgr regno(csp), Z_SP' (Z_SP = Z_R15): 85 __asm__ __volatile__ ("lgr %0, 15":"=r"(csp):); 86 87 assert(((uint64_t)csp & (frame::alignment_in_bytes-1)) == 0, "SP must be aligned"); 88 return (address) csp; 89 } 90 91 char* os::non_memory_address_word() { 92 // Must never look like an address returned by reserve_memory, 93 // even in its subfields (as defined by the CPU immediate fields, 94 // if the CPU splits constants across multiple instructions). 95 return (char*) -1; 96 } 97 98 // OS specific thread initialization. 99 void os::initialize_thread(Thread* thread) { } 100 101 // Frame information (pc, sp, fp) retrieved via ucontext 102 // always looks like a C-frame according to the frame 103 // conventions in frame_s390.hpp. 104 address os::Linux::ucontext_get_pc(const ucontext_t * uc) { 105 return (address)uc->uc_mcontext.psw.addr; 106 } 107 108 void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) { 109 uc->uc_mcontext.psw.addr = (unsigned long)pc; 110 } 111 112 static address ucontext_get_lr(const ucontext_t * uc) { 113 return (address)uc->uc_mcontext.gregs[14/*LINK*/]; 114 } 115 116 intptr_t* os::Linux::ucontext_get_sp(const ucontext_t * uc) { 117 return (intptr_t*)uc->uc_mcontext.gregs[15/*REG_SP*/]; 118 } 119 120 intptr_t* os::Linux::ucontext_get_fp(const ucontext_t * uc) { 121 return NULL; 122 } 123 124 ExtendedPC os::fetch_frame_from_context(const void* ucVoid, 125 intptr_t** ret_sp, intptr_t** ret_fp) { 126 127 ExtendedPC epc; 128 const ucontext_t* uc = (const ucontext_t*)ucVoid; 129 130 if (uc != NULL) { 131 epc = ExtendedPC(os::Linux::ucontext_get_pc(uc)); 132 if (ret_sp) { *ret_sp = os::Linux::ucontext_get_sp(uc); } 133 if (ret_fp) { *ret_fp = os::Linux::ucontext_get_fp(uc); } 134 } else { 135 // Construct empty ExtendedPC for return value checking. 136 epc = ExtendedPC(NULL); 137 if (ret_sp) { *ret_sp = (intptr_t *)NULL; } 138 if (ret_fp) { *ret_fp = (intptr_t *)NULL; } 139 } 140 141 return epc; 142 } 143 144 frame os::fetch_frame_from_context(const void* ucVoid) { 145 intptr_t* sp; 146 intptr_t* fp; 147 ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp); 148 return frame(sp, epc.pc()); 149 } 150 151 bool os::Linux::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) { 152 address pc = (address) os::Linux::ucontext_get_pc(uc); 153 if (Interpreter::contains(pc)) { 154 // Interpreter performs stack banging after the fixed frame header has 155 // been generated while the compilers perform it before. To maintain 156 // semantic consistency between interpreted and compiled frames, the 157 // method returns the Java sender of the current frame. 158 *fr = os::fetch_frame_from_context(uc); 159 if (!fr->is_first_java_frame()) { 160 assert(fr->safe_for_sender(thread), "Safety check"); 161 *fr = fr->java_sender(); 162 } 163 } else { 164 // More complex code with compiled code. 165 assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above"); 166 CodeBlob* cb = CodeCache::find_blob(pc); 167 if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) { 168 // Not sure where the pc points to, fallback to default 169 // stack overflow handling. In compiled code, we bang before 170 // the frame is complete. 171 return false; 172 } else { 173 intptr_t* sp = os::Linux::ucontext_get_sp(uc); 174 address lr = ucontext_get_lr(uc); 175 *fr = frame(sp, lr); 176 if (!fr->is_java_frame()) { 177 assert(fr->safe_for_sender(thread), "Safety check"); 178 assert(!fr->is_first_frame(), "Safety check"); 179 *fr = fr->java_sender(); 180 } 181 } 182 } 183 assert(fr->is_java_frame(), "Safety check"); 184 return true; 185 } 186 187 frame os::get_sender_for_C_frame(frame* fr) { 188 if (*fr->sp() == 0) { 189 // fr is the last C frame. 190 return frame(); 191 } 192 193 // If its not one of our frames, the return pc is saved at gpr14 194 // stack slot. The call_stub stores the return_pc to the stack slot 195 // of gpr10. 196 if ((Interpreter::code() != NULL && Interpreter::contains(fr->pc())) || 197 (CodeCache::contains(fr->pc()) && !StubRoutines::contains(fr->pc()))) { 198 return frame(fr->sender_sp(), fr->sender_pc()); 199 } else { 200 if (StubRoutines::contains(fr->pc())) { 201 StubCodeDesc* desc = StubCodeDesc::desc_for(fr->pc()); 202 if (desc && !strcmp(desc->name(),"call_stub")) { 203 return frame(fr->sender_sp(), fr->callstub_sender_pc()); 204 } else { 205 return frame(fr->sender_sp(), fr->sender_pc()); 206 } 207 } else { 208 return frame(fr->sender_sp(), fr->native_sender_pc()); 209 } 210 } 211 } 212 213 frame os::current_frame() { 214 // Expected to return the stack pointer of this method. 215 // But if inlined, returns the stack pointer of our caller! 216 intptr_t* csp = (intptr_t*) *((intptr_t*) os::current_stack_pointer()); 217 assert (csp != NULL, "sp should not be NULL"); 218 // Pass a dummy pc. This way we don't have to load it from the 219 // stack, since we don't know in which slot we can find it. 220 frame topframe(csp, (address)0x8); 221 if (os::is_first_C_frame(&topframe)) { 222 // Stack is not walkable. 223 return frame(); 224 } else { 225 frame senderFrame = os::get_sender_for_C_frame(&topframe); 226 assert(senderFrame.pc() != NULL, "Sender pc should not be NULL"); 227 // Return sender of sender of current topframe which hopefully 228 // both have pc != NULL. 229 #ifdef _NMT_NOINLINE_ // Is set in slowdebug builds. 230 // Current_stack_pointer is not inlined, we must pop one more frame. 231 frame tmp = os::get_sender_for_C_frame(&topframe); 232 return os::get_sender_for_C_frame(&tmp); 233 #else 234 return os::get_sender_for_C_frame(&topframe); 235 #endif 236 } 237 } 238 239 // Utility functions 240 241 extern "C" JNIEXPORT int 242 JVM_handle_linux_signal(int sig, 243 siginfo_t* info, 244 void* ucVoid, 245 int abort_if_unrecognized) { 246 ucontext_t* uc = (ucontext_t*) ucVoid; 247 248 Thread* t = Thread::current_or_null_safe(); 249 250 // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away 251 // (no destructors can be run). 252 os::ThreadCrashProtection::check_crash_protection(sig, t); 253 254 SignalHandlerMark shm(t); 255 256 // Note: it's not uncommon that JNI code uses signal/sigset to install 257 // then restore certain signal handler (e.g. to temporarily block SIGPIPE, 258 // or have a SIGILL handler when detecting CPU type). When that happens, 259 // JVM_handle_linux_signal() might be invoked with junk info/ucVoid. To 260 // avoid unnecessary crash when libjsig is not preloaded, try handle signals 261 // that do not require siginfo/ucontext first. 262 263 if (sig == SIGPIPE) { 264 if (os::Linux::chained_handler(sig, info, ucVoid)) { 265 return true; 266 } else { 267 if (PrintMiscellaneous && (WizardMode || Verbose)) { 268 warning("Ignoring SIGPIPE - see bug 4229104"); 269 } 270 return true; 271 } 272 } 273 274 #ifdef CAN_SHOW_REGISTERS_ON_ASSERT 275 if ((sig == SIGSEGV || sig == SIGBUS) && info != NULL && info->si_addr == g_assert_poison) { 276 handle_assert_poison_fault(ucVoid, info->si_addr); 277 return 1; 278 } 279 #endif 280 281 JavaThread* thread = NULL; 282 VMThread* vmthread = NULL; 283 if (os::Linux::signal_handlers_are_installed) { 284 if (t != NULL) { 285 if(t->is_Java_thread()) { 286 thread = (JavaThread*)t; 287 } else if(t->is_VM_thread()) { 288 vmthread = (VMThread *)t; 289 } 290 } 291 } 292 293 // Moved SafeFetch32 handling outside thread!=NULL conditional block to make 294 // it work if no associated JavaThread object exists. 295 if (uc) { 296 address const pc = os::Linux::ucontext_get_pc(uc); 297 if (pc && StubRoutines::is_safefetch_fault(pc)) { 298 os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); 299 return true; 300 } 301 } 302 303 // Decide if this trap can be handled by a stub. 304 address stub = NULL; 305 address pc = NULL; // Pc as retrieved from PSW. Usually points past failing instruction. 306 address trap_pc = NULL; // Pc of the instruction causing the trap. 307 308 //%note os_trap_1 309 if (info != NULL && uc != NULL && thread != NULL) { 310 pc = os::Linux::ucontext_get_pc(uc); 311 if (TraceTraps) { 312 tty->print_cr(" pc at " INTPTR_FORMAT, p2i(pc)); 313 } 314 if ((unsigned long)(pc - (address)info->si_addr) <= (unsigned long)Assembler::instr_maxlen() ) { 315 trap_pc = (address)info->si_addr; 316 if (TraceTraps) { 317 tty->print_cr("trap_pc at " INTPTR_FORMAT, p2i(trap_pc)); 318 } 319 } 320 321 // Handle ALL stack overflow variations here 322 if (sig == SIGSEGV) { 323 address addr = (address)info->si_addr; // Address causing SIGSEGV, usually mem ref target. 324 325 // Check if fault address is within thread stack. 326 if (thread->on_local_stack(addr)) { 327 // stack overflow 328 if (thread->in_stack_yellow_reserved_zone(addr)) { 329 if (thread->thread_state() == _thread_in_Java) { 330 if (thread->in_stack_reserved_zone(addr)) { 331 frame fr; 332 if (os::Linux::get_frame_at_stack_banging_point(thread, uc, &fr)) { 333 assert(fr.is_java_frame(), "Must be a Javac frame"); 334 frame activation = 335 SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr); 336 if (activation.sp() != NULL) { 337 thread->disable_stack_reserved_zone(); 338 if (activation.is_interpreted_frame()) { 339 thread->set_reserved_stack_activation((address)activation.fp()); 340 } else { 341 thread->set_reserved_stack_activation((address)activation.unextended_sp()); 342 } 343 return 1; 344 } 345 } 346 } 347 // Throw a stack overflow exception. 348 // Guard pages will be reenabled while unwinding the stack. 349 thread->disable_stack_yellow_reserved_zone(); 350 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW); 351 } else { 352 // Thread was in the vm or native code. Return and try to finish. 353 thread->disable_stack_yellow_reserved_zone(); 354 return 1; 355 } 356 } else if (thread->in_stack_red_zone(addr)) { 357 // Fatal red zone violation. Disable the guard pages and fall through 358 // to handle_unexpected_exception way down below. 359 thread->disable_stack_red_zone(); 360 tty->print_raw_cr("An irrecoverable stack overflow has occurred."); 361 362 // This is a likely cause, but hard to verify. Let's just print 363 // it as a hint. 364 tty->print_raw_cr("Please check if any of your loaded .so files has " 365 "enabled executable stack (see man page execstack(8))"); 366 } else { 367 // Accessing stack address below sp may cause SEGV if current 368 // thread has MAP_GROWSDOWN stack. This should only happen when 369 // current thread was created by user code with MAP_GROWSDOWN flag 370 // and then attached to VM. See notes in os_linux.cpp. 371 if (thread->osthread()->expanding_stack() == 0) { 372 thread->osthread()->set_expanding_stack(); 373 if (os::Linux::manually_expand_stack(thread, addr)) { 374 thread->osthread()->clear_expanding_stack(); 375 return 1; 376 } 377 thread->osthread()->clear_expanding_stack(); 378 } else { 379 fatal("recursive segv. expanding stack."); 380 } 381 } 382 } 383 } 384 385 if (thread->thread_state() == _thread_in_Java) { 386 // Java thread running in Java code => find exception handler if any 387 // a fault inside compiled code, the interpreter, or a stub 388 389 // Handle signal from NativeJump::patch_verified_entry(). 390 if (sig == SIGILL && nativeInstruction_at(pc)->is_sigill_zombie_not_entrant()) { 391 if (TraceTraps) { 392 tty->print_cr("trap: zombie_not_entrant (SIGILL)"); 393 } 394 stub = SharedRuntime::get_handle_wrong_method_stub(); 395 } 396 397 else if (sig == SIGSEGV && 398 os::is_poll_address((address)info->si_addr)) { 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 // Info->si_addr only points to the page base address, so we 405 // must extract the real si_addr from the instruction and the 406 // ucontext. 407 assert(((NativeInstruction*)pc)->is_safepoint_poll(), "must be safepoint poll"); 408 const address real_si_addr = ((NativeInstruction*)pc)->get_poll_address(uc); 409 } 410 411 // SIGTRAP-based implicit null check in compiled code. 412 else if ((sig == SIGFPE) && 413 TrapBasedNullChecks && 414 (trap_pc != NULL) && 415 Assembler::is_sigtrap_zero_check(trap_pc)) { 416 if (TraceTraps) { 417 tty->print_cr("trap: NULL_CHECK at " INTPTR_FORMAT " (SIGFPE)", p2i(trap_pc)); 418 } 419 stub = SharedRuntime::continuation_for_implicit_exception(thread, trap_pc, SharedRuntime::IMPLICIT_NULL); 420 } 421 422 else if (sig == SIGSEGV && ImplicitNullChecks && 423 CodeCache::contains((void*) pc) && 424 !MacroAssembler::needs_explicit_null_check((intptr_t) info->si_addr)) { 425 if (TraceTraps) { 426 tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc)); 427 } 428 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); 429 } 430 431 // SIGTRAP-based implicit range check in compiled code. 432 else if (sig == SIGFPE && TrapBasedRangeChecks && 433 (trap_pc != NULL) && 434 Assembler::is_sigtrap_range_check(trap_pc)) { 435 if (TraceTraps) { 436 tty->print_cr("trap: RANGE_CHECK at " INTPTR_FORMAT " (SIGFPE)", p2i(trap_pc)); 437 } 438 stub = SharedRuntime::continuation_for_implicit_exception(thread, trap_pc, SharedRuntime::IMPLICIT_NULL); 439 } 440 441 else if (sig == SIGFPE && info->si_code == FPE_INTDIV) { 442 stub = SharedRuntime::continuation_for_implicit_exception(thread, trap_pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO); 443 } 444 445 else if (sig == SIGBUS) { 446 // BugId 4454115: A read from a MappedByteBuffer can fault here if the 447 // underlying file has been truncated. Do not crash the VM in such a case. 448 CodeBlob* cb = CodeCache::find_blob_unsafe(pc); 449 CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; 450 if (nm != NULL && nm->has_unsafe_access()) { 451 // We don't really need a stub here! Just set the pending exeption and 452 // continue at the next instruction after the faulting read. Returning 453 // garbage from this read is ok. 454 thread->set_pending_unsafe_access_error(); 455 uc->uc_mcontext.psw.addr = ((unsigned long)pc) + Assembler::instr_len(pc); 456 return true; 457 } 458 } 459 } 460 461 else { // thread->thread_state() != _thread_in_Java 462 if ((sig == SIGILL) && VM_Version::is_determine_features_test_running()) { 463 // SIGILL must be caused by VM_Version::determine_features() 464 // when attempting to execute a non-existing instruction. 465 //*(int *) (pc-6)=0; // Patch instruction to 0 to indicate that it causes a SIGILL. 466 // Flushing of icache is not necessary. 467 stub = pc; // Continue with next instruction. 468 } else if ((sig == SIGFPE) && VM_Version::is_determine_features_test_running()) { 469 // SIGFPE is known to be caused by trying to execute a vector instruction 470 // when the vector facility is installed, but operating system support is missing. 471 VM_Version::reset_has_VectorFacility(); 472 stub = pc; // Continue with next instruction. 473 } else if (thread->thread_state() == _thread_in_vm && 474 sig == SIGBUS && thread->doing_unsafe_access()) { 475 // We don't really need a stub here! Just set the pending exeption and 476 // continue at the next instruction after the faulting read. Returning 477 // garbage from this read is ok. 478 thread->set_pending_unsafe_access_error(); 479 os::Linux::ucontext_set_pc(uc, pc + Assembler::instr_len(pc)); 480 return true; 481 } 482 } 483 484 // Check to see if we caught the safepoint code in the 485 // process of write protecting the memory serialization page. 486 // It write enables the page immediately after protecting it 487 // so we can just return to retry the write. 488 // Info->si_addr need not be the exact address, it is only 489 // guaranteed to be on the same page as the address that caused 490 // the SIGSEGV. 491 if ((sig == SIGSEGV) && !UseMembar && 492 (os::get_memory_serialize_page() == 493 (address)((uintptr_t)info->si_addr & ~(os::vm_page_size()-1)))) { 494 return true; 495 } 496 } 497 498 if (stub != NULL) { 499 // Save all thread context in case we need to restore it. 500 if (thread != NULL) thread->set_saved_exception_pc(pc); 501 os::Linux::ucontext_set_pc(uc, stub); 502 return true; 503 } 504 505 // signal-chaining 506 if (os::Linux::chained_handler(sig, info, ucVoid)) { 507 return true; 508 } 509 510 if (!abort_if_unrecognized) { 511 // caller wants another chance, so give it to him 512 return false; 513 } 514 515 if (pc == NULL && uc != NULL) { 516 pc = os::Linux::ucontext_get_pc(uc); 517 } 518 519 // unmask current signal 520 sigset_t newset; 521 sigemptyset(&newset); 522 sigaddset(&newset, sig); 523 sigprocmask(SIG_UNBLOCK, &newset, NULL); 524 525 // Hand down correct pc for SIGILL, SIGFPE. pc from context 526 // usually points to the instruction after the failing instruction. 527 // Note: this should be combined with the trap_pc handling above, 528 // because it handles the same issue. 529 if (sig == SIGILL || sig == SIGFPE) { 530 pc = (address)info->si_addr; 531 } 532 533 VMError::report_and_die(t, sig, pc, info, ucVoid); 534 535 ShouldNotReachHere(); 536 return false; 537 } 538 539 void os::Linux::init_thread_fpu_state(void) { 540 // Nothing to do on z/Architecture. 541 } 542 543 int os::Linux::get_fpu_control_word(void) { 544 // Nothing to do on z/Architecture. 545 return 0; 546 } 547 548 void os::Linux::set_fpu_control_word(int fpu_control) { 549 // Nothing to do on z/Architecture. 550 } 551 552 //////////////////////////////////////////////////////////////////////////////// 553 // thread stack 554 555 // Minimum usable stack sizes required to get to user code. Space for 556 // HotSpot guard pages is added later. 557 size_t os::Posix::_compiler_thread_min_stack_allowed = (52 DEBUG_ONLY(+ 32)) * K; 558 size_t os::Posix::_java_thread_min_stack_allowed = (32 DEBUG_ONLY(+ 8)) * K; 559 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 32 * K; 560 561 // Return default stack size for thr_type. 562 size_t os::Posix::default_stack_size(os::ThreadType thr_type) { 563 // Default stack size (compiler thread needs larger stack). 564 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K); 565 return s; 566 } 567 568 ///////////////////////////////////////////////////////////////////////////// 569 // helper functions for fatal error handler 570 571 void os::print_context(outputStream *st, const void *context) { 572 if (context == NULL) return; 573 574 const ucontext_t* uc = (const ucontext_t*)context; 575 576 st->print_cr("Processor state:"); 577 st->print_cr("----------------"); 578 st->print_cr(" ip = " INTPTR_FORMAT " ", uc->uc_mcontext.psw.addr); 579 st->print_cr(" proc mask = " INTPTR_FORMAT " ", uc->uc_mcontext.psw.mask); 580 st->print_cr(" fpc reg = 0x%8.8x " , uc->uc_mcontext.fpregs.fpc); 581 st->cr(); 582 583 st->print_cr("General Purpose Registers:"); 584 st->print_cr("--------------------------"); 585 for( int i = 0; i < 16; i+=2 ) { 586 st->print(" r%-2d = " INTPTR_FORMAT " " , i, uc->uc_mcontext.gregs[i]); 587 st->print(" r%-2d = " INTPTR_FORMAT " |", i+1, uc->uc_mcontext.gregs[i+1]); 588 st->print(" r%-2d = %23.1ld " , i, uc->uc_mcontext.gregs[i]); 589 st->print(" r%-2d = %23.1ld " , i+1, uc->uc_mcontext.gregs[i+1]); 590 st->cr(); 591 } 592 st->cr(); 593 594 st->print_cr("Access Registers:"); 595 st->print_cr("-----------------"); 596 for( int i = 0; i < 16; i+=2 ) { 597 st->print(" ar%-2d = 0x%8.8x ", i, uc->uc_mcontext.aregs[i]); 598 st->print(" ar%-2d = 0x%8.8x ", i+1, uc->uc_mcontext.aregs[i+1]); 599 st->cr(); 600 } 601 st->cr(); 602 603 st->print_cr("Float Registers:"); 604 st->print_cr("----------------"); 605 for (int i = 0; i < 16; i += 2) { 606 st->print(" fr%-2d = " INTPTR_FORMAT " " , i, (int64_t)(uc->uc_mcontext.fpregs.fprs[i].d)); 607 st->print(" fr%-2d = " INTPTR_FORMAT " |", i+1, (int64_t)(uc->uc_mcontext.fpregs.fprs[i+1].d)); 608 st->print(" fr%-2d = %23.15e " , i, (uc->uc_mcontext.fpregs.fprs[i].d)); 609 st->print(" fr%-2d = %23.15e " , i+1, (uc->uc_mcontext.fpregs.fprs[i+1].d)); 610 st->cr(); 611 } 612 st->cr(); 613 st->cr(); 614 615 intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); 616 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); 617 print_hex_dump(st, (address)sp, (address)(sp + 128), sizeof(intptr_t)); 618 st->cr(); 619 620 // Note: it may be unsafe to inspect memory near pc. For example, pc may 621 // point to garbage if entry point in an nmethod is corrupted. Leave 622 // this at the end, and hope for the best. 623 address pc = os::Linux::ucontext_get_pc(uc); 624 if (Verbose) { st->print_cr("pc at " PTR_FORMAT, p2i(pc)); } 625 st->print_cr("Instructions: (pc=" PTR_FORMAT ")", p2i(pc)); 626 print_hex_dump(st, pc-64, pc+64, /*intrsize=*/4); 627 st->cr(); 628 } 629 630 void os::print_register_info(outputStream *st, const void *context) { 631 if (context == NULL) return; 632 633 const ucontext_t *uc = (const ucontext_t*)context; 634 635 st->print_cr("Register to memory mapping:"); 636 st->cr(); 637 638 st->print("pc ="); print_location(st, (intptr_t)uc->uc_mcontext.psw.addr); 639 for (int i = 0; i < 16; i++) { 640 st->print("r%-2d=", i); 641 print_location(st, uc->uc_mcontext.gregs[i]); 642 } 643 st->cr(); 644 } 645 646 #ifndef PRODUCT 647 void os::verify_stack_alignment() { 648 } 649 #endif 650 651 int os::extra_bang_size_in_bytes() { 652 // z/Architecture does not require the additional stack bang. 653 return 0; 654 }