90 // currently interrupted by SIGPROF. |
90 // currently interrupted by SIGPROF. |
91 // os::Solaris::fetch_frame_from_ucontext() tries to skip nested |
91 // os::Solaris::fetch_frame_from_ucontext() tries to skip nested |
92 // signal frames. Currently we don't do that on Linux, so it's the |
92 // signal frames. Currently we don't do that on Linux, so it's the |
93 // same as os::fetch_frame_from_context(). |
93 // same as os::fetch_frame_from_context(). |
94 ExtendedPC os::Linux::fetch_frame_from_ucontext(Thread* thread, |
94 ExtendedPC os::Linux::fetch_frame_from_ucontext(Thread* thread, |
95 ucontext_t* uc, |
95 const ucontext_t* uc, |
96 intptr_t** ret_sp, |
96 intptr_t** ret_sp, |
97 intptr_t** ret_fp) { |
97 intptr_t** ret_fp) { |
98 assert(thread != NULL, "just checking"); |
98 assert(thread != NULL, "just checking"); |
99 assert(ret_sp != NULL, "just checking"); |
99 assert(ret_sp != NULL, "just checking"); |
100 assert(ret_fp != NULL, "just checking"); |
100 assert(ret_fp != NULL, "just checking"); |
101 |
101 |
102 return os::fetch_frame_from_context(uc, ret_sp, ret_fp); |
102 return os::fetch_frame_from_context(uc, ret_sp, ret_fp); |
103 } |
103 } |
104 |
104 |
105 ExtendedPC os::fetch_frame_from_context(void* ucVoid, |
105 ExtendedPC os::fetch_frame_from_context(const void* ucVoid, |
106 intptr_t** ret_sp, |
106 intptr_t** ret_sp, |
107 intptr_t** ret_fp) { |
107 intptr_t** ret_fp) { |
108 ucontext_t* uc = (ucontext_t*) ucVoid; |
108 const ucontext_t* uc = (const ucontext_t*) ucVoid; |
109 ExtendedPC epc; |
109 ExtendedPC epc; |
110 |
110 |
111 if (uc != NULL) { |
111 if (uc != NULL) { |
112 epc = ExtendedPC(os::Linux::ucontext_get_pc(uc)); |
112 epc = ExtendedPC(os::Linux::ucontext_get_pc(uc)); |
113 if (ret_sp) { |
113 if (ret_sp) { |
128 } |
128 } |
129 |
129 |
130 return epc; |
130 return epc; |
131 } |
131 } |
132 |
132 |
133 frame os::fetch_frame_from_context(void* ucVoid) { |
133 frame os::fetch_frame_from_context(const void* ucVoid) { |
134 intptr_t* sp; |
134 intptr_t* sp; |
135 ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, NULL); |
135 ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, NULL); |
136 return frame(sp, frame::unpatchable, epc.pc()); |
136 return frame(sp, frame::unpatchable, epc.pc()); |
137 } |
137 } |
138 |
138 |
211 return (char*) 0; |
211 return (char*) 0; |
212 } |
212 } |
213 |
213 |
214 void os::initialize_thread(Thread* thr) {} |
214 void os::initialize_thread(Thread* thr) {} |
215 |
215 |
216 void os::print_context(outputStream *st, void *context) { |
216 void os::print_context(outputStream *st, const void *context) { |
217 if (context == NULL) return; |
217 if (context == NULL) return; |
218 |
218 |
219 ucontext_t* uc = (ucontext_t*)context; |
219 const ucontext_t* uc = (const ucontext_t*)context; |
220 sigcontext* sc = (sigcontext*)context; |
220 sigcontext* sc = (sigcontext*)context; |
221 st->print_cr("Registers:"); |
221 st->print_cr("Registers:"); |
222 |
222 |
223 st->print_cr(" G1=" INTPTR_FORMAT " G2=" INTPTR_FORMAT |
223 st->print_cr(" G1=" INTPTR_FORMAT " G2=" INTPTR_FORMAT |
224 " G3=" INTPTR_FORMAT " G4=" INTPTR_FORMAT, |
224 " G3=" INTPTR_FORMAT " G4=" INTPTR_FORMAT, |
289 st->print_cr("Instructions: (pc=" INTPTR_FORMAT ")", p2i(pc)); |
289 st->print_cr("Instructions: (pc=" INTPTR_FORMAT ")", p2i(pc)); |
290 print_hex_dump(st, pc - 32, pc + 32, sizeof(char)); |
290 print_hex_dump(st, pc - 32, pc + 32, sizeof(char)); |
291 } |
291 } |
292 |
292 |
293 |
293 |
294 void os::print_register_info(outputStream *st, void *context) { |
294 void os::print_register_info(outputStream *st, const void *context) { |
295 if (context == NULL) return; |
295 if (context == NULL) return; |
296 |
296 |
297 ucontext_t *uc = (ucontext_t*)context; |
297 const ucontext_t *uc = (const ucontext_t*)context; |
298 sigcontext* sc = (sigcontext*)context; |
298 const sigcontext* sc = (const sigcontext*)context; |
299 intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); |
299 intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); |
300 |
300 |
301 st->print_cr("Register to memory mapping:"); |
301 st->print_cr("Register to memory mapping:"); |
302 st->cr(); |
302 st->cr(); |
303 |
303 |
341 st->print("I7="); print_location(st, sp[I7->sp_offset_in_saved_window()]); |
341 st->print("I7="); print_location(st, sp[I7->sp_offset_in_saved_window()]); |
342 st->cr(); |
342 st->cr(); |
343 } |
343 } |
344 |
344 |
345 |
345 |
346 address os::Linux::ucontext_get_pc(ucontext_t* uc) { |
346 address os::Linux::ucontext_get_pc(const ucontext_t* uc) { |
347 return (address) SIG_PC((sigcontext*)uc); |
347 return (address) SIG_PC((sigcontext*)uc); |
348 } |
348 } |
349 |
349 |
350 void os::Linux::ucontext_set_pc(ucontext_t* uc, address pc) { |
350 void os::Linux::ucontext_set_pc(ucontext_t* uc, address pc) { |
351 sigcontext* ctx = (sigcontext*) uc; |
351 sigcontext* ctx = (sigcontext*) uc; |
352 SIG_PC(ctx) = (intptr_t)pc; |
352 SIG_PC(ctx) = (intptr_t)pc; |
353 SIG_NPC(ctx) = (intptr_t)(pc+4); |
353 SIG_NPC(ctx) = (intptr_t)(pc+4); |
354 } |
354 } |
355 |
355 |
356 intptr_t* os::Linux::ucontext_get_sp(ucontext_t *uc) { |
356 intptr_t* os::Linux::ucontext_get_sp(const ucontext_t *uc) { |
357 return (intptr_t*) |
357 return (intptr_t*) |
358 ((intptr_t)SIG_REGS((sigcontext*)uc).u_regs[CON_O6] + STACK_BIAS); |
358 ((intptr_t)SIG_REGS((sigcontext*)uc).u_regs[CON_O6] + STACK_BIAS); |
359 } |
359 } |
360 |
360 |
361 // not used on Sparc |
361 // not used on Sparc |
362 intptr_t* os::Linux::ucontext_get_fp(ucontext_t *uc) { |
362 intptr_t* os::Linux::ucontext_get_fp(const ucontext_t *uc) { |
363 ShouldNotReachHere(); |
363 ShouldNotReachHere(); |
364 return NULL; |
364 return NULL; |
365 } |
365 } |
366 |
366 |
367 // Utility functions |
367 // Utility functions |
682 // caller wants another chance, so give it to him |
682 // caller wants another chance, so give it to him |
683 return false; |
683 return false; |
684 } |
684 } |
685 |
685 |
686 if (pc == NULL && uc != NULL) { |
686 if (pc == NULL && uc != NULL) { |
687 pc = os::Linux::ucontext_get_pc((ucontext_t*)uc); |
687 pc = os::Linux::ucontext_get_pc((const ucontext_t*)uc); |
688 } |
688 } |
689 |
689 |
690 // unmask current signal |
690 // unmask current signal |
691 sigset_t newset; |
691 sigset_t newset; |
692 sigemptyset(&newset); |
692 sigemptyset(&newset); |