< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java

Print this page
rev 59104 : imported patch serviceability


  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 package sun.jvm.hotspot.debugger.linux;
  27 
  28 import java.io.*;
  29 import java.util.*;
  30 
  31 import sun.jvm.hotspot.debugger.*;
  32 import sun.jvm.hotspot.debugger.cdbg.*;
  33 import sun.jvm.hotspot.debugger.x86.*;
  34 import sun.jvm.hotspot.debugger.amd64.*;
  35 import sun.jvm.hotspot.debugger.aarch64.*;
  36 import sun.jvm.hotspot.debugger.sparc.*;
  37 import sun.jvm.hotspot.debugger.ppc64.*;
  38 import sun.jvm.hotspot.debugger.linux.x86.*;
  39 import sun.jvm.hotspot.debugger.linux.amd64.*;
  40 import sun.jvm.hotspot.debugger.linux.sparc.*;
  41 import sun.jvm.hotspot.debugger.linux.ppc64.*;
  42 import sun.jvm.hotspot.debugger.linux.aarch64.*;
  43 import sun.jvm.hotspot.utilities.*;
  44 
  45 class LinuxCDebugger implements CDebugger {
  46   private LinuxDebugger dbg;
  47 
  48   LinuxCDebugger(LinuxDebugger dbg) {
  49     this.dbg = dbg;
  50   }
  51 
  52   public List<ThreadProxy> getThreadList() throws DebuggerException {
  53     return dbg.getThreadList();
  54   }
  55 
  56   public List<LoadObject> getLoadObjectList() throws DebuggerException {
  57     return dbg.getLoadObjectList();
  58   }
  59 
  60   public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException {


  76       }
  77     }
  78 
  79     return null;
  80   }
  81 
  82   public CFrame topFrameForThread(ThreadProxy thread) throws DebuggerException {
  83     String cpu = dbg.getCPU();
  84     if (cpu.equals("x86")) {
  85        X86ThreadContext context = (X86ThreadContext) thread.getContext();
  86        Address ebp = context.getRegisterAsAddress(X86ThreadContext.EBP);
  87        if (ebp == null) return null;
  88        Address pc  = context.getRegisterAsAddress(X86ThreadContext.EIP);
  89        if (pc == null) return null;
  90        return new LinuxX86CFrame(dbg, ebp, pc);
  91     } else if (cpu.equals("amd64")) {
  92        AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
  93        Address pc  = context.getRegisterAsAddress(AMD64ThreadContext.RIP);
  94        if (pc == null) return null;
  95        return LinuxAMD64CFrame.getTopFrame(dbg, pc, context);
  96     } else if (cpu.equals("sparc")) {
  97        SPARCThreadContext context = (SPARCThreadContext) thread.getContext();
  98        Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP);
  99        if (sp == null) return null;
 100        Address pc  = context.getRegisterAsAddress(SPARCThreadContext.R_O7);
 101        if (pc == null) return null;
 102        return new LinuxSPARCCFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize());
 103     }  else if (cpu.equals("ppc64")) {
 104         PPC64ThreadContext context = (PPC64ThreadContext) thread.getContext();
 105         Address sp = context.getRegisterAsAddress(PPC64ThreadContext.SP);
 106         if (sp == null) return null;
 107         Address pc  = context.getRegisterAsAddress(PPC64ThreadContext.PC);
 108         if (pc == null) return null;
 109         return new LinuxPPC64CFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize());
 110     } else if (cpu.equals("aarch64")) {
 111        AARCH64ThreadContext context = (AARCH64ThreadContext) thread.getContext();
 112        Address fp = context.getRegisterAsAddress(AARCH64ThreadContext.FP);
 113        if (fp == null) return null;
 114        Address pc  = context.getRegisterAsAddress(AARCH64ThreadContext.PC);
 115        if (pc == null) return null;
 116        return new LinuxAARCH64CFrame(dbg, fp, pc);
 117      } else {
 118        // Runtime exception thrown by LinuxThreadContextFactory if unknown cpu
 119        ThreadContext context = (ThreadContext) thread.getContext();
 120        return context.getTopFrame(dbg);
 121     }
 122   }


  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 package sun.jvm.hotspot.debugger.linux;
  27 
  28 import java.io.*;
  29 import java.util.*;
  30 
  31 import sun.jvm.hotspot.debugger.*;
  32 import sun.jvm.hotspot.debugger.cdbg.*;
  33 import sun.jvm.hotspot.debugger.x86.*;
  34 import sun.jvm.hotspot.debugger.amd64.*;
  35 import sun.jvm.hotspot.debugger.aarch64.*;

  36 import sun.jvm.hotspot.debugger.ppc64.*;
  37 import sun.jvm.hotspot.debugger.linux.x86.*;
  38 import sun.jvm.hotspot.debugger.linux.amd64.*;

  39 import sun.jvm.hotspot.debugger.linux.ppc64.*;
  40 import sun.jvm.hotspot.debugger.linux.aarch64.*;
  41 import sun.jvm.hotspot.utilities.*;
  42 
  43 class LinuxCDebugger implements CDebugger {
  44   private LinuxDebugger dbg;
  45 
  46   LinuxCDebugger(LinuxDebugger dbg) {
  47     this.dbg = dbg;
  48   }
  49 
  50   public List<ThreadProxy> getThreadList() throws DebuggerException {
  51     return dbg.getThreadList();
  52   }
  53 
  54   public List<LoadObject> getLoadObjectList() throws DebuggerException {
  55     return dbg.getLoadObjectList();
  56   }
  57 
  58   public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException {


  74       }
  75     }
  76 
  77     return null;
  78   }
  79 
  80   public CFrame topFrameForThread(ThreadProxy thread) throws DebuggerException {
  81     String cpu = dbg.getCPU();
  82     if (cpu.equals("x86")) {
  83        X86ThreadContext context = (X86ThreadContext) thread.getContext();
  84        Address ebp = context.getRegisterAsAddress(X86ThreadContext.EBP);
  85        if (ebp == null) return null;
  86        Address pc  = context.getRegisterAsAddress(X86ThreadContext.EIP);
  87        if (pc == null) return null;
  88        return new LinuxX86CFrame(dbg, ebp, pc);
  89     } else if (cpu.equals("amd64")) {
  90        AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
  91        Address pc  = context.getRegisterAsAddress(AMD64ThreadContext.RIP);
  92        if (pc == null) return null;
  93        return LinuxAMD64CFrame.getTopFrame(dbg, pc, context);







  94     }  else if (cpu.equals("ppc64")) {
  95         PPC64ThreadContext context = (PPC64ThreadContext) thread.getContext();
  96         Address sp = context.getRegisterAsAddress(PPC64ThreadContext.SP);
  97         if (sp == null) return null;
  98         Address pc  = context.getRegisterAsAddress(PPC64ThreadContext.PC);
  99         if (pc == null) return null;
 100         return new LinuxPPC64CFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize());
 101     } else if (cpu.equals("aarch64")) {
 102        AARCH64ThreadContext context = (AARCH64ThreadContext) thread.getContext();
 103        Address fp = context.getRegisterAsAddress(AARCH64ThreadContext.FP);
 104        if (fp == null) return null;
 105        Address pc  = context.getRegisterAsAddress(AARCH64ThreadContext.PC);
 106        if (pc == null) return null;
 107        return new LinuxAARCH64CFrame(dbg, fp, pc);
 108      } else {
 109        // Runtime exception thrown by LinuxThreadContextFactory if unknown cpu
 110        ThreadContext context = (ThreadContext) thread.getContext();
 111        return context.getTopFrame(dbg);
 112     }
 113   }
< prev index next >