302 |
302 |
303 void os::initialize_thread(Thread* thr) { |
303 void os::initialize_thread(Thread* thr) { |
304 // Nothing to do. |
304 // Nothing to do. |
305 } |
305 } |
306 |
306 |
307 address os::Bsd::ucontext_get_pc(ucontext_t * uc) { |
307 address os::Bsd::ucontext_get_pc(const ucontext_t * uc) { |
308 return (address)uc->context_pc; |
308 return (address)uc->context_pc; |
309 } |
309 } |
310 |
310 |
311 void os::Bsd::ucontext_set_pc(ucontext_t * uc, address pc) { |
311 void os::Bsd::ucontext_set_pc(ucontext_t * uc, address pc) { |
312 uc->context_pc = (intptr_t)pc ; |
312 uc->context_pc = (intptr_t)pc ; |
313 } |
313 } |
314 |
314 |
315 intptr_t* os::Bsd::ucontext_get_sp(ucontext_t * uc) { |
315 intptr_t* os::Bsd::ucontext_get_sp(const ucontext_t * uc) { |
316 return (intptr_t*)uc->context_sp; |
316 return (intptr_t*)uc->context_sp; |
317 } |
317 } |
318 |
318 |
319 intptr_t* os::Bsd::ucontext_get_fp(ucontext_t * uc) { |
319 intptr_t* os::Bsd::ucontext_get_fp(const ucontext_t * uc) { |
320 return (intptr_t*)uc->context_fp; |
320 return (intptr_t*)uc->context_fp; |
321 } |
321 } |
322 |
322 |
323 // For Forte Analyzer AsyncGetCallTrace profiling support - thread |
323 // For Forte Analyzer AsyncGetCallTrace profiling support - thread |
324 // is currently interrupted by SIGPROF. |
324 // is currently interrupted by SIGPROF. |
325 // os::Solaris::fetch_frame_from_ucontext() tries to skip nested signal |
325 // os::Solaris::fetch_frame_from_ucontext() tries to skip nested signal |
326 // frames. Currently we don't do that on Bsd, so it's the same as |
326 // frames. Currently we don't do that on Bsd, so it's the same as |
327 // os::fetch_frame_from_context(). |
327 // os::fetch_frame_from_context(). |
328 // This method is also used for stack overflow signal handling. |
328 // This method is also used for stack overflow signal handling. |
329 ExtendedPC os::Bsd::fetch_frame_from_ucontext(Thread* thread, |
329 ExtendedPC os::Bsd::fetch_frame_from_ucontext(Thread* thread, |
330 ucontext_t* uc, intptr_t** ret_sp, intptr_t** ret_fp) { |
330 const ucontext_t* uc, intptr_t** ret_sp, intptr_t** ret_fp) { |
331 |
331 |
332 assert(thread != NULL, "just checking"); |
332 assert(thread != NULL, "just checking"); |
333 assert(ret_sp != NULL, "just checking"); |
333 assert(ret_sp != NULL, "just checking"); |
334 assert(ret_fp != NULL, "just checking"); |
334 assert(ret_fp != NULL, "just checking"); |
335 |
335 |
336 return os::fetch_frame_from_context(uc, ret_sp, ret_fp); |
336 return os::fetch_frame_from_context(uc, ret_sp, ret_fp); |
337 } |
337 } |
338 |
338 |
339 ExtendedPC os::fetch_frame_from_context(void* ucVoid, |
339 ExtendedPC os::fetch_frame_from_context(const void* ucVoid, |
340 intptr_t** ret_sp, intptr_t** ret_fp) { |
340 intptr_t** ret_sp, intptr_t** ret_fp) { |
341 |
341 |
342 ExtendedPC epc; |
342 ExtendedPC epc; |
343 ucontext_t* uc = (ucontext_t*)ucVoid; |
343 const ucontext_t* uc = (const ucontext_t*)ucVoid; |
344 |
344 |
345 if (uc != NULL) { |
345 if (uc != NULL) { |
346 epc = ExtendedPC(os::Bsd::ucontext_get_pc(uc)); |
346 epc = ExtendedPC(os::Bsd::ucontext_get_pc(uc)); |
347 if (ret_sp) *ret_sp = os::Bsd::ucontext_get_sp(uc); |
347 if (ret_sp) *ret_sp = os::Bsd::ucontext_get_sp(uc); |
348 if (ret_fp) *ret_fp = os::Bsd::ucontext_get_fp(uc); |
348 if (ret_fp) *ret_fp = os::Bsd::ucontext_get_fp(uc); |
969 } |
969 } |
970 |
970 |
971 ///////////////////////////////////////////////////////////////////////////// |
971 ///////////////////////////////////////////////////////////////////////////// |
972 // helper functions for fatal error handler |
972 // helper functions for fatal error handler |
973 |
973 |
974 void os::print_context(outputStream *st, void *context) { |
974 void os::print_context(outputStream *st, const void *context) { |
975 if (context == NULL) return; |
975 if (context == NULL) return; |
976 |
976 |
977 ucontext_t *uc = (ucontext_t*)context; |
977 const ucontext_t *uc = (const ucontext_t*)context; |
978 st->print_cr("Registers:"); |
978 st->print_cr("Registers:"); |
979 #ifdef AMD64 |
979 #ifdef AMD64 |
980 st->print( "RAX=" INTPTR_FORMAT, uc->context_rax); |
980 st->print( "RAX=" INTPTR_FORMAT, uc->context_rax); |
981 st->print(", RBX=" INTPTR_FORMAT, uc->context_rbx); |
981 st->print(", RBX=" INTPTR_FORMAT, uc->context_rbx); |
982 st->print(", RCX=" INTPTR_FORMAT, uc->context_rcx); |
982 st->print(", RCX=" INTPTR_FORMAT, uc->context_rcx); |
1030 address pc = os::Bsd::ucontext_get_pc(uc); |
1030 address pc = os::Bsd::ucontext_get_pc(uc); |
1031 st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc); |
1031 st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc); |
1032 print_hex_dump(st, pc - 32, pc + 32, sizeof(char)); |
1032 print_hex_dump(st, pc - 32, pc + 32, sizeof(char)); |
1033 } |
1033 } |
1034 |
1034 |
1035 void os::print_register_info(outputStream *st, void *context) { |
1035 void os::print_register_info(outputStream *st, const void *context) { |
1036 if (context == NULL) return; |
1036 if (context == NULL) return; |
1037 |
1037 |
1038 ucontext_t *uc = (ucontext_t*)context; |
1038 const ucontext_t *uc = (const ucontext_t*)context; |
1039 |
1039 |
1040 st->print_cr("Register to memory mapping:"); |
1040 st->print_cr("Register to memory mapping:"); |
1041 st->cr(); |
1041 st->cr(); |
1042 |
1042 |
1043 // this is horrendously verbose but the layout of the registers in the |
1043 // this is horrendously verbose but the layout of the registers in the |