< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PStack.java

Print this page
rev 54717 : imported patch 8223306


 183           }
 184       }
 185    }
 186 
 187    public static void main(String[] args) throws Exception {
 188       PStack t = new PStack();
 189       t.execute(args);
 190    }
 191 
 192    // -- Internals only below this point
 193    private Map jframeCache; // Map<ThreadProxy, JavaVFrame[]>
 194    private Map proxyToThread; // Map<ThreadProxy, JavaThread>
 195    private PrintStream out;
 196    private boolean verbose;
 197    private boolean concurrentLocks;
 198 
 199    private void initJFrameCache() {
 200       // cache frames for subsequent reference
 201       jframeCache = new HashMap();
 202       proxyToThread = new HashMap();
 203       Threads threads = VM.getVM().getThreads();
 204       for (JavaThread cur = threads.first(); cur != null; cur = cur.next()) {
 205          List tmp = new ArrayList(10);
 206          try {
 207             for (JavaVFrame vf = cur.getLastJavaVFrameDbg(); vf != null; vf = vf.javaSender()) {
 208                tmp.add(vf);
 209             }
 210          } catch (Exception exp) {
 211             // may be we may get frames for other threads, continue
 212             // after printing stack trace.
 213             exp.printStackTrace();
 214          }
 215          JavaVFrame[] jvframes = new JavaVFrame[tmp.size()];
 216          System.arraycopy(tmp.toArray(), 0, jvframes, 0, jvframes.length);
 217          jframeCache.put(cur.getThreadProxy(), jvframes);
 218          proxyToThread.put(cur.getThreadProxy(), cur);
 219       }
 220    }
 221 
 222    private void printUnknown(PrintStream out) {
 223       out.println("\t????????");
 224    }
 225 
 226    private String[] getJavaNames(ThreadProxy th, Address fp) {
 227       if (fp == null) {
 228          return null;
 229       }
 230       JavaVFrame[] jvframes = (JavaVFrame[]) jframeCache.get(th);
 231       if (jvframes == null) return null; // not a java thread
 232       List names = new ArrayList(10);
 233       for (int fCount = 0; fCount < jvframes.length; fCount++) {
 234          JavaVFrame vf = jvframes[fCount];
 235          Frame f = vf.getFrame();
 236          if (fp.equals(f.getFP())) {
 237             StringBuffer sb = new StringBuffer();
 238             Method method = vf.getMethod();
 239             // a special char to identify java frames in output




 183           }
 184       }
 185    }
 186 
 187    public static void main(String[] args) throws Exception {
 188       PStack t = new PStack();
 189       t.execute(args);
 190    }
 191 
 192    // -- Internals only below this point
 193    private Map jframeCache; // Map<ThreadProxy, JavaVFrame[]>
 194    private Map proxyToThread; // Map<ThreadProxy, JavaThread>
 195    private PrintStream out;
 196    private boolean verbose;
 197    private boolean concurrentLocks;
 198 
 199    private void initJFrameCache() {
 200       // cache frames for subsequent reference
 201       jframeCache = new HashMap();
 202       proxyToThread = new HashMap();
 203       VM.getVM().getThreads().doJavaThreads((cur) -> {

 204          List tmp = new ArrayList(10);
 205          try {
 206             for (JavaVFrame vf = cur.getLastJavaVFrameDbg(); vf != null; vf = vf.javaSender()) {
 207                tmp.add(vf);
 208             }
 209          } catch (Exception exp) {
 210             // may be we may get frames for other threads, continue
 211             // after printing stack trace.
 212             exp.printStackTrace();
 213          }
 214          JavaVFrame[] jvframes = new JavaVFrame[tmp.size()];
 215          System.arraycopy(tmp.toArray(), 0, jvframes, 0, jvframes.length);
 216          jframeCache.put(cur.getThreadProxy(), jvframes);
 217          proxyToThread.put(cur.getThreadProxy(), cur);
 218       });
 219    }
 220 
 221    private void printUnknown(PrintStream out) {
 222       out.println("\t????????");
 223    }
 224 
 225    private String[] getJavaNames(ThreadProxy th, Address fp) {
 226       if (fp == null) {
 227          return null;
 228       }
 229       JavaVFrame[] jvframes = (JavaVFrame[]) jframeCache.get(th);
 230       if (jvframes == null) return null; // not a java thread
 231       List names = new ArrayList(10);
 232       for (int fCount = 0; fCount < jvframes.length; fCount++) {
 233          JavaVFrame vf = jvframes[fCount];
 234          Frame f = vf.getFrame();
 235          if (fp.equals(f.getFP())) {
 236             StringBuffer sb = new StringBuffer();
 237             Method method = vf.getMethod();
 238             // a special char to identify java frames in output


< prev index next >