Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/agent/src/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java
+++ new/agent/src/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java
1 1 /*
2 - * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
2 + * Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 21 * have any questions.
22 22 *
23 23 */
24 24
25 25 package sun.jvm.hotspot.utilities;
26 26
27 27 import sun.jvm.hotspot.code.*;
28 28 import sun.jvm.hotspot.debugger.*;
29 29 import sun.jvm.hotspot.gc_interface.*;
30 30 import sun.jvm.hotspot.interpreter.*;
31 31 import sun.jvm.hotspot.runtime.*;
32 32 import sun.jvm.hotspot.memory.*;
33 33
34 34 /** This class, only intended for use in the debugging system,
35 35 provides the functionality of find() in the VM. */
36 36
37 37 public class PointerFinder {
38 38 public static PointerLocation find(Address a) {
39 39 PointerLocation loc = new PointerLocation(a);
40 40
41 41 CollectedHeap heap = VM.getVM().getUniverse().heap();
42 42 if (heap instanceof GenCollectedHeap) {
43 43 GenCollectedHeap genheap = (GenCollectedHeap) heap;
44 44 if (genheap.isIn(a)) {
45 45 for (int i = 0; i < genheap.nGens(); i++) {
46 46 Generation g = genheap.getGen(i);
47 47 if (g.isIn(a)) {
48 48 loc.gen = g;
49 49 break;
50 50 }
51 51 }
52 52
53 53 if (loc.gen == null) {
54 54 // Should be in perm gen
55 55 Generation permGen = genheap.permGen();
56 56 if (Assert.ASSERTS_ENABLED) {
57 57 Assert.that(permGen.isIn(a), "should have been in ordinary or perm gens if it's in the heap");
58 58 }
59 59 loc.permGen = permGen;
60 60 }
61 61
62 62 if (VM.getVM().getUseTLAB()) {
63 63 // Try to find thread containing it
64 64 for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next()) {
65 65 ThreadLocalAllocBuffer tlab = t.tlab();
66 66 if (tlab.contains(a)) {
67 67 loc.inTLAB = true;
68 68 loc.tlabThread = t;
69 69 loc.tlab = tlab;
70 70 break;
71 71 }
72 72 }
73 73 }
74 74
75 75 return loc;
76 76 }
77 77 } else {
78 78 if (heap.isIn(a)) {
79 79 loc.heap = heap;
80 80 return loc;
81 81 }
82 82 }
83 83
84 84 Interpreter interp = VM.getVM().getInterpreter();
85 85 if (interp.contains(a)) {
86 86 loc.inInterpreter = true;
87 87 loc.interpreterCodelet = interp.getCodeletContaining(a);
88 88 return loc;
89 89 }
90 90
↓ open down ↓ |
78 lines elided |
↑ open up ↑ |
91 91 if (!VM.getVM().isCore()) {
92 92 CodeCache c = VM.getVM().getCodeCache();
93 93 if (c.contains(a)) {
94 94 loc.inCodeCache = true;
95 95 loc.blob = c.findBlobUnsafe(a);
96 96 if (Assert.ASSERTS_ENABLED) {
97 97 Assert.that(loc.blob != null, "Should have found CodeBlob");
98 98 }
99 99 loc.inBlobInstructions = loc.blob.instructionsContains(a);
100 100 loc.inBlobData = loc.blob.dataContains(a);
101 - loc.inBlobOops = loc.blob.oopsContains(a);
101 +
102 + if (loc.blob.isNMethod()) {
103 + NMethod nm = (NMethod) loc.blob;
104 + loc.inBlobOops = nm.oopsContains(a);
105 + }
106 +
102 107 loc.inBlobUnknownLocation = (!(loc.inBlobInstructions ||
103 108 loc.inBlobData ||
104 109 loc.inBlobOops));
105 110 return loc;
106 111 }
107 112 }
108 113
109 114 // Check JNIHandles; both local and global
110 115 JNIHandles handles = VM.getVM().getJNIHandles();
111 116 JNIHandleBlock handleBlock = handles.globalHandles();
112 117 if (handleBlock != null) {
113 118 handleBlock = handleBlock.blockContainingHandle(a);
114 119 }
115 120 if (handleBlock != null) {
116 121 loc.inStrongGlobalJNIHandleBlock = true;
117 122 loc.handleBlock = handleBlock;
118 123 return loc;
119 124 } else {
120 125 handleBlock = handles.weakGlobalHandles();
121 126 if (handleBlock != null) {
122 127 handleBlock = handleBlock.blockContainingHandle(a);
123 128 if (handleBlock != null) {
124 129 loc.inWeakGlobalJNIHandleBlock = true;
125 130 loc.handleBlock = handleBlock;
126 131 return loc;
127 132 } else {
128 133 // Look in thread-local handles
129 134 for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next()) {
130 135 handleBlock = t.activeHandles();
131 136 if (handleBlock != null) {
132 137 handleBlock = handleBlock.blockContainingHandle(a);
133 138 if (handleBlock != null) {
134 139 loc.inLocalJNIHandleBlock = true;
135 140 loc.handleBlock = handleBlock;
136 141 loc.handleThread = t;
137 142 return loc;
138 143 }
139 144 }
140 145 }
141 146 }
142 147 }
143 148 }
144 149
145 150
146 151 // Fall through; have to return it anyway.
147 152 return loc;
148 153 }
149 154 }
↓ open down ↓ |
38 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX