src/os_cpu/linux_mips/vm/os_linux_mips.cpp

changeset 6880
52ea28d233d2
parent 414
c5f826fdfc22
child 8012
5efbe2fd5486
equal deleted inserted replaced
6879:11d997b1e656 6880:52ea28d233d2
21 * or visit www.oracle.com if you need additional information or have any 21 * or visit www.oracle.com if you need additional information or have any
22 * questions. 22 * questions.
23 * 23 *
24 */ 24 */
25 25
26 // do not include precompiled header file 26 // no precompiled headers
27 #include "asm/macroAssembler.hpp" 27 #include "asm/macroAssembler.hpp"
28 #include "classfile/classLoader.hpp" 28 #include "classfile/classLoader.hpp"
29 #include "classfile/systemDictionary.hpp" 29 #include "classfile/systemDictionary.hpp"
30 #include "classfile/vmSymbols.hpp" 30 #include "classfile/vmSymbols.hpp"
31 #include "code/icBuffer.hpp" 31 #include "code/icBuffer.hpp"
130 ExtendedPC epc; 130 ExtendedPC epc;
131 ucontext_t* uc = (ucontext_t*)ucVoid; 131 ucontext_t* uc = (ucontext_t*)ucVoid;
132 132
133 address pc = (address)os::Linux::ucontext_get_pc(uc); 133 address pc = (address)os::Linux::ucontext_get_pc(uc);
134 134
135 /* Jin: to capture invalid 32-bit PC, for debbuging */ 135 /* Jin: to capture invalid 32-bit PC, for debbuging */
136 if (((long)pc & 0xFFFFFFFF00000000UL) == 0) 136 if (((long)pc & 0xFFFFFFFF00000000UL) == 0)
137 { 137 {
138 pc = (address)((long)pc | 0x5500000000UL); 138 pc = (address)((long)pc | 0x5500000000UL);
139 tty->print_cr("<Error> 32-bit pc: %lx", pc); 139 tty->print_cr("<Error> 32-bit pc: %lx", pc);
140 } 140 }
161 } 161 }
162 162
163 // By default, gcc always save frame pointer (%ebp/%rbp) on stack. It may get 163 // By default, gcc always save frame pointer (%ebp/%rbp) on stack. It may get
164 // turned off by -fomit-frame-pointer, 164 // turned off by -fomit-frame-pointer,
165 frame os::get_sender_for_C_frame(frame* fr) { 165 frame os::get_sender_for_C_frame(frame* fr) {
166 //return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
167 //tty->print("c frame sp = 0x%lx, fp=0x%lx, pc=0x%lx \n", (int)fr->sp(),(int)fr->fp(),(int)fr->pc());
168 //tty->print("c frame send_sp =0x%lx, fp = 0x%lx, pc = 0x%lx \n",
169 // (int) fr->sender_sp(), (int) fr->link(), (int)fr->sender_pc());
170 return frame(fr->sender_sp(), fr->link(), fr->sender_pc()); 166 return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
171 } 167 }
172 168
173 //intptr_t* _get_previous_fp() { 169 //intptr_t* _get_previous_fp() {
174 //see StubGenerator::generate_get_previous_fp in stubGenerator_gs2.cpp
175 jint* os::get_previous_fp() { 170 jint* os::get_previous_fp() {
176 int *pc; 171 int *pc;
177 int sp; 172 int sp;
178 int *pc_limit = (int*)(void*)&os::get_previous_fp; 173 int *pc_limit = (int*)(void*)&os::get_previous_fp;
179 int insn; 174 int insn;
199 } while (pc>pc_limit); 194 } while (pc>pc_limit);
200 195
201 ShouldNotReachHere(); 196 ShouldNotReachHere();
202 } 197 }
203 198
199
204 frame os::current_frame() { 200 frame os::current_frame() {
205 //tty->print("@@@@@@@@@@@@@@@@@@@get_previous_fp = 0x%lx \n", (intptr_t)(get_previous_fp())); 201 intptr_t* fp = (intptr_t*)get_previous_fp();
206 frame myframe((intptr_t*)os::current_stack_pointer(), 202 frame myframe((intptr_t*)os::current_stack_pointer(),
207 (intptr_t*)get_previous_fp(), 203 (intptr_t*)fp,
208 CAST_FROM_FN_PTR(address, os::current_frame)); 204 CAST_FROM_FN_PTR(address, os::current_frame));
209 if (os::is_first_C_frame(&myframe)) { 205 if (os::is_first_C_frame(&myframe)) {
210 // stack is not walkable 206 // stack is not walkable
211 return frame(NULL, NULL, NULL); 207 return frame();
212 } else { 208 } else {
213 return os::get_sender_for_C_frame(&myframe); 209 return os::get_sender_for_C_frame(&myframe);
214 } 210 }
215 } 211 }
216 212
286 if (info != NULL && uc != NULL && thread != NULL) { 282 if (info != NULL && uc != NULL && thread != NULL) {
287 pc = (address) os::Linux::ucontext_get_pc(uc); 283 pc = (address) os::Linux::ucontext_get_pc(uc);
288 // Handle ALL stack overflow variations here 284 // Handle ALL stack overflow variations here
289 if (sig == SIGSEGV) { 285 if (sig == SIGSEGV) {
290 address addr = (address) info->si_addr; 286 address addr = (address) info->si_addr;
291 // check if fault address is within thread stack
292 #ifdef PRINT_SIGNAL_HANDLE 287 #ifdef PRINT_SIGNAL_HANDLE
293 //tty->print("handle all stack overflow variations: "); 288 //tty->print("handle all stack overflow variations: ");
294 /*tty->print("addr = %lx, stack base = %lx, stack top = %lx\n", 289 /*tty->print("addr = %lx, stack base = %lx, stack top = %lx\n",
295 addr, 290 addr,
296 thread->stack_base(), 291 thread->stack_base(),
297 thread->stack_base() - thread->stack_size()); 292 thread->stack_base() - thread->stack_size());
298 */ 293 */
299 #endif 294 #endif
300 295
296 // check if fault address is within thread stack
301 if (addr < thread->stack_base() && 297 if (addr < thread->stack_base() &&
302 addr >= thread->stack_base() - thread->stack_size()) { 298 addr >= thread->stack_base() - thread->stack_size()) {
303 // stack overflow 299 // stack overflow
304 #ifdef PRINT_SIGNAL_HANDLE 300 #ifdef PRINT_SIGNAL_HANDLE
305 tty->print("stack exception check \n"); 301 tty->print("stack exception check \n");
328 // to handle_unexpected_exception way down below. 324 // to handle_unexpected_exception way down below.
329 #ifdef PRINT_SIGNAL_HANDLE 325 #ifdef PRINT_SIGNAL_HANDLE
330 tty->print("exception addr is in red zone\n"); 326 tty->print("exception addr is in red zone\n");
331 #endif 327 #endif
332 thread->disable_stack_red_zone(); 328 thread->disable_stack_red_zone();
333 #ifdef PRINT_SIGNAL_HANDLE
334 tty->print_raw_cr("An irrecoverable stack overflow has occurred."); 329 tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
335 #endif 330
331 // This is a likely cause, but hard to verify. Let's just print
332 // it as a hint.
333 tty->print_raw_cr("Please check if any of your loaded .so files has "
334 "enabled executable stack (see man page execstack(8))");
336 } else { 335 } else {
337 // Accessing stack address below sp may cause SEGV if current 336 // Accessing stack address below sp may cause SEGV if current
338 // thread has MAP_GROWSDOWN stack. This should only happen when 337 // thread has MAP_GROWSDOWN stack. This should only happen when
339 // current thread was created by user code with MAP_GROWSDOWN flag 338 // current thread was created by user code with MAP_GROWSDOWN flag
340 // and then attached to VM. See notes in os_linux.cpp. 339 // and then attached to VM. See notes in os_linux.cpp.

mercurial