hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp
changeset 35077 8b86440d3bf1
parent 34667 6b077f0ef25d
child 35201 996db89f378e
equal deleted inserted replaced
35076:14858721b3b3 35077:8b86440d3bf1
    97 void os::initialize_thread(Thread *thread) { }
    97 void os::initialize_thread(Thread *thread) { }
    98 
    98 
    99 // Frame information (pc, sp, fp) retrieved via ucontext
    99 // Frame information (pc, sp, fp) retrieved via ucontext
   100 // always looks like a C-frame according to the frame
   100 // always looks like a C-frame according to the frame
   101 // conventions in frame_ppc64.hpp.
   101 // conventions in frame_ppc64.hpp.
   102 address os::Linux::ucontext_get_pc(ucontext_t * uc) {
   102 address os::Linux::ucontext_get_pc(const ucontext_t * uc) {
   103   // On powerpc64, ucontext_t is not selfcontained but contains
   103   // On powerpc64, ucontext_t is not selfcontained but contains
   104   // a pointer to an optional substructure (mcontext_t.regs) containing the volatile
   104   // a pointer to an optional substructure (mcontext_t.regs) containing the volatile
   105   // registers - NIP, among others.
   105   // registers - NIP, among others.
   106   // This substructure may or may not be there depending where uc came from:
   106   // This substructure may or may not be there depending where uc came from:
   107   // - if uc was handed over as the argument to a sigaction handler, a pointer to the
   107   // - if uc was handed over as the argument to a sigaction handler, a pointer to the
   120 void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
   120 void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
   121   guarantee(uc->uc_mcontext.regs != NULL, "only use ucontext_set_pc in sigaction context");
   121   guarantee(uc->uc_mcontext.regs != NULL, "only use ucontext_set_pc in sigaction context");
   122   uc->uc_mcontext.regs->nip = (unsigned long)pc;
   122   uc->uc_mcontext.regs->nip = (unsigned long)pc;
   123 }
   123 }
   124 
   124 
   125 intptr_t* os::Linux::ucontext_get_sp(ucontext_t * uc) {
   125 intptr_t* os::Linux::ucontext_get_sp(const ucontext_t * uc) {
   126   return (intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/];
   126   return (intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/];
   127 }
   127 }
   128 
   128 
   129 intptr_t* os::Linux::ucontext_get_fp(ucontext_t * uc) {
   129 intptr_t* os::Linux::ucontext_get_fp(const ucontext_t * uc) {
   130   return NULL;
   130   return NULL;
   131 }
   131 }
   132 
   132 
   133 ExtendedPC os::fetch_frame_from_context(void* ucVoid,
   133 ExtendedPC os::fetch_frame_from_context(const void* ucVoid,
   134                     intptr_t** ret_sp, intptr_t** ret_fp) {
   134                     intptr_t** ret_sp, intptr_t** ret_fp) {
   135 
   135 
   136   ExtendedPC  epc;
   136   ExtendedPC  epc;
   137   ucontext_t* uc = (ucontext_t*)ucVoid;
   137   const ucontext_t* uc = (const ucontext_t*)ucVoid;
   138 
   138 
   139   if (uc != NULL) {
   139   if (uc != NULL) {
   140     epc = ExtendedPC(os::Linux::ucontext_get_pc(uc));
   140     epc = ExtendedPC(os::Linux::ucontext_get_pc(uc));
   141     if (ret_sp) *ret_sp = os::Linux::ucontext_get_sp(uc);
   141     if (ret_sp) *ret_sp = os::Linux::ucontext_get_sp(uc);
   142     if (ret_fp) *ret_fp = os::Linux::ucontext_get_fp(uc);
   142     if (ret_fp) *ret_fp = os::Linux::ucontext_get_fp(uc);
   148   }
   148   }
   149 
   149 
   150   return epc;
   150   return epc;
   151 }
   151 }
   152 
   152 
   153 frame os::fetch_frame_from_context(void* ucVoid) {
   153 frame os::fetch_frame_from_context(const void* ucVoid) {
   154   intptr_t* sp;
   154   intptr_t* sp;
   155   intptr_t* fp;
   155   intptr_t* fp;
   156   ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp);
   156   ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp);
   157   return frame(sp, epc.pc());
   157   return frame(sp, epc.pc());
   158 }
   158 }
   562 }
   562 }
   563 
   563 
   564 /////////////////////////////////////////////////////////////////////////////
   564 /////////////////////////////////////////////////////////////////////////////
   565 // helper functions for fatal error handler
   565 // helper functions for fatal error handler
   566 
   566 
   567 void os::print_context(outputStream *st, void *context) {
   567 void os::print_context(outputStream *st, const void *context) {
   568   if (context == NULL) return;
   568   if (context == NULL) return;
   569 
   569 
   570   ucontext_t* uc = (ucontext_t*)context;
   570   const ucontext_t* uc = (const ucontext_t*)context;
   571 
   571 
   572   st->print_cr("Registers:");
   572   st->print_cr("Registers:");
   573   st->print("pc =" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->nip);
   573   st->print("pc =" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->nip);
   574   st->print("lr =" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->link);
   574   st->print("lr =" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->link);
   575   st->print("ctr=" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->ctr);
   575   st->print("ctr=" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->ctr);
   593   st->print_cr("Instructions: (pc=" PTR_FORMAT ")", p2i(pc));
   593   st->print_cr("Instructions: (pc=" PTR_FORMAT ")", p2i(pc));
   594   print_hex_dump(st, pc - 64, pc + 64, /*instrsize=*/4);
   594   print_hex_dump(st, pc - 64, pc + 64, /*instrsize=*/4);
   595   st->cr();
   595   st->cr();
   596 }
   596 }
   597 
   597 
   598 void os::print_register_info(outputStream *st, void *context) {
   598 void os::print_register_info(outputStream *st, const void *context) {
   599   if (context == NULL) return;
   599   if (context == NULL) return;
   600 
   600 
   601   ucontext_t *uc = (ucontext_t*)context;
   601   const ucontext_t *uc = (const ucontext_t*)context;
   602 
   602 
   603   st->print_cr("Register to memory mapping:");
   603   st->print_cr("Register to memory mapping:");
   604   st->cr();
   604   st->cr();
   605 
   605 
   606   // this is only for the "general purpose" registers
   606   // this is only for the "general purpose" registers