< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java

Print this page




  31 import java.io.FileOutputStream;
  32 import java.io.IOException;
  33 import java.io.InputStreamReader;
  34 import java.io.PrintStream;
  35 import java.util.ArrayList;
  36 import java.util.Arrays;
  37 import java.util.Comparator;
  38 import java.util.HashMap;
  39 import java.util.HashSet;
  40 import java.util.Iterator;
  41 import java.util.Stack;
  42 import java.util.regex.Matcher;
  43 import java.util.regex.Pattern;
  44 
  45 import sun.jvm.hotspot.ci.ciEnv;
  46 import sun.jvm.hotspot.code.CodeBlob;
  47 import sun.jvm.hotspot.code.CodeCacheVisitor;
  48 import sun.jvm.hotspot.code.NMethod;
  49 import sun.jvm.hotspot.debugger.Address;
  50 import sun.jvm.hotspot.debugger.OopHandle;

  51 import sun.jvm.hotspot.memory.SymbolTable;
  52 import sun.jvm.hotspot.memory.SystemDictionary;
  53 import sun.jvm.hotspot.memory.Universe;
  54 import sun.jvm.hotspot.oops.DefaultHeapVisitor;
  55 import sun.jvm.hotspot.oops.HeapVisitor;
  56 import sun.jvm.hotspot.oops.InstanceKlass;
  57 import sun.jvm.hotspot.oops.Klass;
  58 import sun.jvm.hotspot.oops.Metadata;
  59 import sun.jvm.hotspot.oops.Method;
  60 import sun.jvm.hotspot.oops.MethodData;
  61 import sun.jvm.hotspot.oops.Oop;
  62 import sun.jvm.hotspot.oops.RawHeapVisitor;
  63 import sun.jvm.hotspot.oops.Symbol;
  64 import sun.jvm.hotspot.oops.UnknownOopException;
  65 import sun.jvm.hotspot.opto.Compile;
  66 import sun.jvm.hotspot.opto.InlineTree;
  67 import sun.jvm.hotspot.runtime.CompiledVFrame;
  68 import sun.jvm.hotspot.runtime.CompilerThread;
  69 import sun.jvm.hotspot.runtime.JavaThread;
  70 import sun.jvm.hotspot.runtime.JavaVFrame;


 836                             for (int i = 0; i < ptrs.size(); i++) {
 837                                 LivenessPathElement e = (LivenessPathElement)ptrs.get(i);
 838                                 ByteArrayOutputStream bos = new ByteArrayOutputStream();
 839                                 Oop.printOopValueOn(e.getObj(), new PrintStream(bos));
 840                                 out.println(bos.toString());
 841                                 oop = e.getObj();
 842                             }
 843                         }
 844                     }
 845                 }
 846             }
 847         },
 848         new Command("printmdo", "printmdo [ -a | expression ]", false) {
 849             // Print every MDO in the heap or the one referenced by expression.
 850             public void doit(Tokens t) {
 851                 if (t.countTokens() != 1) {
 852                     usage();
 853                 } else {
 854                     String s = t.nextToken();
 855                     if (s.equals("-a")) {
 856                         SystemDictionary sysDict = VM.getVM().getSystemDictionary();
 857                         sysDict.allClassesDo(new SystemDictionary.ClassVisitor() {
 858                                 public void visit(Klass k) {
 859                                     if (k instanceof InstanceKlass) {
 860                                         MethodArray methods = ((InstanceKlass)k).getMethods();
 861                                         for (int i = 0; i < methods.length(); i++) {
 862                                             Method m = methods.at(i);
 863                                             MethodData mdo = m.getMethodData();
 864                                             if (mdo != null) {
 865                                                 out.println("MethodData " + mdo.getAddress() + " for " +
 866                                                     "method " + m.getMethodHolder().getName().asString() + "." +
 867                                                     m.getName().asString() +
 868                                                             m.getSignature().asString() + "@" + m.getAddress());
 869                                                 mdo.printDataOn(out);
 870                                     }
 871                                 }
 872                                     }
 873                                 }
 874                             }
 875                             );
 876                     } else {
 877                         Address a = VM.getVM().getDebugger().parseAddress(s);
 878                         MethodData mdo = (MethodData) Metadata.instantiateWrapperFor(a);
 879                         mdo.printDataOn(out);
 880                     }
 881                 }
 882             }
 883         },
 884         new Command("printall", "printall", false) {
 885             // Print every MDO in the heap or the one referenced by expression.
 886             public void doit(Tokens t) {
 887                 if (t.countTokens() != 0) {
 888                     usage();
 889                 } else {
 890                     SystemDictionary sysDict = VM.getVM().getSystemDictionary();
 891                     sysDict.allClassesDo(new SystemDictionary.ClassVisitor() {
 892                             public void visit(Klass k) {
 893                                 if (k instanceof InstanceKlass && ((InstanceKlass)k).getConstants().getCache() != null) {
 894                                     MethodArray methods = ((InstanceKlass)k).getMethods();
 895                                     for (int i = 0; i < methods.length(); i++) {
 896                                         Method m = methods.at(i);
 897                                         HTMLGenerator gen = new HTMLGenerator(false);
 898                                         out.println(gen.genHTML(m));
 899                                     }
 900                                 }
 901                             }
 902                         }
 903                         );
 904                 }
 905             }
 906         },
 907         new Command("dumpideal", "dumpideal { -a | id }", false) {
 908             // Do a full dump of the nodes reachabile from root in each compiler thread.
 909             public void doit(Tokens t) {
 910                 if (t.countTokens() != 1) {
 911                     usage();




  31 import java.io.FileOutputStream;
  32 import java.io.IOException;
  33 import java.io.InputStreamReader;
  34 import java.io.PrintStream;
  35 import java.util.ArrayList;
  36 import java.util.Arrays;
  37 import java.util.Comparator;
  38 import java.util.HashMap;
  39 import java.util.HashSet;
  40 import java.util.Iterator;
  41 import java.util.Stack;
  42 import java.util.regex.Matcher;
  43 import java.util.regex.Pattern;
  44 
  45 import sun.jvm.hotspot.ci.ciEnv;
  46 import sun.jvm.hotspot.code.CodeBlob;
  47 import sun.jvm.hotspot.code.CodeCacheVisitor;
  48 import sun.jvm.hotspot.code.NMethod;
  49 import sun.jvm.hotspot.debugger.Address;
  50 import sun.jvm.hotspot.debugger.OopHandle;
  51 import sun.jvm.hotspot.classfile.ClassLoaderDataGraph;
  52 import sun.jvm.hotspot.memory.SymbolTable;
  53 import sun.jvm.hotspot.memory.SystemDictionary;
  54 import sun.jvm.hotspot.memory.Universe;
  55 import sun.jvm.hotspot.oops.DefaultHeapVisitor;
  56 import sun.jvm.hotspot.oops.HeapVisitor;
  57 import sun.jvm.hotspot.oops.InstanceKlass;
  58 import sun.jvm.hotspot.oops.Klass;
  59 import sun.jvm.hotspot.oops.Metadata;
  60 import sun.jvm.hotspot.oops.Method;
  61 import sun.jvm.hotspot.oops.MethodData;
  62 import sun.jvm.hotspot.oops.Oop;
  63 import sun.jvm.hotspot.oops.RawHeapVisitor;
  64 import sun.jvm.hotspot.oops.Symbol;
  65 import sun.jvm.hotspot.oops.UnknownOopException;
  66 import sun.jvm.hotspot.opto.Compile;
  67 import sun.jvm.hotspot.opto.InlineTree;
  68 import sun.jvm.hotspot.runtime.CompiledVFrame;
  69 import sun.jvm.hotspot.runtime.CompilerThread;
  70 import sun.jvm.hotspot.runtime.JavaThread;
  71 import sun.jvm.hotspot.runtime.JavaVFrame;


 837                             for (int i = 0; i < ptrs.size(); i++) {
 838                                 LivenessPathElement e = (LivenessPathElement)ptrs.get(i);
 839                                 ByteArrayOutputStream bos = new ByteArrayOutputStream();
 840                                 Oop.printOopValueOn(e.getObj(), new PrintStream(bos));
 841                                 out.println(bos.toString());
 842                                 oop = e.getObj();
 843                             }
 844                         }
 845                     }
 846                 }
 847             }
 848         },
 849         new Command("printmdo", "printmdo [ -a | expression ]", false) {
 850             // Print every MDO in the heap or the one referenced by expression.
 851             public void doit(Tokens t) {
 852                 if (t.countTokens() != 1) {
 853                     usage();
 854                 } else {
 855                     String s = t.nextToken();
 856                     if (s.equals("-a")) {
 857                         ClassLoaderDataGraph cldg = VM.getVM().getClassLoaderDataGraph();
 858                         cldg.classesDo(new ClassLoaderDataGraph.ClassVisitor() {
 859                                 public void visit(Klass k) {
 860                                     if (k instanceof InstanceKlass) {
 861                                         MethodArray methods = ((InstanceKlass)k).getMethods();
 862                                         for (int i = 0; i < methods.length(); i++) {
 863                                             Method m = methods.at(i);
 864                                             MethodData mdo = m.getMethodData();
 865                                             if (mdo != null) {
 866                                                 out.println("MethodData " + mdo.getAddress() + " for " +
 867                                                     "method " + m.getMethodHolder().getName().asString() + "." +
 868                                                     m.getName().asString() +
 869                                                             m.getSignature().asString() + "@" + m.getAddress());
 870                                                 mdo.printDataOn(out);
 871                                     }
 872                                 }
 873                                     }
 874                                 }
 875                             }
 876                             );
 877                     } else {
 878                         Address a = VM.getVM().getDebugger().parseAddress(s);
 879                         MethodData mdo = (MethodData) Metadata.instantiateWrapperFor(a);
 880                         mdo.printDataOn(out);
 881                     }
 882                 }
 883             }
 884         },
 885         new Command("printall", "printall", false) {
 886             // Print every MDO in the heap or the one referenced by expression.
 887             public void doit(Tokens t) {
 888                 if (t.countTokens() != 0) {
 889                     usage();
 890                 } else {
 891                     ClassLoaderDataGraph cldg = VM.getVM().getClassLoaderDataGraph();
 892                     cldg.classesDo(new ClassLoaderDataGraph.ClassVisitor() {
 893                             public void visit(Klass k) {
 894                                 if (k instanceof InstanceKlass && ((InstanceKlass)k).getConstants().getCache() != null) {
 895                                     MethodArray methods = ((InstanceKlass)k).getMethods();
 896                                     for (int i = 0; i < methods.length(); i++) {
 897                                         Method m = methods.at(i);
 898                                         HTMLGenerator gen = new HTMLGenerator(false);
 899                                         out.println(gen.genHTML(m));
 900                                     }
 901                                 }
 902                             }
 903                         }
 904                         );
 905                 }
 906             }
 907         },
 908         new Command("dumpideal", "dumpideal { -a | id }", false) {
 909             // Do a full dump of the nodes reachabile from root in each compiler thread.
 910             public void doit(Tokens t) {
 911                 if (t.countTokens() != 1) {
 912                     usage();


< prev index next >