sa-jdi

TableLen / 4 * 8;
      }
      boolean hasLineNumberTable = m.hasLineNumberTable();
      LineNumberTableElement[] lineNumberTable = null;
      int lineNumberAttrLen = 0;
      if (hasLineNumberTable)
      {
        lineNumberTable = m.getLineNumberTable();
        
        lineNumberAttrLen = 2 + lineNumberTable.length * 4;
        
        codeSize += 6 + lineNumberAttrLen;
        
        codeAttrCount = (short)(codeAttrCount + 1);
      }
      boolean hasLocalVariableTable = m.hasLocalVariableTable();
      LocalVariableTableElement[] localVariableTable = null;
      int localVarAttrLen = 0;
      if (hasLocalVariableTable)
      {
        localVariableTable = m.getLocalVariableTable();
        
        localVarAttrLen = 2 + localVariableTable.length * 10;
        
        codeSize += 6 + localVarAttrLen;
        
        codeAttrCount = (short)(codeAttrCount + 1);
      }
      rewriteByteCode(m, code);
      
      writeIndex(_codeIndex);
      
      dos.writeInt(codeSize);
      
      dos.writeShort((short)(int)m.getMaxStack());
      
      dos.writeShort((short)(int)m.getMaxLocals());
      
      dos.writeInt(code.length);
      
      dos.write(code);
      
      dos.writeShort((short)(exceptionTableLen / 4));
      if (exceptionTableLen != 0) {
        for (int e = 0; e < exceptionTableLen; e += 4)
        {
          dos.writeShort((short)exceptionTable.getIntAt(e));
          dos.writeShort((short)exceptionTable.getIntAt(e + 1));
          dos.writeShort((short)exceptionTable.getIntAt(e + 2));
          dos.writeShort((short)exceptionTable.getIntAt(e + 3));
        }
      }
      dos.writeShort(codeAttrCount);
      if (hasLineNumberTable)
      {
        writeIndex(_lineNumberTableIndex);
        dos.writeInt(lineNumberAttrLen);
        dos.writeShort((short)lineNumberTable.length);
        for (int l = 0; l < lineNumberTable.length; l++)
        {
          dos.writeShort((short)lineNumberTable[l].getStartBCI());
          dos.writeShort((short)lineNumberTable[l].getLineNumber());
        }
      }
      if (hasLocalVariableTable)
      {
        writeIndex(_localVariableTableIndex);
        dos.writeInt(localVarAttrLen);
        dos.writeShort((short)localVariableTable.length);
        for (int l = 0; l < localVariableTable.length; l++)
        {
          dos.writeShort((short)localVariableTable[l].getStartBCI());
          dos.writeShort((short)localVariableTable[l].getLength());
          dos.writeShort((short)localVariableTable[l].getNameCPIndex());
          dos.writeShort((short)localVariableTable[l].getDescriptorCPIndex());
          dos.writeShort((short)localVariableTable[l].getSlot());
        }
      }
    }
    if (hasCheckedExceptions)
    {
      CheckedExceptionElement[] exceptions = m.getCheckedExceptions();
      writeIndex(_exceptionsIndex);
      
      int attrSize = 2 + exceptions.length * 2;
      
      dos.writeInt(attrSize);
      dos.writeShort(exceptions.length);
      for (int e = 0; e < exceptions.length; e++)
      {
        short cpIndex = (short)exceptions[e].getClassCPIndex();
        dos.writeShort(cpIndex);
      }
    }
    if (isGeneric) {
      writeGenericSignature(m.getGenericSignature().asString());
    }
  }
  
  protected void rewriteByteCode(Method m, byte[] code)
  {
    ByteCodeRewriter r = new ByteCodeRewriter(m, cpool, code);
    r.rewrite();
  }
  
  protected void writeGenericSignature(String signature)
    throws IOException
  {
    writeIndex(_signatureIndex);
    
    dos.writeInt(2);
    Short index = (Short)utf8ToIndex.get(signature);
    dos.writeShort(index.shortValue());
  }
  
  protected void writeClassAttributes()
    throws IOException
  {
    long flags = klass.getAccessFlags();
    boolean hasSyn = hasSyntheticAttribute((short)(int)flags);
    
    short classAttributeCount = 0;
    if (hasSyn) {
      classAttributeCount = (short)(classAttributeCount + 1);
    }
    Symbol sourceFileName = klass.getSourceFileName();
    if (sourceFileName != null) {
      classAttributeCount = (short)(classAttributeCount + 1);
    }
    Symbol genericSignature = klass.getGenericSignature();
    if (genericSignature != null) {
      classAttributeCount = (short)(classAttributeCount + 1);
    }
    TypeArray innerClasses = klass.getInnerClasses();
    int numInnerClasses = (int)(innerClasses.getLength() / 4L);
    if (numInnerClasses != 0) {
      classAttributeCount = (short)(classAttributeCount + 1);
    }
    dos.writeShort(classAttributeCount);
    if (hasSyn) {
      writeSynthetic();
    }
    if (sourceFileName != null)
    {
      writeIndex(_sourceFileIndex);
      
      dos.writeInt(2);
      Short index = (Short)utf8ToIndex.get(sourceFileName.asString());
      dos.writeShort(index.shortValue());
    }
    if (genericSignature != null) {
      writeGenericSignature(genericSignature.asString());
    }
    if (numInnerClasses != 0)
    {
      writeIndex(_innerClassesIndex);
      int innerAttrLen = 2 + numInnerClasses * 8;
      
      dos.writeInt(innerAttrLen);
      
      dos.writeShort(numInnerClasses);
      for (int index = 0; index < numInnerClasses * 4; index++) {
        dos.writeShort(innerClasses.getShortAt(index));
      }
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.jcore.ClassWriter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools.jcore;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.Symbol;

public class NameFilter
  implements ClassFilter
{
  public Pattern includePattern;
  
  public NameFilter()
  {
    this(System.getProperty("sun.jvm.hotspot.tools.jcore.NameFilter.pattern"));
  }
  
  public NameFilter(String pattern)
  {
    if (pattern == null) {
      pattern = "*";
    }
    includePattern = Pattern.compile(pattern);
  }
  
  public boolean canInclude(InstanceKlass kls)
  {
    String klassName = kls.getName().asString().replace('/', '.');
    Matcher m = includePattern.matcher(klassName);
    return m.matches();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.jcore.NameFilter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools.jcore;

import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.Symbol;

public class PackageNameFilter
  implements ClassFilter
{
  public Object[] pkgList;
  
  public PackageNameFilter()
  {
    this(System.getProperty("sun.jvm.hotspot.tools.jcore.PackageNameFilter.pkgList"));
  }
  
  public PackageNameFilter(String pattern)
  {
    try
    {
      StringTokenizer st = new StringTokenizer(pattern, ",");
      List l = new LinkedList();
      while (st.hasMoreTokens()) {
        l.add(st.nextToken());
      }
      pkgList = l.toArray();
    }
    catch (Exception exp)
    {
      exp.printStackTrace();
    }
  }
  
  public boolean canInclude(InstanceKlass kls)
  {
    String klassName = kls.getName().asString().replace('/', '.');
    int len = pkgList.length;
    if (len == 0) {
      return true;
    }
    for (int i = 0; i < len; i++) {
      if (klassName.startsWith((String)pkgList[i])) {
        return true;
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.jcore.PackageNameFilter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.io.PrintStream;

final class JInfo$1
  extends Tool
{
  private final JInfo this$0;
  
  JInfo$1(JInfo paramJInfo) {}
  
  public void run()
  {
    Tool sysProps = new SysPropsDumper();
    sysProps.setAgent(getAgent());
    System.out.println("Java System Properties:");
    System.out.println();
    sysProps.run();
    System.out.println();
    System.out.println("VM Flags:");
    JInfo.access$000(this$0);
    System.out.println();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.JInfo.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.io.PrintStream;
import sun.jvm.hotspot.runtime.Arguments;

public class JInfo
  extends Tool
{
  public static final int MODE_FLAGS = 0;
  public static final int MODE_SYSPROPS = 1;
  public static final int MODE_BOTH = 2;
  private int mode;
  
  public JInfo(int m)
  {
    mode = m;
  }
  
  protected boolean needsJavaPrefix()
  {
    return false;
  }
  
  public String getName()
  {
    return "jinfo";
  }
  
  protected void printFlagsUsage()
  {
    System.out.println("    -flags\tto print VM flags");
    System.out.println("    -sysprops\tto print Java System properties");
    System.out.println("    <no option>\tto print both of the above");
    super.printFlagsUsage();
  }
  
  public void run()
  {
    Tool tool = null;
    switch (mode)
    {
    case 0: 
      printVMFlags();
      return;
    case 1: 
      tool = new SysPropsDumper();
      break;
    case 2: 
      tool = new Tool()
      {
        public void run()
        {
          Tool sysProps = new SysPropsDumper();
          sysProps.setAgent(getAgent());
          System.out.println("Java System Properties:");
          System.out.println();
          sysProps.run();
          System.out.println();
          System.out.println("VM Flags:");
          JInfo.this.printVMFlags();
          System.out.println();
        }
      };
      break;
    default: 
      usage();
    }
    tool.setAgent(getAgent());
    tool.run();
  }
  
  public static void main(String[] args)
  {
    int mode = -1;
    switch (args.length)
    {
    case 1: 
      if (args[0].charAt(0) == '-') {
        new JInfo(mode).usage();
      } else {
        mode = 2;
      }
      break;
    case 2: 
    case 3: 
      String modeFlag = args[0];
      if (modeFlag.equals("-flags")) {
        mode = 0;
      } else if (modeFlag.equals("-sysprops")) {
        mode = 1;
      } else if (modeFlag.charAt(0) == '-') {
        new JInfo(mode).usage();
      } else {
        mode = 2;
      }
      if (mode != 2)
      {
        String[] newArgs = new String[args.length - 1];
        for (int i = 0; i < newArgs.length; i++) {
          newArgs[i] = args[(i + 1)];
        }
        args = newArgs;
      }
      break;
    default: 
      new JInfo(mode).usage();
    }
    JInfo jinfo = new JInfo(mode);
    jinfo.start(args);
    jinfo.stop();
  }
  
  private void printVMFlags()
  {
    String str = Arguments.getJVMFlags();
    if (str != null) {
      System.out.println(str);
    }
    str = Arguments.getJVMArgs();
    if (str != null) {
      System.out.println(str);
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.JInfo
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.io.IOException;
import java.io.PrintStream;
import sun.jvm.hotspot.utilities.HeapGXLWriter;
import sun.jvm.hotspot.utilities.HeapGraphWriter;
import sun.jvm.hotspot.utilities.HeapHprofBinWriter;

public class JMap
  extends Tool
{
  public static final int MODE_HEAP_SUMMARY = 0;
  public static final int MODE_HISTOGRAM = 1;
  public static final int MODE_PERMSTAT = 2;
  public static final int MODE_PMAP = 3;
  public static final int MODE_HEAP_GRAPH_HPROF_BIN = 4;
  public static final int MODE_HEAP_GRAPH_GXL = 5;
  public static final int MODE_FINALIZERINFO = 6;
  private int mode;
  
  public JMap(int m)
  {
    mode = m;
  }
  
  public JMap()
  {
    this(3);
  }
  
  protected boolean needsJavaPrefix()
  {
    return false;
  }
  
  public String getName()
  {
    return "jmap";
  }
  
  protected String getCommandFlags()
  {
    return "-heap|-heap:format=b|-histo|-permstat|-finalizerinfo";
  }
  
  protected void printFlagsUsage()
  {
    System.out.println("    <no option>\tto print same info as Solaris pmap");
    System.out.println("    -heap\tto print java heap summary");
    System.out.println("    -heap:format=b\tto dump java heap in hprof binary format");
    System.out.println("    -histo\tto print histogram of java object heap");
    System.out.println("    -permstat\tto print permanent generation statistics");
    System.out.println("    -finalizerinfo\tto print information on objects awaiting finalization");
    super.printFlagsUsage();
  }
  
  public void run()
  {
    Tool tool = null;
    switch (mode)
    {
    case 0: 
      tool = new HeapSummary();
      break;
    case 1: 
      tool = new ObjectHistogram();
      break;
    case 2: 
      tool = new PermStat();
      break;
    case 3: 
      tool = new PMap();
      break;
    case 4: 
      writeHeapHprofBin();
      return;
    case 5: 
      writeHeapGXL();
      return;
    case 6: 
      tool = new FinalizerInfo();
      break;
    default: 
      usage();
    }
    tool.setAgent(getAgent());
    tool.setDebugeeType(getDebugeeType());
    tool.run();
  }
  
  public static void main(String[] args)
  {
    int mode = 3;
    if (args.length > 1)
    {
      String modeFlag = args[0];
      boolean copyArgs = true;
      if (modeFlag.equals("-heap"))
      {
        mode = 0;
      }
      else if (modeFlag.equals("-histo"))
      {
        mode = 1;
      }
      else if (modeFlag.equals("-permstat"))
      {
        mode = 2;
      }
      else if (modeFlag.equals("-finalizerinfo"))
      {
        mode = 6;
      }
      else
      {
        int index = modeFlag.indexOf("-heap:format=");
        if (index != -1)
        {
          String format = modeFlag.substring(1 + modeFlag.indexOf('='));
          if (format.equals("b"))
          {
            mode = 4;
          }
          else if (format.equals("x"))
          {
            mode = 5;
          }
          else
          {
            System.err.println("unknown heap format:" + format);
            return;
          }
        }
        else
        {
          copyArgs = false;
        }
      }
      if (copyArgs)
      {
        String[] newArgs = new String[args.length - 1];
        for (int i = 0; i < newArgs.length; i++) {
          newArgs[i] = args[(i + 1)];
        }
        args = newArgs;
      }
    }
    JMap jmap = new JMap(mode);
    jmap.start(args);
    jmap.stop();
  }
  
  public boolean writeHeapHprofBin(String fileName)
  {
    try
    {
      HeapGraphWriter hgw = new HeapHprofBinWriter();
      hgw.write(fileName);
      System.out.println("heap written to " + fileName);
      return true;
    }
    catch (IOException exp)
    {
      System.err.println(exp.getMessage());
    }
    return false;
  }
  
  public boolean writeHeapHprofBin()
  {
    return writeHeapHprofBin("heap.bin");
  }
  
  private boolean writeHeapGXL(String fileName)
  {
    try
    {
      HeapGraphWriter hgw = new HeapGXLWriter();
      hgw.write(fileName);
      System.out.println("heap written to " + fileName);
      return true;
    }
    catch (IOException exp)
    {
      System.err.println(exp.getMessage());
    }
    return false;
  }
  
  public boolean writeHeapGXL()
  {
    return writeHeapGXL("heap.xml");
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.JMap
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.io.PrintStream;
import sun.jvm.hotspot.runtime.PerfDataEntry;
import sun.jvm.hotspot.runtime.PerfMemory.PerfDataEntryVisitor;

final class JSnap$1
  implements PerfMemory.PerfDataEntryVisitor
{
  private final JSnap this$0;
  
  JSnap$1(JSnap paramJSnap, PrintStream paramPrintStream) {}
  
  public boolean visit(PerfDataEntry pde)
  {
    if (pde.supported())
    {
      val$out.print(pde.name());
      val$out.print('=');
      val$out.println(pde.valueAsString());
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.JSnap.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.io.PrintStream;
import sun.jvm.hotspot.runtime.PerfDataEntry;
import sun.jvm.hotspot.runtime.PerfDataPrologue;
import sun.jvm.hotspot.runtime.PerfMemory;
import sun.jvm.hotspot.runtime.PerfMemory.PerfDataEntryVisitor;

public class JSnap
  extends Tool
{
  public void run()
  {
    final PrintStream out = System.out;
    if (PerfMemory.initialized())
    {
      PerfDataPrologue prologue = PerfMemory.prologue();
      if (prologue.accessible()) {
        PerfMemory.iterate(new PerfMemory.PerfDataEntryVisitor()
        {
          public boolean visit(PerfDataEntry pde)
          {
            if (pde.supported())
            {
              out.print(pde.name());
              out.print('=');
              out.println(pde.valueAsString());
            }
            return true;
          }
        });
      } else {
        out.println("PerfMemory is not accessible");
      }
    }
    else
    {
      out.println("PerfMemory is not initialized");
    }
  }
  
  public static void main(String[] args)
  {
    JSnap js = new JSnap();
    js.start(args);
    js.stop();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.JSnap
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.io.PrintStream;

public class JStack
  extends Tool
{
  private boolean mixedMode;
  private boolean concurrentLocks;
  
  public JStack(boolean mixedMode, boolean concurrentLocks)
  {
    this.mixedMode = mixedMode;
    this.concurrentLocks = concurrentLocks;
  }
  
  public JStack()
  {
    this(true, true);
  }
  
  protected boolean needsJavaPrefix()
  {
    return false;
  }
  
  public String getName()
  {
    return "jstack";
  }
  
  protected void printFlagsUsage()
  {
    System.out.println("    -l\tto print java.util.concurrent locks");
    System.out.println("    -m\tto print both java and native frames (mixed mode)");
    super.printFlagsUsage();
  }
  
  public void run()
  {
    Tool tool = null;
    if (mixedMode) {
      tool = new PStack(false, concurrentLocks);
    } else {
      tool = new StackTrace(false, concurrentLocks);
    }
    tool.setAgent(getAgent());
    tool.setDebugeeType(getDebugeeType());
    tool.run();
  }
  
  public static void main(String[] args)
  {
    boolean mixedMode = false;
    boolean concurrentLocks = false;
    int used = 0;
    for (int i = 0; i < args.length; i++) {
      if (args[i].equals("-m"))
      {
        mixedMode = true;
        used++;
      }
      else if (args[i].equals("-l"))
      {
        concurrentLocks = true;
        used++;
      }
    }
    if (used != 0)
    {
      String[] newArgs = new String[args.length - used];
      for (int i = 0; i < newArgs.length; i++) {
        newArgs[i] = args[(i + used)];
      }
      args = newArgs;
    }
    JStack jstack = new JStack(mixedMode, concurrentLocks);
    jstack.start(args);
    jstack.stop();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.JStack
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.io.PrintStream;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.runtime.VM;

public class ObjectHistogram
  extends Tool
{
  public void run()
  {
    run(System.out, System.err);
  }
  
  public void run(PrintStream out, PrintStream err)
  {
    ObjectHeap heap = VM.getVM().getObjectHeap();
    sun.jvm.hotspot.oops.ObjectHistogram histogram = new sun.jvm.hotspot.oops.ObjectHistogram();
    
    err.println("Iterating over heap. This may take a while...");
    long startTime = System.currentTimeMillis();
    heap.iterate(histogram);
    long endTime = System.currentTimeMillis();
    histogram.printOn(out);
    float secs = (float)(endTime - startTime) / 1000.0F;
    err.println("Heap traversal took " + secs + " seconds.");
  }
  
  public static void main(String[] args)
  {
    ObjectHistogram oh = new ObjectHistogram();
    oh.start(args);
    oh.stop();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.ObjectHistogram
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.util.Map;
import sun.jvm.hotspot.oops.DefaultHeapVisitor;
import sun.jvm.hotspot.oops.Oop;

final class PermStat$1
  extends DefaultHeapVisitor
{
  private final PermStat this$0;
  
  PermStat$1(PermStat paramPermStat, Map paramMap) {}
  
  public boolean doObj(Oop oop)
  {
    val$loaderMap.put(oop, new PermStat.LoaderData(null));
    return false;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.PermStat.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.FieldIdentifier;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.oops.OopField;

class PermStat$1ParentFinder
  extends DefaultOopVisitor
{
  PermStat$1ParentFinder(PermStat paramPermStat) {}
  
  public void doOop(OopField field, boolean isVMField)
  {
    if (field.getID().getName().equals("parent")) {
      parent = field.getValue(getObj());
    }
  }
  
  private Oop parent = null;
  private final PermStat this$0;
  
  public Oop getParent()
  {
    return parent;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.PermStat.1ParentFinder
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.io.PrintStream;
import sun.jvm.hotspot.memory.StringTable.StringVisitor;
import sun.jvm.hotspot.memory.SystemDictionary;
import sun.jvm.hotspot.oops.Instance;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.oops.OopField;
import sun.jvm.hotspot.runtime.VM;

class PermStat$1StringStat
  implements StringTable.StringVisitor
{
  private int count;
  private long size;
  private OopField stringValueField;
  private final PermStat this$0;
  
  PermStat$1StringStat(PermStat arg1)
  {
    VM vm = VM.getVM();
    SystemDictionary sysDict = vm.getSystemDictionary();
    InstanceKlass strKlass = SystemDictionary.getStringKlass();
    
    stringValueField = ((OopField)strKlass.findField("value", "[C"));
  }
  
  private long stringSize(Instance instance)
  {
    return instance.getObjectSize() + stringValueField.getValue(instance).getObjectSize();
  }
  
  public void visit(Instance str)
  {
    count += 1;
    size += stringSize(str);
  }
  
  public void print()
  {
    System.out.println(count + " intern Strings occupying " + size + " bytes.");
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.PermStat.1StringStat
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.util.List;
import java.util.Map;
import sun.jvm.hotspot.memory.SystemDictionary.ClassAndLoaderVisitor;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.Klass;
import sun.jvm.hotspot.oops.Oop;

final class PermStat$2
  implements SystemDictionary.ClassAndLoaderVisitor
{
  private final PermStat this$0;
  
  PermStat$2(PermStat paramPermStat, Map paramMap, PermStat.LoaderData paramLoaderData) {}
  
  public void visit(Klass k, Oop loader)
  {
    if (!(k instanceof InstanceKlass)) {
      return;
    }
    PermStat.LoaderData ld = loader != null ? (PermStat.LoaderData)val$loaderMap.get(loader) : val$bootstrapLoaderData;
    if (ld != null)
    {
      numClasses += 1L;
      long size = PermStat.access$100(this$0, (InstanceKlass)k);
      classDetail.add(new PermStat.ClassData(k, size));
      classSize += size;
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.PermStat.2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.io.PrintStream;
import sun.jvm.hotspot.utilities.HeapProgressThunk;

final class PermStat$3
  implements HeapProgressThunk
{
  private final PermStat this$0;
  
  PermStat$3(PermStat paramPermStat, PrintStream paramPrintStream) {}
  
  public void heapIterationFractionUpdate(double fractionOfHeapVisited)
  {
    val$err.print('.');
  }
  
  public void heapIterationComplete()
  {
    val$err.println("done.");
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.PermStat.3
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import sun.jvm.hotspot.oops.Klass;

class PermStat$ClassData
{
  Klass klass;
  long size;
  
  PermStat$ClassData(Klass klass, long size)
  {
    this.klass = klass;this.size = size;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.PermStat.ClassData
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.util.ArrayList;
import java.util.List;

class PermStat$LoaderData
{
  long numClasses;
  long classSize;
  
  private PermStat$LoaderData() {}
  
  PermStat$LoaderData(PermStat.1 x0)
  {
    this();
  }
  
  List classDetail = new ArrayList();
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.PermStat.LoaderData
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import sun.jvm.hotspot.memory.StringTable;
import sun.jvm.hotspot.memory.StringTable.StringVisitor;
import sun.jvm.hotspot.memory.SystemDictionary;
import sun.jvm.hotspot.memory.SystemDictionary.ClassAndLoaderVisitor;
import sun.jvm.hotspot.oops.Array;
import sun.jvm.hotspot.oops.ConstantPool;
import sun.jvm.hotspot.oops.DefaultHeapVisitor;
import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.FieldIdentifier;
import sun.jvm.hotspot.oops.Instance;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.Klass;
import sun.jvm.hotspot.oops.Method;
import sun.jvm.hotspot.oops.ObjArray;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.oops.OopField;
import sun.jvm.hotspot.oops.Symbol;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.utilities.HeapProgressThunk;
import sun.jvm.hotspot.utilities.ReversePtrs;
import sun.jvm.hotspot.utilities.ReversePtrsAnalysis;

public class PermStat
  extends Tool
{
  boolean verbose;
  
  public PermStat()
  {
    verbose = true;
  }
  
  public static void main(String[] args)
  {
    PermStat ps = new PermStat();
    ps.start(args);
    ps.stop();
  }
  
  private static class ClassData
  {
    Klass klass;
    long size;
    
    ClassData(Klass klass, long size)
    {
      this.klass = klass;this.size = size;
    }
  }
  
  private static class LoaderData
  {
    long numClasses;
    long classSize;
    
    private LoaderData() {}
    
    LoaderData(PermStat.1 x0)
    {
      this();
    }
    
    List classDetail = new ArrayList();
  }
  
  public void run()
  {
    printInternStringStatistics();
    printClassLoaderStatistics();
  }
  
  private void printInternStringStatistics()
  {
    StringTable.StringVisitor stat = new StringTable.StringVisitor()
    {
      private int count;
      private long size;
      private OopField stringValueField;
      
      private long stringSize(Instance instance)
      {
        return instance.getObjectSize() + stringValueField.getValue(instance).getObjectSize();
      }
      
      public void visit(Instance str)
      {
        count += 1;
        size += stringSize(str);
      }
      
      public void print()
      {
        System.out.println(count + " intern Strings occupying " + size + " bytes.");
      }
    };
    StringTable strTable = VM.getVM().getStringTable();
    strTable.stringsDo(stat);
    stat.print();
  }
  
  private void printClassLoaderStatistics()
  {
    PrintStream out = System.out;
    final PrintStream err = System.err;
    final Map loaderMap = new HashMap();
    
    final LoaderData bootstrapLoaderData = new LoaderData(null);
    if (verbose) {
      err.print("finding class loader instances ..");
    }
    VM vm = VM.getVM();
    ObjectHeap heap = vm.getObjectHeap();
    vm.getSystemDictionary();Klass classLoaderKlass = SystemDictionary.getClassLoaderKlass();
    try
    {
      heap.iterateObjectsOfKlass(new DefaultHeapVisitor()
      {
        public boolean doObj(Oop oop)
        {
          loaderMap.put(oop, new PermStat.LoaderData(null));
          return false;
        }
      }, classLoaderKlass);
    }
    catch (Exception se)
    {
      se.printStackTrace();
    }
    if (verbose)
    {
      err.println("done.");
      err.print("computing per loader stat ..");
    }
    SystemDictionary dict = VM.getVM().getSystemDictionary();
    dict.classesDo(new SystemDictionary.ClassAndLoaderVisitor()
    {
      public void visit(Klass k, Oop loader)
      {
        if (!(k instanceof InstanceKlass)) {
          return;
        }
        PermStat.LoaderData ld = loader != null ? (PermStat.LoaderData)loaderMap.get(loader) : bootstrapLoaderData;
        if (ld != null)
        {
          numClasses += 1L;
          long size = PermStat.this.computeSize((InstanceKlass)k);
          classDetail.add(new PermStat.ClassData(k, size));
          classSize += size;
        }
      }
    });
    if (verbose)
    {
      err.println("done.");
      err.print("please wait.. computing liveness");
    }
    ReversePtrsAnalysis analysis = new ReversePtrsAnalysis();
    if (verbose) {
      analysis.setHeapProgressThunk(new HeapProgressThunk()
      {
        public void heapIterationFractionUpdate(double fractionOfHeapVisited)
        {
          err.print('.');
        }
        
        public void heapIterationComplete()
        {
          err.println("done.");
        }
      });
    }
    try
    {
      analysis.run();
    }
    catch (Exception e)
    {
      if (verbose) {
        err.println("liveness analysis may be inaccurate ...");
      }
    }
    ReversePtrs liveness = VM.getVM().getRevPtrs();
    
    out.println("class_loader\tclasses\tbytes\tparent_loader\talive?\ttype");
    out.println();
    
    long numClassLoaders = 1L;
    long totalNumClasses = numClasses;
    long totalClassSize = classSize;
    long numAliveLoaders = 1L;
    long numDeadLoaders = 0L;
    
    out.print("<bootstrap>");
    out.print('\t');
    out.print(numClasses);
    out.print('\t');
    out.print(classSize);
    out.print('\t');
    out.print("  null  ");
    out.print('\t');
    
    out.print("live");
    out.print('\t');
    out.println("<internal>");
    for (Iterator keyItr = loaderMap.keySet().iterator(); keyItr.hasNext();)
    {
      Oop loader = (Oop)keyItr.next();
      LoaderData data = (LoaderData)loaderMap.get(loader);
      numClassLoaders += 1L;
      totalNumClasses += numClasses;
      totalClassSize += classSize;
      
      out.print(loader.getHandle());
      out.print('\t');
      out.print(numClasses);
      out.print('\t');
      out.print(classSize);
      out.print('\t');
      
      DefaultOopVisitor parentFinder = new DefaultOopVisitor()
      {
        public void doOop(OopField field, boolean isVMField)
        {
          if (field.getID().getName().equals("parent")) {
            parent = field.getValue(getObj());
          }
        }
        
        private Oop parent = null;
        
        public Oop getParent()
        {
          return parent;
        }
      };
      loader.iterate(parentFinder, false);
      Oop parent = parentFinder.getParent();
      out.print(parent != null ? parent.getHandle().toString() : "  null  ");
      out.print('\t');
      boolean alive = liveness.get(loader) != null;
      out.print(alive ? "live" : "dead");
      if (alive) {
        numAliveLoaders += 1L;
      } else {
        numDeadLoaders += 1L;
      }
      out.print('\t');
      Klass loaderKlass = loader.getKlass();
      if (loaderKlass != null)
      {
        out.print(loaderKlass.getName().asString());
        out.print('@');
        out.print(loader.getKlass().getHandle());
      }
      else
      {
        out.print("    null!    ");
      }
      out.println();
    }
    out.println();
    
    out.print("total = ");
    out.print(numClassLoaders);
    out.print('\t');
    out.print(totalNumClasses);
    out.print('\t');
    out.print(totalClassSize);
    out.print('\t');
    out.print("    N/A    ");
    out.print('\t');
    out.print("alive=");
    out.print(numAliveLoaders);
    out.print(", dead=");
    out.print(numDeadLoaders);
    out.print('\t');
    out.print("    N/A    ");
    out.println();
  }
  
  private static long objectSize(Oop oop)
  {
    return oop == null ? 0L : oop.getObjectSize();
  }
  
  private static long arraySize(Array arr)
  {
    return arr.getLength() != 0L ? arr.getObjectSize() : 0L;
  }
  
  private long computeSize(InstanceKlass k)
  {
    long size = 0L;
    
    size += k.getObjectSize();
    
    ConstantPool cp = k.getConstants();
    size += cp.getObjectSize();
    size += objectSize(cp.getCache());
    size += objectSize(cp.getTags());
    
    size += arraySize(k.getLocalInterfaces());
    size += arraySize(k.getTransitiveInterfaces());
    
    size += objectSize(k.getInnerClasses());
    
    size += objectSize(k.getFields());
    
    ObjArray methods = k.getMethods();
    int nmethods = (int)methods.getLength();
    if (nmethods != 0L)
    {
      size += methods.getObjectSize();
      for (int i = 0; i < nmethods; i++)
      {
        Method m = (Method)methods.getObjAt(i);
        size += m.getObjectSize();
        size += objectSize(m.getConstMethod());
      }
    }
    size += arraySize(k.getMethodOrdering());
    
    return size;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.PermStat
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.io.PrintStream;
import java.util.Iterator;
import java.util.List;
import sun.jvm.hotspot.bugspot.BugSpotAgent;
import sun.jvm.hotspot.debugger.Debugger;
import sun.jvm.hotspot.debugger.cdbg.CDebugger;
import sun.jvm.hotspot.debugger.cdbg.LoadObject;

public class PMap
  extends Tool
{
  public void run()
  {
    run(System.out);
  }
  
  public void run(PrintStream out)
  {
    run(out, getAgent().getDebugger());
  }
  
  public void run(PrintStream out, Debugger dbg)
  {
    CDebugger cdbg = dbg.getCDebugger();
    Iterator itr;
    if (cdbg != null)
    {
      List l = cdbg.getLoadObjectList();
      for (itr = l.iterator(); itr.hasNext();)
      {
        LoadObject lo = (LoadObject)itr.next();
        out.print(lo.getBase() + "\t");
        out.print(lo.getSize() / 1024L + "K\t");
        out.println(lo.getName());
      }
    }
    else if (getDebugeeType() == 2)
    {
      out.println("remote configuration is not yet implemented");
    }
    else
    {
      out.println("not yet implemented (debugger does not support CDebugger)!");
    }
  }
  
  protected boolean requiresVM()
  {
    return false;
  }
  
  public static void main(String[] args)
    throws Exception
  {
    PMap t = new PMap();
    t.start(args);
    t.stop();
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.tools.PMap
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.tools;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import sun.jvm.hotspot.bugspot.BugSpotAgent;
import sun.jvm.hotspot.code.CodeBlob;
import sun.jvm.hotspot.code.CodeCache;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.Debugger;
import sun.jvm.hotspot.debugger.ThreadProxy;
import sun.jvm.hotspot.debugger.cdbg.CDebugger;
import sun.jvm.hotspot.debugger.cdbg.CFrame;
import sun.jvm.hotspot.debugger.cdbg.ClosestSymbol;
import sun.jvm.hotspot.interpreter.Interpreter;
import sun.jvm.hotspot.interpreter.InterpreterCodelet;
import sun.jvm.hotspot.oops.Method;
import sun.jvm.hotspot.runtime.ConcurrentLocksPrinter;
import sun.jvm.hotspot.runtime.DeadlockDetector;
import sun.jvm.hotspot.runtime.Frame;
import sun.jvm.hotspot.runtime.JavaThread;
import sun.jvm.hotspot.runtime.JavaVFrame;
import sun.jvm.hotspot.runtime.Threads;
import sun.jvm.hotspot.runtime.VM;

public class PStack
  extends Tool
{
  private Map jframeCache;
  private Map proxyToThread;
  private PrintStream out;
  private boolean verbose;
  private boolean concurrentLocks;
  
  public PStack(boolean v, boolean concurrentLocks)
  {
    verbose = v;
    this.concurrentLocks = concurrentLocks;
  }
  
  public PStack()
  {
    this(true, true);
  }
  
  public void run()
  {
    run(System.out);
  }
  
  public void run(PrintStream out)
  {
    Debugger dbg = getAgent().getDebugger();
    run(out, dbg, getAgent().isJavaMode());
  }
  
  public void run(PrintStream out, Debugger dbg)
  {
    run(out, dbg, true);
  }
  
  private void run(PrintStream out, Debugger dbg, boolean isJava)
  {
    CDebugger cdbg = dbg.getCDebugger();
    ConcurrentLocksPrinter concLocksPrinter;
    boolean cdbgCanDemangle;
    Iterator itr;
    if (cdbg != null)
    {
      concLocksPrinter = null;
      if (isJava)
      {
        initJFrameCache();
        if (concurrentLocks) {
          concLocksPrinter = new ConcurrentLocksPrinter();
        }
        try
        {
          DeadlockDetector.print(out);
        }
        catch (Exception exp)
        {
          out.println("can't print deadlock information: " + exp.getMessage());
        }
      }
      List l = cdbg.getThreadList();
      cdbgCanDemangle = cdbg.canDemangle();
      for (itr = l.iterator(); itr.hasNext();)
      {
        ThreadProxy th = (ThreadProxy)itr.next();
        try
        {
          CFrame f = cdbg.topFrameForThread(th);
          out.print("----------------- ");
          out.print(th);
          out.println(" -----------------");
          while (f != null)
          {
            ClosestSymbol sym = f.closestSymbolToPC();
            Address pc = f.pc();
            out.print(pc + "\t");
            if (sym != null)
            {
              String name = sym.getName();
              if (cdbgCanDemangle) {
                name = cdbg.demangle(name);
              }
              out.print(name);
              long diff = sym.getOffset();
              if (diff != 0L) {
                out.print(" + 0x" + Long.toHexString(diff));
              }
              out.println();
            }
            else if (isJava)
            {
              String[] names = null;
              
              Interpreter interp = VM.getVM().getInterpreter();
              if (interp.contains(pc))
              {
                names = getJavaNames(th, f.localVariableBase());
                if ((names == null) || (names.length == 0))
                {
                  out.print("<interpreter> ");
                  InterpreterCodelet ic = interp.getCodeletContaining(pc);
                  if (ic != null)
                  {
                    String desc = ic.getDescription();
                    if (desc != null) {
                      out.print(desc);
                    }
                  }
                  out.println();
                }
              }
              else
              {
                CodeCache c = VM.getVM().getCodeCache();
                if (c.contains(pc))
                {
                  CodeBlob cb = c.findBlobUnsafe(pc);
                  if (cb.isNMethod())
                  {
                    names = getJavaNames(th, f.localVariableBase());
                    if ((names == null) || (names.length == 0)) {
                      out.println("<Unknown compiled code>");
                    }
                  }
                  else if (cb.isBufferBlob())
                  {
                    out.println("<StubRoutines>");
                  }
                  else if (cb.isRuntimeStub())
                  {
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd