You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kato-commits@incubator.apache.org by mo...@apache.org on 2009/11/23 15:54:15 UTC
svn commit: r883384 [13/47] - in /incubator/kato/trunk/org.apache.kato: ./
kato.anttasks/src/main/java/org/apache/kato/anttasks/
kato.anttasks/src/main/java/org/apache/kato/anttasks/sitebuilder/
kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/...
Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/test/java/test/apache/kato/hprof/image/TestImagePointer.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/test/java/test/apache/kato/hprof/image/TestImagePointer.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/test/java/test/apache/kato/hprof/image/TestImagePointer.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/test/java/test/apache/kato/hprof/image/TestImagePointer.java Mon Nov 23 15:53:48 2009
@@ -1,183 +1,183 @@
-/*******************************************************************************
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-package test.apache.kato.hprof.image;
-
-import java.io.IOException;
-
-import javax.tools.diagnostics.image.CorruptDataException;
-import javax.tools.diagnostics.image.DataUnavailable;
-import javax.tools.diagnostics.image.ImageAddressSpace;
-import javax.tools.diagnostics.image.ImagePointer;
-import javax.tools.diagnostics.image.MemoryAccessException;
-
-
-public class TestImagePointer extends AbstractHProfTestCase {
-
- ImageAddressSpace space;
- ImagePointer pointer1;
- static final long address1 = 0xfefeededdcdccbcbL;
-
- public void setUp() throws IOException {
- space = getFirstAddressSpace();
- pointer1 = space.getPointer(address1);
- }
-
- public void testGetAddress() throws Exception {
- assertEquals(address1, pointer1.getAddress());
- }
-
- public void testAdd() throws Exception {
- ImagePointer pointer2 = pointer1.add(7);
-
- assertEquals(address1+7, pointer2.getAddress());
- }
-
- public void testIsExecutable() throws Exception {
- try {
- pointer1.isExecutable();
- fail("DataUnavailable should be thrown.");
- } catch (DataUnavailable e) {
- // Expected
- }
- }
-
- public void testIsReadOnly() throws Exception {
- try {
- pointer1.isReadOnly();
- fail("DataUnavailable should be thrown.");
- } catch (DataUnavailable e) {
- // Expected
- }
- }
- public void testIsShared() throws Exception {
- try {
- pointer1.isShared();
- fail("DataUnavailable should be thrown.");
- } catch (DataUnavailable e) {
- // Expected
- }
- }
-
- public void testGetAddressSpace() throws Exception {
- assertEquals(space, pointer1.getAddressSpace());
- }
-
- public void testGetByteAt() throws Exception {
- try {
- pointer1.getByteAt(0);
- fail("Expected MemoryAccessException");
- } catch (MemoryAccessException e) {
- // expected
- } catch (CorruptDataException e) {
- fail("Expected MemoryAccessException");
- }
- }
-
- public void testGetDoubleAt() throws Exception {
- try {
- pointer1.getDoubleAt(0);
- fail("Expected MemoryAccessException");
- } catch (MemoryAccessException e) {
- // expected
- } catch (CorruptDataException e) {
- fail("Expected MemoryAccessException");
- }
- }
-
- public void testGetFloatAt() throws Exception {
- try {
- pointer1.getFloatAt(0);
- fail("Expected MemoryAccessException");
- } catch (MemoryAccessException e) {
- // expected
- } catch (CorruptDataException e) {
- fail("Expected MemoryAccessException");
- }
- }
-
- public void testGetIntAt() throws Exception {
- try {
- pointer1.getIntAt(0);
- fail("Expected MemoryAccessException");
- } catch (MemoryAccessException e) {
- // expected
- } catch (CorruptDataException e) {
- fail("Expected MemoryAccessException");
- }
- }
-
- public void testGetLongAt() throws Exception {
- try {
- pointer1.getLongAt(0);
- fail("Expected MemoryAccessException");
- } catch (MemoryAccessException e) {
- // expected
- } catch (CorruptDataException e) {
- fail("Expected MemoryAccessException");
- }
- }
-
- public void testGetShortAt() throws Exception {
- try {
- pointer1.getShortAt(0);
- fail("Expected MemoryAccessException");
- } catch (MemoryAccessException e) {
- // expected
- } catch (CorruptDataException e) {
- fail("Expected MemoryAccessException");
- }
- }
-
- public void testGetPointerAt() throws Exception {
- try {
- pointer1.getPointerAt(0);
- fail("Expected MemoryAccessException");
- } catch (MemoryAccessException e) {
- // expected
- } catch (CorruptDataException e) {
- fail("Expected MemoryAccessException");
- }
- }
-
- public void testEqualsNull() throws Exception {
- assertFalse(pointer1.equals(null));
- }
-
- public void testEqualsString() throws Exception {
- assertFalse(pointer1.equals("Hello"));
- }
-
- public void testEqualsSelf() throws Exception {
- assertTrue(pointer1.equals(pointer1));
- }
-
- public void testEqualsLike() throws Exception {
- ImagePointer pointer2 = space.getPointer(address1);
-
- assertTrue(pointer1.equals(pointer2));
- }
-
- public void testEqualsDifferent() throws Exception {
- ImagePointer pointer2 = space.getPointer(0x2983474);
-
- assertFalse(pointer1.equals(pointer2));
- }
-
- public void testHashCode() throws Exception {
- ImagePointer pointer2 = space.getPointer(address1);
- assertEquals(pointer1.hashCode(), pointer2.hashCode());
- }
-
-
-}
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package test.apache.kato.hprof.image;
+
+import java.io.IOException;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.image.ImageAddressSpace;
+import javax.tools.diagnostics.image.ImagePointer;
+import javax.tools.diagnostics.image.MemoryAccessException;
+
+
+public class TestImagePointer extends AbstractHProfTestCase {
+
+ ImageAddressSpace space;
+ ImagePointer pointer1;
+ static final long address1 = 0xfefeededdcdccbcbL;
+
+ public void setUp() throws IOException {
+ space = getFirstAddressSpace();
+ pointer1 = space.getPointer(address1);
+ }
+
+ public void testGetAddress() throws Exception {
+ assertEquals(address1, pointer1.getAddress());
+ }
+
+ public void testAdd() throws Exception {
+ ImagePointer pointer2 = pointer1.add(7);
+
+ assertEquals(address1+7, pointer2.getAddress());
+ }
+
+ public void testIsExecutable() throws Exception {
+ try {
+ pointer1.isExecutable();
+ fail("DataUnavailable should be thrown.");
+ } catch (DataUnavailable e) {
+ // Expected
+ }
+ }
+
+ public void testIsReadOnly() throws Exception {
+ try {
+ pointer1.isReadOnly();
+ fail("DataUnavailable should be thrown.");
+ } catch (DataUnavailable e) {
+ // Expected
+ }
+ }
+ public void testIsShared() throws Exception {
+ try {
+ pointer1.isShared();
+ fail("DataUnavailable should be thrown.");
+ } catch (DataUnavailable e) {
+ // Expected
+ }
+ }
+
+ public void testGetAddressSpace() throws Exception {
+ assertEquals(space, pointer1.getAddressSpace());
+ }
+
+ public void testGetByteAt() throws Exception {
+ try {
+ pointer1.getByteAt(0);
+ fail("Expected MemoryAccessException");
+ } catch (MemoryAccessException e) {
+ // expected
+ } catch (CorruptDataException e) {
+ fail("Expected MemoryAccessException");
+ }
+ }
+
+ public void testGetDoubleAt() throws Exception {
+ try {
+ pointer1.getDoubleAt(0);
+ fail("Expected MemoryAccessException");
+ } catch (MemoryAccessException e) {
+ // expected
+ } catch (CorruptDataException e) {
+ fail("Expected MemoryAccessException");
+ }
+ }
+
+ public void testGetFloatAt() throws Exception {
+ try {
+ pointer1.getFloatAt(0);
+ fail("Expected MemoryAccessException");
+ } catch (MemoryAccessException e) {
+ // expected
+ } catch (CorruptDataException e) {
+ fail("Expected MemoryAccessException");
+ }
+ }
+
+ public void testGetIntAt() throws Exception {
+ try {
+ pointer1.getIntAt(0);
+ fail("Expected MemoryAccessException");
+ } catch (MemoryAccessException e) {
+ // expected
+ } catch (CorruptDataException e) {
+ fail("Expected MemoryAccessException");
+ }
+ }
+
+ public void testGetLongAt() throws Exception {
+ try {
+ pointer1.getLongAt(0);
+ fail("Expected MemoryAccessException");
+ } catch (MemoryAccessException e) {
+ // expected
+ } catch (CorruptDataException e) {
+ fail("Expected MemoryAccessException");
+ }
+ }
+
+ public void testGetShortAt() throws Exception {
+ try {
+ pointer1.getShortAt(0);
+ fail("Expected MemoryAccessException");
+ } catch (MemoryAccessException e) {
+ // expected
+ } catch (CorruptDataException e) {
+ fail("Expected MemoryAccessException");
+ }
+ }
+
+ public void testGetPointerAt() throws Exception {
+ try {
+ pointer1.getPointerAt(0);
+ fail("Expected MemoryAccessException");
+ } catch (MemoryAccessException e) {
+ // expected
+ } catch (CorruptDataException e) {
+ fail("Expected MemoryAccessException");
+ }
+ }
+
+ public void testEqualsNull() throws Exception {
+ assertFalse(pointer1.equals(null));
+ }
+
+ public void testEqualsString() throws Exception {
+ assertFalse(pointer1.equals("Hello"));
+ }
+
+ public void testEqualsSelf() throws Exception {
+ assertTrue(pointer1.equals(pointer1));
+ }
+
+ public void testEqualsLike() throws Exception {
+ ImagePointer pointer2 = space.getPointer(address1);
+
+ assertTrue(pointer1.equals(pointer2));
+ }
+
+ public void testEqualsDifferent() throws Exception {
+ ImagePointer pointer2 = space.getPointer(0x2983474);
+
+ assertFalse(pointer1.equals(pointer2));
+ }
+
+ public void testHashCode() throws Exception {
+ ImagePointer pointer2 = space.getPointer(address1);
+ assertEquals(pointer1.hashCode(), pointer2.hashCode());
+ }
+
+
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/test/java/test/apache/kato/hprof/image/TestImagePointer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/test/java/test/apache/kato/hprof/image/TestImageProcess.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/test/java/test/apache/kato/hprof/java/TestJavaHeap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.api/src/test/java/test/apache/kato/hprof/java/TestJavaRuntime.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HPROFFormattedReporter.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HPROFFormattedReporter.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HPROFFormattedReporter.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HPROFFormattedReporter.java Mon Nov 23 15:53:48 2009
@@ -1,215 +1,215 @@
-/*******************************************************************************
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-package org.apache.kato.hprof;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.apache.kato.hprof.datalayer.HProfFactory;
-import org.apache.kato.hprof.datalayer.HProfFile;
-import org.apache.kato.hprof.datalayer.IControlSettingsHProfRecord;
-import org.apache.kato.hprof.datalayer.IHProfRecord;
-import org.apache.kato.hprof.datalayer.IHeapDumpHProfRecord;
-import org.apache.kato.hprof.datalayer.IJavaStackFrameHProfRecord;
-import org.apache.kato.hprof.datalayer.IJavaStackTraceHProfRecord;
-import org.apache.kato.hprof.datalayer.ILoadClassHProfRecord;
-import org.apache.kato.hprof.datalayer.IUTF8HProfRecord;
-
-
-public class HPROFFormattedReporter {
-
-
- private PrintStream out=System.out;
- private Map<Integer,Counter> stats=new TreeMap<Integer,Counter>();
- private TreeSet<String> labels=new TreeSet<String>();
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- //File dump=new File("C:/Documents and Settings/spoole/workspace/HProf Binary Format Reader/data/java.hprof");
- HPROFFormattedReporter reporter=new HPROFFormattedReporter();
- File hprofFile=new File(args[0]);
-
- try {
- reporter.report(hprofFile);
- } catch (IOException e) {
-
- e.printStackTrace();
- }
-
-
- }
-
- public void report(File dump) throws IOException {
-
- HProfFile h=HProfFactory.createReader(dump);
-
- h.open();
-
- String header=h.getHeader();
- int idSize=h.getIdentifierSize();
- long timeStamp=h.getTimeStamp();
-
- out.println("HPROF : "+header);
- out.println("ID SIZE : "+idSize);
- out.println("TIMESTAMP: "+timeStamp);
-
- int counter=0;
- while(true) {
-
- IHProfRecord record=h.getRecord(counter);
- if(record==null) break;
- report(record);
- counter++;
- }
-
- reportStats();
- out.println("Report completed. "+counter+" records");
-
- h.close();
-
-
- }
-
- private void reportStats() {
- for(Integer i:stats.keySet()) {
- Counter c=stats.get(i);
- out.println("tag "+Integer.toHexString(i)+" occurs "+c.count+" time(s)");
- }
-
- }
-
- private void report(IHProfRecord record) {
- int tag=record.getTag();
- accumulateStatistics(tag);
- out.println("----------------------------------------- "+toHex(tag)+":"+record.getDataLength());
- switch(tag) {
-
- case 0x01: IUTF8HProfRecord utf8Record=(IUTF8HProfRecord)record;
- reportUTF8(utf8Record);
- break;
-
- case 0x02: ILoadClassHProfRecord loadClass=(ILoadClassHProfRecord)record;
- reportLoadClass(loadClass);
- break;
-
- case 0x04: IJavaStackFrameHProfRecord frameRecord=(IJavaStackFrameHProfRecord)record;
- reportFrameRecord(frameRecord);
- break;
-
- case 0x05: IJavaStackTraceHProfRecord traceRecord=(IJavaStackTraceHProfRecord)record;
- reportTraceRecord(traceRecord);
- break;
-
- case 0x0C: IHeapDumpHProfRecord dumpRecord = (IHeapDumpHProfRecord)record;
- reportHeapDump(dumpRecord);
- break;
- case 0x0E: IControlSettingsHProfRecord settings=(IControlSettingsHProfRecord) record;
- reportSettings(settings);
- break;
-
- }
-
- }
-
- private void reportFrameRecord(IJavaStackFrameHProfRecord record) {
-
- out.println("frame - stack frame id :"+toHex(record.getStackFrameID()));
- out.println("frame - method name id :"+toHex(record.getMethodNameID()));
- out.println("frame - method signature id :"+toHex(record.getMethodSignatureID()));
- out.println("frame - source file name id :"+toHex(record.getSourceFileNameID()));
- out.println("frame - class serial number :"+record.getClassSerialNumber());
- out.println("frame - line number :"+record.getLineNumber());
- }
-
-
- private String toHex(long h) {
- return HProfRecordFormatter.toHex(h);
- }
-
- private void reportLoadClass(ILoadClassHProfRecord loadClass) {
- out.println("load class - class serial number : "+loadClass.getClassSerialNumber());
- out.println("load class - object ID : "+toHex(loadClass.getClassObjectID()));
- out.println("load class - stack trace serial number : "+loadClass.getStackTraceSerialNumber());
- out.println("load class - class Name ID : "+toHex(loadClass.getClassNameID()));
- }
-
- private void reportUTF8(IUTF8HProfRecord utf8Record) {
-
- try {
- String label=new String(utf8Record.getCharacters(),"UTF-8");
- if(labels.contains(label)) {
- int a=1;
- }
- out.println("utf8 record id: "+toHex(utf8Record.getNameID())+" data: ["+label+"]");
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- private void reportTraceRecord(IJavaStackTraceHProfRecord traceRecord) {
- out.println("stack trace serial number: "+traceRecord.getSerialNumber());
- out.println("frame count: "+traceRecord.getFrameCount());
-
- }
-
- private void reportHeapDump(IHeapDumpHProfRecord dumpRecord) {
- out.println("dump record");
- int index=0;
- while(true) {
- Object record=dumpRecord.getSubRecord(index);
- if(record==null) break;
- out.println(">>"+record);
- index++;
- }
-
- }
-
- private void accumulateStatistics(int tag) {
-
- Counter c=null;
- if(stats.containsKey(tag)) {
- c=stats.get(tag);
- }
- else {
- c=new Counter();
- stats.put(tag,c);
- }
- c.count++;
- }
-
- private void reportSettings(IControlSettingsHProfRecord settings) {
-
- out.println("Is AllocTrace:"+settings.isAllocTrace());
- out.println("Is CPUSampling:"+settings.isCpuSampling());
- out.println("Stack Trace Depth:"+settings.getStackTraceDepth());
-
- }
-
- public HPROFFormattedReporter() {
-
- }
-
- class Counter {
- int count=0;
- }
-}
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.hprof;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.apache.kato.hprof.datalayer.HProfFactory;
+import org.apache.kato.hprof.datalayer.HProfFile;
+import org.apache.kato.hprof.datalayer.IControlSettingsHProfRecord;
+import org.apache.kato.hprof.datalayer.IHProfRecord;
+import org.apache.kato.hprof.datalayer.IHeapDumpHProfRecord;
+import org.apache.kato.hprof.datalayer.IJavaStackFrameHProfRecord;
+import org.apache.kato.hprof.datalayer.IJavaStackTraceHProfRecord;
+import org.apache.kato.hprof.datalayer.ILoadClassHProfRecord;
+import org.apache.kato.hprof.datalayer.IUTF8HProfRecord;
+
+
+public class HPROFFormattedReporter {
+
+
+ private PrintStream out=System.out;
+ private Map<Integer,Counter> stats=new TreeMap<Integer,Counter>();
+ private TreeSet<String> labels=new TreeSet<String>();
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+
+ //File dump=new File("C:/Documents and Settings/spoole/workspace/HProf Binary Format Reader/data/java.hprof");
+ HPROFFormattedReporter reporter=new HPROFFormattedReporter();
+ File hprofFile=new File(args[0]);
+
+ try {
+ reporter.report(hprofFile);
+ } catch (IOException e) {
+
+ e.printStackTrace();
+ }
+
+
+ }
+
+ public void report(File dump) throws IOException {
+
+ HProfFile h=HProfFactory.createReader(dump);
+
+ h.open();
+
+ String header=h.getHeader();
+ int idSize=h.getIdentifierSize();
+ long timeStamp=h.getTimeStamp();
+
+ out.println("HPROF : "+header);
+ out.println("ID SIZE : "+idSize);
+ out.println("TIMESTAMP: "+timeStamp);
+
+ int counter=0;
+ while(true) {
+
+ IHProfRecord record=h.getRecord(counter);
+ if(record==null) break;
+ report(record);
+ counter++;
+ }
+
+ reportStats();
+ out.println("Report completed. "+counter+" records");
+
+ h.close();
+
+
+ }
+
+ private void reportStats() {
+ for(Integer i:stats.keySet()) {
+ Counter c=stats.get(i);
+ out.println("tag "+Integer.toHexString(i)+" occurs "+c.count+" time(s)");
+ }
+
+ }
+
+ private void report(IHProfRecord record) {
+ int tag=record.getTag();
+ accumulateStatistics(tag);
+ out.println("----------------------------------------- "+toHex(tag)+":"+record.getDataLength());
+ switch(tag) {
+
+ case 0x01: IUTF8HProfRecord utf8Record=(IUTF8HProfRecord)record;
+ reportUTF8(utf8Record);
+ break;
+
+ case 0x02: ILoadClassHProfRecord loadClass=(ILoadClassHProfRecord)record;
+ reportLoadClass(loadClass);
+ break;
+
+ case 0x04: IJavaStackFrameHProfRecord frameRecord=(IJavaStackFrameHProfRecord)record;
+ reportFrameRecord(frameRecord);
+ break;
+
+ case 0x05: IJavaStackTraceHProfRecord traceRecord=(IJavaStackTraceHProfRecord)record;
+ reportTraceRecord(traceRecord);
+ break;
+
+ case 0x0C: IHeapDumpHProfRecord dumpRecord = (IHeapDumpHProfRecord)record;
+ reportHeapDump(dumpRecord);
+ break;
+ case 0x0E: IControlSettingsHProfRecord settings=(IControlSettingsHProfRecord) record;
+ reportSettings(settings);
+ break;
+
+ }
+
+ }
+
+ private void reportFrameRecord(IJavaStackFrameHProfRecord record) {
+
+ out.println("frame - stack frame id :"+toHex(record.getStackFrameID()));
+ out.println("frame - method name id :"+toHex(record.getMethodNameID()));
+ out.println("frame - method signature id :"+toHex(record.getMethodSignatureID()));
+ out.println("frame - source file name id :"+toHex(record.getSourceFileNameID()));
+ out.println("frame - class serial number :"+record.getClassSerialNumber());
+ out.println("frame - line number :"+record.getLineNumber());
+ }
+
+
+ private String toHex(long h) {
+ return HProfRecordFormatter.toHex(h);
+ }
+
+ private void reportLoadClass(ILoadClassHProfRecord loadClass) {
+ out.println("load class - class serial number : "+loadClass.getClassSerialNumber());
+ out.println("load class - object ID : "+toHex(loadClass.getClassObjectID()));
+ out.println("load class - stack trace serial number : "+loadClass.getStackTraceSerialNumber());
+ out.println("load class - class Name ID : "+toHex(loadClass.getClassNameID()));
+ }
+
+ private void reportUTF8(IUTF8HProfRecord utf8Record) {
+
+ try {
+ String label=new String(utf8Record.getCharacters(),"UTF-8");
+ if(labels.contains(label)) {
+ int a=1;
+ }
+ out.println("utf8 record id: "+toHex(utf8Record.getNameID())+" data: ["+label+"]");
+ } catch (UnsupportedEncodingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ private void reportTraceRecord(IJavaStackTraceHProfRecord traceRecord) {
+ out.println("stack trace serial number: "+traceRecord.getSerialNumber());
+ out.println("frame count: "+traceRecord.getFrameCount());
+
+ }
+
+ private void reportHeapDump(IHeapDumpHProfRecord dumpRecord) {
+ out.println("dump record");
+ int index=0;
+ while(true) {
+ Object record=dumpRecord.getSubRecord(index);
+ if(record==null) break;
+ out.println(">>"+record);
+ index++;
+ }
+
+ }
+
+ private void accumulateStatistics(int tag) {
+
+ Counter c=null;
+ if(stats.containsKey(tag)) {
+ c=stats.get(tag);
+ }
+ else {
+ c=new Counter();
+ stats.put(tag,c);
+ }
+ c.count++;
+ }
+
+ private void reportSettings(IControlSettingsHProfRecord settings) {
+
+ out.println("Is AllocTrace:"+settings.isAllocTrace());
+ out.println("Is CPUSampling:"+settings.isCpuSampling());
+ out.println("Stack Trace Depth:"+settings.getStackTraceDepth());
+
+ }
+
+ public HPROFFormattedReporter() {
+
+ }
+
+ class Counter {
+ int count=0;
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HPROFFormattedReporter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HPROFUTF8Reporter.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HPROFUTF8Reporter.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HPROFUTF8Reporter.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HPROFUTF8Reporter.java Mon Nov 23 15:53:48 2009
@@ -1,114 +1,114 @@
-/*******************************************************************************
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-package org.apache.kato.hprof;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.apache.kato.hprof.datalayer.HProfFactory;
-import org.apache.kato.hprof.datalayer.HProfFile;
-import org.apache.kato.hprof.datalayer.IHProfRecord;
-import org.apache.kato.hprof.datalayer.IUTF8HProfRecord;
-
-public class HPROFUTF8Reporter {
-
-
- private PrintStream out=System.out;
- private Map<Integer,Counter> stats=new TreeMap<Integer,Counter>();
- private TreeSet<String> labels=new TreeSet<String>();
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- //File dump=new File("C:/Documents and Settings/spoole/workspace/HProf Binary Format Reader/data/java.hprof");
- HPROFUTF8Reporter reporter=new HPROFUTF8Reporter();
- File hprofFile=new File(args[0]);
-
- try {
- reporter.report(hprofFile);
- } catch (IOException e) {
-
- e.printStackTrace();
- }
-
-
- }
-
- public void report(File dump) throws IOException {
-
- HProfFile h=HProfFactory.createReader(dump);
-
- h.open();
-
-
- int counter=0;
- while(true) {
- IHProfRecord record=h.getRecord(counter);
- if(record==null) break;
- report(record);
- counter++;
- }
-
-
- h.close();
-
-
- }
-
- private void report(IHProfRecord record) {
- int tag=record.getTag();
-
- switch(tag) {
-
- case 0x01: IUTF8HProfRecord utf8Record=(IUTF8HProfRecord)record;
- reportUTF8(utf8Record);
- break;
-
-
- }
-
- }
-
- private static String toHex(long v) {
- return "0x"+Long.toHexString(v);
- }
- private void reportUTF8(IUTF8HProfRecord utf8Record) {
-
- try {
- String label=new String(utf8Record.getCharacters(),"UTF-8");
- if(labels.contains(label)) {
- int a=1;
- }
- out.println(label);
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- public HPROFUTF8Reporter() {
-
- }
-
- class Counter {
- int count=0;
- }
-}
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.hprof;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.apache.kato.hprof.datalayer.HProfFactory;
+import org.apache.kato.hprof.datalayer.HProfFile;
+import org.apache.kato.hprof.datalayer.IHProfRecord;
+import org.apache.kato.hprof.datalayer.IUTF8HProfRecord;
+
+public class HPROFUTF8Reporter {
+
+
+ private PrintStream out=System.out;
+ private Map<Integer,Counter> stats=new TreeMap<Integer,Counter>();
+ private TreeSet<String> labels=new TreeSet<String>();
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+
+ //File dump=new File("C:/Documents and Settings/spoole/workspace/HProf Binary Format Reader/data/java.hprof");
+ HPROFUTF8Reporter reporter=new HPROFUTF8Reporter();
+ File hprofFile=new File(args[0]);
+
+ try {
+ reporter.report(hprofFile);
+ } catch (IOException e) {
+
+ e.printStackTrace();
+ }
+
+
+ }
+
+ public void report(File dump) throws IOException {
+
+ HProfFile h=HProfFactory.createReader(dump);
+
+ h.open();
+
+
+ int counter=0;
+ while(true) {
+ IHProfRecord record=h.getRecord(counter);
+ if(record==null) break;
+ report(record);
+ counter++;
+ }
+
+
+ h.close();
+
+
+ }
+
+ private void report(IHProfRecord record) {
+ int tag=record.getTag();
+
+ switch(tag) {
+
+ case 0x01: IUTF8HProfRecord utf8Record=(IUTF8HProfRecord)record;
+ reportUTF8(utf8Record);
+ break;
+
+
+ }
+
+ }
+
+ private static String toHex(long v) {
+ return "0x"+Long.toHexString(v);
+ }
+ private void reportUTF8(IUTF8HProfRecord utf8Record) {
+
+ try {
+ String label=new String(utf8Record.getCharacters(),"UTF-8");
+ if(labels.contains(label)) {
+ int a=1;
+ }
+ out.println(label);
+ } catch (UnsupportedEncodingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ public HPROFUTF8Reporter() {
+
+ }
+
+ class Counter {
+ int count=0;
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HPROFUTF8Reporter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HProfRecordFormatter.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HProfRecordFormatter.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HProfRecordFormatter.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HProfRecordFormatter.java Mon Nov 23 15:53:48 2009
@@ -1,182 +1,182 @@
-/*******************************************************************************
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-package org.apache.kato.hprof;
-
-import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
-
-import org.apache.kato.hprof.datalayer.HProfFile;
-import org.apache.kato.hprof.datalayer.IHProfRecord;
-import org.apache.kato.hprof.datalayer.ILoadClassHProfRecord;
-import org.apache.kato.hprof.datalayer.IUTF8HProfRecord;
-
-public class HProfRecordFormatter {
-
- private static final String hexChars="0123456789ABCDEF";
- private HProfFile prof=null;
- HashMap<Long, Integer> utf8s=null;
-
-
- public HProfRecordFormatter(HProfFile prof, HashMap<Long, Integer> utf8s) {
- this.prof=prof;
- this.utf8s=utf8s;
- }
- public String formatData(IHProfRecord o) {
-
- int tag=o.getTag();
-
- switch(tag) {
-
- case 0x01 : return formatUTF8Data((IUTF8HProfRecord)o);
- case 0x02: return formatLoadCLass((ILoadClassHProfRecord)o);
- case 0x04: return "Frame";
- case 0x05: return "Trace";
- case 0x0A: return "Thread Start";
- case 0x0B: return "Thread End";
- case 0x0C: return "HeapDump";
- case 0x0E: return "Settings";
-
- }
-
- return "";
- }
-
- public String formatLoadCLass(ILoadClassHProfRecord o) {
-
- long id=o.getClassNameID();
- long classID=o.getClassObjectID();
- long serialNo=o.getClassSerialNumber();
- long stackSerial=o.getStackTraceSerialNumber();
-
- String className="";
- if(utf8s.containsKey(id)) {
- int ref=utf8s.get(id);
- className=getName(ref);
- if(className==null) className="";
- else className="("+className+")";
- }
- return "classNameID="+toHex(id)+className+" objectid="+toHex(classID)+" serialNo="+toHex(serialNo)+" stackSerial="+toHex(stackSerial);
- }
-
- public String getName(Long id) {
- if(utf8s.containsKey(id)==false) return null;
- int ref=utf8s.get(id);
- return getName(ref);
- }
- private String getName(int ref) {
- IHProfRecord record=prof.getRecord(ref);
-
- if(record instanceof IUTF8HProfRecord) {
- IUTF8HProfRecord utf8rec=(IUTF8HProfRecord) record;
- return utf8rec.getAsString();
- }
- return null;
- }
- public static String toHex(long v) {
- return "0x"+Long.toHexString(v);
- }
- public static String formatUTF8Data(IUTF8HProfRecord utf8Record) {
-
- try {
- return new String(utf8Record.getCharacters(),"UTF-8");
- } catch (UnsupportedEncodingException e) {
-
- return "Error converting data "+e.toString();
-
- }
-
-
-}
-
- public static String getTagName(IHProfRecord o) {
-
- int tag=o.getTag();
-
- switch(tag) {
-
- case 0x01 : return "UTF8";
- case 0x02: return "LoadClass";
- case 0x04: return "Frame";
- case 0x05: return "Trace";
- case 0x0A: return "Thread started";
- case 0x0B: return "Thread ending";
- case 0x0C: return "HeapDump";
- case 0x0E: return "Settings";
- }
-
- return o.getClass().getName();
- }
- public static String toHex(byte[] bytes) {
- if(bytes==null) return "<no data>";
- return toHex(bytes,0,bytes.length);
- }
- public static String toHex(byte[] bytes, int start, int length) {
-
- if(bytes==null) return "<no data>";
- if(bytes.length<start) return "<bad start>";
-
- StringBuilder builder=new StringBuilder();
- for(int i=0;i<length;i++) {
- int index=i+start;
- if(index>=bytes.length) break;
- builder.append(toHex(bytes[index]));
- builder.append(" ");
- }
- return new String(builder);
- }
-
- private static String toHex(byte b) {
- int value= (int) b & 0xFF;
- int top=value >> 4;
- int bottom= value & 0x0F;
-
- return ""+hexChars.charAt(top)+hexChars.charAt(bottom);
-
- }
- public static String toHex(byte[] bytes, int start, int length, int packet) {
- if(bytes==null) return "<no data>";
- if(bytes.length<start) return "<bad start>";
-
- StringBuilder builder=new StringBuilder();
- int c=packet;
- for(int i=0;i<length;i++) {
- int index=i+start;
- if(index>=bytes.length) break;
- builder.append(toHex(bytes[index]));
- builder.append(" ");
- c--;
- if(c==0) {
- builder.append("\n");
- c=packet;
- }
- }
- return new String(builder);
- }
- public static String toPrintableText(byte[] bytes) {
- if(bytes==null) return "<no data>";
-
- StringBuilder builder=new StringBuilder();
- for(int i=0;i<bytes.length;i++) {
- char c=(char) bytes[i];
- if(Character.isLetterOrDigit(c)) {
- builder.append(c);
-
- }
- else {
- builder.append('.');
- }
- }
- return new String(builder);
- }
-}
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.kato.hprof;
+
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+
+import org.apache.kato.hprof.datalayer.HProfFile;
+import org.apache.kato.hprof.datalayer.IHProfRecord;
+import org.apache.kato.hprof.datalayer.ILoadClassHProfRecord;
+import org.apache.kato.hprof.datalayer.IUTF8HProfRecord;
+
+public class HProfRecordFormatter {
+
+ private static final String hexChars="0123456789ABCDEF";
+ private HProfFile prof=null;
+ HashMap<Long, Integer> utf8s=null;
+
+
+ public HProfRecordFormatter(HProfFile prof, HashMap<Long, Integer> utf8s) {
+ this.prof=prof;
+ this.utf8s=utf8s;
+ }
+ public String formatData(IHProfRecord o) {
+
+ int tag=o.getTag();
+
+ switch(tag) {
+
+ case 0x01 : return formatUTF8Data((IUTF8HProfRecord)o);
+ case 0x02: return formatLoadCLass((ILoadClassHProfRecord)o);
+ case 0x04: return "Frame";
+ case 0x05: return "Trace";
+ case 0x0A: return "Thread Start";
+ case 0x0B: return "Thread End";
+ case 0x0C: return "HeapDump";
+ case 0x0E: return "Settings";
+
+ }
+
+ return "";
+ }
+
+ public String formatLoadCLass(ILoadClassHProfRecord o) {
+
+ long id=o.getClassNameID();
+ long classID=o.getClassObjectID();
+ long serialNo=o.getClassSerialNumber();
+ long stackSerial=o.getStackTraceSerialNumber();
+
+ String className="";
+ if(utf8s.containsKey(id)) {
+ int ref=utf8s.get(id);
+ className=getName(ref);
+ if(className==null) className="";
+ else className="("+className+")";
+ }
+ return "classNameID="+toHex(id)+className+" objectid="+toHex(classID)+" serialNo="+toHex(serialNo)+" stackSerial="+toHex(stackSerial);
+ }
+
+ public String getName(Long id) {
+ if(utf8s.containsKey(id)==false) return null;
+ int ref=utf8s.get(id);
+ return getName(ref);
+ }
+ private String getName(int ref) {
+ IHProfRecord record=prof.getRecord(ref);
+
+ if(record instanceof IUTF8HProfRecord) {
+ IUTF8HProfRecord utf8rec=(IUTF8HProfRecord) record;
+ return utf8rec.getAsString();
+ }
+ return null;
+ }
+ public static String toHex(long v) {
+ return "0x"+Long.toHexString(v);
+ }
+ public static String formatUTF8Data(IUTF8HProfRecord utf8Record) {
+
+ try {
+ return new String(utf8Record.getCharacters(),"UTF-8");
+ } catch (UnsupportedEncodingException e) {
+
+ return "Error converting data "+e.toString();
+
+ }
+
+
+}
+
+ public static String getTagName(IHProfRecord o) {
+
+ int tag=o.getTag();
+
+ switch(tag) {
+
+ case 0x01 : return "UTF8";
+ case 0x02: return "LoadClass";
+ case 0x04: return "Frame";
+ case 0x05: return "Trace";
+ case 0x0A: return "Thread started";
+ case 0x0B: return "Thread ending";
+ case 0x0C: return "HeapDump";
+ case 0x0E: return "Settings";
+ }
+
+ return o.getClass().getName();
+ }
+ public static String toHex(byte[] bytes) {
+ if(bytes==null) return "<no data>";
+ return toHex(bytes,0,bytes.length);
+ }
+ public static String toHex(byte[] bytes, int start, int length) {
+
+ if(bytes==null) return "<no data>";
+ if(bytes.length<start) return "<bad start>";
+
+ StringBuilder builder=new StringBuilder();
+ for(int i=0;i<length;i++) {
+ int index=i+start;
+ if(index>=bytes.length) break;
+ builder.append(toHex(bytes[index]));
+ builder.append(" ");
+ }
+ return new String(builder);
+ }
+
+ private static String toHex(byte b) {
+ int value= (int) b & 0xFF;
+ int top=value >> 4;
+ int bottom= value & 0x0F;
+
+ return ""+hexChars.charAt(top)+hexChars.charAt(bottom);
+
+ }
+ public static String toHex(byte[] bytes, int start, int length, int packet) {
+ if(bytes==null) return "<no data>";
+ if(bytes.length<start) return "<bad start>";
+
+ StringBuilder builder=new StringBuilder();
+ int c=packet;
+ for(int i=0;i<length;i++) {
+ int index=i+start;
+ if(index>=bytes.length) break;
+ builder.append(toHex(bytes[index]));
+ builder.append(" ");
+ c--;
+ if(c==0) {
+ builder.append("\n");
+ c=packet;
+ }
+ }
+ return new String(builder);
+ }
+ public static String toPrintableText(byte[] bytes) {
+ if(bytes==null) return "<no data>";
+
+ StringBuilder builder=new StringBuilder();
+ for(int i=0;i<bytes.length;i++) {
+ char c=(char) bytes[i];
+ if(Character.isLetterOrDigit(c)) {
+ builder.append(c);
+
+ }
+ else {
+ builder.append('.');
+ }
+ }
+ return new String(builder);
+ }
+}
Propchange: incubator/kato/trunk/org.apache.kato/kato.hprof.reader/src/main/java/org/apache/kato/hprof/HProfRecordFormatter.java
------------------------------------------------------------------------------
svn:eol-style = native