Issue #2648 Hprof analysis utility.
Change-Id: Ib450c48a88e8a485a2461e1f4a5c81e1be4fee68 Former-commit-id:b64ac87d9c
[formerly51a7dfb438
] [formerlyde58f318cb
] [formerlyb64ac87d9c
[formerly51a7dfb438
] [formerlyde58f318cb
] [formerly30ac7d37a5
[formerlyde58f318cb
[formerly 1bfc1a31ed9052795e1ab0e83cd4bede3eb8e17c]]]] Former-commit-id:30ac7d37a5
Former-commit-id:ecaea29201
[formerly76561f48b8
] [formerly 4a73f7b07a78c95dd7db67c94ba1568ce519628c [formerly3f7a5c135f
]] Former-commit-id: 2bcc199e67893e47e8ed4a8cd5de59e326b93bf2 [formerly00ed5a277c
] Former-commit-id:909594029e
This commit is contained in:
parent
bf9e58c6ea
commit
d45cad301f
43 changed files with 4127 additions and 0 deletions
7
javaUtilities/com.raytheon.uf.viz.hprof/.classpath
Normal file
7
javaUtilities/com.raytheon.uf.viz.hprof/.classpath
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
28
javaUtilities/com.raytheon.uf.viz.hprof/.project
Normal file
28
javaUtilities/com.raytheon.uf.viz.hprof/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.raytheon.uf.viz.hprof</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,8 @@
|
|||
#Wed Sep 07 17:58:19 CDT 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
15
javaUtilities/com.raytheon.uf.viz.hprof/META-INF/MANIFEST.MF
Normal file
15
javaUtilities/com.raytheon.uf.viz.hprof/META-INF/MANIFEST.MF
Normal file
|
@ -0,0 +1,15 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: com.raytheon.uf.viz.hprof.CaveExporter
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Viz Hprof Analysis
|
||||
Bundle-SymbolicName: com.raytheon.uf.viz.hprof
|
||||
Bundle-Version: 1.14.0.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.raytheon.hprof,
|
||||
com.raytheon.hprof.data,
|
||||
com.raytheon.hprof.data.heap,
|
||||
com.raytheon.hprof.data.heap.dump,
|
||||
com.raytheon.hprof.data.heap.root,
|
||||
com.raytheon.uf.viz.hprof
|
4
javaUtilities/com.raytheon.uf.viz.hprof/build.properties
Normal file
4
javaUtilities/com.raytheon.uf.viz.hprof/build.properties
Normal file
|
@ -0,0 +1,4 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
66
javaUtilities/com.raytheon.uf.viz.hprof/build.xml
Normal file
66
javaUtilities/com.raytheon.uf.viz.hprof/build.xml
Normal file
|
@ -0,0 +1,66 @@
|
|||
<!--
|
||||
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.
|
||||
-->
|
||||
<project name="com.raytheon.uf.viz.hprof" default="dist">
|
||||
|
||||
<property name="src" location="src"/>
|
||||
<property name="bin" location="bin"/>
|
||||
<property name="main" value="com.raytheon.uf.viz.hprof.CaveExporter"/>
|
||||
<property name="qualifier" value="${date}"/>
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="${bin}"/>
|
||||
<tstamp>
|
||||
<format property="date" pattern="yyyyMMdd" />
|
||||
</tstamp>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init">
|
||||
<javac srcdir="${src}" destdir="${bin}"/>
|
||||
</target>
|
||||
|
||||
<target name="copyManifest" depends="init">
|
||||
<loadproperties srcfile="META-INF/MANIFEST.MF">
|
||||
<filterchain>
|
||||
<linecontainsregexp>
|
||||
<regexp pattern="^Bundle-Version: \d+.\d+.\d+.qualifier$" />
|
||||
</linecontainsregexp>
|
||||
<tokenfilter>
|
||||
<replaceregex pattern="qualifier$" replace="${qualifier}" />
|
||||
</tokenfilter>
|
||||
</filterchain>
|
||||
</loadproperties>
|
||||
<copy file="META-INF/MANIFEST.MF" tofile="${bin}/META-INF/MANIFEST.MF" />
|
||||
<manifest file="${bin}/META-INF/MANIFEST.MF" mode="update">
|
||||
<attribute name="Bundle-Version" value="${Bundle-Version}" />
|
||||
</manifest>
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="compile,copyManifest">
|
||||
<jar destfile="${ant.project.name}-${Bundle-Version}.jar" basedir="${bin}" manifest="${bin}/META-INF/MANIFEST.MF"/>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${bin}"/>
|
||||
<delete verbose="true">
|
||||
<fileset dir="." includes="${ant.project.name}-*.jar"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,211 @@
|
|||
/**
|
||||
* 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.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.FileChannel.MapMode;
|
||||
|
||||
/**
|
||||
*
|
||||
* ByteBuffers cannot be used to index more than 2GB of data. Since some hprof
|
||||
* files are larger than that a BigByteBuffer is used to allow long indexing
|
||||
* into a much larger space. BigByteBuffers internally are represented by direct
|
||||
* memory mapped byte buffers that map the contents of a single file.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class HprofFile {
|
||||
|
||||
private HeapDumpRecord heapDump;
|
||||
|
||||
private List<StringRecord> strings = new ArrayList<StringRecord>();
|
||||
|
||||
private List<LoadClassRecord> loadClasses = new ArrayList<LoadClassRecord>();
|
||||
|
||||
/* If these ever get full and cause problems they should be switched to LRU. */
|
||||
private Map<Id, String> usedStrings = new HashMap<Id, String>();
|
||||
|
||||
private Map<Id, String> usedClassnames = new HashMap<Id, String>();
|
||||
|
||||
public HprofFile(String fileName) throws IOException {
|
||||
BigByteBuffer buffer = new BigByteBuffer(fileName);
|
||||
|
||||
String format = null;
|
||||
|
||||
while (buffer.hasRemaining()) {
|
||||
if (buffer.get() == 0x00) {
|
||||
byte[] formatBytes = new byte[(int) buffer.position() - 1];
|
||||
buffer.rewind();
|
||||
/* reread the string */
|
||||
buffer.get(formatBytes);
|
||||
/* reread the null */
|
||||
buffer.get();
|
||||
format = new String(formatBytes);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (format == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"This does not appear to be a valid hprof file!");
|
||||
}
|
||||
System.out.println("Hprof format is " + format);
|
||||
int idSize = buffer.getInt();
|
||||
System.out.println("Dump is from " + new Date(buffer.getLong()));
|
||||
|
||||
long segmentStart = 0;
|
||||
|
||||
while (buffer.hasRemaining()) {
|
||||
byte type = buffer.get();
|
||||
switch (type & 0xFF) {
|
||||
case StringRecord.TAG: {
|
||||
strings.add(new StringRecord(buffer, idSize));
|
||||
break;
|
||||
}
|
||||
case LoadClassRecord.TAG: {
|
||||
loadClasses.add(new LoadClassRecord(buffer, idSize));
|
||||
break;
|
||||
}
|
||||
case StackFrameRecord.TAG: {
|
||||
new StackFrameRecord(buffer, idSize);
|
||||
break;
|
||||
}
|
||||
case StackTraceRecord.TAG: {
|
||||
new StackTraceRecord(buffer, idSize);
|
||||
break;
|
||||
}
|
||||
case HeapDumpRecord.TAG: {
|
||||
heapDump = new HeapDumpRecord(buffer, idSize);
|
||||
break;
|
||||
}
|
||||
case HeapDumpSegmentRecord.TAG: {
|
||||
if (segmentStart == 0) {
|
||||
segmentStart = buffer.position() - 1;
|
||||
}
|
||||
new HeapDumpSegmentRecord(buffer, idSize);
|
||||
break;
|
||||
}
|
||||
case HeapDumpEndRecord.TAG: {
|
||||
long segmentEnd = buffer.position() - 1;
|
||||
buffer.position(segmentStart);
|
||||
BigByteBuffer safeBuffer = buffer.slice();
|
||||
safeBuffer.limit(segmentEnd - segmentStart);
|
||||
heapDump = new MergedHeapDumpSegmentRecord(safeBuffer, idSize);
|
||||
segmentStart = 0;
|
||||
buffer.position(segmentEnd + 1);
|
||||
new HeapDumpEndRecord(buffer, idSize);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new IllegalStateException("Unknown type "
|
||||
+ Integer.toHexString(type & 0xFF));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Id lookUpClass(String className) {
|
||||
Id classNameId = getStringId(className.replace(".", "/"));
|
||||
for (LoadClassRecord loadClass : loadClasses) {
|
||||
if (loadClass.getClassNameId().equals(classNameId)) {
|
||||
return loadClass.getClassId();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public HeapDumpRecord getHeapDump() {
|
||||
return heapDump;
|
||||
}
|
||||
|
||||
public String getString(Id stringId) {
|
||||
if (usedStrings.containsKey(stringId)) {
|
||||
return usedStrings.get(stringId);
|
||||
}
|
||||
for (StringRecord string : strings) {
|
||||
if (string.getId().equals(stringId)) {
|
||||
usedStrings.put(stringId, string.getString());
|
||||
return string.getString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Id getStringId(String string) {
|
||||
for (Entry<Id, String> entry : usedStrings.entrySet()) {
|
||||
if (entry.getValue().equals(string)) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
for (StringRecord stringRec : strings) {
|
||||
if (stringRec.getString().equals(string)) {
|
||||
usedStrings.put(stringRec.getId(), stringRec.getString());
|
||||
return stringRec.getId();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getClassName(Id classId) {
|
||||
if (usedClassnames.containsKey(classId)) {
|
||||
return usedClassnames.get(classId);
|
||||
}
|
||||
for (LoadClassRecord loadClass : loadClasses) {
|
||||
if (loadClass.getClassId().equals(classId)) {
|
||||
String className = getString(loadClass.getClassNameId())
|
||||
.replace("/", ".");
|
||||
usedClassnames.put(classId, className);
|
||||
return className;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<InstanceDump> getInstances(String className) {
|
||||
Id classId = lookUpClass(className);
|
||||
if (classId == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return heapDump.getInstances(classId);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
/**
|
||||
* 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.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*
|
||||
* Represents an Id of an object in an hprof file. The id is generally either 4
|
||||
* or 8 bytes which is essentially an int or a long but the hprof format allows
|
||||
* arbitrary id lengths.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Id implements Comparable<Id> {
|
||||
|
||||
private final byte[] id;
|
||||
|
||||
public Id(BigByteBuffer buffer, int idSize) {
|
||||
id = new byte[idSize];
|
||||
buffer.get(id);
|
||||
}
|
||||
|
||||
public Id(ByteBuffer buffer, int idSize) {
|
||||
id = new byte[idSize];
|
||||
buffer.get(id);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return id.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + Arrays.hashCode(id);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Id other = (Id) obj;
|
||||
if (!Arrays.equals(id, other.id))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append("id=0x");
|
||||
for (byte b : id) {
|
||||
str.append(String.format("%02x", b & 0xFF));
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Id that) {
|
||||
for (int i = 0; i < id.length; i++) {
|
||||
int diff = id[i] - that.id[i];
|
||||
if (diff != 0) {
|
||||
return diff;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,289 @@
|
|||
/**
|
||||
* 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.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.raytheon.hprof.data.HeapDumpRecord;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Represents an instance of an object within a heap dump. This is an enhanced
|
||||
* version of an {@link InstanceDump} that uses all the information in an
|
||||
* {@link HprofFile} to provide useful introspection.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SmartInstance {
|
||||
|
||||
private final HprofFile hprof;
|
||||
|
||||
private final Id id;
|
||||
|
||||
private final String className;
|
||||
|
||||
private final Map<String, BasicType> fields = new HashMap<String, BasicType>();
|
||||
|
||||
public SmartInstance(HprofFile hprof, InstanceDump instance) {
|
||||
this.hprof = hprof;
|
||||
this.id = instance.getId();
|
||||
Id classId = instance.getClassId();
|
||||
className = hprof.getClassName(classId);
|
||||
int idSize = classId.size();
|
||||
HeapDumpRecord heapDump = hprof.getHeapDump();
|
||||
ClassDump classDump = heapDump.getClassDump(classId);
|
||||
BigByteBuffer instanceData = instance.getInstanceData();
|
||||
while (classDump != null) {
|
||||
Map<Id, BasicType> id2type = classDump.parseInstanceData(
|
||||
instanceData, idSize);
|
||||
for (Entry<Id, BasicType> entry : id2type.entrySet()) {
|
||||
String fieldName = hprof.getString(entry.getKey());
|
||||
fields.put(fieldName, entry.getValue());
|
||||
}
|
||||
classDump = heapDump.getClassDump(classDump.getSuperId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected Id getId(String fieldName) {
|
||||
BasicType type = fields.get(fieldName);
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
return type.getObjectId();
|
||||
}
|
||||
|
||||
protected String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public SmartInstance get(String fieldName) {
|
||||
Id fieldId = getId(fieldName);
|
||||
if (fieldId == null) {
|
||||
return null;
|
||||
}
|
||||
InstanceDump field = hprof.getHeapDump().getInstance(fieldId);
|
||||
if (field == null) {
|
||||
return null;
|
||||
}
|
||||
return new SmartInstance(hprof, field);
|
||||
}
|
||||
|
||||
private BasicType getTypeNotNull(String fieldName) {
|
||||
BasicType type = fields.get(fieldName);
|
||||
if (type == null) {
|
||||
throw new IllegalStateException(fieldName
|
||||
+ " is not a a valid field");
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getInt(String fieldName) {
|
||||
return getTypeNotNull(fieldName).getInt();
|
||||
}
|
||||
|
||||
public long getLong(String fieldName) {
|
||||
return getTypeNotNull(fieldName).getLong();
|
||||
}
|
||||
|
||||
public SmartInstance[] getObjectArray(String fieldName) {
|
||||
BasicType type = fields.get(fieldName);
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
HeapDumpRecord heapDump = hprof.getHeapDump();
|
||||
Id fieldId = type.getObjectId();
|
||||
ObjectArrayDump objectArray = heapDump.getObjectArray(fieldId);
|
||||
if (objectArray == null) {
|
||||
return null;
|
||||
}
|
||||
Id[] idArray = objectArray.getArray();
|
||||
SmartInstance[] smartArray = new SmartInstance[idArray.length];
|
||||
for (int i = 0; i < idArray.length; i += 1) {
|
||||
InstanceDump instance = heapDump.getInstance(idArray[i]);
|
||||
if (instance != null) {
|
||||
smartArray[i] = new SmartInstance(hprof, instance);
|
||||
}
|
||||
}
|
||||
return smartArray;
|
||||
}
|
||||
|
||||
public char[] getCharArray(String fieldName) {
|
||||
BasicType type = fields.get(fieldName);
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
Id fieldId = type.getObjectId();
|
||||
BasicType[] primArray = hprof.getHeapDump().getPrimitiveArray(fieldId);
|
||||
if (primArray == null) {
|
||||
return null;
|
||||
}
|
||||
char[] charArray = new char[primArray.length];
|
||||
|
||||
for (int i = 0; i < charArray.length; i += 1) {
|
||||
charArray[i] = primArray[i].getChar();
|
||||
}
|
||||
return charArray;
|
||||
}
|
||||
|
||||
public int[] getIntArray(String fieldName) {
|
||||
BasicType type = fields.get(fieldName);
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
Id fieldId = type.getObjectId();
|
||||
BasicType[] primArray = hprof.getHeapDump().getPrimitiveArray(fieldId);
|
||||
if (primArray == null) {
|
||||
return null;
|
||||
}
|
||||
int[] intArray = new int[primArray.length];
|
||||
|
||||
for (int i = 0; i < intArray.length; i += 1) {
|
||||
intArray[i] = primArray[i].getInt();
|
||||
}
|
||||
return intArray;
|
||||
}
|
||||
|
||||
public String getString(String fieldName) {
|
||||
Id fieldId = getId(fieldName);
|
||||
if (fieldId == null) {
|
||||
return null;
|
||||
}
|
||||
InstanceDump field = hprof.getHeapDump().getInstance(fieldId);
|
||||
if (field != null) {
|
||||
SmartInstance smartField = new SmartInstance(hprof, field);
|
||||
if (!smartField.getClassName().equals(String.class.getName())) {
|
||||
throw new IllegalStateException(fieldName + " is not a String.");
|
||||
}
|
||||
return smartField.toString();
|
||||
} else {
|
||||
Iterator<ClassDump> classDumps = hprof.getHeapDump()
|
||||
.getClassDumps();
|
||||
while (classDumps.hasNext()) {
|
||||
ClassDump classDump = classDumps.next();
|
||||
for (Entry<Id, BasicType> entry : classDump.getStaticFields()
|
||||
.entrySet()) {
|
||||
BasicType f = entry.getValue();
|
||||
if (f.isObject() && f.getObjectId().equals(fieldId)) {
|
||||
String className = hprof
|
||||
.getClassName(classDump.getId());
|
||||
return "{@link " + shortenClass(className) + "#"
|
||||
+ hprof.getString(entry.getKey()) + "}";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "String (" + fieldId + ")";
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<SmartInstance> toArrayList() {
|
||||
if (!getClassName().equals(ArrayList.class.getName())) {
|
||||
throw new IllegalStateException(this + " is not an ArrayList.");
|
||||
}
|
||||
int size = getInt("size");
|
||||
SmartInstance[] elementData = getObjectArray("elementData");
|
||||
ArrayList<SmartInstance> arrayList = new ArrayList<SmartInstance>(size);
|
||||
for (int i = 0; i < size; i += 1) {
|
||||
arrayList.add(elementData[i]);
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<SmartInstance, SmartInstance> toConcurrentHashMap() {
|
||||
if (!getClassName().equals(ConcurrentHashMap.class.getName())) {
|
||||
throw new IllegalStateException(this
|
||||
+ " is not a ConcurrentHashMap.");
|
||||
}
|
||||
ConcurrentHashMap<SmartInstance, SmartInstance> map = new ConcurrentHashMap<SmartInstance, SmartInstance>();
|
||||
SmartInstance[] segments = getObjectArray("segments");
|
||||
for (SmartInstance segment : segments) {
|
||||
SmartInstance[] table = segment.getObjectArray("table");
|
||||
for (SmartInstance entry : table) {
|
||||
while (entry != null) {
|
||||
map.put(entry.get("key"), entry.get("value"));
|
||||
entry = entry.get("next");
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public HashMap<SmartInstance, SmartInstance> toHashMap() {
|
||||
if (!getClassName().equals(HashMap.class.getName())) {
|
||||
throw new IllegalStateException(this + " is not a HashMap.");
|
||||
}
|
||||
HashMap<SmartInstance, SmartInstance> map = new HashMap<SmartInstance, SmartInstance>();
|
||||
SmartInstance[] table = getObjectArray("table");
|
||||
for (SmartInstance entry : table) {
|
||||
while (entry != null) {
|
||||
map.put(entry.get("key"), entry.get("value"));
|
||||
entry = entry.get("next");
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public HashMap<String, SmartInstance> toStringKeyedHashMap() {
|
||||
if (!getClassName().equals(HashMap.class.getName())) {
|
||||
throw new IllegalStateException(this + " is not a HashMap.");
|
||||
}
|
||||
HashMap<String, SmartInstance> map = new HashMap<String, SmartInstance>();
|
||||
SmartInstance[] table = getObjectArray("table");
|
||||
for (SmartInstance entry : table) {
|
||||
while (entry != null) {
|
||||
map.put(entry.getString("key"), entry.get("value"));
|
||||
entry = entry.get("next");
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (className.equals(String.class.getName())) {
|
||||
return "\"" + new String(getCharArray("value")) + "\"";
|
||||
}
|
||||
return shortenClass(className) + " (" + id + ")";
|
||||
}
|
||||
|
||||
private String shortenClass(String className) {
|
||||
int index = className.lastIndexOf('.');
|
||||
return className.substring(index + 1);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* Base class for the different types of records in an {@link HprofFile}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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);
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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 */
|
||||
}
|
||||
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class HeapDumpRecord extends AbstractHprofRecord {
|
||||
|
||||
public static final int TAG = 0x0c;
|
||||
|
||||
protected int idSize;
|
||||
|
||||
protected BigByteBuffer buffer;
|
||||
|
||||
protected List<AbstractRoot> roots;
|
||||
|
||||
protected long[] instancesById;
|
||||
|
||||
protected long[] instancesByClass;
|
||||
|
||||
protected long[] objectArraysById;
|
||||
|
||||
protected long[] primitiveArraysById;
|
||||
|
||||
protected long[] classesById;
|
||||
|
||||
protected Map<Id, ClassDump> usedClasses;
|
||||
|
||||
|
||||
public HeapDumpRecord(BigByteBuffer buffer, int idSize) {
|
||||
super(buffer, idSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init(BigByteBuffer buffer, int idSize) {
|
||||
this.buffer = buffer;
|
||||
this.idSize = idSize;
|
||||
this.roots = new ArrayList<AbstractRoot>();
|
||||
this.usedClasses = new HashMap<Id, ClassDump>();
|
||||
List<Long> instances = new ArrayList<Long>();
|
||||
List<Long> objectArrays = new ArrayList<Long>();
|
||||
List<Long> primitiveArrays = new ArrayList<Long>();
|
||||
List<Long> classes = new ArrayList<Long>();
|
||||
while (buffer.hasRemaining()) {
|
||||
byte type = buffer.get();
|
||||
switch (type & 0xFF) {
|
||||
case RootJNIGlobal.TAG: {
|
||||
roots.add(new RootJNIGlobal(buffer, idSize));
|
||||
break;
|
||||
}
|
||||
case RootJNILocal.TAG: {
|
||||
roots.add(new RootJNILocal(buffer, idSize));
|
||||
break;
|
||||
}
|
||||
case RootJavaFrame.TAG: {
|
||||
roots.add(new RootJavaFrame(buffer, idSize));
|
||||
break;
|
||||
}
|
||||
case RootStickyClass.TAG: {
|
||||
roots.add(new RootStickyClass(buffer, idSize));
|
||||
break;
|
||||
}
|
||||
case RootMonitorUsed.TAG: {
|
||||
roots.add(new RootMonitorUsed(buffer, idSize));
|
||||
break;
|
||||
}
|
||||
case RootThreadObject.TAG: {
|
||||
roots.add(new RootThreadObject(buffer, idSize));
|
||||
break;
|
||||
}
|
||||
case ClassDump.TAG: {
|
||||
classes.add(buffer.position());
|
||||
new ClassDump(buffer, idSize);
|
||||
break;
|
||||
}
|
||||
case InstanceDump.TAG: {
|
||||
instances.add(buffer.position());
|
||||
new InstanceDump(buffer, idSize);
|
||||
break;
|
||||
}
|
||||
case ObjectArrayDump.TAG: {
|
||||
objectArrays.add(buffer.position());
|
||||
new ObjectArrayDump(buffer, idSize);
|
||||
break;
|
||||
}
|
||||
case PrimitiveArrayDump.TAG: {
|
||||
primitiveArrays.add(buffer.position());
|
||||
new PrimitiveArrayDump(buffer, idSize);
|
||||
break;
|
||||
}
|
||||
case HeapDumpSegmentRecord.TAG: {
|
||||
buffer.position(buffer.position() + 8);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new IllegalStateException("Unknown heap type "
|
||||
+ Integer.toHexString(type & 0xFF));
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Sorting all objects...");
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
Collections.sort(instances, new DumpBufferIndexComparator());
|
||||
Collections.sort(objectArrays, new DumpBufferIndexComparator());
|
||||
Collections.sort(primitiveArrays, new DumpBufferIndexComparator());
|
||||
Collections.sort(classes, new DumpBufferIndexComparator());
|
||||
|
||||
this.instancesById = new long[instances.size()];
|
||||
for (int i = 0; i < instances.size(); i++) {
|
||||
this.instancesById[i] = instances.get(i);
|
||||
}
|
||||
|
||||
this.objectArraysById = new long[objectArrays.size()];
|
||||
for (int i = 0; i < objectArrays.size(); i++) {
|
||||
this.objectArraysById[i] = objectArrays.get(i);
|
||||
}
|
||||
|
||||
this.primitiveArraysById = new long[primitiveArrays.size()];
|
||||
for (int i = 0; i < primitiveArrays.size(); i++) {
|
||||
this.primitiveArraysById[i] = primitiveArrays.get(i);
|
||||
}
|
||||
|
||||
this.classesById = new long[classes.size()];
|
||||
for (int i = 0; i < classes.size(); i++) {
|
||||
this.classesById[i] = classes.get(i);
|
||||
}
|
||||
|
||||
/* Add one id and one int before the class id */
|
||||
Collections.sort(instances, new DumpBufferIndexComparator(idSize + 4));
|
||||
|
||||
this.instancesByClass = new long[instances.size()];
|
||||
for (int i = 0; i < instances.size(); i++) {
|
||||
this.instancesByClass[i] = instances.get(i);
|
||||
}
|
||||
|
||||
System.out.println("Spent " + (System.currentTimeMillis() - startTime)
|
||||
/ 1000 + " seconds sorting");
|
||||
}
|
||||
|
||||
public ClassDump getClassDump(Id classId) {
|
||||
if (usedClasses.containsKey(classId)) {
|
||||
return usedClasses.get(classId);
|
||||
}
|
||||
long index = binarySearch(classesById, classId);
|
||||
if (index < 0) {
|
||||
return null;
|
||||
}
|
||||
buffer.position(index);
|
||||
ClassDump classDump = new ClassDump(buffer, idSize);
|
||||
usedClasses.put(classId, classDump);
|
||||
return classDump;
|
||||
}
|
||||
|
||||
public InstanceDump getInstance(Id objectId) {
|
||||
long index = binarySearch(instancesById, objectId);
|
||||
if (index < 0) {
|
||||
return null;
|
||||
}
|
||||
buffer.position(index);
|
||||
return new InstanceDump(buffer, idSize);
|
||||
}
|
||||
|
||||
public ObjectArrayDump getObjectArray(Id objectId) {
|
||||
long index = binarySearch(objectArraysById, objectId);
|
||||
if (index < 0) {
|
||||
return null;
|
||||
}
|
||||
buffer.position(index);
|
||||
return new ObjectArrayDump(buffer, idSize);
|
||||
}
|
||||
|
||||
public BasicType[] getPrimitiveArray(Id objectId) {
|
||||
long index = binarySearch(primitiveArraysById, objectId);
|
||||
if (index < 0) {
|
||||
return null;
|
||||
}
|
||||
buffer.position(index);
|
||||
return new PrimitiveArrayDump(buffer, idSize).getArray();
|
||||
}
|
||||
|
||||
private long binarySearch(long[] array, Id objectId) {
|
||||
int low = 0;
|
||||
int high = array.length - 1;
|
||||
while (low <= high) {
|
||||
int mid = (low + high) / 2;
|
||||
buffer.position(array[mid]);
|
||||
Id id = new Id(buffer, idSize);
|
||||
|
||||
int compval = id.compareTo(objectId);
|
||||
if (compval < 0) {
|
||||
low = mid + 1;
|
||||
} else if (compval > 0) {
|
||||
high = mid - 1;
|
||||
} else {
|
||||
return array[mid];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public List<InstanceDump> getInstances(Id classId) {
|
||||
int low = 0;
|
||||
int high = instancesByClass.length - 1;
|
||||
int mid = (low + high) / 2;
|
||||
while (low <= high) {
|
||||
mid = (low + high) / 2;
|
||||
buffer.position(instancesByClass[mid] + idSize + 4);
|
||||
Id id = new Id(buffer, idSize);
|
||||
|
||||
int compval = id.compareTo(classId);
|
||||
if (compval < 0) {
|
||||
low = mid + 1;
|
||||
} else if (compval > 0) {
|
||||
high = mid - 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (low > high) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<InstanceDump> instances = new ArrayList<InstanceDump>();
|
||||
|
||||
int next = mid;
|
||||
buffer.position(instancesByClass[next--]);
|
||||
InstanceDump instance = new InstanceDump(buffer, idSize);
|
||||
while (instance.getClassId().equals(classId) && next >= 0) {
|
||||
instances.add(instance);
|
||||
buffer.position(instancesByClass[next--]);
|
||||
instance = new InstanceDump(buffer, idSize);
|
||||
}
|
||||
next = mid + 1;
|
||||
buffer.position(instancesByClass[next++]);
|
||||
instance = new InstanceDump(buffer, idSize);
|
||||
while (instance.getClassId().equals(classId)
|
||||
&& next < instancesByClass.length) {
|
||||
instances.add(instance);
|
||||
buffer.position(instancesByClass[next++]);
|
||||
instance = new InstanceDump(buffer, idSize);
|
||||
}
|
||||
return instances;
|
||||
}
|
||||
|
||||
public Map<Id, BasicType> getInstanceFields(InstanceDump instance) {
|
||||
Map<Id, BasicType> id2type = new HashMap<Id, BasicType>();
|
||||
ClassDump classDump = getClassDump(instance.getClassId());
|
||||
BigByteBuffer instanceData = instance.getInstanceData();
|
||||
while (classDump != null) {
|
||||
id2type.putAll(classDump.parseInstanceData(instanceData, idSize));
|
||||
classDump = getClassDump(classDump.getSuperId());
|
||||
}
|
||||
return id2type;
|
||||
}
|
||||
|
||||
public Iterator<ClassDump> getClassDumps() {
|
||||
return new Iterator<ClassDump>() {
|
||||
|
||||
private int index;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return index < classesById.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDump next() {
|
||||
buffer.position(classesById[index]);
|
||||
index += 1;
|
||||
return new ClassDump(buffer, idSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
protected class DumpBufferIndexComparator implements Comparator<Long> {
|
||||
|
||||
private final int indexOffset;
|
||||
|
||||
protected DumpBufferIndexComparator() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
protected DumpBufferIndexComparator(int indexOffset) {
|
||||
this.indexOffset = indexOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Long o1, Long o2) {
|
||||
try {
|
||||
HeapDumpRecord.this.buffer.position(o1 + indexOffset);
|
||||
Id i1 = new Id(HeapDumpRecord.this.buffer,
|
||||
HeapDumpRecord.this.idSize);
|
||||
HeapDumpRecord.this.buffer.position(o2 + indexOffset);
|
||||
Id i2 = new Id(HeapDumpRecord.this.buffer,
|
||||
HeapDumpRecord.this.idSize);
|
||||
return i1.compareTo(i2);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* 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 a segmented heap dump record in an {@link HprofFile}. The segments
|
||||
* are not actually processed seperately, this record is just used as a place
|
||||
* holder until all segments are found and then all segments are processed
|
||||
* together as a {@link MergedHeapDumpSegmentRecord}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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 */
|
||||
}
|
||||
|
||||
}
|
|
@ -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}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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<Id, BasicType> parseInstanceData(BigByteBuffer buffer, int idSize) {
|
||||
Map<Id, BasicType> results = new HashMap<Id, BasicType>();
|
||||
for (int i = 0; i < instanceFieldIds.length; i++) {
|
||||
BasicType type = new BasicType(buffer, instanceFieldTypes[i],
|
||||
idSize);
|
||||
results.put(instanceFieldIds[i], type);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public Map<Id, BasicType> getStaticFields(){
|
||||
Map<Id, BasicType> results = new HashMap<Id, BasicType>(instanceFieldIds.length * 2);
|
||||
for(int i = 0 ; i < staticFieldIds.length ; i += 1){
|
||||
results.put(staticFieldIds[i], staticFieldValues[i]);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
|
@ -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 a single instance of an object in a {@link HeapDumpRecord}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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<SmartInstance> getInstances(String className) {
|
||||
List<InstanceDump> instances = hprof.getInstances(className);
|
||||
List<SmartInstance> smartInstances = new ArrayList<SmartInstance>(
|
||||
instances.size());
|
||||
for (InstanceDump instance : instances) {
|
||||
smartInstances.add(new SmartInstance(hprof, instance));
|
||||
}
|
||||
return smartInstances;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/**
|
||||
* 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 com.raytheon.hprof.HprofFile;
|
||||
|
||||
/**
|
||||
*
|
||||
* Main class for exporting information from a cave heap dump. Parses command
|
||||
* line options and passes all the real work to various exporters.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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();
|
||||
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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<SmartInstance> resources = getInstances("com.raytheon.viz.grid.rsc.general.D2DGridResource");
|
||||
if (resources.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
println("# Section 1 metadata maps for each resource.");
|
||||
for (SmartInstance resource : resources) {
|
||||
outputResource(resource);
|
||||
}
|
||||
println("# Section 2 size and type of all GeneralGridData.");
|
||||
Map<SmartInstance, Integer> sizes = new HashMap<SmartInstance, Integer>();
|
||||
if (useDataMap) {
|
||||
for (SmartInstance resource : resources) {
|
||||
int floats = 0;
|
||||
ConcurrentHashMap<SmartInstance, SmartInstance> dataMap = resource
|
||||
.get("dataMap").toConcurrentHashMap();
|
||||
if (!dataMap.isEmpty()) {
|
||||
println(resource + "{");
|
||||
for (Entry<SmartInstance, SmartInstance> dataEntry : dataMap
|
||||
.entrySet()) {
|
||||
List<SmartInstance> dataList = dataEntry.getValue()
|
||||
.toArrayList();
|
||||
for (SmartInstance gridData : dataList) {
|
||||
floats += outputGeneralGridData(gridData);
|
||||
}
|
||||
}
|
||||
println("}");
|
||||
}
|
||||
sizes.put(resource, floats);
|
||||
}
|
||||
} else {
|
||||
for (SmartInstance resource : resources) {
|
||||
int floats = 0;
|
||||
ArrayList<SmartInstance> requests = resource.get("requestJob")
|
||||
.get("requests").toArrayList();
|
||||
if (!requests.isEmpty()) {
|
||||
println(resource + "{");
|
||||
for (SmartInstance request : requests) {
|
||||
SmartInstance data = request.get("gridData");
|
||||
if (data != null) {
|
||||
List<SmartInstance> dataList = data.toArrayList();
|
||||
for (SmartInstance gridData : dataList) {
|
||||
floats += outputGeneralGridData(gridData);
|
||||
}
|
||||
}
|
||||
}
|
||||
println("}");
|
||||
}
|
||||
sizes.put(resource, floats);
|
||||
}
|
||||
}
|
||||
println("# Section 3 total size of each resource.");
|
||||
List<Entry<SmartInstance, Integer>> sizesList = new ArrayList<Entry<SmartInstance, Integer>>(
|
||||
sizes.entrySet());
|
||||
Collections.sort(sizesList,
|
||||
new Comparator<Entry<SmartInstance, Integer>>() {
|
||||
|
||||
@Override
|
||||
public int compare(Entry<SmartInstance, Integer> e1,
|
||||
Entry<SmartInstance, Integer> e2) {
|
||||
return e1.getValue().compareTo(e2.getValue());
|
||||
}
|
||||
});
|
||||
int totalFloats = 0;
|
||||
for (Entry<SmartInstance, Integer> entry : sizesList) {
|
||||
SmartInstance resource = entry.getKey();
|
||||
int floats = entry.getValue();
|
||||
int size = floats * 4 / 1024;
|
||||
String suffix = "KB";
|
||||
if (size > 1024) {
|
||||
size /= 1024;
|
||||
suffix = "MB";
|
||||
}
|
||||
println(resource + " uses is " + size + suffix);
|
||||
totalFloats += floats;
|
||||
}
|
||||
println("# Section 4 total size of all resources.");
|
||||
println("Total memory usage for " + resources.size()
|
||||
+ " resources is " + totalFloats * 4 / 1024 / 1024 + "MB");
|
||||
}
|
||||
|
||||
protected int outputGeneralGridData(SmartInstance generalGridData)
|
||||
throws IOException {
|
||||
println(" " + generalGridData + "{");
|
||||
SmartInstance gridGeometry = generalGridData.get("gridGeometry");
|
||||
SmartInstance gridRange = gridGeometry.get("gridRange");
|
||||
int[] index = gridRange.getIntArray("index");
|
||||
int width = index[2] - index[0];
|
||||
int height = index[3] - index[1];
|
||||
println(" dimensions are " + width + "x" + height + "");
|
||||
|
||||
int floats = 0;
|
||||
SmartInstance buffer = generalGridData.get("scalarData");
|
||||
if (buffer != null) {
|
||||
int capacity = buffer.getInt("capacity");
|
||||
println(" scalarData contains " + capacity + " floats.");
|
||||
floats += capacity;
|
||||
}
|
||||
buffer = generalGridData.get("direction");
|
||||
if (buffer != null) {
|
||||
int capacity = buffer.getInt("capacity");
|
||||
println(" direction contains " + capacity + " floats.");
|
||||
floats += capacity;
|
||||
}
|
||||
buffer = generalGridData.get("uComponent");
|
||||
if (buffer != null) {
|
||||
int capacity = buffer.getInt("capacity");
|
||||
println(" uComponent contains " + capacity + " floats.");
|
||||
floats += capacity;
|
||||
}
|
||||
buffer = generalGridData.get("vComponent");
|
||||
if (buffer != null) {
|
||||
int capacity = buffer.getInt("capacity");
|
||||
println(" vComponent contains " + capacity + " floats.");
|
||||
floats += capacity;
|
||||
}
|
||||
println(" memory usage is " + floats * 4 / 1024 + "KB");
|
||||
println(" }");
|
||||
return floats;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
/**
|
||||
* 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.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.raytheon.hprof.HprofFile;
|
||||
import com.raytheon.hprof.Id;
|
||||
import com.raytheon.hprof.SmartInstance;
|
||||
import com.raytheon.hprof.data.HeapDumpRecord;
|
||||
import com.raytheon.hprof.data.heap.BasicType;
|
||||
import com.raytheon.hprof.data.heap.dump.ClassDump;
|
||||
|
||||
/**
|
||||
*
|
||||
* Export information about D2DProcedures dialogs
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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<Id, BasicType> staticEntry : classDump.getStaticFields()
|
||||
.entrySet()) {
|
||||
String name = hprof.getString(staticEntry.getKey());
|
||||
if ("openDialogs".equals(name)) {
|
||||
openDialogs = new SmartInstance(hprof,
|
||||
heapDump.getInstance(staticEntry.getValue()
|
||||
.getObjectId()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
HashMap<String, SmartInstance> openDialogsMap = openDialogs
|
||||
.toStringKeyedHashMap();
|
||||
if (!openDialogsMap.isEmpty()) {
|
||||
println("ProcedureDlg.openDialogs{");
|
||||
for (Entry<String, SmartInstance> entry : openDialogsMap.entrySet()) {
|
||||
println(" " + entry.getKey() + " = " + entry.getValue());
|
||||
|
||||
}
|
||||
println("}\n");
|
||||
}
|
||||
|
||||
List<SmartInstance> dialogs = getInstances("com.raytheon.uf.viz.d2d.ui.dialogs.procedures.ProcedureDlg");
|
||||
for (SmartInstance dialog : dialogs) {
|
||||
outputProcedureDialog(dialog);
|
||||
}
|
||||
}
|
||||
|
||||
protected void outputProcedureDialog(SmartInstance dialog)
|
||||
throws IOException {
|
||||
|
||||
println(dialog + "{");
|
||||
println(" fileName = " + dialog.getString("fileName") + "");
|
||||
println("}");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
/**
|
||||
* 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.List;
|
||||
|
||||
import com.raytheon.hprof.HprofFile;
|
||||
import com.raytheon.hprof.SmartInstance;
|
||||
|
||||
/**
|
||||
*
|
||||
* Base class for exporters that want to display information about things in
|
||||
* DispalyPaneContainers/PaneManagers.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 8, 2014 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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<SmartInstance> editors = getInstances(className);
|
||||
for (SmartInstance editor : editors) {
|
||||
outputVizMultiPaneEditor(editor);
|
||||
}
|
||||
}
|
||||
|
||||
protected void outputSideViews() throws IOException {
|
||||
List<SmartInstance> views = getInstances("com.raytheon.uf.viz.d2d.ui.map.SideView");
|
||||
for (SmartInstance view : views) {
|
||||
outputSideView(view);
|
||||
}
|
||||
}
|
||||
|
||||
protected void outputVizMultiPaneEditor(SmartInstance editor)
|
||||
throws IOException {
|
||||
SmartInstance paneManager = editor.get("editorInput")
|
||||
.get("paneManager");
|
||||
|
||||
println(editor + "{");
|
||||
outputPaneManager(paneManager);
|
||||
println("}");
|
||||
}
|
||||
|
||||
protected void outputSideView(SmartInstance view) throws IOException {
|
||||
SmartInstance paneManager = view.get("paneManager");
|
||||
|
||||
println(view + "{");
|
||||
outputPaneManager(paneManager);
|
||||
println("}");
|
||||
}
|
||||
|
||||
protected abstract void outputPaneManager(SmartInstance paneManager)
|
||||
throws IOException;
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
/**
|
||||
* 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.List;
|
||||
|
||||
import com.raytheon.hprof.HprofFile;
|
||||
import com.raytheon.hprof.SmartInstance;
|
||||
|
||||
/**
|
||||
*
|
||||
* Export information about all the resources in display pane containers.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DisplayedResourcesExporter extends DisplayPaneContainerExporter {
|
||||
|
||||
private final List<SmartInstance> resources = new ArrayList<SmartInstance>();
|
||||
|
||||
public DisplayedResourcesExporter(HprofFile hprof, File outputDirectory) {
|
||||
super(hprof, outputDirectory);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFileName() {
|
||||
return "displayedResources.txt";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getComment() {
|
||||
StringBuilder comment = new StringBuilder();
|
||||
comment.append("# This file contains descriptors and resources of all the display pane containers\\n");
|
||||
comment.append("# (SideViews VizMapEditors, and VizXyEditors)\n");
|
||||
return comment.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getInfo() {
|
||||
return "Generating output for DisplayPaneContainer resources...";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void outputPaneManager(
|
||||
SmartInstance paneManager) throws IOException {
|
||||
List<SmartInstance> displayPanes = paneManager.get("displayPanes")
|
||||
.toArrayList();
|
||||
for (SmartInstance dispalyPane : displayPanes) {
|
||||
SmartInstance descriptor = dispalyPane.get("renderableDisplay")
|
||||
.get("descriptor");
|
||||
SmartInstance resourceList = descriptor.get("resourceList");
|
||||
SmartInstance[] array = resourceList.getObjectArray("array");
|
||||
println(" " + descriptor + "{");
|
||||
for (SmartInstance resourcePair : array) {
|
||||
SmartInstance resource = resourcePair.get("resource");
|
||||
if (resource == null) {
|
||||
SmartInstance resourceData = resourcePair
|
||||
.get("resourceData");
|
||||
if (resourceData == null) {
|
||||
println(" Empty Resource Pair");
|
||||
} else {
|
||||
println(" " + resourceData + "(resource was null)");
|
||||
}
|
||||
} else {
|
||||
println(" " + resource);
|
||||
resources.add(resource);
|
||||
}
|
||||
}
|
||||
println(" }");
|
||||
}
|
||||
}
|
||||
public List<SmartInstance> getResources() {
|
||||
return resources;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
* 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.List;
|
||||
|
||||
import com.raytheon.hprof.HprofFile;
|
||||
import com.raytheon.hprof.SmartInstance;
|
||||
|
||||
/**
|
||||
*
|
||||
* Export information about GFEResources, really just the parmId at this point.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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<SmartInstance> resources = getInstances("com.raytheon.viz.gfe.rsc.GFEResource");
|
||||
if (resources.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (SmartInstance resource : resources) {
|
||||
println(resource + "{");
|
||||
println(" parmID = "
|
||||
+ resource.get("parm").get("gridInfo").get("parmID")
|
||||
.getString("parmId"));
|
||||
println("}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
/**
|
||||
* 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.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.raytheon.hprof.HprofFile;
|
||||
import com.raytheon.hprof.Id;
|
||||
import com.raytheon.hprof.SmartInstance;
|
||||
import com.raytheon.hprof.data.HeapDumpRecord;
|
||||
import com.raytheon.hprof.data.heap.BasicType;
|
||||
import com.raytheon.hprof.data.heap.dump.ClassDump;
|
||||
|
||||
/**
|
||||
*
|
||||
* Export information about openGl memory useage.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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<Id, BasicType> staticEntry : classDump.getStaticFields()
|
||||
.entrySet()) {
|
||||
String name = hprof.getString(staticEntry.getKey());
|
||||
if ("textureCache".equals(name)) {
|
||||
textureCache = new SmartInstance(hprof,
|
||||
heapDump.getInstance(staticEntry.getValue()
|
||||
.getObjectId()));
|
||||
} else if ("memoryCache".equals(name)) {
|
||||
memoryCache = new SmartInstance(hprof,
|
||||
heapDump.getInstance(staticEntry.getValue()
|
||||
.getObjectId()));
|
||||
}
|
||||
}
|
||||
long memUsed = memoryCache.getLong("curSize");
|
||||
long memMax = memoryCache.getLong("maxSize");
|
||||
long texUsed = textureCache.getLong("curSize");
|
||||
long texMax = textureCache.getLong("maxSize");
|
||||
println("RAM texture cache using " + (memUsed / 1024 / 1024) + "MB of "
|
||||
+ (memMax / 1024 / 1024) + "MB");
|
||||
println("GL texture cache using " + (texUsed / 1024 / 1024) + "MB of "
|
||||
+ (texMax / 1024 / 1024) + "MB");
|
||||
List<SmartInstance> geoms = getInstances("com.raytheon.viz.core.gl.GLGeometryObject2D");
|
||||
int coords = 0;
|
||||
for (SmartInstance geom : geoms) {
|
||||
SmartInstance lengthBuffer = geom.get("compiledLengths");
|
||||
if (lengthBuffer != null) {
|
||||
int[] lengthArr = lengthBuffer.getIntArray("hb");
|
||||
for (int length : lengthArr) {
|
||||
coords += length;
|
||||
}
|
||||
}
|
||||
}
|
||||
println("GL vbo size(estimate) is " + (coords * 2 * 4 / 1024 / 1024)
|
||||
+ "MB");
|
||||
}
|
||||
|
||||
}
|
|
@ -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.uf.viz.hprof;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.hprof.HprofFile;
|
||||
import com.raytheon.hprof.SmartInstance;
|
||||
|
||||
/**
|
||||
*
|
||||
* Outputs all input handlers for all pane managers. The most useful thing this
|
||||
* can be used for is checking if pan tool is active.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @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<SmartInstance> handlers = paneManager.get("inputManager")
|
||||
.get("handlers").toArrayList();
|
||||
|
||||
if (!handlers.isEmpty()) {
|
||||
println(" InputManager{");
|
||||
for (SmartInstance phandler : handlers) {
|
||||
SmartInstance handler = phandler.get("handler");
|
||||
println(" " + handler);
|
||||
}
|
||||
println(" }");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/**
|
||||
* 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.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.raytheon.hprof.HprofFile;
|
||||
import com.raytheon.hprof.SmartInstance;
|
||||
|
||||
/**
|
||||
*
|
||||
* Outputs metadata map for all requestable resource datas.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 08, 2014 2648 bsteffen Initial doc
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class RequestableResourceExporter extends AbstractExporter {
|
||||
|
||||
private final List<SmartInstance> resources;
|
||||
|
||||
public RequestableResourceExporter(HprofFile hprof, File outputDirectory,
|
||||
List<SmartInstance> resources) {
|
||||
super(hprof, outputDirectory);
|
||||
this.resources = resources;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFileName() {
|
||||
return "requestableResources.txt";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getComment() {
|
||||
StringBuilder comment = new StringBuilder();
|
||||
comment
|
||||
.append("# This file contains the metadataMap for all resources that are on containers found in\n");
|
||||
comment
|
||||
.append("# displayPaneContainers.txt. Keys and values which are interned constants are not always\n");
|
||||
comment.append("# saved to the heap and might not output pretty.");
|
||||
return comment.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getInfo() {
|
||||
return "Generating output for RequestableResources...";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void exportInternal() throws IOException {
|
||||
for (SmartInstance resource : resources) {
|
||||
outputResource(resource);
|
||||
}
|
||||
}
|
||||
|
||||
protected void outputResource(SmartInstance resource)
|
||||
throws IOException {
|
||||
if (resource == null) {
|
||||
return;
|
||||
}
|
||||
SmartInstance resourceData = resource.get("resourceData");
|
||||
if (resourceData == null) {
|
||||
println(resource + "{");
|
||||
println(" No resourceData available.");
|
||||
println("}");
|
||||
return;
|
||||
}
|
||||
SmartInstance metadataMap = resourceData.get(
|
||||
"metadataMap");
|
||||
if (metadataMap == null) {
|
||||
return;
|
||||
}
|
||||
println(resource + "{");
|
||||
outputMetadataMap(metadataMap);
|
||||
println("}");
|
||||
}
|
||||
|
||||
protected void outputMetadataMap(SmartInstance metadataMap)
|
||||
throws IOException {
|
||||
for (Entry<String, SmartInstance> entry : metadataMap
|
||||
.toStringKeyedHashMap().entrySet()) {
|
||||
String key = entry.getKey();
|
||||
SmartInstance value = entry.getValue();
|
||||
SmartInstance constraintType = value.get("constraintType");
|
||||
int ordinal = constraintType.getInt("ordinal");
|
||||
String constraintValue = value.getString("constraintValue");
|
||||
String operand = "";
|
||||
switch (ordinal) {
|
||||
case 0:
|
||||
operand = "=";
|
||||
break;
|
||||
case 1:
|
||||
operand = "!=";
|
||||
break;
|
||||
case 2:
|
||||
operand = ">";
|
||||
break;
|
||||
case 3:
|
||||
operand = ">=";
|
||||
break;
|
||||
case 4:
|
||||
operand = "<";
|
||||
break;
|
||||
case 5:
|
||||
operand = "<=";
|
||||
break;
|
||||
case 6:
|
||||
operand = "between";
|
||||
break;
|
||||
case 7:
|
||||
operand = "in";
|
||||
break;
|
||||
case 8:
|
||||
operand = "like";
|
||||
break;
|
||||
case 9:
|
||||
operand = "ilike";
|
||||
break;
|
||||
case 10:
|
||||
operand = "isnull";
|
||||
break;
|
||||
case 11:
|
||||
operand = "isnotnull";
|
||||
break;
|
||||
}
|
||||
println(" " + key + " " + operand + " " + constraintValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue