Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java @ 8750:39432a1cefdd
8003348: SA can not read core file on OS
Summary: Macosx uses Mach-O file format for binary files, not ELF format. Currently SA works on core files on other platforms, t his change enables SA work on core file generated on Darwin.
Reviewed-by: sla, sspitsyn
Contributed-by: yumin.qi@oracle.com
author | minqi |
---|---|
date | Thu, 14 Mar 2013 00:33:08 -0700 |
parents | 5a98bf7d847b |
children |
comparison
equal
deleted
inserted
replaced
8719:c8b31b461e1a | 8750:39432a1cefdd |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
40 import sun.jvm.hotspot.utilities.*; | 40 import sun.jvm.hotspot.utilities.*; |
41 | 41 |
42 public class Threads { | 42 public class Threads { |
43 private static JavaThreadFactory threadFactory; | 43 private static JavaThreadFactory threadFactory; |
44 private static AddressField threadListField; | 44 private static AddressField threadListField; |
45 private static CIntegerField numOfThreadsField; | |
45 private static VirtualConstructor virtualConstructor; | 46 private static VirtualConstructor virtualConstructor; |
46 private static JavaThreadPDAccess access; | 47 private static JavaThreadPDAccess access; |
47 | 48 |
48 static { | 49 static { |
49 VM.registerVMInitializedObserver(new Observer() { | 50 VM.registerVMInitializedObserver(new Observer() { |
55 | 56 |
56 private static synchronized void initialize(TypeDataBase db) { | 57 private static synchronized void initialize(TypeDataBase db) { |
57 Type type = db.lookupType("Threads"); | 58 Type type = db.lookupType("Threads"); |
58 | 59 |
59 threadListField = type.getAddressField("_thread_list"); | 60 threadListField = type.getAddressField("_thread_list"); |
61 numOfThreadsField = type.getCIntegerField("_number_of_threads"); | |
60 | 62 |
61 // Instantiate appropriate platform-specific JavaThreadFactory | 63 // Instantiate appropriate platform-specific JavaThreadFactory |
62 String os = VM.getVM().getOS(); | 64 String os = VM.getVM().getOS(); |
63 String cpu = VM.getVM().getCPU(); | 65 String cpu = VM.getVM().getCPU(); |
64 | 66 |
100 if (cpu.equals("x86")) { | 102 if (cpu.equals("x86")) { |
101 access = new BsdX86JavaThreadPDAccess(); | 103 access = new BsdX86JavaThreadPDAccess(); |
102 } else if (cpu.equals("amd64") || cpu.equals("x86_64")) { | 104 } else if (cpu.equals("amd64") || cpu.equals("x86_64")) { |
103 access = new BsdAMD64JavaThreadPDAccess(); | 105 access = new BsdAMD64JavaThreadPDAccess(); |
104 } | 106 } |
107 } else if (os.equals("darwin")) { | |
108 if (cpu.equals("amd64") || cpu.equals("x86_64")) { | |
109 access = new BsdAMD64JavaThreadPDAccess(); | |
110 } | |
105 } | 111 } |
106 | 112 |
107 if (access == null) { | 113 if (access == null) { |
108 throw new RuntimeException("OS/CPU combination " + os + "/" + cpu + | 114 throw new RuntimeException("OS/CPU combination " + os + "/" + cpu + |
109 " not yet supported"); | 115 " not yet supported"); |
142 } | 148 } |
143 | 149 |
144 return createJavaThreadWrapper(threadAddr); | 150 return createJavaThreadWrapper(threadAddr); |
145 } | 151 } |
146 | 152 |
153 public int getNumberOfThreads() { | |
154 return (int) numOfThreadsField.getValue(); | |
155 } | |
156 | |
147 /** Routine for instantiating appropriately-typed wrapper for a | 157 /** Routine for instantiating appropriately-typed wrapper for a |
148 JavaThread. Currently needs to be public for OopUtilities to | 158 JavaThread. Currently needs to be public for OopUtilities to |
149 access it. */ | 159 access it. */ |
150 public JavaThread createJavaThreadWrapper(Address threadAddr) { | 160 public JavaThread createJavaThreadWrapper(Address threadAddr) { |
151 try { | 161 try { |