20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 package sun.jvm.hotspot.runtime;
26
27 import java.util.*;
28 import sun.jvm.hotspot.debugger.*;
29 import sun.jvm.hotspot.types.*;
30 import sun.jvm.hotspot.runtime.solaris_sparc.SolarisSPARCJavaThreadPDAccess;
31 import sun.jvm.hotspot.runtime.solaris_x86.SolarisX86JavaThreadPDAccess;
32 import sun.jvm.hotspot.runtime.solaris_amd64.SolarisAMD64JavaThreadPDAccess;
33 import sun.jvm.hotspot.runtime.win32_amd64.Win32AMD64JavaThreadPDAccess;
34 import sun.jvm.hotspot.runtime.win32_x86.Win32X86JavaThreadPDAccess;
35 import sun.jvm.hotspot.runtime.win32_ia64.Win32IA64JavaThreadPDAccess;
36 import sun.jvm.hotspot.runtime.linux_x86.LinuxX86JavaThreadPDAccess;
37 import sun.jvm.hotspot.runtime.linux_ia64.LinuxIA64JavaThreadPDAccess;
38 import sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess;
39 import sun.jvm.hotspot.runtime.linux_sparc.LinuxSPARCJavaThreadPDAccess;
40 import sun.jvm.hotspot.utilities.*;
41
42 public class Threads {
43 private static JavaThreadFactory threadFactory;
44 private static AddressField threadListField;
45 private static VirtualConstructor virtualConstructor;
46 private static JavaThreadPDAccess access;
47
48 static {
49 VM.registerVMInitializedObserver(new Observer() {
50 public void update(Observable o, Object data) {
51 initialize(VM.getVM().getTypeDataBase());
52 }
53 });
54 }
55
56 private static synchronized void initialize(TypeDataBase db) {
57 Type type = db.lookupType("Threads");
58
59 threadListField = type.getAddressField("_thread_list");
73 access = new SolarisAMD64JavaThreadPDAccess();
74 }
75 } else if (os.equals("win32")) {
76 if (cpu.equals("x86")) {
77 access = new Win32X86JavaThreadPDAccess();
78 } else if (cpu.equals("amd64")) {
79 access = new Win32AMD64JavaThreadPDAccess();
80 } else if (cpu.equals("ia64")) {
81 access = new Win32IA64JavaThreadPDAccess();
82 }
83 } else if (os.equals("linux")) {
84 if (cpu.equals("x86")) {
85 access = new LinuxX86JavaThreadPDAccess();
86 } else if (cpu.equals("ia64")) {
87 access = new LinuxIA64JavaThreadPDAccess();
88 } else if (cpu.equals("amd64")) {
89 access = new LinuxAMD64JavaThreadPDAccess();
90 } else if (cpu.equals("sparc")) {
91 access = new LinuxSPARCJavaThreadPDAccess();
92 }
93
94 }
95
96 if (access == null) {
97 throw new RuntimeException("OS/CPU combination " + os + "/" + cpu +
98 " not yet supported");
99 }
100
101 virtualConstructor = new VirtualConstructor(db);
102 // Add mappings for all known thread types
103 virtualConstructor.addMapping("JavaThread", JavaThread.class);
104 if (!VM.getVM().isCore()) {
105 virtualConstructor.addMapping("CompilerThread", CompilerThread.class);
106 }
107 // for now, use JavaThread itself. fix it later with appropriate class if needed
108 virtualConstructor.addMapping("SurrogateLockerThread", JavaThread.class);
109 virtualConstructor.addMapping("JvmtiAgentThread", JvmtiAgentThread.class);
110 virtualConstructor.addMapping("ServiceThread", ServiceThread.class);
111 }
112
113 public Threads() {
114 }
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 package sun.jvm.hotspot.runtime;
26
27 import java.util.*;
28 import sun.jvm.hotspot.debugger.*;
29 import sun.jvm.hotspot.types.*;
30 import sun.jvm.hotspot.runtime.solaris_sparc.SolarisSPARCJavaThreadPDAccess;
31 import sun.jvm.hotspot.runtime.solaris_x86.SolarisX86JavaThreadPDAccess;
32 import sun.jvm.hotspot.runtime.solaris_amd64.SolarisAMD64JavaThreadPDAccess;
33 import sun.jvm.hotspot.runtime.win32_amd64.Win32AMD64JavaThreadPDAccess;
34 import sun.jvm.hotspot.runtime.win32_x86.Win32X86JavaThreadPDAccess;
35 import sun.jvm.hotspot.runtime.win32_ia64.Win32IA64JavaThreadPDAccess;
36 import sun.jvm.hotspot.runtime.linux_x86.LinuxX86JavaThreadPDAccess;
37 import sun.jvm.hotspot.runtime.linux_ia64.LinuxIA64JavaThreadPDAccess;
38 import sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess;
39 import sun.jvm.hotspot.runtime.linux_sparc.LinuxSPARCJavaThreadPDAccess;
40 import sun.jvm.hotspot.runtime.bsd_x86.BsdX86JavaThreadPDAccess;
41 import sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess;
42 import sun.jvm.hotspot.utilities.*;
43
44 public class Threads {
45 private static JavaThreadFactory threadFactory;
46 private static AddressField threadListField;
47 private static VirtualConstructor virtualConstructor;
48 private static JavaThreadPDAccess access;
49
50 static {
51 VM.registerVMInitializedObserver(new Observer() {
52 public void update(Observable o, Object data) {
53 initialize(VM.getVM().getTypeDataBase());
54 }
55 });
56 }
57
58 private static synchronized void initialize(TypeDataBase db) {
59 Type type = db.lookupType("Threads");
60
61 threadListField = type.getAddressField("_thread_list");
75 access = new SolarisAMD64JavaThreadPDAccess();
76 }
77 } else if (os.equals("win32")) {
78 if (cpu.equals("x86")) {
79 access = new Win32X86JavaThreadPDAccess();
80 } else if (cpu.equals("amd64")) {
81 access = new Win32AMD64JavaThreadPDAccess();
82 } else if (cpu.equals("ia64")) {
83 access = new Win32IA64JavaThreadPDAccess();
84 }
85 } else if (os.equals("linux")) {
86 if (cpu.equals("x86")) {
87 access = new LinuxX86JavaThreadPDAccess();
88 } else if (cpu.equals("ia64")) {
89 access = new LinuxIA64JavaThreadPDAccess();
90 } else if (cpu.equals("amd64")) {
91 access = new LinuxAMD64JavaThreadPDAccess();
92 } else if (cpu.equals("sparc")) {
93 access = new LinuxSPARCJavaThreadPDAccess();
94 }
95 } else if (os.equals("bsd")) {
96 if (cpu.equals("x86")) {
97 access = new BsdX86JavaThreadPDAccess();
98 } else if (cpu.equals("amd64")) {
99 access = new BsdAMD64JavaThreadPDAccess();
100 }
101 }
102
103 if (access == null) {
104 throw new RuntimeException("OS/CPU combination " + os + "/" + cpu +
105 " not yet supported");
106 }
107
108 virtualConstructor = new VirtualConstructor(db);
109 // Add mappings for all known thread types
110 virtualConstructor.addMapping("JavaThread", JavaThread.class);
111 if (!VM.getVM().isCore()) {
112 virtualConstructor.addMapping("CompilerThread", CompilerThread.class);
113 }
114 // for now, use JavaThread itself. fix it later with appropriate class if needed
115 virtualConstructor.addMapping("SurrogateLockerThread", JavaThread.class);
116 virtualConstructor.addMapping("JvmtiAgentThread", JvmtiAgentThread.class);
117 virtualConstructor.addMapping("ServiceThread", ServiceThread.class);
118 }
119
120 public Threads() {
121 }
|