Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/tools/PStack.java @ 8103:5ed317b25e23
7165259: Remove BugSpot
Reviewed-by: coleenp, mgronlun
author | sla |
---|---|
date | Fri, 22 Feb 2013 10:03:02 +0100 |
parents | da91efe96a93 |
children | 39432a1cefdd |
comparison
equal
deleted
inserted
replaced
8102:fc64254f5579 | 8103:5ed317b25e23 |
---|---|
48 run(System.out); | 48 run(System.out); |
49 } | 49 } |
50 | 50 |
51 public void run(PrintStream out) { | 51 public void run(PrintStream out) { |
52 Debugger dbg = getAgent().getDebugger(); | 52 Debugger dbg = getAgent().getDebugger(); |
53 run(out, dbg, getAgent().isJavaMode()); | 53 run(out, dbg); |
54 } | 54 } |
55 | 55 |
56 public void run(PrintStream out, Debugger dbg) { | 56 public void run(PrintStream out, Debugger dbg) { |
57 run(out, dbg, true); | |
58 } | |
59 | |
60 private void run(PrintStream out, Debugger dbg, final boolean isJava) { | |
61 CDebugger cdbg = dbg.getCDebugger(); | 57 CDebugger cdbg = dbg.getCDebugger(); |
62 if (cdbg != null) { | 58 if (cdbg != null) { |
63 ConcurrentLocksPrinter concLocksPrinter = null; | 59 ConcurrentLocksPrinter concLocksPrinter = null; |
64 if (isJava) { | 60 // compute and cache java Vframes. |
65 // compute and cache java Vframes. | 61 initJFrameCache(); |
66 initJFrameCache(); | 62 if (concurrentLocks) { |
67 if (concurrentLocks) { | 63 concLocksPrinter = new ConcurrentLocksPrinter(); |
68 concLocksPrinter = new ConcurrentLocksPrinter(); | 64 } |
69 } | 65 // print Java level deadlocks |
70 // print Java level deadlocks | 66 try { |
71 try { | 67 DeadlockDetector.print(out); |
72 DeadlockDetector.print(out); | 68 } catch (Exception exp) { |
73 } catch (Exception exp) { | 69 out.println("can't print deadlock information: " + exp.getMessage()); |
74 out.println("can't print deadlock information: " + exp.getMessage()); | |
75 } | |
76 } | 70 } |
77 | 71 |
78 List l = cdbg.getThreadList(); | 72 List l = cdbg.getThreadList(); |
79 final boolean cdbgCanDemangle = cdbg.canDemangle(); | 73 final boolean cdbgCanDemangle = cdbg.canDemangle(); |
80 for (Iterator itr = l.iterator() ; itr.hasNext();) { | 74 for (Iterator itr = l.iterator() ; itr.hasNext();) { |
98 if (diff != 0L) { | 92 if (diff != 0L) { |
99 out.print(" + 0x" + Long.toHexString(diff)); | 93 out.print(" + 0x" + Long.toHexString(diff)); |
100 } | 94 } |
101 out.println(); | 95 out.println(); |
102 } else { | 96 } else { |
103 if (isJava) { | 97 // look for one or more java frames |
104 // look for one or more java frames | 98 String[] names = null; |
105 String[] names = null; | 99 // check interpreter frame |
106 // check interpreter frame | 100 Interpreter interp = VM.getVM().getInterpreter(); |
107 Interpreter interp = VM.getVM().getInterpreter(); | 101 if (interp.contains(pc)) { |
108 if (interp.contains(pc)) { | 102 names = getJavaNames(th, f.localVariableBase()); |
109 names = getJavaNames(th, f.localVariableBase()); | 103 // print codelet name if we can't determine method |
110 // print codelet name if we can't determine method | 104 if (names == null || names.length == 0) { |
111 if (names == null || names.length == 0) { | 105 out.print("<interpreter> "); |
112 out.print("<interpreter> "); | 106 InterpreterCodelet ic = interp.getCodeletContaining(pc); |
113 InterpreterCodelet ic = interp.getCodeletContaining(pc); | 107 if (ic != null) { |
114 if (ic != null) { | 108 String desc = ic.getDescription(); |
115 String desc = ic.getDescription(); | 109 if (desc != null) out.print(desc); |
116 if (desc != null) out.print(desc); | 110 } |
117 } | 111 out.println(); |
118 out.println(); | 112 } |
119 } | 113 } else { |
120 } else { | 114 // look for known code blobs |
121 // look for known code blobs | 115 CodeCache c = VM.getVM().getCodeCache(); |
122 CodeCache c = VM.getVM().getCodeCache(); | 116 if (c.contains(pc)) { |
123 if (c.contains(pc)) { | 117 CodeBlob cb = c.findBlobUnsafe(pc); |
124 CodeBlob cb = c.findBlobUnsafe(pc); | 118 if (cb.isNMethod()) { |
125 if (cb.isNMethod()) { | 119 names = getJavaNames(th, f.localVariableBase()); |
126 names = getJavaNames(th, f.localVariableBase()); | 120 // just print compiled code, if can't determine method |
127 // just print compiled code, if can't determine method | 121 if (names == null || names.length == 0) { |
128 if (names == null || names.length == 0) { | 122 out.println("<Unknown compiled code>"); |
129 out.println("<Unknown compiled code>"); | 123 } |
130 } | 124 } else if (cb.isBufferBlob()) { |
131 } else if (cb.isBufferBlob()) { | 125 out.println("<StubRoutines>"); |
132 out.println("<StubRoutines>"); | 126 } else if (cb.isRuntimeStub()) { |
133 } else if (cb.isRuntimeStub()) { | 127 out.println("<RuntimeStub>"); |
134 out.println("<RuntimeStub>"); | 128 } else if (cb.isDeoptimizationStub()) { |
135 } else if (cb.isDeoptimizationStub()) { | 129 out.println("<DeoptimizationStub>"); |
136 out.println("<DeoptimizationStub>"); | 130 } else if (cb.isUncommonTrapStub()) { |
137 } else if (cb.isUncommonTrapStub()) { | 131 out.println("<UncommonTrap>"); |
138 out.println("<UncommonTrap>"); | 132 } else if (cb.isExceptionStub()) { |
139 } else if (cb.isExceptionStub()) { | 133 out.println("<ExceptionStub>"); |
140 out.println("<ExceptionStub>"); | 134 } else if (cb.isSafepointStub()) { |
141 } else if (cb.isSafepointStub()) { | 135 out.println("<SafepointStub>"); |
142 out.println("<SafepointStub>"); | 136 } else { |
143 } else { | 137 out.println("<Unknown code blob>"); |
144 out.println("<Unknown code blob>"); | 138 } |
145 } | 139 } else { |
146 } else { | 140 printUnknown(out); |
147 printUnknown(out); | 141 } |
148 } | 142 } |
149 } | 143 // print java frames, if any |
150 // print java frames, if any | 144 if (names != null && names.length != 0) { |
151 if (names != null && names.length != 0) { | 145 // print java frame(s) |
152 // print java frame(s) | 146 for (int i = 0; i < names.length; i++) { |
153 for (int i = 0; i < names.length; i++) { | 147 out.println(names[i]); |
154 out.println(names[i]); | 148 } |
155 } | 149 } |
156 } | |
157 } else { | |
158 printUnknown(out); | |
159 } | |
160 } | 150 } |
161 f = f.sender(th); | 151 f = f.sender(th); |
162 } | 152 } |
163 } catch (Exception exp) { | 153 } catch (Exception exp) { |
164 exp.printStackTrace(); | 154 exp.printStackTrace(); |
165 // continue, may be we can do a better job for other threads | 155 // continue, may be we can do a better job for other threads |
166 } | 156 } |
167 if (isJava && concurrentLocks) { | 157 if (concurrentLocks) { |
168 JavaThread jthread = (JavaThread) proxyToThread.get(th); | 158 JavaThread jthread = (JavaThread) proxyToThread.get(th); |
169 if (jthread != null) { | 159 if (jthread != null) { |
170 concLocksPrinter.print(jthread, out); | 160 concLocksPrinter.print(jthread, out); |
171 } | 161 } |
172 } | 162 } |
176 out.println("remote configuration is not yet implemented"); | 166 out.println("remote configuration is not yet implemented"); |
177 } else { | 167 } else { |
178 out.println("not yet implemented (debugger does not support CDebugger)!"); | 168 out.println("not yet implemented (debugger does not support CDebugger)!"); |
179 } | 169 } |
180 } | 170 } |
181 } | |
182 | |
183 protected boolean requiresVM() { | |
184 return false; | |
185 } | 171 } |
186 | 172 |
187 public static void main(String[] args) throws Exception { | 173 public static void main(String[] args) throws Exception { |
188 PStack t = new PStack(); | 174 PStack t = new PStack(); |
189 t.start(args); | 175 t.start(args); |