51 #include "runtime/thread.inline.hpp" |
51 #include "runtime/thread.inline.hpp" |
52 #include "runtime/timer.hpp" |
52 #include "runtime/timer.hpp" |
53 #include "utilities/debug.hpp" |
53 #include "utilities/debug.hpp" |
54 #include "utilities/events.hpp" |
54 #include "utilities/events.hpp" |
55 #include "utilities/vmError.hpp" |
55 #include "utilities/vmError.hpp" |
56 #ifdef BUILTIN_SIM |
|
57 #include "../../../../../../simulator/simulator.hpp" |
|
58 #endif |
|
59 |
56 |
60 // put OS-includes here |
57 // put OS-includes here |
61 # include <sys/types.h> |
58 # include <sys/types.h> |
62 # include <sys/mman.h> |
59 # include <sys/mman.h> |
63 # include <pthread.h> |
60 # include <pthread.h> |
99 |
90 |
100 return (char*) 0xffffffffffff; |
91 return (char*) 0xffffffffffff; |
101 } |
92 } |
102 |
93 |
103 address os::Linux::ucontext_get_pc(const ucontext_t * uc) { |
94 address os::Linux::ucontext_get_pc(const ucontext_t * uc) { |
104 #ifdef BUILTIN_SIM |
|
105 return (address)uc->uc_mcontext.gregs[REG_PC]; |
|
106 #else |
|
107 return (address)uc->uc_mcontext.pc; |
95 return (address)uc->uc_mcontext.pc; |
108 #endif |
|
109 } |
96 } |
110 |
97 |
111 void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) { |
98 void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) { |
112 #ifdef BUILTIN_SIM |
|
113 uc->uc_mcontext.gregs[REG_PC] = (intptr_t)pc; |
|
114 #else |
|
115 uc->uc_mcontext.pc = (intptr_t)pc; |
99 uc->uc_mcontext.pc = (intptr_t)pc; |
116 #endif |
|
117 } |
100 } |
118 |
101 |
119 intptr_t* os::Linux::ucontext_get_sp(const ucontext_t * uc) { |
102 intptr_t* os::Linux::ucontext_get_sp(const ucontext_t * uc) { |
120 #ifdef BUILTIN_SIM |
|
121 return (intptr_t*)uc->uc_mcontext.gregs[REG_SP]; |
|
122 #else |
|
123 return (intptr_t*)uc->uc_mcontext.sp; |
103 return (intptr_t*)uc->uc_mcontext.sp; |
124 #endif |
|
125 } |
104 } |
126 |
105 |
127 intptr_t* os::Linux::ucontext_get_fp(const ucontext_t * uc) { |
106 intptr_t* os::Linux::ucontext_get_fp(const ucontext_t * uc) { |
128 #ifdef BUILTIN_SIM |
|
129 return (intptr_t*)uc->uc_mcontext.gregs[REG_FP]; |
|
130 #else |
|
131 return (intptr_t*)uc->uc_mcontext.regs[REG_FP]; |
107 return (intptr_t*)uc->uc_mcontext.regs[REG_FP]; |
132 #endif |
|
133 } |
108 } |
134 |
109 |
135 // For Forte Analyzer AsyncGetCallTrace profiling support - thread |
110 // For Forte Analyzer AsyncGetCallTrace profiling support - thread |
136 // is currently interrupted by SIGPROF. |
111 // is currently interrupted by SIGPROF. |
137 // os::Solaris::fetch_frame_from_ucontext() tries to skip nested signal |
112 // os::Solaris::fetch_frame_from_ucontext() tries to skip nested signal |
215 } |
190 } |
216 |
191 |
217 // By default, gcc always saves frame pointer rfp on this stack. This |
192 // By default, gcc always saves frame pointer rfp on this stack. This |
218 // may get turned off by -fomit-frame-pointer. |
193 // may get turned off by -fomit-frame-pointer. |
219 frame os::get_sender_for_C_frame(frame* fr) { |
194 frame os::get_sender_for_C_frame(frame* fr) { |
220 #ifdef BUILTIN_SIM |
|
221 return frame(fr->sender_sp(), fr->link(), fr->sender_pc()); |
|
222 #else |
|
223 return frame(fr->link(), fr->link(), fr->sender_pc()); |
195 return frame(fr->link(), fr->link(), fr->sender_pc()); |
224 #endif |
|
225 } |
196 } |
226 |
197 |
227 NOINLINE frame os::current_frame() { |
198 NOINLINE frame os::current_frame() { |
228 intptr_t *fp = *(intptr_t **)__builtin_frame_address(0); |
199 intptr_t *fp = *(intptr_t **)__builtin_frame_address(0); |
229 frame myframe((intptr_t*)os::current_stack_pointer(), |
200 frame myframe((intptr_t*)os::current_stack_pointer(), |
313 |
276 |
314 //%note os_trap_1 |
277 //%note os_trap_1 |
315 if (info != NULL && uc != NULL && thread != NULL) { |
278 if (info != NULL && uc != NULL && thread != NULL) { |
316 pc = (address) os::Linux::ucontext_get_pc(uc); |
279 pc = (address) os::Linux::ucontext_get_pc(uc); |
317 |
280 |
318 #ifdef BUILTIN_SIM |
|
319 if (pc == (address) Fetch32PFI) { |
|
320 uc->uc_mcontext.gregs[REG_PC] = intptr_t(Fetch32Resume) ; |
|
321 return 1 ; |
|
322 } |
|
323 if (pc == (address) FetchNPFI) { |
|
324 uc->uc_mcontext.gregs[REG_PC] = intptr_t (FetchNResume) ; |
|
325 return 1 ; |
|
326 } |
|
327 #else |
|
328 if (StubRoutines::is_safefetch_fault(pc)) { |
281 if (StubRoutines::is_safefetch_fault(pc)) { |
329 os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); |
282 os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); |
330 return 1; |
283 return 1; |
331 } |
284 } |
332 #endif |
|
333 |
285 |
334 address addr = (address) info->si_addr; |
286 address addr = (address) info->si_addr; |
335 |
287 |
336 // Make sure the high order byte is sign extended, as it may be masked away by the hardware. |
288 // Make sure the high order byte is sign extended, as it may be masked away by the hardware. |
337 if ((uintptr_t(addr) & (uintptr_t(1) << 55)) != 0) { |
289 if ((uintptr_t(addr) & (uintptr_t(1) << 55)) != 0) { |
541 void os::print_context(outputStream *st, const void *context) { |
493 void os::print_context(outputStream *st, const void *context) { |
542 if (context == NULL) return; |
494 if (context == NULL) return; |
543 |
495 |
544 const ucontext_t *uc = (const ucontext_t*)context; |
496 const ucontext_t *uc = (const ucontext_t*)context; |
545 st->print_cr("Registers:"); |
497 st->print_cr("Registers:"); |
546 #ifdef BUILTIN_SIM |
|
547 st->print( "RAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RAX]); |
|
548 st->print(", RBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBX]); |
|
549 st->print(", RCX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RCX]); |
|
550 st->print(", RDX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDX]); |
|
551 st->cr(); |
|
552 st->print( "RSP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSP]); |
|
553 st->print(", RBP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBP]); |
|
554 st->print(", RSI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSI]); |
|
555 st->print(", RDI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDI]); |
|
556 st->cr(); |
|
557 st->print( "R8 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R8]); |
|
558 st->print(", R9 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R9]); |
|
559 st->print(", R10=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R10]); |
|
560 st->print(", R11=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R11]); |
|
561 st->cr(); |
|
562 st->print( "R12=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R12]); |
|
563 st->print(", R13=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R13]); |
|
564 st->print(", R14=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R14]); |
|
565 st->print(", R15=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R15]); |
|
566 st->cr(); |
|
567 st->print( "RIP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RIP]); |
|
568 st->print(", EFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EFL]); |
|
569 st->print(", CSGSFS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_CSGSFS]); |
|
570 st->print(", ERR=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_ERR]); |
|
571 st->cr(); |
|
572 st->print(" TRAPNO=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_TRAPNO]); |
|
573 st->cr(); |
|
574 #else |
|
575 for (int r = 0; r < 31; r++) { |
498 for (int r = 0; r < 31; r++) { |
576 st->print("R%-2d=", r); |
499 st->print("R%-2d=", r); |
577 print_location(st, uc->uc_mcontext.regs[r]); |
500 print_location(st, uc->uc_mcontext.regs[r]); |
578 } |
501 } |
579 #endif |
|
580 st->cr(); |
502 st->cr(); |
581 |
503 |
582 intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); |
504 intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); |
583 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); |
505 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); |
584 print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t)); |
506 print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t)); |
604 // context does not match how we defined our abstract Register set, so |
526 // context does not match how we defined our abstract Register set, so |
605 // we can't just iterate through the gregs area |
527 // we can't just iterate through the gregs area |
606 |
528 |
607 // this is only for the "general purpose" registers |
529 // this is only for the "general purpose" registers |
608 |
530 |
609 #ifdef BUILTIN_SIM |
|
610 st->print("RAX="); print_location(st, uc->uc_mcontext.gregs[REG_RAX]); |
|
611 st->print("RBX="); print_location(st, uc->uc_mcontext.gregs[REG_RBX]); |
|
612 st->print("RCX="); print_location(st, uc->uc_mcontext.gregs[REG_RCX]); |
|
613 st->print("RDX="); print_location(st, uc->uc_mcontext.gregs[REG_RDX]); |
|
614 st->print("RSP="); print_location(st, uc->uc_mcontext.gregs[REG_RSP]); |
|
615 st->print("RBP="); print_location(st, uc->uc_mcontext.gregs[REG_RBP]); |
|
616 st->print("RSI="); print_location(st, uc->uc_mcontext.gregs[REG_RSI]); |
|
617 st->print("RDI="); print_location(st, uc->uc_mcontext.gregs[REG_RDI]); |
|
618 st->print("R8 ="); print_location(st, uc->uc_mcontext.gregs[REG_R8]); |
|
619 st->print("R9 ="); print_location(st, uc->uc_mcontext.gregs[REG_R9]); |
|
620 st->print("R10="); print_location(st, uc->uc_mcontext.gregs[REG_R10]); |
|
621 st->print("R11="); print_location(st, uc->uc_mcontext.gregs[REG_R11]); |
|
622 st->print("R12="); print_location(st, uc->uc_mcontext.gregs[REG_R12]); |
|
623 st->print("R13="); print_location(st, uc->uc_mcontext.gregs[REG_R13]); |
|
624 st->print("R14="); print_location(st, uc->uc_mcontext.gregs[REG_R14]); |
|
625 st->print("R15="); print_location(st, uc->uc_mcontext.gregs[REG_R15]); |
|
626 #else |
|
627 for (int r = 0; r < 31; r++) |
531 for (int r = 0; r < 31; r++) |
628 st->print_cr( "R%d=" INTPTR_FORMAT, r, (uintptr_t)uc->uc_mcontext.regs[r]); |
532 st->print_cr( "R%d=" INTPTR_FORMAT, r, (uintptr_t)uc->uc_mcontext.regs[r]); |
629 #endif |
|
630 st->cr(); |
533 st->cr(); |
631 } |
534 } |
632 |
535 |
633 void os::setup_fpu() { |
536 void os::setup_fpu() { |
634 } |
537 } |