diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/.classpath b/javaUtilities/com.raytheon.uf.viz.hprof/.classpath
new file mode 100644
index 0000000000..ad32c83a78
--- /dev/null
+++ b/javaUtilities/com.raytheon.uf.viz.hprof/.classpath
@@ -0,0 +1,7 @@
+
+
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class BigByteBuffer { + + private final long chunkSize = 1024 * 1024 * 256; + + private final ByteBuffer[] buffers; + + private final long offset; + + private final long capacity; + + private long mark = -1; + + private long position = 0; + + private long limit; + + public BigByteBuffer(String fileName) throws IOException { + FileInputStream fis = new FileInputStream(fileName); + FileChannel fileChannel = fis.getChannel(); + offset = 0; + limit = capacity = fileChannel.size(); + int nBuffers = (int) (capacity / chunkSize); + if (nBuffers * chunkSize < capacity) { + nBuffers += 1; + } + buffers = new ByteBuffer[nBuffers]; + for (int i = 0; i < buffers.length; i += 1) { + buffers[i] = fileChannel.map(MapMode.READ_ONLY, i * chunkSize, + Math.min(capacity - i * chunkSize, chunkSize)); + } + fis.close(); + } + + protected BigByteBuffer(ByteBuffer[] buffers, long offset, long capacity) { + this.buffers = buffers; + this.offset = offset; + this.capacity = capacity; + this.limit = capacity; + } + + public final long capacity() { + return capacity; + } + + public final long position() { + return position; + } + + public final BigByteBuffer position(long newPosition) { + if ((newPosition > limit) || (newPosition < 0)) + throw new IllegalArgumentException(); + position = newPosition; + if (mark > position) + mark = -1; + return this; + } + + public final long limit() { + return limit; + } + + public final BigByteBuffer limit(long newLimit) { + if ((newLimit > capacity) || (newLimit < 0)) + throw new IllegalArgumentException(); + limit = newLimit; + if (position > limit) + position = limit; + if (mark > limit) + mark = -1; + return this; + } + + public final BigByteBuffer rewind() { + position = 0; + mark = -1; + return this; + } + + public final long remaining() { + return limit - position; + } + + public final boolean hasRemaining() { + return position < limit; + } + + public BigByteBuffer slice() { + return new BigByteBuffer(buffers, this.position() + offset, + this.remaining()); + } + + public byte get() { + return get(nextGetIndex()); + } + + public byte get(long index) { + checkIndex(index); + return getBuffer(index).get(bufferIndex(index)); + } + + public void get(byte[] dst) { + long start = nextGetIndex(dst.length); + ByteBuffer buffer = getBuffer(start); + buffer.position(bufferIndex(start)); + int offset = 0; + int remaining = dst.length; + while (remaining > 0) { + int length = Math.min(remaining, buffer.remaining()); + buffer.get(dst, offset, length); + offset += length; + remaining -= length; + buffer = getBuffer(start + offset); + buffer.position(bufferIndex(start + offset)); + + } + } + + public short getShort() { + byte[] dst = new byte[2]; + get(dst); + return ByteBuffer.wrap(dst).getShort(); + } + + public int getInt() { + byte[] dst = new byte[4]; + get(dst); + return ByteBuffer.wrap(dst).getInt(); + } + + public long getLong() { + byte[] dst = new byte[8]; + get(dst); + return ByteBuffer.wrap(dst).getLong(); + } + + final ByteBuffer getBuffer(long index) { + return buffers[(int) ((offset + index) / chunkSize)]; + } + + final int bufferIndex(long index) { + return (int) ((offset + index) % chunkSize); + } + + final long nextGetIndex() { + if (position >= limit) + throw new BufferUnderflowException(); + return position++; + } + + final long nextGetIndex(int nb) { + if (limit - position < nb) + throw new BufferUnderflowException(); + long p = position; + position += nb; + return p; + } + + final long checkIndex(long i) { + if ((i < 0) || (i >= limit)) + throw new IndexOutOfBoundsException(); + return i; + } +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/HprofFile.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/HprofFile.java new file mode 100644 index 0000000000..b4f7a9688a --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/HprofFile.java @@ -0,0 +1,215 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ + +package com.raytheon.hprof; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import com.raytheon.hprof.data.HeapDumpEndRecord; +import com.raytheon.hprof.data.HeapDumpRecord; +import com.raytheon.hprof.data.HeapDumpSegmentRecord; +import com.raytheon.hprof.data.LoadClassRecord; +import com.raytheon.hprof.data.MergedHeapDumpSegmentRecord; +import com.raytheon.hprof.data.StackFrameRecord; +import com.raytheon.hprof.data.StackTraceRecord; +import com.raytheon.hprof.data.StringRecord; +import com.raytheon.hprof.data.heap.dump.InstanceDump; + +/** + * + * Root object for an hprof file, description of the data structure can be found + * in a java installation at java/demo/jvmti/hprof/src/manual.html. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class HprofFile { + + private HeapDumpRecord heapDump; + + private List
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class Id implements Comparable
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class SmartInstance { + + private final HprofFile hprof; + + private final Id id; + + private final String className; + + private final Map
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public abstract class AbstractHprofRecord { + + protected final int time; + + public AbstractHprofRecord(BigByteBuffer buffer, int idSize) { + time = buffer.getInt(); + long size = buffer.getInt(); + if (size < 0) { + /* size is really an unsigned int. */ + size = ((int) size) & 0xFFFFFFFFL; + } + BigByteBuffer safeBuffer = buffer.slice(); + safeBuffer.limit(size); + init(safeBuffer, idSize); + buffer.position(buffer.position() + size); + } + + protected abstract void init(BigByteBuffer buffer, int idSize); +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/HeapDumpEndRecord.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/HeapDumpEndRecord.java new file mode 100644 index 0000000000..6cd1daefd6 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/HeapDumpEndRecord.java @@ -0,0 +1,56 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data; + +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.HprofFile; + +/** + * Object for the heap dump end record in an {@link HprofFile}, this type of + * record has no content. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + * @see MergedHeapDumpSegmentRecord + */ +public class HeapDumpEndRecord extends AbstractHprofRecord { + + public static final int TAG = 0x2c; + + public HeapDumpEndRecord(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + } + + @Override + protected void init(BigByteBuffer buffer, int idSize) { + /* This record has no content */ + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/HeapDumpRecord.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/HeapDumpRecord.java new file mode 100644 index 0000000000..17c97d4179 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/HeapDumpRecord.java @@ -0,0 +1,366 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.HprofFile; +import com.raytheon.hprof.Id; +import com.raytheon.hprof.data.heap.BasicType; +import com.raytheon.hprof.data.heap.dump.ClassDump; +import com.raytheon.hprof.data.heap.dump.InstanceDump; +import com.raytheon.hprof.data.heap.dump.ObjectArrayDump; +import com.raytheon.hprof.data.heap.dump.PrimitiveArrayDump; +import com.raytheon.hprof.data.heap.root.AbstractRoot; +import com.raytheon.hprof.data.heap.root.RootJNIGlobal; +import com.raytheon.hprof.data.heap.root.RootJNILocal; +import com.raytheon.hprof.data.heap.root.RootJavaFrame; +import com.raytheon.hprof.data.heap.root.RootMonitorUsed; +import com.raytheon.hprof.data.heap.root.RootStickyClass; +import com.raytheon.hprof.data.heap.root.RootThreadObject; + +/** + * + * Heap dump Record within an {@link HprofFile}. This object holds most of the + * interesting infromation in a hprof file. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class HeapDumpRecord extends AbstractHprofRecord { + + public static final int TAG = 0x0c; + + protected int idSize; + + protected BigByteBuffer buffer; + + protected List
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + * @see MergedHeapDumpSegmentRecord + */ +public class HeapDumpSegmentRecord extends AbstractHprofRecord { + + public static final int TAG = 0x1c; + + public HeapDumpSegmentRecord(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + } + + @Override + protected void init(BigByteBuffer buffer, int idSize) { + /* + * Don't actually process this type of record, it gets processed after + * all the segments are found. + */ + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/LoadClassRecord.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/LoadClassRecord.java new file mode 100644 index 0000000000..f558d9bc68 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/LoadClassRecord.java @@ -0,0 +1,88 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data; + +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.HprofFile; +import com.raytheon.hprof.Id; + +/** + * + * Record of a loaded class in an {@link HprofFile}. Only really used for + * correlating class ids in the dump to their names. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class LoadClassRecord extends AbstractHprofRecord { + + public static final int TAG = 0x02; + + private int classSerialNumber; + + private Id classId; + + private int stackSerialNumber; + + private Id classNameId; + + public LoadClassRecord(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + } + + @Override + protected void init(BigByteBuffer buffer, int idSize) { + classSerialNumber = buffer.getInt(); + classId = new Id(buffer, idSize); + stackSerialNumber = buffer.getInt(); + classNameId = new Id(buffer, idSize); + } + + public static int getTag() { + return TAG; + } + + public int getClassSerialNumber() { + return classSerialNumber; + } + + public Id getClassId() { + return classId; + } + + public int getStackSerialNumber() { + return stackSerialNumber; + } + + public Id getClassNameId() { + return classNameId; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/MergedHeapDumpSegmentRecord.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/MergedHeapDumpSegmentRecord.java new file mode 100644 index 0000000000..17f26479b7 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/MergedHeapDumpSegmentRecord.java @@ -0,0 +1,55 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data; + +import com.raytheon.hprof.BigByteBuffer; + +/** + * + * Represents all the segments in a {@link HeapDumpSegmentRecord} together so + * that all segments can be treeated as a continuous {@link HeapDumpRecord}. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class MergedHeapDumpSegmentRecord extends HeapDumpRecord { + + public MergedHeapDumpSegmentRecord(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + buffer.position(0); + super.init(buffer, idSize); + } + + @Override + protected void init(BigByteBuffer buffer, int idSize) { + /* This is not the full buffer */ + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/StackFrameRecord.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/StackFrameRecord.java new file mode 100644 index 0000000000..e30acbe13e --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/StackFrameRecord.java @@ -0,0 +1,100 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data; +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.HprofFile; +import com.raytheon.hprof.Id; + +/** + * + * Represents a stack frame within an {@link HprofFile}. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class StackFrameRecord extends AbstractHprofRecord { + + public static final int TAG = 0x04; + + private Id stackFrameId; + + private Id methodNameId; + + private Id methodSigId; + + private Id sourceFileId; + + private int classSerialNumber; + + private int lineNumber; + + public StackFrameRecord(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + } + + @Override + protected void init(BigByteBuffer buffer, int idSize) { + stackFrameId = new Id(buffer, idSize); + methodNameId = new Id(buffer, idSize); + methodSigId = new Id(buffer, idSize); + sourceFileId = new Id(buffer, idSize); + classSerialNumber = buffer.getInt(); + lineNumber = buffer.getInt(); + } + + public static int getTag() { + return TAG; + } + + public Id getStackFrameId() { + return stackFrameId; + } + + public Id getMethodNameId() { + return methodNameId; + } + + public Id getMethodSigId() { + return methodSigId; + } + + public Id getSourceFileId() { + return sourceFileId; + } + + public int getClassSerialNumber() { + return classSerialNumber; + } + + public int getLineNumber() { + return lineNumber; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/StackTraceRecord.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/StackTraceRecord.java new file mode 100644 index 0000000000..d74f0588bf --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/StackTraceRecord.java @@ -0,0 +1,78 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data; +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.HprofFile; +import com.raytheon.hprof.Id; + +/** + * + * Represents a stack trace within an {@link HprofFile}. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class StackTraceRecord extends AbstractHprofRecord { + + public static final int TAG = 0x05; + + private int stackSerialNumber; + + private int threadSerialNumber; + + private Id[] stackFrames; + + public StackTraceRecord(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + } + + @Override + protected void init(BigByteBuffer buffer, int idSize) { + stackSerialNumber = buffer.getInt(); + threadSerialNumber = buffer.getInt(); + int numberOfFrames = buffer.getInt(); + if (numberOfFrames < 0) { + numberOfFrames = 0; + } + stackFrames = new Id[numberOfFrames]; + for (int i = 0; i < numberOfFrames; i++) { + stackFrames[i] = new Id(buffer, idSize); + } + } + + public int getStackSerialNumber() { + return stackSerialNumber; + } + + public int getThreadSerialNumber() { + return threadSerialNumber; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/StringRecord.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/StringRecord.java new file mode 100644 index 0000000000..0ea6e03d06 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/StringRecord.java @@ -0,0 +1,71 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data; + +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.HprofFile; +import com.raytheon.hprof.Id; + +/** + * + * Represents a string within an {@link HprofFile}. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class StringRecord extends AbstractHprofRecord { + + public static final int TAG = 0x01; + + private Id id; + + private String string; + + public StringRecord(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + } + + @Override + protected void init(BigByteBuffer buffer, int idSize) { + id = new Id(buffer, idSize); + byte[] string = new byte[(int) buffer.remaining()]; + buffer.get(string); + this.string = new String(string).intern(); + } + + public Id getId() { + return id; + } + + public String getString() { + return string; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/BasicType.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/BasicType.java new file mode 100644 index 0000000000..a4d439916a --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/BasicType.java @@ -0,0 +1,233 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data.heap; + +import java.nio.ByteBuffer; + +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.Id; +import com.raytheon.hprof.data.HeapDumpRecord; + +/** + * + * Represents a basic type within a {@link HeapDumpRecord}. Used primarily for + * fields of objects starts with a byte indicating the type of the field and + * depending on the bytes holds either the primitive value or an object id. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class BasicType { + + private static final byte OBJECT = 2; + + private static final byte BOOLEAN = 4; + + private static final byte CHAR = 5; + + private static final byte FLOAT = 6; + + private static final byte DOUBLE = 7; + + private static final byte BYTE = 8; + + private static final byte SHORT = 9; + + private static final byte INT = 10; + + private static final byte LONG = 11; + + private final byte type; + + private final byte[] data; + + public BasicType(BigByteBuffer buffer, int idSize) { + this(buffer, buffer.get(), idSize); + } + + public BasicType(BigByteBuffer buffer, byte type, int idSize) { + this.type = type; + switch (type) { + case OBJECT: + data = new byte[idSize]; + break; + case FLOAT: + case INT: + data = new byte[4]; + break; + case BOOLEAN: + case BYTE: + data = new byte[1]; + break; + case CHAR: + case SHORT: + data = new byte[2]; + break; + case DOUBLE: + case LONG: + data = new byte[8]; + break; + default: + throw new IllegalArgumentException("Unknown basic type " + + Integer.toHexString(type & 0xFF)); + } + buffer.get(data); + } + + public boolean isObject() { + return type == OBJECT; + } + + public boolean isBoolean() { + return type == BOOLEAN; + } + + public boolean isChar() { + return type == CHAR; + } + + public boolean isFloat() { + return type == FLOAT; + } + + public boolean isDouble() { + return type == DOUBLE; + } + + public boolean isByte() { + return type == BYTE; + } + + public boolean isShort() { + return type == SHORT; + } + + public boolean isInt() { + return type == INT; + } + + public boolean isLong() { + return type == LONG; + } + + public Id getObjectId() { + if (!isObject()) { + throw new IllegalStateException(type + " is not an OBJECT"); + } + return new Id(ByteBuffer.wrap(data), data.length); + } + + public boolean getBoolean() { + if (!isBoolean()) { + throw new IllegalStateException(type + " is not a BOOLEAN"); + } + return ByteBuffer.wrap(data).get() != 0; + } + + public char getChar() { + if (!isChar()) { + throw new IllegalStateException(type + " is not a CHAR"); + } + return ByteBuffer.wrap(data).getChar(); + } + + public float getFloat() { + if (!isFloat()) { + throw new IllegalStateException(type + " is not a FLOAT"); + } + return ByteBuffer.wrap(data).getFloat(); + } + + public double getDouble() { + if (!isDouble()) { + throw new IllegalStateException(type + " is not a DOUBLE"); + } + return ByteBuffer.wrap(data).getDouble(); + } + + public byte getByte() { + if (!isByte()) { + throw new IllegalStateException(type + " is not a BYTE"); + } + return data[0]; + } + + public short getShort() { + if (!isShort()) { + throw new IllegalStateException(type + " is not a SHORT"); + } + return ByteBuffer.wrap(data).getShort(); + } + + public int getInt() { + if (!isInt()) { + throw new IllegalStateException(type + " is not an INT"); + } + return ByteBuffer.wrap(data).getInt(); + } + + public long getLong() { + if (!isLong()) { + throw new IllegalStateException(type + " is not a LONG"); + } + return ByteBuffer.wrap(data).getLong(); + } + + public int getSize() { + return data.length; + } + + @Override + public String toString() { + switch (type) { + case OBJECT: + return "Object: " + getObjectId(); + case FLOAT: + return "Float: " + getFloat(); + case INT: + return "Int: " + getInt(); + case BOOLEAN: + return "Boolean: " + getBoolean(); + case BYTE: + return "Byte: " + getByte(); + case CHAR: + return "Char: " + getChar(); + case SHORT: + return "Short: " + getShort(); + case DOUBLE: + return " Double: " + getDouble(); + case LONG: + return "Long: " + getLong(); + default: + return "Unknown basic type " + Integer.toHexString(type & 0xFF); + } + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/dump/AbstractDump.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/dump/AbstractDump.java new file mode 100644 index 0000000000..7dc71ae7c0 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/dump/AbstractDump.java @@ -0,0 +1,58 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data.heap.dump; + +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.Id; +import com.raytheon.hprof.data.HeapDumpRecord; + +/** + * + * Base class for all the types of data dumped into a {@link HeapDumpRecord}. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class AbstractDump { + + protected final Id id; + + protected final int stackSerialNumber; + + protected AbstractDump(BigByteBuffer buffer, int idSize) { + id = new Id(buffer, idSize); + stackSerialNumber = buffer.getInt(); + } + + public Id getId() { + return id; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/dump/ClassDump.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/dump/ClassDump.java new file mode 100644 index 0000000000..0272bcb435 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/dump/ClassDump.java @@ -0,0 +1,124 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data.heap.dump; + +import java.util.HashMap; +import java.util.Map; + +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.Id; +import com.raytheon.hprof.data.HeapDumpRecord; +import com.raytheon.hprof.data.heap.BasicType; + +/** + * + * Class data for a single class in a {@link HeapDumpRecord}. This class + * contains most of the same information as a {@link Class} object, in a much + * more cryptic form. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class ClassDump extends AbstractDump { + + public static final int TAG = 0x20; + + private final Id superId; + + private final int instanceSize; + + private final BasicType[] constantPool; + + private final Id[] staticFieldIds; + + private final BasicType[] staticFieldValues; + + private final Id[] instanceFieldIds; + + private final byte[] instanceFieldTypes; + + public ClassDump(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + superId = new Id(buffer, idSize); + /* Id classLoaderId = */new Id(buffer, idSize); + /* Id signerId = */new Id(buffer, idSize); + /* Id protectionDomainId = */new Id(buffer, idSize); + /* Id reservedId1 = */new Id(buffer, idSize); + /* Id reservedId2 = */new Id(buffer, idSize); + instanceSize = buffer.getInt(); + short constantPoolSize = buffer.getShort(); + constantPool = new BasicType[constantPoolSize]; + for (int i = 0; i < constantPoolSize; i++) { + /* short constantPoolIndex = */buffer.getShort(); + constantPool[i] = new BasicType(buffer, idSize); + } + short numberOfStaticFields = buffer.getShort(); + staticFieldIds = new Id[numberOfStaticFields]; + staticFieldValues = new BasicType[numberOfStaticFields]; + for (int i = 0; i < numberOfStaticFields; i++) { + staticFieldIds[i] = new Id(buffer, idSize); + staticFieldValues[i] = new BasicType(buffer, idSize); + } + short numberOfInstanceFields = buffer.getShort(); + instanceFieldIds = new Id[numberOfInstanceFields]; + instanceFieldTypes = new byte[numberOfInstanceFields]; + for (int i = 0; i < numberOfInstanceFields; i++) { + instanceFieldIds[i] = new Id(buffer, idSize); + instanceFieldTypes[i] = buffer.get(); + } + } + + public Id getSuperId() { + return superId; + } + + public int getInstanceSize() { + return instanceSize; + } + + public Map
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class InstanceDump extends AbstractDump { + + public static final int TAG = 0x21; + + private final Id classId; + + private final BigByteBuffer instanceData; + + public InstanceDump(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + classId = new Id(buffer, idSize); + int size = buffer.getInt(); + instanceData = buffer.slice(); + instanceData.limit(size); + buffer.position(buffer.position() + size); + } + + public Id getClassId() { + return classId; + } + + public BigByteBuffer getInstanceData() { + instanceData.rewind(); + return instanceData; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/dump/ObjectArrayDump.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/dump/ObjectArrayDump.java new file mode 100644 index 0000000000..9b8cdc34fd --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/dump/ObjectArrayDump.java @@ -0,0 +1,69 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data.heap.dump; + +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.Id; +import com.raytheon.hprof.data.HeapDumpRecord; + +/** + * + * Data for an array of object in a {@link HeapDumpRecord}. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class ObjectArrayDump extends AbstractDump { + + public static final int TAG = 0x22; + + private final Id arrayClassId; + + private final Id[] array; + + public ObjectArrayDump(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + int numElements = buffer.getInt(); + arrayClassId = new Id(buffer, idSize); + array = new Id[numElements]; + for (int i = 0; i < numElements; i++) { + array[i] = new Id(buffer, idSize); + } + } + + public Id[] getArray() { + return array; + } + + public Id getArrayClassId() { + return arrayClassId; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/dump/PrimitiveArrayDump.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/dump/PrimitiveArrayDump.java new file mode 100644 index 0000000000..1406cbf7f4 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/dump/PrimitiveArrayDump.java @@ -0,0 +1,63 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data.heap.dump; + +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.data.HeapDumpRecord; +import com.raytheon.hprof.data.heap.BasicType; + +/** + * + * Data for an array of primitives in a {@link HeapDumpRecord}. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class PrimitiveArrayDump extends AbstractDump { + + public static final int TAG = 0x23; + + private final BasicType[] array; + + public PrimitiveArrayDump(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + int numElements = buffer.getInt(); + byte type = buffer.get(); + array = new BasicType[numElements]; + for (int i = 0; i < numElements; i++) { + array[i] = new BasicType(buffer, type, idSize); + } + } + + public BasicType[] getArray() { + return array; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/AbstractRoot.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/AbstractRoot.java new file mode 100644 index 0000000000..cc3263f76d --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/AbstractRoot.java @@ -0,0 +1,55 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data.heap.root; + +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.Id; +import com.raytheon.hprof.data.HeapDumpRecord; + +/** + * + * Base class for all garbage collection(GC) roots in a {@link HeapDumpRecord}. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class AbstractRoot { + + protected final Id id; + + protected AbstractRoot(BigByteBuffer buffer, int idSize) { + id = new Id(buffer, idSize); + } + + public Id getId() { + return id; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/AbstractRunningRoot.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/AbstractRunningRoot.java new file mode 100644 index 0000000000..532cf212cc --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/AbstractRunningRoot.java @@ -0,0 +1,55 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data.heap.root; + +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.data.HeapDumpRecord; + +/** + * + * Base class for all running roots in a {@link HeapDumpRecord}. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class AbstractRunningRoot extends AbstractRoot { + + protected final int threadSerialNumber; + + protected AbstractRunningRoot(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + threadSerialNumber = buffer.getInt(); + } + + public int getThreadSerialNumber() { + return threadSerialNumber; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootJNIGlobal.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootJNIGlobal.java new file mode 100644 index 0000000000..c199233f27 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootJNIGlobal.java @@ -0,0 +1,56 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data.heap.root; + +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.Id; + +/** + * + * GC Root for a JNI Global. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class RootJNIGlobal extends AbstractRoot { + public static final int TAG = 0x01; + + private final Id globalRefId; + + public RootJNIGlobal(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + globalRefId = new Id(buffer, idSize); + } + + public Id getGlobalRefId() { + return globalRefId; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootJNILocal.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootJNILocal.java new file mode 100644 index 0000000000..dcd4bac896 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootJNILocal.java @@ -0,0 +1,56 @@ +/** + * This software was developed and / or mimport com.raytheon.hprof.BigByteBuffer; +to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data.heap.root; + +import com.raytheon.hprof.BigByteBuffer; + +/** + * + * GC Root for a JNI Local. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class RootJNILocal extends AbstractRunningRoot { + + public static final int TAG = 0x02; + + private final int frameNumberInStack; + + public RootJNILocal(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + frameNumberInStack = buffer.getInt(); + } + + public int getFrameNumberInStack() { + return frameNumberInStack; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootJavaFrame.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootJavaFrame.java new file mode 100644 index 0000000000..8c22ecc634 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootJavaFrame.java @@ -0,0 +1,56 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data.heap.root; + +import com.raytheon.hprof.BigByteBuffer; + +/** + * + * GC Root for a single java stack frame. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class RootJavaFrame extends AbstractRunningRoot { + + public static final int TAG = 0x03; + + private final int frameNumberInStack; + + public RootJavaFrame(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + frameNumberInStack = buffer.getInt(); + } + + public int getFrameNumberInStack() { + return frameNumberInStack; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootMonitorUsed.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootMonitorUsed.java new file mode 100644 index 0000000000..b4903d7a80 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootMonitorUsed.java @@ -0,0 +1,50 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data.heap.root; + +import com.raytheon.hprof.BigByteBuffer; +import com.raytheon.hprof.HprofFile; + +/** + * + * A type of root that appears in an {@link HprofFile}. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + * @see HprofFile + */ +public class RootMonitorUsed extends AbstractRoot { + public static final int TAG = 0x07; + + public RootMonitorUsed(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootStickyClass.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootStickyClass.java new file mode 100644 index 0000000000..711aaf8e91 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootStickyClass.java @@ -0,0 +1,48 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data.heap.root; + +import com.raytheon.hprof.BigByteBuffer; + +/** + * + * GC Root for a sticky class. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class RootStickyClass extends AbstractRoot { + public static final int TAG = 0x05; + + public RootStickyClass(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootThreadObject.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootThreadObject.java new file mode 100644 index 0000000000..6614decabe --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/hprof/data/heap/root/RootThreadObject.java @@ -0,0 +1,56 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.hprof.data.heap.root; + +import com.raytheon.hprof.BigByteBuffer; + +/** + * + * GC Root for a thread object. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class RootThreadObject extends AbstractRunningRoot { + + public static final int TAG = 0x08; + + private final int stackTraceSerialNumber; + + public RootThreadObject(BigByteBuffer buffer, int idSize) { + super(buffer, idSize); + stackTraceSerialNumber = buffer.getInt(); + } + + public int getStackTraceSerialNumber() { + return stackTraceSerialNumber; + } + +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/uf/viz/hprof/AbstractExporter.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/uf/viz/hprof/AbstractExporter.java new file mode 100644 index 0000000000..57d3bfd8f6 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/uf/viz/hprof/AbstractExporter.java @@ -0,0 +1,123 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.hprof; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; + +import com.raytheon.hprof.HprofFile; +import com.raytheon.hprof.SmartInstance; +import com.raytheon.hprof.data.heap.dump.InstanceDump; + +/** + * + * Base class for objects exporting information from an hprof file. Provides a + * framework for creating and commenting a file for output. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public abstract class AbstractExporter { + + protected final HprofFile hprof; + + private final File outputDirectory; + + private Writer writer; + + public AbstractExporter(HprofFile hprof, File outputDirectory) { + this.hprof = hprof; + this.outputDirectory = outputDirectory; + } + + public void export() { + System.out.println(getInfo()); + try { + exportInternal(); + } catch (Throwable e) { + e.printStackTrace(); + } + close(); + } + + protected abstract String getFileName(); + + protected abstract void exportInternal() throws IOException; + + protected String getComment() { + return null; + } + + protected String getInfo() { + return "Generating output for " + getClass().getSimpleName() + "..."; + } + + protected void print(String output) throws IOException { + if (writer == null) { + writer = new BufferedWriter(new FileWriter(new File( + outputDirectory, getFileName()))); + String comment = getComment(); + if (comment != null) { + println(comment); + } + } + writer.append(output); + } + + protected void println(String output) throws IOException { + print(output + "\n"); + } + + protected void close() { + if (writer != null) { + try { + writer.close(); + } catch (Throwable e) { + e.printStackTrace(); + } + } + } + + protected List
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class CaveExporter { + + public static void main(String[] args) { + if (args.length < 1) { + System.out + .println("Provide some args, an hprof file is required, an output directory is optional."); + System.exit(1); + } + HprofFile hprof; + try { + hprof = new HprofFile(args[0]); + } catch (IOException e) { + throw new IllegalArgumentException("Error opening hprof file: " + + args[0], e); + } + + File outputDir = null; + if (args.length > 1) { + outputDir = new File(args[1]); + } else { + outputDir = new File("."); + } + if (!outputDir.isDirectory()) { + if (!outputDir.mkdirs()) { + throw new IllegalArgumentException( + "Cannot make output directory: " + outputDir); + } + } + DisplayedResourcesExporter displayPanes = new DisplayedResourcesExporter( + hprof, outputDir); + displayPanes.export(); + new RequestableResourceExporter(hprof, outputDir, + displayPanes.getResources()).export(); + + new D2DGridResourceExporter(hprof, outputDir).export(); + new GLInfoExporter(hprof, outputDir).export(); + new InputHandlerExporter(hprof, outputDir).export(); + new D2DProcedureDialogExporter(hprof, outputDir).export(); + new GFEResourceExporter(hprof, outputDir).export(); + + } +} diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/uf/viz/hprof/D2DGridResourceExporter.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/uf/viz/hprof/D2DGridResourceExporter.java new file mode 100644 index 0000000000..839bd4cbc4 --- /dev/null +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/uf/viz/hprof/D2DGridResourceExporter.java @@ -0,0 +1,206 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.hprof; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; + +import com.raytheon.hprof.HprofFile; +import com.raytheon.hprof.SmartInstance; + +/** + * + * Export information about D2DGridResources, mostly analyze memory usage of raw + * data. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class D2DGridResourceExporter extends RequestableResourceExporter { + + private final boolean useDataMap = false; + + public D2DGridResourceExporter(HprofFile hprof, File outputDirectory) { + super(hprof, outputDirectory, null); + } + + @Override + protected String getFileName() { + return "d2dGridResources.txt"; + } + + @Override + protected String getComment() { + StringBuilder comment = new StringBuilder(); + comment.append("# This file contains information about D2DGridResources, there are 4 sections:\n"); + comment.append("# 1) Metadata maps for each resource. \n"); + comment.append("# 2) Size and type of all GeneralGridData. \n"); + comment.append("# 3) Total size of each resource. \n"); + comment.append("# 4) Total size of all resources.\n#"); + + return comment.toString(); + } + + @Override + protected String getInfo() { + return "Generating output for D2DGridResource..."; + } + + @Override + protected void exportInternal() throws IOException { + List
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class D2DProcedureDialogExporter extends AbstractExporter { + + public D2DProcedureDialogExporter(HprofFile hprof, File outputDirectory) { + super(hprof, outputDirectory); + } + + @Override + protected String getFileName() { + return "d2dProcedureDialogs.txt"; + } + + @Override + protected String getComment() { + return "# This file contains information about open D2D Procedure Dialogs."; + } + + @Override + protected String getInfo() { + return "Generating output for D2D Procedure Dialogs..."; + } + + @Override + protected void exportInternal() throws IOException { + Id classId = hprof + .lookUpClass("com.raytheon.uf.viz.d2d.ui.dialogs.procedures.ProcedureDlg"); + if (classId == null) { + System.out.println("None found."); + return; + } + HeapDumpRecord heapDump = hprof.getHeapDump(); + ClassDump classDump = heapDump.getClassDump(classId); + SmartInstance openDialogs = null; + for (Entry
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 8, 2014 bsteffen Initial creation + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public abstract class DisplayPaneContainerExporter extends AbstractExporter { + + public DisplayPaneContainerExporter(HprofFile hprof, File outputDirectory) { + super(hprof, outputDirectory); + } + + @Override + protected void exportInternal() throws IOException { + try { + outputVizMultiPaneEditors("com.raytheon.uf.viz.core.maps.display.VizMapEditor"); + } catch (Throwable e) { + e.printStackTrace(); + } + try { + outputVizMultiPaneEditors("com.raytheon.uf.viz.xy.VizXyEditor"); + } catch (Throwable e) { + e.printStackTrace(); + } + try { + outputSideViews(); + } catch (Throwable e) { + e.printStackTrace(); + } + + } + + protected void outputVizMultiPaneEditors(String className) + throws IOException { + List
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class DisplayedResourcesExporter extends DisplayPaneContainerExporter { + + private final List
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class GFEResourceExporter extends AbstractExporter { + + public GFEResourceExporter(HprofFile hprof, File outputDirectory) { + super(hprof, outputDirectory); + } + + @Override + protected String getFileName() { + return "gfeResources.txt"; + } + + @Override + protected String getComment() { + return "# This file contains the parmId of every GFE Resource"; + } + + @Override + protected String getInfo() { + return "Generating output for GFEResource..."; + } + + @Override + protected void exportInternal() throws IOException { + List
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class GLInfoExporter extends AbstractExporter { + + public GLInfoExporter(HprofFile hprof, File outputDirectory) { + super(hprof, outputDirectory); + } + + @Override + protected String getFileName() { + return "glInfo.txt"; + } + + @Override + protected String getComment() { + return "# This file contains information about possible openGL memory usage."; + } + + @Override + protected String getInfo() { + return "Generating output for GL..."; + } + + @Override + protected void exportInternal() throws IOException { + Id classId = hprof + .lookUpClass("com.raytheon.viz.core.gl.internal.cache.ImageCache"); + HeapDumpRecord heapDump = hprof.getHeapDump(); + ClassDump classDump = heapDump.getClassDump(classId); + SmartInstance textureCache = null; + SmartInstance memoryCache = null; + for (Entry
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class InputHandlerExporter extends + DisplayPaneContainerExporter { + + public InputHandlerExporter(HprofFile hprof, File outputDirectory) { + super(hprof, outputDirectory); + } + + @Override + protected String getFileName() { + return "inputHandlers.txt"; + } + + @Override + protected String getComment() { + StringBuilder comment = new StringBuilder(); + comment.append("# This file contains inputHandlers of all the display pane containers\n"); + comment.append("# (SideViews VizMapEditors, and VizXyEditors). The editor with the most\n"); + comment.append("# handlers is probably the active editor.\n"); + return comment.toString(); + } + + @Override + protected String getInfo() { + return "Generating output for DisplayPaneContainer input handlers..."; + } + + @Override + protected void outputPaneManager( + SmartInstance paneManager) throws IOException { + List
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jan 08, 2014 2648 bsteffen Initial doc + * + *+ * + * @author bsteffen + * @version 1.0 + */ +public class RequestableResourceExporter extends AbstractExporter { + + private final List