< prev index next >

agent/src/share/classes/sun/jvm/hotspot/HSDB.java

Print this page




  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot;
  26 
  27 import java.io.*;
  28 import java.awt.*;
  29 import java.awt.event.*;
  30 import java.math.*;
  31 import javax.swing.*;
  32 import javax.swing.tree.*;
  33 import java.util.*;
  34 
  35 import sun.jvm.hotspot.code.*;
  36 import sun.jvm.hotspot.compiler.*;
  37 import sun.jvm.hotspot.debugger.*;
  38 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;

  39 import sun.jvm.hotspot.gc_interface.*;
  40 import sun.jvm.hotspot.interpreter.*;
  41 import sun.jvm.hotspot.memory.*;
  42 import sun.jvm.hotspot.oops.*;
  43 import sun.jvm.hotspot.runtime.*;
  44 import sun.jvm.hotspot.ui.*;
  45 import sun.jvm.hotspot.ui.tree.*;
  46 import sun.jvm.hotspot.ui.classbrowser.*;
  47 import sun.jvm.hotspot.utilities.*;
  48 
  49 /** The top-level HotSpot Debugger. FIXME: make this an embeddable
  50     component! (Among other things, figure out what to do with the
  51     menu bar...) */
  52 
  53 public class HSDB implements ObjectHistogramPanel.Listener, SAListener {
  54   public static void main(String[] args) {
  55     new HSDB(args).run();
  56   }
  57 
  58   //--------------------------------------------------------------------------------


 975                                "\n@bci " + bci + lineNumberAnno;
 976               } catch (Exception e) {
 977                 anno += "\n(ERROR while iterating vframes for frame " + curFrame + ")";
 978               }
 979 
 980               nextVFrame = curVFrame.javaSender();
 981               if (nextVFrame != null) {
 982                 nextFrame = nextVFrame.getFrame();
 983               }
 984             } while (nextVFrame != null && nextFrame.equals(curFrame));
 985 
 986             if (shouldSkipOopMaps) {
 987               anno = anno + "\nNOTE: null or empty OopMapSet found for this CodeBlob";
 988             }
 989 
 990             if (curFrame.getFP() != null) {
 991               annoPanel.addAnnotation(new Annotation(curFrame.getSP(),
 992                                                      curFrame.getFP(),
 993                                                      anno));
 994             } else {
 995               if (VM.getVM().getCPU().equals("x86") || VM.getVM().getCPU().equals("amd64")) {
 996                 // For C2, which has null frame pointers on x86/amd64
 997                 CodeBlob cb = VM.getVM().getCodeCache().findBlob(curFrame.getPC());
 998                 Address sp = curFrame.getSP();
 999                 if (Assert.ASSERTS_ENABLED) {
1000                   Assert.that(cb.getFrameSize() > 0, "CodeBlob must have non-zero frame size");
1001                 }
1002                 annoPanel.addAnnotation(new Annotation(sp,
1003                                                        sp.addOffsetTo(cb.getFrameSize()),
1004                                                        anno));
1005               } else {
1006                 Assert.that(VM.getVM().getCPU().equals("ia64"), "only ia64 should reach here");
1007               }



1008             }
1009 
1010             // Add interpreter frame annotations
1011             if (curFrame.isInterpretedFrame()) {
1012               annoPanel.addAnnotation(new Annotation(curFrame.addressOfInterpreterFrameExpressionStack(),
1013                                                      curFrame.addressOfInterpreterFrameTOS(),
1014                                                      "Interpreter expression stack"));
1015               Address monBegin = curFrame.interpreterFrameMonitorBegin().address();
1016               Address monEnd = curFrame.interpreterFrameMonitorEnd().address();
1017               if (!monBegin.equals(monEnd)) {
1018                   annoPanel.addAnnotation(new Annotation(monBegin, monEnd,
1019                                                          "BasicObjectLocks"));
1020               }
1021               if (interpreterFrameMethod != null) {
1022                 // The offset is just to get the right stack slots highlighted in the output
1023                 int offset = 1;
1024                 annoPanel.addAnnotation(new Annotation(curFrame.addressOfInterpreterFrameLocal(offset),
1025                                                        curFrame.addressOfInterpreterFrameLocal((int) interpreterFrameMethod.getMaxLocals() + offset),
1026                                                        "Interpreter locals area for frame with SP = " + curFrame.getSP()));
1027               }


1073                                 anno = "NewGen ";
1074                               } else if (i == 1) {
1075                                 anno = "OldGen ";
1076                               } else {
1077                                 anno = "Gen " + i + " ";
1078                               }
1079                               bad = false;
1080                               break;
1081                             }
1082                           }
1083 
1084                         } else if (collHeap instanceof ParallelScavengeHeap) {
1085                           ParallelScavengeHeap heap = (ParallelScavengeHeap) collHeap;
1086                           if (heap.youngGen().isIn(handle)) {
1087                             anno = "PSYoungGen ";
1088                             bad = false;
1089                           } else if (heap.oldGen().isIn(handle)) {
1090                             anno = "PSOldGen ";
1091                             bad = false;
1092                           }




1093                         } else {
1094                           // Optimistically assume the oop isn't bad
1095                           anno = "[Unknown generation] ";
1096                           bad = false;
1097                         }
1098 
1099                         if (!bad) {
1100                           try {
1101                             Oop oop = VM.getVM().getObjectHeap().newOop(handle);
1102                             if (oop instanceof Instance) {
1103                                 // Java-level objects always have workable names
1104                               anno = anno + oop.getKlass().getName().asString();
1105                             } else {
1106                               ByteArrayOutputStream bos = new ByteArrayOutputStream();
1107                               Oop.printOopValueOn(oop, new PrintStream(bos));
1108                               anno = anno + bos.toString();
1109                             }
1110                           }
1111                           catch (AddressException e) {
1112                             anno += "CORRUPT OOP";




  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot;
  26 
  27 import java.io.*;
  28 import java.awt.*;
  29 import java.awt.event.*;
  30 import java.math.*;
  31 import javax.swing.*;
  32 import javax.swing.tree.*;
  33 import java.util.*;
  34 
  35 import sun.jvm.hotspot.code.*;
  36 import sun.jvm.hotspot.compiler.*;
  37 import sun.jvm.hotspot.debugger.*;
  38 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
  39 import sun.jvm.hotspot.gc_implementation.shenandoah.*;
  40 import sun.jvm.hotspot.gc_interface.*;
  41 import sun.jvm.hotspot.interpreter.*;
  42 import sun.jvm.hotspot.memory.*;
  43 import sun.jvm.hotspot.oops.*;
  44 import sun.jvm.hotspot.runtime.*;
  45 import sun.jvm.hotspot.ui.*;
  46 import sun.jvm.hotspot.ui.tree.*;
  47 import sun.jvm.hotspot.ui.classbrowser.*;
  48 import sun.jvm.hotspot.utilities.*;
  49 
  50 /** The top-level HotSpot Debugger. FIXME: make this an embeddable
  51     component! (Among other things, figure out what to do with the
  52     menu bar...) */
  53 
  54 public class HSDB implements ObjectHistogramPanel.Listener, SAListener {
  55   public static void main(String[] args) {
  56     new HSDB(args).run();
  57   }
  58 
  59   //--------------------------------------------------------------------------------


 976                                "\n@bci " + bci + lineNumberAnno;
 977               } catch (Exception e) {
 978                 anno += "\n(ERROR while iterating vframes for frame " + curFrame + ")";
 979               }
 980 
 981               nextVFrame = curVFrame.javaSender();
 982               if (nextVFrame != null) {
 983                 nextFrame = nextVFrame.getFrame();
 984               }
 985             } while (nextVFrame != null && nextFrame.equals(curFrame));
 986 
 987             if (shouldSkipOopMaps) {
 988               anno = anno + "\nNOTE: null or empty OopMapSet found for this CodeBlob";
 989             }
 990 
 991             if (curFrame.getFP() != null) {
 992               annoPanel.addAnnotation(new Annotation(curFrame.getSP(),
 993                                                      curFrame.getFP(),
 994                                                      anno));
 995             } else {
 996               // For C2, which has null frame pointers on x86/amd64/aarch64
 997               CodeBlob cb = VM.getVM().getCodeCache().findBlob(curFrame.getPC());
 998               Address sp = curFrame.getSP();
 999               if (Assert.ASSERTS_ENABLED) {
1000                 Assert.that(cb.getFrameSize() > 0, "CodeBlob must have non-zero frame size");







1001               }
1002               annoPanel.addAnnotation(new Annotation(sp,
1003                                                      sp.addOffsetTo(cb.getFrameSize()),
1004                                                      anno));
1005             }
1006 
1007             // Add interpreter frame annotations
1008             if (curFrame.isInterpretedFrame()) {
1009               annoPanel.addAnnotation(new Annotation(curFrame.addressOfInterpreterFrameExpressionStack(),
1010                                                      curFrame.addressOfInterpreterFrameTOS(),
1011                                                      "Interpreter expression stack"));
1012               Address monBegin = curFrame.interpreterFrameMonitorBegin().address();
1013               Address monEnd = curFrame.interpreterFrameMonitorEnd().address();
1014               if (!monBegin.equals(monEnd)) {
1015                   annoPanel.addAnnotation(new Annotation(monBegin, monEnd,
1016                                                          "BasicObjectLocks"));
1017               }
1018               if (interpreterFrameMethod != null) {
1019                 // The offset is just to get the right stack slots highlighted in the output
1020                 int offset = 1;
1021                 annoPanel.addAnnotation(new Annotation(curFrame.addressOfInterpreterFrameLocal(offset),
1022                                                        curFrame.addressOfInterpreterFrameLocal((int) interpreterFrameMethod.getMaxLocals() + offset),
1023                                                        "Interpreter locals area for frame with SP = " + curFrame.getSP()));
1024               }


1070                                 anno = "NewGen ";
1071                               } else if (i == 1) {
1072                                 anno = "OldGen ";
1073                               } else {
1074                                 anno = "Gen " + i + " ";
1075                               }
1076                               bad = false;
1077                               break;
1078                             }
1079                           }
1080 
1081                         } else if (collHeap instanceof ParallelScavengeHeap) {
1082                           ParallelScavengeHeap heap = (ParallelScavengeHeap) collHeap;
1083                           if (heap.youngGen().isIn(handle)) {
1084                             anno = "PSYoungGen ";
1085                             bad = false;
1086                           } else if (heap.oldGen().isIn(handle)) {
1087                             anno = "PSOldGen ";
1088                             bad = false;
1089                           }
1090                         } else if (collHeap instanceof ShenandoahHeap) {
1091                           ShenandoahHeap heap = (ShenandoahHeap) collHeap;
1092                           anno = "ShenandoahHeap ";
1093                           bad = false;
1094                         } else {
1095                           // Optimistically assume the oop isn't bad
1096                           anno = "[Unknown generation] ";
1097                           bad = false;
1098                         }
1099 
1100                         if (!bad) {
1101                           try {
1102                             Oop oop = VM.getVM().getObjectHeap().newOop(handle);
1103                             if (oop instanceof Instance) {
1104                                 // Java-level objects always have workable names
1105                               anno = anno + oop.getKlass().getName().asString();
1106                             } else {
1107                               ByteArrayOutputStream bos = new ByteArrayOutputStream();
1108                               Oop.printOopValueOn(oop, new PrintStream(bos));
1109                               anno = anno + bos.toString();
1110                             }
1111                           }
1112                           catch (AddressException e) {
1113                             anno += "CORRUPT OOP";


< prev index next >