14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 package sun.jvm.hotspot.debugger.proc; 26 27 import java.io.*; 28 import java.net.*; 29 import java.util.*; 30 import java.lang.reflect.*; 31 import sun.jvm.hotspot.debugger.*; 32 import sun.jvm.hotspot.debugger.cdbg.*; 33 import sun.jvm.hotspot.debugger.proc.amd64.*; 34 import sun.jvm.hotspot.debugger.proc.sparc.*; 35 import sun.jvm.hotspot.debugger.proc.x86.*; 36 import sun.jvm.hotspot.debugger.amd64.*; 37 import sun.jvm.hotspot.debugger.sparc.*; 38 import sun.jvm.hotspot.debugger.x86.*; 39 import sun.jvm.hotspot.utilities.*; 40 41 /** <P> An implementation of the JVMDebugger interface which sits on 42 * top of proc and relies on the SA's proc import module for 43 * communication with the debugger. </P> 44 * 45 * <P> <B>NOTE</B> that since we have the notion of fetching "Java 46 * primitive types" from the remote process (which might have 47 * different sizes than we expect) we have a bootstrapping 48 * problem. We need to know the sizes of these types before we can 49 * fetch them. The current implementation solves this problem by 50 * requiring that it be configured with these type sizes before they 51 * can be fetched. The readJ(Type) routines here will throw a 52 * RuntimeException if they are called before the debugger is 53 * configured with the Java primitive type sizes. </P> 54 */ 55 56 public class ProcDebuggerLocal extends DebuggerBase implements ProcDebugger { 69 * purpose of supporting remote debugging. </P> */ 70 public ProcDebuggerLocal(MachineDescription machDesc, boolean useCache) { 71 this.machDesc = machDesc; 72 int cacheNumPages; 73 int cachePageSize; 74 75 final String cpu = PlatformInfo.getCPU(); 76 if (cpu.equals("sparc")) { 77 threadFactory = new ProcSPARCThreadFactory(this); 78 pcRegIndex = SPARCThreadContext.R_PC; 79 fpRegIndex = SPARCThreadContext.R_I6; 80 } else if (cpu.equals("x86")) { 81 threadFactory = new ProcX86ThreadFactory(this); 82 pcRegIndex = X86ThreadContext.EIP; 83 fpRegIndex = X86ThreadContext.EBP; 84 unalignedAccessesOkay = true; 85 } else if (cpu.equals("amd64") || cpu.equals("x86_64")) { 86 threadFactory = new ProcAMD64ThreadFactory(this); 87 pcRegIndex = AMD64ThreadContext.RIP; 88 fpRegIndex = AMD64ThreadContext.RBP; 89 } else { 90 try { 91 Class tfc = Class.forName("sun.jvm.hotspot.debugger.proc." + 92 cpu.toLowerCase() + ".Proc" + cpu.toUpperCase() + 93 "ThreadFactory"); 94 Constructor[] ctfc = tfc.getConstructors(); 95 threadFactory = (ProcThreadFactory)ctfc[0].newInstance(this); 96 } catch (Exception e) { 97 throw new RuntimeException("Thread access for CPU architecture " + PlatformInfo.getCPU() + " not yet supported"); 98 // Note: pcRegIndex and fpRegIndex do not appear to be referenced 99 } 100 } 101 if (useCache) { 102 // Cache portion of the remote process's address space. 103 // For now, this cache works best if it covers the entire 104 // heap of the remote process. FIXME: at least should make this 105 // tunable from the outside, i.e., via the UI. This is a 16 MB 106 // cache divided on SPARC into 2048 8K pages and on x86 into 107 // 4096 4K pages; the page size must be adjusted to be the OS's 108 // page size. | 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 package sun.jvm.hotspot.debugger.proc; 26 27 import java.io.*; 28 import java.net.*; 29 import java.util.*; 30 import java.lang.reflect.*; 31 import sun.jvm.hotspot.debugger.*; 32 import sun.jvm.hotspot.debugger.cdbg.*; 33 import sun.jvm.hotspot.debugger.proc.amd64.*; 34 import sun.jvm.hotspot.debugger.proc.aarch64.*; 35 import sun.jvm.hotspot.debugger.proc.sparc.*; 36 import sun.jvm.hotspot.debugger.proc.x86.*; 37 import sun.jvm.hotspot.debugger.amd64.*; 38 import sun.jvm.hotspot.debugger.aarch64.*; 39 import sun.jvm.hotspot.debugger.sparc.*; 40 import sun.jvm.hotspot.debugger.x86.*; 41 import sun.jvm.hotspot.utilities.*; 42 43 /** <P> An implementation of the JVMDebugger interface which sits on 44 * top of proc and relies on the SA's proc import module for 45 * communication with the debugger. </P> 46 * 47 * <P> <B>NOTE</B> that since we have the notion of fetching "Java 48 * primitive types" from the remote process (which might have 49 * different sizes than we expect) we have a bootstrapping 50 * problem. We need to know the sizes of these types before we can 51 * fetch them. The current implementation solves this problem by 52 * requiring that it be configured with these type sizes before they 53 * can be fetched. The readJ(Type) routines here will throw a 54 * RuntimeException if they are called before the debugger is 55 * configured with the Java primitive type sizes. </P> 56 */ 57 58 public class ProcDebuggerLocal extends DebuggerBase implements ProcDebugger { 71 * purpose of supporting remote debugging. </P> */ 72 public ProcDebuggerLocal(MachineDescription machDesc, boolean useCache) { 73 this.machDesc = machDesc; 74 int cacheNumPages; 75 int cachePageSize; 76 77 final String cpu = PlatformInfo.getCPU(); 78 if (cpu.equals("sparc")) { 79 threadFactory = new ProcSPARCThreadFactory(this); 80 pcRegIndex = SPARCThreadContext.R_PC; 81 fpRegIndex = SPARCThreadContext.R_I6; 82 } else if (cpu.equals("x86")) { 83 threadFactory = new ProcX86ThreadFactory(this); 84 pcRegIndex = X86ThreadContext.EIP; 85 fpRegIndex = X86ThreadContext.EBP; 86 unalignedAccessesOkay = true; 87 } else if (cpu.equals("amd64") || cpu.equals("x86_64")) { 88 threadFactory = new ProcAMD64ThreadFactory(this); 89 pcRegIndex = AMD64ThreadContext.RIP; 90 fpRegIndex = AMD64ThreadContext.RBP; 91 } else if (cpu.equals("aarch64")) { 92 threadFactory = new ProcAARCH64ThreadFactory(this); 93 pcRegIndex = AARCH64ThreadContext.PC; 94 fpRegIndex = AARCH64ThreadContext.FP; 95 } else { 96 try { 97 Class tfc = Class.forName("sun.jvm.hotspot.debugger.proc." + 98 cpu.toLowerCase() + ".Proc" + cpu.toUpperCase() + 99 "ThreadFactory"); 100 Constructor[] ctfc = tfc.getConstructors(); 101 threadFactory = (ProcThreadFactory)ctfc[0].newInstance(this); 102 } catch (Exception e) { 103 throw new RuntimeException("Thread access for CPU architecture " + PlatformInfo.getCPU() + " not yet supported"); 104 // Note: pcRegIndex and fpRegIndex do not appear to be referenced 105 } 106 } 107 if (useCache) { 108 // Cache portion of the remote process's address space. 109 // For now, this cache works best if it covers the entire 110 // heap of the remote process. FIXME: at least should make this 111 // tunable from the outside, i.e., via the UI. This is a 16 MB 112 // cache divided on SPARC into 2048 8K pages and on x86 into 113 // 4096 4K pages; the page size must be adjusted to be the OS's 114 // page size. |