73 long size = ob.getSize(); 74 if ( pc.greaterThanOrEqual(base) && pc.lessThan(base.addOffsetTo(size))) { 75 return ob; 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 rbp = context.getRegisterAsAddress(AMD64ThreadContext.RBP); 94 if (rbp == null) return null; 95 Address pc = context.getRegisterAsAddress(AMD64ThreadContext.RIP); 96 if (pc == null) return null; 97 return new LinuxAMD64CFrame(dbg, rbp, pc); 98 } else if (cpu.equals("sparc")) { 99 SPARCThreadContext context = (SPARCThreadContext) thread.getContext(); 100 Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP); 101 if (sp == null) return null; 102 Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_O7); 103 if (pc == null) return null; 104 return new LinuxSPARCCFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize()); 105 } else if (cpu.equals("ppc64")) { 106 PPC64ThreadContext context = (PPC64ThreadContext) thread.getContext(); 107 Address sp = context.getRegisterAsAddress(PPC64ThreadContext.SP); 108 if (sp == null) return null; 109 Address pc = context.getRegisterAsAddress(PPC64ThreadContext.PC); 110 if (pc == null) return null; 111 return new LinuxPPC64CFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize()); 112 } else if (cpu.equals("aarch64")) { 113 AARCH64ThreadContext context = (AARCH64ThreadContext) thread.getContext(); 114 Address fp = context.getRegisterAsAddress(AARCH64ThreadContext.FP); 115 if (fp == null) return null; 116 Address pc = context.getRegisterAsAddress(AARCH64ThreadContext.PC); 117 if (pc == null) return null; | 73 long size = ob.getSize(); 74 if ( pc.greaterThanOrEqual(base) && pc.lessThan(base.addOffsetTo(size))) { 75 return ob; 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 96 long libptr = dbg.findLibPtrByAddress(pc); 97 if (libptr == 0L) { // Java frame 98 Address rbp = context.getRegisterAsAddress(AMD64ThreadContext.RBP); 99 if (rbp == null) { 100 return null; 101 } 102 return new LinuxAMD64CFrame(dbg, rbp, pc, null); 103 } else { // Native frame 104 DwarfParser dwarf; 105 try { 106 dwarf = new DwarfParser(libptr); 107 } catch (DebuggerException e) { 108 Address rbp = context.getRegisterAsAddress(AMD64ThreadContext.RBP); 109 if (rbp == null) { 110 return null; 111 } 112 return new LinuxAMD64CFrame(dbg, rbp, pc, null); 113 } 114 dwarf.processDwarf(pc); 115 Address cfa = ((dwarf.getCFARegister() == AMD64ThreadContext.RBP) && 116 !dwarf.isBPOffsetAvailable()) 117 ? context.getRegisterAsAddress(AMD64ThreadContext.RBP) 118 : context.getRegisterAsAddress(dwarf.getCFARegister()) 119 .addOffsetTo(dwarf.getCFAOffset()); 120 if (cfa == null) { 121 return null; 122 } 123 return new LinuxAMD64CFrame(dbg, cfa, pc, dwarf); 124 } 125 } else if (cpu.equals("sparc")) { 126 SPARCThreadContext context = (SPARCThreadContext) thread.getContext(); 127 Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP); 128 if (sp == null) return null; 129 Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_O7); 130 if (pc == null) return null; 131 return new LinuxSPARCCFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize()); 132 } else if (cpu.equals("ppc64")) { 133 PPC64ThreadContext context = (PPC64ThreadContext) thread.getContext(); 134 Address sp = context.getRegisterAsAddress(PPC64ThreadContext.SP); 135 if (sp == null) return null; 136 Address pc = context.getRegisterAsAddress(PPC64ThreadContext.PC); 137 if (pc == null) return null; 138 return new LinuxPPC64CFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize()); 139 } else if (cpu.equals("aarch64")) { 140 AARCH64ThreadContext context = (AARCH64ThreadContext) thread.getContext(); 141 Address fp = context.getRegisterAsAddress(AARCH64ThreadContext.FP); 142 if (fp == null) return null; 143 Address pc = context.getRegisterAsAddress(AARCH64ThreadContext.PC); 144 if (pc == null) return null; |